akhauriyash/Code-Regression huggingface dataset:
//Tue Dec 22 22:01:34 JST 2009
#include<set>
#include<iostream>
#include<queue>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define mp make_pair
int dx[]={0,1,1,0,-1,-1};
int dy[]={-1,-1,0,1,1,0};
#define CONNECT true
#define UNCONNECT false
#define CANMOVE true
#define CANNOTMOVE false

class state{
public:
  int len;
  int x[8],y[8];
  int cnt;
  int path[8];
  bool is_connected(int me,int you){
    if ( x[me]==x[you]){
      if ( y[me]-1 == y[you] || y[me]+1 == y[you] || y[me]==y[you])return CONNECT;
    }else if ( x[me]+1 == x[you]){
      if (y[me] ==y[you] || y[me]-1==y[you])return CONNECT;
    }else if ( x[me]-1==x[you]){
      if (y[me] ==y[you] || y[me]+1 == y[you])return CONNECT;
    }

    return UNCONNECT;
  }

  bool can_good_pos(int cur){
    rep(i,cur-1){
      if ( is_connected(cur,i)==CONNECT)return false;//©ªÌOÈOÌâÂÆÂÈªÁÄ¢éÌÅ¾ßB
    }
    if (cur==0 ||  is_connected(cur,cur-1)==CONNECT)return true;//©ªÆOÌâÂÆÂÈªÁÄ¢éÌÅ¨
    return false;
  }
  
  void make_next(int now,queue<state>&Q,set<state>&S,bool flag,set<pair<int,int> > & NG){
    if ( now == len){
      if ( S.find((*this))==S.end()){
	cnt++;
	S.insert(*this);
	Q.push(*this);
	cnt--;
      }
      return;
    }

    //don't move
    
    if (can_good_pos(now) ){
      path[now]=-1;
      make_next(now+1,Q,S,CANMOVE,NG);
    }

    if ( flag == CANNOTMOVE)return;//OÌª®¢Ä½ç©ªÍ®¯È¢

    rep(i,6){
      x[now]+=dx[i];
      y[now]+=dy[i];

      path[now]=i;

      if (NG.find(mp(x[now],y[now])) == NG.end() && can_good_pos(now)){
	make_next(now+1,Q,S,CANNOTMOVE,NG);//©ªª®¢½çÌÍ®¯È¢B
      }
      x[now]-=dx[i];
      y[now]-=dy[i];
    }
        
  }
  
  bool operator<(const state & a)const{
    rep(i,len){
      if ( x[i]!=a.x[i])return x[i]<a.x[i];
      if ( y[i]!=a.y[i])return y[i]<a.y[i];
    }
    return false;
  }
  
};



int bfs(state ini,int dx,int dy,set<pair<int,int> > &NG){
  queue<state> Q;
  set<state> S;
  Q.push(ini);
  S.insert(ini);
  while(!Q.empty()){
    state now = Q.front();
    Q.pop();

    if ( now.x[0]==dx && now.y[0]==dy){
      return now.cnt;
    }
    now.make_next(0,Q,S,CANMOVE,NG);
  }
  return -1;
}


main(){
  int n,m,dx,dy;
  while(cin>>n && n){
    state ini;
    set<pair<int,int> > NG;
    
    ini.len=n;
    ini.cnt=0;
    rep(i,n)cin>>ini.x[i]>>ini.y[i];
    cin>>m;
    int outx[m],outy[m];
    rep(i,m){
      cin>>outx[i]>>outy[i];
      //NG.insert(mp(outx[i],outy[i]));
    }
    cin>>dx>>dy;

    
    int minx=min(dx,-999999),miny=min(dy,-999999);
    rep(i,n){
      minx=min(minx,ini.x[i]);
      miny=min(miny,ini.y[i]);
    }
    rep(i,m){
      minx=min(minx,outx[i]);
      miny=min(miny,outy[i]);
    }
    
    rep(i,n)ini.x[i]-=minx,ini.y[i]-=miny;
    rep(i,m)outx[i]-=minx,outy[i]-=miny,NG.insert(mp(outx[i],outy[i]));

    dx-=minx;
    dy-=miny;
    cout << bfs(ini,dx,dy,NG)<<endl;
  }
  return false;
}

Measured memory_bytes: 30000
#ruby
#UnionFind

class UnionFind

	def initialize(arr)
		@union_root = {}
		@union_size = {}
		arr.each do |e|
			@union_root[e] = e
			@union_size[e] = 1
		end
	end

	def find(obj)
		if @union_root[obj] == obj
			obj
		else
			find(@union_root[obj])
		end
	end

	def union(obj,targ)
		if issame(obj,targ)
			return
		end
		if size(obj) > size(targ)
			@union_size[find(obj)] += size(find(targ))
			@union_root[find(targ)] = find(obj)
		else
			@union_size[find(targ)] += size(find(obj))
			@union_root[find(obj)] = find(targ)
		end
	end

	def issame(obj,targ)
		find(obj) == find(targ)
	end

	def size(obj)
		@union_size[find(obj)]
	end
end

n,m = gets.chomp.split(" ").map(&:to_i)

uf = UnionFind.new((1..n).to_a)

m.times do
  n1,n2 = gets.chomp.split(" ").map(&:to_i)
  uf.union(n1,n2)
end

max = 0

