akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(j,n) for(int j = 0; j < (n); ++j)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define drep2(j,n) for(int j = (n)-1; j >= 0; --j)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define srep2(j,s,t) for (int j = s; j < t; ++j)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;

int main() {
  string S;
  cin >> S;
  int zero = 0;
  int one = 0;
  rep(i,S.length()){
    if(S[i] == '0'){
      zero++;
    }else {
      one++;
    }
  }
  int diff = abs(zero - one);
  cout << S.length() - diff << endl;
  return 0;
}

Measured memory_bytes: 512
K = int(input())
a = [7 % K]
for i in range(1, K+1):
    a.append((a[i-1]*10 + 7) % K)
flag = True
for i in range(len(a)):
    if a[i] == 0:
        print(i+1)
        flag = False
        break
if flag:
    print(-1)

Measured memory_bytes: 48544
#include <iostream>

using namespace std;

int main()
{
    int a,b,c ;
    cin >>a>>b>> c ;
    if (a==b){
        cout << c << endl;
    }else if (a==c){
    cout <<b<<endl;
    }else{
    cout<<a<< endl;
    }
    return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int q; cin >> q;
  vector<ll> A;
  REP(i, q){
    int tmp; cin >> tmp;
    if(tmp == 0){
      ll p; cin >> p;
      A.push_back(p);
    }else if(tmp == 1){
      ll p; cin >> p;
      cout << A[p] << endl;
    }else{
      A.pop_back();
    }
  }
}


Measured memory_bytes: 4964
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  int n;
  cin >> n;
  int a[n];
  rep(i,n){
    cin >> a[i];
    a[i]--;
  }
  int ans=0;
  int cnt=0;
  int temp=0;
  while(temp!=1 && cnt<=n+3){
    temp=a[temp];
    cnt++;
  }
  if(temp==1)cout << cnt << endl;
  else cout << -1 << endl;
return 0;}

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

using namespace std;


void solve() {
    string s, t;
    cin >> s >> t;
    vector<int> cns(26,0), cnt(26,0);
    for (char x: s) {
        cns[x-'a']++;
    }
    for (char x: t) {
        cnt[x-'a']++;
    }
    for (int i = 0; i < 26; i++) {
        if (cnt[i] && !cns[i]) {
            cout << -1; return;
        }
    }
    int n = s.size(), m = t.size();
    vector<vector<int>> g(26);
    for (int i = 0; i < n; i++) {
        g[s[i]-'a'].emplace_back(i);
    }
    using ll=long long ;
    ll crt = -1;
    for (char x: t) {
        int k = x - 'a';
        ll nex = (crt+1)%n;
        int i = lower_bound(g[k].begin(), g[k].end(), nex) - g[k].begin();
        ll ad = i == (int)g[k].size()? (n + g[k][0] - nex+1) :g[k][i] - nex+1;
        crt += ad;
    }
    cout << crt+1;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 1228
#include <stdio.h>

int main(){
  int N;
  double A,S=0.0;
  scanf("%lld",&N);
  for(int i=1;i<=N;i++){
    scanf("%lf",&A);
    S+=1.0/A;
  }
  printf("%lf\n",1.0/S);
  return 0;
}

Measured memory_bytes: 1748
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		long l = 0;
		long r = (long)2e9;
		while(r - l > 1){
			long c = (l+r) / 2;
			if(lose(c)){
				l = c;
			} else {
				r = c;
			}
		}
		Console.WriteLine(r);
		
		
	}
	
	bool lose(long c){
		long inc = A - B;
		long cnt = 0;
		for(int i=0;i<N;i++){
			if(H[i] < c * B) continue;
			long rest = H[i] - c * B;
			long cnt0 = rest / inc;
			if(rest % inc != 0) cnt0++;
			cnt += cnt0;
		}
		return cnt > c;
	}
	
	
	
	int N;
	long A,B;
	long[] H;
	public Sol(){
		var d = ria();
		N = d[0]; A = d[1]; B = d[2];
		H = new long[N];
		for(int i=0;i<N;i++) H[i] = ri();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 15836
x = list(map(str, input()))
for i in range(2**3):
  op = ["-","-","-"]
  for j in range(3):
    if (i & 1<<j):
      op[j] = "+"
  if eval(x[0]+op[0]+x[1]+op[1]+x[2]+op[2]+x[3]) == 7:
    print(x[0]+op[0]+x[1]+op[1]+x[2]+op[2]+x[3]+"=7")
    break

Measured memory_bytes: 61952
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

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

  ll a, b;
  cin >> a >> b;

  cout << a*b/__gcd(a,b ) << endl;
}



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

