akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define lld double
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define all(v) v.begin(),v.end()
#define vc vector
#define rep1(it,v) for(it=v.begin();it!=v.end();it++)
#define ayush ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define input(v) for(auto &it:v)cin>>it
#define M 1000000007
#define pb push_back

ll dp[105][100005]; 


int main()
{
    ll n,k; cin>>n>>k; vc<ll> v1(n); input(v1);
    
    rep(i,0,v1[0]) dp[0][i]=1; 
    
    rep(i,1,n-1)
    {
        vc<ll> v2(k+1); v2[0]=dp[i-1][0];
        rep(j,1,k) v2[j]=(v2[j-1] + dp[i-1][j])%M;
        rep(j,0,k)
        {
            if(j-v1[i] > 0)
            dp[i][j]=(v2[j] - v2[j-v1[i]-1] + M)%M;
            else 
            dp[i][j]=v2[j];
        }
    }
    
    cout<<dp[n-1][k];
    
}

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

class disjointset{

  public:
    vector<int>rank,parent,sz;
	disjointset(int size){
        rank=parent=sz=vector<int>(size+1);
        for(int i=0;i<=size;i++)rank[i]=0,parent[i]=i,sz[i]=1;
	}
    int root(int n){return (parent[n]==n?n:parent[n]=root(parent[n]));}
    void unite(int x,int y){
        x=root(x);y=root(y);
        if(x!=y){
            if(rank[x]>rank[y])parent[y]=x,sz[x]+=sz[y];
            else parent[x]=y,sz[y]+=sz[x];
            if(rank[x]==rank[y])rank[root(x)]++;
        }
    }
    bool same(int x,int y){return root(x)==root(y);}
    int size(int n){return sz[root(n)];}
};

int main(){
    int n,m,x,y,ans=0;
    cin>>n>>m;
    int a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    disjointset ds(n);
    for(int i=0;i<m;i++){cin>>x>>y;ds.unite(x,y);}
    for(int i=0;i<n;i++)ans+=ds.same(a[i],i+1);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t x,k,d,ans;
  cin>>x>>k>>d;
  if(abs(x)<d){
    if(k%2==0){cout<<abs(x)<<endl;return 0;}
    else{cout<<min(abs(x-d),abs(x+d))<<endl;return 0;}
  }
  if(abs(x)/d>=k){
    cout<<min(abs(x+d*k),abs(x-d*k))<<endl;
    return 0;
  }
  else{
    if((abs(x)/d)%2==k%2){
      cout<<min(abs(x-abs(x)/d*d),abs(x+abs(x)/d*d))<<endl;
      return 0;
    }
    else{
      ans=min(abs(x-abs(x)/d*d),abs(x+abs(x)/d*d));
      ans=min(abs(ans+d),abs(ans-d));
      cout<<ans<<endl;
    }
  }
}

Measured memory_bytes: 3572
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int dp[101000][3];

int main(){
  string S;
  cin >> S;
  int ssize = (int)S.size();
  vector<int> a(ssize,0);
  a[0]=1;
  for(int i=1;i<ssize;i++){
    if(a[i-1]==-1){
      a[i] = a[i-2];
      a[i]++;
    }
    else if(S[i] == S[i-1]){
      if(a[i-2]==-1){
        a[i] = a[i-1]+1;
      }
      else a[i]=-1;
    }
    else a[i] = a[i-1]+1;
  }
  //for(auto s:a) cout << s << " ";
  sort(rall(a));

  cout << a[0] << endl;
  return 0;
}


Measured memory_bytes: 1412
sS = input().rstrip()
sT = input().rstrip()




def fConv2B(sA):
    iL = len(sA)
    dA = {}
    for s in "abcdefghijklmnopqrstuvwxyz":
        dA[s] = 0
    iCounter = 1
    for i in range(iL):
        s = sA[i]
        if s in dA:
            if dA[sA[i]] == 0:
                dA[sA[i]] = iCounter
                iCounter += 1
        if  iCounter  == 27 :
            break

    aR = [0]*iL
    for i in range(iL):
        aR[i] = dA[sA[i]]
#   print(aR)
    return aR



if fConv2B(sS) == fConv2B(sT) :
    print("Yes")
else:
    print("No")


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


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

    // int init_i = min(N, Y / 10000);
    int init_i = N;
    for (int i = init_i; i >= 0; i--) {

        // int init_j = min(N - i, (Y - 10000) / 5000);
        int init_j = N - i;
        for (int j = init_j; j >= 0; j--) {

            int k = N - i - j;
            if (i * 10000 + j * 5000 + k * 1000 == Y) {
                if (i + j + k == N) {
                    cout << i << ' ' << j << ' ' << k << '\n';
                    return 0;
                }
            }
        }
    }
    cout << "-1 -1 -1" << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <map>
#include <set>

#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)

typedef long long int64;

using namespace std;

int main() {
	ios_base::sync_with_stdio(0);
	int n, m, k;
	cin >> n >> m >> k;
	vector<string> s(n);
    for (int i = 0; i < n; ++i) {
	    cin >> s[i];
	}		
	vector<vector<int>> a(n, vector<int>(m, 0));
	vector<pair<int, int>> p;
	int max_x = 0;
	for (int i = 0; i < n; ++i) {
	    for (int j = 0; j < m; ++j) {
		    if (s[i][j] == '#') {
			    p.emplace_back(i, j);
				max_x = max(max_x, i);
			}
		}
	}
	sort(all(p));
	int prevx = -1;
	for (int step = 0; step < p.size(); ++step) {
		int lx = prevx + 1;
		int rx = p[step].first;
		if (rx == max_x) {
		   rx = n - 1;
		}
		int ly = 0;
		if (step > 0 && p[step - 1].first == p[step].first) {
		    ly = p[step - 1].second + 1;
		}
		int ry = p[step].second;
		if (step + 1 == p.size() || p[step + 1].first != p[step].first) {
	        ry = m - 1;
		}
		for (int i = lx; i <= rx; ++i) {
			for (int j = ly; j <= ry; ++j) {
			    a[i][j] = step + 1;
			}
		}
	    if (step + 1 < p.size() && p[step + 1].first != p[step].first) {
	        prevx = p[step].first;
		}
	}
	for (int i = 0; i < n; ++i) {
	    for (int j = 0; j < m; ++j) {
		    cout << a[i][j] << "  ";
		}
		cout << endl;
	}

    return 0;
}


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

