akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long int ll;

const ll mod=1e9+7;

vector<ll> p;
ll p_num[1000005];
bool isprime[1000005];


void sieve(ll maxn){
    for(ll i=0;i<maxn;++i)isprime[i]=true;
    for(ll i=2;i<maxn;++i){
        if(!isprime[i])continue;
        p.push_back(i);
        ll t=2;
        while(i*t<maxn){
            isprime[i*t]=false;
            t++;
        }
    }
}


ll modPow(ll a, ll n) {
    if(n==1)return a%mod;
    if (n%2==1)return(a*modPow(a,n-1))%mod;
    ll t=modPow(a,n/2);
    return (t*t)%mod;
}

ll modDiv(ll a,ll b){
    return (a%mod)*modPow(b,mod-2)%mod;
}



ll N;
ll A[10004];

int main(){
    cin>>N;
    for(int i=0;i<N;++i)cin>>A[i];
    sieve(1000001);
    ll ans=0;
    for(int i=0;i<N;++i){
        ll x=A[i];
        //cout<<x<<endl;
        for(ll j=2;j*j<=x;j++){
            ll k=0;
            while(x%j==0){
                k++;
                x/=j;
                //cout<<j<<endl;
            }
            p_num[j]=max(k,p_num[j]);
        }
        if(x!=1)p_num[x]=max(1LL,p_num[x]);
    }
    ll X=1;
    for(int i=0;i<1000001;++i){
        for(int j=0;j<p_num[i];++j){
            //cout<<i<<endl;
            X*=i;
            X%=mod;
        }
    }
    for(int i=0;i<N;++i){
        ans+=modDiv(X,A[i]);
        ans%=mod;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 9332
N=int(input())
A=[0]*N
B=[0]*N
for i in range(N):
  A[i],B[i] = map(int,input().split())
  
cnt=0
for i in range(N-1,-1,-1):
  A[i] += cnt
  s=A[i]%B[i]
  if s!=0:
    cnt +=B[i]-s
  #print(i,A,cnt)

print(cnt)

Measured memory_bytes: 14836
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long ans=0;
  long long x;cin >> x;
  long long y = x/11;
  if(x%11>6){
    ans=y*2+2;
  }else if(x%11==0){
    ans=y*2;
  }else{
    ans=y*2+1;
  }
  cout << ans << endl;
}

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

int main(void) {
    long long int a, b, x;
    cin >> a >> b >> x;

    long long int n;
    if (a == 0) {
        n = b/x + 1;
    } else {
        n = b/x - (a-1)/x;
    }

    cout << n << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int N = 1e5 + 5;

#define endl "\n"
int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	double n;
	cin >> n;
	cout << (int)pow(n, 3) << endl;
	return 0;
}

Measured memory_bytes: 384
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:512000000")
#include<utility>
#include<iostream>
#include<fstream>
#include<vector>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<functional>
#include<random>
#include<climits>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
#include<ccomplex>

//4Head

#define all(x) x.begin(), x.end()
#define mp make_pair
#define X first
#define Y second

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(NULL));

ll const mod = 1e9 + 7;

namespace {
	ll mul(ll a, ll b) {
		ll val = a * b - (ll)((ld)a * b / mod) * mod;
		if (val < 0) val += mod;
		if (val >= mod) val -= mod;
		return val;
	}

	ll poww(ll a, ll b) {
		ll val = 1;
		a %= mod;
		while (b > 0) {
			if (b % 2) val = mul(a, val);
			a = mul(a, a);
			b >>= 1;
		}
		return val % mod;
	}

	ll inv(ll a) {
		return poww(a, mod - 2);
	}
}

ll const maxn = 3e5 + 5;

signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll n; cin >> n;
	set<ll>kek;
	for (ll i = 0; i < n; i++) {
		ll t; cin >> t; kek.insert(t);
	}
	if (kek.size() == n) {
		cout << "YES\n";
	} else {
		cout << "NO\n";
	}
	return 0;
}

/*
3
0 1
3 0
1 0
*/

Measured memory_bytes: 9600
using System;
using System.ComponentModel;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int K = int.Parse(Console.ReadLine());
            var ab = Console.ReadLine().Split(" ");
            int A = int.Parse(ab[0]);
            int B = int.Parse(ab[1]);
            string res = "NG";

            for (int i = A; i <= B; i++)
            {
                if (i % K == 0)
                {
                    res = "OK";
                    break;
                }
            }

            Console.WriteLine(res);
        }
    }
}


Measured memory_bytes: 27540
#include <iostream>

using namespace std;

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

    if (n%10 == 3)
    {
        cout << "bon\n";
    }
    else if (n%10 == 0 || n%10 == 1 || n%10 == 6 || n%10 == 8)
    {
        cout << "pon\n";
    }
    else
    {
        cout << "hon\n";
    }
    return 0;
}


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

typedef long long int ll;
typedef vector<int> vi;			
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef pair<int, int> 	pii;
typedef vector<bool> vb;
#define endl '\n'
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size()
#define MOD 1000000007
#define F first
#define S second
#define pb push_back
#define pf push_front
#define rb pop_back
#define rf pop_front
#define in insert
#define mp make_pair
#ifdef LOCAL
	#include "../../trace.h"
#else
    #define trace(args...)
#endif

ll div_floor(const ll &a,const ll &b) { return a / b - (((a ^ b) < 0) and a % b);}
ll div_ceil(const ll &a,const ll &b) { return a / b + (((a ^ b) >= 0) and a % b);}

