akhauriyash/Code-Regression huggingface dataset:
# Problem D - Friend Suggestions

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

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

# initialization
friend_uf = UnionFind(N)
not_list = [[] for i in range(N+1)]
ans_list = [0] * (N)

# friend relation union
for i in range(M):
    a, b = map(int, input().split())
    friend_uf.union(a-1, b-1)
    not_list[a].append(b)
    not_list[b].append(a)

# block relation union
for i in range(K):
    c, d = map(int, input().split())
    if friend_uf.same(c-1, d-1):
        not_list[c].append(d)
        not_list[d].append(c)

# output
for i in range(1, N+1):
    group_size = friend_uf.size(i-1)
    not_size = not_list[i]
    ans = group_size - len(set(not_size)) - 1
    ans_list[i-1] = ans
ans_list = list(map(str, ans_list))
print(" ".join(ans_list))


Measured memory_bytes: 117920
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
using namespace std;
using namespace __gnu_pbds;
using ll = int64_t;
using ld = long double;
using ull = uint64_t;
using pl = pair<ll, ll>;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

ll t, d, m, n;

ll a, b, c;
vector<ll> v;

int main() {
  ios::sync_with_stdio(0);
  cout.precision(10);

  cin >> n >> m;
  v.resize(n);

 ll total = 0;
  for (int i = 0; i < n; i++) {
    cin >> v[i];
    total += v[i];
  }
  ll cnt = 0;
  for (int i = 0; i < n; i++) {
    if (v[i]*4*m >= total) {
      cnt++;
    }
  }
  if (cnt >= m) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}



Measured memory_bytes: 256
n = int(input())

a = [[0]*n for x in range(n)]

for i in range(n):
  nood = list(map(int,input().split()))
  nood_elements = nood[0]-1
  for j in range(2,len(nood)):
    a[nood_elements][nood[j]-1] += 1
  
  for j in range(n-1):
    print(a[nood_elements][j],end=" ")
  print(a[nood_elements][n-1])


Measured memory_bytes: 5640
import java.lang.*;
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] h = new int[n+1];
        h[0] = 0;
        for(int i = 0;i<n;i++){
            h[i+1] = sc.nextInt();
        }
        for(int i = 0;i<n;i++){
            if(h[i]<h[i+1]){
                h[i+1]-=1;
            }else if(h[i]==h[i+1]){

            }else{
                System.out.println("No");
                return;
            }
        }
        System.out.println("Yes");
    }
}

Measured memory_bytes: 50040
#include<stdio.h>
#include <queue>
using namespace std;

bool flag = true;

void solve(queue<int> left, queue<int> right, queue<int> all) {
	if (all.size() > 0) {
		if (left.size() > 0) {
			if (all.front() > left.back()) {
				left.push(all.front());
				all.pop();
				solve(left, right, all);
			}
			else {
				if (right.size() > 0) {
					if (all.front() > right.back()) {
						right.push(all.front());
						all.pop();
						solve(left, right, all);
					}
					else if(all.size() == 0){
					
					}
					else {
						flag = false;
					}
				}
				else {
					right.push(all.front());
					all.pop();
					solve(left, right, all);
				}
			}
		}
		else {
			left.push(all.front());
			all.pop();
			solve(left, right, all);
		}
	}
}

int main() {

	int n;
	scanf("%d", &n);
	for (; n > 0; n--) {
		queue<int> all;
		queue<int> left;
		queue<int> right;
		for (int i = 0; i < 10; i++) {
			int temp;
			scanf("%d", &temp);
			all.push(temp);
		}
		solve(left, right, all);
		if (flag)
			printf("YES\n");
		else
			printf("NO\n");
	}	
	return 0;
}

Measured memory_bytes: 1052
#include <iostream>
#include <climits>
using namespace std;
long long arr[1000005];

long long gcd(long long a, long long b){
  return (b == 0) ? a : gcd(b, a%b);
}

bool multiples(long long n, long long target){
  long long gcdNum = 0;
  for(long long i = 0; i < n; i++){
    gcdNum = gcd(gcdNum, arr[i]);
  }
  return (target%gcdNum == 0);
}

int main(){
	std::ios::sync_with_stdio(false);
	cin.tie(); cout.tie();
	long long n, target, largest = INT_MIN;
	cin >> n >> target; 
	for(long long i = 0; i < n; i++){
		cin >> arr[i];
		largest = max(largest, arr[i]);
	}

	if(largest >= target && multiples(n, target)) {
    cout << "POSSIBLE" << endl;
  }
  else cout << "IMPOSSIBLE" << endl;
  return 0;
}

Measured memory_bytes: 3704
import bisect as bc

N = int(input())
A = list(map(int,input().split()))
A.sort()

dp = [True for _ in range(A[-1]+1)]

for i in range(N):
    ai = A[i]
    for j in range(2,A[-1]+1):
        if ai*j > A[-1]:
            break
        dp[ai*j] = False

ans = 0
finish = [True for _ in range(A[-1]+1)]
for i in range(N):
    if dp[A[i]] and finish[A[i]]:
        if bc.bisect_right(A,A[i]) - bc.bisect_left(A,A[i]) == 1:
            ans += 1
            finish[A[i]] = False

print(ans)




Measured memory_bytes: 167564
n=int(input())
l=list(map(int,input().split()))
s=[0 for i in range(n+1)]
ans=0
for i,j in enumerate(l,1):
    if(i==j):
        s[i]=1
    if(s[i-1] and s[i]):
        ans+=1
        s[i]=0
    elif(s[i-1] and not s[i]):
        ans+=1
if(s[-1]==1):
  ans+=1
print(ans)

Measured memory_bytes: 13880
import java.util.*;

public class Main {

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