int N, M;

bool check(vector<string> a, vector<string> b, int x, int y) {
  for (int i = 0; i < M; i++) {
    string sub = a[i + y].substr(x, M);
    if (sub != b[i]) {
      return false;
    }
  }
  return true;
}

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

  vector<string> A(N);
  vector<string> B(M);
  rep(i, N) cin >> A[i];
  rep(i, M) cin >> B[i];

  for (int i = 0; i <= N - M; i++) {
    for (int j = 0; j <= N - M; j++) {
      if (check(A, B, j, i)) {
        puts("Yes");
        return 0;
      };
    }
  }
  puts("No");
}

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

int main() {
	int n;
	cin>>n;
	if( n&1 )
		cout<<(n/2)*(n/2+1)<<endl;
	else
		cout<<n*n/4<<endl; 
	return 0;
	}


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

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define debug(i) cout << i << endl;
#define debugarr(a) for(auto i : a) cout << i << " ";

#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define pi pair<int,int>
#define pll pair<ll, ll>
#define vpi vector<pi>

#define MAXN 100010
#define LEFT(x) (x<<1)
#define RIGHT(x) (x<<1|1)

using namespace std;

int tree[MAXN * 4];
bool used[MAXN];

void build(int i, int l, int r) {
    if(l == r) tree[i] = (!used[l] ? l : -1);
    else {
        int mid = (l+r)>>1;
        build(LEFT(i), l, mid);
        build(RIGHT(i), mid+1, r);
        tree[i] = max(tree[LEFT(i)], tree[RIGHT(i)]);
    }
}

void update(int i, int l, int r, int pos) {
    if(l == r) tree[i] = -1;
    else {
        int mid = (l+r)>>1;
        if(pos <= mid)
            update(LEFT(i), l, mid, pos);
        else
            update(RIGHT(i), mid+1, r, pos);
        tree[i] = max(tree[LEFT(i)], tree[RIGHT(i)]);
    }
}

int query(int i, int l, int r, int x, int y) {
    if(l >= x && r <= y) {
        //cout << "no: " << i << endl;
        return tree[i];
    }
    else if(r < x || l > y) return -1;
    else {
        //cout << "no: " << i << endl;
        int mid = (l+r)>>1;
        return max(query(LEFT(i), l, mid, x, y), query(RIGHT(i), mid+1, r, x, y));
    }
}

bool cmp(pi p1, pi p2) {
    return p1.S > p2.S;
}

