akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep2(i, m, n) for (int i = (m); i < (n); ++i)
#define rep(i, n) rep2(i, 0, n)
#define all(a) (a).begin(), (a).end()
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline int sz(T &x) { return x.size(); }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
const int INF  = 1<<30;


struct item {
  int v, w;
  bool operator<(const item &r) const { return w < r.w; }
  void operator+=(const item &r) { w += r.w, v += r.v; }
};


vector<item> enum_powerset(const vector<item> &is) {
  vector<item> a = {{0, 0}};
  vector<item> c;
  a.reserve(1<<sz(is));
  c.reserve(1<<sz(is));
  for (auto &i : is) {
    auto b = a;
    for (auto &e : b) e += i;
    merge(all(a), all(b), back_inserter(c));
    swap(a, c);
    c.clear();
  }
  return a;
}


int solve(const vector<item> &is, int W) {
  int n = sz(is);
  auto a = enum_powerset({is.begin(), is.begin() + n/2});
  auto b = enum_powerset({is.begin() + n/2, is.end()});
  reverse(all(a));
 
  int ans = 0;
  int vbmax = -INF;
  auto itr = b.begin();
  for (auto &[va, wa] : a) {
    while (itr != b.end() && wa + itr->w <= W) {
      chmax(vbmax, itr->v);
      ++itr;
    }
    chmax(ans, va + vbmax);
  }
  return ans;
}


int main() {
  int n; cin >> n;
  vector<item> is(n);
  for (auto &[v, w] : is) cin >> v >> w;
  is.insert(is.begin(), {0, 0});

  int q; cin >> q;
  rep(_, q) {
    int v, l; cin >> v >> l;
    vector<item> qi;
    while (v) {
      qi.push_back(is[v]);
      v /= 2;
    }
    cout << solve(qi, l) << '\n';
  }
}


Measured memory_bytes: 7392
#include <iostream>
#include <string>

using namespace std;

int main(void){
  while(1){
    int n;
    cin >> n;
    if(n == 0){return 0;}

    string tmp;
    int w[n];
    for(int i = 0 ; i < n ; i++){
      cin >> tmp;
      w[i] = tmp.length();
    }

    int ans = -1;

    for(int i = 0 ; i < n - 4 ; i++){
      int  cur = i;
      bool istanku = true;

      int sum = 0;
      for(int j = 0 ; cur + j < n ; j++){
        sum += w[cur + j];
        if(sum == 5){
          cur = i + j + 1;
          break;
        }else if(sum > 5){
          istanku = false;
        }
      }

      if(istanku == true){
        sum = 0;
        for(int j = 0 ; cur + j < n ; j++){
          sum += w[cur + j];
          if(sum == 7){
            cur = cur + j + 1;
            break;
          }else if(sum > 7){
            istanku = false;
          }
        }
      }

      if(istanku == true){
        sum = 0;
        for(int j = 0 ; cur + j < n ; j++){
          sum += w[cur + j];
          if(sum == 5){
            cur = cur + j + 1;
            break;
          }else if(sum > 5){
            istanku = false;
          }
        }
      }

      if(istanku == true){
        sum = 0;
        for(int j = 0 ; cur + j < n ; j++){
          sum += w[cur + j];
          if(sum == 7){
            cur = cur + j + 1;
            break;
          }else if(sum > 7){
            istanku = false;
          }
        }
      }

      if(istanku == true){
        sum = 0;
        for(int j = 0 ; cur + j < n ; j++){
          sum += w[cur + j];
          if(sum == 7){
            cur = cur + j + 1;
            break;
          }else if(sum > 7){
            istanku = false;
          }
        }
      }

      if(istanku == true){
        ans = i + 1;
        break;
      }
    }

    cout << ans << endl;

  }
}

Measured memory_bytes: 3144
#!/usr/bin/env python
# -*- coding: utf-8 -*-

a,b,c,d = map(int, input().split())

def canTalk(x, y, d):
  return abs(x-y) <= d

if canTalk(a, c, d):
  print("Yes")
else:
  if canTalk(a, b, d) and canTalk(b, c, d):
    print("Yes")
  else:
    print("No")


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