    if(d == 25) {
      System.out.println("Christmas");
    } else if(d == 24) {
      System.out.println("Christmas Eve");
    } else if(d == 23) {
      System.out.println("Christmas Eve Eve");
    } else if(d == 22) {
      System.out.println("Christmas Eve Eve Eve");
    }
  }

}

Measured memory_bytes: 19796
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<ll>::iterator sit;
typedef map<ll,ll>::iterator mit;

const int MOD=1e9+7;

int add(int a, int b)
{
	a+=b;
	while(a>=MOD) a-=MOD;
	return a;
}

int mult(int a, int b)
{
	return (a*1LL*b)%MOD;
}

vector<ii> adj[200011];
ll dist[200011];
ll dp[200011];
ll dp2[200011];
ll dist2[200011];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n,m,s,t; cin>>n>>m>>s>>t; s--; t--;
	for(int i=0;i<m;i++)
	{
		int u,v; ll d; cin>>u>>v>>d;
		u--; v--; d*=2;
		adj[u].pb(mp(v,d)); adj[v].pb(mp(u,d)); 
	}
	priority_queue<ii,vector<ii>,greater<ii> > pq;
	for(int i=0;i<n;i++) dist[i]=ll(1e18);
	pq.push(mp(0,s)); dist[s] = 0; dp[s] = 1;
	while(!pq.empty())
	{
		ll D = pq.top().fi; int u=pq.top().se; pq.pop();
		for(int i=0;i<adj[u].size();i++)
		{
			int v=adj[u][i].fi; ll w=adj[u][i].se;
			if(D+w<dist[v])
			{
				dp[v] = dp[u];
				dist[v] = D + w;
				pq.push(mp(dist[v],v));
			}
			else if(D+w==dist[v])
			{
				dp[v] = add(dp[v], dp[u]);
			}
		}
	}
	ll finaldist = dist[t];
	finaldist>>=1;
	swap(s,t);
	for(int i=0;i<n;i++) dist2[i]=ll(1e18);
	pq.push(mp(0,s)); dist2[s] = 0; dp2[s] = 1;
	while(!pq.empty())
	{
		ll D = pq.top().fi; int u=pq.top().se; pq.pop();
		for(int i=0;i<adj[u].size();i++)
		{
			int v=adj[u][i].fi; ll w=adj[u][i].se;
			if(D+w<dist2[v])
			{
				dp2[v] = dp2[u];
				dist2[v] = D + w;
				pq.push(mp(dist2[v],v));
			}
			else if(D+w==dist2[v])
			{
				dp2[v] = add(dp2[v], dp2[u]);
			}
		}
	}
	finaldist = dist2[t];
	finaldist>>=1;
	int ans=0;
	for(int i=0;i<n;i++)
	{
		if(dist[i]==finaldist)
		{
			ans = add(ans, mult(mult(dp[i],dp2[i]),mult(dp[i],dp2[i])));
		}
	}
	for(int i=0;i<n;i++)
	{
		for(ii v:adj[i])
		{
			if(dist[i] + v.se == dist[v.fi] && dist[v.fi] + dist2[v.fi] == finaldist*2 && dist[v.fi] > finaldist && dist[i] < finaldist)
			{
				ans = add(ans, mult(mult(dp[i], dp2[v.fi]), mult(dp[i], dp2[v.fi])));
			}
		}
	}
	ans = add(mult(dp2[t], dp2[t]), MOD - ans);
	cout<<ans<<'\n';
}


Measured memory_bytes: 21752
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>

#define                           int                         long long
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<int,int>
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);




using namespace std;

const int inf=1e18;
const int mod=1e9+7;
const int M=100009;