int main() {
    ios_base::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;

    ll ans = 0;
    pi work[n];
    for(int i = 0; i < n; i++) cin >> work[i].F >> work[i].S;
    sort(work, work + n, cmp);

    bool used[m+1];
    memset(used, false, sizeof used);
    build(1, 1, m+1);
    for(pi par : work) {
        if(par.F > m) continue;
        int dia = query(1, 1, m+1, 1, m - par.F + 1);
        if(dia <= 0) continue;
        else {
            ans += par.S;
            update(1, 1, m+1, dia);
            /*for(int i = 1; i <= m * 3; i++) {
                cout << "no: " << i << endl;
                cout << " max: " << tree[i] << endl;
            }*/
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 2176
import java.util.Scanner;

public class Main {

    public static final int MOD = 1000000007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int x = Integer.parseInt(sc.next());
        int t = Integer.parseInt(sc.next());
        int ans = (n / x) * t;
        if (n % x != 0) {
            ans += t;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 35548
using System;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            const double btc = 380000.0;
            var n = int.Parse(Console.ReadLine());
            double sum = 0.0;
            for(var i = 0; i < n; i++)
            {
                var input = Console.ReadLine().Split(' ');
                if (input[1] == "BTC")
                {
                    sum += double.Parse(input[0]) * btc;
                }
                else
                {
                    sum += double.Parse(input[0]);
                }
            }
            Console.WriteLine(sum);
        }
    }
}


Measured memory_bytes: 11220
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long 
#define REP(i, a, b) for (ll i = a; i < b; i++)
#define REPI(i, a, b) for (ll i = b - 1; i >= a; i--)
#define i_os ios::sync_with_stdio(0);  cin.tie(0);  cout.tie(0);
#define INF (ll)1e18 + 100
#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
#define MAX 1e6
/*SOME BITMASK KNOWLEDGE
1)x & (x - 1):sets the last one bit of x to zero
power of two exactly when x & (x − 1) = 0.
2)x & -x:sets all the one bits to zero, except last one bit
3)x | (x - 1):inverts all the bits after the last one bit*/
#define o_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define o_setll tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
typedef tree<pair<ll, ll>,null_type,less<pair<ll, ll>>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set


int main() 
{
	ll n;
	cin>>n;
	ll arr[n];
	REP(i,0,n){
		cin>>arr[i];
	}
	ll dp[2][n+2];
	REP(i,0,n+2){
		dp[0][i] = 0; dp[1][i] = 0;
	}
	dp[1][n-1] = arr[n-1];
	dp[0][n-2] = max(arr[n-1],arr[n-2]);
	dp[1][n-2] = max(arr[n-1],arr[n-2]);

	REPI(i,0,n-2){
		if((n-i) % 2 == 1){
			dp[0][i] = max(arr[i] + dp[0][i+2],max(arr[i+1] + dp[0][i+3],arr[i+2] + dp[1][i+4]));
			dp[1][i] = arr[i] + dp[1][i+2];	
			// cout<<i<<endl;
		}
		else {
			dp[0][i] = max(arr[i] + dp[0][i+2],arr[i+1] + dp[1][i+3]);
			dp[1][i] = dp[0][i];
		}
	}
	// REP(i,0,n){
	// 	cout<<dp[0][i]<<" "<<dp[1][i]<<endl;
	// }
	cout<<dp[0][0]<<endl;

	return 0;
}  


Measured memory_bytes: 8324
n=int(input())
import sys
mod=10**9+7 ; inf=float("inf")
from math import sqrt, ceil
from collections import deque, Counter, defaultdict #すべてのkeyが用意されてる defaultdict(int)で初期化
input=lambda: sys.stdin.readline().strip()
sys.setrecursionlimit(11451419)
from decimal import ROUND_HALF_UP,Decimal  #変換後の末尾桁を0や0.01で指定
  #Decimal((str(0.5)).quantize(Decimal('0'), rounding=ROUND_HALF_UP))
from functools import lru_cache
from bisect import bisect_left as bileft, bisect_right as biright
#メモ化再帰defの冒頭に毎回 @lru_cache(maxsize=10**10)
#引数にlistはだめ
#######ここまでテンプレ#######
#ソート、"a"+"b"、再帰ならPython3の方がいい
#######ここから天ぷら########

d=defaultdict(int)
for i in range(n):
    d[input()]+=1
m=int(input())
for i in range(m):
    d[input()]-=1
print(max(0, max(d.values())))

Measured memory_bytes: 9952
#include <stdio.h>
int main(){
    int a,b,c[1000]={},d=0,flag,sum=0;
    scanf("%d%d",&a,&b);
  for(int i=0;i<a;i++){
    scanf("%d",&c[i]);
  }
  
  do{
    flag=0;
    for(int i=0;i<a-1;i++){
   if(c[i]>c[i+1]) {
     d=c[i];
     c[i]=c[i+1];
     c[i+1]=d;
     flag++;
   }
  }
  }while(flag);
    
    for(int i=0;i<b;i++){
    sum+=c[i];
    }
  printf("%d",sum);
  return 0;
}

Measured memory_bytes: 1740
#include<iostream>
#include<cstdlib>
#include<iomanip>
#include<cmath>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;



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

	vector<int> p(n), q(n);
	for (int i = 0; i < n; i++)
		cin >> p[i];
	for (int i = 0; i < n; i++)
		cin >> q[i];

	vector<int> a(n);
	for (int i = 0; i < n; i++)
		a[i] = i + 1;

	map<vector<int>, int> mp;
	do {
		mp[a] = mp.size();
	} while (next_permutation(a.begin(), a.end()));

	cout << abs(mp[p] - mp[q]) << endl;
}

Measured memory_bytes: 5248
/* << IN THE NAME OF GOD >> */
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define pob pop_back
#define ft first
#define sc second
#define err(x) cerr << #x  << " = "<<  x << '\n'
#define out(x) cout << x << '\n'
#define forp(i, r, l) for(int i = int(r); i < int(l); i++)
#define forn(i, r, l) for(int i = int(r); i > int(l); i--)
#define FAST ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef pair<int, int> pii;
const int maxn = 1e6;
 
		  
int main()
{FAST;
        int a ,b;
        cin >> a >> b;
        a < 9 && b < 9 ? cout << "Yay!" : cout << ":(";

	return 0;
}
 












Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  vector<int> oldarr(N), newarr;
  for(int i=0;i<N;++i) cin>>oldarr[i];
  vector<int> ans;
  bool can;
  int index;
  for(int i=0;i<N;++i) {
    newarr.clear();
    can = false;
    for(int j=oldarr.size()-1;j>=0;--j) {
      if(oldarr[j]==j+1) {
        can = true;
        index = j;
        ans.push_back(oldarr[j]);
        break;
      }
    }
    if(!can) break;
    for(int j=0;j<oldarr.size();++j) {
      if(j==index) continue;
      newarr.push_back(oldarr[j]);
    }
    oldarr = newarr;
  }
  if(!can) {
    cout<<-1<<endl;
    return 0;
  }
  for(int i=N-1;i>=0;--i) {
    cout<<ans[i]<<endl;
  }
}


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

int main(){
  string s;
  cin >> s;

  if(s == "Sunny") cout << "Cloudy";
  if(s == "Cloudy") cout << "Rainy";
  if(s == "Rainy") cout << "Sunny";
  
  return 0;
}

Measured memory_bytes: 256
import bisect
import copy
import heapq
import sys
import itertools
import math
import queue
from functools import lru_cache
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7 

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


class V:
    def __init__(self, f, v=None):
        self.f = f
        self.v = v
 
    def __str__(self):
        return str(self.v)
 
    def ud(self, n):
        if n is None:
            return

        if self.v is None:
            self.v = n
            return
        self.v = self.f(self.v, n) 


def main():
    N, M, K = read_values()
    A = read_list()
    B = read_list()

    if sum(A) + sum(B) <= K:
        print(N + M)
        return

    SB = [0] * (M + 1)
    for i in range(M):
        SB[i + 1] = SB[i] + B[i]

    res = V(max, 0)
    for i in range(N):
        j = bisect.bisect_right(SB, K) - 1
        res.ud(j + i)
        K -= A[i]
        if K < 0:
            break
    else:
        j = bisect.bisect_right(SB, K) - 1
        res.ud(j + N)
    
    print(res)


