akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string>
#include <sstream>

#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define repr(i, a, b) for(int i = (a); i >= (b); i--)
#define range(x) begin(x), end(x)

#define dump(x) cerr << #x << " : " << x << '\n'

#define pb push_back

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;

const int iinf = 1 << 29;
const ll linf = 1l << 61;

int K;
int d[100000]; //dp[i] : K で割った余りが i になる数の桁の総和の最小値
// (nk + i) * 10 = i * 10 (mod K)
// (nk + i) + 1 = i + 1 (mod K)
// dp[(i * 10) % K] = dp[i];
// dp[(i + 1) % K] = 1 + dp[i];
// nord : i -> (i * 10) % K : 0
//      : i -> (i + 1) % K : 1

int main(int argc, char* argv[])
{
	scanf("%d", &K);
	fill(d, d + K, iinf);
	typedef pair<int, int> P;
	priority_queue<P, vector<P>, greater<P>> pq;
	pq.push(P(1, 1));
	d[1] = 1;
	while(!pq.empty())
	{
		int v = pq.top().second;
		int c = pq.top().first;
		pq.pop();
		if(d[v] < c) continue;
		int ten = (v * 10) % K;
		if(d[ten] > c)
		{
			d[ten] = c;
			pq.push(P(c, ten));
		}
		int inc = (v + 1) % K;
		if(d[inc] > c + 1)
		{
			d[inc] = c + 1;
			pq.push(P(c + 1, inc));
		}
	}
	printf("%d\n", d[0]);

	return 0;
}


Measured memory_bytes: 1276
import java.util.*;
public class Main{
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      String s = sc.next();
      int n = s.length();
      int cnt1 = 0;
      int cnt2 = 0;
      for(int i = 0;i < n;i+=2){
      	if(s.substring(i,i+1).equals("0"))cnt1++;
      }
      for(int i = 1;i < n;i+=2){
      	if(s.substring(i,i+1).equals("1"))cnt1++;
      }
      for(int i = 0;i < n;i+=2){
      	if(s.substring(i,i+1).equals("1"))cnt2++;
      }
      for(int i = 1;i < n;i+=2){
      	if(s.substring(i,i+1).equals("0"))cnt2++;
      }
      System.out.println(Math.min(cnt1,cnt2));
    }
}

Measured memory_bytes: 34904
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
typedef long long ll;
typedef vector<vector<ll>> vvl;
typedef vector<ll> vl;
typedef vector<vector<char>> vvc;
typedef vector<char> vc;
typedef pair<ll,ll> pll;
typedef priority_queue<string> priquest;
typedef priority_queue<string,vector<string>,greater<string>> rpriquest;
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
  return x+y-max(x,y);
}

const ll big=1000000007;
ll exp(ll x,ll y){
    if(y==0)return 1;
    if(x==1||x==0)return x;
    if(y%2==1)return (exp(x,y-1)*x)%big;
    ll t=exp(x,y/2);
    return (t*t)%big;
}
void chmin(ll a,ll b){
    if(a>b)a=b;
    return;
}

//”次”の広義単調増加数列 size()=n,max<=m
void next_vec(vector<int> &ans,int m,int n,bool &aaa){
   for(int i=n-1;i>=0;i--){
     if(ans[i]!=m){
       ans[i]++;
       rep2(j,i,n)ans[j]=ans[i];
       aaa=true;
       return;
     }
   }
  aaa=false;
  return;
}


int main(){
  int n,m,q;
  cin >> n >> m >> q;
  vector<int> a(q),b(q),c(q),d(q);
  ll MAX=0;
  rep(i,q){cin >> a[i] >> b[i] >> c[i] >> d[i];MAX+=d[i];}
  vector<int> ans(n,1);
  ll M=0;
  bool aaa=true;
  while(aaa){
    ll cnt=0;
    rep(i,q)
    if(ans[b[i]-1]-ans[a[i]-1]==c[i])cnt+=d[i];
    M=max(M,cnt);
    //if(cnt==10)rep(i,n)cout << ans[i] << endl;
    if(M==MAX)break;
    next_vec(ans,m,n,aaa);
  }
  cout << M << endl;
}

Measured memory_bytes: 3628
n = int(input())
d = {}
for i in range(n):
    s = input()
    if s not in d:
        d[s] = 1
    else:
        d[s] += 1
m = max(d.values())

ans = [_ for _ in d if d[_] == m]
ans.sort()
[print(_) for _ in ans]


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>


template <class T> void chmin(T&a, const T&b) { a = min(a,b); }
template <class T> void chmax(T&a, const T&b) { a = max(a,b); }

const double EPS =1e-9;
const long INF =2147483647;//32bit 2*1e+9
const long MOD =1e+9+7;
#define PI 3.14159265258979

int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

int main(void){
	char S[5]={'a','e','i','o','u'},c;
	cin>>c;

	REP(i,5){
		if(S[i]==c){
			puts("vowel");
			return 0;
		}
	}
	puts("consonant");
 return 0; 
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b) - 1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))
 
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
 
typedef long long Int;
typedef vector<int> VI;
typedef pair<int, int> PII;
 
const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000;
const Int LINF = INF * (Int) INF;
const int MAX = 107;
const int MOD = 998244353;