int main() {
    int n, m, num, ans = 0;
    cin >> n >> m;
    vector<pair<int, int> >V(m);
    rep(i, m) {
        cin >> V[i].second >> V[i].first;
    }
    sort(V.begin(), V.end());
    int b = -1;
    rep(i, m) {
        if (b <= V[i].second) {
            ans++;
            b = V[i].first;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define mod 1000000007

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k;
    cin>>n>>k;
    ll ans=0;
    for(ll i=k;i<=n+1;i++)
    {
        ll mn=(i-1)*i;
        mn=mn/2;
        ll mx=n*(n+1)-(n-i)*(n-i+1);
        mx=mx/2;
        ans+=mx-mn+1;
        ans=ans%mod;
    }

    cout<<ans<<endl<<endl;

    return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define mo 1000000007
#define pi 3.1415926535898
#define eps 1e-9 
using namespace std;
long long read(){
    long long xx=0,flagg=1;
    char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-')
        ch=getchar();
    if(ch=='-'){
        flagg=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        xx=xx*10+ch-'0';
        ch=getchar();
    }
    return xx*flagg;
}
void pus(long long xx,long long flagg){
    if(xx<0){
        putchar('-');
        xx=-xx;
    }
    if(xx>=10)
        pus(xx/10,0);
    putchar(xx%10+'0');
    if(flagg==1)
        putchar(' ');
    if(flagg==2)
        putchar('\n');
    return;
}
long long n,q,top,i,zhan[100005],cf[100005],x,l,r,mid,max1,sum[100005];
int main(){
	//freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
    n=read();q=read();
    top=1;
    zhan[top]=n;
    for(i=1;i<=q;i++){
    	x=read();
		while(zhan[top]>=x)
			top--;
		top++;
		zhan[top]=x;
	}
	cf[top]=1;
	for(i=top;i>=1;i--){
		max1=i;
		x=zhan[i];
		while(max1!=0){
			l=1;r=max1-1;mid=(l+r>>1);max1=0;
			while(l<=r){
				if(zhan[mid]<=x){
					max1=max(max1,mid);
					l=mid+1;
				}
				else
					r=mid-1;
				mid=(l+r>>1);
			}
			if(max1==0){
				sum[x]+=cf[i];
				break;
			}
			cf[max1]+=(x/zhan[max1])*cf[i];
			x=x%zhan[max1];
		}
		cf[i]=0;
	}
	for(i=n;i>=1;i--)
		sum[i]+=sum[i+1];
	for(i=1;i<=n;i++)
		pus(sum[i],2);
    return 0;
}

Measured memory_bytes: 4096
x1, x2, x3, x4, x5 = map(int, input().split())
if(x1 == 0):
	print(1)
elif(x2 == 0):
	print(2)
elif(x3 == 0):
	print(3)
elif(x4 == 0):
	print(4)
else:
	print(5)

Measured memory_bytes: 9052
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>

using namespace std;

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  string s1,s2,s3;
  cin >> s1 >> s2 >> s3;

  transform(s1.begin(), s1.end(), s1.begin(), ::toupper);
  transform(s2.begin(), s2.end(), s2.begin(), ::toupper);
  transform(s3.begin(), s3.end(), s3.begin(), ::toupper);

  cout << s1[0] << s2[0] << s3[0] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define sz(v) (int)(v).size()

using namespace std;

typedef long long ll;
typedef long double ld;

using P = pair<int, int>;

static const long long MOD = 1000000007;
static const long long LINF = (ll)(1e18+99);
static const int INF = 1e9+99;

int ans;

int main(void) {
    int x;
    cin >> x;
    if (x>=30) puts("Yes");
    else puts("No");

    return 0;
}



Measured memory_bytes: 3640
PROGRAM YYMMorMMYY
      IMPLICIT NONE
      integer :: ant,post
      
      read'(i2i2)',ant,post
      
      
      if( 1<=ant.and.ant<=12 )then
        if( 1<=post.and.post<=12 )then
          print*,'AMBIGUOUS'
        else
          print*,'MMYY'
        end if
      else
        if( 1<=post.and.post<=12 )then
          print*,'YYMM'
        else
          print*,'NA'
        end if
      end if
      
      
      
      END PROGRAM

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define fr first
#define ii pair<ll,ll>
#define sc second
#define mp make_pair
#define All(v) v.begin(),v.end()
using namespace std;
int main()
{
   int n;
   cin>>n;
   int a[n];
   int ans = 0;
   int minx[10];
   for(int i=0;i<10;i++)
    minx[i] = 1e9;
   for(int i=0;i<n;i++)
   {
       cin>>a[i];
       minx[a[i]%10] = min(minx[a[i]%10] , a[i]);
       ans+=a[i];
   }
   if(ans%10 == 0)
   {
       int ma = 1e9;
       for(int i=1;i<=9;i++)
       {
           ma = min(ma , minx[i]);
       }
       if(ma == 1e9)
       {
           cout<<0;
       }
       else
        cout<<ans-ma<<endl;
   }
   else 
    cout<<ans<<endl;
}


Measured memory_bytes: 256
N,M = map(int,input().split())
C = [input().split() for m in range(M)]

for n in range(1000):
  n = str(n)
  if len(n)==N:
    for s,c in C:
      if n[int(s)-1]!=c:
        break
    else:
      print(n)
      exit()

print(-1)

Measured memory_bytes: 9112
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Aman
 */


#include<bits/stdc++.h>

using namespace std;

#include <iostream>


#define ll   long long

void __print(int x) { cout << x; }

void __print(long x) { cout << x; }

void __print(long long x) { cout << x; }

void __print(unsigned x) { cout << x; }

void __print(unsigned long x) { cout << x; }

void __print(unsigned long long x) { cout << x; }

void __print(float x) { cout << x; }

void __print(double x) { cout << x; }

void __print(long double x) { cout << x; }

void __print(char x) { cout << '\'' << x << '\''; }

void __print(const char *x) { cout << '\"' << x << '\"'; }

void __print(const string &x) { cout << '\"' << x << '\"'; }

void __print(bool x) { cout << (x ? "true" : "false"); }

template<typename T, typename V>
void __print(const pair<T, V> &x) {
    cout << '{';
    __print(x.first);
    cout << ',';
    __print(x.second);
    cout << '}';
}

template<typename T>
void __print(const T &x) {
    int f = 0;
    cout << '{';
    for (auto &i: x) cout << (f++ ? "," : ""), __print(i);
    cout << "}";
}


#ifdef LOCAL
#else
#define dbg(x...)
#endif


class APluralForm {
public:

    void solve2(std::istream &cin, std::ostream &cout) {
        string s;
        cin >> s;
        s += (s.back() == 's' ? "es" : "s");
        cout << s;
    }

    void solve(std::istream &cin, std::ostream &cout) {
        ll t = 1;
//            cin >> t;
        while (t--) {
            solve2(cin, cout);
        }
    }

};


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    APluralForm solver;
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 3660
import java.util.Scanner;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) {
        //コード
        Scanner scanner = new Scanner(System.in);

        Integer n = Integer.parseInt(scanner.next());
        Integer r = Integer.parseInt(scanner.next());
        Integer max_num = 10;

        int inside_rating = r;

        if (n < max_num) {
            inside_rating += 100 * (10 - n);
        }

        System.out.println(inside_rating);

    }
}

Measured memory_bytes: 22996
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cstdio>
#include<cmath>
#include<deque>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<tuple>
#include<utility>
#include<vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef vector<vector<int>> vvi;

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define REP(i, n)  for(int i=0; i<(int)(n); i++)
#define REPS(i, n)  for(int i=1; i<=(int)(n); i++)
#define PER(i, n) for(int i=(int)(n)-1; i>= 0; i--)
#define PERS(i, n)  for(int i=(int)(n); i>0; i--)
#define FOR(i, c) for(__typeof((c).begin()) i = (c).begin(); i!=(c).end(); i++)
#define RFOR(i, c)  for(__typeof((c).rbegin()) i=(c).rbegin(); i!=(c).end(); i++)
#define ALL(container)  (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) (container).size()
#define FILL0(n)  setfill('0') << right << setw(n)
#define mp(a, b)  make_pair(a, b)
#define toLower(c)  c+0x20
#define toUpper(c)  c-0x20
#define pb  push_back
#define eb  emplace_back

const int INF = 1e9;
const long long LLINF = 1e18;
const int MOD = 1000000007;

int main(){
  int A, B; cin >> A >> B;
  cout << max(A+B, max(A-B, A*B)) << endl;
}


Measured memory_bytes: 256
S = gets.chomp

A = S[0,2].to_i
B = S[2,2].to_i

class Integer
  def month?
    (1..12).include? self
  end
end

if [A,B].all? &:month?
  puts "AMBIGUOUS"
elsif A.month?
  puts "MMYY"
elsif B.month?
  puts "YYMM"
else
  puts "NA"
end


Measured memory_bytes: 1788
import numpy as np
n,m,x=map(int,input().split())
c=[]
a=[]
for i in range(n):
    d=list(map(int,input().split()))
    c.append(d[0])
    a.append(d[1:])
#print(c)
#print(a)

chk=np.zeros(m)
ans=10**9
for j in range(2**n):
    t=0
    s=np.zeros(m)
    for i in range(n):
        if j>>i&1:
            t+=c[i]
            for k in range(m):
                s[k]+=a[i][k]
            if min(s)>=x:
                ans=min(ans,t)

if ans==10**9:
    print(-1)
else:
    print(ans)


Measured memory_bytes: 27048
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <iomanip> 
#include <cstring>
#include <queue>
#include <stack> 
#include <vector>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
int n,m;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin >> n >> m;
	ll sum = 0;
	int t;
	for(int i = 1;i <= m;i++){
		cin >> t;
		sum += t;
	}
	if(sum > n){
		cout << -1 << endl;
	}else{
		cout << n - sum << endl;
	}
	return 0;
}


Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define pb push_back
#define ll long long
#define ld long double
#define fi first
#define se second
#define INF 1000000000+10
const ll mod = 1000000000+7;
const int N = 1000+50;