void solve(){
	ll k; cin>>k; if(k%7==0) k = k/7;
	ll power = 1%k, summ = 0;
	for(ll i = 1; i<=1e7; i++){
		summ = (summ + power)%k;
		power = (power*10)%k;
		if(summ==0){
			cout<<i<<endl; return;
		}
	}
	cout<<-1<<endl;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	#ifdef LOCAL
		freopen(".inp.txt", "r", stdin);
    	freopen(".out.txt", "w", stdout);
    	freopen(".err.txt", "w", stderr);
	#endif
	int t=1;
	while(t--)
		solve();
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <stdlib.h>
#define E_MAX 100000
#define V_MAX 10001

typedef struct edge {
    int s, t, w;
} edge;

edge edges[E_MAX];
int x[V_MAX];

int compare(const void *a, const void *b) {
    return (*(edge *)a).w - (*(edge *)b).w;
}

void initx(int n) {
    for(int i=0; i<n; i++) x[i] = i;
}

void unite(int a, int b) {
    x[x[b]] = x[a];
}

int find(int a) {
    if (x[a] == a) return a;
    else return x[a] = find(x[a]);
}

int same(int a, int b) {
    return find(a) == find(b);
}

int main() {
    int n, m, cnt = 0;
    scanf("%d%d", &n, &m);
    initx(n);
    for(int i=0; i<m; i++)
        scanf("%d%d%d", &edges[i].s, &edges[i].t, &edges[i].w);

    qsort(edges, m, sizeof(edge), compare);

    for(int i=0; i<m; i++) {
        edge e = edges[i];
        if (!same(e.s, e.t)) {
            unite(e.s, e.t);
            cnt += e.w;
        }
    }
    printf("%d\n", cnt);
}



Measured memory_bytes: 4004
A,B,C,D = map(int, input().split())

def gcd(c,d):
	if(c==0):
		return d
	else:
		return gcd(d%c,c)
prod = C*D
lcm = prod//gcd(C,D)

A-=1

AC=A//C
AD=A//D
BC=B//C
BD=B//D
ACD=A//lcm
BCD=B//lcm

print(B-A-BC-BD+BCD+AC+AD-ACD)


Measured memory_bytes: 3060
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus >= 201703L
#        pragma GCC target("avx2")
#    else
#        pragma GCC target("avx")
#    endif

#endif
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

    Int x, a, b;
    cin >> x >> a >> b;

    if (abs(a - x) < abs(b - x)) {
        cout << 'A' << endl;
    } else {
        cout << 'B' << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cctype>
#include<cstdlib>
#include<algorithm>
#include<bitset>
#include<vector>
#include<list>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<ctime>
#include<complex>
#include<functional>
#include<climits>
#include<cassert>
#include<iterator>
#include<unordered_set>
#include<unordered_map>
using namespace std;

#define MAX 8005

char buf[MAX];


deque<int> ar[2];
string s;
bool dp[MAX][MAX*2];

inline bool reachable(deque<int> &d, int goal) {
	if (abs(goal) > 8000) {
		return false;
	}
	memset(dp, false, sizeof(dp));
	int base = MAX;
	dp[0][base] = true;
	for (int i = 0; i < d.size(); i++) {
		for (int ich = 0; ich < MAX * 2; ich++) {
			if (dp[i][ich] == true) {
				int nex = ich + d[i];
				dp[i + 1][nex] = true;
				nex = ich - d[i];
				dp[i + 1][nex] = true;
			}
		}
	}
	return dp[d.size()][goal + base];
}

int main() {
	scanf("%s", buf);
	int a, b;
	scanf("%d%d", &a, &b);
	s = buf;
	int cur = 0;
	int cnt = 0;
	bool FA = false;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'T') {
			ar[cur].push_back(cnt);
			cur ^= true;
			cnt = 0;
		}
		else {
			cnt++;
		}
	}
	ar[cur].push_back(cnt);
	//0 first
	if (ar[1].size()==0&&ar[0].size() == 0) {
		puts("No");
		return 0;
	}
	if (ar[0].size()) {
		a -= ar[0].front();
		ar[0].pop_front();
	}
	if (reachable(ar[0], a) && reachable(ar[1], b)) {
		puts("Yes");
	}
	else {
		puts("No");
	}
	return 0;
}

Measured memory_bytes: 125440
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define rrep(i,a) for(int i=(int)a-1;i>=0;--i)
#define REP(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RREP(i,a,b) for(int i=(int)a-1;i>=b;--i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n) / gcd(n, m)*abs(m);//gl=xy
}
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
using namespace std;

template< class T >
struct CumulativeSum2D {
  vector< vector< T > > data;

  CumulativeSum2D(int W, int H) : data(W + 1, vector< int >(H + 1, 0)) {}

  void add(int x, int y, T z) {
    ++x, ++y;
    if(x >= data.size() || y >= data[0].size()) return;
    data[x][y] += z;
  }

  void build() {
    for(int i = 1; i < data.size(); i++) {
      for(int j = 1; j < data[i].size(); j++) {
        data[i][j] += data[i][j - 1] + data[i - 1][j] - data[i - 1][j - 1];
      }
    }
  }

  T query(int sx, int sy, int gx, int gy) {
    return (data[gx][gy] - data[sx][gy] - data[gx][sy] + data[sx][sy]);
  }
};

using P=pair<int,int>;
void solve(){
  int h,w,k;
  cin>>h>>w>>k;
  vector<string>s(h);
  int ans=numeric_limits<int>::max();
  CumulativeSum2D<int>sum(h,w);
  rep(i,h)cin>>s[i];
  rep(i,h)rep(j,w)sum.add(i,j,(int)(s[i][j]=='1'));
  sum.build();
  rep(bit,1<<(h-1)){
    int cnt=0;
    int pre=0;
    bool bad=false;
    vector<P>v;
    rep(i,h-1){
      if(bit&(1<<i)){
        ++cnt;
        v.eb(pre,i+1);//[pre,i+1)
        pre=i+1;
      }
    }
    v.eb(pre,h);//番兵を忘れない
    vector<int>sum2(v.size()+5);
    int j=0;
    int prej=0;
    while(j<w){
      rep(a,v.size()){
        sum2[a]+=sum.query(v[a].first,j,v[a].second,j+1);
      }
      bool ng=false;
      rep(a,v.size()){
        if(sum2[a]>k)ng=true;
      }
      if(ng){
        ++cnt;
        if(prej==j){
          bad=true;
          break;
        }
        rep(a,v.size())sum2[a]=0;
        prej=j;
      }
      else ++j;
    }
    if(bad)continue;
    chmin(ans,cnt);
  }
  cout<<ans;
}

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


Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>