inline int bigmod(int B,int P){int R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}
inline int ad(int x,int y){int ret=(x%mod+y%mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline int sub(int x,int y){int ret=((x%mod)-(y%mod)+mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline int gun(int x,int y){int ret=((x%mod)*(y%mod))%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
 main()

{
    fast
    string s;
    cin>>s;
    int sz=s.size();
    int x=0;
    f(i,0,sz-1)
    {
        int  yo=s[i]-'0';
        x+=yo;
    }
    int y=s[0]-'0';
    y--;
    y+=((sz-1)*9);
    cout<<max(x,y)<<endl;
    return 0;
}


Measured memory_bytes: 256
# coding: utf-8


def solve(*args: str) -> str:
    n, m = map(int, args[0].split())
    A = list(map(int, args[1].split()))
    ret = max(-1, n-sum(A))

    return str(ret)


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))


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

# メモ化するための初期化
a, p = [1], [1]
for i in range(N):
    a.append(a[i] * 2 + 3)
    p.append(p[i] * 2 + 1)

def f(N, X):
    # X <= 0 や X > a_N を許容し解説本文から簡略化
    if N == 0:
        if X <= 0:
            return 0
        else:
            return 1
    elif X <= 1 + a[N - 1]:
        return f(N - 1, X - 1)
    else:
        return p[N - 1] + 1 + f(N - 1, X - 2 - a[N - 1])

print(f(N, X))


Measured memory_bytes: 3188
import copy

N, Ma, Mb = map(int, input().split())
ABC = [tuple(map(int, input().split())) for _ in range(N)]

INF, W = 10 ** 10, N * 10 * max(Ma, Mb)
dp = [[INF] * (W * 2 + 1)]

for a, b, c in ABC:
    dp.append(copy.deepcopy(dp[-1]))
    df = a * Mb - b * Ma
    dp[-1][df + W] = min(dp[-1][df + W], c)
    for d in range(-W, W + 1):
        if not dp[-2][d] == INF:
            dp[-1][df + d] = min(c + dp[-2][d], dp[-2][df + d], dp[-1][df + d])

print("-1" if dp[N][W] == INF else dp[N][W])


Measured memory_bytes: 6260
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back 
#define pf push_front 
#define mp make_pair
#define fr first
#define sc second
#define Rep(i,n) for(int i=0;i<(n);i++)
#define All(v) v.begin(),v.end()
typedef pair<int, int> Pii; typedef pair<int, Pii> Pip;
const int INF = 1107110711071107;

main()
{
  int n;
  int isprime[2*123457];

  fill_n(isprime, 2*123457, 1);
  
  for(int i=2; i<2*123457; i++) {
    for(int j=2; i*j<2*123457; j++) {
      isprime[i*j] = 0;
    }
  }
  
  while( cin >> n, n ) {
    int ans = 0;
    for(int i=n+1; i<=2*n; i++) {
      if( isprime[i] ) ans++;
    }

    cout << ans << endl;
  }
}

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

int number[200000];

int main() 
{
	int  n,small;
	cin>>n;
	int count=1;
	cin>>number[0];
	small=number[0];
	for(int i=1;i<n;i++)
	{
		cin>>number[i];
		if(small>=number[i])
		{
		//	cout<<number[i]<<endl; 
			count++;
			small=number[i];
		}
	}
	cout<<count;
	return 0;
}

Measured memory_bytes: 4416
S = str(input())
ans = 0
s_ctr = 0
# s の後の t をひたすら省く
for i in range(len(S)):
    if S[i] == "S":
        s_ctr += 1
    else:
        if s_ctr > 0:
            ans += 1
            s_ctr -= 1
print(len(S) - ans * 2)

Measured memory_bytes: 40304
from collections import defaultdict
mod = 10**9 + 7
n = int(input())
d = defaultdict(int)
for c in list(input()):
    d[c] += 1

res = 1
for c in d:
    res *= (d[c]+1)
    res %= mod
res = res + mod - 1
res %= mod
print(res)

Measured memory_bytes: 4340
#include <bits/stdc++.h>
using namespace std;
/*
bool isPrime(int x)
{
	test++;
	if(x < 2)
		return false;
	if(x == 2)
		return true;
	if(x % 2 == 0)
		return false;
	for(int i = 3; i * i <= x; i += 2)
	{
		if(x % i == 0)
			return false;
	}
	return true;
}
*/
vector<bool> prime(1e7 + 1, true);
void make_prime()
{
	prime[0] = prime[1] = false;
	for(int i = 2; i <= 1e7 + 10; i++)
	{
		if(prime[i])
		{
			for(int j = 2 * i; j <= 1e7 + 10; j += i)
				prime[j] = false;
		}
	}
}
int main()
{
	long n;
	cin >> n;
	int p = 2;
	int cnt = 0;
	make_prime();
	for(int q = 3; q <= n; q++)
	{
		if(prime[q] && prime[p + q] == true)
			cnt++;
	}
	cout << cnt * 2 << endl;
	return 0;
}



Measured memory_bytes: 3984
import java.util.Scanner;
 
class Main {
    public static void main(String[] args) {
        int a, b;
        Scanner sc = new Scanner(System.in);
        a = sc.nextInt();
        b = sc.nextInt();
        System.out.println(a * b + " " + 2 * (a + b));
    }
}


Measured memory_bytes: 26128
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#include <fstream>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}

#define INF 1e9+7
#define LLINF 1e18+7
#define N 110000
ll MOD=1e9+7;

template< unsigned mod >
struct RollingHash {
  vector< unsigned > hashed, power;

  inline unsigned mul(unsigned a, unsigned b) const {
    unsigned long long x = (unsigned long long) a * b;
    unsigned xh = (unsigned) (x >> 32), xl = (unsigned) x, d, m;
    asm("divl %4; \n\t" : "=a" (d), "=d" (m) : "d" (xh), "a" (xl), "r" (mod));
    return m;
  }

  RollingHash(const string &s, unsigned base = 10007) {
    int sz = (int) s.size();
    hashed.assign(sz + 1, 0);
    power.assign(sz + 1, 0);
    power[0] = 1;
    for(int i = 0; i < sz; i++) {
      power[i + 1] = mul(power[i], base);
      hashed[i + 1] = mul(hashed[i], base) + s[i];
      if(hashed[i + 1] >= mod) hashed[i + 1] -= mod;
    }
  }

  unsigned get(int l, int r) const {
    unsigned ret = hashed[r] + mod - mul(hashed[l], power[r - l]);
    if(ret >= mod) ret -= mod;
    return ret;
  }

  unsigned connect(unsigned h1, int h2, int h2len) const {
    unsigned ret = mul(h1, power[h2len]) + h2;
    if(ret >= mod) ret -= mod;
    return ret;
  }

  int LCP(const RollingHash< mod > &b, int l1, int r1, int l2, int r2) {
    int len = min(r1 - l1, r2 - l2);
    int low = -1, high = len + 1;
    while(high - low > 1) {
      int mid = (low + high) / 2;
      if(get(l1, l1 + mid) == b.get(l2, l2 + mid)) low = mid;
      else high = mid;
    }
    return (low);
  }
};

using RH = RollingHash< 1000000007 >;

main(){
    int n=in();
    string s;cin>>s;
    RH rh(s);
    int l=0,r=n;
    while(l<r-1){
        int mid=(l+r)/2;
        map<ll,int> m;
        bool flag=false;
        rep(i,n+1-mid){
            ll now=rh.get((int)i,(int)i+mid);
            int t=m[now];
            if(t==0)m[now]=i+1;
            else{
                if(i>=m[now]-1+mid)flag=true;
            }
        }
        if(flag)l=mid;
        else r=mid;
    }
    cout<<l<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define M 510
#define LL long long
#define rep(i, x, y) for(int i = (x); i <= (y); ++ i)
inline int read() {
	char ch = getchar(); int x = 0, f = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-') f = -1;
		ch = getchar();
	}
	while('0' <= ch && ch <= '9') {
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	return x * f;
}
char s[M][M];
int main() {
	//freopen("in.txt", "r", stdin);
	int A = read(), B = read();
	if(A == 1) {
		rep(i, 1, 99) rep(j, 1, 99) s[i][j] = '.';
		for(int i = 2; i <= 99; i += 3) {
			for(int j = 2; j <= 99; j += 3) {
				if(B) s[i][j] = '#', B --;
			}
		}
	}
	else if(B == 1) {
		rep(i, 1, 99) rep(j, 1, 99) s[i][j] = '#';
		for(int i = 2; i <= 99; i += 3) {
			for(int j = 2; j <= 99; j += 3) {
				if(A) s[i][j] = '.', A --;
			}
		}
	}
	else {
		A --; B --;
		for(int i = 1; i <= 50; ++ i) {
			rep(j, 1, 99) s[i][j] = '#';
		}
		for(int i = 51; i <= 99; ++ i) {
			rep(j, 1, 99) s[i][j] = '.';
		}
		for(int i = 2; i <= 50; i += 3) {
			for(int j = 2; j <= 99; j += 3) {
				if(A) s[i][j] = '.', A --;
			}
		}
		for(int i = 53; i <= 99; i += 3) {
			for(int j = 2; j <= 99; j += 3) {
				if(B) s[i][j] = '#', B --;
			}
		}
	}
	printf("99 99\n");
	rep(i, 1, 99) {
		rep(j, 1, 99) printf("%c", s[i][j]);
		puts("");
	}
	return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let q = read::<usize>();

    let mut queries = vec![];
    for _ in 0..q {
        let v = read_vec::<i64>();
        queries.push(v);
    }

    let mut b_sum = 0;
    let mut lower_a = BinaryHeap::new();
    let mut lower_a_sum = 0;
    let mut upper_a = BinaryHeap::new();
    let mut upper_a_sum = 0;
    for v in queries {
        if v[0] == 1 {
            let (a, b) = (v[1], v[2]);
            if lower_a.is_empty() || *lower_a.peek().unwrap() >= a {
                lower_a.push(a);
                lower_a_sum += a;
            } else {
                upper_a.push(-a);
                upper_a_sum += a;
            }
            if lower_a.len() > upper_a.len() + 1 {
                let na = lower_a.pop().unwrap();
                lower_a_sum -= na;
                upper_a.push(-na);
                upper_a_sum += na;
            }
            if lower_a.len() < upper_a.len() {
                let na = -upper_a.pop().unwrap();
                upper_a_sum -= na;
                lower_a.push(na);
                lower_a_sum += na;
            }
            b_sum += b;
        } else {
            let mut ans = b_sum;
            ans += -lower_a_sum + lower_a.len() as i64 * *lower_a.peek().unwrap();
            if !upper_a.is_empty() {
                ans += upper_a_sum - upper_a.len() as i64 * *lower_a.peek().unwrap();
            }
            println!("{} {}", *lower_a.peek().unwrap(), ans);
        }
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


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

int main() {
  int OOTJNY;
  cin >> OOTJNY;
  int a;
  double KYR;
  int WAYO;
  WAYO = OOTJNY;
  KYR = 0;
  
  while(OOTJNY != 0){
  a = OOTJNY % 10;
  KYR += a;
  OOTJNY /= 10;
  }
  
  double YABAI;
  YABAI = WAYO / KYR;
  WAYO = YABAI;
  if(YABAI == WAYO){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define ordered_set tree<long long, null_type,less<long long>, rb_tree_tag,tree_order_statistics_node_update>
//s.find_by_order(index) returns iterator to the index-th element
//in O(logn) time.



typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vii;
typedef vector<string> vss;
typedef vector<pair<ll, ll> > vpll;
typedef unordered_map<ll ,ll> mpll;
typedef unordered_map<int ,int> mpii;
typedef unordered_map<char ,ll> mpcl;
typedef pair<ll , ll> pll;
typedef complex<double> cd;
typedef vector< complex<double> > vcd;


#define fore(i,n) for(i=0;i<n;i++)
#define forz(i,s,f) for(i=s;i<f;i++)
#define forer(i,n) for(i=n-1;i>=0;i--)
#define forzr(i,s,f) for(i=s;i>=f;i--)
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ff first
#define ss second
#define pvec(i,vec) fore(i,vec.size())cout<<vec[i]<<" ";cout<<"\n";

const ll mod=1e9+7;
const ll modulo=998244353;
const double pi = 3.14159265358979323846;


ll power(ll x,ll y,ll m)//gives (x^y)%m
{
    ll ans=1;
    while (y>0)
    {
        if(y & 1)
        {
            ans=(ans*x)%m;
        }
        y=y/2;
        x=(x*x)%m;
    }
    return ans;
}

ll gcd(ll a,ll b)
{
	if(a==0)
		return b;
	else
		return(gcd(b%a,a));
}

ll lcm(ll a,ll b)
{
	ll ans=(a*b)/gcd(a,b);
	return ans;
}

long double logn(long double a,long double n)
{
	return(log(n)/log(a));
}

bool sortbysec(pll &a,pll &b)
{
    return(a.ss<b.ss);
}

int main(int argc, char const *argv[])
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);

	ll te=1,test,i,j,n,m,flag,k,p,temp,t;
	//cin>>te;
	
	for(test=1;test<=te;test++)
	{
		cin>>n>>m>>t;
		
		k=ceil((double)n/(double)m);
		cout<<(k*t)<<"\n";
		/*vll a(n);
		fore(i,n)
		{
			cin>>a[i];
		}*/


		//cout<<"hello\n";
		//cout<<"Case #"<<test<<": ";
	}

	return 0;
}

Measured memory_bytes: 3636
use std::io;

fn main() {
    let mut terminal_input = String::new();
    io::stdin().read_line(&mut terminal_input).expect("Failed to read line");
    let terminal_input: Vec<&str> = terminal_input.split(' ').collect();
    let a: i32 = terminal_input[0].trim().parse().expect("Type error");
    let b: i32 = terminal_input[1].trim().parse().expect("Type error");

    // println!( "{:?}", terminal_input);
    let terminal_output1: i32 = a*b;
    let terminal_output2: i32 = 2*a +2*b;
    println!( "{} {}", terminal_output1, terminal_output2 );
}



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

int main(){
	std::string str;
	cin >> str;
	
	char a = str[0];
	bool is_good = true;
	
	for(int i = 1; i < str.length(); i++){
		if( a == str[i] ){
			is_good = false;
			break;
		}
		a = str[i];
	}
	if( is_good )cout << "Good" << endl;
	else cout << "Bad" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <bitset>
#include <algorithm>
using namespace std;
 
///////////////////////////SubMain//////////////////////////////////
int main(int argc, char *argv[])
{
 
	int n;
	cin >> n;
	while (n--)
	{
		int ball[10];
		
		for (int i = 0; i < 10; ++i)
		{
			cin >> ball[i];
		}
 
		bitset<10> direction;
		int all = 1024;
		while (all-- > 0)
		{
			direction = static_cast<bitset<10> >(all);
			bool perfect = true;
			int left = 0;
			int right = 0;
			for (int i = 0; i < 10; ++i)
			{
				if (direction[i])
				{
					if (ball[i] > left)
					{
						left = ball[i];
					}
					else
					{
						perfect = false;
						break;
					}
				}
				else
				{
					if (ball[i] > right)
					{
						right = ball[i];
					}
					else
					{
						perfect = false;
						break;
					}
				}
			}
			if (perfect)
			{
				break;
			}
		}
	
		if (all >= 0)
		{
			cout << "YES" << endl;
		}
		else
		{
			cout << "NO" << endl;
		}
	}
 
	return 0;
}

Measured memory_bytes: 2976
#!/usr/bin/env python3

import math

n, d = map(int, input().split())

zahyo = [tuple(map(int, input().split())) for _ in range(n)]

ans = 0
for p, q in zahyo:
    dis = math.sqrt(p ** 2 + q ** 2)
    if dis <= d:
        ans += 1

print(ans)


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

long long gcd(long long x, long long y)
{
    if (y == 0)
        return x;
    return gcd(y, x % y);
}

long long lcm(long long x, long long y)
{
    if (x == 0 || y == 0)
        return 0;
    return x / gcd(x, y) * y;
}

int main()
{
    int A, B, C;
    cin >> A >> B >> C;
    if (A == B)
        cout << C << endl;
    else if (B == C)
        cout << A << endl;
    else
        cout << B << endl;
}

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

int main(int argc, char **argv) {
        int n=0;
        std::string s;
        std::cin >> n;
        std::cin >> s;

        std::string **ss = new std::string* [4];
        for (int i = 0 ; i < 4 ; i++) {
                *(ss+i) = new std::string(n+2,'S');
        }
        ss[1][0][1] = 'W';
        ss[2][0][0] = 'W';
        ss[3][0][0] = 'W';
        ss[3][0][1] = 'W';
        for (int i = 0; i < n; i++) {
                if (s[i] == 'o') {
                        for (int j = 0; j < 4; j++) {
                                if(ss[j][0][i+1] == 'S') {
                                        if (ss[j][0][i] == 'S') {
                                                ss[j][0][i+2] = 'S';
                                        } else {
                                                ss[j][0][i+2] = 'W';
                                        }
                                } else {
                                        if(ss[j][0][i] == 'W') {
                                                ss[j][0][i+2] = 'S';
                                        } else {
                                                ss[j][0][i+2] = 'W';
                                        }
                                }
                        }
                } else {
                        for (int j = 0; j < 4; j++) {
                                if(ss[j][0][i+1] == 'S') {
                                        if (ss[j][0][i] == 'W') {
                                                ss[j][0][i+2] = 'S';
                                        } else {
                                                ss[j][0][i+2] = 'W';
                                        }
                                } else {
                                        if(ss[j][0][i] == 'S') {
                                                ss[j][0][i+2] = 'S';
                                        } else {
                                                ss[j][0][i+2] = 'W';
                                        }
                                }
                        }
                }
        }
        for (int j = 0; j < 4; j++) {
                if (ss[j][0][0] == ss[j][0][n]) {
                        if (ss[j][0][1] == ss[j][0][n+1]) {
                                std::cout << ss[j][0].substr(1,n) << std::endl;
                                return 0;
                        }
                }
        }
        std::cout << "-1" << std::endl;

        return 0;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	int pn = 1;
	if (ci - cn + 16 > cm) {
		if ((ct = getcha()) == '-') { pn = -1; ct = getcha(); }
		A = ct - '0';
		while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';;
		return pn * A;
	}
	else {
		if ((ct = *ci++) == '-') { pn = -1; ct = *ci++; }
		A = ct - '0';
		while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';;
		return pn * A;
	}
}

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


	int N = getint();
	int S[100000];
	rep(i, N) S[i] = getint();

	ll kotae = 0;
	rep1(ab, N / 2 - 1) {
		int n = ab;
		ll kari = 0;
		if ((N - 1) % n) {
			while (n + ab < N - 1) {
				kotae = max(kotae, (kari += S[n] + S[N - 1 - n]));
				n += ab;
			}
		}
		else {
			while (n + n < N - 1) {
				kotae = max(kotae, (kari += S[n] + S[N - 1 - n]));
				n += ab;
			}
		}
	}
	printf("%lld", kotae);

	Would you please return 0;
}

Measured memory_bytes: 640
#!/usr/bin/env python3

import sys
sys.setrecursionlimit(300000)


def solve(N: int, T: int, A: "List[int]", B: "List[int]"):
    max_t = T + max(A)
    dp = [-1] * (max_t + 1)
    dp[0] = 0
    p = []
    for i in range(N):
        p.append((A[i], B[i]))
    p.sort()
    for i in range(N):
        for t in range(T - 1, -1, -1):
            if dp[t] >= 0:
                dp[t + p[i][0]] = max(dp[t + p[i][0]], dp[t] + p[i][1])
    ret = 0
    for v in dp:
        ret = max(ret, v)
    print(ret)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    T = int(next(tokens))  # type: int
    A = [int()] * (N)  # type: "List[int]"
    B = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
    solve(N, T, A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 43484
#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  int k;
  cin >> s >> k;
  vector<string> vec;  
  for(int i = 0; i < s.size(); i++){
    for(int j = i + 1; j <= min((int)s.size(), i + k); j++){
      vec.push_back(s.substr(i,j - i));
    }
  }
  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
  cout << vec[k - 1] << endl;
  return 0;
}


Measured memory_bytes: 1660
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    int n;
    cin>>n;
    ll ans=1;
    for(int i=2; i<=n; ++i){
        ans*=i;
        ans%=1000000007;
    }
    cout<<ans<<endl;
}


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

void Main()
{
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    REP(i, n)
    cin >> h[i];

    int count = 0;
    for (int i = 0; i < h.size(); i++)
    {
        if (h[i] >= k)
        {
            count++;
        }
    }
    cout << count << endl;
}

int main()
{
    std::cout << std::fixed << std::setprecision(15);
    Main();
}

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

int main() {
  string s, t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  reverse(t.begin(), t.end());

  if (s < t) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


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

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

    int pattern = 0;
//    for (int a=0; a<=A; ++a) {
//        int resA = X - 500 * a;
//        for (int b=0; b<=B; ++b) {
//            int resB = resA - 100 * b;
//            if ((resB % 50) == 0) {
//                int c = resB / 50;
//                if ((c >= 0) && (c <= C)) ++pattern;
//            }
//        }
//    }
    for (int a=0; a<=A; ++a) {
        for (int b=0; b<=B; ++b) {
            for (int c=0; c<=C; ++c) {
                int v = 500 * a + 100 * b + 50 * c;
                if (v == X) ++pattern;
            }
        }
    }
    cout << pattern << endl;
}


Measured memory_bytes: 3548
#include <iostream>
    #include <string>
    using namespace std;
    bool can=false;
    int max_pos=-1;
    string s,t;
    bool check(int start_pos) {
    	if (s.size() - start_pos < t.size())
    		return false;
    	for (int i = start_pos; i < start_pos + t.size(); ++i) {
    		if (s[i] == t[i - start_pos] || s[i] == '?') 
    			continue;
    		else
    			return false;
    	}
    	return true;
    }
    int main() 
	{
    	cin >> s >> t;
    	for (int i = 0; i < (int) s.size(); ++i)
		{
    		if (check(i))
			{
    			max_pos = i;
    			can = true;
    		}
    	}
    	if (!can)
		{
    		cout << "UNRESTORABLE" << endl;
    		return 0;
    	}
    	for (int i = max_pos; i < max_pos + (int) t.size(); ++i)
		{
    		s[i] = t[i - max_pos];
    	}
    	for (int i = 0; i < (int) s.size(); ++i)
		{
    		if (s[i] == '?')
    		{
    			s[i] = 'a';
    		}
    	}
    	cout<<s<<endl;
    	return 0;
    }

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

//#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

#define int long long
using namespace std;
const int INF = 2e9;
const int MOD = 1e9 + 7;
const int MB = 31;

void solve() {
	int n;
	cin >> n;
	set<int> st;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		st.insert(x);
	}
	cout << (st.size() == n ? "YES" : "NO");
}
signed main() {
	/*
	freopen("search.in", "r", stdin);
	freopen("search.out", "w", stdout);
	*/
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout << fixed;
	cout.precision(12);
	solve();
}

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

#define ipr pair<int, int>
#define pb push_back
#define ff first
#define ss second
#define fr(i, j, k) for (int i = j; i < k; i++)
#define rf(i, j, k) for (int i = j; i >= k; i--)
#define ll unsigned long long
#define int long long
#define ld long double
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define mp make_pair
#define cnt_ones(x) __builtin_popcountll(x)

#define IOS                           \
    std::ios::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);

const int Maxn = (int)1e6 + 1;
const ld pi = acos(-1);
const int mod = (int)1e9 + 7;
const int inf = (int)1e18;

template <class T>
ostream &operator<<(ostream &out, vector<T> &A) {
    fr(i, 0, (int)A.size()) out << A[i] << " ";
    return out;
}

vector<int> arr(Maxn, 1);

void sieve(){
    arr[0] = 0;
    for(int i=2;i<Maxn;i++){
        for(int j=i;j<Maxn;j+=i){
            arr[j]++;
        }
    }
    fr(i,1,Maxn)
        arr[i] += arr[i-1];
}
int32_t main() {
    IOS int Q = 1;
    // cin >> Q;
    sieve();
    while (Q--) {
        int n;  cin>>n;
        cout << arr[n-1] << endl;
    }
    return 0;
}


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

using namespace std;

using ll = long long;

constexpr char newl = '\n';

double dp[301][301][301];

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

    int n;
    cin >> n;

    int sum = 0;
    array<int, 4> cnt{};
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        ++cnt[a];
    }

    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= n; j++) {
            for (int k = 0; k <= n; k++) {
                int rest = i + j + k;
                if (rest == 0) continue;
                dp[i][j][k] = n;
                if (k > 0) dp[i][j][k] += dp[i][j][k - 1] * k;
                if (j > 0 && k < n) dp[i][j][k] += dp[i][j - 1][k + 1] * j;
                if (i > 0 && j < n) dp[i][j][k] += dp[i - 1][j + 1][k] * i; 
                dp[i][j][k] /= rest;
            }
        }
    }
    cout << fixed << setprecision(15) << dp[cnt[3]][cnt[2]][cnt[1]] << newl;
    return 0;
}

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