int dp[MAX][MAX];
int n, m;
string s[MAX];

int main(int argc, char* argv[])
{
	ios::sync_with_stdio(false); cin.tie(0);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    // mt19937 rng(47);

    
    cin >> n >> m;
    FOR(i,0,n) {
        cin >> s[i];
    }

    FOR(i,0,n)
        FOR(j,0,m) {
            dp[i][j] = INF;
        }
    
    dp[0][0] = (s[0][0] == '#');
    
    FOR(i,0,n)
        FOR(j,0,m) {
            if (i + 1 < n) {
                dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + (s[i + 1][j] == '#' && s[i][j] == '.'));
            }
            if (j + 1 < m) {
                dp[i][j + 1] = min(dp[i][j + 1], dp[i][j] + (s[i][j + 1] == '#' && s[i][j] == '.'));
            }
        }

    cout << dp[n - 1][m - 1] << endl;
    
    cerr << 1.0 * clock() / CLOCKS_PER_SEC << endl;
	return 0;
}



Measured memory_bytes: 384
while True:
  N,M,P=map(int,input().split())
  if N==0 and M==0 and P==0:
    break
  card=[]
  for i in range(N):
    card.append(int(input()))
  if card[M-1]==0:
    print(0)
  else:
    sc=sum(card)
    kati=sc*100-(sc*100*(P/100))
    haitou=kati//(card[M-1])
    print(int(haitou))



Measured memory_bytes: 5624
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <string>
#include <cstring>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <ctime>
#include <vector>
#include <fstream>
#include <list>
#include <iomanip>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define ms(s) memset(s, 0, sizeof(s))
const ll INF = 1e9;
inline ll read(){
    ll X = 0,w = 0 ;
    char ch = 0;
    while(!isdigit(ch)) {w |= ch == '-';ch = getchar();}
    while(isdigit(ch)) X = (X<<3) + (X<<1) + (ch ^ 48),ch = getchar();
    return w ? -X : X;
}

ll dat[10005];
ll dp[3005][3005];
int main()
{
    ll n;
    cin>>n;
    ll sum=0;
    for(ll i=0;i<n;++i)
    {
        cin>>dat[i];
        sum+=dat[i];
    }
    ll len=0;
    if(n%2==1) 
    {
        for(ll i=0;i<n;++i)
        {
            dp[i][i]=dat[i];
        }
        len=2;
    }
    else
    {
        for(ll i=0;i<n-1;++i)
        {
            dp[i][i+1]=max(dat[i],dat[i+1])-min(dat[i],dat[i+1]);
        }
        len=3;
    }
    while(len<n)
    {
        for(ll i=0;i+len<n;++i)
        {
            dp[i][i+len]=max(min(dat[i]-dat[i+1]+dp[i+2][i+len],dat[i]-dat[i+len]+dp[i+1][i+len-1]),min(dat[i+len]-dat[i+len-1]+dp[i][i+len-2],dat[i+len]-dat[i]+dp[i+1][i+len-1]));
        }   
        len+=2;
    }
    cout<<(sum+dp[0][n-1])/2-(sum-dp[0][n-1])/2<<endl;
    return 0;
}

Measured memory_bytes: 70016
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a, b = LI()
    if a < b:
        a, b = b, a
    ans = a
    a -= 1
    ans += max(a, b)
    print(ans)
    return

#B
def B():
    n = II()
    h = LI()
    dp = [0 for i in range(n)]
    ans = 0
    for i in range(n):
        dp[i] = max(dp[i - 1], h[i])
        if dp[i - 1] <= h[i]:
            ans += 1
    print(ans)
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    B()


Measured memory_bytes: 39280
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>

//this code is fake. I should have devided the arrays like two buffering. 

using namespace std;

int func(int x, int y, int h, int w, string *s){
    if(s[x][y]=='#')
        return 0;
    
    bool diff=true;
    int cnt=-1;
    s[x][y]='0';
    while(diff){
        diff = false;
        cnt ++;
        for(int i=0; i<h;i++){
            for(int j=0; j<w; j++){
                if(s[i][j]==char('0'+cnt)){
                    if(i-1>=0)
                    if(s[i-1][j]=='.'){
                        s[i-1][j]=char('0'+cnt+1);
                        diff = true;
                    }
                    if(i+1<=h-1)
                    if(s[i+1][j]=='.'){
                        s[i+1][j]=char('0'+cnt+1);
                        diff = true;
                    }
                    if(j-1>=0)
                    if(s[i][j-1]=='.'){
                        s[i][j-1]=char('0'+cnt+1);
                        diff = true;
                    }
                    if(j+1<=w-1)
                    if(s[i][j+1]=='.'){
                        s[i][j+1]=char('0'+cnt+1);
                        diff = true;
                    }
                }
            }
        }  
    }

    return cnt;
}


int main()
{
    int h,w;
    char c;
    string str;
    cin >> h >> w;

    string s[h];

    for(int i=0; i<h;i++){
        cin >> str;
        s[i]=str;
    }

    string aaa[h];

    int ans=0;

    for(int i=0; i<h;i++){
        for(int j=0; j<w; j++){
            //copy s to aaa
            for(int l=0; l<h; l++){
                aaa[l]=s[l];
            }        
            
            //start is (i,j). if it is '#', break
            int longest = func(i,j,h,w,aaa);
            //cout << longest << endl;
            ans = max(ans, longest);
        }
    }


    cout << ans <<  endl;
}