int main(void) {
	int n, i;
	int ayaneru = 0, asumisu = 0;
	char tomatu[128], sumipe[128];
	if (scanf("%d", &n) != 1) return 1;
	for (i = 0; i < n; i++) {
		int mareitaso;
		if (scanf("%127s%127s", tomatu, sumipe) != 2) return 1;
		mareitaso = strcmp(tomatu, sumipe);
		if (mareitaso > 0) ayaneru += 3;
		else if (mareitaso < 0) asumisu += 3;
		else ayaneru++, asumisu++;
	}
	printf("%d %d\n", ayaneru, asumisu);
	return 0;
}


Measured memory_bytes: 2104
#include <cstdio>
#include <algorithm>
using namespace std;
typedef pair<int, int> ii;
const int mod = 1000000007;
int main() {
	int N;
	scanf("%d", &N);
	ii VX[N], LR[N + 2];
	for (int i = 0; i < N; ++i) scanf("%d %d", &VX[i].second, &VX[i].first);
	sort(VX, VX + N);
	int mxX[N], mnX[N];
	for (int i = 0; i < N; ++i) mxX[i] = mnX[i] = VX[i].second;
	for (int i = 1; i < N; ++i) mxX[i] = max(mxX[i], mxX[i - 1]);
	for (int i = N - 1; i > 0; --i) mnX[i - 1] = min(mnX[i - 1], mnX[i]);
	for (int i = 0; i < N; ++i) {
		int l = 0, u = i, m;
		while (l != u) {
			m = (l + u) / 2;
			if (mxX[m] >= VX[i].second) u = m;
			else l = m + 1;
		}
		LR[i + 1].first = l + 1;
		l = i, u = N - 1;
		while (l != u) {
			m = (l + u + 1) / 2;
			if (mnX[m] <= VX[i].second) l = m;
			else u = m - 1;
		}
		LR[i + 1].second = u + 1;
	}
	sort(LR + 1, LR + N + 1);
	LR[0] = ii(0, 0);
	LR[N + 1] = ii(N + 1, N + 1);
	int dptable[N + 2], sum = 1, l = 0;
	dptable[0] = 1;
	for (int i = 1; i < N + 2; ++i) {
		while (l < i && LR[l].second < LR[i].first - 1) sum = ((sum - dptable[l++]) % mod + mod) % mod;
		dptable[i] = sum;
		sum = (sum + dptable[i]) % mod;
	}
	printf("%d", dptable[N + 1]);
	return 0;
}

Measured memory_bytes: 7176
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <queue>
using namespace std;
int main(){
    int n,m;
    cin >> n >> m;
    vector<vector<int>> vec(1e5+1);
    for(int i=0;i<n;i++){
        int a,b;
        cin >> a >> b;
        vec[a].push_back(b);
    }
  //  cout<<vec.top().first<<" "<<vec.top().first<<endl;
  priority_queue<int> q;
  long long vl=0;
    for(int i=1;i<=m;i++){
        for(int k=0;k<vec[i].size();k++){
            q.push(vec[i][k]);
        }
        if(!q.empty()){
            vl += q.top();
            q.pop();
        }
    }
    cout << vl <<endl;
}

Measured memory_bytes: 5632
// https://atcoder.jp/contests/dp/tasks/
#include <bits/stdc++.h>

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

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

map<int, map<int, ll>> d;
map<int, ll> dmax;

ll dp(int from, int to);

ll dmaxp(int idx) {
    if (dmax[idx] == -1) {
        // dmax[to] = max(d[to][0], .... d[to][N])
        ll m = 0;
        for (auto it = d[idx].begin(); it != d[idx].end(); it++) {
            // printf("...max %d->%d\n", to, it->first);
            m = max(m, dp(idx, it->first));
        }
        dmax[idx] = m + 1;
        // printf("dmax[%d]=%lld\n", idx, dmax[idx]);
    }
    return dmax[idx];
}

ll dp(int from, int to) {
    if (d[from][to] == -1) {
        if (d.find(to) == d.end()) {
            d[from][to] = 0;
        } else {
            d[from][to] = dmaxp(to);
        }
    }
    return d[from][to];
}