int main()
{
    string a;int t=0;
	cin>>a;
	for(int i=0;i<3;i++){
		if(a[i]=='A'){
			t++;
		}
	} 
	if(t==0||t==3){
		cout<<"No"<<endl;
	}else{
		cout<<"Yes"<<endl;
	}
}

Measured memory_bytes: 256
import numpy as np


def main():
    n = int(input())
    As = list(map(int, input().split()))
    mod = 10**9 + 7

    As_sum = np.sum(As) % mod
    ans = 0
    for i in range(n):
        As_sum -= As[i]
        As_sum %= mod
        ans += As_sum * As[i]
        ans %= mod
    ans %= mod
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 49972
S = input()

now = S[0]
i = 1
mozi_list = [now]
num = 1
while i < len(S):
	#print(i, mozi_list)
	if i != len(S) - 1:
		if len(now) == 1:
			if now != S[i]:
				now = S[i]
				mozi_list.append(now)
				i += 1
				num += 1
			else:
				now = S[i:i + 2]
				mozi_list.append(now)
				i += 2
				num += 1
		elif len(now) == 2:
			now = S[i]
			mozi_list.append(now)
			i += 1
			num += 1
	else:
		if len(now) == 2:
			now = S[i]
			mozi_list.append(now)
			i += 1
			num += 1
		elif now != S[i]:
			now = S[i]
			mozi_list.append(now)
			i += 1
			num += 1
		else:
			i += 1