// GCC reference:
//   https://gcc.gnu.org/

// C++ language references:
//   https://cppreference.com/
//   https://isocpp.org/
//   http://www.open-std.org/jtc1/sc22/wg21/

// Boost libraries references:
//   https://www.boost.org/doc/


Measured memory_bytes: 256
n = int(input())
A = [int(input()) for i in range(n)]
a = 0
cnt = 1
while 1:
    if A[a] == -1:
        print(-1)
        break
    if A[a]-1 == 1:
        print(cnt)
        break
    b,A[a] = A[a]-1,-1
    a = b
    cnt += 1


Measured memory_bytes: 7084
#include <stdio.h>

int main(void)
{
  long N;
  scanf("%ld", &N);
  long long int ans = 0;
  long long int i;
  for(i = 1; i <= N; i++){
    if(i % 3 != 0 && i % 5 != 0){
      ans += i;
    }
  }
  printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 1700
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

int main(){
	vll a(5), b(5);
    ll rec = 100, sum = 0;
    REP(i, 5){
        cin >> a[i];
        
        b[i] = a[i] % 10;
        if(b[i] == 0){
            b[i] = 10;
            sum += a[i];
        }
        else{
            sum += (a[i] + 10 - b[i]);
        }
    }
    VSORT(b);
    if(b[0] == 10){
        cout << sum << endl;
        return 0;
    }
    cout << sum - (10 - b[0]) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <list>
#include<map>
#include<set>
using namespace std;

int main() {
    int n, k,p; 
    cin >> n >> k;
    vector<double> v;
    for (int i = 0; i < n;i++) {
        cin >> p;
        double q = 1. * (p + 1) / 2;
        v.push_back(q);
    }
    double ans = 0;
    for (int j = 0; j < k; j++) {
        ans += v[j];
    }
    double m = ans;
    for (int i = 1; i <=n-k;i++) {
        ans += v[i + k - 1] - v[i - 1];
        m = max(m, ans);
    }
    printf("%.6f\n", m);
}


Measured memory_bytes: 2420
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <climits>

int main(){
  std::string S,T;
  std::cin >> S >> T;
  long result=T.length();
  for(long i=0; i<=S.length()-T.length();i++){
    long temp=0;
    for(long j=0; j<T.length();j++){
      if(T[j]!=S[i+j]){
        temp++;
      }
    }
    if(result>temp){
      result=temp;
    }
  }
  std::cout << result << std::endl;
  return 0;
}

Measured memory_bytes: 3200
#include<iostream>
using namespace std;
#define MAX 600000


int A[MAX], H;

void maxHeapify(int A[], int i){
	int largest;
	int l = 2*i;
	int r = 2*i+1;
	if(l <= H && A[l] > A[i]){
		largest = l;
	} else {
		largest = i;
	}
	if(r <= H && A[r] > A[largest]){
		largest = r;
	}
	if(largest != i){
		swap(A[i],A[largest]);
		maxHeapify(A,largest);
	}
}

void bildMaxHeap(int A[]){
	for(int i = H/2; i >= 1; i--){
		maxHeapify(A, i);
	}
}

int main(){
	
	cin>>H;
	
	for(int i = 1; i <= H; i++){
		cin>>A[i];
	}
	
	bildMaxHeap(A);
	
	for(int i = 1; i <= H; i++){
		cout<<" "<<A[i];
	}
	
	cout<<endl;
	
	return 0;
}


Measured memory_bytes: 5048
import queue
N, M = map(int, input().split())
G = [[] for _ in range(N)]
dist = [-1] * N
pre = [-1] * N

for i in range(M):
    a, b = map(lambda n: int(n) - 1, input().split())
    G[a].append(b)
    G[b].append(a)

q = queue.Queue()
dist[0] = 0
q.put(0)

while not q.empty(): 
    v = q.get()
    for u in G[v]:
        if dist[u] != -1:
            continue
        dist[u] = dist[v] + 1
        pre[u] = v
        q.put(u)
    
print('Yes')

for i in range(1, N):
    print(pre[i] + 1)

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;
typedef long double ld;

const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    int n;
    string s;
    cin >> n >> s;
    int r = 0, b = 0;
    rep (i, s.size()) {
        if (s[i] == 'R') r++;
        else if (s[i] == 'B') b++;
    }
    if (r > b) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}



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

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

ll a[1010];
ll b[1010];
ll c[1010];
vector<ll>vec;
int main() {
    ll x,y,z,k;
    
    cin>>x>>y>>z>>k;
    for(int i=0;i<x;i++) {
       cin>>a[i];
    }
    for(int i=0;i<y;i++) {
       cin>>b[i];
    }
    for(int i=0;i<z;i++) {
       cin>>c[i];
    }
    sort(a,a+x,greater<ll>());
    sort(b,b+y,greater<ll>());
    sort(c,c+z,greater<ll> ());
    REP(i,x){
        REP(j,y){
            REP(l,z){
                if((i+1)*(j+1)*(l+1)<=k){
                    vec.push_back(a[i]+b[j]+c[l]);
                }
                else break;
            }
        }
    }
    sort(vec.rbegin(),vec.rend());
    REP(i,k) cout<<vec[i]<<endl;
  
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f first
#define s second
#define Fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fo(a,b,c) for(int i=a;i<b;i+=c)  
typedef pair<ll , pair<ll, ll> > pi;
int pow(int x,int y){
    int res=1;
    while(y){
        if(y&1) res*=x;
        y>>=1;
        x*=x;
    }
    return res;
}   
struct Compare {
    constexpr bool operator()(pi const & a,
                              pi const & b) const noexcept
    { return a.first < b.first || (a.first == b.first && a.second.first > b.second.first); }
 
};
void prefix_function( string s,ll arr[] )
{
     long long border=0; arr[0]=0;
    for(long long i=1;i<s.size();i++)
    {
      while(border>0 && s[i]!=s[border])
        border=arr[border-1];
     
     if(s[i]==s[border])
         border++;
      else
       border=0;
      
      arr[i]=border;
    }
}
ll mod=998244353;
ll add( ll a , ll b)
{
    return (((a%mod)+(b%mod))%mod);
}
ll mul(ll a,ll b)
{
  return (((a%mod)*(b%mod))%mod);
}
//send mod-2 for a^-1 if mod is a prime number
ll binpow(ll a, ll b) {
    ll res = 1;
    while (b) {
        if (b & 1) res = mul(res, a);
        a = mul(a, a);
        b >>= 1;
    }
    return res;
}
ll dsu_arr[100000];
ll dsu_sz[100000];
void dsu(ll n)
{
    for(ll i=0;i<=n;i++)
    {
        dsu_arr[i]=i;
        dsu_sz[i]=1;
    }
}
ll find(ll x)
{
     ll root=x;
    while (root!=dsu_arr[root])
    {
        root=dsu_arr[root];
    }
    while(x!=dsu_arr[x])
    {
        dsu_arr[x]=root;
        x=dsu_arr[x];
    }
    return root;
}
ll merge(ll x,ll y)
{
    ll root1=find(x);
    ll root2=find(y);
    
    if(root1==root2)
    return 0ll;
 
    if(dsu_sz[x]>dsu_sz[y]){
    dsu_arr[root2]=root1;
    dsu_sz[x]+=dsu_sz[y];
    }
    else
    {
         dsu_sz[y]+=dsu_sz[x];
        dsu_arr[root1]=root2;
    }
    return 1ll;
}


int main()
{
ll x,y,z;
cin>>x>>y>>z;
x=abs(x);
ll rem=x%z;
ll div=x/z;

if(div>=y)
{
    cout<<abs(x-(y*z))<<endl;
    return 0;
}
y-=div;
ll extra=abs(rem-z);
if(y%2==0)
{
    cout<<rem<<endl;
}
else
cout<<extra<<endl;



}



   
      
    
        



Measured memory_bytes: 3616
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



int main(){

	int tmp;
	vector<int> V;

	for(int i = 0; i < 3; i++){
		scanf("%d",&tmp);
		V.push_back(tmp);
	}

	sort(V.rbegin(),V.rend());

	printf("%d\n",10*V[0]+V[1]+V[2]);


	return 0;
}


Measured memory_bytes: 3728
use text_io::*;
use std::collections::*;
use std::process::exit;

fn main() {
    let mut n:usize = read!();
    let mut v:Vec<usize> = Vec::new();
    for i in 0..n {
        let a:usize = read!();
        v.push(a);
    }
    let mut ans = 0;
    for i in 0..n {
        for j in i+1..n {
            ans+=v[i]*v[j];
        }
    }
    println!("{}",ans);
}

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

int f(int x) {
  int a, b, c, d, e;
  a = x % 10;
  b = (x / 10) % 10;
  c = (x / 100) % 10;
  d = (x / 1000) % 10;
  e = (x / 10000) % 10;
  
  return a + b + c + d + e;
}

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  
  int i, ans = 0;
  for(i = 1; i <= n; i++){
    if(a <= f(i) && f(i) <= b) ans += i;
  }
  
  cout << ans << endl;
}

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

#define trace(...) __f( #__VA_ARGS__ , __VA_ARGS__ )
template <typename Arg1>
void __f( const char* name , Arg1&& arg1 ) {
        cerr << name << " : " << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void __f( const char* na , Arg1&& arg1 , Args&&... args ) {
        const char* c = strchr( na + 1 , ',' );
        cerr.write( na , c - na ) << " : " << arg1 << " , ";
        __f( c + 1 , args... );
}
#define endl "\n"
#define all(V) V.begin(),V.end()
#define Unique(V) sort(all(V)),V.erase(unique(all(V)),V.end())
#define IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long int LL;
typedef pair <int,int> pii;
const int MOD = 1e9 + 7;
const int inf = 1e9;
const double EPS = 1e-9;
const double PI = acos(-1.0);
const long long INF = 1e18;
const int N = 1e5 + 5;

int a[ N ];
int ans;

int main( ) {
        IO;
        #ifdef LOCAL
            //freopen( "input.txt" , "r" , stdin );
        #endif // LOCAL
        int n;
        cin >> n;
        for( int i = 1; i <= n; i++ ) cin >> a[i];
        for( int i = 2; i < n; i++ ) {
                vector <int> V;
                V.push_back( a[i-1] );
                V.push_back( a[i] );
                V.push_back( a[i+1] );
                sort( all( V ) );
                if( a[i] == V[1] ) ans++;
        }
        cout << ans << endl;
        return 0;
}










Measured memory_bytes: 256
# https://atcoder.jp/contests/abc168/tasks/abc168_c


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

hm = H * 60 + M
gm = hm * Math::PI * 2 / 720 - M * Math::PI * 2 / 60
ans = Math.sqrt(A ** 2 + B ** 2 - 2 * A * B * Math.cos(gm))

puts ans


Measured memory_bytes: 14708
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vvll=vector<vll>;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vb=vector<bool>;
using pii=pair<int,int>;
using vpii=vector<pair<int,int>>;

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;}

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)
//試験導入
#define irep(i, end_i, begin_i) for (ll i = (ll)begin_i-1; i >= (ll)end_i; i--)

