akhauriyash/Code-Regression huggingface dataset:
// Ivan Carvalho
// Problem D - Educational Dynamic Programming Contest - AtCoder
// Link : https://atcoder.jp/contests/dp
#include <bits/stdc++.h>
using namespace std;

const int MAXW = 1e5 + 10;

long long knapsack[MAXW];
int N,W;

int main(){

	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);   
    freopen("output.txt", "w", stdout);
    #endif
	cin >> N >> W;

	for(int item = 1;item<=N;item++){
		int w,v;
		cin >> w >> v;
		for(int i = W;i>=w;i--) knapsack[i] = max(knapsack[i-w] + v,knapsack[i]);
	}

	long long best = knapsack[W];
	// for(int i = 0 ; i < N ; i++)
		// cout<<knapsack[i]<<" ";
	// for(int i = 0;i<=W;i++) best = max(best,knapsack[i]);
	cout << best << endl;

	return 0;

}

Measured memory_bytes: 4364
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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;

int main(){
  long double a, b, c;
  cin >> a >> b >> c;

  cout << ( 2 * sqrt(a*b) < c - a - b  ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int a, b, ans;
	char op = 's';
	bool flag = false;

	do {
		switch (op) {
			case '+':
				ans = a + b;
				break;
			case '-':
				ans = a - b;
				break;
			case '*':
				ans = a * b;
				break;
			case '/':
				ans = a / b;
break;
			default:
				flag = true;
				break;
		}

		if (!flag) printf("%d\n", ans);
		flag = false;
		scanf("%d %c %d", &a, &op, &b);
	} while (op != '?');
	return 0;
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  int n;
  cin >> n;
  vector<long long> a(87);
  a.at(0)=2;
  a.at(1)=1;
  for(int i = 2; i<=86; i++){
    a.at(i)=a.at(i-1)+a.at(i-2);
  }
  cout << a.at(n) << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
int a[105],sum,s1;
int main()
{
 int n,ans=100000;
 scanf("%d",&n);
 for(int i=1;i<=n;i++)
 {
  scanf("%d",&a[i]);
  sum+=a[i];
 }
 for(int i=1;i<=n;i++)
 {
  s1+=a[i];
  ans=min(ans,abs(2*s1-sum));
 }
 printf("%d\n",ans);
 return 0;
}

Measured memory_bytes: 128
#16Bmissing
def mn(li):
    if li[0]== "S":
        c[0]=0
    elif li[0]== "H":
        li[0]=1
    elif li[0]== "C":
        li[0]=2
    elif li[0]== "D":
        li[0]=3
    li[1]=int(li[1])
    return li
def nm(nu):
    if nu==0:
        co="S"
    elif nu==1:
        co="H"
    elif nu==2:
        co="C"
    elif nu==3:
        co="D"
#    co+=??? ???+str(li[1])
    return co
T=[]
for i in range(4):
    T.append([])
    for j in range(14):
        T[i].append(0)
N=int(input())
for i in range(N):
    c=[j for j in input().split()]
    c=mn(c)
  #  print(c)
    T[c[0]][c[1]]=1
#print(T)
for i in range(4):
    for j in range(1,14):
        if T[i][j]==0:
            print(nm(i)+" "+str(j))

Measured memory_bytes: 7784
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int INF = 1000000009;
int main()
{
  string s;
  cin >> s;
  ll ans = 0;
  char tmp = s[0];
  vector<int> v(s.size() + 1);
  rep(i,s.size()){
    if(s[i]=='<'){
      v[i + 1] = v[i] + 1;
    }
  }
  reverse(s.begin(),s.end());
  reverse(v.begin(), v.end());
  rep(i,s.size()){
    if(s[i]=='>'){
      v[i + 1] = max(v[i+1],v[i] + 1);
    }
  }
  rep(i,s.size()+1){
    ans += v[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 2820
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define int long long
#define INF 1e18
using namespace std;
template<typename T> void cmin(T &a, T b) { a = min(a, b); }
template<typename T> void cmax(T &a, T b) { a = max(a, b); }

signed main() {
  int a, b, q;
  cin >> a >> b >> q;
  vector<int> j(a + 2), t(b + 2);
  j[0] = -INF, t[0] = -INF;
  j[a + 1] = INF, t[b + 1] = INF;
  loop(i, 1, a + 1) cin >> j[i];
  loop(i, 1, b + 1) cin >> t[i];

  while (q--) {
    int x;
    cin >> x;
    int ans = INF;
    auto J = lower_bound(all(j), x);
    auto T = lower_bound(all(t), x);
    // cout << *(prev(J, 1)) << ' ' << (*J) << endl;
    // cout << *(prev(T, 1)) << ' ' << *T << endl;
    cmin(ans, abs(x - *J) + abs(*J - *prev(T, 1)));
    cmin(ans, abs(x - *J) + abs(*J - *(T)));

    cmin(ans, abs(x - *T) + abs(*T - *prev(J, 1)));
    cmin(ans, abs(x - *T) + abs(*T - *(J)));

    cmin(ans, abs(x - *prev(J, 1)) + abs(*prev(J, 1) - *prev(T, 1)));
    cmin(ans, abs(x - *prev(J, 1)) + abs(*prev(J, 1) - *(T)));

    cmin(ans, abs(x - *prev(T, 1)) + abs(*prev(T, 1) - *prev(J, 1)));
    cmin(ans, abs(x - *prev(T, 1)) + abs(*prev(T, 1) - *(J)));

    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 2944
#include <iostream>
#include <cstdio>
#include <string>

using namespace std;

string s;

int main(void)
{
    int i, res = 0;
    
    cin >> s;
    
    for (i = 1; i < s.size(); ++i)
    {
        if (s[i] != s[i-1])
        {
            ++res;
        }
    }
    
    printf("%d\n", res);
    
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	// cout<<setprecision(10)<<fixed;
	int n;
	ll a[125252];
	cin>>n;
	REP(i, n){
		cin>>a[i];
	}
	ll now=0;
	REP(i, n){
		now=a[i]-now;
	}
	cout<<now<<" ";
	now/=2;
	REP(i, n-1){
		now=a[i]-now;
		cout<<now*2<<" \n"[i==n-2];
	}
	return 0;
}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define int ll

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

  int N,C,K; 
  cin>>N>>C>>K;
  vector<int>T(N);
  for(int i=0;i<N;i++)cin>>T[i];
  vector<pii>x(N);
  for(int i=0;i<N;i++)x[i]={T[i]+K,T[i]};
  sort(rng(x));
  int now=0;
  int ans=0;
  int memo=0;
  for(auto it:x){
    if(now<it.second){
      now=it.first;
      ans++;
      memo=1;
    }
    else{
      memo++;
      if(memo>C)memo=1,ans++,now=it.first;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int main() {
    LL X, Y;
    cin >> X >> Y;
    cout << (llabs(X - Y) <= 1 ? "Brown" : "Alice") << endl;
}


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

namespace {
  ll read() {
    ll x;
    cin >> x;
    return x;
  }

  string reads() {
    string s;
    cin >> s;
    return s;
  }

  template<class T>
  void write(T x) {
    cout << x << ' ';
  }

  void newline() {
    cout << '\n';
  }
}

struct interval {
  int l = 0, r = 0;
};

bool overlap(interval a, interval b) {
  return a.r >= b.l && a.l <= b.r;
}

interval merge(interval a, interval b) {
  /*
  int l = 1e9;
  int r = -1e9;
  for (int i = a.l; i <= a.r; i += 2) {
    for (int j = b.l; j <= b.r; j += 2) {
      l = min(l, i + j - 2 * min(i, j));
      r = max(r, i + j);
    }
  }
  */
  int l;
  if (overlap(a, b)) {
    l = (a.l + b.l) % 2 == 0 ? 0 : 1;
  } else {
    if (a.r > b.l) swap(a, b);
    l = b.l - a.r;
  }
  int r = a.r + b.r;
  return {l, r};
}

int main() {
  int N = read();
  string S = reads();
  vector<vector<int>> G(N);
  for (int i = 0; i < N - 1; i++) {
    int u = read() - 1;
    int v = read() - 1;
    G[u].push_back(v);
    G[v].push_back(u);
  }
  const int INF = 1e9;
  int ans = INF;
  for (int rt = 0; rt < N; rt++) {
    vector<interval> dp(N);
    vector<int> size(N);
    vector<int> dist(N);
    function<void(int, int)> dfs = [&](int u, int p) {
      if (S[u] == '1') size[u] = 1;
      for (int v : G[u]) {
        if (v == p) continue;
        dfs(v, u);
        size[u] += size[v];
        dist[u] += dist[v] + size[v];
        dp[v].l += size[v];
        dp[v].r += size[v];
        dp[u] = merge(dp[u], dp[v]);
      }
    };
    dfs(rt, -1);
    if (dist[rt] % 2 == 0 && dp[rt].l == 0) {
      ans = min(ans, dist[rt] / 2);
    }
  }
  if (ans == INF) ans = -1;
  write(ans);
  newline();
}

struct init {
  init() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
  }
} init_;




Measured memory_bytes: 640
n = 55555
primes = set(range(2, n+1))
for i in range(2, int(n**0.5+1)):
    primes.difference_update(range(i*2, n+1, i))
primes=list(primes)

N = int(input())
ans = []
cnt = 0
for p in primes:
    if p % 5 == 1:
        ans += [p]
        cnt += 1
    if cnt == N:
        break

for p in ans:
    print(p, end=" ")


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

int main() {
  string s;
  long ans=1000;
  cin >> s;
  for(int i=0;i<s.size()-2;i++) {
    long x=(s[i]-'0')*100+(s[i+1]-'0')*10+(s[i+2]-'0');
    ans=min(ans,max(x-753,753-x));
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<cstring>
#include<bitset>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<numeric>
#include<set>
#include<math.h>
#include<unordered_map>
using namespace std;

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

#define rep(i,x) for(int i=0;i<x;i++)
#define re(i,x,y) for(int i=x;i<y;i++)

long long INF=1e9;
const int mod=10007;
#define ll long long

int main(){
    int n;
    cin>>n;
    vector<ll>a(n);
    rep(i,n){
        cin>>a[i];
    }
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    ll ans=1,num1=0;
    for(int i=0;i<n;){
        ll num=1;
        while(a[i]==a[i+1]){
            num++;
            i++;
        }
        if(num>=4&&num1==0){
            ans=(a[i]*a[i]);
            break;
        }else if(num>=4&&num1==1){
            ans*=a[i];
            break;
        }else if(num>=2&&num1<=1){
            ans*=a[i];
            num1++;
            if(num1==2){
                cout<<ans<<endl;
                return 0;
            }
        }
        if(i==n-1){
            ans=0;
        }
        i++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(b);i>(a);--i)
#define eper(i,a,b) for(int i=((int)(a));i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF (1<<30)-1
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

string s;
char sub[] = {'a', 'b', 'c'};
bool d[3];
int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    cin >> s;
    bool flag = true;
    rep(i, 0, 3) {
        rep(j, 0, 3) {
            if (s[i] == sub[j] && !d[j]) {
                d[j] = true;
            }
        }
    }
    rep(i, 0, 3) if (d[i] == false) {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			String s = scanner.next();
			LocalDate date = LocalDate.parse(s, DateTimeFormatter.ofPattern("yyyy/MM/dd"));
			LocalDate date0430 = LocalDate.of(2019, 4, 30);
			System.out.println((date.isAfter(date0430)) ? "TBD" : "Heisei");
		}
	}
}


Measured memory_bytes: 36308
n=int(input())
a=[int(i) for i in input().split()]
m = [[a for i in range(2)] for j in range(n)]
sum=0
count=1
a.sort()
for i in range(n):
 m[i][0]=a[n-i-1]
 sum=sum+a[i]
 m[n-i-1][1]=sum

for i in range(n-1):
  if 2*m[i+1][1]>=m[i][0]:
     count=count+1
  else:
     break

print(count)

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

int ceiling_div(int a, int b){ // ceiling(a/b)= floor((a+b-1)/b)
  return (a+b-1)/b;
}

int main(){
  int N,D,A;
  cin >> N >> D >> A;

  vector<pair<int, int>> data(N);
  for(int i=0; i<N; i++){
    cin >> data.at(i).first >> data.at(i).second;
  }
  sort(data.begin(), data.end());

  vector<int> ngh_id(N); // ngh_id.at(r)= |x_l- x_r|<=2*D を満たすような最小の添字l
  int left= N-1;
  for(int right= N-1; right >= 0; right--){
    while(left > 0 && data.at(right).first- data.at(left-1).first <= 2*D){
      left--;
    }
    ngh_id.at(right)= left;

    if(right==left) left--;
  }

  vector<int> damage_tot(N+1); // damage_tot.at(i)= モンスター[0,i)が受けるダメージの総和
                               // モンスターiが受けるダメージ= damage_tot.at(i)- damage_tot.at(ngh_id.at(i))
  int64_t ans= 0;
  for(int i=0; i<N; i++){
    int hp_edge= data.at(i).second-(damage_tot.at(i)- damage_tot.at(ngh_id.at(i)) );
    if( hp_edge>0 ){
      int n_diff= ceiling_div(hp_edge, A);
      ans+= n_diff;
      damage_tot.at(i+1)= damage_tot.at(i)+ A*n_diff;
    }
    else{
      damage_tot.at(i+1)= damage_tot.at(i);
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 3328
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Queue;

public class Main {

	public static final int BIG_NUM  = 2000000000;
	public static final int MOD  = 1000000007;

	public static void main(String[] args) {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		try {
			String first_input[] = br.readLine().split("\\s+");

			int N = Integer.parseInt(first_input[0]);
			int quantum = Integer.parseInt(first_input[1]);

			Queue<Process> Q = new ArrayDeque<Process>();

			for(int loop = 0; loop < N; loop++){
				String input[] = br.readLine().split("\\s+");
				Q.add(new Process(input[0],Integer.parseInt(input[1])));
			}

			StringBuilder ans = new StringBuilder();
			Process tmp = new Process();

			int current_time = 0;

			while(!Q.isEmpty()){
				tmp = Q.peek();
				Q.poll();

				if(tmp.getTime() <= quantum){
					current_time += tmp.getTime();
					ans.append(tmp.getName()).append(" ").append(Integer.toString(current_time)).append("\n");
				}else{
					current_time += quantum;
					Q.add(new Process(tmp.getName(),tmp.getTime()-quantum));
				}
			}

			System.out.print(ans.toString());

		}catch (IOException e) {
			e.printStackTrace();
		}
	}
}

class Process{

	private String name;
	private int time;

	Process(){
		//Do nothing
	}

	Process(String arg_name,int arg_time){
		name = arg_name;
		time = arg_time;
	}

	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public int getTime() {
		return time;
	}
	public void setTime(int time) {
		this.time = time;
	}
}


Measured memory_bytes: 72672
n, x, m = map(int, input().split())
li = [x]
se = {x}
for i in range(n-1):
    x = x*x%m
    if x==0:
        print(sum(li))
        exit(0)
    if x in se:
        idx = li.index(x)
        break
    li.append(x)
    se.add(x)
else:
    print(sum(li))
    exit(0)
ans = sum(li) + sum(li[idx:])*((n-len(li)) // (len(li)-idx)) + sum(li[idx:idx+(n-len(li)) % (len(li)-idx)])
print(ans)

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

int main()
{
	int n, x;

	while(cin >> n >> x){
		if(!n && !x)
			break;

		int count = 0;

		for(int i=1; i<=n ;++i){
			for(int j=i+1 ; j<=n; ++j){
				for(int k=j+1; k<=n;++k){
					if(i+j+k == x){
						++count;
					}
				}
			}
		}
		cout << count << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <array>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <list>
#include <cmath>
#include <stack>
#include <queue>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using namespace std;

const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll 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;
	}
};

struct combination {
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
} comb(2000005);

mint g(int r, int c) {
	return comb(r + c + 2, r + 1) - 1;
}

int main()
{
	long long a, b, k;
	cin >> a >> b >> k;
	long long minA = min(a, k);
	k -= minA;
	a -= minA;
	if (k > 0)
	{
		long long minB = min(b, k);
		//青木くんのクッキーを食べる
		k -= minB;
		b -= minB;
	}
	cout << a << " " << b;
}


Measured memory_bytes: 31488
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;

int main(){
	int A, B, n=0;
	cin >> A >> B;
	for (int i = 0; i < 2; i++){
		if (A >= B){
			n += A;
			A--;
		}
		else{
			n += B;
			B--;
		}
	}
	cout << n << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int l,r;
  cin>>l>>r;
  if(r-l > 2018) cout<<0<<endl;
  else{
    l%=2019;
    r%=2019;
    if(l>r){cout<<0<<endl;return 0;}
    
    else{
      int ans=BIG;
      repi(i,l,r+1){
	repi(j,i+1,r+1){
	  ans=min(ans,(i*j)%2019);
	}
      }
      cout<<ans<<endl;
    }
  }

  return 0;
}


Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.conv;
import std.range;
import std.array;
import std.algorithm;

void main(){
  auto q=readln.split.to!(int[]),a=q[0],b=q[1];
  if(a*b%2==0)writeln("Even");
  else writeln("Odd");
}  

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<utility>
#include<list>
#include<algorithm>
#include <ctype.h>
#include<deque>
using namespace std;
using ll = long long int;

int n, m;
vector<int> node[51];
vector<bool> visited;
bool check[51][51] = { false };

int dfs(int pos, int num = 0) {
	if (num == n)
		return num;

	if (!visited[pos]) {
		visited[pos] = true;
		num++;
		for (int i = 0; i < node[pos].size(); i++) {
			num = dfs(node[pos][i], num);
			if (num == n)
				return num;
		}

	}
	return num;
}

int main(void) {
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int ai, bi;
		cin >> ai >> bi;
		node[ai].push_back(bi);
		node[bi].push_back(ai);
	}
	int ret = 0;
	for (int i = 1; i < n + 1; i++) {
		int edge = node[i].size();
		int ai = i;
		for (int j = 0; j < edge; j++) {
			int bi = node[i].front();
			if (!check[ai][bi] || !check[bi][ai]) {
				auto itr = find(node[ai].begin(), node[ai].end(), bi);
				node[ai].erase(itr);
				itr = find(node[bi].begin(), node[bi].end(), ai);
				node[bi].erase(itr);

				visited = vector<bool>(51, false);
				if (dfs(i) < n)
					ret++;
				check[ai][bi] = true;
				check[bi][ai] = true;
				node[ai].push_back(bi);
				node[bi].push_back(ai);
			}
		}
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma warning(disable:4996)
#ifdef _MSC_VER
#  define __builtin_popcount __builtin_popcountll
#  define __builtin_popcountll __popcnt
#endif
#define int long long
using namespace std;
using ll = long long;
using ld = long double;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
inline void my_io() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	std::cout << fixed << setprecision(10);
}
signed main() {
	my_io();
	int n;
	cin >> n;
	vector<int>v(n);
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}
	sort(v.begin(), v.end());
	int sum = 0;
	for (int i = 0; i < n - 1; i++) {
		sum += v[i];
	}
	if (sum > v[n - 1]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <vector>
#include <cstring>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <list>

#include <cmath>
#include <algorithm>
#include <cassert>
#include <bitset>
#include <complex>
#include <climits>
#include <functional>
using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> l4;
typedef pair<double, double> dd;
#define mp make_pair
#define pb push_back

#define debug(x) cerr << #x << " = " << x << " "


int main()
{
  ll k, a, b;
  scanf("%lld %lld %lld", &k, &a, &b);
  ll ans = 1;
  if (a + 2 >= b) ans = 1 + k;
  else
    {
      ll taken = min(a-1, k);
      ans += taken;
      k -= taken;
      if (k%2 == 1)
	{
	  --k;
	  ++ans;
	}
      ans += k/2 * (b-a);
    }
  printf("%lld\n", ans);
}


Measured memory_bytes: 256
n=int(input())
l=list(map(int,input().split()))
if(0 in l):
    print(0)
else:
    
    ans = 1
    for i in range(len(l)):
        ans = ans * l[i]
        if(ans > 1000000000000000000 ):
            break
    if(ans > 1000000000000000000):
        print(-1)
    else:
        print(ans)
        


Measured memory_bytes: 87836
N = int(input())
L = [a for a in map(int,input().split())]
K = max(L)
Power = []
for i in range(1,K+1):
  add = 0
  for j in range(len(L)):
    add+= (i - L[j])**2
  Power.append(add)
print(min(Power))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll a7=1000000007;
ll inf=100000000000000000;

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

int main(){
    ll n;cin>>n;
    string s;cin>>s;
    ll ans=0;
    if(n!=1){
        for(ll i=1;i<n;i++){
        if(i<n-1){
            if(s[i]==s[i-1]){
                
            }else{
                ans++;
            }
        }else{
            if(s[i]==s[i-1]){
                ans++;
            }else{
                ans++;
                ans++;
            }
        }
        }
    }else{
        ans=1;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#include "time.h"
#include "unistd.h"
#include "string.h"
#include <math.h>
int ans;
int main(int argc, char* argv[]){
  int a,b;
  scanf("%d %d",&a,&b);
  if (a+b>=10) {
    printf("error");
  }else{
    printf("%d\n",a+b);
  }
}


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

using namespace std;

typedef long long ll;

int main(){
  string s;
  cin>>s;
  ll n=s.size();
  ll b=0;
  string ans="";
  for(int i=n-1;i>=0;i--){
    if(s[i]=='B'){
      b++;
    }else{
      if(b>0){
        b--;
      } else{
        ans.push_back(s[i]);
      }
    }
  }
  reverse(ans.begin(), ans.end());
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
def dfs(graph, visited, edge):
    visited[edge] = True

    for i in range(n):
        if graph[edge][i] == 1 and visited[i] == False:
            dfs(graph, visited, i)

    if sum(visited) == n: return True
    else: return False


n, m = map(int, input().split())
input_list = []
for i in range(m):
    input_list.append(list(map(int, input().split())))
    
cnt = 0
for skip in range(m):
    graph = [[0]*n for _ in range(n)]

    for stage in range(m):
        if stage == skip:
            continue

        i, j = input_list[stage]
        graph[i-1][j-1] = 1
        graph[j-1][i-1] = 1

    visited = [False for _ in range(n)]

    cnt += dfs(graph, visited, 0)        

print(m - cnt)

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

int main()
{
  while(true){
    int n;
    cin >> n;
    if( n == 0 ) break;
    for(int i = 0; i < n; ++i ){
      int pm,pe,pj;
      double meav;
      double av;
      char rank = 'C';
      cin >> pm >> pe >> pj; // math , english, japanese
      meav = ((double)(pm+pe))/2.;
      av = ((double)(pm+pe+pj))/3.;
      if( pm == 100 || pe == 100 || pj == 100 ){
	rank = min( 'A' , rank );
      }
      if( meav >= 90.0 ){
	rank = min( 'A' , rank );
      }
      if( av >= 80.0 ){
	rank = min( 'A', rank );
      }
      if( av >= 70.0 ){
	rank = min( 'B', rank );
      }
      if( av >= 50.0 && ( pm >= 80 || pe >= 80 ) ){
	rank = min( 'B', rank );
      }
      
      cout << rank << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <cctype>
#include <utility>
#include <string>
#include <cmath>
#include <vector>
using namespace std;

#define _gp(l) const auto gcu{getchar##l}; const auto pcu{putchar##l}
#ifdef __linux
_gp(_unlocked);
#else
_gp();
#endif
#define _DEF(r, n, ...) inline r n(__VA_ARGS__) noexcept
#define _T template<typename T>
#define _HT template<typename H,typename... T>
_T _DEF(T,in,int c){T n{};int m{1};while(isspace(c)){c=gcu();}if(c=='-')m=-1,c=gcu();do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
_DEF(int,in,){return in<int>(gcu());}
#define _SCAN(...) _DEF(bool,scan,__VA_ARGS__)
_SCAN(char &c){c=gcu();gcu();return c!=EOF;}
_T _SCAN(T &n){int c{gcu()};return c==EOF?false:(n=in<T>(c),true);}
#define _OUT(...) _DEF(void,out,__VA_ARGS__)
#define _OUTL(...) _DEF(void,outl,__VA_ARGS__)
_OUT(bool b){pcu('0'+b);}
_OUT(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_SCAN(string &s){int c;s="";for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=(char)c;}}
_OUT(string s){for(char c:s)pcu(c);}
#endif
_OUT(const char *s){while(*s)pcu(*s++);}
_T _OUT(T n){static char b[20];char *p{b};T m=n<0?pcu('-'),-1:1;if(!n)*p++='0';else while(n)*p++=(char)(n%10*m+'0'),n/=10;while(p!=b)pcu(*--p);}
_OUTL(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _OUT(vector<T> v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);}
#endif
_HT _SCAN(H &h,T&&... t){return scan(h)&&scan(t...);}
_HT _OUT(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _OUTL(T&&... t){out(move(t)...);outl();}
struct range{int e,b{0},s{1};range(int _b,int _e,int _s):e(_e),b(_b),s(_s){}range(int _b,int _e):e(_e),b(_b){}range(int _e):e(_e){}
	struct it{int v,s;it(int _v,int _s):v(_v),s(_s){}operator int()const{return v;}operator int&(){return v;}int operator*()const{return v;}it& operator++(){v+=s;return *this;}};
	it begin(){return{b, s};}it end(){return{e,s};}};

int main() {
	for (double n; scanf("%lf", &n), n >= 0;) {
		vector<int> a;
		double b = 1.0 / (1 << 7);
		for (int i {}; i < 12; i++, b *= 2) {
			int r = fmod(n * b, 2.0);
			n -= r / b;
			a.push_back(r);
		}
		if (n)
			outl("NA");
		else {
			for (int i: range(12)) {
				if (i == 8)
					out('.');
				out(a[i]);
			}
			outl();
		}
	}
}


Measured memory_bytes: 2632
n = int(input())
mod = 10**9 + 7

max = (10**n)%mod
a = 8**n%mod
b = 9**n%mod
no09 = a
nine_in = (b - a)%mod
zero_in = (b - a)%mod

ans = abs((max - no09 - nine_in - zero_in)%mod)
print(ans)

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

int main() {
	
	int n; cin>>n;
	vector<int> c(n-1),s(n-1),f(n-1);
	for(int i=0; i<n-1; i++){
		cin >>c.at(i)>>s.at(i)>>f.at(i);
	}
	for(int i=0; i<n-1; i++){
		int time{};
		for(int j=i; j<n-1; j++){
			if(time%f.at(j)==0);
			else time = (time/f.at(j)+1)*f.at(j);
			time = max(s.at(j),time);
			time += c.at(j);
		}
		cout << time << '\n';
	}
	cout << 0 << endl;
	
}

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

#define FOR(i,n) for(int i=0;i<n;i++)
#define FORI(i,z,n) for(int i=z;i<n;i++)

using namespace std;

int main () {
    string s1, s2;
    cin >> s1;
    cin.ignore();
    cin >> s2;

    vector<vector<int> > dyn = vector<vector<int> >(s1.length()+1, vector<int>(s2.length()+1, 0));

    FOR(i, s1.length()+1) dyn[i][0] = i;
    FOR(i, s2.length()+1) dyn[0][i] = i;

    FOR(i, s1.length()) {
        FOR(j, s2.length()) {
            int x = i+1;
            int y = j+1;

            int m = s1.length() + s2.length();
            if (s1[i] == s2[j]) {
                // Same last letter
                m = min(m, dyn[x-1][y-1]);
            }

            // Add/sub letters
            m = min(m, dyn[x-1][y] + 1);
            m = min(m, dyn[x][y-1] + 1);

            // Substitute letters
            m = min(m, dyn[x-1][y-1] + 1);

            dyn[x][y] = m;
        }
    }

    cout << dyn[s1.length()][s2.length()] << endl;
}



Measured memory_bytes: 6848
#include<stdio.h>
#include<stdlib.h>
 
struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
}Node1;
 
typedef struct node *Node;
 
Node root;
 
Node treeSearch(Node u, int k){
  while(u != NULL && k != u->key){
      if(k < u->key){
    u = u->left;
      }else{ 
    u = u->right;
      }
    }
  return u;
}
 
void treeDelete(Node z){
  Node y; 
  Node x;
}
 
void insert(int k){
  Node y = NULL;
  Node x = root;
  Node z;
 
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NULL;
  z->right = NULL;
 
  while(x != NULL){
    y = x;
    if(z->key < x->key){
      x = x->left;
    }else{
      x = x->right;
    }
    z->parent = y;
  }
  if(y == NULL){
    root = z;
  }else if(z->key < y->key){
    y->left = z;
  }else{
    y->right = z; 
  }
}
 
void inorder(Node u){
 if(u != NULL){
     inorder(u->left);
     printf(" %d",u->key);
     inorder(u->right);
   }
}
 
void preorder(Node u){
 if(u != NULL){   
      printf(" %d",u->key);
      preorder(u->left);
      preorder(u->right);
    }
}
 
int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);
 
  for (i = 0;i < n;i++){
    scanf("%s", com);
    if (com[0] == 'f'){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if (t != NULL) printf("yes\n");
      else printf("no\n");
    } else if (com[0] == 'i'){
      scanf("%d", &x);
      insert(x);
    } else if (com[0] == 'p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if (com[0] == 'd'){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }
  return 0;
}

Measured memory_bytes: 19364
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF (1LL<<57)
#define MV 200001
#define LMV 21
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define emp emplace
#define whoami(x) cerr<<#x<<" "<<x<<"\n";
#define mp make_pair
#define ins insert
#define sz size

void FLASH() {ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}
void SETF() {cout.ios_base::setf(ios_base::fixed);}
void UNSETF() {cout.ios_base::unsetf(ios_base::fixed);}

typedef long long ll;
typedef long double ld;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<PII, int> PPII;
typedef pair<PLL, ll> PPLL;
typedef map<int, int> MII;
typedef map<ll, ll> MLL;
typedef map<PII, int> MPII;
typedef map<PLL, ll> MPLL;
typedef set<int> SI;
typedef set<ll> SL;

int ar[MV];
ll arr[MV];

void solve(int T)
{
	int a,b;
	cin>>a>>b;
	cout<<max(0, a-2*b)<<"\n";
	return;
}

int main(void)
{
	FLASH();
	int T;
	T = 1;

/*#ifndef ONLINE_JUDGE
	time_t time_t1, time_t2;
	time_t1 = clock();
#endif*/

	while(T--)
	solve(T);

/*#ifndef ONLINE_JUDGE
	time_t2 = clock();
	SETF();
	cout<<"Time taken: "<<setprecision(7)<<(time_t2 - time_t1)/(double)CLOCKS_PER_SEC<<"\n";
	UNSETF();
#endif*/

	return 0;
}

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

namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
    string str1=Console.ReadLine();
    string str2=Console.ReadLine();
    string str3=Console.ReadLine();
      
      Console.WriteLine(str1.Substring(0,1)+str2.Substring(1,1)+str3.Substring(2,1));
    }
    
  }

}

Measured memory_bytes: 25784
#b
n = int(input())
a = list (map(int, input().split()))
a = [i-1 for i in a]
b = list (map(int, input().split()))
c = list (map(int, input().split()))

ans = 0

# print(a,b,c)
for i,v in enumerate(a):
    ans += b[v]
    if i != n-1:
        if a[i]+1 == a[i+1] :
            ans += c[v]

print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<P>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T>inline bool chmax(T &a, T b){if (a < b){a = b;return 1;}return 0;}
template <typename T>inline bool chmin(T &a, T b){if (a > b){a = b;return 1;}return 0;}

int main()
{
    string s;
    cin >> s;
    ll n = s.size();
    bool yes = true;
    
    rep(i, n)
    {
        if (i % 2 == 0)
        {
            if (!(s[i] == 'R' || s[i] == 'U' || s[i] == 'D'))
                yes = false;
        }
        if (i % 2 == 1)
        {
            if (!(s[i] == 'L' || s[i] == 'U' || s[i] == 'D'))
                yes = false;
        }
    }

    if (yes)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
int N_MAX=100001;
int main()
{
  int n,m,a,b,i,j;
  int p[N_MAX];
  vector<int> v[N_MAX];
  queue<int> q;
  cin >> n >> m;
  for(i=0;i<m;i++){
    cin >> a >> b;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  fill(p+1,p+n+1,0);
  p[1]=1;
  q.push(1);
  while(!q.empty()){
    i=q.front(); q.pop();
    for(j=0;j<v[i].size();j++)
      if(p[v[i][j]]==0){
        p[v[i][j]]=i;
        q.push(v[i][j]);
      }
  }
  cout << "Yes" << endl;
  for(i=2;i<=n;i++)
    cout << p[i] << endl;
  return 0;
}

Measured memory_bytes: 9996
#include<bits/stdc++.h>
using namespace std;
const int maxn=3e5+10,mod=1e9+7;
void plusle(int &a,int b){a+=b;if(a>=mod)a-=mod; return;}
void minun(int &a,int b){a-=b; if(a<0)a+=mod; return;}
int add(int a,int b) {a+=b;return a>=mod?a-mod:a;}
int sub(int a,int b) {a-=b;return a<0?a+mod:a;}
int mul(int a,int b) {return (int)((long long)a*b%mod);}
int power(int a,int b) {int res=1;while (b>0) {if (b&1) {res=mul(res,a);}a=mul(a,a);b>>=1;}return res;}
int n,a[maxn],b[maxn],c[maxn],k;
int ans;

int main(){
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            if(a[i]>a[j]){
                b[i]++;
            }
        }
    }
    for(int i=1;i<=n;i++){
        plusle(ans,mul(k,b[i]));
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            if(a[i]>a[j]){
                c[i]++;
            }
        }
    }
    k=((1LL*(k)*(k-1))/2)%mod;
    for(int i=1;i<=n;i++){
        plusle(ans,mul(k,c[i]));
    }
    printf("%d\n",ans);
}
/*
    Good Luck
        -Lucina
*/


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N;
  string r;
  cin >> N;
  cout << 0 << endl << flush;
  cin >> r;
  if (r == "Vacant")
    return 0;
  ll left = 0;
  ll right = N;

  while (abs(right - left) > 1) {
    ll mid = left + (right - left) / 2;
    string r2;
    cout << mid << endl << flush;
    cin >> r2;
    if (r2 == "Vacant")
      return 0;
    else if ((mid % 2 == 1 && r2 != r) || (mid % 2 == 0 && r2 == r))
      left = mid;
    else
      right = mid;
  }

  return 0;
}


Measured memory_bytes: 852
from heapq import heappush, heappop

N, M = map(int, input().split())
A = [int(i) for i in input().split()]

c = []
for a in A :
    heappush(c, -a)
    
for _ in range(M) :
    b = heappop(c)
    heappush(c, (b + 1) // 2)
    
print(-sum(c))

Measured memory_bytes: 64792
object Main {
  def main(args: Array[String]): Unit = {
    solve
  }

  def solve(): Unit = {
    val sc = new java.util.Scanner(System.in)
    val n = sc.nextInt
    val a = new Array[Int](n)
    for (i <- 0 until n) {
      a(i) = sc.nextInt
    }

    val colors = scala.collection.mutable.Set[String]()
    var over3200 = 0
    for (i <- 0 until n) {
      if (a(i) <= 399) colors.add("grey")
      else if (a(i) <= 799) colors.add("brown")
      else if (a(i) <= 1199) colors.add("green")
      else if (a(i) <= 1599) colors.add("light_blue")
      else if (a(i) <= 1999) colors.add("blue")
      else if (a(i) <= 2399) colors.add("yellow")
      else if (a(i) <= 2799) colors.add("orange")
      else if (a(i) <= 3199) colors.add("red")
      else over3200 += 1
    }

    val min = if (colors.size != 0) colors.size else 1
    val max = colors.size + over3200
    println(min + " " + max)

  }
}


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

using namespace std;

const int N = 1e4;

int cnt[N + 69];

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  for (int x = 1; x <= N; x++) {
    for (int y = 1; y <= N; y++) {
      for (int z = 1; z <= N; z++) {
        long long sum = (x * x) + (y * y) + (z * z) + (x * y) + (y * z) + (z * x);
        if (sum > N) {
          break;
        }
        ++cnt[sum];
      }
    }
  }
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cout << cnt[i] << '\n';
  }
}


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

int indexOf(int Num, int array[],int startIndex, int endIndex){
  	for(int i = startIndex;i < endIndex;i++)
    	if(array[i] == Num)
          return i;
	return -1;
}

int main(){
  int N;
  cin >> N;
  int a[N];
  
  for(int i = 0; i <N; i++)
    cin >> a[i];
  
  
  int currentPosition = indexOf(1, a, 0, N);
  if(currentPosition == -1){
    cout << -1;
    return 0;
  }
  
  int count = 2;
  
  while(true){
  	currentPosition = indexOf(count, a, currentPosition, N);
    if(currentPosition == -1){
        cout << N - count + 1;
        return 0;      
    }
    else{
    ++count; 
    }
  }
}
          

          
          

Measured memory_bytes: 1024
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <numeric>
#include <queue>
#include <string>
#include <vector>

using namespace std;

int main ()
{
    int N;
    cin >> N;
    vector<int> A (N);
    for (int i = 1; i < N; i++) {
        cin >> A[i];
    }
    vector<int> boss (N);
    for (int i = 1; i < N; i++) {
        boss[A[i] - 1]++;
    }
    for (int i = 0; i < N; i++) {
        cout << boss[i] << "\n";
    }
}


Measured memory_bytes: 4844
#include <iostream>

int gcd(int a,int b) {
	if (a == 0 || b == 0) {
		return 0;
	}
	int r;
	while ((r = a%b) != 0) {
		a = b;
		b = r;
	}
	return b;
}

int main(void) {
	int a;
	int b;
	while (std::cin >> a >> b) {
		std::cout << gcd(a,b) << std::endl;
	}
	return 0;
}

Measured memory_bytes: 3052
#include <iostream>
#include <stdio.h>

using namespace std;

int main() {
	int a, b, sum, min, mul, most;
	cin >> a >> b;
	sum = a+b;
	min = a-b;
	mul = a*b;
	if (sum >= min && sum >= mul) most = sum;
	if (min >= sum && min >= mul) most = min;
	if (mul >= sum && mul >= min) most = mul;
	cout << most << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
  int n;
  cin>>n;
  int j = 0;
  for(int i = 0;i < n;i++){
    int l,r;
    cin>>l>>r;
    j +=r-l + 1;
  }
  cout<<j<<endl;
  return 0;
  }


Measured memory_bytes: 3160
import java.util.*;	
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long sum = 1;
		for(long i = 1;i <= n;i++) {
			sum = (sum*i)%(1000000000+7);
		}
		System.out.println(sum);
	}

}


Measured memory_bytes: 21844
#include<stdio.h>
#include<iostream>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cstring>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<iterator>
//#include<math.h>

using namespace std;
#define int long long
/*                      */    //#undef int
#define INF 1000000009
#define INFL 1000000000000000018ll
#define mod 1000000007
#define pb push_back
#define fi first
#define se second
#define mk(a, b) make_pair(a, b)
typedef pair<int, int> PA;
typedef priority_queue<int> PQ;
typedef priority_queue<PA, vector<PA>, greater<PA> >PQG;

int n, k;

signed main()
{
    cin >> n >> k;
    if(k == 0){
        cout << n * n << endl;
        return 0;
    }
    int ans = 0;
    for(int i = k + 1; i <= n; i++){
        ans += (n / i) * (i - k);
        if((n % i) >= k){
            ans += (n % i) - (k - 1);
        }
    }
    cout << ans << endl;

    return 0;
}
/*


*/


Measured memory_bytes: 256
import java.util.Scanner;

  public class Main {
    public static void main(String[] args) {

    // 標準入力からデータを読み込む準備
    Scanner sc = new Scanner(System.in);

    // 2つの文字の固まりをそれぞれ整数値と想定して読み込む
    int a = sc.nextInt();
    int b = sc.nextInt();
    int area = a*b;
    int length = (a+b)*2;

    System.out.println(area + " " + length);
    sc.close();
}
}


Measured memory_bytes: 26416
h, w, k = gets.split.map(&:to_i)

count = 0

result = h.times.map {
  row = gets.chomp

  next nil unless row.include?('#')

  row.scan(/\.*#\.*/).flat_map { |chunk|
    count += 1
    [count.to_s] * chunk.size
  }.join(' ')
}

result.each_with_index do |row, index|
  next unless row.nil?

  result[index] = result[0..index].reverse_each.find { |row| row } ||
                  result[index..-1].find { |row| row }
end

puts result.join("\n")


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

using namespace std;

const int MAXN = 1e5;

int freq[MAXN + 2];

int main() {
    //ifstream cin(".in");
    //ofstream cout(".out");
    int n, num, ans = 0;
    cin >> n;
    for (int i = 0; i < n; ++i) {
      cin >> num;
      ++freq[num];
    }
    ans = freq[0] + freq[1];
    for (int i = 1; i <= MAXN; ++i)
      ans = max(ans, freq[i] + freq[i - 1] + freq[i + 1]);
    cout << ans;
    return 0;
}


Measured memory_bytes: 640