if __name__ == "__main__":
    main()



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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define INF LONG_LONG_MAX
#define MOD 1000000007
#define yn(f) cout << (f ? "Yes" : "No") << endl;
#define YN(f) cout << (f ? "YES" : "NO") << endl;

int k,a,b;

signed main() {
    cin >> k >> a >> b;
    int c = k;
    while(true) {
        if (a <= c && c <= b) {
            cout << "OK" << endl;
            return 0;
        }
        if (b < c) {
            cout << "NG" << endl;
            return 0;
        }
        c += k;
    }
}




Measured memory_bytes: 3636
#include<iostream>
#include<queue>
#include<vector>
using namespace std;

struct P
{
	int x,y,l;
};

int main(){
	int w,h;
	int dx[]={0,0,-1,1};
	int dy[]={-1,1,0,0};

	while(cin >> w >> h, w|h){

		vector< vector<bool> > map;
		vector<bool>b;

		for(int ix=0;ix<w*2-1+2;ix++)
			b.push_back(true);
		map.push_back(b);

		for(int iy=0;iy<h*2-1;iy++){
			b.clear();
			b.push_back(true);
			if(iy%2==0){
				for(int ix=0;ix<w*2-1;ix++){
					bool t=0;
					if(ix%2==1)
						cin >> t;
					b.push_back(t);
				}
			}else{
				for(int ix=0;ix<w*2-1;ix++){
					bool t=0;
					if(ix%2==0)
						cin >> t;
					b.push_back(t);
				}
			}
			b.push_back(true);
			map.push_back(b);
		}
		b.clear();
		for(int ix=0;ix<w*2-1+2;ix++)
			b.push_back(true);
		map.push_back(b);

		queue<P> que;
		que.push((P){1,1,0});
		int path=0;
		while(!que.empty()){

			P p=que.front();que.pop();
			if(p.x==w*2-1&&p.y==h*2-1){
				path=p.l+1;
				break;
			}

			/*
			cout << endl;
			for(int iy=0;iy<map.size();iy++){
				for(int ix=0;ix<map.at(iy).size();ix++)
				if(p.x!=ix||p.y!=iy)
					cout << map[iy][ix];
				else
					cout << X;
				cout << endl;
			}
			cout << endl;
			*/

			if(!(p.x+p.y))path++;
			map[p.y][p.x]==true;
			for(int i=0;i<4;i++){
				if(!map[p.y+dy[i]][p.x+dx[i]]){
					map[p.y+dy[i]][p.x+dx[i]]=true;
					que.push((P){p.x+dx[i]*2,p.y+dy[i]*2,p.l+1});
				}
			}
		}
		cout << path << endl;
	}

	return 0;
}

Measured memory_bytes: 1232
def actual(A, B, K):
    min_left = A
    max_left = min(A + (K - 1), B)

    min_right = max(B - (K - 1), max_left + 1)
    max_right = B

    left = set(range(min_left, max_left + 1))
    right = set(range(min_right, max_right + 1))

    unique_nums = left | right

    return '\n'.join(map(str, sorted(unique_nums)))

A, B, K = map(int, input().split())
print(actual(A, B, K))

Measured memory_bytes: 9116
N, X = map(int, input().split())

a, p = [1], [1]
for i in range(N):
    a.append(a[i] * 2 + 3)
    p.append(p[i] * 2 + 1)

def f(N, X):
    if N == 0:
        return 0 if X <= 0 else 1
    elif X <= 1 + a[N-1]:
        return f(N-1, X-1)
    else:
        return p[N-1] + 1 + f(N-1, X-2-a[N-1])

print(f(N, X))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
#ifdef XVENOM
	#define errp(...) fprintf(stderr, __VA_ARGS__)
	#define dbg(...) errp("[%s]: ", #__VA_ARGS__), dbg_str(__VA_ARGS__)
#else
	#define errp(...)
	#define dbg(...)
#endif
template <typename U, typename V> string to_string (pair<U, V>);
string to_string (const string& e_) { return "\"" + e_ + "\""; }
string to_string (char e_) { return "\'" + string(1, e_) + "\'"; }
string to_string (bool e_) { return e_ ? "true" : "false"; }
template <typename T> string to_string (T e_) {
	string s_ = "[ ";
	for (const auto& x_ : e_) s_ += to_string(x_) + " ";
	return s_ + "]";
}
template <typename U, typename V> string to_string (pair<U, V> e_) {
	return "(" + to_string(e_.first) + ", " + to_string(e_.second) + ")";
}
void dbg_str () { errp(" \n"); }
template <typename U, typename... V> void dbg_str (U u, V... v) {
	errp(" %s", to_string(u).c_str()); dbg_str(v...);
}
/* --- */

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	/* --- */
	int k, i;
	string s;

	cin >> s;
	cin >> k;

	for(i = 0; i < k - 1; i++){
		if(s[i] != '1') break;
	}	

	cout << s[i];
}

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

void maxHeapify(int *,int);
void buildMaxHeap(int *);
int left(int i){return 2*i;}
int right(int i){return 2*i+1;}

int H;

int main()
{
  int *A,i;

  scanf("%d",&H);
  if(H<1 || H>500000) exit(1);

  A = (int *)malloc(sizeof(int)*H*2+1);
  
  for(i=1;i<=H;i++)
    scanf("%d",&A[i]);

  buildMaxHeap(A);

  for(i=1;i<=H;i++)
    printf(" %d",A[i]);
  printf("\n");

  return 0;
}

void maxHeapify(int *A,int i)
{
  int l,r,largest,t;
  
  l = left(i);
  r = right(i);
  //printf("/l=%d,r=%d\n",l,r);

  if(l<=H && A[l]>A[i]) largest = l; //親と左の子の比較
  else largest = i;
  if(r<=H && A[r]>A[largest]) largest = r; //親と右の子の比較
  if(largest != i){ //子が大きければ交換
    t = A[i];
    A[i] = A[largest];
    A[largest] = t;
    maxHeapify(A,largest); 
  }
}