long long INF = 1LL<<60;
int main( ){
    int n;
    int y;
    cin>>n>>y;
    ll res;
    rep(i,0,n+1){
        rep(j,0,n-i+1){
            ll k=n-(i+j);
            if(k>=0){
                if(10000*i+5000*j+1000*k==y){
                    cout<<i<<" "<<j<<" "<<k<<endl;
                    return 0;
                }
            }
        }
    }
    cout<<"-1 -1 -1"<<endl;
    return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>				//Written by ThiDaiLoc
using namespace std;				//Team Three Wolves
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> trp;
typedef vector<ll> vi;
typedef vector<pll> vp;

#define fu(i,a,b)   for(ll i=a;i<=b;i++)
#define f1(i,n)     for(ll i=1;i<=n;i++)
#define fs(i,s)     for(ll i=0;i+1<=s.length();i++)
#define fd(i,b,a)   for(ll i=b;i>=a;i--)
#define fuv(i,a)    for(ll i=0;i<a.size();i++)
#define fdv(i,a)    for(ll i=(ll)a.size()-1;i>=0;i--)
#define ms(a,x)     memset(a, x, sizeof a)
#define prec(n)     fixed<<setprecision(n)
#define uni(a)      (a).erase(unique(all(a)), (a).end())
#define pb(i)       push_back(i)
#define pob         pop_back()
#define sc(a)       cin>>a
#define sc2(a,b)    cin>>a>>b
#define pr(a)       cout<<a<<endl
#define pr2(a,b)    cout<<a<<" "<<b<<endl
#define rpr(a)      return cout<<a<<endl,0
#define prY         cout<<"YES"<<endl
#define prN         cout<<"NO"<<endl
#define bit(n,i)    (((n)>>(i))&1)
#define lowb(a,n,x) lower_bound(a,a+n,x) -a
#define lowb2(a,x)  lower_bound(all(a),x) -a.begin()
#define all(x)      (x).begin(), (x).end()
#define sz(a)       (ll)a.size()
#define le(s)       (ll)s.length()		
#define re          return 	
#define	mp(a,b)     make_pair(a,b)
#define	mp3(a,b,c)  make_pair(a,make_pair(b,c))
#define se          second
#define fi          first 
#define sse         second.second
#define sfi         second.first
#define soA         sort(A+1,A+1+n)
#define so(A,n)     sort(A+1,A+1+n)
#define sov(v)      sort(all(v))
#define sovr(v)     sort(all(v),greater<ll>())
#define debug(x)    cerr << #x << " = " << x << endl
#define INPUT       freopen("locin.txt", "r", stdin)
#define OUTPUT      freopen("locout.txt", "w", stdout)
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline ll mnz(ll& a,ll b){return a=(a>b?b:a);}
inline ll mxz(ll& a,ll b){return a=(a<b?b:a);}
inline string toString(ll n) {stringstream ss; ss << n;return ss.str();}
double const eps = 1e-6;
ll const Base=1e9+7,oo=1e17,MAXN=1e6;


ll A[MAXN+5];

ll Solves(){
	
	ll n,m,k,cnt=0,ans=0,x,y,q,c,sum=0,v,t;
	// PROCESS IN HERE
	string s;
	sc2(n,s);
	fs(i,s){
		s[i]=((s[i]+n-'A')%('Z'-'A'+1)+'A');	
	}
	pr(s);
	
	
	
	re 0;
	// Hack it if you can :)
}

int main(){
	//INPUT;
	if(fopen("locin.txt", "r"))INPUT;
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll test=1;
//	sc(test);
	fu(T,1,test){
//		cout<<"Case #"<<T<<": ";
		Solves();
	} 		
}

Measured memory_bytes: 256
def main():
    n = int(input())
    arr = list(map(int,input().split()))
    if 0 in arr:
        return 0
    prod = 1
    max1 = 10**18
    for i in arr:
        prod*=i
        if(prod==0):
            return 0
        if(prod>max1):
            return -1
    return prod

print(main())

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

int main(){
  int N;
  cin >> N;
  string S;
  bool flag = false;
  for(int i = 0; i < N; i++){
    cin >> S;
    if(S == "Y"){
      flag = true;
    }
  }
  if(flag){
    cout << "Four" << endl;
  }
  else{
    cout << "Three" << endl;
  }
}  


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B;
  cin >> A >> B;
  if (A >= 13){
    cout << B << endl;
  }
  else if ( 6 <= A && A <= 12 ){
    cout << B /2 << endl; 
  }
  else if ( 0 <= A && A <= 5){
    cout << 0 << endl;
  }
}

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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define size_t unsigned long long
#define ll long long
#define rep(i,a) for(int i=0;i<(a);i++)
#define repr(i,a) for(int i=(int)(a)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=a;i--)
#define ALL(a) a.begin(), a.end()
using namespace std;
int si() { int x; scanf("%d", &x); return x; }
long long sl() { long long x; scanf("%lld", &x); return x; }
string ss() { string x; cin >> x; return x; }
void pi(int x) { printf("%d ", x); }
void pl(long long x) { printf("%lld ", x); }
void pd(double x) { printf("%.15f ", x); }
void ps(const string &s) { printf("%s ", s.c_str()); }
void br() { putchar('\n'); }