n.times do |i|
  sz = uf.size(i+1)
  #oy = uf.find(i+1)
  #puts("root:#{oy} size:#{sz}")
  if max < sz
    max = sz
  end
end

p max

Measured memory_bytes: 31600
#include <bits/stdc++.h>
#define REP(i,n) for (long long i=0;i<(n);i++)
#define FOR(i,a,b) for (long long i=(a);i<(b);i++)
#define RREP(i,n) for(long long i=n;i>=0;i--)
#define RFOR(i,a,b) for(long long i=(a);i>(b);i--)
#define dump1d_arr(array) REP(i,array.size()) cerr << #array << "[" << (i) << "] ==> " << (array[i]) << endl
#define dump2d_arr(array) REP(i,array.size()) REP(j,array[i].size()) cerr << #array << "[" << (i) << "]" << "[" << (j) << "] ==> " << (array[i][j]) << endl
#define dump(x)  cerr << #x << " => " << (x) << endl
#define dumpP(p) cerr << "( " << p.first << " , " << p.second << " )" << ends
#define SORT(c) sort((c).begin(),(c).end())
#define MIN(vec) *min_element(vec.begin(), vec.end())
#define MAX(vec) *max_element(vec.begin(), vec.end())
#define UNIQ(vec) vec.erase(unique(vec.begin(), vec.end()),vec.end()) //ソートの必要あり
#define IN(n,m)  (!(m.find(n) == m.end()))
#define ENUM(m) for (auto itr = m.begin(); itr != m.end(); ++itr)
#define dump_MAP(m) for(auto itr = m.begin(); itr != m.end(); ++itr) { cerr << itr->first << " --> "  << itr->second << endl; }
#define FINDL(vec,x) (lower_bound(vec.begin(),vec.end(),x) - vec.begin())
#define FINDU(vec,x) (upper_bound(vec.begin(),vec.end(),x) - vec.begin())
#define ROUND(N) setprecision(N)
#define ROUND_PRINT(N,val) cout << fixed;cout << setprecision(N) << val << endl
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define INARR(h,w,x,y) (0 <= y && y < h && 0 <= x && x < w)
#define EQ(a,b) (abs(a - b) < 1e-10)
using namespace std;
constexpr int dx[4] = {0,1,0,-1};
constexpr int dy[4] = {1,0,-1,0};
constexpr long double pi = M_PI;
constexpr double eps = 1e-10;
constexpr long mod = 1000000007;
constexpr short shINF = 32767;
constexpr long loINF = 2147483647;
constexpr long long llINF = 9223372036854775807;
typedef long long LL;
typedef vector<LL> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<LL,LL> pr;
typedef vector<bool> VB;
typedef vector<pr> VP;
struct Order {
	bool operator() (pr const& a,pr const& b) const {
		return a.first > b.first || ((a.first == b.first) && (a.second > b.second));
	}
};


int main(void) {
	long N;
	cin >> N;
	VI A(N);
	REP(i,N) cin >> A[i];
	REP(i,N-1) A[i+1] += A[i];
	long sum = A[N-1];
	long l,r,P,Q,R,S,k,s;
	long ans = loINF;
	FOR(i,1,N-1) {
		l = A[i];
		r = sum - l;
		k = FINDL(A,l/2);
		s = FINDL(A,(r/2)+l);
		dump(i);
		REP(lc,2) REP(rc,2) {
			P = A[max(k-(long)lc,0L)];
			Q = l - P;
			R = A[max(s-(long)rc,(long)i+1)] - l;
			S = r - R;
			if ( P != 0 && Q != 0 && R != 0 && S != 0) {
				vector<long> order = {P,Q,R,S};
				SORT(order);
				ans = min(ans,order[3] - order[0]);
			}
		}
	}
	cout << ans << endl;
}