int dp[N][N];
string s[N];

main()
{ 
	SPEED;
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n,m;
	cin >> n>> m;
	for(int i = 0; i<n; i++)
	{
		cin >> s[i];
	}
	for(int i = 0; i<n; i++)
	{
		for(int j = 0; j<m; j++)
		{
			if(i==0&&j==0){dp[i][j] = 1;continue;}
			if(s[i][j]=='#')continue;
			if(i>0&&s[i-1][j]!='#')dp[i][j] += dp[i-1][j];
			if(j>0&&s[i][j-1]!='#')dp[i][j] += dp[i][j-1];
			if(dp[i][j] >= mod)dp[i][j] -= mod; 
		}
	}
	cout << dp[n-1][m-1] <<endl;
}

Measured memory_bytes: 5376
#include <stdio.h>

int main(void){
    int n,m,ans;
    int x,y,r;
    char d;
    int gemx,gemy;
    int stage[21][21];
    int i,j;
    while(scanf("%d",&n)!=EOF && n!=0){
        x=10,y=10,ans=0;
        //initialising
        for(i=0;i<=20;i++){
            for(j=0;j<=20;j++)stage[i][j]=0;
        }
        //gems mapping
        for(i=0;i<n;i++){
            scanf("%d %d",&gemx,&gemy);
            stage[gemx][gemy]=1;
        }
        //robot
        scanf("%d",&m);
        for(i=0;i<m;i++){
            scanf("%s %d",&d,&r);
            switch(d){
                case 'N':
                    for(j=0;j<r;j++){
                        y++;
                        if(stage[x][y]==1)stage[x][y]=0;
                    }
                    break;
                case 'S':
                    for(j=0;j<r;j++){
                        y--;
                        if(stage[x][y]==1)stage[x][y]=0;
                    }
                    break;
                case 'E':
                    for(j=0;j<r;j++){
                        x++;
                        if(stage[x][y]==1)stage[x][y]=0;
                    }
                    break;
                case 'W':
                    for(j=0;j<r;j++){
                        x--;
                        if(stage[x][y]==1)stage[x][y]=0;
                    }
                    break;
            }
        }
        //map checking
        for(i=0;i<=20;i++){
            for(j=0;j<=20;j++)if(stage[i][j]!=0)ans++;
        }
        if(ans==0)printf("Yes\n");
        else printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 584
#include<iostream>
using namespace std;
int main(){
    int n,m,A[100][100],b[100],c[100];
    cin>>n>>m;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin>>A[i][j];
        }
    }
    for(int i=0;i<m;i++){
        cin>>b[i];
    }
    for(int i=0;i<n;i++){
        c[i]=0;
        for(int j=0;j<m;j++){
            c[i]+=A[i][j]*b[j];
        }
    }
    for(int i=0;i<n;i++){
        cout<<c[i]<<endl;
    }
    return 0;
}


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

using namespace std;

int main() {
    int N, A;
    int count = 0;
    int ans = 100000;
    cin >> N;

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

        while (A % 2 == 0)
        {
            A /= 2;
            count++;
        }
        
        if (count < ans)
        {
            ans = count;
        }
        
        count = 0;
    }
    
    cout << ans << "\n";
    
}


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

#define IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

typedef long long ll;

using namespace std;

const int INF = 1e9;
const int N = 1005;

vector<vector<int>>g(N);
vector<int>col(N);
set<int>wt, blk;
bool color(int nd, int c){
	col[nd] = c;
	if(c == 1)wt.insert(nd);
	else blk.insert(nd);
	for(int i = 0; i < g[nd].size(); i++){
		int ch = g[nd][i];
		if(col[ch] != 0){
			if(col[ch] == col[nd])
				return false;
		}
		else if(!color(ch, c % 2 + 1))
			return false;
	}
	return true;
}
map<pair<int,pair<int,int>>,pair<int,int>>dp;
vector<pair<int,int>>op;
pair<int,int> go(int i, int w, int b){
	if(i == op.size())
		return {w, b};
	if(dp.find({i,{w, b}}) != dp.end())
		return dp[{i,{w, b}}];
	pair<int,int> tmp1 = go(i + 1, w + op[i].first, b + op[i].second);
	pair<int,int> tmp2 = go(i + 1, w + op[i].second, b + op[i].first);
	if(abs(tmp1.first - tmp1.second) < abs(tmp2.first - tmp2.second))
		return dp[{i,{w, b}}] = tmp1;
	return dp[{i,{w, b}}] = tmp2;
}

