akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<bool>> vvbool;

const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const double PI = 3.14159265358979323846264338327950288;
//========================================================================


int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	//==================================


	ll X, Y;
	cin >> X >> Y;

	if (X== 0) {
		cout << abs(Y) + ll(Y < 0);
		return 0;
	}
	else if (Y == 0) {
		cout << abs(X) + ll(X > 0);
		return 0;
	}

	if (X*Y < 0) {
		cout << abs(abs(X) - abs(Y)) + 1;
	}
	else if (X < Y) {
		cout << Y - X;
	}
	else{

		cout << X - Y + 2;

	}


}


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

using namespace std;

int main(int argc, const char *argv[]) {
  string S;
  cin >> S;

  if(S.compare("SUN")==0){
    cout << "7" << endl;
  }else if(S.compare("MON")==0){
    cout << "6" << endl;
  }else if(S.compare("TUE")==0){
    cout << "5" << endl;
  }else if(S.compare("WED")==0){
    cout << "4" << endl;
  }else if(S.compare("THU")==0){
    cout << "3" << endl;
  }else if(S.compare("FRI")==0){
    cout << "2" << endl;
  }else if(S.compare("SAT")==0){
    cout << "1" << endl;
  }

  return 0;
}


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

int main(){
    int n,a[101];
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int at=0;
    for(int i=0;i<n;i++){
        int minj=i;
        for(int j=i;j<n;j++){
            if(a[j]<a[minj]){
                minj=j;
            }
        }
            if(minj!=i){
                swap(a[i],a[minj]);
                at++;
            }
            
    }
    for(int i=0;i<n;i++){
        cout<<(i==0?"":" ")<<a[i];
    }
    cout<<endl<<at<<endl;
    
}


Measured memory_bytes: 3084
import java.math.BigDecimal;
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		double r = scan.nextDouble();
		scan.close();
		double ans1 = r * r * Math.PI;
		double ans2 = 2 * r * Math.PI;
		System.out.println(BigDecimal.valueOf(ans1).toPlainString()
				+ " " + BigDecimal.valueOf(ans2).toPlainString());
	}
}


Measured memory_bytes: 28332
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e15;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

template<class T>
inline bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<class T>
inline bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    deque<char> deq;
    string S; cin >> S;
    rep(i,SZ(S)){
        deq.emplace_back(S[i]);
    }
    int Q; cin >> Q;
    int frag=1;
    rep(q,Q){
        int a; cin >> a;
        if(a==1){
            frag=1-frag;
        }
        else {
            int b; char c; cin >> b >> c;
            b--;
            if(frag^b){
                deq.emplace_front(c);
            }
            else {
                deq.emplace_back(c);
            }
        }
    }
    if(!frag) reverse(all(deq));
    while(!deq.empty()){
        cout << deq.front();
        deq.pop_front();
    }
    cout << endl;
    
}