int main() {
    int n, m;
    cin >> n >> m;

    rep(i, m) {
        int x, y;
        cin >> x >> y;
        if (d.find(x) == d.end()) {
            d[x].emplace(y, -1);
            dmax[x] = -1;
        } else {
            d[x][y] = -1;
        }
    }

    for (auto it = d.begin(); it != d.end(); it++) {
        for (auto it2 = it->second.begin(); it2 != it->second.end(); it2++) {
            int from = it->first;
            int to = it2->first;
            dp(from, to);
            // ll r = dp(from, to);
            // printf("%d->%d = %lld\n", from, to, r);
        }
    }

    // fill dmax table
    for (auto it = d.begin(); it != d.end(); it++) {
        dmaxp(it->first);
    }

    ll ans = 0;
    for (auto it = dmax.begin(); it != dmax.end(); it++) {
        ans = max(ans, it->second);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 28288
/**
 *    Coded by : lucky_21
 *               --------Lokesh Singh
**/

#include<bits/stdc++.h>
using namespace std;

#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define     F           first
#define     S           second
#define     pb          push_back
#define     lb          lower_bound
#define     ub          upper_bound
#define     pii         pair<int,int>
#define     all(x)      x.begin(),x.end()
#define     fix         fixed<<setprecision(10)
#define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)
#define     repb(i,b,a) for(int i=int(b);i>=int(a);i--)
#define     FastIO      ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

typedef double db;
typedef long long ll;

const int N=1e5+5;
const int mod=1e9+7;

int n,a[N][3],dp[N][3];
int rec(int i,int prev){
    if(i>n) return 0;
    int &cache=dp[i][prev];
    if(cache) return cache;
    rep(j,0,2){
        if(j!=prev) cache=max(cache,a[i][j]+rec(i+1,j));
    }
    return cache;
}
signed main(){
    FastIO;
    cin>>n;
    rep(i,1,n) cin>>a[i][0]>>a[i][1]>>a[i][2];
    cout<<rec(0,0);
    return 0;
}


Measured memory_bytes: 10368
# include <iostream>

using namespace std;

//https://atcoder.jp/contests/abc081/tasks/abc081_b

int main(){
    int N;
    cin >> N;

    int A[N];
    for(int i=0;i<N;i++){
        cin >> A[i];
    }

    int sum = 0;
    bool end = false;
    while(1){
        for(int i=0;i<N;i++){
            if(A[i] % 2 == 1){
                end = true;
            }
            A[i] /= 2; 
        }
        if(end == true){
            break;
        }else{
            sum += 1;
        }
    }
    cout << sum << endl;
    
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;

public class Main {

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split("");

		for (int i = 0; i < str.length; i++) {
			if (str[i].equals("7")) {
				System.out.println("Yes");
				return;
			}
		}

		System.out.println("No");
	}
}

Measured memory_bytes: 32892
def count_diff(q,a):
    lst_q = list(q)
    lst_a = list(a)
    len_q = len(lst_q)
    ng = 0
    for i in range(len_q):
        if lst_q[i] != lst_a[i]:
            ng += 1
    print(ng)

q = input()
a = input()

count_diff(q,a)

Measured memory_bytes: 12432
import sys
input = sys.stdin.readline

N=int(input())
dic={}
sum=0
for i in range(N):
    s=list(input())
    s.sort()
    s = "".join(s)
    if s in dic:
        sum+=dic[s]
        dic[s]+=1
    else:
        dic[s]=1
print(sum)

Measured memory_bytes: 17804
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(a); i++)
typedef long long ll;
template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

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

const ll inf = 1LL<<60;
const ll mod = 1000000007;

ll f(string s) {
  int len = s.size();
  ll ret = stoll(s);

  for (int i=1; i<len; i++) {
    ret += stoll(s.substr(0, i)) * pow(2, (len-i-1));
    ret += f(s.substr(i, len-i));
  }

  return ret;
}

int main()
{
  string s; cin>>s;
  cout << f(s) << endl;

  return 0;
}


Measured memory_bytes: 4056
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
//#include <numeric> //iota
//#include <sstream>
//#include <cstring>
//#include <tuple>
//#include <random>
//#include <string>
//#include <unordered_set>
//#include <bitset>
//#include <unordered_map>
//#include <stack>
//#include <cmath>
//#include <deque>
//#include <queue>
//#include <list>
#include <array>
using namespace std;
#define endl "\n"
#define all(x) (x).begin(), (x).end()
#define vec vector
#define pb push_back
#define pp pop_back
#define fi first
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define se second
#define un_map unordered_map
#define rep(i,a,n) for (int i = a; i < n; ++i) 
#define inc_rep(i,a,n,inc) for (int i = a; i < n; i += inc) 
#define couts(x) cout << x << "\n" 
#define watch(x) cout << #x << " : " << x << endl;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<long long, long long>  PLII;
template<typename T>
void print(vector<T>& v) {rep(i, 0, (int)v.size()) cout << v[i] << " ";cout << endl;}
int nxt() {int x;cin >> x;return x;}
ll nxtl() {ll x;cin >> x;return x;}
string nxts() {string x;cin >> x;return x;}
double nxtd() {double x; cin >> x; return x;}

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

int main() {
	IOS;
	int n = nxt();
	vector<ll> v(n);
	generate(all(v), nxtl);
	ll ans = 0;
	rep (i, 1, n) {
		ans += max(0LL, v[i - 1] - v[i]);
		v[i] = max(v[i], v[i - 1]);
	}
	cout << ans;
}


Measured memory_bytes: 4788
#include<stdio.h>

static const int N = 1000;

void trace(int A[], int n){
  int i;
  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

int main(){
  int n, i, j;
  int A[N+1];
  scanf("%d", &n);

  for ( i = 1; i <= n; i++ ) scanf("%d", &A[i]);
  
  trace(A, n);

  for(i=2;i<=n;i++){
    A[n+1] = A[i]; //A[n+1] is key
    j = i - 1;
    while(j >= 0 && A[j] > A[n+1]){
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = A[n+1];
    trace(A,n);
  }

  return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const int INT_INF = 2147483647;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef pair<int,int> P;

int main(){
  int h,w,d;
  cin >> h >> w >> d;
  //int a[h][w];
  int x[h*w];
  int y[h*w];
  rep(i,h)rep(j,w){
    int a;
    cin >> a;
    a--;
    x[a]=i;
    y[a]=j;
  }
  int p[h*w];
  rep(i,d)p[i]=0;
  for(int i=d;i<h*w;i++){
    p[i]=p[i-d]+abs(x[i]-x[i-d])+abs(y[i]-y[i-d]);
  }
  int q;
  cin >> q;
  rep(i,q){
    int l,r;
    cin >> l >> r;
    cout << p[r-1]-p[l-1] << endl;
  }
  // rep(i,h*w)cout << x[i] <<" "<< y[i] <<  endl;
  // rep(i,h*w)cout << p[i] << endl;
  return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  int n;
  unordered_set<string> us;
  bool flg = true;
  cin >> n;
  vector<string> s(n);
  rep(i, n) cin >> s[i];
  us.insert(s[0]);

  for (int i = 1; i < n; ++i) {
    if (us.find(s[i]) != us.end() || s[i-1][s[i-1].length() - 1] != s[i][0])
    {
      flg = false;
      break;
    }
    us.insert(s[i]);
  }

  cout << (flg ? "Yes" : "No") << endl;
  return 0;
}


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

#define show(x) cerr << #x << " = " << x << endl ;
#define input_from_file freopen("input.txt","r",stdin)
#define output_to_file freopen("output.txt" , "w",stdout)
#define output_to_error freopen("error.txt" , "w" ,stderr)
#define fastio ios_base::sync_with_stdio(0)
#define endl '\n'


int main()
{
	#ifdef LOCAL
        input_from_file;
        output_to_file;
        output_to_error;
    #endif
	fastio;cin.tie(0);cout.tie(0);
	string s ; 
	cin >> s ; 
	for(int i = 0 ; i < s.size() ; ++i)
		cout << 'x';

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
#include <ctime>
#include <tuple>
#include <bitset>
using namespace std;

/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long ll;

#define fi first
#define se second

using Graph = vector<vector<int>>;

int main()
{
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> c(n);
    vector<vector<int>> a(n, vector<int>(m));

    for (int i = 0; i < n; i++)
    {
        cin >> c[i];
        for (int j = 0; j < m; j++)
        {
            cin >> a[i][j];
        }
    }
    ll ans = 10000000000000;
    for (int bit = 0; bit < (1 << n); bit++)
    {
        ll tmp = 0;
        vector<ll> vec(m, 0); // m科目
        for (int i = 0; i < n; i++)
        {
            if (bit & (1 << i))
            {
                for (int j = 0; j < m; j++)
                {
                    vec[j] += a[i][j];
                }
            }
        }
        sort(vec.begin(), vec.end());
        if (vec[0] >= x)
        {
            for (int i = 0; i < n; i++)
            {
                if (bit & (1 << i))
                {
                    tmp += c[i];
                }
            }
            ans = min(ans, tmp);
        }
    }
    if (ans == 10000000000000)
    {
        cout << -1 << endl;
    }
    else
    {
        cout << ans << endl;
    }

    return 0;
}

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

using namespace std;
using ll =long long;
//nCm 
const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//nCmここまで

#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
const ll INF = 1LL << 60;

//Write From this Line

const int mod = 1e9+7;
int main()
{
	string s ;
	cin >> s ;
	rep(i,s.size()) cout << 'x' ;

}


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

const int maxN = 2e6 + 10;
int n;
long long val[maxN];
long long sum[maxN];

int main(){
	//freopen("b2.txt","r",stdin);
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%lld",&val[i]);
	}
	for(int i=1; i<=n;i++){
		sum[i] = sum[i-1] + val[i];
	//	printf("%d\n",sum[i] );
	}	
	long long res = 5e18;
	for(int i=1; i<=n-1;i++){
		long long t =abs(sum[i] - (sum[n] - sum[i]));

		res = min(res, t);

	}
	printf("%lld\n",res);


	return 0;
}

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

int main(){
    int N,M; cin>>N;
    vector<string> s(N);
    for(int i=0;i<N;i++) cin>>s[i];
    cin>>M;
    vector<string> t(M);
    for(int i=0;i<M;i++) cin>>t[i];

    int ans=0;
    for(int i=0;i<N;i++){
        int count=0;
        for(int j=0;j<N;j++){
            if(s[i]==s[j]) count++;
        }
        for(int j=0;j<M;j++){
            if(s[i]==t[j]) count--;
        }
        ans=max(ans,count);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
typedef long long int ll;
ll mo=1000000007;
bool ok(ll arr[],ll n,ll mid,ll k){
    ll sum=0;
    for(ll i=0;i<n;i++){
            sum+=(arr[i]-1)/mid;
        }
    return (sum<=k);    
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t=1;
    //cin>>t;
    while(t)
    {
        ll n,k;
        cin>>n>>k;
        ll arr[n];
        ll ma=INT_MIN;
        for(ll i=0;i<n;i++){
            cin>>arr[i];
            ma=max(ma,arr[i]);
        }

        ll l=0;
        ll r=ma;
        ll mid;
        while(l<r-1){
            mid=l+(r-l)/2;
            if(ok(arr,n,mid,k)){
                r=mid;
            }
            else{
                l=mid;
            }
        }
        cout<<r<<endl;
        t--;
    }
}

Measured memory_bytes: 5088
#include <stdio.h>
#include <string.h>

int main(void)
{
    int n, taro_output = 0, hanako_output = 0;
    char taro[101], hanako[101];

    scanf("%d", &n);

    while(n--)
    {
        scanf("%s %s", &taro, &hanako);

        const int result = strcmp(taro, hanako);

        if(result == 0)
        {
            taro_output++;
            hanako_output++;
        }

        else if(result > 0)
        {
            taro_output += 3;
        }

        else
        {
            hanako_output += 3;
        }
    }

    printf("%d %d\n", taro_output, hanako_output);

    return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    int cnt = 1;
    rep(i, n-1){
        if(s[i]!=s[i+1])
            cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

map<LL,LL> m1;
vector<pair<LL,LL> > v1[1000005];

int main(){
	LL n,m;
	LL i,j,k;
	LL a,b,c,d;
	LL x,y;
	LL m1_cnt=0;
	cin>>n>>x>>y;
	if(y==0){
		if(x==0)cout<<1<<endl;
		else cout<<n+1<<endl;
		return 0;
	}
	if(y<0)x=-x,y=-y;
	y*=2;
	for(i=0;i<=n;i++){
		a=(n-i)*(n-i-1)-n*(n-1)/2;
		b=n*(n-1)/2-i*(i-1);
		a=a*y/2+(n-2*i)*x;
		b=b*y/2+(n-2*i)*x;
		if(a>=0)d=a%y,c=a/y;
		else c=-((-a-1)/y+1),d=a-c*y;
		a=c;
		if(b>=0)b/=y;
		else b=-((-b-1)/y+1);
		if(m1.find(d)==m1.end()){
			m1[d]=m1_cnt++;
		}
		v1[m1[d]].push_back(make_pair(a,1));
		v1[m1[d]].push_back(make_pair(b,-1));
		//cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;
	}
	LL s=0;
	for(i=0;i<m1_cnt;i++){
		a=0;
		sort(v1[i].begin(),v1[i].end());
		s++;
		for(j=0;j<v1[i].size()-1;j++){
			a+=v1[i][j].second;
			if(a>0)s+=v1[i][j+1].first-v1[i][j].first;
			if(a==0 && v1[i][j+1].first-v1[i][j].first>0)s++;
		}
	}
	cout<<s<<endl;
}

Measured memory_bytes: 45568
using System;

class Program
{
    static void Main(string[] args)
    {
        int i, j;

        string[] strInput = Console.ReadLine().Split(' ');
        Int64 n = Int64.Parse(strInput[0]);
        Int64 d = Int64.Parse(strInput[1]);

        Int64[] x = new Int64[n];
        Int64[] y = new Int64[n];

        int result = 0;

        for(i = 0; i < n; i++)
        {
            strInput = Console.ReadLine().Split(' ');
            x[i] = Int64.Parse(strInput[0]);
            y[i] = Int64.Parse(strInput[1]);
            if(Math.Sqrt(x[i] * x[i] + y[i] * y[i]) <= (double)d)
            {
                result++;
            }
        }

        Console.WriteLine(result);

        return;
    }
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

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

ll N,A[202020];
ll i, j, k,ans;
map<ll, ll> mp;

int main(){
    scanf("%lld", &N);
    fornum(i,0,N){
        scanf("%lld", &A[i]);
    }
    fornum(i,0,N){
        ans += mp[i - A[i]];
        ++mp[i + A[i]];
    }
    printf("%lld\n", ans);

    return 0;
}

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

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

    int A, B;
    int outlet = 1;
    int counter = 0;

    cin >> A >> B;

    while(outlet < B)
    {
        outlet += A;
        --outlet;
        ++counter;
    }

    cout << counter;

    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);
      	int i = 0, input, total = 0;
      	while(i < 3){
          input = Integer.parseInt(sc.next());
          total += input;
          i++;
        }
      
      	if(total % 10 == 7){
        	System.out.println("YES");
        }else{
        	System.out.println("NO");
        }
	}
}


Measured memory_bytes: 20564
#include<iostream>
#include<map>
#include<vector>
#include<cmath>
#include<string>
#include <algorithm> 
using namespace std;

# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define p(s) std::cout << s << endl;

int main()
{
    map<string,int> mp;
    vector<string> v;
    int n;cin >> n ;
    for(int i=0;i<n;i++){
        string s;cin >> s;
        mp[s]++;
    }
    int m;cin >> m ;
    for(int i=0;i<m;i++){
        string s;cin >> s;
        mp[s]--;
    }

    int ret=0;
    for(auto x:mp) {ret=max(ret,x.second);}
    p(ret)

}

Measured memory_bytes: 256
# 各辺をグラフから取り除いて、グラフが連結であるかを判定する
# DFSを使っての解法
n, m = map(int, input().split())

graph = [[False for _ in range(50)] for _ in range(50)]
visited = [False for _ in range(50)]

def dfs(v):
    visited[v] = True
    for v2 in range(n):
        if graph[v][v2] == False: continue
        if visited[v2] == True: continue
        dfs(v2)

a = [0 for _ in range(50)]
b = [0 for _ in range(50)]
for i in range(m):
    a[i], b[i] = map(int, input().split())
    a[i] -= 1
    b[i] -= 1
    graph[a[i]][b[i]] = True
    graph[b[i]][a[i]] = True

ans = 0

for i in range(m):
    graph[a[i]][b[i]] = False
    graph[b[i]][a[i]] = False

    for j in range(n):
        visited[j] = False

    dfs(0)

    brige = False
    for j in range(n):
        if visited[j] == False: brige = True
    if brige: ans += 1

    graph[a[i]][b[i]] = True
    graph[b[i]][a[i]] = True

print(ans)


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

int main() {
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;

    if ((x - r >= 0 && x + r <= W) &&
        (y - r >= 0 && y + r <= H)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


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

int main()
{
    int x; cin >> x;
    bool check;
    while(1){
        check = true;
        for(int i=2; i<=sqrt(x); i++){
            if(!(x%i)) {check = false; break;}
        }
        if(check) {cout << x << endl; return 0;}
        x++;
    }
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  vector<int> a(n+1);
  for(int i=0;i<n;i++){
    cin>>a[i+1];
  }
  vector<int> x(n+1);
  for(int i=n;i>=1;i--){
    if(i>n*0.5){
      x[i]=a[i];
    }
    else{
      int sum=0;
      int k=2;
      while(i*k<=n){
        sum+=x[i*k];
        k++;
      }
      if(sum%2==a[i]){
        x[i]=0;
      }
      else x[i]=1;
    }
  }
  int cnt=0;
  for(auto& e:x){
    if(e==1) cnt++;
  }
  cout<<cnt<<endl;
  for(int i=1;i<=n;i++){
    if(x[i]==1) cout<<i<<" ";
  }

}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#include <cmath>
#include <iostream>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007
int main() {
	long double a,b,h,m;
	cin>>a>>b>>h>>m;
	long double A=h*30.0+m/2.0;
	long double B=6.0*m;
	long double now=double(abs(A-B));
	now=now*2.0*M_PI/360.0;
	now= double(cos( now));
    long double ans=a*a+b*b-2.0*a*b*now;
	ans=sqrt(ans);
	cout <<printf("%.10Lf",ans);
	// your code goes here
	return 0;
}


Measured memory_bytes: 4152
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cassert>
#include<queue>
#define rep(ii,aa,bb) for(int ii=aa;ii<=bb;ii++)
using namespace std;
typedef long long int ll;
ll n;
string s;
ll m;
ll dp[5005][5005]; //dp[i][j]表示方案i字符j
int main(){
	cin>>n>>s;
	m=s.size();
	rep(j,0,n)dp[0][j]=0;
	dp[0][0]=1;
	rep(i,1,n)rep(j,0,n){
		if(j==0)dp[i][j]=dp[i-1][j]+2*dp[i-1][j+1];else
		dp[i][j]=dp[i-1][j-1]+2*dp[i-1][j+1];
		dp[i][j]%=1000000007;
	}
//	rep(i,0,n){rep(j,0,n)printf("%4lld",dp[i][j]);printf("\n");}
	printf("%lld",dp[n][m]);
	return 0;
}


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

int main(){
  int A,B,C,D;
  cin >> A>>B>>C>>D;
  int k=A+B-C-D;
  if (k>0) cout << "Left"<<endl;
  else if (k==0) cout << "Balanced" <<endl;
  else cout << "Right"<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iostream>

using namespace std;

const int maxn = 1e5 + 5;

int h[maxn] = {0};
int dp[maxn] = {0};

int Fact(int n, int k)
{
	if(n <= 1 + k)
	{
		int min = dp[1] + abs(h[n] - h[1]);
		for(int i = 2; i < n; i++)
		{
			if(dp[i] + abs(h[n] - h[i]) < min)
			{
				min = dp[i] + abs(h[n] - h[i]);
			}
		}
		return min;
	}
	else
	{
		int min = dp[n - k] + abs(h[n] - h[n - k]);
		for(int i = n - k + 1; i < n; i++)
		{
			if(dp[i] + abs(h[n] - h[i]) < min)
			{
				min = dp[i] + abs(h[n] - h[i]);
			}
		}
		return min;
	}
}

int main()
{
	int n,k;
	scanf("%d %d",&n,&k);
	for(int i = 1; i <= n; i++)
	{
		scanf("%d",&h[i]);
	}
	for(int i = 1; i <= n; i++)
	{
		if(i == 1)
		{
			dp[i] = 0;
		}
		else if(i == 2)
		{
			dp[i] = abs(h[2] - h[1]);
		}
		else
		{
			dp[i] = Fact(i, k);
		}
	}
	printf("%d\n",dp[n]);
	return 0;
}

Measured memory_bytes: 1024
#pragma GCC optimize(2,3,"Ofast")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define in inline
#define MP make_pair
#define PB push_back
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define ROF(i,a,b) for(int i=(a);i>=(b);i--)
#define MEM(x,v) memset(x,v,sizeof(x))
namespace fast_io
{
	char buf[1<<12],*p1=buf,*p2=buf,sr[1<<23],z[23],nc;int C=-1,Z=0,Bi=0,ny;
	in char gc() {return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<12,stdin),p1==p2)?EOF:*p1++;}
	in int read()
	{
		int x=0;ny=1;while(nc=gc(),(nc<48||nc>57)&&nc!=EOF)if(nc==45)ny=-1;Bi=1;if(nc<0)return nc;
		x=nc-48;while(nc=gc(),47<nc&&nc<58&&nc!=EOF)x=(x<<3)+(x<<1)+(nc^48),Bi++;return x*ny;
	}
	in db gf() {int a=read(),y=ny,b=(nc!='.')?0:read();return (b?a+(db)b/pow(10,Bi)*y:a);}
	in int gs(char *s) {char c,*t=s;while(c=gc(),c<32);*s++=c;while(c=gc(),c>32)*s++=c;return s-t;}
	in void ot() {fwrite(sr,1,C+1,stdout);C=-1;}
	in void flush() {if(C>1<<22) ot();}
	template <typename T>
	in void write(T x,char t)
	{
		int y=0;if(x<0)y=1,x=-x;while(z[++Z]=x%10+48,x/=10);
		if(y)z[++Z]='-';while(sr[++C]=z[Z],--Z);sr[++C]=t;flush();
	}
	in void write(char *s) {int l=strlen(s);for(int i=0;i<l;i++)sr[++C]=*s++;sr[++C]='\n';flush();}
};
using namespace fast_io;
typedef pair<int,int> PII;
const int maxn=100010;
int n,a[2][18],f[18][262144],cnt[18][262144],sz[262144],ans=1e9;
int main(){
	n=read();
	FOR(i,0,n-1) a[0][i]=read();
	FOR(i,0,n-1) a[1][i]=read();
	FOR(i,0,(1<<n)-1) sz[i]=sz[i>>1]+(i&1);
	FOR(i,0,n-1) FOR(j,0,(1<<n)-1) FOR(k,0,n-1) if(((j>>k)&1) && i>k) cnt[i][j]++;
	MEM(f,0x3f);
	FOR(i,0,n-1) f[i][1<<i]=cnt[i][(1<<n)-1];
	FOR(j,1,(1<<n)-1) FOR(i,0,n-1) if((j>>i)&1){
		FOR(k,0,n-1) if(!((j>>k)&1) && a[abs(i-(sz[j]-1))%2][i]<=a[abs(k-sz[j])%2][k]){
			f[k][j|(1<<k)]=min(f[k][j|(1<<k)],f[i][j]+cnt[k][((1<<n)-1)^j]);
		}
	}
	FOR(i,0,n-1) ans=min(ans,f[i][(1<<n)-1]);
	printf("%d\n",ans==1e9?-1:ans);
}
//Author: disangan233
//In my dream's scene,I can see the everything that in Cyaegha.

Measured memory_bytes: 38144
#=$<.read.split.map(&:to_i)
N,A,B,C,D=gets.split.map(&:to_i)
S='-' + gets.chomp

def check(s)
  s !~ /##/
end

ret = if C<D
  check(S[A..B]) && check(S[C..D])
      else
  check(S[A..C]) && S[B-1..D+1] =~ /\.\.\./
end

puts (ret ? 'Yes' : 'No')


Measured memory_bytes: 2428
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long a,i;
  cin>>a;
  string s,t;
  cin>>s>>t;
  for(i=0;i<a;i++)
  {
    cout<<s[i]<<t[i];
  }
  return 0;
}


Measured memory_bytes: 256
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using lint = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main()
{
  int k,x;
  cin >> k >>x;
  for(int i=max(-1000000,x-k+1);i <= min(1000000,x+k-1);i++)cout << i << " ";
  cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x) for(long long i=0; i<x;i++)
#define mod 1000000007
#define INF 10000000000
typedef long long ll;


int main(){
  int N,W;
  cin>>N>>W;
  ll w[N],v[N];
  rep(i,N) cin>>w[i]>>v[i];
  
  ll DP[W+1];
  rep(i,W+1) DP[i] =0;
  
  rep(i,N){
    for(ll j=W;j>=0;j--){
    	if(j+w[i]<W+1){
        	DP[j+w[i]]=max(DP[j+w[i]],DP[j]+v[i]);
        }
    }
  }
  
  ll ans = 0;
  rep(i,W+1) ans= max(ans,DP[i]);
  
  cout<<ans;
  
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
const int N = 1e5+5;
const int M = 5*1e5+5;
#define pi acos(-1)
#define INF 1e10
#define INM INT_MIN
#define pb(a)  push_back(a)
#define mk(a,b) make_pair(a,b)
#define dbg(x) cout << "now this num is " << x << endl;
#define met0(axx) memset(axx,0,sizeof(axx));
#define metf(axx) memset(axx,-1,sizeof(axx));
#define sd(ax) scanf("%d",&ax)
#define sld(ax) scanf("%lld",&ax)
#define sldd(ax,bx) scanf("%lld %lld",&ax,&bx)
#define sdd(ax,bx) scanf("%d %d",&ax,&bx)
#define sddd(ax,bx,cx) scanf("%d %d %d",&ax,&bx,&cx)
#define sfd(ax) scanf("%lf",&ax)
#define sfdd(ax,bx) scanf("%lf %lf",&ax,&bx)
#define pr(a) printf("%d\n",a)
#define plr(a) printf("%lld\n",a)
int gcd(int a,int b)
{
	return b>0?gcd(b,a%b):a;
}
int main()
{
	int k;sd(k);
	LL sum = 0;
	for(int i=1;i<=k;++i)
	{
		for(int j=1;j<=k;++j)
		{
			int t1 = gcd(i,j);
			for(int m=1;m<=k;++m)
			{
				int t2 = gcd(t1,m);
				sum += t2;
			}
		}
	}
	plr(sum);
	//system("pause");
	return 0;
}

Measured memory_bytes: 3756
#include <iostream>
#include <vector>
#include <queue>

using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;

int main() {
    int N, M;
    cin >> N >> M;
    priority_queue<ll> q;
    ll el;
    REP(i, N) {
        cin >> el;
        q.push(el);
    }
    REP(i,M) {
        ll m = q.top();
        q.pop();
        m /= 2;
        q.push(m);
    }

    ll sum=0;
    REP(i,N) {
        sum += q.top();
        // cout << q.top() << endl;
        q.pop();
    }


    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 1400
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include <cmath>
#include <limits>

using namespace std;
#define int long  long int
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; }

signed main()
{
	int N;
	string S;
	cin >> N >> S;
	int cnt = 1;
	for (int i = 0; i < N - 1; i++)
	{
		if (S[i] == S[i + 1])continue;
		cnt++;
	}
	cout << cnt;
}

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

using namespace std;

int main() {
  int n;
  cin >> n;
  int x, y;
  vector<vector<pair<int, int>>> e(n);
  vector<int> res(n - 1);
  function<void(int, int, int)> dfs;
  dfs = [&](int x, int p, int c) -> void {
    set<int> used;
    used.insert(c);
    int nc = 1;
    for (auto& to : e[x]) {
      if (to.first == p) continue;
      while (used.count(nc)) nc++;
      res[to.second] = nc;
      dfs(to.first, x, nc);
      nc++;
    }
  };
  for (int i = 0; i < n - 1; i++) {
    cin >> x >> y;
    x--;
    y--;
    e[x].emplace_back(y, i);
    e[y].emplace_back(x, i);
  }
  dfs(0, -1, 0);
  int mc = 0;
  cout << *max_element(res.begin(), res.end()) << '\n';
  for (int i = 0; i < n - 1; i++) cout << res[i] << '\n';
  return 0;
}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    LL n; cin >> n;
    LL a[5];
    inc(i, 0, 5) cin >> a[i];
    LL mmin = *min_element(a, a+5);
    LL ans = (n+mmin-1)/mmin + 4;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256