print(num)




Measured memory_bytes: 55372
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<queue>
#include<algorithm>
using namespace std;
#define vi vector<int>
int read()
{
	char c=getchar();
	int res=0;
	while(c<'0'||c>'9') c=getchar();
	while(c>='0'&&c<='9') res=(res<<1)+(res<<3)+(c^48),c=getchar();
	return res;
}
int n,m,d[100005],maxd=0,maxnum=0,vis[100005],A,B;
vi G[100005];
void dfs(int x)
{
	vis[x]=1;
	int sz=G[x].size();
	for(int i=0;i<sz;i++)
	{
		int y=G[x][i];
		if(vis[y]==2) A?B=y:A=y;
		else if(!vis[y]) dfs(y);
	}
}
int main()
{
	n=read(),m=read();
	for(int i=1;i<=m;i++)
	{
		int x=read(),y=read();
		G[x].push_back(y);G[y].push_back(x);
		d[x]++,d[y]++;
	}
	for(int i=1;i<=n;i++)
	{
		if(d[i]&1)
		{
			puts("No");
			return 0;
		}
		if(d[i]>maxd) maxd=d[i],maxnum=1;
		else if(d[i]==maxd) maxnum++;
	}
	if(maxd>=6){puts("Yes");return 0;}
	else if(maxd<=2||maxnum==1){puts("No");return 0;}
	else if(maxnum>2){puts("Yes");return 0;}
	else
	{
		for(int i=1;i<=n;i++) if(d[i]==maxd) vis[i]=2;
		int sum=0;
		for(int i=1;i<=n;i++)
		{
			if(!vis[i])
			{
				A=0,B=0;
				dfs(i);
				if(A==B) sum++;
			}
		}
		if(sum) puts("Yes");
		else puts("No");
	}
}