Measured memory_bytes: 1792
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 100000000
#define INF 300000000000000000
#define MOD 1000
#define mod 1000000007
#define INT_MAX_ 2147483647
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define rep(i,n)for (ll i = 0; i < (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
#define me memset
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[5]={-1,0,1,0,0};
int dy[5]={0,-1,0,1,0};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp1(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_time=clock();
    //-------------------------------
    ll n,m;cin>>n>>m;
    V<Pll>ans;
    ll cnt=m;
    if(n%2==0){
        //even
        ll l=n/2;
        ll s=0;
        for(ll i=0;i<m;i++){
            if ((l + 1 + i) - (l - i) >= l) s = 1;
            ans.pb(mp(l-i-s,l+1+i));
        }
    }
    else{
        for(ll i=n/2;i>=1;i--){
            ans.pb(mp(i,n-i));
            cnt--;
            if(cnt==0)break;
        }
    }
    for(ll i=0;i<m;i++){
        cout<<ans[i].fi<<" "<<ans[i].se<<endl;
    }
    //-------------------------------  
    //ll end_time=clock();cout<<"time="<<end_time-begin_time<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------





































Measured memory_bytes: 5264
#include <stdio.h>
int main(){
  int a, b, c, d, e, n, total, score, max, min, i;
  max = 0;
  min = 500;
  while(1){
    scanf("%d",&n);
    if( n == 0 ){
      break;
    }
    for( i = 0 ; i < n ; i++){
      scanf("%d %d %d %d %d",&a, &b, &c, &d, &e);
      total = a + b + c+ d + e;
      if(total > max){ max = total; }
      if(total < min){ min = total; }
    }
    printf("%d %d\n",max,min);
    max = 0;
    min = 500;
  }
  return 0;
}

Measured memory_bytes: 600
#include <assert.h>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <bitset>
typedef long long ll;
typedef unsigned long long ull;

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define DEBUG(vec) for (auto v : vec) { cout << v << " "; } cout << endl;

using namespace std;

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

  ull N, M;
  cin >> N >> M;

  cout << (1900 * M + 100 * (N - M)) * (1 << M) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MOD=1000000007;
long long n,k,ans=1,l,r,flg=1,a[233333];
int main(){
    scanf("%lld%lld",&n,&k);r=n-1;
    for(int i=0;i<n;i++)scanf("%lld",&a[i]);
    sort(a,a+n);
    if(k%2)ans=a[r],r--,k--,flg=(ans<0?-1:1);
    while(k){
        long long x=a[l]*a[l+1],y=a[r]*a[r-1];
        if(x*flg>y*flg)ans*=x%MOD,ans%=MOD,l+=2;
        else ans*=y%MOD,ans%=MOD,r-=2;
        k-=2; 
    }
    printf("%lld",(ans%MOD+MOD)%MOD);
}

Measured memory_bytes: 5316
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a = sc.nextLong()
    val b = sc.nextLong()
    val c = sc.nextLong()
    val k = sc.nextLong()
    val ans = (a - b) * (if (k % 2 == 0L) 1 else -1)
    println(ans)
}

Measured memory_bytes: 31268
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
ll gcdll(ll a, ll b ){
    ll r, tmp;
    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(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll k;
    cin >> k;
    ll ans =0;
    REP(a,k){
        REP(b,k){
            REP(c,k){
                ans+=gcdll(a+1,(gcdll(b+1,c+1)));
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <queue>

using namespace std;

int N, M, S, T;
int memo[111111][3];
const int INF = 1 << 25;

struct Q {
  int pos, step, cost;
  int &visited() {
    return memo[pos][step];
  }
};

int main() {
  while (cin >> N >> M) {
    vector<int> edge[N];
    for (int i = 0; i < 111111; i++) {
      for (int j = 0; j < 3; j++) {
        memo[i][j] = INF;
      }
    }
    for (int i = 0; i < M; i++) {
      int u, v;
      cin >> u >> v;
      edge[u-1].push_back(v-1);
    }
    cin >> S >> T;
    S--, T--;

    queue<Q> que;
    que.push(Q{S, 0, 0});
    int ans = -1;
    while (que.size()) {
      Q q = que.front();
      que.pop();
      if (q.pos == T && q.step == 0) {
        ans = q.cost;
        break;
      }
      int nstep = (q.step + 1) % 3;
      int ncost = q.cost + 1;
      for (int i = 0; i < edge[q.pos].size(); i++) {
        Q n = Q{edge[q.pos][i], nstep, ncost};
        if (n.visited() != INF) continue;
        n.visited() = ncost;
        que.push(n);
      }
    }
    if (ans > 0) {
      cout << ans / 3 << endl;
    } else {
      cout << -1 << endl;
    }
  }
}


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

int main(){
  int N;
  int max = 1;
  string name;
  cin >> N;
  map<string, int> votes;
  for(int i=0;i<N;i++){
    cin >> name;
    if (votes.count(name)) {
      votes.at(name) += 1;
      if(votes.at(name) > max) max = votes.at(name);
    }
    else {
      votes[name] = 1;
    }
  }
  for (auto p : votes) {
    auto key = p.first;
    auto num = p.second;
    if(num == max) cout << key << endl;
  }
}

Measured memory_bytes: 25344
import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

N, M = map(int, input().split())

if N != 1 and N != 0:
    N = combinations_count(N, 2)
else:
    N = 0
if M != 1 and M != 0:
    M = combinations_count(M, 2)
else:
    M = 0


print(N+M)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <vector>
#include<iterator>
#include<utility>
#include<map>
#include<algorithm>


using namespace std;

typedef long long ll; // %lld
typedef vector<ll> vi;
typedef pair<int, int> pi;

#define mod (pow(10,9)+7);
#define PB push_back
#define POB pop_back
#define MP make_pair
#define itri std::vector<int>::iterator
#define max(a, b) (a < b ? b : a)
#define min(a, b) ((a > b) ? b : a)


void showpq( vector <ll> gq)
{
	vector <ll> g = gq;
	reverse(g.begin(), g.end());
	while (!g.empty())
	{
		cout << g.back() << " ";
		g.pop_back();
	}
	cout << '\n';
}


int main()
{
#ifndef ONLINE_JUDGE
	freopen("inno.in", "r", stdin);
	freopen("ottu.txt", "w", stdout);
#endif


	ll n , x, ba;
	vi koko;

	cin >> x >> n;

	for (ll i = 0; i < n; ++i)
	{
		cin >>  ba;
		koko.PB(ba);
	}

	ll diff = 0;

	while (1)
	{
		if ( count( koko.begin(), koko.end() , (x - diff) ) == 0 )
		{
			cout <<  (x - diff)  << endl;
			break;
		}

		if ( count( koko.begin(), koko.end() , (x + diff) ) == 0 )
		{
			cout <<  (x + diff)   << endl;
			break;
		}

		diff += 1;


	}

	return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main() {
  int N, M;
  cin >> N >> M;
  map<int, int> mp;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    mp[-a]++;
  }

  for (int i = 0; i < M; i++) {
    int b, c;
    cin >> b >> c;
    mp[-c] += b;
  }

  int ans = 0, cont = 0;
  for (auto x : mp) {

    if (cont + x.second >= N) {
      ans += (N - cont) * x.first * -1;
      break;
    }

    ans += x.second * x.first * -1;
    cont += x.second;
  }

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


Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
#define x first
#define y second
#define mp make_pair
#define pb push_back
template <typename TYPE> inline void chkmax(TYPE &x,TYPE y){x<y?x=y:0;}
template <typename TYPE> inline void chkmin(TYPE &x,TYPE y){y<x?x=y:0;}
template <typename TYPE> void readint(TYPE &x)
{
    x=0;int f=1;char c;
    for(c=getchar();!isdigit(c);c=getchar())if(c=='-')f=-1;
    for(;isdigit(c);c=getchar())x=x*10+c-'0';
    x*=f;
}
const int MAXN=100005;

int a,b;

int main()
{
	cin>>a>>b;
	if(b>=a)cout<<"unsafe";
	else cout<<"safe";
	return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

ll N, A, B;

ll solve() {
  if (B < A) return 0;
  if (N == 1) {
    if (A == B) return 1;
    else        return 0;
  }
  return (A + B*(N-1)) - (A*(N-1) + B) + 1;
}

void _main() {
  cin >> N >> A >> B;
  ll ans = solve();
  cout << ans << "\n";
}

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

int main()
{
        int n;
        cin >> n;
        int S[13];
        int H[13];
        int C[13];
        int D[13];

        for (int i = 0; i < 13; ++i) {
                S[i]  = 0;
                H[i] = 0;
                C[i] = 0;
                D[i] = 0;
        }
        for (int i = 0; i < n; ++i) {
                int tmp;
                char c;
                cin >> c >> tmp;
                if (c == 'S') {
                        S[tmp-1] += 1;
                }
                else if(c == 'H') {
                        H[tmp-1] += 1;
                }
                else if (c == 'C') {
                        C[tmp-1] += 1;
                }
                else {
                        D[tmp-1] += 1;
                }
        }
        for (int i = 0; i < 13; ++i) {
                if (S[i] == 0) {
                        cout << "S " << i+1 << endl;
                }
        }
        for (int i = 0; i < 13; ++i) {
                if (H[i] == 0) {
                        cout << "H " << i+1 << endl;
                }
        }
        for (int i = 0; i < 13; ++i) {
                if (C[i] == 0) {
                        cout << "C " << i+1 << endl;
                }
        }
        for (int i = 0; i < 13; ++i) {
                if (D[i] == 0) {
                        cout << "D " << i+1 << endl;
                }
        }

}



Measured memory_bytes: 3104
def LI(): return [int(x) for x in input().split(" ")]
def LS(): return [str(x) for x in input().split(" ")]
def ItoS(L): return [str(x) for x in L]
def StoI(L): return [int(c) for c in L]


def solve():
    n, t = LI()
    T = LI()

    ans = 0
    for i in range(len(T) - 1):
        ans += min(t, T[i + 1] - T[i])

    print(ans + t)


solve()

Measured memory_bytes: 25840
#include <stdio.h>

int main(void) {
	int a, b ,c, x;
	scanf("%d %d %d", &a, &b, &c);
	for(int i=a; i<=b; i++){
		if(c%i==0){
			x++;
		}
	}
	printf("%d\n", x);
	
	return 0;
}



Measured memory_bytes: 2104
#include<iostream>
using namespace std;
main()
{
  string s;cin>>s;
  int a=s[0]-'0',b=s[1]-'0',c=s[2]-'0',d=s[3]-'0';
  	   if(a-b-c-d==7)cout<<a<<'-'<<b<<'-'<<c<<'-'<<d<<"=7";
  else if(a-b-c+d==7)cout<<a<<'-'<<b<<'-'<<c<<'+'<<d<<"=7";
  else if(a-b+c-d==7)cout<<a<<'-'<<b<<'+'<<c<<'-'<<d<<"=7";
  else if(a-b+c+d==7)cout<<a<<'-'<<b<<'+'<<c<<'+'<<d<<"=7";
  else if(a+b-c-d==7)cout<<a<<'+'<<b<<'-'<<c<<'-'<<d<<"=7";
  else if(a+b-c+d==7)cout<<a<<'+'<<b<<'-'<<c<<'+'<<d<<"=7";
  else if(a+b+c-d==7)cout<<a<<'+'<<b<<'+'<<c<<'-'<<d<<"=7";
  else if(a+b+c+d==7)cout<<a<<'+'<<b<<'+'<<c<<'+'<<d<<"=7";
}

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

public class Main {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        long n = Long.parseLong(sc.next());
        Long[] train = {Long.parseLong(sc.next()),
                Long.parseLong(sc.next()),
                Long.parseLong(sc.next()),
                Long.parseLong(sc.next()),
                Long.parseLong(sc.next())};

        Arrays.sort(train);
        long result = n % train[0] == 0 ? n / train[0] + 4 : n / train[0] + 5;

        System.out.println(result);
    }
}

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


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

class BEasyLinearProgramming {
public:
    void solve(std::istream& cin, std::ostream& cout) {
		ios::sync_with_stdio(false);
        cin.tie(nullptr);
        long long a,b,c,k;
        cin >> a >> b >> c >> k;

        if (a >= k){
            cout << k << endl;
        }else {
            cout << a -(k - (a +b))<< endl;
        }

	}
};


int main() {
	BEasyLinearProgramming solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
const long long INF = 1LL << 60;
int cnt = 0;
int main()
{
    string s;
    cin >> s;
    int y = 700;
    if (s[0] == 'o')
        y += 100;
    if (s[1] == 'o')
        y += 100;
    if (s[2] == 'o')
        y += 100;
    cout << y << endl;
}


Measured memory_bytes: 3592
n = int(input())
p = list(map(int, input().split()))
ret = 0
for i in range(n-2):
    if p[i] < p[i+1] < p[i+2]:
        ret += 1
    elif p[i+2] < p[i+1] < p[i]:
        ret += 1
print(ret)

Measured memory_bytes: 61444
import java.io.BufferedReader;
        import java.io.IOException;
        import java.io.InputStreamReader;
        import java.lang.reflect.Array;
        import java.math.BigInteger;
        import java.util.*;
        import java.lang.*;

public class  Main {
    static class FastReader{
        BufferedReader br;
        StringTokenizer st;

        public FastReader(){
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next(){
            while(st==null || !st.hasMoreElements()){
                try{
                    st=new StringTokenizer(br.readLine());
                }
                catch(IOException e){
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt(){
            return Integer.parseInt(next());
        }

        Long nextLong(){
            return Long.parseLong(next());
        }

        double nextDouble(){
            return Double.parseDouble(next());
        }
        String nextLine(){
            String str="";
            try{
                str=br.readLine();
            }
            catch(IOException e){
                e.printStackTrace();
            }
            return str;
        }
    }
    static int gcd(int a,int b){
        if(b==0){
            return a;
        }else{
            return gcd(b,a%b);
        }
    }
    public static void main(String[] args) {
        FastReader in = new FastReader();
        int k=in.nextInt();
        long sum=0;
        for(int i=1;i<=k;i++){
            for(int j=1;j<=k;j++){
                int a =gcd(i,j);
                for(int m =1;m<=k;m++){
                    sum+=gcd(a,m);
                }
            }
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 32700
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;

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

    LL a, b, c, d;
    cin >> a >> b >> c >> d;

    LL ans = a * c;
    ans = max(ans, a * d);
    ans = max(ans, b * c);
    ans = max(ans, b * d);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3688
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void) {
	int N,M;
	cin >> N >> M;
	vector<int> X(M);
	for (int i = 0; i < M; ++i) {
		cin >> X[i];
	}
	sort(X.begin(),X.end());
	long long res = 0;
	if (N < M) {
		vector<int> dis(M-1);
		for (int i = 1; i < M; ++i) {
			dis[i-1] = X[i] - X[i-1];
			res += dis[i-1];
		}
		sort(dis.begin(),dis.end());
		for (int i = 0; i < N-1; ++i) {
			res -= dis[M-i-2];
		}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string sS = Console.ReadLine().Trim();
            int iN = int.Parse(sS);

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            int iOut = 0;
            List<int> lstMlt2 = new List<int>() { 64, 32, 16, 8, 4, 2, 1 };
            for (int i = 0; i < lstMlt2.Count; i++)
            {
                if (lstMlt2[i] <= iN) { iOut = lstMlt2[i]; break; }
            }

            //出力
            Console.WriteLine("{0}", iOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }
}


Measured memory_bytes: 13268
#include<stdio.h>
#include<stdlib.h>

typedef long long int int64;

int cmp(const void *a,const void *b){
  return *(int *)a-*(int *)b;
}

void run(void){
  int n;
  scanf("%d",&n);
  int *a=(int *)calloc(n,sizeof(int));
  int *b=(int *)calloc(n,sizeof(int));
  int i,j;
  for(i=0;i<n;i++) scanf("%d",a+i);
  for(i=0;i<n;i++) scanf("%d",b+i);
  qsort(a,n,sizeof(int),cmp);
  qsort(b,n,sizeof(int),cmp);
  i=j=0;
  int64 ans=1;
  int cnt=0;
  const int mod=1000000007;
  while(i<n && j<n){
    if(a[i]<b[j]){
      if(cnt>=0) cnt++;
      else ans=ans*(-cnt++)%mod;
      i++;
    } else {
      if(cnt<=0) cnt--;
      else ans=ans*cnt--%mod;
      j++;
    }
  }
  while(i<n){
    ans=ans*(-cnt++)%mod;
    i++;
  }
  while(j<n){
    ans=ans*cnt--%mod;
    j++;
  }
  printf("%lld\n",ans);
}

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


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

using namespace std;
int a[100005],dp[100005],i,j,k,n;
const int inf=1e9+5;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie();
    cin>>n>>k;
    for(i=1; i<=n; i++)
    {
        cin>>a[i];
        dp[i]=inf;
    }
    dp[1]=0;
    for(i=1; i<=n; i++)
        for(j=i+1; j<=i+k; j++)
          dp[j]=min(dp[j],dp[i]+abs(a[i]-a[j]));
        cout<<dp[n];
            return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<iomanip>
#include<stack>
#include<queue>
#include<numeric>
#include<algorithm>
#include<string>
#include<map>
#include<bitset>
#include<set>
#include<cmath>
#define int long long
#define inf 8938103643641919514ll
#define oku 1000000007ll
using namespace std;
int a,b,c,d,e,f,g,n;
int dx[]={0,-1,0,1,0};
int i,j,k;
int p[100001],q[100001],r[100001],ans;
signed main(){
	cin>>n;
	for(i=0;i<n;i++){
		int u;
		cin>>u;
		q[u-1]++;
	}
	for(i=0;i<100000;i++)
		if(q[i]!=0){
			ans++;
			if((q[i]%=2)==0){
				q[i]+=2;
				a++;
			}
		}
	if(a%2==1)
		ans--;
	cout<<ans<<endl;
}

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

typedef long long ll;
typedef pair<int,int> pii;

long long MOD = 1000000000 + 7;
long long MAX = 1000000000000000000;

int main(){
  cout << setprecision(10);
  int N;
  ll A,B;
  cin >> N >> A >> B;

  vector<ll> H(N);

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

  // sort(H.begin(), H.end());

  ll right = 10000000000;
  ll left = 0;
  ll mid;

  auto isOK = [&A,&B,&H](ll x){

    ll tmp = 0;
    for(int i = 0; i < H.size(); i++){
      ll h = H[i] - B * x;
      if(h > 0){
        tmp += (h + A - B - 1) / (A - B) ;
      }
    }
    return ( tmp <= x );

  };

  while(right - left > 1){
    mid = left + (right - left)/2;

    if(isOK(mid)){
      right = mid;
    } else {
      left = mid;
    }
  }
  cout << right << endl;
}


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

int main(){
    int l, r, d;
    cin >> l >> r >> d;
    int count = 0;
    for (int i = l; i <= r;i++){
        if(i%d==0){
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
    using namespace std;
    #define el "\n"
    #define ll long long
    #define ull unsigned long long int
    #define pb push_back
    #define mp make_pair
    #define X first
    #define Y second
    #define M 1000000007
    #define all(v) v.begin(), v.end()
    long long pow(long long int a,long long int b,long long int MOD)
    {
        long long x=1,y=a; 
        while(b > 0)
        {
            if(b%2 == 1)
            {
                x=(x*y);
                if(x>MOD) x%=MOD;
            }
            y = (y*y);
            if(y>MOD) y%=MOD; 
            b /= 2;
        }
        return x;
    }
    long long InverseEuler(long long int n, long long int MOD)
    {
        return pow(n,MOD-2,MOD);
    }
   
    int main() {
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      string s;
      cin>>s;
      map<char,int> mp;
      for(int i=0;i<s.size();i++)mp[s[i]-'A']++;
      if(mp.size()==2)cout<<"Yes"<<el;
      else cout<<"No"<<el;
      return 0;
    }


Measured memory_bytes: 256
from heapq import heappush, heappop
from collections import defaultdict
def dijkstra(graph:list, node:int, start:int) -> list:
    # graph[node] = [(cost, to)]
    inf = float('inf')
    dist = [inf]*node

    dist[start] = 0
    heap = [(0,start)]
    while heap:
        cost,thisNode = heappop(heap)
        for NextCost,NextNode in graph[thisNode]:
            dist_cand = dist[thisNode]+NextCost
            if dist_cand < dist[NextNode]:
                dist[NextNode] = dist_cand
                heappush(heap,(dist[NextNode],NextNode))
    return dist

N,X,Y = map(int,input().split())
graph = [[] for _ in range(N)]
graph[X-1].append((1,Y-1))
graph[Y-1].append((1,X-1))
for i in range(N-1):
    graph[i].append((1,i+1))
    graph[i+1].append((1,i))

ans = defaultdict(lambda:0)
for i in range(N):
    d = dijkstra(graph,N,i)

    for k in d:
        ans[k] += 1
for i in range(1,N):
    print(ans[i]//2)

Measured memory_bytes: 91276
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF 1e18
#define INF 1e9
#define MOD (ll)(1e9+7)
using namespace std;

#define fs first
#define sc second

using P = pair<ll,ll>;
using Pll = pair<P,ll>;
using PQ = priority_queue<P,vector<P>,greater<P>>;


signed main(){
    ll a;
    double b;
    cin >> a >> b;
    cout << (a*(ll)(floor(b * 100.0+0.5)))/100 << endl;
    return 0;
}


Measured memory_bytes: 3872
#include "bits/stdc++.h"
using namespace std;
#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define LLINF (long long) 1e18//1234567890987654321
#define INF 1234567890l
#define pb push_back
#define ins insert
#define f first
#define s second	
#define db 0
#define EPS (1e-7)    //0.0000001 the value
#define PI (acos(-1))
#define MAXN 300006
#define MAXK 26
#define MAXX 15000006
#define ll long long int
#define ld long double
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
#define FOR(ii, ss, ee) for(ll ii = ss; ii < ee; ii++)
#define space " "
#define cbr cout << "hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ((ll)x.size())
#define ph push
#define btinpct(x) __builtin_popcountll(x)
#define p2(x) (1LL<<(x))
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
typedef pair <ll, ll> pi;
typedef pair <ll, pi> spi;
typedef pair <pi, pi> dpi;
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss
ll n, m, c,A[25][25],B[25],sum;
int main()
{
	cin>>n>>m>>c;
	FOR(i,0,m)cin>>B[i];
	FOR(i,0,n)FOR(j,0,m)cin>>A[i][j];
	FOR(i,0,n)
	{
		ll ans = 0;
		FOR(j,0,m) ans += (A[i][j]*B[j]);
		ans += c;
		if(ans>0)sum++;
	}
	cout<<sum;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		int d = scan.nextInt();
		
		do {
			c -= b;
			if(c <= 0) {
				System.out.println("Yes");
				return;
			}
			
			a -= d;
			if(a <= 0) {
				System.out.println("No");
				return;
			}
		}while(true);
	}
}

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }
template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	int N; cin >> N;

	vint P(N), X(N);
	vvint G(N);
	vint dp(N, 0);
	for (int i = 1; i < N; i++) {
		cin >> P[i]; --P[i];
		G[P[i]].push_back(i);
		dp[P[i]] = INF;
	}
	cin >> X;
	
	dp[N-1] = 0;
	for (int u = N-1; u >= 0; u--) {
		vvint dp2(G[u].size()+1, vint(X[u]+1, INF));
		dp2[0][0] = 0;
		for (int i = 0; i < G[u].size(); i++) {
			auto &v = G[u][i];
			for (int j = 0; j+X[v] <= X[u]; j++) {
				chmin(dp2[i+1][j+X[v]], dp2[i][j] + dp[v]);
			}
			for (int j = 0; j+dp[v] <= X[u]; j++) {
				chmin(dp2[i+1][j+dp[v]], dp2[i][j] + X[v]);
			}
		}
		int minv = INF;
		for (int j = 0; j <= X[u]; j++) {
			chmin(minv, dp2[G[u].size()][j]);
		}
		dp[u] = minv;	
	}

	if (dp[0] == INF) {
		cout << "IMPOSSIBLE" << endl;
	} else {
		cout << "POSSIBLE" << endl;
	}
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


Measured memory_bytes: 1332
#include <algorithm>
#include <climits>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;

#define all(collection) (collection).begin(), (collection).end()
#define loop(i, times) for(int i = 0; i < times; i++)
#define seloop(i, start_index, end_index) for(int i = start_index; i < end_index; i++)
#define eqseloop(i, start_index, end_index) for(int i = start_index; i <= end_index; i++)

long CountEvenHalfK(int n, int k)
{
	long count = (n - k / 2) / k + 1;
	return (count * count * count);
}

long CountEvenXK(int n, int k)
{
	long count = n / k;
	return (count * count * count);
}

long CountOddXK(int n, int k)
{
	long count = n / k;
	return (count * count * count);
}


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

	if (n * 2 - k < 0)
	{
		cout << 0;
		return 0;
	}

	if (k % 2 == 0)
		cout << CountEvenHalfK(n, k) + CountEvenXK(n, k);
	else
		cout << CountOddXK(n, k);
	return 0;
}

Measured memory_bytes: 256
#import sys
#input = sys.stdin.readline
#input = sys.stdin.buffer.readline


#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

#import numpy as np
from collections import defaultdict

def main():
	n=II()
	A=LI()

	a=0

	ans=[]

	for i in A:
		a^=i

	for i in A:
		ans.append(a^i)

	print(*ans)












if __name__ == "__main__":
	main()


Measured memory_bytes: 33260
gets[/(\d{2})(\d{2})/]

puts case [$1.to_i.between?(1, 12), $2.to_i.between?(1, 12)]
when [false, true]
  'YYMM'
when [true, false]
  'MMYY'
when [true, true]
  'AMBIGUOUS'
else
  'NA'
end


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  set<int>a,b;
  cin>>n;
  while(n--){
    int x;
    cin>>x;
    a.insert(x);
  }
  cin>>n;
  while(n--){
    int x;
    cin>>x;
    b.insert(x);
  }
  vector<int>c;
  set_intersection(a.begin(),a.end(),b.begin(),b.end(),back_inserter(c));
  for(int i=0;i<c.size();i++)cout<<c[i]<<endl;
}


Measured memory_bytes: 22040
#include <bits/stdc++.h>
using namespace std;
int main ()
{
  string s,k;
  cin>>s>>k;
  for(int i=0;i<s.size();i++)
  {
      if(s[i]!=k[i])
      {
          cout<<"No"<<endl;
          return 0;
      }
  }
  if(s.size()==k.size()-1)
  {
      cout<<"Yes"<<endl;
  }
  return 0;
}



Measured memory_bytes: 3588
#include<iostream> 
#include<bits/stdc++.h> 
using namespace std;
int main(){ 
	ios::sync_with_stdio(false); 
	cin.tie(0); 
	int n;
	cin>>n;
	vector<int> a(n),b(n),c(n); 
	for(int i=0;i<n;i++){ 
		cin>>a[i]>>b[i]>>c[i];
	}
	vector<vector<int>> dp(n,vector<int>(3,0)); 
	dp[0][0]=a[0];
	dp[0][1]=b[0];
	dp[0][2]=c[0];
	for(int i=1;i<n;i++){ 
		dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i];
		dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b[i];
		dp[i][2]=max(dp[i-1][0],dp[i-1][1])+c[i]; 
	}
	cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2])); 


	
	return 0;
} 



Measured memory_bytes: 6912
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<cmath>

using namespace std;
using ll = long long;

int main(){
    ll k,a,b;cin>>k>>a>>b;
    ll ans=1;
    ll coin=0;
    if(b-a>1){
        for(ll i=0;i<k;i++){
            if(coin>0){
                ans+=b;
                coin--;
            }
            else if(i!=k-1&&ans>=a){
                ans-=a;
                coin++;
            }
            else ans++;
        }
    }
    else ans += k;

    cout<<ans<<endl;
}


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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int ch[31][101010];

int main() {
    int N, C;
    cin >> N >> C;
    rep(i, N) {
        int s, t, c;
        cin >> s >> t >> c;
        c--;
        ch[c][s]++;
        ch[c][t+1]--;
    }
    rep(i, C) rep(j, 101010) if (j>0) ch[i][j] += ch[i][j-1];
    rep(i, C) rep(j, 101010) if (ch[i][j]>0) ch[i][j] = 1;
    int ans = 0;
    rep(i, 101010) {
        int tmp=0;
        rep(c, C) tmp += ch[c][i];
        ans=max(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 12032
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>

using namespace std;
using ll = long long;

#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    ll x, y;
    cin >> x >> y;
    ll ans = 0;
    while (x <= y) {
        ans++;
        x *= 2;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 400000;

int gcd(int a, int b) {
	if (a < b) { return gcd(b, a); }
	if (b == 0) { return a; }
	return gcd(b, a%b);
}


int main() {

	int N;
	cin >> N;

	int A[MAX];
	repn(i, N) cin >> A[i];

	int r[MAX];
	int l[MAX];

	r[0] = 0;

	for (int i = 1; i <= N; i++) {
		r[i] = gcd(r[i - 1], A[i]);

		
	}

	l[N+1] = 0;

	for (int i = N; i >= 1; i--) {
		l[i] = gcd(l[i + 1], A[i]);

		
	}

	int ans = 0;

	rep(i, N) {
		if (gcd(r[i], l[i + 2]) > ans) {
			ans = gcd(r[i], l[i + 2]);
		}
	}

	cout << ans;

	system("PAUSE");

}

Measured memory_bytes: 4984
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;

using ll = long long;

ll binpow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1){
            res = (res * a)%mod;
        }
        a = (a * a)%mod;
        b >>= 1;
    }
    return (res%mod);
}

signed main(){
	ll a,b;
  	cin >> a >> b;
    cout << (ll)(a*b) << "\n";
    	return 0;
}

Measured memory_bytes: 3596
W, H, N = map(int,input().split())
left = 0
right = W
bottom = 0
top = H
for _ in range(N):
    x, y, a = map(int,input().split())
    if a == 1:
        left = max(left, x)
    elif a == 2:
        right = min(right, x)
    elif a == 3:
        bottom = max(bottom, y)
    else:
        top = min(top, y)
ans = (right - left) * (top - bottom)
if left > right or bottom > top:
    ans = 0
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <numeric>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)




int main() {

		int R;
		cin >> R;
		int s = R;
		if (R%2!=0) {
			s *= 2;
		}
		
		cout << s << endl;
	
}

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

#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define endl "\n"
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define rev(a) (a).rbegin(),(a).rend()
#define pll pair<ll,ll>
#define rep(i,a,b) for(long long i = (a); i <= (b); i++)

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

int main(){
	fast;
	ll t = 1; 
	//cin >> t;
	while(t--){
	   list<char> l;
	   string s; cin >> s;
	   for(auto x : s){
	       l.pb(x);
	   }
	   
	   ll q; cin >> q;
	   bool normal = true;
	   while(q--){
	       ll q1; cin >> q1;
	       if(q1 == 1){
	           if(normal) normal = false;
	           else normal = true;
	       }
	       else{
	           ll f; cin >> f;
	           char x; cin >> x;
	           if(normal){
	               if(f == 1) l.push_front(x);
	               else l.pb(x);
	           }
	           else{
	               if(f == 1) l.pb(x);
	               else l.push_front(x);
	           }
	       }
	   }
	   
	   if(normal){
	       for(auto x : l) cout << x;
	   }
	   else{
	       string s; cin >> s;
	       for(auto x : l) s += x;
	       reverse(all(s));
	       cout << s << endl;
	   }
	}
}

Measured memory_bytes: 10064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr long long INF = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int N;
    cin>>N;
    vector<vector<int>> x(15,vector<int>(15,-1));
    vector<vector<int>> y(15,vector<int>(15,-1));
    int A[N];
    rep(i,N){
        cin>>A[i];
        rep(j,A[i]){
            cin>>x[i][j]>>y[i][j];
            x[i][j]--;
        }

    }
    int ans=0;
    for(int bit=0;bit<(1<<N);bit++){
        int c=0;
        for(int i=0;i<N;i++){
            if(bit&(1<<i)){
                c++;
                rep(j,A[i]){
                    if(y[i][j]==1&&!(bit&(1<<x[i][j]))) c=-16;
                    if(y[i][j]==0&&(bit&(1<<x[i][j]))) c=-16;
                }
            }
            if(c==-16) break;
        }
        ans=max(ans,c);
    }
    cout << ans << endl;

    



}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::sort;

int main()
{
  string w;
  string ans = "Yes";

  cin >> w;
  sort(w.begin(), w.end());

  char prev = w[0];

  for(int i = 1; i < w.length(); i++) {
    // odd
    if(i % 2 != 0 && prev != w[i]) {
      ans = "No";
      break;
    } else {
      prev = w[i];
    }
  }
  if(w.length() == 1) {
    ans = "No";
  }
  cout << ans << endl;
}


Measured memory_bytes: 256