Measured memory_bytes: 976
#include <iostream>
using namespace std;
typedef long long ll;
ll k, a[55];
int main(void){
    // Your code here!
    cin >> k;
    cout << 50 << endl;
    for (ll i = 1; i <= 50; i++){
        a[i] = 49 + k / 50 + 1;
    }
    for (ll i = 1; i <= 50 - k % 50; i++){
        for (ll j = 1; j <= 50; j++){
            if (i == j){
                a[j] -= 50;
            } else {
                a[j]++;
            }
        }
    }
    for (ll i = 1; i <= 50; i++){
        cout << a[i];
        if (i == 50) cout << endl;
        else cout << ' ';
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl
#define YORN(f) cout<<((f)?"YES":"NO")<<endl
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main()
{
    int m, n;
    cin >> m >> n;
    cout << (m - 1) * (n - 1) << endl;
    return 0;
}

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

int main(){
    int N;
    cin >> N;
    int a[N];
    int sum = 0;
    for (int i = 0; i < N; i++)
    {
        scanf("%d", &a[i]);
        sum = sum^a[i];
    }
    for(int i=0;i<N;i++){
        cout << (sum^a[i]) << " ";
    }
    return 0;
}

Measured memory_bytes: 4400
# coding: UTF-8

N = int(input())
A = list(map(int, input().split()))
a = 1
block = []
for i in range(N):
    if A[i] == a:
        block.append(A[i])
        a += 1
    else:
        continue
if len(block) > 0:
    print(N - len(block))
else:
    print(-1)


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

using LL = long long;
using LD = long double;
 
LL mod = 998244353;
const LD pi = 3.141592653589793238;

int main()
{
	LL a, b, h, m;
	cin >> a >> b >> h >> m;

	LD hang = (pi/6)*h + (pi/360)*m;
	LD mang = (pi/30)*m;
	
	LD ang = abs(hang-mang);
	ang = min(ang, 2*pi-ang);


	LD len = sqrtl(a*a + b*b - 2*a*b*cosl(ang));
	cout << fixed << setprecision(15) << len << "\n";
}

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl




typedef long long ll;
const ll mod = 1e9+7;
const int maxn = 1e6 + 5;
const ll inf = 1e18;


int n;
int h[maxn], a[maxn];





ll t[maxn*4], o[maxn*4];

void push(int v) {
    t[2*v]+=o[v];
    t[2*v+1]+=o[v];
    o[2*v]+=o[v];
    o[2*v+1]+=o[v];
    o[v]=0;
}

ll queryMax(int v, int tl, int tr, int l, int r) {
    if (l>tr||r<tl) return -inf;
    if (l<=tl&&tr<=r) {
	return t[v];
    } else {
	push(v);
	int tm=(tl+tr)/2;
	return max(queryMax(2*v,tl,tm,l,r),queryMax(2*v+1,tm+1,tr,l,r));
    }
}

void rangeAdd(int v, int tl, int tr, int l, int r, ll dx) {
    if (l>r) return;
    if (l>tr||r<tl) return;
    if (l<=tl&&tr<=r) {
	t[v]+=dx;
	o[v]+=dx;
    } else {
	push(v);
	int tm=(tl+tr)/2;
	rangeAdd(2*v,tl,tm,l,r,dx);
	rangeAdd(2*v+1,tm+1,tr,l,r,dx);
	t[v]=max(t[2*v],t[2*v+1]);
    }
}


void upd(int l, int r, ll dx) {
    if (l>r) return;
    rangeAdd(1,1,maxn,l+1,r+1,dx);
}

ll qry(int l, int r) {
    assert(l<=r);
    return queryMax(1,1,maxn,l+1,r+1);
}

void edit(int i, ll val) {
    upd(i,i,val-qry(i,i));
}

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

    
    cin>>n;
    vector<int> id;
    for (int i=0; i<n; i++) {
	cin>>h[i];
	id.push_back(h[i]);
    }
    for (int i=0; i<n; i++) {
	cin>>a[i];
    }

    sort(id.begin(), id.end());
    
    for (int i=0; i<n; i++) {
	int idx = lower_bound(id.begin(), id.end(), h[i]) - id.begin();
	edit(idx, qry(0,idx)+a[i]);
    }

    ll res = qry(0,n-1);
    cout<<res<<endl;

    return 0;
}


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

// #define fi first
// #define se second
#define rep(i, n) for (ll i=0;i<(n); i++)
#define ALL(v) (v).begin(), (v).end()
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pi;

//const ll M=1000000007ll;
//const ll MOD=1000000007ll;
const ll MOD=2019ll;
const ll MAX=100000001ll;
//const ll M = 1000000000+7;

//const int mod = 1000000007;
const int mod = 2019;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
   return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

mint f(ll n){
  if(n==0) return 1;
  mint ans = f(n/2);
  ans *= ans;
  if(n%2==1) ans*= 2;
  return ans;
}

mint g(ll n, ll x){
  if(x==0) return 1;
  mint ans = g(n, x/2);
  ans *= ans;
  if(x%2==1) ans*= n;
  return ans;  
}

mint choose(ll n, ll k){
  mint x=1, y=1;
  rep(i,k){
    x *= (n-i);
    y *= (i+1);
  }
  return x / y;
}

struct BIT {
  private:
   vector<ll> bit;
   ll N;
 
  public:
   BIT(ll size) {
     N = size;
     bit.resize(N + 1);
   }
 
   // 一点更新です
   void add(ll a, ll w) {
     for (ll x = a; x <= N; x += x & -x) bit[x] += w;
   }
 
   // 1~Nまでの和を求める。
   int sum(ll a) {
     ll ret = 0;
     for (ll x = a; x > 0; x -= x & -x) ret += bit[x];
     return ret;
   }
 };
 
ll fff(ll n, vector<ll>& v, ll i, ll j, ll rl){
  ll can = 0;
  ll can_i = 0;

  cout << v[0]<<endl;
  
  // right
  if(rl == 0){
    rep(k, n){
      if(v[k]*(j-k)>can){
	can = v[k]*(j-k);
	can_i = k;
      }
      //cout << can<<endl;
    }
    v[can_i] = 0;
    return can;
  }
  // left
  else{
    rep(k, n){
      if(v[k]*(k-i)>can){
	can = v[k]*(k-i);
	can_i = k;
      }
      //cout << can<<endl;

    }
    v[can_i] = 0;
    return can;
  }
  
}

ll ff(ll x){
  return x * (x+1) / 2;
}

int main(){
  ll k,a,b;
  cin>>k>>a>>b;

  ll ans;
  if(a+1>=b) ans=k+1; 
  else {ans = a + (k-a+1)/2 * (b-a);
    if((k-a+1)%2==1) ans++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{

  public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();

      int[] arr = new int[n];
      for(int i = 0; i < n; i++)
        arr[i] =  sc.nextInt();
      Arrays.sort(arr);
      long h = 0;
      long w = 0;
      int i = arr.length - 1;
      for(; i > 0; i--) {
        if(arr[i] == arr[i-1]) {
            h = arr[i];
            i-=2;
            break;
        }
      } 
      for(; i > 0; i--) {
        if(arr[i] == arr[i-1]) {
            w = arr[i];
            break;
        }
      }
      System.out.println(h*w);
  }
}


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

int main()
{
    int n;
    cin >> n;
    vector<int> l(n);
    rep(i,n) cin >> l[i];
    sort(l.begin(),l.end());

    int cnt = 0;
    rep(i,n-2)
        rep2(j,i+1,n-1)
        {
            int min_l = l[j]-l[i]+1;
            int max_l = l[j]+l[i];

            auto itr_min = lower_bound(l.begin()+j+1,l.end(),min_l);
            auto itr_max = lower_bound(l.begin()+j+1,l.end(),max_l);
            if(itr_min==l.end()) continue;
            int d_min = distance(l.begin(),itr_min);
            int d_max = distance(l.begin(),itr_max);

            cnt += d_max-d_min;
        }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 384
N,M = map(int, input().split())
As = list(map(int, input().split()))
import heapq
q = []
heapq.heapify(q)
for a in As:
    heapq.heappush(q,-a)
for i in range(M):
    a = heapq.heappop(q)
    a = (-a)//2*-1
    # print(a)
    heapq.heappush(q,a)

print(-1*sum(list(q)))

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

#define ll long long int
#define ull unsigned long long int
#define db double
#define ld long double
#define MOD 1000000007
#define inf (1LL << 62)
#define pi acos(-1.0)
#define si(a) scanf("%lld",&a)
#define sd(n) scanf("%lf", &n)
#define for1(i, stop) for(ll i = 1; i <= stop; i++)
#define for0(i, stop) for(ll i = 0; i < stop; i++)
#define rep1(i, start) for(ll i = start; i >= 1; i--)
#define rep0(i, start) for(ll i = (start-1); i >= 0; i--)
#define loop(i, start, stop, inc) for(ll i = start; i <= stop; i += inc)
#define pb(v,a) v.push_back(a)
#define pll pair <ll, ll>
#define mp make_pair
#define pbp(v,a,i) v.push_back(make_pair(a,i))
#define srt(v) sort(v.begin(),v.end())
#define rv(v) reverse(v.begin(),v.end())
#define ms(n, i) memset(n, i, sizeof(n))
#define debug printf("Debug\n");
#define en '\n'



#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef tuple<ll,ll,ll>tpl;

int main()
{
    _fastio
    ll n;
    cin>>n;
    if(n%1000==0)
    	cout<<"0"<<en;
    else
    {
    	ll c=(n/1000)+1;
    	c=c*1000;
    	cout<<c-n<<en;
    }
}


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

using namespace std;

int n,a[60];
int maxv,maxj;

int f(int x){
	if (x<0)return -x;
	else return x;
}

int main()
{
	cin>>n;
	int i,j;
	bool flag=1;
	for (i=1;i<=n;i++){
		cin>>a[i];
		if (f(a[i])>maxv){
			maxv=f(a[i]);
			maxj=i; 
		}
		if (i!=1 && a[i]<a[i-1])flag=0;
	}
	if (flag){
		cout<<0<<endl;
		return 0;
	}
	cout<<2*(n-1)<<endl;
	for (i=1;i<=n;i++){
		if (i==maxj)continue;
		cout<<maxj<<' '<<i<<endl;
	}
	for (i=2;i<=n;i++){
		if (a[maxj]>0){
			cout<<i-1<<' '<<i<<endl;
		}
		else{
			cout<<n-i+2<<' '<<n-i+1<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(a) int((a).size())

int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	string s;
	cin>>s;
	if(s[2] == s[3] && s[4] == s[5]) cout<<"Yes\n";
	else cout<<"No\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int n,a,b,c,d;
    string s;
    cin>>n>>a>>b>>c>>d;
    cin>>s;
    bool cnt1=false,cnt2=false;
    repi(i,a-1,c) if(s[i]=='#'&&s[i]==s[i+1]) cnt1=true;
    repi(i,b-1,d) if(s[i]=='#'&&s[i]==s[i+1]) cnt1=true;
    if(c<d){
        if(!cnt1) cout<<"Yes";
        else cout<<"No";
    }
    else{
        repi(i,b-1,d) if(s[i-1]=='.'&&s[i]==s[i-1]&&s[i+1]==s[i]) cnt2=true;
        if((!cnt1)&&cnt2) cout<<"Yes";
        else cout<<"No";
    }
}

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

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

  //cout << num % 10 << endl;
//  cout << num / 10 << endl;

  if(num%10 == 7)
    {
      cout << "Yes" << endl;
    }

  else
  {
    while(num > 0)
      {
        num /= 10;
        if (num%10 == 7)
          {
            cout << "Yes" << endl;
            break;
          }
      }
      if (num == 0)
        cout << "No" << endl;
  }
}


Measured memory_bytes: 3600
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

struct SCC {
    vector<vector<int>> G, G_r, G_out;
    vector<int> vs, used, cmp;
    SCC() = default;
    explicit SCC(int n) : G(n), G_r(n), G_out(n), used(n), cmp(n) {}

    void add_edge(int a, int b){
        G[a].emplace_back(b);
        G_r[b].emplace_back(a);
    }

    void dfs(int v){
        used[v] = 1;
        for (auto &&u : G[v]) if(!used[u]) dfs(u);
        vs.emplace_back(v);
    }

    void dfs_r(int v, int k){
        used[v] = 1;
        cmp[v] = k;
        for (auto &&u : G_r[v]) if(!used[u]) dfs_r(u, k);
    }

    int build() {
        int n = G.size();
        for (int i = 0; i < n; ++i) if(!used[i]) dfs(i);
        fill(used.begin(),used.end(), 0);
        int k = 0;
        for (int i = n - 1; i >= 0; --i) {
            if(!used[vs[i]]){
                dfs_r(vs[i], k++);
            }
        }
        G_out.resize(k);
        for (int i = 0; i < n; ++i) {
            for (auto &&j : G[i]) {
                if(cmp[i] != cmp[j]){
                    G_out[cmp[i]].emplace_back(cmp[j]);
                }
            }
        }
        for (int i = 0; i < k; ++i) {
            sort(G_out.begin(), G_out.end());
            G_out.erase(unique(G_out.begin(), G_out.end()), G_out.end());
        }
        return k;
    }

    int operator[](int k) const { return cmp[k]; }
};

struct TwoSAT {
    int n;
    SCC scc;
    explicit TwoSAT(int n) : n(n), scc(n*2) {};
    int negate(int v){
        int ret = n+v;
        if(ret >= n*2) ret -= n*2;
        return ret;
    }

    vector<int> build() {
        scc.build();
        vector<int> res(n);
        for (int i = 0; i < n; ++i) {
            if(scc[i] == scc[n+i]) return {};
            res[i] = scc[i] > scc[n+i];
        }
        return res;
    }

    void add_if(int u, int v){ // u -> v
        scc.add_edge(u, v);
        scc.add_edge(negate(v), negate(u));
    }

    void add_or(int u, int v){ // u || v
        add_if(negate(u), v);
    }
};

int main() {
    int n, d;
    cin >> n >> d;
    vector<int> xs(n), ys(n);
    for (int i = 0; i < n; ++i) {
        cin >> xs[i] >> ys[i];
    }
    TwoSAT G(n);
    for (int i = 0; i < n; ++i) {
        for (int j = i+1; j < n; ++j) {
            if(abs(xs[i]-xs[j]) < d) G.add_if(i, j+n);
            if(abs(xs[i]-ys[j]) < d) G.add_if(i, j);
            if(abs(ys[i]-xs[j]) < d) G.add_if(i+n, j+n);
            if(abs(ys[i]-ys[j]) < d) G.add_if(i+n, j);
        }
    }
    auto res = G.build();
    if(res.empty()) puts("No");
    else {
        puts("Yes");
        for (int i = 0; i < n; ++i) {
            printf("%d\n", res[i] ? xs[i] : ys[i]);
        }
    }
    return 0;
}

Measured memory_bytes: 3988
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
using namespace std;

#define ABS(a) (((a) >= 0) ? (a) : -(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define RFOR(i, a, b) for (int i = a; i > b; --i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define int long long

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

const int kMaxN = 100000;

int N, K;
int A[kMaxN];
int ans = 0;

signed main() {
  cin >> N >> K;
  REP(i, N) { cin >> A[i]; }

  ans = 1 + (N-K + (K-1) - 1)/(K-1);

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


Measured memory_bytes: 1024
#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);}

bitset<11> dig;

int main(){

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

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

    long long k;
    string n;

    cin >> n >> k;

    for(int i = 0; i < k; ++i){
        int j;
        cin >> j;
        dig[j] = 1;
    }

    bool g = false;
    bool good = true;
    for(int i = 0; i < n.size();){
        bool found = false;
        for(int j = 0; j < 10; ++j){
            if(g == false && j < n[i] - '0')
                continue;
            if(dig[j])
                continue;
            if(j > n[i] - '0')
                g = true;
            found = true;
            break;
        }
        if(!found){
            good = false;
            break;
        } else {
            ++i;
        }
    }

    g = false;
    if(good == false){
        for(int j = 1; j < 10; ++j){
            if(dig[j])
                continue;
            cout << j;
            break;
        }
        g = true;
    }

    for(int i = 0; i < n.size(); ++i){
        for(int j = 0; j < 10; ++j){
            if(g == false && j < n[i] - '0')
                continue;
            if(dig[j])
                continue;
            if(j > n[i] - '0')
                g = true;
            cout << j;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//#pragma GCC optimize ("Ofast")
//#pragma GCC target ("avx,avx2")
#define rep(i, n)    for(ll i = 0; i < (n); ++i)
#define repA(i, a, n)  for(ll i = a; i <= (n); ++i)
#define repD(i, a, n)  for(ll i = a; i >= (n); --i)
#define pb push_back
#define X first
#define Y second
typedef long long int ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vii;
const ll INF = 1e18+1;
const ll MOD = 1000000007L;
#ifdef umang99m
    #include "/home/umang/Desktop/folder/home/.templates/header.h"
#else
    #define dbg(args...)
    #define timer()
#endif
ll mod(ll a) {return abs(a);}
int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    ll n;
    cin>>n;
    vi h(n);
    rep(i,n) cin>>h[i];
    vi ans(n);
    ans[n-1] = 0;
    ans[n-2] = mod(h[n-1] - h[n-2]);
    for(int i=n-3; i>=0; i--){
        ans[i] = min(ans[i+1] + mod(h[i+1]-h[i]), ans[i+2] + mod(h[i+2]-h[i]));
    }
    cout<<ans[0]<<endl;

    timer();
    return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	string s;
	cin>>s;
	if (s=="ABC")
		cout<<"ARC";
	else
		cout<<"ABC";
}

Measured memory_bytes: 3584
def main():
    N,K=map(int,input().split())
    A=list(map(int,input().split()))
    pos=set()
    pos.add(0)
    i=0
    traversal=[0]
    start=0
    nodes=[1]
    while(start<K):
        position=A[i]-1
        if position in pos:
            break
        traversal.append(position)
        pos.add(position)
        start+=1
        nodes.append(A[i])
        i=position
    if start==K:
        print(nodes[-1])
    else:
        ind=traversal.index(position)
        interval=len(traversal)-ind
        print(nodes[ind+((K-ind)%interval)])
if __name__=='__main__':
    main()

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

int main() {
    string w, t; cin >> w >> t;
    
    long long ans = 0;
    while(t != "END_OF_TEXT") {
        transform(t.begin(), t.end(), t.begin(), ::tolower);
        if (t == w) ++ans;
        cin >> t; 
    }
    cout << ans << endl;
    return 0;
}


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

#define ll long long
#define debug(x) cout<<x<<"DE"<<endl;

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    string s;ll x=0;
    cin>>s;
    for(int i=2;i<=s.size();i++){
        if(s[i-2]==s[i-1]&&s[i-1]=='0')s[i-1]='1',x++;
        else if(s[i-2]==s[i-1]&&s[i-1]=='1')s[i-1]='0',x++;
    }
    cout<<x;
}


Measured memory_bytes: 3716
import sys
import itertools

N, M = (int(i) for i in input().split())
ks= [[int(i) for i in input().split()] for i in range(M)]
p = [int(i) for i in input().split()]
count = 0
comb = itertools.product(range(2), repeat = N)
comb = list(comb)
for ci in comb:
    FLAG = 1
    c = list(ci)
    #print(c)
    for i in range(M):
        count2 = 0
        for j in range(1, ks[i][0]+1):
            ##print(c)
            if c[ks[i][j]-1] == 1:
                count2+=1
            #print(count2, p[i])
        if count2%2 == p[i]:
            pass
        else:
            FLAG = 0
    if FLAG == 1:
        count +=1

print(count)


Measured memory_bytes: 42736
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v){stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modpow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isprime(ll n){if(n<2)return 0;if(!(n%2))return !(n-2);lll d=n-1,t,y;while(!(d%2))d>>=1;vl al={2,325,9375,28178,450775,9780504,1795265022};for(ll a:al){if(n<=a)break;t=d,y=modpow(a,t,n);while(t!=n-1&&y!=1&&y!=n-1)y=y*y%n,t<<=1;if(y!=n-1&&!(t%2))return 0;}return 1;}
void dout(double d){printf("%.12f\n",d);}
void YN(bool z){cout<<(z?"YES\n":"NO\n");}
void Yn(bool z){cout<<(z?"Yes\n":"No\n");}
void yn(bool z){cout<<(z?"yes\n":"no\n");}
mt19937 rnd; void set_rnd(){random_device r;rnd=mt19937(r());}
vl fact, rfact; void set_fact(int n, ll m){fact.pb(1);rfact.pb(1);FOR(i,1,n+1)fact.pb(fact[i-1]*i%m),rfact.pb(modpow(fact[i],m,m-2));}
const int iinf = 1e9+6;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
const int N = 1e5;
void init(){
  set_rnd();
//  set_fact(N);
}
string s;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  init();
  cin >> s;
  ll ans = 0;
  int c = 0;
  FOR(i, 0, sz(s)){
    if(s[i] == 'B'){
      c++;
    }else{
      ans += c;
    }
  }
  cout  << ans << endl;
  return 0;
}

Measured memory_bytes: 720
#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];
  }
  bool ans = true;
  for(int i=0;i<n;i++){
    if(a[i]%2==1){
      ans = false;
    }
  }
  int sum =0;
  bool dame = true;
  if(ans){
    while(dame){
      for(int i=0;i<n;i++){
        a[i] /=2;
      if(a[i]%2==1){
        dame = false;
      }
     }
      sum ++;
   }
  }
    cout << sum;
}


Measured memory_bytes: 256
#include<cstdio>
#include<vector>
int a[100005];
int start[100005];
int solid[100005];
std::vector<int> end[100005];

int getCost(int l,int r,int m){
    if(r>=l) return r-l;
    else return r-l+m;
}

int min(int a,int b){ return a>b?b:a; }

long long calCost(int x,int n,int m){
    long long res = 0;
    for(int i = 1; i <= n-1; i++){
        long long add = min(getCost(a[i],a[i+1],m),1+getCost(x,a[i+1],m));
        res += add;
    }
    return res;
}

int main(){
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i = 1; i <= n; i++){ 
        scanf("%d",&a[i]);
        a[i]--;
    }
    //for(int i = 1; i <= n; i++) printf("%d ",a[i]);
    //printf("\n");
    int cnt = 0;
    for(int i = 1; i <= n-1; i++){
        int l = (a[i]+1)%m, r = a[i+1];
        solid[i] = getCost(a[i],a[i+1],m);
        start[l]++;
        end[r].push_back(i);
        if(l>r) cnt++;
    }
    long long ans = calCost(0,n,m);
    //printf("ans = %lld\n",ans);
    long long sum = ans;
    for(int i = 0; i < m-1/*?*/; i++){
        cnt = cnt+start[i]-(int)end[i].size();
        //printf("i = %d, cnt = %d\n",i,cnt);
        for(int u: end[i]){
            sum = sum-1ll+(long long)solid[u];
        }
        sum -= (long long)cnt;
        if(ans>sum) ans = sum;
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 9060
#include <bits/stdc++.h>
using namespace std;
#define MAXN 10000001
typedef long long int ll;
int spf[MAXN];
void sieve()
{
    spf[1] = 1;
    for (int i=2; i<MAXN; i++)
        spf[i] = i;
    for (int i=4; i<MAXN; i+=2)
        spf[i] = 2;

    for (int i=3; i*i<MAXN; i++)
    {
        if (spf[i] == i)
        {
            for (int j=i*i; j<MAXN; j+=i)
                if (spf[j]==j)
                    spf[j] = i;
        }
    }
}
int countDivisors(int x)
{
      int result = 1;
      int currentDivisor = spf[x];
      int currentCount = 1;
      while (currentDivisor != 1) {
        x /= currentDivisor;
        int newDivisor = spf[x];
        if (newDivisor != currentDivisor) {
          result *= currentCount + 1;
          currentDivisor = newDivisor;
          currentCount = 1;
        } else {
          currentCount++;
        }
      }
      if (x != 1) {
        result *= currentCount + 1;
      }

      return result;
}
int main()
{
    sieve();
    int n;
    cin>>n;
    ll dp[n+1];
    dp[0] = 0;
    dp[1] = 1;
    for(ll i=2;i<=n;i++)
    dp[i] = dp[i-1] + i*(ll)countDivisors(i);
    cout<<dp[n];
}


Measured memory_bytes: 120768
#include<iostream>
#include<string>
using namespace std;
int main(){
long long int n;cin>>n;
  int t[4000];
  long long int ans=0LL;
  long long int a,b,c=0LL;
  for(long long int i=0;i<n;i++){
  	char ho;cin>>ho;
    if(ho=='R'){
      a++;
      t[i]=0;
    }
    if(ho=='G'){
      b++;
      t[i]=1;
    }
    if(ho=='B'){
      c++;
      t[i]=2;
    }
  }
  ans+=a*b*c;
for(int i=0;i<n;i++){
	for(int j=0;j<=i and j<n-i;j++){
    	if(t[i+j]!=t[i] and t[i]!=t[i-j] and t[i-j]!=t[i+j]){
        	ans--;
        }
    }
}
  cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 3588
S = str(input())
s = list(S)
u = s
p = 0
for i in range(2,len(s)-1):
        if s[i] == 'C':
            p = p + 1
for i in range(2,len(s)-p):
    if s[i] == 'C':
        if i != len(s) - 1:
            del s[i]
if s[0] == 'A':
    del s[0]
    if p == 1:
        q = ''.join(s)
        if q.islower() == True:
            print('AC')
        else:
            print('WA')
    else:
        print('WA')
else:
    print('WA')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define retunr return
#define pb push_back
#define mp make_pair
#define null NULL
#define sc(x) scanf("%d", &x)
#define sc64(x) scanf("%lld", &x)
#define pr(x) printf("%d", (x))
#define pr64(x) printf("%lld", (x))
#define sp putchar(' ')
#define ln putchar('\n')
#define rep(i,l,r) for (int i = l, lim = r;i <= lim; ++i)
#define repr(i,l,r) for (int i = r, lim = l;i >= lim; --i)
#define fi first
#define se second
#define SET(__set, val) memset(__set, val, sizeof __set)
#define fill(a,v,n) memset((a),(v),sizeof(a[0])*(n))
#define copy(a,b,n) memcpy((a),(b),sizeof(a[0])*(n))
#define ALL(x) (x.begin(),x.end())
#define prf(x) printf("%.20f", x)
#define for_each_edge(u) for(int i = point[u];i;i=G[i].n)
typedef unsigned int uint;
typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define N 100010
#define M 1024
#define MOD 1000000007
void _add(int &a, int b){a = (a+b)%MOD;}
void _sub(int &a, int b){a = (a+MOD-b)%MOD;}
void _mul(int &a, int b){a = (ll)a*b%MOD;}
void _max(int &a, int b){a = max(a,b);}
void _min(int &a, int b){a = min(a,b);}
ll gcd(ll a, ll b){if(!b)return a;return gcd(b,a%b);}
ll pw(ll a, ll b){ll res(1);while(b){if(b&1)res=res*a%MOD;a=a*a%MOD;b>>=1;}return res;}
ll pwM(ll a, ll b, ll mod){ll res(1);while(b){if(b&1)res=res*a%mod;a=a*a%mod;b>>=1;}return res;}

const int infi = 2147483647;
const ll infl = 9223372036854775807ll;
const db PI = 3.14159265358979323846;

/*
struct E{
	int v, w, n;
}G[N];
int cnt, point[N];
void adde(int u, int v, int w = 0){
	G[++cnt]=(E){v,w,point[u]},point[u]=cnt;
	G[++cnt]=(E){u,w,point[v]},point[v]=cnt;
}
void Ginit(int n){
	cnt = 0;
	fill(point,0,n+1);
}
*/
/*
struct hh{
	int a, b;
	bool operator < (const hh &x) const{
		if(a==x.a)return b<x.b;
		return a<x.a;
	}
}a[N];
*/
int n, m, k,q;
int a[N];
pii num1[N], num2[N];
int main(){
//	freopen("1", "r", stdin);
	sc(n);
	rep(i,1,n)sc(a[i]);
	rep(i,1,n){
		num1[a[i]].fi++;
		num1[a[i]].se = a[i];
		i++;
	}
	m = 100000;
	rep(i,2,n){
		num2[a[i]].fi++;
		num2[a[i]].se = a[i];
		i++;
	}
	sort(num1+1,num1+100000+1);
	sort(num2+1,num2+100000+1);
	
	if(num1[m].se != num2[m].se){
		pr(n-num1[m].fi-num2[m].fi),ln;
	}else{
		pr(min(n-num1[m].fi-num2[m-1].fi, n-num1[m-1].fi-num2[m].fi)),ln;
	}
/*
	int Case;
	sc(Case);
	rep(ca, 1, Case){
	    printf("Case #%d: ", ca);
	}
*/
	return 0;
}


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

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

  int ans=0;

  int now=0;
  for (int i = 0; i < 3; i++) {
    if(s[i]=='R')now++;
    else {

      now=0;
    }
    ans=max(now,ans);

  }
  std::cout << ans << '\n';




  return 0;
}


Measured memory_bytes: 3592
import java.util.*;
import java.lang.Math;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      	long x = sc.nextLong();
      	long k = sc.nextLong();
      	long d = sc.nextLong();
      	long m = x / d;
      
      	if( Math.abs(m) > k ){
          if( m > 0 ){
          	x = x - k*d;
          }else{
            x = x + k*d;
          }
          //System.out.println(x+":"+k+":"+m);
        }else{
          x = x - m*d;
          k = k - Math.abs(m);
          //System.out.println(x+":"+k+"::"+m);
          if( k%2 == 1 ){
            if( Math.abs(x+d) <= Math.abs(x-d) ){
              x += d;
            }else{
              x -= d;
            }
          }
          
        }
      System.out.println(Math.abs(x));
	}
}

Measured memory_bytes: 26972
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;

void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int a, b, c;
    cin >> a >> b >> c;
    if (a > b)
        swap(a, b);
    if (b > c)
        swap(b, c);
    if (a > b)
        swap(a, b);
    if (a == 5 && b == 5 && c == 7)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
};


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define pb push_back
#define mpr make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ll long long
#define ld long double
#define fi first
#define se second
#define all(arr) arr.begin(), arr.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define fo(i, l, r) for (int i = l; i <= r; i++)
#define INF 1000000001
#define inf1 1000000000000000001
#define MOD 1000000007
#define mod 1000000007
#define pie 3.14159265358979323846264338327950L
#define N 200009
#define M 2000009
#define mid(l, r) l + (r - l) / 2
#define vec vector<int>
#define umap unordered_map<int, int>
#define yes cout << "YES" << endl;
#define no cout << "NO" << endl;
#define endl "\n"
#define int long long
using namespace std;
 
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};  
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}
ll lcm(ll a, ll b) { return (a*b)/ gcd(a,b);}



