akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define mod 1000000007
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { cerr << (itr) << " "; }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

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

  vector<bool> dp(1000010, 0);

  int n;
  cin >> n;
  vector<int> a(n);
  map<int, int> mp;
  repr(i, n, 0) {
    cin >> a[i];
    mp[a[i]] += 1;
  }

  int max_val = *max_element(a.begin(), a.end());

  sorti(a);

  // エラトステネスの篩
  for (int i = 0; i < n; ++i) {
    int val = a[i];
    if (!dp[val]) {
      for (int j = val * 2; j <= max_val; j += val) {
        dp[j] = true;
      }
    }
  }

  int ans = 0;
  for (int i = 0; i < n; ++i) {
    int val = a[i];
    if (!dp[val] && mp[val] == 1) ans += 1;
  }

  cout << ans << endl;
}

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

using ll = long long;
#define int long long

#define LOG(variable) cout << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cout << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, n, r) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
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 { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= 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 { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
int in() {int x; cin>>x; return x;}
string stin() {string s; cin>>s; return s;}
/***** MAIN *****/
signed main() {
  int n = in();
  string s = to_string(n);
  REP(i,s.size()) {
    if(s[i] == '7') {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No";
  cout << "\n";
  return 0;
}
/***** MAIN *****/


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

using namespace std;

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

using LL = long long;

//------------------------------------------
//------------------------------------------

constexpr LL mod = 1e9 + 7;

int main() {

    string S;
    cin >> S;

    int N = 13;

    string T = S;
    reverse(T.begin(), T.end());

    vector<LL> dp(N, 0);
    dp[0] = 1;

    LL base = 1;
    for (int i = 0; i < T.size(); i++) {
        vector<LL> next(N, 0);
        if (T[i] == '?') {
            for (int k = 0; k <= 9; k++) {
                LL d = (k * base);
                for (int j = 0; j < N; j++) {
                    next[(d + j) % N] += dp[j];
                    next[(d + j) % N] %= mod;
                }
            }
        } else {
            for (int j = 0; j < N; j++) {
                LL d = ((T[i] - '0') * base);
                next[(d + j) % N] += dp[j];
                next[(d + j) % N] %= mod;
            }
        }
        dp = next;
        base *= 10;
        base %= 13;
    }

    cout << dp[5] << endl;

}
























Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std; 
#define ll long long int
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define INF LLONG_MAX
#define PI acos(-1)
const ll MOD = 1e9 + 7;
#define x first
#define y second
#define all(x) x.begin(),x.end()
#define mem(a,b) memset(a,b,sizeof(a))
#define rep(c,a,b) for(ll c=a;c<b;c++)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define min_heap priority_queue<pll,vector<pll>,greater<pll> >
ll dx4[]={-1,1,0,0};
ll dy4[]={0,0,-1,1};
ll dx8[]={-1,-1,-1,0,1,1,1,0};
ll dy8[]={-1,0,1,1,1,0,-1,-1};
bool isvalid(ll x,ll y,ll n,ll m)
{
	return (x>=0 and y>=0 and x<n and y<m);
}
bool isprime[1000];
vector<ll> prime;
void sievetoprime(ll n)
{
	mem(isprime,true);
	for(ll p=2;p*p<=n;p++)
	{
		if(isprime[p]==true)
		{
			for(ll i=p*p;i<=n;i+=p)
				isprime[i]=false;
		}
	}
}
ll ok[100005]={0};
ll wc[100005]={0};
void solve()
{	
	ll n,m;
	cin>>n>>m;
	ll ac=0;
	ll a;
	string s;
	
	for(ll i=0;i<m;i++)
	{
		cin>>a>>s;
		if(s=="AC" and ok[a]==0)
		{
			ok[a]=1;
			ac++;
		}
		if(s=="WA" and ok[a]==0)
		{	
			wc[a]++;
		}
	}
	ll cnt=0;
	for(ll i=0;i<=100005;i++)
	{
		if(ok[i])
		{
			cnt+=wc[i];
		}
	}
	cout<<ac<<" "<<cnt;
}	
int main()
{
	IOS
	ll t;
	t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 1792
s = input()
max_plus = len(s)-1
plus = [reversed(bin(i)[2:]) for i in range(2**max_plus)]
value_sum = 0

for i in plus:
    value = 0
    prov_s = s
    end_plus = 0
    for index, j in enumerate(i):
        if j == "1":
            cut_index = (1+index)*(-1)+end_plus
            value += int(prov_s[cut_index:])
            prov_s = prov_s[0:cut_index]
            end_plus += -1 * cut_index
    value_sum += value + (int(prov_s) if prov_s else 0)
print(value_sum)

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;


#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    ll n,m,waans=0,acans=0;
    cin>>n>>m;
    vector<int> wa(n+1);
    vector<bool> ac(n+1);
    for (int i = 0; i < m; i++)
    {
        int p;
        string s;
        cin>>p>>s;
        if(s=="WA")
        {
            wa[p]++;
        }
        else
        {
            if(ac[p]==false)
            {
                ac[p]=true;
                waans+=wa[p];
                acans++;
            }
        }
    }
    cout<<acans<<" "<<waans<<endl;
    
    return 0;
}

Measured memory_bytes: 640
a, b = (int(i) for i in input().split())

if a == b: 
  print('Draw')
  exit()
if b-a > 0:
  if a != 1:
    print('Bob')
  else:
    print('Alice')
else:
  if b == 1:
    print('Bob')
  else:
    print('Alice')


Measured memory_bytes: 2940
/* template.cpp [[[ */
#include <bits/stdc++.h>
using namespace std;
#define get_macro(a, b, c, d, name, ...) name
#define rep(...) get_macro(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep(...) get_macro(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rep1(n) rep2(i_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, b) rep4(i, a, b, 1)
#define rep4(i, a, b, s) for (ll i = (a); i < (ll)(b); i += (ll)s)
#define rrep1(n) rrep2(i_, n)
#define rrep2(i, n) rrep3(i, 0, n)
#define rrep3(i, a, b) rrep4(i, a, b, 1)
#define rrep4(i, a, b, s) for (ll i = (ll)(b) - 1; i >= (ll)(a); i -= (ll)s)
#define each(x, c) for (auto &&x : c)
#define fs first
#define sc second
#define all(c) begin(c), end(c)
using ui = unsigned;
using ll = long long;
using ul = unsigned long long;
using ld = long double;
const int inf = 1e9 + 10;
const ll inf_ll = 1e18 + 10;
const ll mod = 1e9 + 7;
const ll mod9 = 1e9 + 9;
const int dx[]{-1, 0, 1, 0, -1, 1, 1, -1};
const int dy[]{0, -1, 0, 1, -1, -1, 1, 1};
template<class T, class U> void chmin(T &x, const U &y){ x = min<T>(x, y); }
template<class T, class U> void chmax(T &x, const U &y){ x = max<T>(x, y); }
struct prepare_ { prepare_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } prepare__;
/* ]]] */

ll n, m, k;
ll a[20000];
ll dp[20010];

int main(){
  cin >> n >> m >> k;
  rep(i, n) cin >> a[i];
  
  fill_n(dp, 20010, inf_ll);
  dp[0] = 0;
  rep(i, n){
    ll s = 0, mn = a[i], mx = a[i];
    rep(j, i, min(i + m, n)){
      s += a[j];
      chmin(mn, a[j]);
      chmax(mx, a[j]);
      ll c = k + (j - i + 1) * (mx - mn);
      chmin(dp[j + 1], dp[i] + c);
    }
  }
  
  cout << dp[n] << endl;
}

Measured memory_bytes: 3496
//                        Bismillahir Rahmanir Rahim
//ALGO:
#include<bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define FILL(a, x) memset(a, x, sizeof(a))
#define ll long long
#define Fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define INF ll_MAX
#define MX 1000010
#define mod  998244353
#define dout if(debug) cout
#define FR(i, n) for(ll i=0; i<n; i++)
#define FOR(i, n) for(ll i=1; i<=n; i++)
const double Pi=acos(-1);
using namespace std;
ll debug=01;
void solve(){
    ll n, x, m;
    cin>>n>>x>>m;
    ll a[m+10]={0}, f[m+10]={0};
    a[1]=x;
    ll sum=x, len, start;
    f[x]=1;
    for(ll i=2;i<=n;i++){
        x=(x*x)%m;
        a[i]=x;
        if(f[x]){
            len=i-f[x];
            start=f[x];
            goto circle;
        }
        sum+=x;
        f[x]=i;
    }
    cout<<sum; return;
    circle: ;
    sum=0;
    for(ll i=1; i<start; i++)sum+=a[i];
    n-=(start-1);
    ll y=n/len;
    for(ll j=1; j<=len; j++){
        sum+=a[start+j-1]*y;
    }
    for(ll j=1; j<=(n%len); j++) sum+=a[start+j-1];
    cout<<sum;
}
int main() {
    Fast
    ll tst=1;
    //cin>>tst;
    for(ll T=1; T<=tst; T++){
        //cout<<"Case "<<T<<": ";
        solve();
    }
}


Measured memory_bytes: 5140
N = input()
len = len(N)
num = 0
cnt = 1
for i in range(0, len, 1):
    cnt = 1
    for j in range(i + 1, len, 1):
        if (N[i] != N[j]):
            break
        else:
            cnt += 1
    num = max(num, cnt)
print("Yes" if 3 <= num else "No")


Measured memory_bytes: 2940
parseInt(x)=parse(Int,x)
parseMap(x::Array{SubString{String},1})=map(parseInt,x)
function bsearch(a::Array{Int,1},x::Int);l,r=1,length(a);while l<=r;m=l+div(r-l,2);if a[m]<x;l=m+1;else;r=m-1;end;end;return(l-1);end

function main()
	a,b,t = readline() |> split |> parseMap
	println(div(t,a)*b)
end
main()


Measured memory_bytes: 167492
'use strict';
(function(stdin) {

    var inputs = stdin.toString().trim().split(' ');

    var a = Number(inputs[0]);
    var b = Number(inputs[1]);
    if (a < b) {
        console.log('a < b');
    } else if (a > b) {
        console.log('a > b');
    } else {
        console.log('a == b');
    }

}(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 15524
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=(0);i<(n);i++)
#define qwq(x) cerr<<"# "<<#x<<" = "<<x<<endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef unsigned long long u64;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

template<class T> inline void read(T &x){
	int f=0;x=0;char ch=getchar();
	for(;!isdigit(ch);ch=getchar())f|=(ch=='-');
	for(;isdigit(ch);ch=getchar())x=x*10+ch-'0';
	if(f)x=-x;
}

const int T=18,S=(2<<T)+5,N=105,mod=998244353;
int f[S],g[N][N],h[N],a[N],n;
unordered_map<u64,int> F;
char s[N];

int fix(int x){
	return x>=mod?x-mod:x;
}

int solve(u64 s,int n){
	if(n<=1)return (s&1)+1;
	if(n<=T&&f[s|(1<<n)])return f[s|(1<<n)];
	if(n>T&&F.count(s|(1ll<<n)))return F[s|(1ll<<n)];	
	int res=solve(s>>1,n-1);
	if(s&1)res=fix(res+res);
	int suf[n+1];
	fill(suf,suf+n+1,-1);
	rep(len,1,n/2){
		u64 st=(1ll<<len)-1,las=-1; int ans=0;
		for(int p=0,k=1;p+len<=n;p+=len,k++){
			st&=s>>p;
			if(k>=2){
				if(st!=las)ans=solve(st,len);
				if(suf[p+len]==-1)
					suf[p+len]=solve(s>>(p+len),n-p-len);
				las=st,res=(res+(ll)ans*suf[p+len])%mod;
			}
		}
	}
	if(n<=T)f[s|(1<<n)]=res;
	else F[s|(1ll<<n)]=res;
	return res;
}

int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	rep(i,1,n)a[i]=s[i]-'0',g[i][i]=a[i]+1;
	rep(len,1,n/2)
		rep(l,1,n-2*len+1){
			u64 full=(1ll<<len)-1,st=(1ll<<len)-1,las=-1; int ans=0;
			for(int p=l,k=1;p+len<=n+1;p+=len,k++){
				REP(i,len)st&=full-(1ll<<i)+((1ll*a[p+i])<<i);
				if(k>=2){
					if(st!=las)ans=solve(st,len);
					las=st,g[l][p+len-1]=fix(g[l][p+len-1]+ans);
				}
			}
		}
	h[0]=1;
	rep(i,1,n)rep(j,0,i-1)
		h[i]=(h[i]+(ll)h[j]*g[j+1][i])%mod;
	cout<<h[n]<<endl;
	return 0;
}

Measured memory_bytes: 2944
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include<iomanip>

int main() {
	int N;
	std::cin >> N;
	
	std::vector<int> p(N);

	for (auto& _p : p) {
		std::cin >> _p;
	}
	
	bool flag = true;

	int num = 0;

	for (int i = 0; i < N; i++) {
		if (p[i] == i + 1) {

		}
		else if (p[p[i] - 1] == i + 1) {
			num++;
		}
		else {
			flag = false;
		}
	}

	if (( num ==0 || num == 2) && flag == true) {
		std::cout << "YES" << std::endl;
	}
	else {
		std::cout << "NO" << std::endl;
	}

	
	return 0;
}

Measured memory_bytes: 256
def is_b_larger_than_a(a, b):
  n = min(len(a), len(b))
  for i in range(n):
    if ord(a[i]) > ord(b[i]):
      return False
    if ord(a[i]) < ord(b[i]):
      return True
  return len(a) < len(b)

s = sorted(input(), reverse=False)
t = sorted(input(), reverse=True)

if is_b_larger_than_a(s, t):
  print("Yes")
else:
  print("No")


Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<string>
#include<set>

const long long int MOD=1e9+7;

using namespace std;

int main(){
    int n, b[109];
    cin >> n;
    for(int i=0;i<n-1;i++){
        cin >> b[i];
    }
    b[n-1] =100009;
    long long int sm=0;
    sm+=b[0];
    for(int i=1;i<n;i++){
        sm+=min(b[i-1], b[i]);
    }
    cout << sm << endl;
}



Measured memory_bytes: 256
lis = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
n = input()
for s in lis:
    if s in n:
        pass
    else:
        ans = s
        break
    if s == "z":
        ans = "None"
print(ans)

Measured memory_bytes: 3188
from heapq import*
i=input
for _ in'_'*int(i()):
 n,s,x,*y=int(i()),0,[]
 for _ in'_'*n:
  k,l,r=map(int,i().split())
  if l>r:x+=(k,l,r),
  else:y+=(n-k,r,l),
 for x in x,y:
  x.sort();n,*h=len(x),
  while n:
   n-=1
   while x and x[-1][0]>n:k,l,r=x.pop();heappush(h,(r-l,l,r))
   if h:s+=heappop(h)[1]
  for*_,r in x+h:s+=r
 print(s)

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

int main()
{
  int n;
  cin>>n;
  vector<int> ans(26,1e9);
  for(int i=0;i<n;i++)
  {
    string s;
    cin>>s;
    vector<int> v(26,0);
    for(auto i:s)
      v[i-'a']++;
    for(int i=0;i<26;i++)
      ans[i]=min(ans[i],v[i]);
  }
  for(int i=0;i<26;i++)
  {
    while(ans[i]--)
      cout<<char('a'+i);
  }
    
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(ll I = int((B)-1); I >= int(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int N;
	cin >> N;
	vector<string> s(N);
	FOR(i,0,N)cin >> s[i];
	string t;
	cin >> t;
	int f=0,b=0,n=0;
	for(string x:s){
		bool h = false;
		string aa,bb,cc;
		FOR(j,0,x.size()){
			if(x[j]=='?'){
				h = true;
			}
			aa += x[j];
			bb += (x[j]=='?' ? 'a':x[j]);
			cc += (x[j]=='?' ? 'z':x[j]);
		}
		if(not h){
			if(t>aa){
				f++;
			}else if(t<aa){
				b++;
			}else{
				n++;
			}
		}else{
			if(t<bb&&t<cc){
				b++;
			}else if(t>bb&&t>cc){
				f++;
			}else{
				n++;
			}
		}
	}
	cout << f+1;
	FOR(i,0,n){
		cout << " " << f+2+i;
	}
	cout << endl;
}

Measured memory_bytes: 896
#include <iostream>
using namespace std;
typedef long long ll;

int main() {
	ll a,b,n;cin >>a>>b>>n;
	ll x = (a*n)/b - a*(n/b);
	ll tmp = (n/b)*b-1;
	ll y = (a*tmp)/b - a*(tmp/b);
	ll out = max(x,y);
	cout << max(0LL,out) << endl;
	return 0;
}

Measured memory_bytes: 3576
#include<bits/stdc++.h>
typedef long long ll;
#define pii pair<int,int>
#define ff first
#define ss second
using namespace std;
void fast()
{
ios::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
}
int main()
{
    int a,b,c,d,e;
    for(int i=1;i<=5;i++)
    {
        cin>>a;
        if(a==0)
        {
            cout<<i<<endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 3572
#include <stdio.h>

int main() {
  int a, b, ans = 0;
  scanf("%d %d", &a, &b);
  for (int i = 0; i < 2; i++) {
    if (a > b) {
      ans += a;
      a -= 1;
    }else {
      ans += b;
      b -= 1;
    }
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define mp make_pair
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }
template<typename T> inline T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }




int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    /*
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    */
    
    int a, b;
    cin >> a >> b;
    cout << max(0, a - 2 * b) << endl;
    
}


Measured memory_bytes: 892
import java.util.Scanner;

class Main {
 
    public static void main(String[] args) {
 
        Scanner sc = null;
        try {
            sc = new Scanner(System.in);
 
            String s = null;
            while (sc.hasNext()) {
                s = sc.nextLine();
                
                s = s.replaceAll("apple", "XXXXX");
                s = s.replaceAll("peach", "apple");
                s = s.replaceAll("XXXXX", "peach");
 
                System.out.println(s);
            }
        } finally {
            sc.close();
        }
    }
}

Measured memory_bytes: 25988
from sys import stdin

N, Y = [int(x) for x in stdin.readline().rstrip().split()]

# 最大の枚数を求める
z = Y // 1000
if z < N:
  print('-1 -1 -1')
  exit()
  
# 最小の枚数を求める
x = Y // 10000
y = (Y - x * 10000) // 5000
z = (Y - x * 10000 - y * 5000) // 1000
if x + y + z > N:
  print('-1 -1 -1')
  exit()
  
obj = N - (x + y + z)
for a in range(x+1):
  for b in range(x-a+1):
    for c in range(y+1):
      if(a + 9*b + 4*c == obj):
        print('{} {} {}'.format(str(x-a-b), str(y+2*a-c), str(z+10*b+5*c)))
        exit()

print('-1 -1 -1')

Measured memory_bytes: 3064
#include <iostream>                                  
using namespace std;                                 
                                                     
int main(void) {                                     
  int S;                                             
  cin >> S;                                          
  int h = S/3600;                                    
  int m = S%3600/60;                                 
  int s = S%3600%60;                                 
  cout << h << ":" << m << ":" << s << endl;         
  return 0;                                          
}                                                    
                             

Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<pair<int,int>> xy;
    rep(i,n){
            int x,y;
            cin >> x >> y;
            xy.emplace_back(x,y);
    }
    vector<vector<double>> list(n,vector<double>(n));
    double ans=0;
    rep(i,n){
        for(int j=i+1;j<n;j++){
            list[i][j]=sqrt(pow((xy[i].first-xy[j].first),2.0)+pow(xy[i].second-xy[j].second,2.0));
            ans+=list[i][j];          
        }
    }
    ans=ans*2/n;
    printf("%lf\n",ans);
}

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

using namespace std;

#define endl '\n'
#define ll long long

const ll mod = 1e9 + 7;
const double pi = 3.1415926535897932384626433832795028841971693993751058209749445923078;

//iostream::sync_with_stdio(false);

const int maxn = 1e4 + 5;

int main()
{
	string s;
	cin >> s;
	if (s == "ABC")
	{
		cout << "ARC" << endl;
	}
	else
	{
		cout << "ABC" << endl;
	}
	return 0;
}




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

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

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int n, m;
  cin >> n >> m;

  const int INF = 1 << 30;
  int dis[20][20];
  fill((int*)dis, (int*)(dis + n), INF);
  for (int i = 0; i < n; i++) dis[i][i] = 0;
  for (int i = 0; i < m; i++) {
    int a, b, c, d;
    char ch;
    cin >> a >> ch >> b >> ch >> c >> ch >> d;
    a--, b--;
    dis[a][b] = c;
    dis[b][a] = d;
  }
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (dis[i][k] == INF || dis[k][j] == INF) continue;
        dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
      }
    }
  }
  int s, g, V, P;
  char ch;
  cin >> s >> ch >> g >> ch >> V >> ch >> P;
  s--, g--;
  cout << V - P - dis[s][g] - dis[g][s] << endl;

  return 0;
}


Measured memory_bytes: 3152
#include <bits/stdc++.h>
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
#define all(x) (x).begin(),(x).end()

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(10);
    int N,M;
    cin >> N >> M;
    if(N == M)cout <<"Yes"<< "\n";
    if(N != M)cout <<"No"<< "\n";
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>

typedef long double ld;
typedef long long ll;

using namespace std;

#define MAXN (1 << 10)

int a[MAXN];

int main() {
	int n, m;
	cin >> n >> m;
	int sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		sum += a[i];
	}

	int cnt = 0;
	for (int i = 0; i < n; i++) {
		if (4 * m * a[i] >= sum) {
			cnt++;
		}
	}
	if (cnt >= m) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}

	return 0;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    cout<<(1+n)*n/2<<endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections;

namespace CompetitiveProgramming
{
  class Solve
  {
    public Solve()
    {
      int N = Scanner.nextInt();
      int K = Scanner.nextInt();
      bool[] D = new bool[10];
      for (int i = 0; i < K; i++) 
      {
        int d = Scanner.nextInt();
        D[d] = true;
      }

      for (int i = N; ; i++) 
      {
        bool isOK = true;
        for (int j = i; j > 0; j /= 10) {
          int temp = j % 10;
          if (D[temp]) {
            isOK = false;
            break;
          }
        }
        if (isOK) 
        {
          Console.WriteLine(i);
          break;
        }
      }
    }

  }

  class Program
  {
    static void Main(string[] args)
    {
        new Solve();
    }
  }

  public class Pair<T, U>
  {
    public Pair()
    {

    }
    public Pair(T first, U second)
    {
      this.first = first;
      this.second = second;
    }
    public T first { get; set; }
    public U second { get; set; }
  }

  class Scanner
  {
    private static List<string> buf = new List<string>();

    private static void next()
    {
      if (buf.Count == 0)
      {
        buf = Console.ReadLine().Split().ToList();
      }
    }

    private static string pop()
    {
      string ret = buf[0];
      buf.RemoveAt(0);
      return ret;
    }

    public static int nextInt()
    {
      next();
      return int.Parse(pop());
    }
    public static long nextLong()
    {
      next();
      return long.Parse(pop());
    }
    public static string nextString()
    {
      next();
      return pop();
    }
    public static double nextDouble()
    {
      next();
      return double.Parse(pop());
    }
  }
}


Measured memory_bytes: 2904
#include<bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  vector<int>ofi(N + 1, 0);
  for (int i = 0; i < N - 1; i ++) {
    int a;
    cin >> a;
    ofi[a] ++;
  }
  for (int i = 1; i <= N; i ++) cout << ofi[i] << endl;
}

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

signed main(){
  int N;
  cin>>N;
  int out=0;
  std::vector<int> t(N+1),x(N+1),y(N+1);
  t[0]=0;
  x[0]=0;
  y[0]=0;
  for(int i=1;i<N+1;i++)cin>>t[i]>>x[i]>>y[i];
  for(int i=1;i<N+1;i++){
    if(t[i]-t[i-1]<abs(x[i]-x[i-1])+abs(y[i]-y[i-1]))out++;
    else if((t[i]-t[i-1])%2!=(abs(x[i]-x[i-1])+abs(y[i]-y[i-1]))%2)out++;
  }
  if(out)cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
}


Measured memory_bytes: 1408
import sys
from collections import deque
input = sys.stdin.readline

S = input()

dq = deque(S.rstrip())
Q = int(input());

reverse = False

for _ in range(Q):
    q = input().split()
    if q[0] == '1':
        reverse ^= 1
    else:
        F, C = q[1:]
        if (F == '1') ^ reverse:
            dq.appendleft(C)
        else:
            dq.append(C)

ans = ""
if reverse:
    while dq:
        ans += dq.pop()
else:
    while dq:
        ans += dq.popleft()
print(ans)

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

int main() {
    string S;
    cin >> S;
    vector<int> t(0);
    ll ans = 0;
    for (int i = 0; i < S.size(); i++) {
        if (t.size() != 0 && t.at(t.size()-1) != S.at(i)) {
            t.pop_back();
            ans += 2;
        } else {
            t.push_back(S.at(i));
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1020
import java.util.Scanner;

/**
 * https://beta.atcoder.jp/contests/abc077/tasks/abc077_b
 */
public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		sc.close();
		
		int ans = 1;
		while((ans+1)*(ans+1)<=N){
			ans++;
		}
		System.out.println(ans*ans);

	}

}


Measured memory_bytes: 21844
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

int digit_sum(int value)
{
	int sum = 0;
	while(value)
	{
		sum += value % 10;
		value /= 10;
	}
	return sum;
}

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

	int N;
	
	cin >> N;

	int min = 10000;

	for (int i = 1; i < N / 2 + 1; i++)
	{
		int tmp = digit_sum(i) + digit_sum(N - i);
		if (tmp < min)
		{
			min = tmp;
		}
	}

	cout << min << endl;
	return 0;
}


Measured memory_bytes: 256
/* 拡張ダイクストラ */
#include <bits/stdc++.h>
using namespace std;

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF             2e9
#define INF_LL          1LL<<60
#define ll              long long
#define Ceil(x, n)      (((((x))+((n)-1))/n))
#define CeilN(x, n)     (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)    ((x)-(x)%(n))
#define ALL(x)          (x).begin(),(x).end()
typedef pair<ll, ll>    P;

int main() {
    ll x, y;
    cin >> x >> y;
    if(x % y == 0) {
        cout << -1  << endl;
    } else {
        cout << x * (y-1) << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def make_divisors(n: int) -> list:
    return_list = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            return_list.append(i)
            if i != n // i:
                return_list.append(n//i)

    return return_list

def main():
    n, m = i_map()

    divisors_list = make_divisors(m)

    divisors_list.sort(reverse=True)

    for num in divisors_list:
        if num <= m / n:
            print(num)
            exit()

if __name__ == '__main__':
    main()


Measured memory_bytes: 77320
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
using static AtCoderTemplate.MyLibrary;
 
namespace AtCoderTemplate
{
    class Program
    {
        static void Main (string[] args)
        {
            string S=Console.ReadLine();
            string T=Console.ReadLine();
 
            string T2=T.Remove(S.Length,1);
            if(S==T2)
            {
                Console.WriteLine("Yes");
            }
            else{
                Console.WriteLine("No");
            }
        }
    }
 
    class MyLibrary
    {
 
        // 自作の関数
        public static int MyFunction (int n)
        {
            return 0;
        }
    }
}


Measured memory_bytes: 25896
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<numeric>
#include<cassert>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define rep(i,s,n) for(int i=(s); i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))
#define print(x) printf("%d\n",x)

using namespace std;

typedef unsigned int uint;
typedef long long ll;

const int _dx[] = {0,1,0,-1};
const int _dy[] = {-1,0,1,0};

int getInt(){
  int ret = 0,c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}

int v[100000];
int d[100000];
struct test{
  int operator () (int a, int b){
    return b - a;
  }
};

int main(){
  int t = getInt();
  while(t --> 0){
    int n = getInt();
    int k = getInt();

    REP(i,n)
      v[i] = getInt();

    if(n <= k){
      puts("0");
      continue;
    }

    sort(v, v+n);
    transform(v, v+n-1, v+1, d, test());
    sort(d, d+n-1);

    ll all = (ll)v[n-1] - (ll)v[0];
    REP(i, k-1)
      all -= d[n-i-2];

    printf("%lld\n",all);
  }
  return 0;
}

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

int main(){

int W,H;

cin>> W >> H;

while(W&&H){
for(int i=1;i<=W;i++){
    for(int j=1;j<=H;j++){
cout<<"#";
}
cout<<endl;
}
cout<<endl;
cin >> W>> H;
}
return 0;
}


Measured memory_bytes: 3064
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;
import java.util.Scanner;
import java.util.Stack;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] line = sc.nextLine().split(" ");
        Stack<Integer> stack = new Stack<Integer>();
        int a=0,b=0;
        for(int i=0; i<line.length; i++){
            if(line[i].equals("+")) {
                a = stack.pop();
                b = stack.pop();
                stack.push(b+a);
            } else if (line[i].equals("-")) {
                a = stack.pop();
                b = stack.pop();
                stack.push(b-a);
            } else if (line[i].equals("*")) {
                a = stack.pop();
                b = stack.pop();
                stack.push(b*a);
            } else {
                stack.push(Integer.parseInt(line[i]));
            }
        }
        System.out.println(stack.pop());
    }
}



Measured memory_bytes: 26176
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        int ans=0;

        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int x = sc.nextInt();

        top:for(int i = 0;i<=a;i++){
            if(i*500>x) break;
            second:for(int i1 = 0;i1<=b;i1++){
                if((i*500+i1*100)>x) continue top;
                for(int i2 = 0;i2<=c;i2++){
                    int tmp = i * 500 + i1 * 100 + i2 * 50;
                    if(tmp ==x) {
                        ans++;
                        continue second;
                    }
                    if(tmp >x){
                        continue second;
                    }
                }
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 23636
/******************************************
* AUTHOR : AMAN SAXENA *
* Nick : blue-meth *
* "There's some good in this world, and it's worth fighting for." *
* INSTITUTION : KIET Group of Institutions *
******************************************/
#include <bits/stdc++.h>

const long long MODULO=1000000007;
const long long N = 1e5 + 7;
#define FOR(i,a,n) for(int i=a;i<n;i++)
#define FOR1(i,a,n) for(int i=a;i<=n;i++)
#define FOR2(i,a,n) for(int i=a;i>=n;i--)
#define pb push_back
#define mp make_pair
#define ll long long 
#define ull unsigned long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define pi 3.14159265359

using namespace std;

ll amanpower(ll a, ll b) {
	ll r = 1;
	while (b > 0) 
	{
		if (b & 1) r = r * a;
		a = a * a;
		b >>= 1;
	}
	return r;
}

ll amanlcm(ll a, ll b)
{
	 return a*(b/__gcd(a,b));
}
//Prime Numbers

vector<bool>prime(N+1,true);
void sieve()
{
	ll i,j,k;
	prime[0]=prime[1]=false;
	for(i=2;i*i<=N;i++)
	{
		if(prime[i])
		{
			for(j=i*i;j<=N;j+=i)
			{
				prime[j]=false;
			}
		}
	}
}

//Exponentiation

ll power(ll a,ll b)
{
	ll r=1;
	while(b)
	{
		if(b%2==1)
			r=r*a;
		b/=2;
		a*=a;
	}
	return r;
}
ll power(ll a,ll b,ll m)
{
	a=a%m;
	ll r=1;
	while(b)
	{
		if(b%2==1)
			r=(r*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return r;
}

//Prime Factors

vector<ll> factors(ll n)
{
	vector<ll>r;
	ll i,j;
	for(i=1;i*i<=n;i++)
	{
		if(n%i==0)
		{
			r.push_back(i);
			if(n/i!=i)
				r.push_back(n/i);
		}
	}
	return r;
}


//********* CODE START *********


void solve()
{
	string s;
	cin >> s;
	ll sum = 0;
	ll n = s.length();
	FOR(i,0,n)
	{
		sum += int(s[i]- '0');
	}
	// cout << sum << '\n';
	if(sum%9 == 0)
	{
		cout << "Yes";
	}
	else cout << "No";


}

void test()
{
	int t;
	cin>>t;
	while(t--) //for(int j=1;j<=t;j++) cout << "Case #" << j << ": ";
	{
		solve();
	}
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	//#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	//#endif
	
	// test();
	solve();

	
	return 0;
}

Measured memory_bytes: 3784
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<fstream>       //ファイルストリーム（標準入力変更用）
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

//名前
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef map<string, int> msi;
typedef map<string, ll> msll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pllll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;

//定数
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;

//マクロ
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,s,e) for(int i=s;i<e;i++)
#define repse(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define in(x1) cin >> x1
#define in2(x1, x2) cin >> x1 >> x2
#define in3(x1, x2, x3) cin >> x1 >> x2 >> x3
#define outl(x) cout << x << endl
#define out2l(x, y) cout << x << " " << y << endl 

//よく使う関数
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int N, K;
vll A;

bool C(double x)
{
    int count = 0;

    rep(i, N)
    {
        double a = (double)A[i];

        double c = ceil(a / x);

        count += (ll)c - 1LL;
    }

    return count <= K;
}

int main()
{
    in2(N, K);

    A.resize(N);
    rep(i, N) in(A[i]);

    double lb = 0;
    double ub = *max_element(all(A));

    rep(i, 100)
    {
        double mid = (lb + ub) / 2;

        if (C(mid))
        {
            ub = mid;
        }
        else
        {
            lb = mid;
        }
    }

    ll ans = ceil(ub);

    outl(ans);

    return 0;
}

Measured memory_bytes: 4708
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}
template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

bool check(int x, vector<int> &s, int m) {
    int index = 0;
    int target = s.back();
    int cnt = 0;
    int level = 1;
    while (index < s.size()) {
        if (target < level + x) {
            cnt++;
            break;
        }
        while (index < s.size() && s[index] < level) {
            index++;
        }
        int dlevel = 1;
        if (s[index] < level + x) {
            dlevel = max(dlevel, x - abs(level - s[index]));
        }
        if (index > 0) {
            dlevel = max(dlevel, x - abs(level - s[index - 1]));
        }
        cnt++;
        level += dlevel;
        if (cnt >= m) break;
    }
    return cnt >= m;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, m;
    while (cin >> n >> m, n + m) {
        vector<int> s(n);
        REP(i, 0, n) {
            cin >> s[i];
        }
        int l = s[0], r = 1000010;
        int ans = -1;
        while (l <= r) {
            int mid = (l + r) / 2;
            bool c = check(mid, s, m);
            if (c) {
                ans = mid;
                l = mid + 1;
            } else {
                r = mid - 1;
            }
        }
        cout << ans << endl;
    }
    return 0;
}



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

int main(){
int N,K;
int value=1;
int count=0;  
  cin>>N>>K;
  while(value<K&&count<N){
    value*=2;
    count+=1;
  }
  value=value+(N-count)*K;
  cout<<value<<endl;
}


Measured memory_bytes: 256
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let mut a: Vec<usize> = (0..3)
        .map(|_| itr.next().unwrap().parse().unwrap())
        .collect();
    a.sort();

    let max = a[2] * 3;
    let sum = a.iter().sum::<usize>();
    if (max - sum) % 2 == 0 {
        println!("{}", (max - sum) / 2);
    } else {
        println!("{}", (max - sum) / 2 + 2);
    }
}


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

#define pb push_back

using VI = vector <int>;
using ll = long long;

const int MXT = 26;
const int MXD = 365;

int D;
int C[MXT+10], S[MXD+10][MXT+10];

VI best;
ll best_score;


void update(VI &current, ll &new_score) {
	if (best.empty() || best_score < new_score) {
		best_score = new_score;
		best = current;
	}
	return;
}

void input() {
	scanf("%d", &D);
	for (int i = 1; i <= MXT; i ++) scanf("%d", &C[i]);
	for (int i = 1; i <= D; i ++) {
		for (int j = 1; j <= MXT; j ++) scanf("%d", &S[i][j]);
	}
	return;
}
void output() {
	for (auto x : best) printf("%d\n", x);
}

namespace Greedy {
	int last[MXT+10];
	void greedy() {
		for (int param = 1; param <= 10; param ++) {
			fill_n(last, MXT+1, 0);
			ll delta[MXT + 1] = {0};
			VI greedy_ans;
			ll score = 0;
			for (int i = 1; i <= D; i ++) {
				ll sum = 0;
				for (int j = 1; j <= MXT; j ++) delta[j] += C[j];
				sum = accumulate(delta + 1, delta + MXT + 1, 0ll);
				ll mx = -2e18;
				int ansd = -1;
				for (int j = 1; j <= MXT; j ++) {
					ll val = param * (- sum + delta[j]) + S[i][j];
					if (mx < val) mx = val, ansd = j;
				}
				score += S[i][ansd] + delta[ansd] - sum;
				delta[ansd] = 0;
				greedy_ans.pb(ansd);
			}
			update(greedy_ans, score);
		}
	}
}

int main() {
	input();
	Greedy::greedy();
	output();
	return 0;
}


Measured memory_bytes: 3840
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int w,h;
char ta[60][60];
bool used[60][60];
int fast=-1;
void dfs(int i,int j){
	used[i][j]=1;
	if(ta[i][j]=='W'){
	if(fast==-1)fast=0;
	else if(fast==1){
	fast=2;
	}
	return ;
	}
	if(ta[i][j]=='B'){
	if(fast==-1)fast=1;
	else if(fast==0){
	fast=2;
	}
	return ;
	}
	if(i+1<h&&used[i+1][j]==0)dfs(i+1,j);
	if(i-1>=0&&used[i-1][j]==0)dfs(i-1,j);
	if(j+1<w&&used[i][j+1]==0)dfs(i,j+1);
	if(j-1>=0&&used[i][j-1]==0)dfs(i,j-1);
}

int main(){
	while(true){
	cin>>w>>h;
	if(w==0&&h==0)break;
	for(int i=0;i<60;i++)for(int j=0;j<60;j++)ta[i][j]=' ';
	for(int i=0;i<h;i++){
	for(int j=0;j<w;j++)
	cin>>ta[i][j];
	}
	int a=0,b=0;//Wさん,Bさん
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
		fast=-1;
		for(int i=0;i<60;i++)for(int j=0;j<60;j++)used[i][j]=0;
		if(ta[i][j]!='W'&&ta[i][j]!='B')dfs(i,j);
		else continue;
		if(fast==0){a++;}
		else if(fast==1){b++;}
		}
	}
	cout<<b<<" "<<a<<endl;
	}

	return 0;
}

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