const int MOD = 1e9 + 7;

struct mint {
    int n;
    mint(int n_ = 0) : n(n_) {}
};

mint operator+(mint a, mint b) { a.n += b.n; if (a.n >= MOD) a.n -= MOD; return a; }
mint operator-(mint a, mint b) { a.n -= b.n; if (a.n < 0) a.n += MOD; return a; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }

string s,t;


int main () {
  s = "No";
  int i=0;
  cin >> s >> t;
  if(s[0] == t[0]) i++;
  if(s[1] == t[1]) i++;
  if(s[2] == t[2]) i++;
  cout << i << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>

using namespace std;

int main()
{
  int n;
  int a[200010];
  map<int, int> buck;
  
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    buck[a[i]]++;
  }
  
  for (int i = 0; i < n; i++) {
    if (buck[a[i]] > 1) {
      cout << "NO" << endl;
      return (0);
    }
  }
  
  cout << "YES" << endl;
}

Measured memory_bytes: 10368
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

using namespace std;

int main()
{
    int a[3];
    
    for (int i = 0;i < 3;i++){
        cin >> a[i];
    }
    
    cout << a[2] << " " << a[0] << " " << a[1] << endl;
}


Measured memory_bytes: 256
N_all, M_part = map(int, input().split())
Hyou = list(map(int, input().split()))