void test_case()
{
  string s;
  cin>>s;

  int n = s.size();

  if(s[n-1] == 's') {
    s = s + "es";
  } else {
    s =s + "s";
  }

  cout<<s<<endl;


}
 
signed main ()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(20);
 
    //  freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
 
    int t = 1;
    // cin >> t;
    while (t--)
    {
        test_case();
    }
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,n) for (int64_t i=0; i<(n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()
#define chmax(x,y) x=max(x,y)




int main(){
    int n,m; cin>>n>>m;
    int ans=1900*m+100*(n-m);
    int kari=pow(2,m);
    ans*=kari;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3976
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP2(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
#define INF 2e9
typedef long long ll;

int main()
{
  ll a,b,c;
  cin>>a>>b>>c;

  if(b<c) swap(b,c);
  if(a<b) swap(a,b);
  if(a%2 && b%2 && c%2) cout<<b*c<<endl;
  else cout<<0<<endl;
  
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class MainClass : Scanner
{
    static void Main()
    {
        var (K, A, B) = ReadStream<long,long,long>();
        if (B - A <= 2)
        {
            WriteLine(K+1);return;
        }
        long dif = B - A;
        long ans = 0;
        K -= (A - 1);
        ans += K / 2 * dif+A;
        if (K % 2 == 1) ans++;
        WriteLine(ans);
    }
}

class Scanner
{
    public static int RInt() => int.Parse(Console.ReadLine());
    public static long RLong() => long.Parse(Console.ReadLine());
    public static string RString() => Console.ReadLine();
    public static double RDouble() => double.Parse(Console.ReadLine());

    public static int[] RInts() => Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
    public static int[] RInts(Func<string, int> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static long[] RLongs() => Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
    public static long[] RLongs(Func<string, long> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static double[] RDoubles() => Array.ConvertAll(Console.ReadLine().Split(), double.Parse);
    public static double[] RDoubles(Func<string, double> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static string[] RStrings() => Console.ReadLine().Split();
    //public static string[] RStrings(Func<string, string> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static T1 ReadStream<T1>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        return r1;
    }
    public static (T1, T2) ReadStream<T1, T2>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        return (r1, r2);
    }
    public static (T1, T2, T3) ReadStream<T1, T2, T3>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        var r3 = (T3)Convert.ChangeType(r[2], typeof(T3));
        return (r1, r2, r3);
    }
    public static (T1, T2, T3, T4) ReadStream<T1, T2, T3, T4>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        var r3 = (T3)Convert.ChangeType(r[2], typeof(T3));
        var r4 = (T4)Convert.ChangeType(r[3], typeof(T4));
        return (r1, r2, r3, r4);
    }
}

Measured memory_bytes: 27536
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;


public class A
{
	public static void Main()
	{
		int A = Int32.Parse(Console.ReadLine());
		int B = Int32.Parse(Console.ReadLine());
		int C = Int32.Parse(Console.ReadLine());
		int D = Int32.Parse(Console.ReadLine());

		Console.WriteLine(Math.Min(A,B) + Math.Min(C,D));
	}
}





Measured memory_bytes: 13140
object Main{
  def main(args:Array[String]):Unit = {
    val sc = new java.util.Scanner(System.in)
    val k = sc.nextLong
    val a = sc.nextLong
    val b = sc.nextLong
    
    if(b-a <= 2){
      println(k+1)
    }
    else{
      val count = Math.max(0, (k-a+1)/2)
      println(1 + (b-a)*count + (k-count*2))
    }
  }
}


Measured memory_bytes: 25532
// #pragma GCC optimize("unroll-loops", "omit-frame-pointer", "inline")
// #pragma GCC option("arch=native", "tune=native", "no-zero-upper")
// #pragma GCC
// target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("tree-vectorize","openmp","predictive-commoning")
// #pragma GCC option("D_GLIBCXX_PARALLEL","openmp")

// #pragma GCC optimize("O3")
// #pragma GCC target("avx2")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << endl;

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

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"

void solve() {
  ll N;
  cin >> N;
  for (ll n = 1; n <= 3500; n++) {
    for (ll w = 1; w <= 3500; w++) {
      ll x = 4 * n * w - w * N - n * N;
      ll y = n * w * N;
      if (x == 0 && y == 0) {
        cout << 1 << ' ' << n << ' ' << w << endl;
        return;
      }
      if (x == 0) continue;
      if (y % x != 0) continue;
      if (y / x <= 0) continue;
      cout << y / x << ' ' << n << ' ' << w << endl;
      return;
    }
  }
  return;
}

signed main() {
  fastio();
  solve();
  //   int t;
  //   cin >> t;
  //   while (t--) solve();

  // int t; cin >> t;
  // for(int i=1;i<=t;i++){
  //   cout << "Case #" << i << ": ";
  //   solve();
  // }
  return 0;
}


Measured memory_bytes: 256
parseInt(x) = parse(Int, x)
parseBigInt(x) = parse(BigInt, x)
parseFloat(x) = parse(Float64, x)
parseBigFloat(x) = parse(BigFloat, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n,x,y=parseMap(split(readline()))
    dis=[[j-i for j in 1:n] for i in 1:n]
    for i in 1:n
        for j in i+1:n
            dis[i][j]=min(dis[i][j],abs(i-x)+abs(j-y)+1)
        end
    end
    cnt=Dict{Int,Int}(i=>0 for i in 1:n-1)
    for i in dis
        for j in i
            if haskey(cnt,j)
                cnt[j]+=1
            end
        end
    end
    for i in 1:n-1
        println(cnt[i])
    end
end
main()

Measured memory_bytes: 146320
#include<stdio.h>
#include<math.h>
int main(){
int i=0,x,y,min,max;
while(i<3000){
   scanf("%d %d",&x,&y);
   if(x==0 && y ==0){
      break;
   }
   min=fmin(x,y);
   max=fmax(x,y);
   printf("%d %d\n",min,max);
   i++;
}
   return 0;
}

Measured memory_bytes: 1796
N, A = map(int, input().split())
xs = list(map(int, input().split()))

sumX = sum(xs)

# dp[i][j]: i枚で合計jとなる選び方の個数
dp = [[0] * (sumX + 1) for _ in range(N + 1)]
dp[0][0] = 1
for k, x in enumerate(xs):
    for i in reversed(range(k + 1)):
        for j in range(sumX + 1):
            if dp[i][j] == 0: continue
            dp[i + 1][j + x] += dp[i][j]

# 平均A = i枚で合計(A*i)
ans = 0
for i in range(1, min(N, sumX // A) + 1):
    ans += dp[i][A * i]
print(ans)


Measured memory_bytes: 4084
n = gets.to_i
hash = Hash.new(0)
n.times do
  s = gets.chomp
  hash[s] += 1
end
m = gets.to_i
m.times do
  t = gets.chomp
  hash[t] -= 1
end
val = hash.sort_by{|k,v| -v}.to_a[0][1]
if val < 0
  puts 0
else
  puts val
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef pair<long long, long long> P;
#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#define int long long
signed main(signed argc, char* argv[]) {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	const int MOD = 1e9+7;
	char c;
	cin>>c;
	cout<<char((int)c+1)<<endl;
}

Measured memory_bytes: 256
from collections import Counter

n=int(input())
s=[Counter(input()) for _ in range(n)]

c = s[0]
#各アルファベット(a,b,c,...,z)に対して，使用回数の最小値を求める
c = s[0]
for i in range(1,n):
    for k,v in c.items():
        c[k] = min(s[i][k], c[k])
        
c = sorted(c.items())
ans = ''
for k,v in c:
    ans += k*v
print(ans)

Measured memory_bytes: 40432
#include<bits/stdc++.h>
#define LL long long
const int N=200005;
using namespace std;

int n,a[N],b[N],num[N],tot=0;
int fa[N],sz[N],ans=0,chk[N];
map<int,int>vis;

int getfa(int x){
	if(fa[x]!=x)fa[x]=getfa(fa[x]);
	return fa[x];
}

void add(int x,int y){
	int X=getfa(x),Y=getfa(y);
	if(X==Y)return;
	fa[X]=Y;chk[Y]=1;
}

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		if(!vis[a[i]])vis[a[i]]=++tot;
		a[n+1]^=a[i];
		num[vis[a[i]]]++;
	}
	if(!vis[a[n+1]])vis[a[n+1]]=++tot;
	num[vis[a[n+1]]]++;
	for(int i=1;i<=n;i++){
		scanf("%d",&b[i]);
		if(!vis[b[i]]||num[vis[b[i]]]<=0)ans=-1;
		b[n+1]^=b[i];
		num[vis[b[i]]]--;
	}
	if(!vis[b[n+1]]||num[vis[b[n+1]]]<=0)ans=-1;
	if(ans==-1){
		printf("-1\n");
		return 0;
	}
	for(int i=1;i<=tot;i++)fa[i]=i;
	for(int i=1;i<=n;i++){
		if(a[i]==b[i])continue;
		ans++;
		add(vis[a[i]],vis[b[i]]);
	}
	if(vis[a[n+1]]!=vis[b[n+1]])add(vis[a[n+1]],vis[b[n+1]]);
	for(int i=1;i<=tot;i++)fa[i]=getfa(i);
	for(int i=1;i<=tot;i++){
		if(fa[i]==i&&chk[i])ans++;
		if(i==vis[a[n+1]]){
			if(fa[i]!=i||(fa[i]==i&&chk[i]))ans--;
		}
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 9600
n,m = map(int,input().split())
a = sorted(list(map(int,input().split())),reverse=True)
b = sum(a)/(4*m)
c=[]
for i in a[:m]:
  if i >= b:
    c.append(i)

if len(c) == m:
  print('Yes')
else:
  print('No')


Measured memory_bytes: 9000