void buildMaxHeap(int *A)
{
  int i;
  
  for(i=H/2;i>=1;i--)
    maxHeapify(A,i);
}



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

void Main() {
  long long X, K, D;
  cin >> X >> K >> D;

  X = abs(X);
  long long times = X / D;
  if (times > K) cout << X - D * K << endl;
  else {
    if ((times - K) % 2 == 0) cout << X % D << endl;
    else cout << abs(X % D - D) << endl;
  }
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}



Measured memory_bytes: 3620
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.lang.*;


public class Main{
	static final long MOD = 1000000007;
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int n = sc.nextInt();
		String s = sc.next();
		String t = sc.next();
		StringBuilder sb = new StringBuilder(2 * n);
		for (int i = 0; i < n; i++) {
			sb.append(s.charAt(i));
			sb.append(t.charAt(i));
		}
		System.out.println(sb);
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	private int readByte() {
		if (hasNextByte()) {
			return buffer[ptr++];
		} else {
			return -1;
		}
	}
	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}
	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
		return hasNextByte();
	}
	public String next() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	public long nextLong() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || Integer.MAX_VALUE < nl) {
			throw new NumberFormatException();
		}
		return (int) nl;
	}
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 23252
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;

int main() {
    int R[MAX], n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> R[i];
    }
    int maxv = -10000000000;
    int minv = R[0];
    
    for (int i = 1; i < n; i++) {
        maxv = max(maxv, R[i] - minv);
        minv = min(minv, R[i]);
    }
    
    cout << maxv << endl;
    return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
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; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

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


    ll N, K;
    cin >> N >> K;
    ll res = 0;
    while(N>0){
    	res++;
    	N /= K;
    }
    cout << res << endl;
    return 0;
}

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

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str_array = in.readLine().split(" ");
    int n = Integer.parseInt(str_array[0]);
    int m = Integer.parseInt(str_array[1]);
    System.out.println(n==m?"Yes":"No");
  }
}

Measured memory_bytes: 21076
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<long>p(n+1);
  int i;
  for(i=1;i<=n;i++){
    cin >> p[i];
  }
  int chk = 0;
  int tmp = 0;
  int cnt = 0;
  while(chk == 0){
    chk = 1;
    if(p[1] == 1){
      p[1] = p[2];
      cnt++;
      p[2] = 1;
    }
    for(i=2;i<n;i++){
      if(p[i]==i){
        tmp = p[i];
        p[i] = p[i+1];
        p[i+1] = tmp;
        cnt++;
      }
    }
    if(p[n]==n){
      p[n] = p[n-1];
      p[n-1] = n;
      cnt++;
    }
    for(i=1;i<=n;i++){
      if(p[i]==i)chk=0;
    }

  }
  cout << cnt << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <ctype.h>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define all(v) (v).begin(), (v).end()
#define rev(s) (s).rbegin(), (s).rend()
#define MP make_pair
#define X first
#define Y second

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<double, double> dP;

const int INF = 100000000;
const double EPS = 1e-10;

vector<string> parse(string s){
	int idx = 0;
	vector<string> words;
	FOR(i, 1, s.size()){
		if(s[i] == '_' || (s[i] >= 'A' && s[i] <= 'Z')){
			words.push_back(s.substr(idx, i-idx));
			if(s[i] == '_')i++;
			idx = i;
		}
	}
	words.push_back(s.substr(idx, s.size()-idx));

	return words;
}

string ChangeCamelCase(vector<string> words, char type){
	string res;
	rep(i, words.size()){
		if(type == 'D' || (type == 'L' && i == 0)) words[i][0] = tolower(words[i][0]);
		else words[i][0] = toupper(words[i][0]);

		res += words[i];

		if(type == 'D' && (i != words.size()-1)) res+= '_';
	}

	return res;
}

int main(){
	string s;
	char t;

	while(cin >> s >> t, t != 'X'){
		cout << ChangeCamelCase(parse(s), t) << endl;
	}

	return 0;
}

Measured memory_bytes: 1200
#include <iostream>

using namespace std;

long long gcd(long long a, long long b) {
	if(a < b) {
		long long tmp = a;
		a = b;
		b = tmp;
	}
	while(a % b) {
		/* a = n*b + r */
		/* a -> b, b -> r */
		long long r = a % b;
		a = b;
		b = r;
	}
	
	return b;
}
int main() {
	int N;
	cin >> N;
	long long lcd = 1;
	for(int i = 0; i < N; i++) {
		long long T;
		cin >> T;
		long double lcd2 = lcd / gcd(T, lcd);
		lcd = lcd2 * T;
	}
	cout << lcd << endl;
	return 0;
}


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

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

typedef pair< long long, long long > P;
typedef pair< long long, P > PP;
typedef pair< P, P > PPP;

const long long MOD = 1e9 + 7;
const long long  INF = 5e18;
const double DINF = 5e14;
const double eps = 1e-10;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };

#define fr first
#define sc second
#define pb push_back
#define eb emplace_back
#define ALL(x) (x).begin(),(x).end()



ull n, X, x[200010], rui[200010], ans = INF;

int main() {
	cin >> n >> X;
	for (int i = 0;i < n;i++) {
		cin >> x[i];
		rui[i + 1] = rui[i] + x[i];
	}
	for (int k = 1;k <= n;k++) {
		ull sum = n * X + k * X, p = 5;
		for (int now = n;now > 0;) {
			if (now == n)sum += (rui[now] - rui[max(0, now - 2 * k)])*p, now -= 2 * k, now = max(now, 0), p += 2;
			else sum += (rui[now] - rui[max(0, now - k)])*p, p+=2, now -= k, now = max(now, 0);
		}
		if (sum < 0)continue;
		ans = min(ans, sum);
	}
	cout << ans << endl;
	return 0;
}



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