Hyou.sort(reverse=True)
summ = sum(Hyou)

thres = summ / (4 * M_part)

if (Hyou[M_part - 1] >= thres):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
//debug
#ifdef grief
#define debug(...) do{\
	fprintf(stderr , "%s - %d : (%s) = " , __PRETTY_FUNCTION__ , __LINE__ , #__VA_ARGS__ );\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){
	cerr<<x<<endl;
}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){
	cerr<<x<<" , ";
	_DO(tail...);
}
#else
#define debug(...)
#endif
//type
typedef long long ll;
typedef pair<int,int> pii;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef priority_queue<pll,vector<pll>,greater<pll> > heap;
//macro
#define SZ(x) ((ll)(x).size())
#define ALL(x) (x).begin(),(x).end()
#define F first
#define S second
#define mkp make_pair
#define pb push_back
const ll INF=4e18;
const ll MAX=1e6+5;
const ll MOD=1e9+7;
//}}}
int a,b,c;
bool che(){
	return a+c==b+b;
}
int main(){
	//ios_base::sync_with_stdio(0); cin.tie(0);
	cin>>a>>b>>c;
	if(che())
		cout<<"YES\n";
	else
		cout<<"NO\n";
	return 0;
}


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

int main() {
	int N;
	cin >> N;
	int num = 3;
	string x;
	for (int i=0; i<N; i++){
		cin >> x;
		if (x=="Y") {
			num++;
			break;
		}
	}
	string ans = num==3 ? "Three" : "Four";
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
        #define endl '\n'
        #define modulo 1000000007
        #define int long long
        #pragma GCC optimize("-Ofast")
        #define float double
        #define PI 3.141592653589793238462643383279502884
        #define sinDegrees(x) sin((x) * PI / 180.0)
        #define tanDegrees(x) tan((x) * PI / 180.0)
        #define atanDegrees(x) atan(x)* 180.0 / PI
        #define f first
       // #define s second
        using namespace std;
        int power(int x,int y,int m)
        {
        int temp;
        if(y == 0)
        return 1;
        temp = (power(x, y/2,m))%m;
        if (y%2 == 0)
        return ((temp%m)*temp);
        else
        return ((x*temp%m)*temp%m)%m;
        }
        int inv(int x)
        {
        return (power(x,modulo-2,modulo))%modulo;
        }
        bool comp(int a,int b)
        {
            return a>b;
        }
        ///Solution created by:Ahmadsm2005
        int32_t main()
        {
            //freopen("output.txt","w", stdout);
            //freopen("input0.txt","r", stdin);
            iostream::sync_with_stdio(0);
            cin.tie(0);
            cout.tie(0);
            int X,Y,a,b,flag=0;
            cin>>X>>Y>>a>>b;
            if(a*2==X||b*2==Y){
            flag=0;
            if(a*2==X&&b*2==Y)
            flag=1;
            }
            cout<<fixed<<setprecision(10)<<.5*X*Y<<' '<<flag;
            return 0;
        }


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}

	static class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			int N = in.nextInt();
			int ans = 0;
			for(int i = 0; true; i++) {
				if(Math.pow(i, 2) > N) {
					ans = (int)Math.pow(i - 1, 2);
					break;
				}else if(Math.pow(i, 2) == N) {
					ans = (int)Math.pow(i - 1, 2);
				}
			}
			out.println(ans);
		}
	}
	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

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