Measured memory_bytes: 10936
#include<iostream>
#include<vector>
#include<algorithm>
//#include<function>

using namespace std;

int main()
{
	int i;
	int a;
	vector<int> num;
	
	for(i=0;i<10;i++)
	{
		cin >> a ;
		num.push_back(a);
	}
	
	sort(num.begin(),num.end());
	
	for(i=9;i>6;i--)
		cout << num[i] << endl;
}

Measured memory_bytes: 0
N = int(input())
blue = []
for i in range(N):
  blue.append(input())
M = int(input())
red = []
for i in range(M):
  red.append(input())
ans = 0
for i in range(N):
  count = 0
  for j in range(N):
    if blue[j] == blue[i]:
      count += 1
  for j in range(M):
    if red[j] == blue[i]:
      count -= 1
  if count > ans:
    ans = count
print(ans)

Measured memory_bytes: 9092
using System;
using System.Linq;

class AtCoderCS {
    static void Main(string[] args) {
        int[] NM = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
        int N = NM[0], M = NM[1];
        int[] H = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();

        bool[] table = Enumerable.Repeat(true, N).ToArray();
        for(int i = 0; i < M; i++) {
            int[] AB = Console.ReadLine().Split(' ').Select(i => int.Parse(i) - 1).ToArray();
            int A = AB[0], B = AB[1];
            if (H[A] == H[B]) {
                table[A] = false;
                table[B] = false;
            }
            else if(H[A] < H[B])
                table[A] = false;
            else
                table[B] = false;
        }

        Console.WriteLine(table.Count(i => i));
    }
}