int main() {
	int N;
	string s;
	cin>>N>>s;
	int l= 0;
	int r = 0;
	for (int i=0; i<N; i++){
		if (s[i]=='(') l++;
		else l--;
		if (l<0){
			l=0;
			r++;
		}
	}
	while(r--) cout<<'(';
	cout << s;
	while(l--) cout<<')';
}

Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str();}
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);

int main(){
	int n;
	while(cin>>n,n){
		int ans=0;
		FOR(i,0,sqrt(n)+1){
			FOR(j,i,sqrt(n-i*i)+1){
				FOR(k,j,sqrt(n-i*i-j*j)+1){
					int d=n-i*i-j*j-k*k;
					if((int)sqrt(d)>=k&&sqrt(d)==(int)sqrt(d)){
						ans++;;
					}
				}
			}
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 1168
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

bool lead0(const string &a){
	return a.size() > 1 && a[0] == '0';
}

bool eqcomp(string a, string b, string c, char x){
	replace(a.begin(), a.end(), 'X', x);
	replace(b.begin(), b.end(), 'X', x);
	replace(c.begin(), c.end(), 'X', x);

	if(lead0(a) || lead0(b) || lead0(c)){
		return false;
	}

	size_t len = max(a.size(), b.size());
	string t(len + 1, '0');
	for(size_t i = 0; i < len; ++i){
		if(i < a.size()){
			t[i] += a[a.size() - 1 - i] - '0';
		}
		if(i < b.size()){
			t[i] += b[b.size() - 1 - i] - '0';
		}
		if(t[i] > '9'){
			t[i] -= 10;
			++t[i + 1];
		}
	}

	if(*t.rbegin() == '0'){
		t.erase(t.end() - 1);
	}
	reverse(t.begin(), t.end());
	return t == c;
}

int main(){
	char bufa[128] = "", bufb[128] = "", bufc[128] = "";
	string a, b, c;
	while(scanf(" %[^+]+%[^=]=%s", bufa, bufb, bufc) == 3){
		a = bufa;
		b = bufb;
		c = bufc;

		char ans;
		for(ans = '0'; ans <= '9' && !eqcomp(a, b, c, ans); ++ans);
		printf(ans > '9' ? "NA\n" : "%c\n", ans);
	}
}

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

MOD = 1000000007  # type: int


def solve(N: int, A: "List[int]"):
    ans = 0

    B = [sum(A[1:])]
    for i, a in enumerate(A[1:-1]):
        B.append(B[i] - a)

    for i, ai in enumerate(A[:-1]):
        ans += (ai * B[i]) % MOD
    
    print(ans % MOD)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 108560
import java.util.*;

public class Main{
    public static void main(String[]args){
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int D = sc.nextInt();
        boolean flag = true;
        while(flag){
            C=C-B;
            A=A-D;
            if(C<=0 || A<=0){
                flag = false;
            }
        }
        if(C<=0) System.out.println("Yes");
        else System.out.println("No");
    }
}

Measured memory_bytes: 35780
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  // フレンドリーさでsort、greedyに
  // 最大の人は１回貢献、次点の人からは2回貢献
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i, N) cin >> A[i];
  sort(A.rbegin(), A.rend());
  ll ans = A[0];
  int remain = N - 2;
  int cur = 1;
  while (remain > 0) {
    if (remain == 1) {
      ans += A[cur];
      break;
    } else {
      ans += 2 * A[cur];
      ++cur;
      remain -= 2;
    }
  }
  cout << ans << '\n';
  return 0; 
}

Measured memory_bytes: 4044
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <complex>
using namespace std;

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

#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp make_pair
#define ERASE(v,i) (v).erase(remove(all(v),i),(v).end())
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(it,c) for(typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define debug(x) cerr<<#x<<" = "<<(x)<<endl;
#define LINE cerr<<"LINE: "<<__LINE__<<endl;

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T> void preview(T a,T b){for(T it=a;it!=b;++it)cerr<<*it<<" ";cerr<<endl;}

const int INF = 100000000;
const double PI = acos(-1.0), EPS = 1e-10;

int main() {
	for(int N; cin >> N, N;) {
		vector<int> v(N);
		rep(i,N) cin >> v[i];
		int MIN = INF;
		for(int i = 0; i < (1 << N); i++) {
			int a = 0, b = 0;
			for(int j = 0; j < N; j++) {
				if(i & (1 << j)) a += v[j];
				else b += v[j];
			}
			int ab = abs(a - b);
			MIN = min(ab, MIN);
		}

		cout << MIN << endl;
	}
	return 0;
}

Measured memory_bytes: 0
N = int(input())

d={}
maxN=0
for i in range(N):
  k = input()
  if k in d:
    d[k] += 1
  else:
    d[k]=1
  maxN = max(d[k], maxN)

s = []
for k,v in d.items():
  if maxN==v:
    s.append(k)
s=sorted(s)
for _ in s:
  print(_)

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

using namespace std;

/*  テンプレここから */
typedef long long ll;

#define rep(i, n) for(int i = 0; i < n; ++i)
#define repi(i, start, end) for(int i = start; i < end; ++i)
#define all(x) (x).begin(), (x).end()
#define INF (1e9)
#define INFL (1e18)
#define add_mod(a, b, x) ( (ll)(a) + (ll)(b) ) % (ll)(x)
#define mul_mod(a, b, x) ( ((ll)(a) % (ll)(x)) * ((ll)(b) % (ll)(x)) ) % (ll)(x)
#define out(x) cout << (x) << endl;
#define outyes(bool_val) cout << (bool_val ? "yes" : "no") << endl;
#define outYes(bool_val) cout << (bool_val ? "Yes" : "No") << endl;
#define outYES(bool_val) cout << (bool_val ? "YES" : "NO") << endl;
#define outPossible(bool_val) cout << (bool_val ? "Possible" : "Impossible") << endl;
#define outPOSSIBLE(bool_val) cout << (bool_val ? "POSSIBLE" : "IMPOSSIBLE") << endl;

ll sub_mod(ll a, ll b, ll x){
    ll tmp = (a - b) % x;
    if(tmp < 0) tmp += x;
    return tmp;
}
ll gcd(ll a, ll b){
    if(b == 0) return a;
    else return gcd(b, a % b);
}

int dx[] = {0, 1, 0, -1};
int dy[] = {-1, 0, 1, 0};
/*  テンプレここまで */

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

    int n;
    cin >> n;

    int min_cnt[30];
    rep(i, 30) min_cnt[i] = 100000000;

    rep(i, n){
        int cnt[30] = {0};
        string s;
        cin >> s;
        rep(j, s.size()) ++ cnt[s[j] - 'a'];
        rep(j, 30) min_cnt[j] = min(min_cnt[j], cnt[j]);
    }

    rep(i, 30){
        rep(j, min_cnt[i]) cout << (char)('a' + i);
    }
    cout << endl;
}

Measured memory_bytes: 256
#pragma comment(linker, "/STACK:102400000,102400000")
#include <iostream>
#include <string>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <ctime>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>
#include <cmath>
#include <assert.h>
#include <iomanip>
using namespace std;
#define vi vector<int>
#define pii pair<int,int>
#define x first
#define y second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define SZ(x) (int)x.size()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=b-1;i>=a;i--)
#define pi acos(-1)
#define mod 1000000007
#define inf 1000000007
#define ll long long
#define ull unsigned long long
#define DBG(x) cerr<<(#x)<<"="<<x<<"\n";
#define N 100010
#define _DEBUG
template <class U,class T> void Max(U &x, T y){if(x<y)x=y;}
template <class U,class T> void Min(U &x, T y){if(x>y)x=y;}
template <class T> void add(int &a,T b){a=(a+b)%mod;}
inline int gcd(int a,int b){return b==0?a:gcd(b,a%b);}
inline ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}