int main(){
	int value[100], x, max=0;
        string max_is = "";
	
	for(int j=0; j<100; j++){
		value[j] = 0;
	}
	
	while(cin>>x){
		value[x-1]++;
	}
	
	for(int i=0; i<100; i++){
		if(max<value[i]){
			max = value[i]; 
			max_is = "";
			max_is = to_string(i+1);
		}else if(max == value[i]){
			max_is = max_is + "\n" + to_string(i+1);
		}
	}

	cout << max_is << endl;

	return 0;
}

	

Measured memory_bytes: 1232
N, M = map(int, raw_input().split())
roadlist = []
for i in range(0, N):
	town = []
	for j in range(0, N):
		town.append(0)
	roadlist.append(town)

for i in range(0, M):
	a, b = map(int, raw_input().split())
	roadlist[a-1][b-1] = roadlist[a-1][b-1] + 1
	roadlist[b-1][a-1] = roadlist[b-1][a-1] + 1

for i in range(0, N):
	cnt = 0
	for j in range(0, N):
		cnt = cnt + roadlist[i][j]
	print cnt

Measured memory_bytes: 2692
import java.io.*;
class Main {
  public static void main(String... args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String s = br.readLine();
    while(s != null) {
      String[] arr = s.split(" ");
      int sum = Integer.parseInt(arr[0]) + Integer.parseInt(arr[1]);
      System.out.println((int)Math.log10(sum)+1);
      s = br.readLine();
    }
  }
}

Measured memory_bytes: 16992