int main(){
	IO;

	int n, m;
	cin >> n >> m;
	set<pair<int,int>>edg;
	for(int i = 0; i < m; i++){
		int u, v;
		cin >> u >> v;
		if(u > v)swap(u, v);
		edg.emplace(u, v);
	}
	for(int i = 1; i <= n; i++){
		for(int j = i + 1; j <= n; j++){
			if(edg.count({i, j}))
				continue;
			g[i].push_back(j);
			g[j].push_back(i);
		}
	}

	bool ok = 1;
	for(int i = 1; i <= n; i++)
		if(col[i] == 0){
			wt.clear();
			blk.clear();
			if(!color(i, 1))
				ok = 0;
			op.emplace_back(wt.size(), blk.size());
		}
//	for(auto x: op)cerr << x.first << " " << x.second << endl;
	if(!ok){
		cout << -1;
		return 0;
	}
	pair<int,int>res = go(0, 0, 0);
//	cerr << res.first << " " << res.second << endl;
	cout << res.first * (res.first - 1) / 2 + res.second * (res.second - 1) / 2;

	return 0;
}


Measured memory_bytes: 27136
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

ll dfs(vl &amount, ll rem, ll cnt, ll &ans){
  if(cnt > ans){
    return -1;
  }
  
  if(amount.size() == 0){
    ans = min(ans, cnt + rem);
    return 0;
  }

  ll top = amount[amount.size() - 1];
  ll div = rem / top;
  amount.pop_back();

  ll ret = 0;

  rep_inv(i, div, -1){
    ret = dfs(amount, rem - top * i, cnt + i, ans);
    if(ret == -1) break;
  }

  amount.push_back(top);
  
  return 0;
}

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

  ll div_6 = 1, div_9 = 1;
  priority_queue<ll, vl, greater<ll>> que;

  while(div_6 < N){
    div_6 *= 6;
    que.push(div_6);
  }
  
  while(div_9 < N){
    div_9 *= 9;
    que.push(div_9);
  }

  vl amount;
  while(!que.empty()){
    amount.push_back(que.top());
    que.pop();
  }
  
  ll ans = (ll)pow(10, 18);
  ll ret = dfs(amount, N, 0, ans);

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (int i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define fi first
#define se second
#define int long long
using namespace std;
using ll = long long;
using II = pair<int, int>; using VII = vector<II>; using VVII = vector<VII>;
using VI = vector<int>; using VVI = vector<VI>; using VVVI = vector<VVI>;
using VD = vector<double>; using VVD = vector<VD>; using VVVD = vector<VVD>;
template <class T = int> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template <class T = int> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template <class T> ostream& operator<<(ostream &s, const vector<T>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : " "); return s; }
template <class T> ostream& operator<<(ostream &s, const vector<vector<T>>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : "\n"); return s; }
template <class T, class S> ostream& operator<<(ostream &s, const pair<T, S>& p) { s << "{" << p.first << ", " << p.second << "}"; return s; }
template <class T, class S> ostream& operator<<(ostream& s, const map<T, S> m) { for (auto it = m.begin(); it != m.end(); it++) { s << *it << (next(it) == m.end() ? "" : "\n"); } return s; }
#ifdef _MY_DEBUG
  #define dump(...) cerr << "/* " << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << endl, dump_func(__VA_ARGS__), cerr << "*/\n\n";
#else
  #define dump(...)
#endif
void dump_func() { cerr << endl; }
template <class Head, class... Tail> void dump_func(Head&& h, Tail&&... t) { cerr << h << (sizeof...(Tail) == 0 ? "" : ", "), dump_func(forward<Tail>(t)...); }
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); } } fast;
constexpr int MOD = 1e9 + 7;

signed main() {
  int n; cin >> n;
  VI a(3);
  REP (i, n) {
    int x; cin >> x;
    x--;
    a[x]++;
  }
  double N = n;
  VVVD dp(n + 1, VVD(n + 1, VD(n + 1)));
  REPI (s, 1, n + 1) {
    REP (k, s + 1) {
      REP (j, s + 1) {
        int i = s - k - j;
        if (i < 0) break;
        double tmp = N / s;
        if (i > 0) {
          tmp += dp[i - 1][j][k] * i / s;
        }
        if (j > 0) {
          tmp += dp[i + 1][j - 1][k] * j / s;
        }
        if (k > 0) {
          tmp += dp[i][j + 1][k - 1] * k / s;
        }
        dp[i][j][k] = tmp;
      }
    }
  }
  cout << setprecision(10);
  cout << dp[a[0]][a[1]][a[2]] << endl;
}


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

/* short names and const
using ll = long long;
using vll = vector<long long>;
using df = vector<vector<long long>>;
df data(n, vector<long long>(m));
const int MOD = 1e9 + 7;
const long long INF = 1e18;
*/

/* Boost!
#include <boost/algorithm/string/classification.hpp> // is_any_of
#include <boost/algorithm/string/split.hpp>
using boost::algorithm::split; // split(result, s, boost::is_any_of(","));
#include <boost/algorithm/string/join.hpp>
using boost::algorithm::join; // string s = join(arr, "");
#include <boost/algorithm/string/replace.hpp>
using boost::algorithm::replace_all; // replace_all(s, "AtCoder", "A");
#include <boost/range/algorithm.hpp> // boost::sort(arr)
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;
*/

/* print(arr)
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
    cout << a;
    if (&a != &vec.back()) cout << " ";
  }
  cout << endl;
}
*/

/* fast cin and precise cout
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  getline(cin, s);
  cout << fixed << setprecision(15);
*/

/* sum function
int sum(vector<int> &arr) {
  int res = accumulate(arr.begin(), arr.end(), 0);
  return res;
}
*/


int main() {
  int n;
  cin >> n;
  int odd = (n + 1) / 2;
  int even = n / 2;
  cout << odd * even << endl;
}


Measured memory_bytes: 256
# aoj_how_meny_island.py
import sys
sys.setrecursionlimit(500000)
def printseen():
    for i in seen:
        print(i)

def dsf(h,w):
    seen[h][w]=True
    for i in dh:
        for j in dw:
            nh = h+i
            nw = w+j
            if canGo(nh,nw,i,j):
                dsf(nh,nw)
    return 1