int main(){
  string w;
  cin >> w;
  map<char, int> mp;
  for(int i = 0; i < w.size(); i++) mp[w[i]]++;
  for(auto itr = mp.begin(); itr != mp.end(); itr++){
    if(itr->second % 2 == 1){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  while(true){
    int m,nmin,nmax;
    cin>>m>>nmin>>nmax;

    if(m==0&&nmin==0&&nmax==0){
      break;
    }
    int P[200];
    for(int i=0;i<m;i++){
      cin>>P[i];
    }
    int gap=-1;
    int n=-1;
    for(int i=nmin;i<=nmax;i++){
      int g=P[i-1]-P[i];
      if(gap<=g){
        gap=g;
        n=i;
      }
    }
    cout<<n<<endl;
  }
  return 0;
}



Measured memory_bytes: 2992
#include <iostream>
#include <string>
#include <math.h>
#include <stdio.h>
#include <ctype.h>
#include <algorithm>

using namespace std;

char x[11][11];

void search(int i, int j, int direction);

int main () {
    
    for(int i=0; i<11; i++){
        for(int j=0; j<11; j++){
            x[i][j]='0';
        }
    }


    while(cin
          >>x[1][2]>>x[1][4]>>x[1][6]>>x[1][8]
          >>x[2][1]>>x[2][3]>>x[2][5]>>x[2][7]>>x[2][9]
          >>x[3][2]>>x[3][4]>>x[3][6]>>x[3][8]
          >>x[4][1]>>x[4][3]>>x[4][5]>>x[4][7]>>x[4][9]
          >>x[5][2]>>x[5][4]>>x[5][6]>>x[5][8]
          >>x[6][1]>>x[6][3]>>x[6][5]>>x[6][7]>>x[6][9]
          >>x[7][2]>>x[7][4]>>x[7][6]>>x[7][8]
          >>x[8][1]>>x[8][3]>>x[8][5]>>x[8][7]>>x[8][9]
          >>x[9][2]>>x[9][4]>>x[9][6]>>x[9][8]
          )
        
        
    {
        search(1, 1, 1);
        cout<<endl;
        
    }
    
    return 0;
}

void search(int i, int j, int direction){
    while(1){
    char around[4];
    around[0]=x[i-1][j];
    around[1]=x[i][j+1];
    around[2]=x[i+1][j];
    around[3]=x[i][j-1];
    
    char output[4]={'U','R','D','L'};
    int next[4]={0,1,2,3};
    
        int move[4][2]={0};
    if(around[0]=='1'){
        move[0][0]=i-2;move[0][1]=j;
    }
    if(around[1]=='1'){
        move[1][0]=i;move[1][1]=j+2;
    }
    if(around[2]=='1'){
        move[2][0]=i+2;move[2][1]=j;
    }
    if(around[3]=='1'){
        move[3][0]=i;move[3][1]=j-2;
    }
    
    for(int k=0; k<4; k++){
        int temp = (direction+3+k)%4;
        if(around[temp]=='1'){
            direction=next[temp];
            i=move[temp][0];
            j=move[temp][1];
            cout<<output[temp];
            break;
        }
    }
        if(i==1&&j==1){
            break;
        }
    }
    
}

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

int main(){
  string s;
  cin >> s;
  if(s[0] == 'A' && s[1] >= 'a' && s[1] <= 'z'){
    int c = 0;
    bool flag = false;
    for(int i = 2;i < s.size()-1;i++){
      if(s[i] == 'C'){
        c++;
      }else if(!(s[i] >= 'a' && s[i] <= 'z')){
        flag = true;
      }
    }
    if(c == 1 && !flag && s[s.size()-1] >= 'a' && s[s.size()-1] <= 'z'){
      cout << "AC" << endl;
    }else{
      cout << "WA" << endl;
    }
  }else{
    cout << "WA" << endl;
  }

  return 0;
}




Measured memory_bytes: 256
a, b, c = gets.split(' ').map(&:to_i)
if a + b + c == 17
    if a == 7 && b == c
    puts 'YES'
  elsif b == 7 && a == c
    puts 'YES'
  elsif c == 7 && a == b
    puts 'YES'
  else
    puts 'NO'
  end
else
  puts 'NO'
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; using ll = long long; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    string S;
    cin >> S;
    write(S.substr(0, 3));
}


Measured memory_bytes: 3612
w, h, n = map( int, input().split())
l = 0
r = w
d = 0
u = h
for _ in range(n):
    x, y, a = map( int, input().split())
    if a == 1:
        l = max(l,x)
    elif a == 2:
        r = min(r,x)
    elif a == 3:
        d = max(d,y)
    else:
        u = min(u,y)
if r-l <= 0 or u-d <= 0:
    print(0)
else:
    print((r-l)*(u-d))

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>
#include<queue>
#include<stack>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e8;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用

#include<iostream>
#include<math.h>


//最大公約数
long long gcd(long long a, long long b)
{
	long long tmp, r;
	if (a < b)
	{
		tmp = a;
		a = b;
		b = tmp;
	}
	r = a % b;
	while (r != 0)
	{
		a = b;
		b = r;
		r = a % b;
	}

	return b;
}

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

	ll a, b;
	cin >> a >> b;

	ll gcdNum = gcd(a, b);
	vector<ll> koyaku;

	for (int i = 1; i <= sqrt(gcdNum); i++)
	{
		if (gcdNum % i == 0)
		{
			koyaku.push_back(i);
			if(gcdNum/i!=1)
			koyaku.push_back(gcdNum / i);
		}
	}
	ll ans = 0;
	bool fl = false;

	for (int i = 0; i < koyaku.size(); i++)
	{
		for (int j = 1; j <= sqrt(koyaku[i]); j++)
		{
			if (koyaku[i] % j == 0 && koyaku[i] != j && j!=1)
			{
				fl = false;
				break;
			}
			else
				fl = true;
		}
		if (fl)
		{
			ans++;
		}
	}

	cout << ans << endl;


	return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

    ll A,P; cin >> A >> P;

    cout << (A*3+P)/2 << endl;

    return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <set>
#include <stack>
using ll = long long;
using uint = unsigned int;
using graph = std::vector<std::vector<ll>>;
using wGraph = std::vector<std::vector<std::pair<ll,ll>>>;
#define rep(i,n) for (int i=0; i < int(n); i++)

using namespace std;
ll MOD7 = 1000000007;
ll MOD9 = 1000000009;
vector<ll> InputVec(ll N){
    vector<ll> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    return A;
}
void OutputVec(vector<ll> A){
    for (int i = 0; i < A.size(); ++i) {
        cout << A[i] << ",";
    }
    cout << endl;
}
vector<vector<ll>> InputVec2d(ll H,ll W){
    vector<vector<ll>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<ll>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        for (int xi = 0; xi < W; ++xi) {
            cin >> A[yi][xi];
        }
    }
    return A;
}
vector<vector<char>> InputVec2dStr(ll H,ll W){
    vector<vector<char>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<char>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        string S;
        cin >> S;
        for (int xi = 0; xi < W; ++xi) {
            A[yi][xi] = S[xi];
        }
    }
    return A;
}
void OutputVec2d(vector<vector<ll>> A){
    for (int yi = 0; yi < A.size(); ++yi) {
        for (int xi = 0; xi < A[yi].size(); ++xi) {
            cout << A[yi][xi] << ",";
        }
        cout << endl;
    }
}
graph InputGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    return G;
}
graph InputDGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
    }
    return G;
}
void OutputGraph(graph G){
    for (int i = 0; i < G.size(); ++i) {
        cout << i << ":";
        for (int j = 0; j < G[i].size(); ++j) {
            cout << G[i][j]<< ",";
        }
        cout << endl;
    }
}
void OutputAnswerBool(bool b,bool isUpperCase = false){
    if(b){
        if(isUpperCase){
            cout << "YES" << endl;
        }else{
            cout << "Yes" << endl;
        }
    }else{
        if(isUpperCase){
            cout << "NO" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}

int main() {
    ll N,M;
    cin >> N >> M;
    vector<ll> num(N);
    vector<bool> red(N);
    for (int i = 0; i < N; ++i) {
        num[i] = 1;
    }
    red[0] = true;
    for (int i = 0; i < M; ++i) {
        ll from,to;
        cin >> from >> to;
        from--;to--;
        if(red[from]){
            red[to] = true;
        }
        num[from]--;
        num[to]++;
        if(num[from] == 0){
            red[from] = false;
        }
    }
    ll count = 0;
    for (int i = 0; i < N; ++i) {
        if(red[i])count++;
    }
    cout << count << endl;
}


Measured memory_bytes: 1024
from datetime import datetime
n = int(input().rstrip())
l = [[i for i in input().split()] for i in range(n)]
total = 0
for v in l:
    if v[1] == "JPY":
        total += int(v[0])
    elif v[1] == "BTC":
        total += float(v[0]) * 380000.0
print(total)


Measured memory_bytes: 3312
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define pb push_back
#define ld long double
#define f first
#define s second
#define in insert
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e18 + 5;
const int mod = 1e9 + 7;
const int  N = 2e5 + 314;
const long double pi = 3.1415926535897932384626433832795;
void solve(){
	string s, t;
	cin>>s>>t;
	int cnt = 0;
	for(int i = 0; i < sz(s); i++){
		if(s[i]!=t[i])cnt++;
	}
	cout<<cnt;
}	
signed main(){
	speed;
	int t=1;
	//cin>>t;
	while(t--)solve();
}

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

int main(){
  
  int n; cin >> n;
  
  vector<int> a(n + 1), b(n + 1);
  
  for (int i = 1; i <= n; i++){
    int tmp; cin >> tmp;
    a[i] = tmp;
  }
  
  int m = 0;
  
  for (int i = n; i >= 1; i--){

    if (i > n/2) {b[i] = a[i]; if(b[i] == 1) m++;}
    else {
      int c = 0;
      for(int j = 2 * i; j <= n; j += i){
        if(b[j] == 1) c++;
      }
      
      b[i] = (c + a[i]) % 2;
      if(b[i] == 1) m++;
    }
  }
  
  cout << m << endl;
  for (int i = 1; i <= n; i++){
    if(b[i] == 1) cout << i << endl;
  }
}

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

int main(){
  int64_t N;
  cin >> N;
  vector<int64_t> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  int64_t cnt = 0;
  for(int i=N-1; i>=0; i--){
    if(vec.at(i) == 0){
      cnt++;
      vec.at(i) = cnt * -1;
    }
    else{
      cnt = 0;
    }
  }
  
  int64_t ans = 0;
  
  for(int i=0; i<N; i++){
    int64_t x = 0;
    int64_t j = i;
    while(j < N){
      if(vec.at(j) < 0){
        ans += abs(vec.at(j));
        j += abs(vec.at(j));
      }
      else if((x + vec.at(j)) == (x ^ vec.at(j))){
        ans++;
        x += vec.at(j);
        j++;
      }
      else{
        break;
      }
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 1792
/**
 *      AGC 22 A
 *      author  : kyomukyomupurin
 *      created : 2018-09-25 15:48:55
**/

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

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

    if (S == "zyxwvutsrqponmlkjihgfedcba"){
        cout << -1 << endl; return 0;
    }

    vector<char> rm;

    if ((int) S.size() < 26){
        for (char c = 'a'; c <= 'z'; ++c){
            if (S.find(c) == string::npos){
                cout << S << c << endl; return 0;
            }
        }
    }

    else {
        for (auto i = 0; i < 26; ++i) {
            rm.push_back(S[(int) S.size() - 1]);
            sort(rm.begin(), rm.end());
            S.pop_back();
            for (auto x : rm){
                if (S[(int) S.size() - 1] < x){
                    S.pop_back();
                    cout << S << x << endl; return 0;
                }
            }
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define forn(i, a, n) for (int i = (int)(a); i < (int)(n); ++i)
#define ford(i, a, n) for (int i = (int)(n) - 1; i >= (int)(a); --i)
#define fore(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define fs first
#define sn second
#define trace(a)\
    for (auto i : a) cerr << i << ' ';\
    cerr << '\n'
#define eb emplace_back

#ifndef M_PI
const ld M_PI = acos(-1.0);
#endif

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

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

const ld eps = 1e-9;
const int INF = 2000000000;
const ll LINF = 1ll * INF * INF;
const ll MOD = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); 
    srand((unsigned)chrono::high_resolution_clock::now().time_since_epoch().count());
    int n, k;
    cin >> n >> k;
    map<int, int> cnt;
    forn(i, 0, n) {
        int a;
        cin >> a;
        ++cnt[a];
    }
    vector<int> vals;
    for (auto p : cnt)
        vals.eb(p.sn);
    sort(all(vals));
    reverse(all(vals));
    //trace(vals);
    int ans = n;
    for (int i = 0; i < k && i < vals.size(); ++i)
        ans -= vals[i];
    cout << ans << '\n';
}


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


int main() {
  ll n;
  string s;
  cin >> n;
  cin >> s;
  set<int> r,g,b;
  rep(i,n){
    if(s[i] == 'R') r.insert(i+1);
    if(s[i] == 'G') g.insert(i+1);
    if(s[i] == 'B') b.insert(i+1);
  }
  // cout << r.size() << " " << g.size() << " " << b.size() << endl;
  ll ans = r.size() * g.size() * b.size();
  ll counts = 0;
  // cout << ans << endl;
  // for(auto x:b) cout << x << " ";
  // cout << endl;
  for(auto u: r){
    for(auto v: g) {
      if(b.count(2*u-v)) {
        // cout << u << " " << v << " " << 2*u-v << endl;
        ++counts;
      }
      if((u+v)%2 == 0 && b.count((u+v)/2)) {
        // cout << u << " " << v << " " << (u+v)/2 << endl;
        ++ counts;
      }
      if(b.count(2*v-u)) {
        // cout << u << " " << v << " " << 2*v-u << endl;
        ++counts;
      }
    }
  }
  cout << ans - counts << endl;
  return 0;
}

Measured memory_bytes: 3752
#include<stdio.h>

#define N 25

struct Node{
	int link, left, right;
}tree[N+1];

void addNode(int id, int left, int right)
{
	tree[id].left = left;
	tree[id].right = right;
	if(left != -1){
		tree[left].link = 1;
	}
	if(right != -1){
		tree[right].link = 1;
	}
	return;
}

int rootNode(void)
{
	int i;
	for(i = 0; i < N + 1; i++){
		if(tree[i].link == 0){
			return(i);
		}
	}
	return(-1);
}

void preorderInner(int id)
{
	if(id == -1){
		return;
	}
	printf(" %d", id);
	preorderInner(tree[id].left);
	preorderInner(tree[id].right);
	return;
}

void preorder(void)
{
	printf("Preorder\n");
	preorderInner(rootNode());
	printf("\n");
	return;
}

void inorderInner(int id)
{
	if(id == -1){
		return;
	}
	inorderInner(tree[id].left);
	printf(" %d", id);
	inorderInner(tree[id].right);
	return;
}

void inorder(void)
{
	printf("Inorder\n");
	inorderInner(rootNode());
	printf("\n");
	return;
}

void postorderInner(int id)
{
	if(id == -1){
		return;
	}
	postorderInner(tree[id].left);
	postorderInner(tree[id].right);
	printf(" %d", id);
	return;
}

void postorder(void)
{
	printf("Postorder\n");
	postorderInner(rootNode());
	printf("\n");
	return;
}

int main(int argc, char* argv[])
{
	int i, n, id, left, right;

	scanf("%d", &n);
	for(i = 0; i < n; i++){
		scanf("%d %d %d", &id, &left, &right);
		addNode(id, left, right);
	}

	preorder();
	inorder();
	postorder();

	return(0);
}

Measured memory_bytes: 616
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

int main(){
    int N;
    cin >> N;
    map<string,int> cnt;
    int ans=0;
    for(int i=0;i<N; i++){
        string c;
        cin >> c;
        if(cnt.count(c)==0){
            ans++;
        }
        cnt[c]=1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 19096
#include <iostream>
#include <string>
#include <sstream>

using namespace std;

string s;

string int_to_string(int number){

  stringstream ss;
  ss << number;

  return ss.str();
}

string string_change(void){

  int S = s.size();
  string RS = "";
  for( int i = 0 ; i < S ; i++ ){
    int cnt = 0;
    for( int j = i ; s[j] == s[i] ; j++ ) cnt++;
    i += cnt - 1;
    RS += int_to_string(cnt);
    RS += s[i];
  }
  return RS;
}

int main(void){

  int n;
  while( cin >> n , n ){
    cin >> s;
    while(n--){
      s = string_change();
    } 
    cout << s << endl;
  }
  return 0;
}

Measured memory_bytes: 1364
#include<bits/stdc++.h>
using namespace std;
 void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
 int main()
{
    fast();
    double r;
    const double pi = 3.14159265359;
    cin >> r;
    cout << 2 * r * pi;
   
    return 0;
    }
   


Measured memory_bytes: 3808
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int n, m;
vll x, y;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> m;
    x.resize(n), y.resize(m);
    for (int i = 0; i < n; i++) cin >> x[i];
    for (int i = 0; i < m; i++) cin >> y[i];

    ll xsum = 0, xtotal = 0;
    for (int i = 1; i < n; i++) {
        xsum += (x[i] - x[0]) % MOD;
        if (xsum >= MOD) xsum -= MOD;
    }
    xtotal += xsum;
    for (int i = 1; i < n; i++) {
        xsum -= ((x[i] - x[i - 1]) % MOD) * (n - i) % MOD;
        if (xsum < 0) xsum += MOD;
        xtotal += xsum;
        if (xtotal >= MOD) xtotal -= MOD;
    }
    
    ll ysum = 0, ytotal = 0;
    for (int i = 1; i < m; i++) {
        ysum += (y[i] - y[0]) % MOD;
        if (ysum >= MOD) ysum -= MOD;
    }
    ytotal += ysum;
    for (int i = 1; i < m; i++) {
        ysum -= ((y[i] - y[i - 1]) % MOD) * (m - i) % MOD;
        if (ysum < 0) ysum += MOD;
        ytotal += ysum;
        if (ytotal >= MOD) ytotal -= MOD;
    }

    cout << xtotal * ytotal % MOD << '\n';
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
using namespace std;
class Process {
public:
	Process() : next(NULL) {}
	Process *next;
	string pname;
	int ptime;
};

class Queue {
	Process *head;
	Process *tail;
public:
	Queue() : head(NULL), tail(NULL) {}

	void enqueue(Process *p) {
		if (head == NULL) {
			head = p;
		} else {
			tail->next = p;
		}
		tail = p;
		tail->next = NULL;
	}
	Process *dequeue() {
		Process *p = head;
		if (head != NULL) {
			head = head->next;
		}
		return p;
	}
};

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

	Process *p;
	Queue queue;
	for (int i = 0; i < n; ++i) {
		p = new Process;
		cin >> p->pname >> p->ptime;
		queue.enqueue(p);
	}

	int current = 0;
	while((p = queue.dequeue()) != NULL) {
		if (p->ptime > q) {
			p->ptime -= q;
			current += q;
			queue.enqueue(p);
		} else {
			current += p->ptime;
			cout << p->pname << " " << current << endl;
		}
	}
}

Measured memory_bytes: 5108
#include <stdio.h>

void Do(void){
  int A, B;
  scanf("%d", &A);
  scanf("%d", &B);
  printf("%d\n", A + B);
}

int main(void){
  int N;
  scanf("%d", &N);
  if(N == 1) printf("Hello World\n");
  else Do();
  return 0;
}


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

int main(){
    int W,H,x,y;
    cin>>W>>H>>x>>y;
    double outval = (double) W * (double) H /2.0; 

    cout<<fixed << setprecision(4)<<outval <<" ";

    if((x == W/2)&&(y == H/2)){
        if((W%2==0)&&(H%2==0)){
            cout<<"1"<<endl;
        }
        else{
            cout<<"0"<<endl;
        }
    }
    else{
        cout<<"0"<<endl;
    }


}



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

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBUG = true;


int main(){

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

    int ans = -1;
    for(int i  = 0; i < 5; i++){
        if(v[i] == 0) ans = i + 1;
    }    
    cout << ans << endl;



    return 0;
}

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

using namespace std;
using ll=long long;
using vi=vector<int>;
using vl=vector<ll>;
using vs=vector<string>;
using li=list<int>;
using lil=list<ll>;
using lis=list<string>;
using fli=forward_list<int>;
using fll=forward_list<ll>;
using fls=forward_list<string>;
using si=stack<int>;
using sl=stack<ll>;
using ss=stack<string>;
using qi=queue<int>;
using ql=queue<ll>;
using qs=queue<string>;
using pqi=priority_queue<int>;
using pql=priority_queue<ll>;
using pqs=priority_queue<string>;
using dqi=deque<int>;
using dql=deque<ll>;
using dqs=deque<string>;

#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, a, n) for(int i = (n); i < (a); i++)
#define repr(i, n) for(int i = (n); i >= 0; i--)
#define repr2(i, a, n) for(int i = (n); i >= (a); i--)

template<typename T,typename U>
void Inparray(T &f,U n){for(int i=0;i<n;i++) cin>>f[i];}

template<typename T,typename U>
void Printarray(T f,U n){for(int i=0;i<n;i++) i!=n ? cout<<f[i]<<" " : cout<<f[i];}
template<typename T,typename U>
void Printarray2(T f,U n){for(int i=0;i<n;i++) cout<<f[i]<<endl;}
template<typename T,typename U,typename V>
void Printarray3(T f,U a,V b){
  rep(i,a){
    rep(j,b){
      cout<<f[i][j];
    }
    cout<<endl;
  }
}
template<typename T,typename U>
void Printarray4(T f,U n){
  rep(i,n){
    rep(j,n){
      cout<<f[i][j];
    }
    cout<<endl;
  }
}

void flagfunc(bool flag,string A,string B){flag ? cout<<A<<endl : cout<<B<<endl;}
void flag2func(bool flag){flag ? cout<<"Yes"<<endl : cout<<"No"<<endl;}
void flag3func(bool flag){flag ? cout<<"YES"<<endl : cout<<"NO"<<endl;}

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int n,m;cin>>n>>m;
  int a,cnt=0;rep(i,m){cin>>a;cnt+=a;}
  n-cnt>=0 ? cout<<n-cnt<<endl : cout<<-1<<endl;
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n == 0) return 1;

    ll res = modpow(x, n/2);
    if(n%2 == 0) return res*res%mod;
    else return res*res%mod*x%mod;
}

ll power(ll x, ll n){
    if(n == 0) return 1;

    ll res = power(x, n/2);
    if(n%2 == 0) return res*res;
    else return res*res*x;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */

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

    string hoge; cin >> hoge;
    int slen = hoge.length();
    string s = "0";
    s += hoge;

    // sをi文字目まで見て、カウントをjまでつけるような場合の数
    vector< vector<ll> > dp(100005, vector<ll>(4, 0));
    dp[0][0] = 1;

    for(int i=0; i<slen; ++i){
        if(s[i+1] == 'A'){
            // not count
            dp[i+1][0] += dp[i][0];
            dp[i+1][1] += dp[i][1];
            dp[i+1][2] += dp[i][2];
            dp[i+1][3] += dp[i][3];
            // count
            dp[i+1][1] += dp[i][0];
        }
        else if(s[i+1] == 'B'){
            // not count
            dp[i+1][0] += dp[i][0];
            dp[i+1][1] += dp[i][1];
            dp[i+1][2] += dp[i][2];
            dp[i+1][3] += dp[i][3];
            // count
            dp[i+1][2] += dp[i][1];
        }
        else if(s[i+1] == 'C'){
            // not count
            dp[i+1][0] += dp[i][0];
            dp[i+1][1] += dp[i][1];
            dp[i+1][2] += dp[i][2];
            dp[i+1][3] += dp[i][3];
            // count
            dp[i+1][3] += dp[i][2];
        }
        else{
            // not count
            dp[i+1][0] += 3*dp[i][0];
            dp[i+1][1] += 3*dp[i][1];
            dp[i+1][2] += 3*dp[i][2];
            dp[i+1][3] += 3*dp[i][3];

            // count
            dp[i+1][1] += dp[i][0];
            dp[i+1][2] += dp[i][1];
            dp[i+1][3] += dp[i][2];
        }

        for(int j=0; j<4; ++j) chmod(dp[i+1][j]);
    }

    cout << dp[slen][3] << endl;

    // for(int i=0; i<=slen; ++i){
    //     for(int j=0; j<4; ++j){
    //         cout << dp[i][j] << ' ';
    //     }
    //     cout << endl;
    // }
    
	return 0;
}


Measured memory_bytes: 7504
#include <bits/stdc++.h>
using namespace std;
 
int main(void) {
 
    string S;
    cin >> S;

    if (S[0] == 'A') {
        if (S[1] == 'A') {
            if (S[2] == 'A') {
                cout << "No" << endl;
            } else {
                cout << "Yes" << endl;
            }
        } else {
                cout << "Yes" << endl;
        }
    } else {
        if (S[1] == 'B') {
            if (S[2] == 'B') {
                cout << "No" << endl;
            } else {
                cout << "Yes" << endl;
            }
        } else {
                cout << "Yes" << endl;
        }
    }
 
    return 0;
}


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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

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

void solve() {
  long long a, b; scanf("%lld%lld", &a, &b);
  long long g = __gcd(a, b);
  int ans = 1;
  for (long long i = 1; i*i <= g; ++i) {
    if (g % i) continue;
    if (prime(i)) ++ans;
    if (prime(g/i)) ++ans;
  }
  printf("%d", ans);
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


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

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long double ld;

using namespace std;

int h, w;

int main() {
	cin >> h >> w;
	int cnt = 0;
	for (int i = 0; i < h; ++i) {
		string s;
		cin >> s;
		for (int j = 0; j < w; ++j)
			if (s[j] == '#')
				++cnt;
	}
	if (cnt == h + w - 1) {
		cout << "Possible\n";
	}
	else {
		cout << "Impossible\n";
	}
	return 0;
}




Measured memory_bytes: 764
import java.util.Scanner;
 
class Main {
	int n;
	int[][] abc;
	int[][] dp;
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		Main m = new Main(sc);
		m.solve();
	}
	Main(Scanner sc){
		n = sc.nextInt();
		abc = new int[n][3];
		dp = new int[n+1][3];
		for(int i=0;i<n;i++){
			abc[i][0] = sc.nextInt();
			abc[i][1] = sc.nextInt();
			abc[i][2] = sc.nextInt();
		}
		sc.close();
	}
	void solve(){
		for(int i=1;i<=n;i++){
			for(int j=0;j<3;j++){
				for(int k=0;k<3;k++){
					if(j==k) continue;
					dp[i][j] = Math.max(dp[i][j], dp[i-1][k]+abc[i-1][j]);
				}
			}
		}
		System.out.println(Math.max(Math.max(dp[n][0], dp[n][1]),dp[n][2]));
	}
}

Measured memory_bytes: 102992
#include <bits/stdc++.h>
#define arep(a,i,n) for(ll i=(a);i<(n);i++)
#define rep(i,n) for(ll i=0;i<(n);i++)
#define cinf(x,n) for(ll i=0;i<(n);i++)cin>>x[i];
#define coutf(x,n) for(ll i=0;i<(n);i++)cout<<x[i]<<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

int main(){
	int x;
	cin >> x;
	if(x)
		cout << 0 << endl;
	else
		cout << 1 << endl;
}

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

using namespace std;

int main(void) {

  int n, k;
  cin >> n >> k;
  int keta = 0;
  for (;n > 0;keta++){
  	n /= k;
  }

  cout << keta << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stdio.h>
using namespace std;

int dp[3003][3003];
int main() {
	string s1, s2, ans;
	cin >> s1 >> s2;
	string current = s1;
	s1 = "." + current;
	current = s2;
	s2 = "." + current;
	vector<string> new_dp(3002,""), new_dp2(3002, "");
	for(int i = 1; i < s1.size(); ++i) {
		for(int j = 1; j < s2.size(); ++j) {
			if(s1[i] == s2[j]) {
				dp[i][j] = 1 + dp[i - 1][j - 1];
				new_dp[j] = new_dp2[j - 1] + s2[j];
			}
			else {
				if(dp[i - 1][j] >= dp[i][j - 1]) {
					dp[i][j] = dp[i - 1][j];
					new_dp[j] = new_dp2[j];
				}
				else {
					dp[i][j] = dp[i][j - 1];
					new_dp[j] = new_dp[j - 1];
				}
			}
		}
		new_dp2 = new_dp;
	}
	cout << new_dp2[s2.size() - 1];
}


Measured memory_bytes: 52080
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
//---------------------------------------------------------------------------------------------------
typedef pair<int,int> P;

int main(void){
    // Your code here!
    ll k,a,b; cin >> k >> a >> b;
    if (a >= b -1 ) cout << k+1 << endl;
    else {
        if (k <= a) {
            cout << k + 1 << endl;
        } else {
            if ((k-a+1)% 2 == 0) {
                cout << a +(k-a+1)/2*(b-a) << endl;
            } else {
                cout << a +(k-a+1)/2*(b-a) + 1 << endl;
            }
            
        }
    }
}


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

namespace Atcoder
{
    class Atcoderrrrrrr
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            if (N == 3)
            {
                Console.WriteLine("YES");
            }
            else if (N == 5)
            {
                Console.WriteLine("YES");
            }
            else if (N == 7)
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}


Measured memory_bytes: 11092
#include <cstdio>
#include <cstdlib>
#include <algorithm>

int parent(int i){
	return i/2;
}

int left(int i){
	return 2*i;
}

int right(int i){
	return 2*i+1;
}

void maxHeapify(int *A, int i, int n){
	int l_idx, r_idx, temp;
	l_idx = left(i+1)-1;
	r_idx = right(i+1)-1;
	temp = i;

	if(r_idx < n){\
		if(A[r_idx] > A[i]){
			temp = r_idx;
		}
	}
	if (l_idx < n){
		if (A[l_idx] > A[temp]){
			temp = l_idx;
		}
	}
	if (temp != i){
		std::swap(A[i], A[temp]);
		maxHeapify(A, temp, n);
	}
}

int main(void){
	int i,n;
	int *A;
	scanf("%d", &n);
	A = new int[n];
	for(i=0;i<n;i++){
		scanf("%d", &A[i]);
	}

	for(i=(n-1)/2;i>=0;i--){
		maxHeapify(A, i, n);
	}

	for(i=0;i<n;i++){
		printf(" %d", A[i]);
	}
	printf("\n");
	delete[] A;
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  int h[N+1];
  rep(i, N) cin >> h[i];
  h[N] = 0;
  int ans, buf;
  ans = 0;
  
  while (1) {
    buf = ans;
    for (int i = 0; i < N; ++i) {
      if (h[i]) {
        --h[i];
        if (!h[i+1]) ++ans;
      }
    }
    if (ans == buf) break;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int N,M;
	scanf("%d %d",&N,&M);

	int f;

	char A[N][N+1];
	char B[M][M+1];
	for(int i=0; i<N; i++){
		scanf("%s",A[i]);
	}
	for(int i=0; i<M; i++){
		scanf("%s",B[i]);
	}


	for(int i=0; i<=N-M; i++){
		for(int l=0; l<=N-M; l++){
			f=0;
			for(int j=0; j<M; j++){
				for(int k=0; k<M; k++){
					if(A[j+i][k+l]!=B[j][k]){ f=1; break; }
				}
			}
			if(f==0){ printf("Yes\n");return 0; }
		}
	}
	
	printf("No\n");
	return 0;
}

Measured memory_bytes: 128
N,X = map(int,input().split())
#バーガーは2*cnt+3、パティは2*cnt+1
#レベルNバーガー&パティの総数リスト　indexは[N]
numB = [1]
numP = [1]
for i in range(50):
    numB.append(numB[i]*2+3)
    numP.append(numP[i]*2+1)
#二分探索の作成
L = 0; R = numB[N]+1
K = N   #Kは今調べているバーガー
ans = 0
while K>0:
    Mid = (L+R)//2
    if X == L+1:
        break
    if L+2 <= X <= Mid-1:
        K -= 1
        L += 1; R = Mid
        continue
    if X == Mid:
        ans += numP[K-1]+1
        break
    if Mid+1 <= X <= R-2:
        ans += numP[K-1]+1
        K -= 1
        L = Mid; R -= 1
        continue
    if X == R-1:
        ans += numP[K]
        break
else:
    ans += 1
print(ans)



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

using namespace std;

int main() {
  int h, w;
  cin >> h >> w;
  int n;
  cin >> n;
  vector< vector<int> > ans;
  vector<int> colors;
  int cnt = w;
  for (int i = 0; i < n; ++i) {
    int color;
    cin >> color;
    for (int j = 0; j < color; ++j) {
      colors.push_back(i + 1);
      cnt--;
      if (cnt == 0) {
	ans.push_back(colors);
	colors = vector<int>();
	cnt = w;
      }
    }
  }

  for (int i = 0; i < h; ++i) {
    if (i % 2 == 0) {
      for (int j = 0; j < w; ++j) {
	if (j == w - 1) cout << ans[i][j] << endl;
	else cout << ans[i][j] << " ";
      }
    } else {
      for (int j = w - 1; j >= 0; --j) {
	if (j == 0) cout << ans[i][j] << endl;
	else cout << ans[i][j] << " ";
      }
    }
  }
  return 0;
}



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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

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

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

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"; return os;}
template<class T,size_t n> ostream& operator<<(ostream &os, const array<T,n> &t) {os<<"{"; rep(i,n) {os<<t[i]<<",";} os<<"}"; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const ll INF = 1e17+7;

typedef vector<ll> vi;

// 最大流を求める(Dinic法)
class Flow{
	public:
		int N;	// 頂点数
		vector<vi> F, C, edge;	// F:残余グラフ C:初期容量 edge:隣接する頂点

		vi itr, lv;	// itr:調べ終わったかどうか  lv:Sからの距離

		// コンストラクタ n:頂点数
		Flow(int n): N(n), F(n,vi(n)), C(n,vi(n)), edge(n) {}

		// f->tにコストcの辺を追加する(同じf->tに対して何度も追加することも可能)
		void addEdge(int f, int t, ll c){
			F[f][t] = C[f][t] = c;
			edge[f].push_back(t);
			edge[t].push_back(f);
		}

		// sからの最短距離を求める。これを実行するとDFSでは最短経路の中から探索する
		ll bfs(int S, int T){
			lv.assign(N, 0);
			queue<int> q;
			q.push(S);
			lv[S] = 1;
			while( !q.empty() ){
				int n = q.front(); q.pop();
				for(auto v: edge[n]) if( !lv[v] && F[n][v] ){
					lv[v] = lv[n] + 1;
					q.push(v);
				}
			}
			return lv[T];
		}

		// 増加パスをDFSで探す
		ll dfs(int n, ll c, int T){
			if( n == T ) return c;
			for(;itr[n] < edge[n].size(); ++itr[n]){
				int v = edge[n][itr[n]];
				if( F[n][v] && lv[v] > lv[n] ){
					ll f = dfs(v, min(c, F[n][v]), T);
					F[n][v] -= f;
					F[v][n] += f;
					if(f) return f;
				}
			}
			return 0;
		}

		// 流す。最大流を求める(現在の状態からいくら流れたかが返ってくる)
		ll maxFlow(int S, int T){
			if( S == T ) return INF;
			ll ret = 0, f;
			while( bfs(S,T) ){
				itr.assign(N,0);
				while( f = dfs(S, INF, T) ) ret += f;
			}
			return ret;
		}

		// 辺に流れている流量を取得する
		ll flow(int f, int t){ return C[f][t] - F[f][t]; }

		// 隣接する辺の流量の合計を取得する。n=S,T以外の場合は、出た値を1/2倍したものがその点の流量
		ll flow(int n){
			ll ret=0;
			for(int v: edge[n]) ret += abs( flow(n,v) );
			return ret;
		}

		// グラフを初期値に戻す
		void reset(){ rep(i,N) rep(j,N) F[i][j] = C[i][j]; }
};

int main(){
	//ios_base::sync_with_stdio(false);
	ll N, ans=0;
	ll a[105]={};

	cin >> N;
	rep(i,N) cin >> a[i];

	Flow fl(N+5);
	int S = N+1;
	int T = N+2;
	rep(i,N){
		if( a[i] <= 0 ) fl.addEdge(S, i, -a[i]);
		else fl.addEdge(i, T, a[i]);
	}
	reps(i,1,N) for(int j=i+i; j<=N; j+=i) fl.addEdge(i-1, j-1, INF);

	ll sum = 0;
	rep(i,N) sum += max(0ll, a[i]);

	chmax(ans, sum - fl.maxFlow(S, T));

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
int main()
{
    ll a, b, c, d, e, f, g;
    cin >> a >> b >> c >> d >> e >> f >> g;
    ll ans = 0;
    ans += b;
    if(a == 0 || d == 0 || e == 0)
    {
        ans += a / 2 * 2;
        ans += d / 2 * 2;
        ans += e / 2 * 2;
        cout << ans << endl;
        return 0;
    }
    if((a % 2 && d % 2) || (a % 2 && e % 2) || (d % 2 && e % 2))
    {
        a -= 1;
        d -= 1;
        e -= 1;
        ans += 3;
    }
    ans += a / 2 * 2;
    ans += d / 2 * 2;
    ans += e / 2 * 2;
    cout << ans << endl;
}


Measured memory_bytes: 3620