Measured memory_bytes: 23380
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

#define FOR(i,s,e) for (int i = int(s); i < int(e); i++)
#define FORIT(i,c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define ISEQ(c) (c).begin(), (c).end()
typedef long long ll;

int SURP = 1000000007;

int main(){
	int A,B;
	cin >> A >> B;

	int ret = A * B;

	if(ret < A + B) ret = A+B;
	if(ret < A - B) ret = A-B;

	cout << ret << endl;
	return 0;
}


Measured memory_bytes: 256
#include<string>
#include<iostream>
#include<cstdio>
#include<cstdlib>
using namespace std;
int main(){
  int n,a;
  char str[10];

  scanf("%d", &n);
  for(int i=0; i<n; i++){
    cin >> a;
    cout << "Case " << i+1 << ":" << endl;
    for(int j=0; j<10; j++){
    sprintf(str,"%08d",a*a);
    string str2 = string(str);
    string str3 = str2.substr(2,4);
    a = atoi(str3.c_str());
    cout << a << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1292
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=(a);i<(b);++i)

template<class T> inline void chmin(T& a, T b) {if (a > b) a = b;}
template<class T> inline void chmax(T& a, T b) {if (a < b) a = b;}

//vector出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){
  o<<"{";
  for(int i=0;i<(int)v.size();i++) o << (i>0?", ":"") << v[i];
  o<<"}"<<endl;
  return o;
}

//逆元　a/b の modをとるとき -> a*modinv(b)%mod
long long modinv(long long a, long long m = 1e9+7) {
  long long b = m, u = 1, v = 0;
  while (b) {
    long long t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m; 
  if (u < 0) u += m;
  return u;
}
ll const mod = 1e9+7;

// combination
const int MAX = 510000;
const ll MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
  ll N,M;
  cin >> N >> M;
  COMinit();
  ll ans = 0, s=1, s2=1;
  
  vector<ll> per(M+1,1);
  rep2(i,1,M+1) per[i] = per[i-1]*i%mod;
  // cout << per << endl;
  s = per[M]*modinv(per[M-N])%mod;
  
  rep2(i,1,N+1) {
    s2 = COM(N,i) * (per[M-i]*modinv(per[M-N])%mod) %mod;
    if (i%2==0) s+=s2;
    else s-=s2;
    s%=mod;
  }
  ans = per[M]*modinv(per[M-N])%mod;
  ans = ans*s%mod + mod;
  cout << ans %mod << endl;
}

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

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

  long long res = 0;
  int right = 0;
  int sum = 0;
  for (int left = 0; left < n; left ++) {
    while (right < n && (sum ^ a[right]) == (sum + a[right])) {
      sum += a[right];
      right ++;
    }
    res += right - left;
    if (left == right) right ++;
    else sum -= a[left];
  }

  cout << res << endl;
}


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

int main(){
  double N;
  cin >> N;
  
  int i;
  double s;
  s=0.0;
  for(i=1;i<=N;i=i+2){
    s=s+1.0;
  }
  
  cout << s/N << endl;
}

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

int n,m,u,v,dp[100007],ans;

vector<int>ho[100007];
int dfs(int p){
	int sum=0;
	if(dp[p]!=0){
		return dp[p];
	}
	for(int i=0;i<ho[p].size();i++){
		sum=max(sum,dfs(ho[p][i]));
	}
	return dp[p]=sum+1;
}

int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++){
		scanf("%d%d",&u,&v);
		ho[u].push_back(v);
	}
	for(int i=1;i<=n;i++){
		ans=max(ans,dfs(i));
	}
	printf("%d\n",ans-1);
}

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

#define M 1000000007
#define pb emplace_back
#define f first
#define s second
#define rep(i, st, ed) for(ll i=st; i<ed; ++i)
#define repn(i, st, ed) for(ll i=st; i<=ed; ++i)
#define repb(i, ed, st) for(ll i=ed; i>=st; --i)
#define all(v) v.begin(),v.end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define PI acosl(-1.0)
#define mp(a, b) make_pair(a, b)
#define eps 1e-9

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ll> vec;
typedef vector<pll> vecp;
typedef map<ll, ll> mpll;


const int N = 1e5 + 10;
const ll INF = 1LL << 60;

template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << to_string(H) << endl;
  debug_out(T...);
}
#define LOCAL 3
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:" << endl, debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif


void solve()
{
	ll k, a, b;
	cin>>k>>a>>b;
	ll ans = 0;
	if(a+2 >= b){
		ans = k+1;
		cout<<ans<<endl;
		return;	
	}
	ll rem = k - a + 1;
	ll x = rem / 2;
	ans += x*b - (x - 1)*a;
	if(rem%2 == 1) ans++;
	cout<<ans<<endl;
}