def canGo(nh,nw,i,j):
#    print("going to ",nh,nw)
    # staying
    if i == 0 and j == 0:return False
    # out of range
    if nh < 0 or nw < 0 or nh >= H or nw >= W:return False
    # if you seen skip it
    if seen[nh][nw]:return False
    # if you meet sea skip it 
    if C[nh][nw] == "0" : return False
#    print("can go to ",nh,nw)
    return True

while True:
    W,H = map(int,input().split())
    if W==0 and H==0:
        exit()
    C = []
    for i in range(H):
        C.append(input().split())
    seen = [[False for _ in range(W)] for _ in range(H)]
    dh = [-1,0,1]
    dw = [-1,0,1]
    cnt = 0
    for h in range(H):
        for w in range(W):
            # すでに見てる場所と、海は見ない
            if not seen[h][w] and not C[h][w]=="0":
                cnt += dsf(h,w)
    print(cnt)


Measured memory_bytes: 8332
#include <bits/stdc++.h>
using namespace std;
#define rep(k,dst)    for(int i=k; i<dst;  i++)
#define rep2(k,dst)   for(int j=k; j<dst;  j++)
#define INF 1000000000000 //1e+12
#define MOD 10000007 //1e9+7
#define ll long long
#define pb pop_back
template<typename T> inline void chMin(T* a, T* b) {if(*a>*b) *a=*b;}
template<typename T> inline void chMax(T* a, T* b) {if(*a<*b) *a=*b;}
template<typename T> inline int  divUp(T a, T b)   {return ((a+b-1)/b);}
const double PI = acos(-1);

int main(){
    int h, a; cin >> h >> a;
    int ans=0;
    while(h>0){
        h -= a;
        ans++;
    }
    cout << ans << endl;
    return 0;
}
/*
3 3
1 7
3 2
1 7
*/


Measured memory_bytes: 3644
#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
	long long n,a,b;
	cin>>n;
	for(long long i=1;i*i<=n;i++)
	{
		if(n%i==0)
		a=i;
		b=n/a;
	}
	cout<<a+b-2<<endl;
	return 0;
}

Measured memory_bytes: 256
from collections import deque

N = int(input())
tree = [set() for _ in range(N)]
for _ in range(N - 1):
    a, b = map(int, input().split())
    tree[a - 1].add(b - 1)
    tree[b - 1].add(a - 1)
C = sorted(list(map(int, input().split())))

ans = [0] * N

print(sum(C[:-1]))

ans[0] = C.pop()
n = min(tree[0])
ans[n] = C.pop()

d = deque([0, n])
visited = set(d)
while d:
    x = d.pop()
    for new_x in tree[x]:
        if new_x not in visited:
            ans[new_x] = C.pop()
            d.append(new_x)
            visited.add(new_x)

print(*ans)


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

long long A,B,C,TMP1,TMP2,ANS1,ANS2,ANS3,ans;
 
int main()
{
	cin >> A >> B >> C;
	if(A%2==0 || B%2==0 || C%2==0)
	{
		cout<<0;
		return 0;
	}
	
	TMP1 = A/2;
	TMP2 = A - TMP1;
	ANS1 = abs(B*C*TMP2 - B*C*TMP1);
	TMP1 = B/2;
	TMP2 = B - TMP1;
	ANS2 = abs(A*C*TMP2 - A*C*TMP1);
	TMP1 = C/2;
	TMP2 = C- TMP1;
	ANS3 = abs(A*B*TMP2 - A*B*TMP1);
	ans = min(ANS1,ANS2);
	ans = min(ans,ANS3);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
A, B = map(int, input().split())
N = len(bin(10**12)[2:])
ans = 0
A = max(0, A - 1)
for i in range(N):
    k = 1 << i
    k2 = k * 2
    a = A // k2 * k + max(0, A % k2 - k + 1)
    b = B // k2 * k + max(0, B % k2 - k + 1)
    ans += (b - a) % 2 * k
print(ans)

Measured memory_bytes: 3060
package main

import (
	"fmt"
	"sort"
)

type Product struct {
	Price    int64
	Quantity int
}

type ArrProduct []Product

func (a ArrProduct) Len() int           { return len(a) }
func (a ArrProduct) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ArrProduct) Less(i, j int) bool { return a[i].Price < a[j].Price }

func main() {
	var N, M, B, t int
	var A, total int64
	fmt.Scan(&N, &M)
	arr := make([]Product, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&A, &B)
		arr[i].Price = A
		arr[i].Quantity = B
	}
	sort.Sort(ArrProduct(arr))
	for i := 0; i < M && t < M; i++ {
		q := arr[i].Quantity
		for j := 0; j < q && t < M; j++ {
			total += arr[i].Price
			t++
		}
	}
	fmt.Println(total)
}

Measured memory_bytes: 5376
#include <iostream>
#include <string.h>
using namespace std;
int main(void){
   int A; cin>>A;
   int num[4]; num[0]=A/1000; num[1]=(A-num[0]*1000)/100; num[2]=(A-num[0]*1000-num[1]*100)/10; num[3]=A%10;
   int ansi=0;
   for(int i=0;i<4;i++){
       cin>>num[i];
   }
   for(int i=0;i<(1<<3);i++){
       int sum=0;
       sum+=num[0];
       for(int j=0;j<3;j++){
          if(i&(1<<j)){
            sum+=num[j+1];
          }
          else {sum-=num[j+1];}
       }
       if(sum==7){ansi=i; break;}
   }
   cout<<num[0];
   for(int i=0;i<3;i++){
       if(ansi&(1<<i)){
           cout<<'+'<<num[i+1];
       }
       else{cout<<'-'<<num[i+1];}
   }
   cout<<"=7";
   return 0;
}


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

#define int long long int
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define rep(i,a,b) for (int i = a; i < b; ++i)
#define IOS ios::sync_with_stdio(false); cin.tie(NULL);
#ifndef LOCAL
#define dbg(...) ;
#define endl '\n'
#endif

const int inf = 1e15;
const int MOD = 1e9 + 7;
const int N = 2e5 + 5;

char a[101][101];
int dp[101][101];

