akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef pair<pii,pii> P;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
typedef vector<vector<ll>> mat;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<62;
double pi=3.141592653589793238462643383279L;
double eps=1e-14;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define mrep(itr,mp) for(auto& itr:mp)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define umh unordered_map<ll,ll,custom_hash>
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll c=gcd(a,b);
    return a*b/c;
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
    now%=md;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll popcount(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}

int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    int n;cin>>n;
    ll a[n];
    rep(i,0,n)cin>>a[i];
    if(a[0]>0){
        cout<<-1<<endl;
        return 0;
    }
    ll ans=0;
    rep(i,1,n){
        if(a[i]>a[i-1]+1){
            cout<<-1<<endl;
            return 0;
        }
        else if(a[i]<a[i-1]+1){
            ans+=a[i-1];
        }
    }
    ans+=a[n-1];
    cout<<ans<<endl;
}


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

#define endl '\n'

using namespace std;

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

  string s;
  cin >> s;
  map<char, int> ans;
  for (int i = 0; i < s.length(); i++) {
    ans[s[i]]++;
  }
  if (ans.size() == 2) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef double dd;
int main()
{
    int a,b;
    cin>>a>>b;
    int n1,n2;
    n1 = ceil((dd)a/0.08);
    n2 = ceil((dd)b/0.10);
    int y = max(n1,n2);
    while(true)
    {
        int r1,r2;
        r1 = 8*y;
        r2 = y/10;
        r1 = r1/100;
        if(r1==a and r2==b)
        {
            cout<<y<<"\n";
            return 0;
        }
        else if(r1>a or r2 >b)
        {
            cout<<"-1\n";
            return 0;
        }
        else
        {
            y++;
        }
    }
    return 0;
}

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

int main()
{
	
	int N,T,a[110],amax=0,sum=0;
	
	cin >> N >> T;
	for(int i=0; i<T; i++) {
		cin >> a[i];
		amax = max(amax, a[i]);
		sum += a[i];
	}
	
	int ans = amax - (sum - amax) -1;
	if(ans < 0) ans = 0;
	cout << ans << endl;
	
	return 0;
}



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