int main()
{
	ll Tests = 1;
    //cin>>Tests;
    while(Tests--)
    {
    	solve();
    }
    return 0;
}

Measured memory_bytes: 256
import java.text.*;import java.util.*;class Main{public static void main(String[]z){ChoiceFormat f=new ChoiceFormat("0#0|35.5#1|37.5#2|40#3|43#4|50#5|55#6|70#7"),g=new ChoiceFormat("0#0|71#1|77#2|83#3|89#4|105#5|116#6|148#7");for(Scanner s=new Scanner(System.in);s.hasNext();)System.out.println(new String[]{"AAA","AA","A","B","C","D","E","NA"}[Math.max(new Integer(f.format(s.nextDouble())),new Integer(g.format(s.nextDouble())))]);}}

Measured memory_bytes: 12000
#include <stdio.h>

int main(){
    int p[101]={0}, i, a, b, c, count=0;

    scanf("%d %d %d", &a, &b, &c);

    p[a]++;
    p[b]++;
    p[c]++;

    for(i=1; i<=100; i++)
        if(p[i]) count++;

    printf("%d", count);

    return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i = (a);i < (n);i++)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

int main(){
  	int n,a,b,memo = 0,memo_f = 1;
  	string s;
  	cin >> n >> a >> b >> s;
  
  	rep(i,0,n){
    	switch(s[i]){
          case 'a':
            	if(a+b > memo){
                  cout << "Yes" << endl;
                  memo++;
                }
            	else{
                  cout << "No" << endl;
                }
            break;
          case 'b':
            	if(a+b > memo && b >= memo_f){
					cout << "Yes" << endl;
                  	memo++;
                }
            	else{
                  	cout << "No" << endl;
                }
            	memo_f++;
            break;
          case 'c':
            	cout << "No" << endl;
            break;
        }
    }
  
  	return 0;
}

Measured memory_bytes: 896
class Factorial():
    def __init__(self, n, mod):
        self.mod = mod
        self.fct = [0 for _ in range(n + 1)]
        self.inv = [0 for _ in range(n + 1)]
        self.fct[0] = 1
        self.inv[0] = 1
        for i in range(n):
            self.fct[i + 1] = self.fct[i] * (i + 1) % mod
        self.inv[n] = pow(self.fct[n], mod - 2, mod)
        for i in range(n)[::-1]:
            self.inv[i] = self.inv[i + 1] * (i + 1) % mod

    def comb(self, m, k):
        if m < k: return 0
        return self.fct[m] * self.inv[k] * self.inv[m - k] % self.mod

MOD = 998244353
N, A, B, K =map(int,input().split())

f = Factorial(N, MOD)

res = 0

for i in range(N + 1):
    if (K - A * i) % B == 0:
        j = (K - A * i) // B
        if 0 <= j <= N:
            res += f.comb(N, i) * f.comb(N, j)
            res %= MOD

print(res)

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

int main(){
  int h,w;
  cin >> h >> w;
  char a[h][w];
  for (int i = 0; i < h; i++)
  {
    for (int j = 0; j < w; j++)
    {
      cin >> a[i][j];
    }
  }

  cout << string(w+2,'#') << endl;
  for (int i = 0; i < h; i++)
  {
    cout << '#';
    for (int j = 0; j < w; j++)
    {
      cout << a[i][j]; 
    }
    cout << '#' << endl;
  }
  cout << string(w+2,'#') << endl;
}

Measured memory_bytes: 256
a, b, m = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ans = min(A) + min(B)
for _ in range(m):
    x, y, c = map(int, input().split())
    ans = min(ans, A[x-1] + B[y-1] - c)

print(ans)

Measured memory_bytes: 18608
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef pair<int,int> P;
const int INF=(int)1e9;
const int MOD=(int)1e9+7;
struct Accelerate_Cin{
    Accelerate_Cin(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
};



int main(){
  int N;
  int a[101];
  cin>>N;
  for(int t=0;t<N;t++){
    cin>>a[t];
  }

  int max=0;
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      int temp=abs(a[i]-a[j]);
      if(temp>max)max=temp;
    }
  }

  cout<<max<<endl;
  return 0;
}


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

const long long MOD = 1000000007LL;
long long GCD(long long a, long long b){return b == 0 ? a : GCD(b, a % b);}
long long fast_exp(long long base, long long exp, long long mod = MOD) {
    long long tot = 1;
    for(;exp > 0;exp >>= 1) {
       if((exp & 1) == 1) tot = tot * base % mod;
       base = base * base % mod;
    }
    return tot;
}
long long slow_mult(long long base, long long exp, long long mod = MOD) {
    long long tot = 0;
    for(;exp > 0;exp >>= 1){
       if((exp & 1) == 1) tot = (tot + base) % mod;
       base = base * 2 % mod;
    }
    return tot;
}

int fa[27], fb[27];

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    string a, b; cin >> a >> b;
    int n = a.size();

    for(auto i : a)
        fa[i - 'a']++;
    for(auto i : b)
        fb[i - 'a']++;

    sort(fa, fa + 26);
    sort(fb, fb + 26);

    for(int i = 0; i < 26; ++i){
        if(fa[i] != fb[i]){
            cout << "No";
            return 0;
        }
    }

    cout << "Yes";

    return 0;

}


Measured memory_bytes: 916