signed main(){
    IOS;
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            cin >> a[i][j];
            dp[i][j] = inf;
        }
    }
    if (a[1][1] == '#') dp[1][1] = 1;
    else dp[1][1] = 0;
    for (int i = 2; i <= m; i++)
    {
        if (a[1][i] == '.') dp[1][i] = dp[1][i-1];
        else if (a[1][i] == a[1][i-1]) dp[1][i] = dp[1][i-1];
        else dp[1][i] = 1 + dp[1][i-1];
    }
    for (int i = 2; i <= n; i++)
    {
        if (a[i][1] == '.') dp[i][1] = dp[i-1][1];
        else if (a[i][1] == a[i-1][1]) dp[i][1] = dp[i-1][1];
        else dp[i][1] = 1 + dp[i-1][1];
    }
    for (int i = 2; i <= n; i++) {
        for (int j = 2; j <= m; j++) {
            if (a[i][j] == '.') dp[i][j] = min(dp[i-1][j], dp[i][j-1]);
            else {
                if (a[i-1][j] == a[i][j-1]) {
                    dbg(i, j)
                    dp[i][j] = 1 + min(dp[i-1][j], dp[i][j-1]);
                }
                if (a[i-1][j] == a[i][j]) {
                    dp[i][j] = min(dp[i][j], dp[i-1][j]);
                }
                if (a[i][j-1] == a[i][j]) {
                    dp[i][j] = min(dp[i][j], dp[i][j-1]);
                }
                if (a[i-1][j] != a[i][j]) dp[i][j] = min(dp[i][j], 1 + dp[i-1][j]);
                if (a[i][j-1] != a[i][j]) dp[i][j] = min(dp[i][j], 1 + dp[i][j-1]);
            }
        }
    }
    cout << dp[n][m] << endl;
    return 0;

}

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

const int N = 51;

int main(){
  int m[N],f[N],r[N];
  int n=0;

  for(int i=0;i<N;++i){    
    cin >> m[i] >> f[i] >> r[i];

    if(m[i] == -1 && f[i] == -1 && r[i] == -1){
      break;
    }

    ++n;
  }
  
  for(int i=0;i<n;++i){
    if(m[i] == -1 || f[i] == -1){
      cout << "F" << endl;
    }else if(m[i] + f[i] >= 80){
      cout << "A" << endl;
    }else if(m[i] + f[i] >= 65){
      cout << "B" << endl;
    }else if(m[i] + f[i] >= 50){
      cout << "C" << endl;
    }else if(m[i] + f[i] >= 30){
      if(r[i] >= 50){
	cout << "C" << endl;
      }else{
	cout << "D" << endl;
      }
    }else {
      cout << "F" << endl;
    }
  }

  return 0;
}



Measured memory_bytes: 3120
require 'pp'

def gets; ARGF.gets; end

class Solver

  def main
    a = gets.chomp.to_i
    b = gets.chomp.to_i

    if a < b
      puts "LESS"
    elsif a == b
      puts "EQUAL"
    else
      puts "GREATER"
    end
  end
end

if __FILE__ == $0
  Solver.new.main
end


Measured memory_bytes: 2300
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,M,X;
  cin>>N>>M>>X;
  vector<int> S(M);
  int small=0,big=0;
  for(int i=0;i<M;i++){
    cin>>S.at(i);
    if(S.at(i)<X) small++;
    else big++;
  }
  cout<<min(small,big)<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
using namespace std;
typedef long long ll;
const int MAX_N=100000;
vector<pair<int, int> > edge;
int N, M;
int par[MAX_N];  //親
ll sizes[MAX_N]; //木の深さ
void init(int n)
{
    for (int i = 0; i < n; i++)
    {
        par[i] = i;
        sizes[i] = 1;
    }
}
//木の根を求める
int find(int x)
{
    if (par[x] == x)
    {
        return x;
    }
    else
    {
        return par[x] = find(par[x]);
    }
}
//併合
void unite(int x, int y)
{
    x = find(x);
    y = find(y);
    if(x==y) return;
    if (par[x] > par[y]) swap(x, y); // merge technique
    par[y] =x;
    sizes[x] += sizes[y];
    }

bool same(int x,int y){
    return find(x)==find(y);
}

void solve(){
    init(N);
    ll ans[MAX_N];
    ans[M-1]=(ll)N*(N-1)/2;
    for(int i=M-1;i>0;i--){
        int a=edge[i].first;
        int b=edge[i].second;
        if(!same(a,b)){
        ans[i-1]=ans[i]-(ll)(sizes[find(a)]*sizes[find(b)]);
        unite(a,b);
        }
        else ans[i-1]=ans[i];
    }
    for(int i=0;i<M;i++)cout<<ans[i]<<'\n';
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N>>M;
    for(int i=0;i<M;i++) {
        int a, b;
        cin>>a>>b;
        a=a-1;
        b=b-1;
        edge.push_back(make_pair(a,b));
    }
    solve();
    return 0;
}

Measured memory_bytes: 4212
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  vector<int> v(3);
  for(int i=0;i<3;i++){
    cin>>v[i];
  }
  sort(v.begin(),v.end());
  int g=2*v[2]-v[1]-v[0];
  if(g%2==0)cout<<g/2<<endl;
  else if(g%2==1)cout<<(g+1)/2+1<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <string.h>
#include <stdio.h>
#define M 1046527
#define NIL (-1)
#define L 14
char H[M][L];
typedef long long int ll;
using namespace std;
int getChar(char ch) {
	if (ch == 'A') return 1;
	else if (ch == 'C') return 2;
	else if (ch == 'G') return 3;
	else if (ch == 'T') return 4;
	else return 0;
}
ll getKey(char str[]) {
	ll sum = 0, p = 1;
	for (ll i = 0; i < strlen(str); i++) {
		sum += p * (getChar(str[i]));
		p *= 5;
	}
	return sum;
}
int h1(int key) { return key % M; }
int h2(int key) { return 1 + (key % (M - 1)); }

int find(char str[]) {
	ll key, h;
	key = getKey(str);
	for (ll i = 0;; i++) {
		h = (h1(key) + i * h2(key)) % M;
		if (strcmp(H[h], str) == 0) return 1;
		else if (strlen(H[h]) == 0) return 0;
	}
}
int insert(char str[]) {
	ll key, h;
	key = getKey(str);
	for (ll i = 0;; i++) {
		h = (h1(key) + i * h2(key)) % M;
		if (strcmp(H[h], str) == 0) return 1;
		else if (strlen(H[h]) == 0) {
			strcpy(H[h], str);
			return 0;
		}
	}
}