int pow(int a,int b){
    int ans=1;
    while(b){
        if(b&1)ans=1LL*ans*a%mod;
        a=1LL*a*a%mod;b>>=1;
    }
    return ans;
}
int pow(int a,int b,int c){
    int ans=1;
    while(b){
        if(b&1)ans=1LL*ans*a%c;
        a=1LL*a*a%c;b>>=1;
    }
    return ans;
}

int main(){
    //srand(time(NULL)+clock());
    int T,ca=0,k,i,j,m=0,K,n;
    //double start=clock();
    int a,b;
    scanf("%d%d%d",&K,&a,&b);
    if(b<=a+1||K<=a){
        printf("%d\n",K+1);return 0;
    }
    K-=a-1;
    ll ans=a+1LL*(b-a)*(K/2);
    if(K&1)ans++;
    printf("%lld\n",ans);
    //cerr<<(1.*clock()-start)/CLOCKS_PER_SEC<<"\n";
}


Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
 
public class Main {
 
	public Main() {
		// TODO 自動生成されたコンストラクター・スタブ
	}
 
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		Map <Long,Long> mapA = new HashMap<Long,Long> ();
		Map <Long,Long> mapB = new HashMap<Long,Long> ();
			// 整数の入力
		int a,b,ans;

		a = sc.nextInt();
		b = sc.nextInt();
		sc.close();
		
		if(a-b>a+b) {
			ans=a-b;
		}
		else {
			ans=a+b;
		}
		if(a*b>ans) {
			System.out.print(a*b);
		}
		else {
			System.out.print(ans);
		}

			// 出力
 
	}
}

Measured memory_bytes: 21844
#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int isprime(int n){
    int count =0;
    for(int i=2;i<=sqrt(n);i++)
    if(n%i==0)count++;
    if(count)return 0;
    return 1;
}
int main()
{
  int t;
   for(int i=0;i<5;i++){
       cin>>t;
       if(t==0)cout<<i+1;
   }
     return 0;
}




Measured memory_bytes: 3620
using System;
using System.Linq;
using System.Collections.Generic;

namespace AtCoder
{
	class Program
	{
		public static void Main()
		{
			var inputNums = IO.ReadIntArray();
			var votes = IO.ReadIntArray();
			var targetVoteNum = votes.OrderByDescending(iNumber => iNumber).ElementAt(inputNums[1] - 1);
			var per = targetVoteNum / (float)votes.Sum();
			var minPer = 1f / (4 * inputNums[1]);
			IO.Write(per >= minPer);
		}
	}

	public static class IO
	{
		public static string   Read()							  { return Console.ReadLine(); }
		public static string[] ReadArray(char iSplitter = ' ')	  { return Read().Split(iSplitter); }
		public static int	   ReadInt()						  { return int.Parse(Read()); }
		public static int[]	   ReadIntArray(char iSplitter = ' ') { return ReadArray().Select(iText => int.Parse(iText)).ToArray(); }
		public static char[]   ReadCharArray()					  { return Read().ToCharArray(); }

		public static void Write(string iValue)			  { Console.WriteLine(iValue); }
		public static void Write(int iValue)			  { Console.WriteLine(iValue); }
		public static void Write(IEnumerable<int> iValue) { Console.WriteLine(string.Join(" " , iValue)); }
		public static void Write(long iValue)			  { Console.WriteLine(iValue); }
		public static void Write(decimal iValue)		  { Console.WriteLine(iValue); }
		public static void Write(bool iValue)			  { Console.WriteLine(iValue ? "Yes" : "No"); }
	}