Measured memory_bytes: 49500
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <tuple>
template <typename T> constexpr T my_abs(const T &x) { return x < 0 ? -x : x; }
using ll = long long;
int main()
{
	// freopen("yahoo2019-C.in", "r", stdin);
	int k, a, b;
	scanf("%d%d%d", &k, &a, &b);
	ll ans = k + 1;
	if (a <= b && a <= k)
	{
		int rem = k - (a - 1);
		ans = std::max(ans, a + (ll)rem / 2 * (b - a) + rem % 2);
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 128
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;


public class Main {
	
	public static void main(String[] args) throws IOException {
		Main m = new Main();
		m.input();
		m.solve();
		m.output();
	}
	
//	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	InputUtil in = new InputUtil();
	PrintWriter out = new PrintWriter(System.out);

	int N = 0;
	int[] A = null;
	int ans = 1;
	
	public void input() throws IOException {
		N = in.nextInt();
		A = in.nextInt(new int[N]);
	}

	public void solve() throws IOException {
		int a = 1;
		int k = 1;
		for(int i=0; i<N; i++){
			a *= 3;
			if(A[i]%2 == 0)
				k *= 2;
		}
		ans = a-k;
	}
	
	
	public void output() {
		out.println(ans);
		out.flush();
		
	}
}



class InputUtil {
	//Static Fields
	private static final int BUFSIZ = 100000;
	
	//Fields
	protected InputStream in;
	private byte[] buf = null;
	private int ptr = 0;
	private int max = -1;
	private DataInputStream dis = null;
	//Constructors
	public InputUtil() {this(System.in,BUFSIZ);}
	public InputUtil(InputStream in, int bufsiz) {
		initBuf(bufsiz);
		initIn(in);
	}
	
	//Methods
	//Initializer
	protected void initIn(InputStream in) {dis = new DataInputStream(this.in = in);}
	protected void initBuf(int bufsiz) {buf = new byte[bufsiz];}
	
	//buffer operation
	private void next() throws IOException {ptr++; readBuf();}
	private void readBuf() throws IOException {
		if(ptr >= max && dis.available()>0) {
			if(max>0) Arrays.fill(buf,0,max,(byte)0);
			max = dis.read(buf);
			ptr = 0;
		}
	}
	
	//Number Input Reader/Parser
	private boolean isNum(byte b) {return '0' <= b && b <= '9'; }
	private boolean isMinus(byte b) {return b=='-'; }

	private int _nextInt() throws IOException {
		int sign = 1;
		int res = 0;
		byte c;
		while (!isNum(c=buf[ptr]) && !isMinus(c)) 
			next();
		if (isMinus(buf[ptr])) {
			sign = -1;
			next();
		}
		while (isNum(c=buf[ptr])) {
			res *= 10;
			res += c - '0' ;
			next();
		}
		next();
		return sign * res;
	}
	
	public int nextInt() throws IOException {
		readBuf();
		return _nextInt();
	}

	public int[] nextInt(int[] result) throws IOException {
		readBuf();
		for(int i=0; i<result.length; i++) {
			result[i] = _nextInt();
		}
		return result;
	}
	
	//Close 
	public void close() throws IOException {
		if(!this.in.equals(System.in)) 
			this.in.close();
	}

}


Measured memory_bytes: 22996
#include <iostream>

using namespace std;

int m[124][124] = {{}};
int p[124] = {};
int n;

void chain(){
  for(int i = 0 ;i < n;i++) m[i][i] = 0;
  for(int l = 2;l <= n;l++){
    for(int i = 1 ;i <= n - l + 1;i++){
      int j = i + l - 1;
      m[i][j] = (1 << 21);
      for(int k = i;k <= j;k++){
        m[i][j] = min(m[i][j],m[i][k] + m[k + 1][j] + p[i - 1] *p[k] *p[j]);
      }
    }
  }

  cout << m[1][n] << endl;

}


int main(){

  cin >> n;

  for(int i = 1;i <= n;i++){
    cin >> p[i - 1] >> p[i];
  }

  chain();

}

Measured memory_bytes: 3080
n = int(input())
x = [list(map(int, input().split())) for _ in range(n)]
d = 0

for i in range(n - 1):
    for j in range(i + 1, n):
        d += ((x[i][0] - x[j][0]) ** 2 + (x[i][1] - x[j][1]) ** 2) ** 0.5
  
print(2 * d / n)


Measured memory_bytes: 3060
#include<cstdio>
#include<iostream>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<list>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<iomanip>
#include<fstream>
#include<ctime>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;
const int N = 100005;

int n, m, k, tab[N], a, b, vis[N], aktInd[N], i, miss;
set<ii> ss;
ii top;
VI graf[N], wek[N];
LL res;

void dfs(int w) {
	vis[w] = k;
	for (int i=0;i<graf[w].size();i++) if (vis[graf[w][i]] == -1) dfs(graf[w][i]);
}

int main() {
scanf("%d %d", &n, &m);
res = 0;
for (i=0;i<n;i++) {
	graf[i].resize(0);
	vis[i] = -1;
	scanf("%d", &tab[i]);
	res += tab[i];
}
for (i=0;i<m;i++) {
	scanf("%d %d", &a, &b);
	graf[a].pb(b);
	graf[b].pb(a);
}
k = 0;
for (i=0;i<n;i++) if (vis[i] == -1) {
	k++;
	dfs(i);
}
if (k * 2  - 2 > n) {
	printf("Impossible\n");
	return 0;
}
if (k == 1) {
	printf("0\n");
	return 0;
}
miss = n - (k * 2 - 2);
for (i=1;i<=k;i++) wek[i].resize(0);
for (i=0;i<n;i++) wek[vis[i]].pb(tab[i]);
ss.clear();
for (i=1;i<=k;i++) if (wek[i].size() > 1) {
	sort(wek[i].begin(), wek[i].end());
	ss.insert(ii(-wek[i][wek[i].size()-1], i));
	aktInd[i] = wek[i].size() - 1;
}
while (miss > 0) {
	top = *(ss.begin());
	ss.erase(top);
	miss--;
	res += top.first;
	if (aktInd[top.second] > 1) {
		aktInd[top.second]--;
		ss.insert(ii(-wek[top.second][aktInd[top.second]], top.second));
	}
}
printf("%lld\n", res);

return 0;
}



Measured memory_bytes: 10240