int main() {
    char H[M][L];
	int N;
	char str[L], com[9];
	for (ll i = 0; i < M; i++) {
		H[i][0] = '\0';
	}
	scanf("%d", &N);
	for (ll i = 0; i < N; i++) {
		scanf("%s %s", com, str);
		if (com[0] == 'i') {
			insert(str);
		}
		else {
			if (find(str)) {
				cout << "yes" << endl;
			}
			else {
				cout << "no" << endl;
			}
		}
	}
}



Measured memory_bytes: 17440
n,w=map(int,input().split())
#dp=[[0,0] for i in range(w+1)]
dp=[]
for i in range((10**5)+1):
    dp.append([0,float("inf")])
dp[0][0]=1
dp[0][1]=0
it=[]
val=[]
for i in range(n):
    a,b=input().split()
    it.append(int(a))
    val.append(int(b))
for i in range(n):
    x=val[i]
   # dp2=dp[:]
    ac=[]
    for j in range(len(dp)-x,-1,-1):
        if dp[j][0]==1:
            if it[i]+dp[j][1]<=w:
                dp[j+x][1]=min(dp[j+x][1],it[i]+dp[j][1])
                ac.append(j+x)
   # print(dp)
    for i in ac:
        dp[i][0]=1
  #  print(dp,dp2)
print(max([j for j,i in enumerate(dp) if i[0]==1]))


Measured memory_bytes: 82652
#include<iostream>
#include<string>
#include<math.h>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<stack>

#define ll long long
#define vl vector<ll>
#define vvl vector< vector<ll> >
#define vb vector<bool>
#define vbb vector< vector<bool> >
#define vs vector<string>
#define vc vector<char>
#define vvc vector< vector<char> >

#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()

using namespace std;


int main(){
	ll n; cin >> n;
	vl d(n);
	for (ll i = 0; i < n; ++i) cin >> d[i];
	sort(all(d));
	d.erase(unique(all(d)), d.end());
	cout << d.size() << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <map>
#include <math.h>
#include <vector>

#define INF 100000000

long long n,t;
long long pre = 0;
long long start = 0;
int main(){
  long long total = 0;
  scanf("%lld%lld", &n, &t);
  for(int i = 0; i < n; i++){
    long long now;
    scanf("%lld", &now);
    if(now - pre > t){
      total += pre - start + t;
      start = now;
    }
    pre = now;
  }
  total += pre - start + t;
  printf("%lld\n", total);
}



Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

static int INF = 100010;

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

    vector<int> dp(N+1);

    dp[0] = 0;

    for (int i = 1; i <= N; ++i) {
        dp[i] = INF;

        {
            int pow = 1;
            while (pow <= i) {
                dp[i] = min(dp[i], dp[i-pow] + 1);
                pow *= 6;
            }
        }

        {
            int pow = 1;
            while (pow <= i) {
                dp[i] = min(dp[i], dp[i-pow] + 1);
                pow *= 9;
            }
        }
    }

    cout << dp[N] << endl;

    return 0;
}


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