	public static class Util
	{
		public static long Gcd(long i0 , long i1)	{ return (i0 > i1) ? _Gcd(i0 , i1) : _Gcd(i0 , i1); }
		public static long ModPow(long iBaseNumber , long iPow , long iModNumber)
		{
			var num = 1L;
			while(iPow != 0)
			{
				if((iPow & 0x1) != 0)
				{
					num = (num * iBaseNumber) % iModNumber;
				}
				iBaseNumber = (iBaseNumber * iBaseNumber) % iModNumber;
				iPow >>= 1;
			}
			return num;
		}

		private static long _Gcd(long i0 , long i1)	{ return (i1 == 0) ? i0 : _Gcd(i1 , i0 % i1); }
	}
}


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

const int N=1e5+20,MOD=1e9+7;

int n,k,dp[N],ans;

int mul(int a,int b) {return (1ll*a*b)%MOD;}

int power(int a,int b)
{
	int num=a,ans=1;
	while(b)
	{
		if(b&1) ans=mul(ans,num);
		b>>=1;
		num=mul(num,num);
	}
	return ans;
}

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

	for(int i=k;i>=1;i--)
	{
		int choices=1;
		for(int j=2*i;j<=k;j+=i,choices++)
		{
			dp[i]=(dp[i]-dp[j])%MOD;
			if(dp[i]<0) dp[i]+=MOD;
		}
		dp[i]=(dp[i]+power(choices,n))%MOD;
		ans=(ans+mul(i,dp[i]))%MOD;
	}

	printf("%d",ans);
}

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

int main()
{
	double R;
	cin >> R;
	cout << setprecision(10) << 2 * R * PI << endl;
	return 0;
}

Measured memory_bytes: 3788
#include <bits/stdc++.h>  
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define pl pair<ll,ll>
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define vl vector<ll>
#define mod 1000000007


int main()
{
    ll n;cin>>n;
    ll ans=0;
    for(ll i=0;i<=32;i++)
    {
        ll x=pow(2,i);
        if(x<=n)
        ans=x;
    }
    cout<<ans<<"\n";
    
}

Measured memory_bytes: 4080
#include <stdio.h>
static int ints[256];
int main(void) {
    int c;
    while ((c = getchar()) != EOF) {
        if (c >= 'A' && c <= 'Z') c ^= 0x20;
        ++ints[c];
    }
    for (c = 'a'; c <= 'z'; ++c) printf("%c : %d\n", c, ints[c]);
    return 0;
}

Measured memory_bytes: 524
import java.io.*;
import java.util.*;

public class Main {


	public static void main(String[] args) throws Exception{
		BufferedReader  jk =  new BufferedReader(new InputStreamReader( System.in))  ; 
		PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out)) ; 
		//StringTokenizer ana = new StringTokenizer(jk.readLine()) ;

		String ss = jk.readLine() ; 
		String tt = jk.readLine()  ; 
		char[] s= ss.toCharArray() ; 
		char [] t = tt.toCharArray() ; 
		int n = s.length ; int m = t.length ; 
		int dp[][] = new int[n][m] ; 
		int pa[][] = new int[n][m] ; 
		if(s[0]==t[0]) dp[0][0]=1 ; 
		for(int i=1 ; i<n;i++)
		{
			dp[i][0]=dp[i-1][0] ; 
			if(s[i]==t[0]) dp[i][0]=Integer.min(dp[i][0]+1, 1) ;

		}
		for(int j=1 ; j<m ;j++)
		{
			dp[0][j]=dp[0][j-1] ; 
			if(t[j]==s[0]) dp[0][j]=Integer.min(dp[0][j]+1, 1) ;
			pa[0][j]=1 ;
		}
		for(int i=1 ; i<n ;i++)
		{
			for(int j=1 ; j<m ;j++)
			{
				if(s[i]==t[j])
				{
					dp[i][j] = dp[i-1][j-1]+ 1 ; 
				}
				else
				{
					int y = dp[i][j-1] ; int x= dp[i-1][j] ; 
					if(y>x)
					{
						dp[i][j]= y ;pa[i][j]=1 ;
					}
					else dp[i][j]=x ; 
				}


			}
		}
		int i=n-1 ; int j = m-1 ; 
		int ans = dp[i][j] ; 
		char d[]= new char[ans] ; 
		int u = ans -1 ;

		while(i>0 && j>0)
		{
			if(t[j]==s[i]) 
			{
				d[u]=t[j] ;    u-- ; 	
				i-- ; j-- ;
			}
			else
			{
				if(pa[i][j]==1) j-- ; 
				else i-- ; 
			}	
		}
		if(dp[i][j]==1)
		{
             if(i==0) d[0]=s[0] ; 
             else d[0]=t[0] ; 
		}
		for(int te=0 ; te<ans ;te++)
		{
			out.print(d[te]);
		}



		out.flush();
	}
}



Measured memory_bytes: 128856
#include "bits/stdc++.h"

using namespace std;

#define int long long

signed main(void) {

  int r, d, x; cin >> r >> d >> x;

  for (int i = 0; i < 10; ++i) {
        x = r * x - d;
  cout << x << endl;

  }

  return 0;
}


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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  int n; std::cin >> n;
  vi p(n); rep(i, n) std::cin >> p[i];
  int ans = 0;
  rep(i, n-1) {
    if (p[i] == i+1) swap(p[i], p[i+1]), ans++;
  }
  drep(i, n) {
    if (p[i] == i+1) swap(p[i], p[i-1]), ans++;
  }
  std::cout << ans << "\n";
}


Measured memory_bytes: 640