int main(){
    int n;
    string s;
    cin >>n >>s;
    int nw=0,nb=0,nw0=0,nb0=0,ans;
    for(auto&& w:s){
        if(w=='.')nw++;
    }
    nb=s.size()-nw;
    nb0=nw;
    nw0=0; 
    ans=nb0;
    for(int i=0;i<n;i++){
        if(s[i]=='.'){
            nb0--;
        }else{
            nw0++;
        }
        ans=min(ans,nb0+nw0);
    }


    cout<<ans<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define all(V) V.begin(),V.end()
using ll = long long;

int main() {
	string S;
	cin >> S;
	if (S.size() % 2 == 1) {
		cout << "No" << endl;
		return 0;
	}
	for (int i = 0;i < S.size();i += 2) {
		if (S[i] != 'h' || S[i + 1] != 'i') {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
typedef long long LL;
using namespace std;
#define REPF( i , a , b ) for ( int i = a ; i <= b ; ++ i )
#define REP( i , n ) for ( int i = 0 ; i < n ; ++ i )
#define CLEAR( a , x ) memset ( a , x , sizeof a )
const int N=1e7;
int sum[N];
bool vis[N];
void initPrime()
{
    int num = 0, m = sqrt (N + 0.5);
    for (int i = 2; i <= m; ++i)
        if (vis[i] == 0)
            for (int j = i * i; j <= N; j += i) vis[j] = 1;
    sum[1]=0;
    for(int i=2;i<=N;i++)
    {
        if(!vis[i])  sum[i]=sum[i-1]+1;
        else   sum[i]=sum[i-1];
    }
//    for(int i=2;i<=10;i++)
//        cout<<"233  "<<sum[i]<<endl;
}
int main()
{
    int n;
    initPrime();
    while(~scanf("%d",&n))
        printf("%d\n",sum[n]);
    return 0;
}

Measured memory_bytes: 50016
#!/usr/bin/env python3
import sys


def solve(X: int):
    if X == 1:
        print(1)
        return

    res = 0
    for b in range(X):
        for p in range(2,10):
            xx =  b**p 
            if xx == X:
                print(xx)
                return
            elif xx < X:
                res = max(res,xx)
            else:
                break

    print(res)
        


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    solve(X)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
S = gets
count_T = 0
count_S = 0
S.each_char do |c|
  case c
  when 'T' then
    if count_S > 0 then
      count_S -= 1
    else
      count_T += 1
    end
  when 'S' then
    count_S += 1
  end
end

puts count_T+count_S


Measured memory_bytes: 1916
#include <iostream>
#include <vector>
#include <string>
#include <map>
using namespace std;

int main() {
    int w,h,k;
    cin >> h >> w >> k;

    vector<string> m(h);
    for (int i = 0; i < h; ++i) {
        cin >> m[i];
    }

    int ans = 0;
    for (int i = 0; i < (1 << h); ++i) {
        for (int j = 0; j < (1 << w); ++j) {
            int cnt = 0;
            for (int y = 0; y < h; ++y) {
                if (((i >> y) & 1) == 0) {
                    for (int x = 0; x < w; ++x) {
                        if (((j >> x) & 1) == 0) {
                            if (m[y][x] == '#') {
                                cnt++;
                            }
                        }
                    }
                }
            }
            if (cnt == k) ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3600
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<utility>
#include<string>
#include<utility>
#include<iomanip>
#include<bitset>
#include<math.h>
using namespace std;


int main(){

    long long l,r;
    cin >> l >> r;
    long long ans = 9223372036854775807;
    long long mod = 2019;
    for (int i = l; i < r+1; i++)
    {
        for (int j = l;  j < i; j++)
        {
            ans = min(((i%mod) * (j%mod))%mod,ans);
            if(ans == 0){
                break;
            }
        }
        if(ans == 0){
            break;
        }
    }
    cout << ans << endl;
}

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

string S;
int H,W;

int main()
{
	cin >> H >> W;
	for(int i = 0;i < H;i++)
	{
		for(int j = 0;j < W;j++)
		{
			cin >> S;
			if(S == "snuke")
			{
				cout << (char)('A' + j) << i + 1 << endl;
				return 0;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <algorithm>
#include <complex>
#include <cassert>
#include <vector>
#include <iomanip>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
using namespace std;

typedef pair<int, int> P;

int main(){
    int n;
    while (cin >> n && n){
        vector<P> v(n * 2);
        rep(i, n){
            int a, b, c, d, e, f;
            scanf("%d:%d:%d %d:%d:%d", &a, &b, &c, &d, &e, &f);
            int arive = a * 3600 + b * 60 + c;
            int leave = d * 3600 + e * 60 + f;
            v[i] = P(arive, 1);
            v[i + n] = P(leave, -1);
        }
        sort(all(v));

        int ans = 0;
        int cur = 0;
        rep(i, v.size()){
            cur += v[i].second;
            ans = max(ans, cur);
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1332
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a,b,k;
int main()
{
    scanf("%lld%lld%lld",&a,&b,&k);
    k=min(k,a+b);
    if(k<=a)
    {
        a-=k;
        printf("%lld %lld\n",a,b);
    }
    else
    {
        k-=a;
        b-=k;
        printf("%lld %lld\n",0ll,b);
    }
}


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

int all_sum(int n) {
  int sum = 0;
  while(n>0){
    sum += n%10;
    n/=10;
  }
  return sum;
};

int main() {
  int N;
  cin >> N;
  int res = 50;
  for(int i=1; i<N; i++) {
    int c = all_sum(i) + all_sum(N-i);
    res = min(res,c);
  }
  cout << res << endl;
}


Measured memory_bytes: 256
//shara's here
//SPEEEEEEEEEED IS KEEEEEEEEEEY
//REEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEAD
#include <bits/stdc++.h>
using namespace std;
typedef string s;
typedef long long ll;
typedef long double ld;
#if !defined(ONLINE_JUDGE)
#include "C:\debug.hpp"
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#define pb push_back
#define ins insert
#define vl vector<ll>
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
int main(){
    speed;
    long double x,ans=0,q=100;
    cin >> x;
    while(q<x){
        q+=(ll)(((0.01)*q));
        ans++;
    }
    cout<<ans<<endl;













return 0;}
/*
███████████████████████████████████████████████████
███████████████████████████████████████████████████
██████████████████████████████████▀████████████████
██████████████████████████████████░▀███████████████
██████████████████████████████▌███░░░▀▀████████████
██▀████████████████████▐██████░▐██░░░░░░▀▀█████████
██░████████████████████▐█████▌░██▌▄░░░░▄▄░▄████▀███
█▌░███████████████████▀░█████░░░█░░░▄████░░███▀▐███
█▌░▐██████████████████░░████▌░░░▀░░▀███▀▀░▐███▄████
██░▀██████████████▌▐█▐▄▄████▌░░░░░░░░░░░░░▌████████
███░███████████████▀░▄▄██▀█▐░░░░░░░░░░░░░░▐████████
███▄░██████████████▄░░░░░░▀▀▀░░░░░░░░░░░░░█▐███████
████▄░██████████████████▄▄▄▄▄▄▐▄░░░░░░░░░░░████████
█████▄█████████████████▀▀▀▀▀▀░░░░░░░░░░░░░░████████
████████████████████████▄░░░░░░░░░░░░░░░▄░░████████
██████████████████████████▄▄▄░░░░░░░░░▄█░▄█████████
████████████████████████████████▄░░░░██▄███▀░░▀████
█████████████████████████████▀█████▄███▀▀▀░░▄▄░████
████████████████████████████▀░░▀░░▀▀░░░░▄▄▄██▀░░▀▀█
███████████████████████████▌░░░░░░░░░░░███████░░░▄█
███████████████▄░▀████████▀░░░░░░▀░░░░███████▌░░░██
███▄▄████████████▄░▀██████▄░░░░░█░░░░████████░░░▀▀
░▀█████████████████▄░▀█████░░░░██░░░░▀██████░░░░░▄█
▐█▄▀█████████████████▄░▀████░░░██▌░░░▐████▀░░░░▄███
▐███▄▀▀█████████████████▄░▀▀░░░░▀██▌▄█▀▀░░░▄▄██████
▀▀▀▀▀░░░▀▀▀▀▀░░░▀▀▀▀▀▀▀▀▀▀▀░░░░░░░▀▀░░░░░░▀▀▀▀▀▀▀▀▀
*/


Measured memory_bytes: 3784
import sys
from pprint import pprint

def solve(a, b):
    if 1 <= a <= 9 and 1 <= b <= 9:
        print(a*b)
    else:
        print(-1)

if __name__ == '__main__':
    a, b = map(int, sys.stdin.readline().strip().split(" "))
    solve(a, b)

Measured memory_bytes: 38256
#include<stdio.h>

int main(void)
{
  int a,b,i=0,frag=0;
  char postnum[12];
  scanf("%d %d %s",&a,&b,postnum);
  while(postnum[i] != '\0')
    {
      if(postnum[i] == '-')
	{
	  frag = 1;
	  if(i != a)
	    {
	      printf("No\n");
	      return 0;
	    }
	}
      i++;
    }
  if(frag == 0)
    {
      printf("No\n");
      return 0;
    }
  if(i != a+b+1)
    {
      printf("No\n");
      return 0;
    }
  printf("Yes\n");
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  int n = s.length();
  int i,j;
  i=0;
  j=n-1;
  int ans = 0;
  while(i<j){
    if(s[i]==s[j]){
      i++;
      j--;
    }else if(s[i] == 'x'){
      i++;
      ans++;
    }else if(s[j] == 'x'){
      j--;
      ans ++;
    }else{
      ans = -1;
      break;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 512
A, B = map(int, input().split())

A -= 1

if (A+1) % 2 == 0:
    a = (A+1) // 2 % 2
else:
    a = (A // 2 % 2) ^ A

if (B+1) % 2 == 0:
    b = (B+1) // 2 % 2
else:
    b = (B // 2 % 2) ^ B
    
#print(a, b)
print(a ^ b)

Measured memory_bytes: 3060
#include<stdio.h>
int d[3000][3000]={0};
int l[3000];
int main(){
  int n,m,k,min,mi,a,b,c,max,i,j;
  double D;
  scanf("%d %d %d",&n,&m,&k);
  for(i=0;i<n;i++)l[i]=2100000000;
  while(m--){
    scanf("%d %d %d",&a,&b,&c);
    a--;
    b--;
    d[a][b]=d[b][a]=c;
  }//return 0;
  while(k--){
    char f[3000]={0};
    scanf("%d",&a);
    a--;
    l[mi=a]=0;
    for(i=0;i<n;i++){
      f[mi]=2;
      for(j=0;j<n;j++){
	if(d[mi][j]==0||f[j]==2)continue;
	if(l[j]>l[mi]+d[mi][j]){
	  l[j]=l[mi]+d[mi][j];
	  f[j]=1;
	}
      }
      min=2100000000;
      for(j=0;j<n;j++){
	if(f[j]!=1)continue;
	if(min>l[j])min=l[mi=j];
      }
      if(min==2100000000)break;
    }
  }
  for(i=max=0;i<n;i++){//printf("%d %d\n",i+1,l[i]);
    for(j=0;j<n;j++){
      if(i==j)continue;//printf("%d %d\n",l[i],l[mi]);
      D=(d[i][j]+l[i]+l[j])/2.0+0.5;//printf("%f\n",D);
      if(max<D)max=D;
    }
  }
  printf("%d\n",max);
  return 0;
}
  

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

using namespace std;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    int n;
    int a, b;
    int l1 = 0, l2 = 0, l3 = 0;
    cin >> n >> a >> b;
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        if(x <= a) l1++;
        else if(x > b) l3++;
        else l2++;
    }
    cout << min(l1, min(l2, l3));
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int a, b;
    scanf("%d %d", &a, &b);
    
    if(a<b){
        printf("a < b\n");
    }else if(a>b){
        printf("a > b\n");
    }else if(a==b){
        printf("a == b\n");
    }
    
    return 0;
}


Measured memory_bytes: 2044
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define int long long
#define pi 3.141592653589793238462643383279502
#define M 1000000007
#define F first
#define S second
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
bool isPowerOfTwo(int n)
{
   if(n==0)
   return false;

   return (ceil(log2(n)) == floor(log2(n)));
}
int power(int x, unsigned int y, int p)
{
    int res = 1;

    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;

        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
bool isprime(int x)
{
      if(x<2)
        return false;
    for(int i=2;i*i<=x;i++)
     {
        if (x%i==0)
            return false;
    }
    return true;
}

void solve()
{
int x,y,z;
cin>>x>>y>>z;
cout<<z<<" "<<x<<" "<<y;

}

signed main()
{ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int t;
//cin>>t;
t=1;
while(t--)
{
  solve();
}
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T>bool even(T n) { return ! (n & 1); }
template<class T>bool odd(T n) { return n & 1; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;}
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll A, B, C;
        cin >> A >> B >> C;
        vll abc = {A, B, C};

        ll ans = 0;
        while (true) {
                if (abc[0] == abc[1] and abc[1] == abc[2]) {
                        --ans;
                        break;
                }
                if (abc[0]+2 == abc[1] and abc[1] == abc[2]) break;
                if (abc[0] == abc[1]+2 and abc[1]+2 == abc[2]) break;
                if (abc[0] == abc[1] and abc[1] == abc[2]+2) break;
                *min_element(all(abc)) += 1;
                *min_element(all(abc)) += 1;       
                ++ans;         
        }
        ++ans;
        cout << ans << endl;
}


Measured memory_bytes: 3580
stdin.ReadLine()
|> fun x -> x.Split() |> Array.map int |> fun x -> (x.[0], x.[1])
|> fun (n, q) ->
  (
    List.init (n - 1) (fun _ -> stdin.ReadLine() |> fun x -> x.Split() |> Array.map int |> fun x -> (x.[0], x.[1])),
    List.init q       (fun _ -> stdin.ReadLine() |> fun x -> x.Split() |> Array.map int |> fun x -> (x.[0], x.[1]))
  )
  |> fun (nabs, qpxs) ->
    (
      (
        (Array.create (n + 1) [])
        |> fun (edges: int list array) ->
          nabs
          |> List.iter (
            fun  (a, b) ->
              (
                (edges.[a] <- b::edges.[a]),
                (edges.[b] <- a::edges.[b])
              )
              |> ignore
          )
          |> fun () -> edges
      ),
      (
        (Array.zeroCreate (n + 1))
        |> fun (points: int array) ->
          qpxs
          |> List.iter (
            fun (p, x) ->
              (points.[p] <- points.[p] + x)
          )
          |> fun () -> points
      )
    )
  |> fun (edges, points) ->
    (
      [| [(0, 1)] |],
      Array.concat [ [| 0 |]; Array.create (n) (-1) ]
    )
    |> fun ((stack: (int * int) list array), (ret: int array)) ->
      Seq.initInfinite (
        fun _ ->
          match stack.[0] with
          | [] -> ()
          | (pi, ci)::ts ->
            (ret.[ci] <- ret.[pi] + points.[ci])
            |> fun () ->
              match edges.[ci] with
              | [] -> (stack.[0] <- ts)
              | cs ->
                cs
                |> List.filter ((<>) pi)
                |> List.map (fun i -> (ci, i))
                |> fun hs -> (stack.[0] <- (hs @ ts))
      )
      |> Seq.takeWhile (fun _ -> stack.[0] |> List.isEmpty |> not)
      |> Seq.length
    |> fun _ -> ret
|> fun ret ->
  ret
  |> Array.skip 1
  |> Array.map string
  |> String.concat " "
|> printfn "%s"


Measured memory_bytes: 104012
#include <bits/stdc++.h>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
typedef pair<int,int>P;

int n,m;
int dp[444];
vector<P>v[444];

int dfs(int now){

  if(dp[now])return dp[now];
  
  int res=0;
  
  r(i,v[now].size()){
    int nex=v[now][i].first;
    int cost=v[now][i].second;
    res=max(res,dfs(nex)+cost);
  }
  return dp[now] = res;
}

int main(){

  cin>>n>>m;

  r(i,m){
    int a,b,c;
    cin>>a>>b>>c;
    v[a].push_back(P(b,c));
  }

  cout<< dfs(0) <<endl;
}




Measured memory_bytes: 3128
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi M_PI
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    int n, w, h, s, t;
    while (cin >> n && n){
        cin >> w >> h;
        VVI f(w,VI(h));
        while (n--){
            int i, j;
            cin >> i >> j;
            f[i-1][j-1] = 1;
        }
        cin >> s >> t;
        int ans = 0;
        REP(i,w+1-s) REP(j,h+1-t){
            int p = 0;
            FOR(x,i,i+s-1) FOR(y,j,j+t-1) p += f[x][y];
            ans = max(ans, p);
        }
        cout << ans << endl;
    }
    return 0;
}

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

using namespace std;

int main(void) {
    int a,b,i,n,c=1;
    string s;
    cin >> n;
    cin >> s;
    for(i=1;i<n;i++){
        if(s[i] != s[i-1])
            c++;
    }
    cout << c << endl;
   return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
     
    int main(){
       int X,Y;
       scanf("%d %d",&X,&Y);
       if(Y<2*X||4*X<Y){
          printf("No\n");
       }else if(Y%2==1){
          printf("No\n");
       }else{
          printf("Yes\n");
       }
       return 0;
    }
       

Measured memory_bytes: 1588
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define TO_STRING(a) #a
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }
template<class T> void MSG(T a){ cout << TO_STRING(a) << " = " << a << endl; }



int main()
{
	int n;
	cin >> n;
	
	vint score(n, 0);
	
	rep(i, n*(n-1)/2)
	{
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		
		score[a-1] += (c > d ? 3 :(c == d ? 1 : 0));
		score[b-1] += (c < d ? 3 :(c == d ? 1 : 0));
	}
	
	rep(print, n)
	{
		int rank = 1;
		rep(over, n)
		if(score[print] < score[over])
			rank++;
		
		cout << rank << endl;
	}
}

Measured memory_bytes: 0
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(int i = 0; i < n; i++)




int main() {
    int a,b,c,i;
    scanf("%d",&a);
    a=a*100;
    scanf("%d",&b);
    b=b*10;
    scanf("%d",&c);
    i=a+b+c;
    if(i%4==0){
        printf("YES");
    }else{
        printf("NO");
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
#define RF(x) freopen(x,"r",stdin)
#define WF(x) freopen(x,"w",stdout)
typedef long long LL;
using namespace std;
typedef pair<LL,LL> PLL;
typedef pair<int,int> PII;
const LL MOD = 1e9+7;
const int SIZE = 1e6+5;
const LL INF = 1LL<<60;
const double eps = 1e-4;
const double PI=3.1415926535897932;

int p[20009];
int v[20009];
int a[20009],b[20009];

int main(){
	DRI(n);
	REP(i,n){
		RI(p[i]);p[i]--;
		v[p[i]]=i;
	}
	a[0]=1,b[0]=v[0]-a[0];
	REPP(i,1,n){
		a[i]=max(a[i-1]+1,v[i]-(b[i-1]-1));
		b[i]=v[i]-a[i];
	}
	REP(i,n){
		a[i]+=MOD/2;
		b[i]+=MOD/2;
	}
	REP(i,n)printf("%d ",a[i]);puts("");
	REP(i,n)printf("%d ",b[i]);
}


Measured memory_bytes: 896
function Main(input) {
    var aryMin = function (a, b) {return Math.min(a, b);}
    
    input = input.trim().split("\n").map(function(x) { return x.split(" ")});

    let N = parseInt(input[0][0], 10);
    let K = parseInt(input[0][1], 10);
    let v_h = input[1].map(e => parseInt(e, 10));

    let DP = [];

    for (let i = 0; i < K; i++){
        DP.push(Math.abs(v_h[0] - v_h[i]));
    }

    let x = [];
    for(let i = K; i < N; i++){
        for (let j = 0; j < K; j++){
            x[j] = DP[i - K + j] + Math.abs(v_h[i] - v_h[i - K + j]);
        }
        DP.push(x.reduce(aryMin));
    }

    console.log(DP[N - 1]);

}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 41348
#include<bits/stdc++.h>
#ifndef LOCAL_PROJECT
#define cerr if(0)cerr
#endif
using namespace std;
typedef pair<int,int>pii;
typedef long long ll;
typedef pair<ll,ll> pll;
mt19937 rng(chrono::system_clock::now().time_since_epoch().count());
const int mn=1e3+10;
const ll inf=0x3f3f3f3f3f3f3f3f;
const ll mod=998244353;
#define mid ((l+r)>>1)
string s[6];
int main(){
#ifdef LOCAL_PROJECT
    freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
#else
    cin.tie(0);
    cin.sync_with_stdio(0);
#endif
    int n,m,k;
    cin>>n>>m>>k;
    for(int i=0;i<n;i++)cin>>s[i];
    int ans=0;
    for(int i=0;i<1<<n;i++)for(int j=0;j<1<<m;j++){
        int sc=0;
        for(int ii=0;ii<n;ii++)if((i>>ii)&1){
            for(int jj=0;jj<m;jj++)if((j>>jj)&1){
                sc+=s[ii][jj]=='#';
            }
        }
        cerr<<sc<<endl;
        ans+=sc==k;
    }
    printf("%d",ans);
}

Measured memory_bytes: 3796
#include<bits/stdc++.h>
#define Fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Freed freopen ("0in.txt","r",stdin);
#define Fout freopen ("0out.txt","w",stdout);
#define ll long long int
#define pb push_back
#define mp make_pair
#define pi acos(-1.0)
#define Mod 1000000007
#define limit 200008
using namespace std;
vector <int> g[limit];
bool vis[limit];
int ct;
void bfs(int u)
{
    vis[u]=1;
    ct++;
    queue<int> qu;
    qu.push(u);
    while(!qu.empty())
    {
        u = qu.front();
        qu.pop();
        for(int i=g[u].size()-1; i>=0; i--)
        {
            int v = g[u][i];
            if(vis[v]==0)
            {
                ct++;
                vis[v]=1;
                qu.push(v);
            }
        }
    }
}
void solve(int t)
{
    int i,j,n,m,u,v,ans=0;
    cin >> n >> m;
    for(i=0; i<m; i++)
    {
        cin >> u >> v;
        g[u].pb(v);
        g[v].pb(u);
    }
    for(i=1; i<=n; i++)
    {
        ct = 0;
        if(vis[i]==0)
            bfs(i);
        ans = max(ans,ct);
    }
    cout <<ans <<endl;
    return ;
}
int  main()
{
//    Fast
//    Freed
//    Fout
    int t,tt=1;
  //  cin >> tt;
    for(t=1; t<=tt; t++)
        solve(t);
  return 0;
}



Measured memory_bytes: 15296
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
def A():
    a,b,c,d = IR(4)
    print(min(a,b)+min(c,d))

#B
def B():
    n = I()
    d,x = LI()
    a = IR(n)
    for i in range(1,d+1):
        for j in a:
            if (i-1)%j == 0:
                x += 1
    print(x)
#C
def C():
    n = I()
    a = LI()
    ans = abs(a[0])
    for i in range(n-1):
        ans += abs(a[i+1]-a[i])
    ans += abs(a[-1])
    a.insert(0,0)
    a.append(0)
    for i in range(1,n+1):
        if a[i-1] <= a[i] <= a[i+1] or a[i+1] <= a[i] <= a[i-1]:
            print(ans)
        else:
            print(ans-abs(a[i]-a[i-1])-abs(a[i+1]-a[i])+abs(a[i+1]-a[i-1]))
#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == "__main__":
    C()


Measured memory_bytes: 64156
import java.util.Scanner;

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

        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        if (a == b) {
            System.out.println(c);
        } else if (b == c) {
            System.out.println(a);
        } else {
            System.out.println(b);
        }
    }
}

Measured memory_bytes: 22228
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

int main(){
  string s;
  cin >> s;
  
  bool all_same = true;
  rep(i,s.size()-1){
    if(s[i]!=s[i+1]) all_same = false;
  }
  if(all_same){
    cout << s.size() << endl;
    return 0;
  }
  
  int cnt = s.size() / 2;
  char center = s[cnt];
  bool chk = true;
  while(chk){
    if(s[cnt] != center || s[s.size()-1-cnt] != center || cnt == s.size()-1){
      chk = false;
    }else{
      cnt++;
    }
  }
  cout << cnt << endl;
  
  return 0;
}

Measured memory_bytes: 512
N, A, B = map(int, input().split())

c = N // (A + B)

if (A == 0):
    print(0)
    exit()
if (N <= A):
    print(N)
    exit()
elif (N <= (A + B)):
    print(A)
    exit()

if (A + B) * c < N:
    if (N - (A + B) * c <= A):
        print(A * c + N - (A + B) * c)
    elif(N - (A + B) * c > A):
        print(A * c + A)
elif (A + B) * c == N:
    print(A * c)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <cstdio>
using namespace std;
int main()
{
       ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);int n;
       char c;
       cin >> c;
       if (isupper(c))cout << "A" << endl;
       else cout <<"a" << endl;
	return 0;
}



Measured memory_bytes: 3636
# -*- coding: utf-8 -*-
import sys
from operator import itemgetter
from fractions import gcd
from math import ceil, floor, sqrt
from copy import deepcopy
from collections import Counter, deque
import heapq
from functools import reduce
sys.setrecursionlimit(200000)
# local only
# if not __debug__:
#     fin = open('in_1.txt', 'r')
#     sys.stdin = fin
# local only
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())
def debug(*args, sep=" ", end="\n"): print("debug:", *args, file=sys.stderr, sep=sep, end=end) if not __debug__ else None
def exit(*arg): print(*arg); sys.exit()
# template


def main():
    N, K = mi()
    S = li()
    count = 1
    ss = []
    for i in range(N):
        if i == N - 1:
            ss.append((S[i], count))
            break
        if S[i] == S[i + 1]:
            count += 1
        if S[i] != S[i + 1]:
            ss.append((S[i], count))
            count = 1
    # print(ss)
    cntL = 0
    cntR = 0
    for s, i in ss:
        if s == "L":
            cntL += 1
        else:
            cntR += 1
    # print(cntL, cntR)
    if K >= min(cntL, cntR):
        print(N - 1)
    else:
        print(N - len(ss) + 2 * K)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 13328
#include <iostream>

class Node {
public:
	int key;
	Node* left;
	Node* right;
	Node* parent;
	Node() {left = right = parent = NULL;}
	Node(int key) { this->key = key; left = right = parent = NULL;}
	~Node(){}
};

void insert(Node** T, Node* z)
{	
	Node* y = NULL;
	Node* x = *T; // address of root
	while ( x != NULL ) {
		y = x;
		if (z->key < x->key) x = x->left;
		else x = x->right;
	}
	z->parent = y;
	
	if ( y == NULL ) *T = z; // T is empty
	else {
		if (z->key < y->key) {
			y->left = z; //std::cout << z << "is a LEFT child of " << y << std::endl;
		}
		else {
			y->right = z; //std::cout << z << "is a RIGHT child of " << y << std::endl;
		}
	}
}

void walk_preorder(Node* T)
{
	std::cout << " " << T->key;
	if (T->left != NULL) walk_preorder(T->left);
	if (T->right != NULL) walk_preorder(T->right);
}

void walk_inorder(Node* T)
{
	if (T->left != NULL) walk_inorder(T->left);
	std::cout << " " << T->key;
	if (T->right != NULL) walk_inorder(T->right);
}

void deleteNodes(Node* x)
{
	if (x->left != NULL) deleteNodes(x->left);
	if (x->right != NULL) deleteNodes(x->right);
	delete x;
}
	
int main()
{
	int n;
	std::cin >> n;
	
	char dummy;
	std::cin >> dummy; // to avoid \n
	
	Node* BST = NULL;
	
	for (int i=0; i<n; i++) {
		//std::cout << BST << std::endl;
		std::string buf;
		getline(std::cin, buf);
		int pos = buf.find(' ', 0);
		if (pos == std::string::npos) {
			// print
			walk_inorder(BST); std::cout << std::endl;
			walk_preorder(BST); std::cout << std::endl;
		}
		else { // insert
			int key = std::stoi(buf.substr(pos+1));
			Node* z = new Node(key);
			//std::cout << "node " << i << ": " << z << std::endl;
			insert(&BST, z);
		}
	}
	
	deleteNodes(BST);
	
	return 0;
}



Measured memory_bytes: 26592
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,i;
	string str,s1,s2;
	cin >> n;
	cin >> s1 >> s2;
	i=0;
	while(i<n)
	{
		str.push_back(s1[i]);
		str.push_back(s2[i]);
		i++;
	}
	cout << str << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define check system("pause")
#define all(x) (x).begin(),(x).end()
#define de(a) cout<<#a<<" = "<<a<<endl
#define dd(a) cout<<#a<<" = "<<a<<" "
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF 0x3f3f3f3f
const ll mod = 998244353;
const int N = 6e3+20;
#define dep(i,a,b) for(int i=(a);i>=(b);i--)
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define mes(p,b) memset(p,b,sizeof(p))
#define sz(x) int(x.size())
int n,w;ll dp[N][N],a;
int main()
{
  	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	cin>>n>>w;
	dp[0][0]=1;
	rep(i,1,n){
		cin>>a;
		rep(j,0,w){
			if(j>=a)
			dp[i][j]=dp[i-1][j-a]+dp[i-1][j]*2;
			else
			dp[i][j]=dp[i-1][j]*2;
			dp[i][j]%=mod;
		}
	}
	cout<<dp[n][w];
  	return 0;
}



Measured memory_bytes: 85888
N = gets.to_i
lists = {}
# binding.pry
(N-1).times do
  s, t = gets.split.map(&:to_i)
  (lists[s-1] ||= []) << t-1
  (lists[t-1] ||= []) << s-1
end
# p lists

check = Array.new(N)
check[0] = "blue"
queue = [] << 0
# binding.pry
while !queue.empty?
  now = queue.shift
  lists[now].each do |to|
    if !check[to]
      case check[now]
      when "blue"
        color = "red"
      when "red"
        color = "blue"
      end
      check[to] = color
      queue << to
    end
  end
end
# puts check
b_count = check.count("blue")
r_count = N - b_count
cnt1 = 0
cnt2 = 0
cnt3 = 1

if b_count > N / 3 && r_count > N / 3
  N.times do |i|
    if check[i] == "blue"
      if cnt1 * 3 + 1 <= N
        print "#{cnt1 * 3 + 1} "
        cnt1 += 1
      elsif cnt3 * 3 <= N
        print "#{cnt3 * 3} "
        cnt3 += 1
      else
        raise "error"
      end
    else
      if cnt2 * 3 + 2 <= N
        print "#{cnt2 * 3 + 2} "
        cnt2 += 1
      elsif cnt3 * 3 <= N
        print "#{cnt3 * 3} "
        cnt3 += 1
      else
        raise "error"
      end
    end
  end
else
  if b_count <= N / 3
    pre = "blue"
  elsif r_count <= N / 3
    pre = "red"
  end
  N.times do |i|
    if check[i] == pre
      if cnt3 * 3 <= N
        print "#{cnt3 * 3} "
        cnt3 += 1
      else
        raise "error"
      end
    else
      if cnt1 * 3 + 1 <= N
        print "#{cnt1 * 3 + 1} "
        cnt1 += 1
      elsif cnt2 * 3 + 2 <= N
        print "#{cnt2 * 3 + 2} "
        cnt2 += 1
      elsif cnt3 * 3 <= N
        print "#{cnt3 * 3} "
        cnt3 += 1
      else
        raise "error"
      end
    end
  end
end
puts

Measured memory_bytes: 57724
#include <iostream>

using namespace std;
int main(int argc, char *argv[]) {
	int n;
	cin >> n;
	int v[n];
	int c[n];
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> c[i];
	}
	
	int ans = 0;
	for (int i = 0; i < n; i++) {
		ans += max(v[i] - c[i], 0);
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<queue>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int a,b,c;
int main()
{
	scanf("%d",&a);
	c=a;
	while (a!=0)
	{
		b+=a%10;
		a=a/10;
	}
	if (c%b==0) printf("Yes");
	    else printf("No");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl

typedef long long ll;
typedef long double ld;
using namespace std;

const int MOD = 1e9 + 7;

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string s;
  cin >> s;
  if(s == "Sunny")
  {
    cout << "Cloudy";
  }
  else if(s == "Cloudy")
  {
    cout << "Rainy";
  }
  else
  {
    cout << "Sunny";
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ar array
#define AC ios_base::sync_with_stdio(0);
const int M = 1e9+7;
using namespace std;

int main(){
    AC
    int n;
    ll d;
    cin>>n>>d;
    d = d*d;
    int ans = 0;
    for(int i=0; i<n; i++){
        ll x, y;
        cin>>x>>y;
        if(x*x+y*y <= d)
            ans++;
    }
    cout<<ans<<endl;
}

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

using namespace std;

int a, b, c;
int ans = 0;

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

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int N = sc.nextInt();

System.out.println((int)Math.sqrt(N)*(int)Math.sqrt(N));

	}

	//以下、自作ライブラリ

	//最大公約数
	public static long gcd(long a, long b) {
		if (a < b)
			return gcd(b, a);
		long c = 0;
		c = a % b;
		if (c == 0)
			return b;
		return gcd(b, c);
	}

	//最小公倍数
	public static long lcm(long m, long n) {
		return m * n / gcd(m, n);
	}

	//素数判定
	public static boolean isPrime(int n) {
		if (n < 2)
			return false;
		if (n == 2)
			return true;
		if (n % 2 == 0)
			return false;

		for (int i = 3; i * i <= n; i += 2) {
			if (n % i == 0)
				return false;
		}
		return true;
	}
}

//以下、高速スキャナークラス
class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 21204
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr ll  MOD = (1e9+7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int lcm(int a, int b) { return a / gcd(a, b) * b; }

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;
}
ll factorial(ll n, ll m=2) {
    // calculate n!
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n, m; cin >> n >> m;
    ll s = 0;
    rep(i, m) {
        ll tmp; cin >> tmp;
        s += tmp;
    }
    ll ans = (n-s >= 0) ? n-s : -1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3652
import heapq


def dijkstra(s):
    inf=float("inf")
    color=["white" for _ in range(n)]
    D=[inf for _ in range(n)]

    M=[[] for _ in range(n)]
    for a,b,c in ABC:
        M[a-1].append([b-1,c])
        M[b-1].append([a-1,c])

    D[s]=0

    H=[(0,s)]
    heapq.heapify(H)

    while len(H)>=1:
        u=heapq.heappop(H)[1]
        if color[u]=="black":continue
        color[u]="black"

        V=[(i,j) for i,j in M[u] if color[i]!="black"]
        while len(V)!=0:
            for i,j in V:
                if D[u]+j<D[i]:
                    D[i]=D[u]+j
                    color[i]="gray"
                    heapq.heappush(H,(D[i],i))
            break

    return D


n=int(input())
ABC=[list(map(int,input().split())) for _ in range(n-1)]
q,k=map(int,input().split())
XY=[list(map(int,input().split())) for _ in range(q)]
D=dijkstra(k-1)
for x,y in XY:
    print(D[x-1]+D[y-1])

Measured memory_bytes: 126680
#include <bits/stdc++.h>
using namespace std;
#define finish(x) reutrn cout << x << endl, 0;
#define ll long long

int n, x, y, dp[100001][2], mod = 1e9 + 7;
vector <int> v[100001];

void dfs(int node, int pnode){
    for(auto &i : v[node])
        if(i != pnode)
            dfs(i, node);
    dp[node][1] = 1;
    for(auto &i : v[node])
        if(i != pnode)
            dp[node][1] = 1LL * dp[node][1] * dp[i][0] % mod;
    dp[node][0] = 1;
    for(auto &i : v[node])
        if(i != pnode)
            dp[node][0] = 1LL * dp[node][0] * (dp[i][0] + dp[i][1]) % mod;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    for(int i = 0 ; i < n - 1 && cin >> x >> y ; i++)
        v[x].push_back(y), v[y].push_back(x);
    dfs(1, 0);
    cout << (dp[1][0] + dp[1][1]) % mod << endl;
}


Measured memory_bytes: 13440
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define rep(n, i) Rep(0, n-1, i)

typedef long long ll;
typedef pair<int, int> P;
typedef std::priority_queue<int> IntPrioQueue; //Z->A
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue; //A->Z


const int MAX = 100010;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const int MOD = 1000000007;

int rel[MAX];
vector <P> G[MAX];
bool men[MAX];
bool dfs(int v){
    bool flag = true;
    rep(G[v].size(), i) {
        if (rel[G[v][i].first] == INF) {
            rel[G[v][i].first] = rel[v] + G[v][i].second;
            flag = flag and dfs(G[v][i].first);
        }
        else flag = flag and (rel[G[v][i].first] == rel[v] + G[v][i].second);
    }
    return flag;
}

void solve(void){
    int N, M;
    cin >> N >> M;
    rep(N, i) rel[i] = INF;
    bool flag = true;
    rep(M, i) {
        int l, r, d;
        scanf("%d %d %d\n", &l, &r, &d);
        l--;r--;
        G[l].push_back(P(r, d));
        G[r].push_back(P(l, -d));
        men[l] = men[r] = true;
    }
    rep(N, i) {
        if (men[i] and rel[i] == INF) {
            rel[i] = 0;
            flag = flag and dfs(i);
        }
    }
    cout << (flag?"Yes":"No") << '\n';
}

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


Measured memory_bytes: 12032
#include<iostream>
#include<string>
using namespace std;
struct Dice{
  int s[6];
  void roll(char c){
    int b;
    if(c=='E'){
      b=s[0];
      s[0]=s[3];
      s[3]=s[5];
      s[5]=s[2];
      s[2]=b;
    }
    if(c=='W'){
      b=s[0];
      s[0]=s[2];
      s[2]=s[5];
      s[5]=s[3];
      s[3]=b;
    }
    if(c=='N'){
      b=s[0];
      s[0]=s[1];
      s[1]=s[5];
      s[5]=s[4];
      s[4]=b;
    }
    if(c=='S'){
      b=s[0];
      s[0]=s[4];
      s[4]=s[5];
      s[5]=s[1];
      s[1]=b;
    }
  }
  int top() {
    return s[0];
  }
};
int main(){
  Dice d;
  for(int i=0;i<6;i++) cin >> d.s[i];
  string s;cin >> s;
  for(int i=0;i<s.size();i++) d.roll(s[i]);
  cout << d.top() << endl;
  return 0;
}


Measured memory_bytes: 3144
# https://atcoder.jp/contests/abs/tasks/abc083_b



N, A, B = gets.split.map(&:to_i)

ans = 0
1.upto(N) do |i|
  sum = i.to_s.chars.inject(0) { |result, char| result + char.to_i }
  ans += i if sum >= A && sum <= B
end

puts ans


Measured memory_bytes: 1788