int main()
{
    int n,i;
    long sum=0;
    cin>>n;
    int a[n+2];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    for(i=0;(i+1)<n;i++)
    {
        sum+=(a[i+1]-a[i]);
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding('utf8');

var g_input = '';
process.stdin.on('data', function(chunk) {
    g_input += chunk;
});

process.stdin.on('end', function() {
    Main(g_input.split(/\r?\n/));
});

function Main(input) {
    var s = input[0];
    var i = 0;
    var j = s.length - 1;
    var ans = 0;
    while (i < j) {
        if (s.charAt(i) == s.charAt(j)) {
            i++;
            j--;
        }
        else if (s.charAt(i) == 'x') {
            i++;
            ans++;
        }
        else if (s.charAt(j) == 'x') {
            j--;
            ans++;
        }
        else {
            ans = -1;
            break;
        }
    }

    console.log(ans);

    return 0;
}


Measured memory_bytes: 21192
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::*;

use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed reading char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed parsing")
}

fn main() {
  let (s,t): (String,String) = (read::<String>(), read::<String>());

  println!("{}{}", t,s);
}


Measured memory_bytes: 4352
#include <stdio.h>

int main(void){
  int total = 700;
  char S[256];
  scanf("%s",S);
  
  if(S[0] == 'o'){
    total = total+100;
  }
  if(S[1] == 'o'){
    total = total+100;
  }
  if(S[2] == 'o'){
    total = total+100;
  }
  
  printf("%d\n",total);

  return 0;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
	ost<<"{";
	for(int i=0;i<v.size();i++){
		if(i)ost<<",";
		ost<<v[i];
	}
	ost<<"}";
	return ost;
}

const double PI=acos(-1);

signed main(){
	int a,b,x;
	cin>>a>>b>>x;
	double ang;
	if(a*a*b>=2*x){
		double tmp=1.0*x*2/a/b/b;
		ang=atan(tmp);
	}
	else{
		double tmp=a*b-1.0*x/a;
		tmp/=a*a;
		tmp=1.0/tmp;
		tmp/=2;
		ang=atan(tmp);
	}

	ang/=PI;
	ang*=180;
	ang=90-ang;
	printf("%.20f\n",ang);
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define NL            "\n"
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
int main()
{
    _SAD()
    int n;
    cin>>n;
    int a[n],b[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(int i=0;i<n;i++)
    {
        cin>>b[i];
    }
    int cnt=0,mx=0,m=0;
    while(1)
    {
        for(int i=0;i<min(m+1,n);i++)
        {
            cnt+=a[i];
        }
        for(int i=m;i<n;i++)
        {
            cnt+=b[i];
        }
        m++;
        mx=max(mx,cnt);
        cnt=0;
        if(m==n)
        {
            break;
        }
    }
    cout<<mx<<NL;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstdlib>
#define ll long long
using namespace std;

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

  vector<int> a(n);
  vector<int> b(n);
  vector<ll int> c(m);
  vector<ll int> d(m);

  for(int i = 0; i < n; i++){
    cin >> a[i] >> b[i];
  }

  for(int i = 0; i < m; i++){
    cin >> c[i] >> d[i];
  }

  for(int i = 0; i < n; i++){
    ll int min = 1000000000;
    ll int minP;
    
    for(int j = 0; j < m; j++){
      ll int dummy = abs(a[i]-c[j]) + abs(b[i]-d[j]);

      if(dummy < min){
	min = dummy;
	minP = j+1;
      }
    }

    cout << minP << endl;
  }

  return 0;

}


Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = []
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});

reader.on('line', (line) => {
  lines.push(line);
});

reader.on('close', () => {
 var x = Number(lines[0].split(' ')[0]);
 var n = Number(lines[0].split(' ')[1]);
 var ans = '';
 var a = [];

 for(i=-100; i<=101; i++){
   a.push(i);
 }

 function diffArray(arr1, arr2) {
  var newArr = [];
  for(var a = 0 ; a < arr1.length; a++){
    if(arr2.indexOf(arr1[a]) === -1 ){
      newArr.push(arr1[a]);
    }    
  }
  for(var b = 0; b < arr2.length; b++){
    if(arr1.indexOf(arr2[b]) === -1 ){
       newArr.push(arr2[b]);
       }
  }
  return newArr;
}

function getClosestNum(num, ar){
   //近似値を保持しておく変数
   var closest;
   //配列かどうか、要素があるか判定
   if(Object.prototype.toString.call(ar) ==='[object Array]' && ar.length>0){
     //まず配列の最初の要素を近似値として保持する
     closest = ar[0];
     //配列の要素を順次比較していく
     for(var i=0;i<ar.length;i++){ 
        //この時点での近似値と、指定値の差異を絶対値で保持しておく
        var closestDiff = Math.abs(num - closest);
        //読み込んだ値と比較し、差異を絶対値で保持しておく
        var currentDiff = Math.abs(num - ar[i]);
        //新しく比較した値のほうが近かったら、近似値として保持しておく
        if(currentDiff < closestDiff){
            closest = ar[i];
        }
      }
     //ループが終わったら、近似値を返す
      return closest;
    }
 //配列じゃなかったらfalse
 return false;
}

 if(n === 0){
   ans = x;
 }else{
   var p = lines[1].split(' ');
   p = p.map(function(str) { return Number(str)});

   if(p.indexOf(x) == -1){
     ans = x;
   }else{
     var saar = diffArray(a,p);
     ans = getClosestNum(x,saar);
   }
}
  
console.log(ans);
 
});

Measured memory_bytes: 30208
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,j;
    long long sum=0;
    cin>>n;
    int d[n];
    for(i=0;i<n;i++)
        cin>>d[i];
    for(i=0;i<n;i++)
    {
        for(j=i+1;j<n;j++)
        {
            sum+=d[i]*d[j];
        }
    }

    cout<<sum<<endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull; 
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define SQ(a) (a)*(a)

template <class T, class U> ostream& operator<< (ostream &out, pair<T,U> c) { out << "(" << c.first << " "; out << c.second << ")"; return out; }
template <class T> ostream& operator<< (ostream &out, vector<T> c) { for (auto it = c.begin(); it != c.end(); ++it) { if (it != c.begin()) out << " "; out << *it; } return out; }
template <class T> ostream& operator<< (ostream &out, set<T> c) { for (auto it = c.begin(); it != c.end(); ++it) { if (it != c.begin()) out << " "; out << *it; } return out; }
const double PI  = 3.141592653589793238463;


int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    vi v(n);
    FOR(i,0,n){
        cin >> v[i];
    }
    int s = 0;
    FOR(i,0,n){
        s += 2*min(v[i], k-v[i]);
    }
    cout << s;
    cout << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  int i,j,count[5]={},num[4]={};
  for(i=1;i<=3;i++)
  {
    scanf("%d",&j);
    count[j]++;
    scanf(" %d",&j);
    count[j]++;
  }
  for(j=1;j<=4;j++)num[count[j]]++;

  if(num[1]==2&&num[2]==2)printf("YES");
  else{printf("NO");}
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main(){
    string n;
    cin>>n;
    int res=0;
    for(int i=0;i<n.size();i++){
        res+=n[i]-'0';
    }
    if(res%9==0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3708
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using pp=pair<ll,pair<int,int>>;
using Graph=vector<vector<pair<int,ll>>>;

int main(){
  ll N,A,B,C,D;
  cin>>N>>A>>B>>C>>D;
  if(abs<ll>(A-B)>(N-1)*D){
    cout<<"NO"<<endl;
  }else{
    ll x=abs<ll>(A-B);
    ll y=D-C;
    bool flag=false;
    for(ll i=0;i<=N-1;i++){
      ll z=D*i-(N-1-i)*C;
      if(z>=x){
        if(z-y*(N-1)<=x){
          flag=true;
          break;
        }
      }
    }
    if(flag){
      cout<<"YES"<<endl;
    }else{
      cout<<"NO"<<endl;
    }
  }

}


Measured memory_bytes: 384
n = int(input())
a = list(map(int, input().split()))

num_list = [0]* (len(a)+1)

for i in range(len(a)):
#    num_list[i] = a.count(i)
    num_list[a[i]] += 1

total = 0

for j in range(len(num_list)):
    total += (num_list[j]* (num_list[j]-1))/2

#print(total)

for k in range(len(a)):
#    print(num_list[a[k]]) 
    print(int(total-(num_list[a[k]])+1))
"""
import math

n = int(input())
a = list(map(int, input().split()))

cnt = flaot(0.0)

for i in range(1, len(a)+1):
    b = a[0:i-1]+a[i:len(a)]
    
    cnt = 0.0
    for j in range (1, len(a)):
        cnt += b.count(j)*(b.count(j)-1)/2
    print(int(cnt))
"""

Measured memory_bytes: 26140
k,a,b = gets.chomp.split(" ").map(&:to_i)
sum = 0

if (k < a+1) or b-a < 3 then
  print k + 1
elsif 
  k -= a + 1
  sum = b
  
  sum += k/2 * (b-a)
  print k%2==0 ? sum : sum+1
end

Measured memory_bytes: 1788