akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>

#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007

using namespace std;

struct UnionFind{
  vector<int> par,num;

  UnionFind(int N) : par(N),num(N){
    for(int i=0;i<N;i++){
      par[i] = i;
      num[i] = 1;
    }
  }

  int root(int x){
    if(par[x] == x) return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y){
    int rx = root(x);
    int ry = root(y);
    if(rx == ry) return;
    par[rx] = ry;
    num[ry] = num[ry]+num[rx]; 
  }

  int get_num(int x){
    int rx = root(x);
    return num[rx];
  }

  bool same(int x, int y){
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
};


int main(void){
  int n;
  cin >> n;
  if(n%10 == 2 || n%10 == 4 || n%10 == 5 || n%10 == 7 || n%10 == 9){
    cout << "hon" << endl;
  }
  else if(n%10 == 3){
    cout << "bon" << endl;
  }
  else{
    cout << "pon" << endl;
  }
  return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define flash ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define lb lower_bound
#define ub upper_bound
#define endl '\n'
#define rep(n) for(ll j=1;j<=n;j++)
#define loope(i,a,b) for(ll i=a;i<=b;i++)
#define loopne(i,a,b) for(ll i=a;i<b;i++)

ll mod=1e9+7;
ll dp[101][100005];
int main()
{
    ll n;
    cin>>n;
    ll k;
    cin>>k;
    ll candy[n];
    rep(n)
    cin>>candy[j];
    for(ll i=1;i<=k;i++)
    {
        dp[0][i]=0;
    }
    dp[0][0]=1;
    for(ll i=1;i<=n;i++)
    {
        ll sum[k+1];
        sum[0]=dp[i-1][0];
        for(ll j=1;j<=k;j++)
        {
            sum[j]=((dp[i-1][j])%mod+sum[j-1]%mod+mod)%mod;
        }
        for(ll j=0;j<=k;j++)
        { 
            ll ans=sum[j];
            ll x=j-candy[i]-1;
            if(x>=0)
            {
               ans=(ans-sum[x]+mod)%mod;
            }
            dp[i][j]=ans%mod;
        }
    }
    cout<<dp[n][k];
    return 0;
    
}

Measured memory_bytes: 79872
#include <iostream>
#include <vector>
#include <map>
using namespace std;
using ll = long long;

template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}

template <class T>
map<T, T> prime_factorize(T n) {
    map<T, T> res;
    for (T i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            res[i]++;
            n /= i;
        }
    }
    if (n != 1)
        res[n] = 1;
    return res;
}

int main() {
    ll a, b;
    cin >> a >> b;
    ll s = GCD(a, b);
    auto m = prime_factorize(s);
    cout << m.size() + 1 << endl;
}

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

int main() 
{
  int N = 0, i = 0, ans = 0;
  int A[201] = {0};
  cin >> N;
  for (i = 0; i < N; i++) {
    cin >> A[i];
  }
  
  while (1) {
    for (i = 0; i < N; i++) {
      if (A[i] & 1) {
        break;
      }
      A[i] = (A[i] >> 1);
    }
    if (i == N) {
      ans++;
      continue;
    } else {
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <sys/time.h>

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <utility>
#include <cctype>

using namespace std;

using ll = long long;
using P = pair<int, int>;
using VP = pair<int, pair<int, int> > ;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mkp(a, b) make_pair(a, b)
ll mod = 1000000007LL;

const int maxE = 300010;
int parent[maxE];
int parent_rank[maxE];


int main() {
	int n;
	cin >> n;
	ll a[n];
	rep(i, n) {
		cin >> a[i];
	}
	ll ans = 0;
	ll sum = 0;
	for(int i = n - 1; i >= 0; i--) {
		ans = (ans + sum * a[i]) % mod;
		sum = (sum + a[i]) % mod;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 4724
#include<bits/stdc++.h>
using namespace std;
const int MAXN = (int) 1e6 + 10;
const int MOD = (int) 1e9 + 7;

int n, h;

int main(){
	scanf("%d%d", &n, &h);
	int sum = 0;
	for (int i=1; i<=n; i++) {
		int x;
		scanf("%d", &x);
		if (x >= h) sum ++;
	}
	cout << sum << '\n';
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> v(n);
  for (auto& x : v) cin >> x;
  sort(v.begin(), v.end());
  int ans = 0;
  for (int i = 0; i < k; i++) ans += v[i];
  cout << ans << endl;
}

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

int main(){
    constexpr int b[10] = {1000000, 2, 5, 5, 4, 5, 6, 3, 7, 6};
    int N, M;
    cin >> N >> M;
    
    vector<int> can(M);
    for(auto&i : can)cin >> i;
    
    vector<string> dp(N + 1);
    vector<int> did(N + 1);
    did[0] = 1;
    for(int i = 0; i <= N; ++i){
        if(did[i]){
            for(auto j : can){
                if(i + b[j] <= N){
                    auto s = dp[i];
                    did[i + b[j]] = 1;
                    s.push_back('0' + j);
                    if(dp[i + b[j]].size() < s.size())dp[i + b[j]] = s;
                    else if(dp[i + b[j]].size() == s.size())dp[i + b[j]] = max(dp[i + b[j]], s);
                }
            }
        }
    }
    cout << dp[N] << endl;
}

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

ll gosencho = 5e18;

void Main()
{
  string S;
  cin >> S;
  ll K;
  cin >> K;
  for (ll i = 0; i < K; i++) {
    if (S[i] != '1') {cout << S[i] << endl; return;}
  }
  cout << 1 << endl; return;
}

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

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

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

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

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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



///////////////////////////

ll inv[MAX];

void INV() {
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
	}
}

ll iv(ll i) {
	if (i == 1) { return 1; }
	return MOD - iv(MOD%i)*(MOD / i) % MOD;
}

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

	ll p[MAX] = {};

	repn(i, N) {
		ll a = A[i];

		ll j = 2;
		while (j*j <= a) {
			if (a%j == 0) {
				ll cnt = 0;
					while (a%j == 0) {
						a /= j;
						cnt++;
					}
					p[j] = max(cnt, p[j]);
			}
			j++;
		}
		if (a != 1) { p[a]=max(p[a],1); }
	}

	ll l = 1;

	repn(i, MAX-1) {
		repn(j, p[i]) {
			l = l * i%MOD;
		}
	}

	ll ans = 0;

	repn(i, N) {
		ans += l * iv(A[i]);
		ans %= MOD;
	}

	
	cout << ans;
	
	
	system("PAUSE");

}


Measured memory_bytes: 10240
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
 
bool checkV(int newPosFirst, int newPosSecond, int m, int n) {
    return newPosFirst >= 0 &&
           newPosFirst < m && 
           newPosSecond >= 0 &&
           newPosSecond < n;
}
     
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0); 
    cout.tie(0);
    
    ll n, w; cin >> n >> w;
    vector<pair<ll,ll>> v(1);
    vector<vector<ll>> dp(n+1, vector<ll>(w+1, 0));
    for (int i = 0; i < n; i++) {
        int a, b; cin >> a >> b;
        v.emplace_back(a, b);
    }

    ll maxValue = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= w; j++) {
            if (j-v[i].first >= 0) {
                dp[i][j] = max(dp[i-1][j-v[i].first]+v[i].second, dp[i][j]);
            }
            dp[i][j] = max(dp[i][j], dp[i-1][j]);
            maxValue = max(maxValue, dp[i][j]);
        }
    }

    cout << maxValue << endl;
    return 0;
}

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

const int MAX = 1000000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}



int main() {
  int n,k;

  cin >>n>>k;
  COMinit();
  for(int i=1;i<=k;i++){
    cout<<COM((n-k+1),i)%MOD*COM(k-1,i-1)%MOD<<endl;
  }

}


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

using ll=long long;
using namespace std;

#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vll(v) sort((v).begin(), (v).end(), greater<long long>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

ll gcd(ll a, ll b) { return b?gcd(b, a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a, b)*b;}

const int IINF=(1<<30);
const ll LLINF = 1LL<<60;

char BigAlphaToSmall(char a){
    if (a >= 65 && a <= 90){
        return a + 32;
    }
    return a;
}

char SmallAlphaToBig(char a){
    if (a >= 97 && a <= 122){
        return a - 32;
    }
    return a;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    int n, q;
    cin >> n >> q;
    vector<list<int>> hoge(n);
    int a, b, c;
    for (int i = 0; i < q; i++){
        cin >> a;
        if(a == 0){
            cin >> b >> c;
            hoge[b].push_back(c);
            continue;
        }

        if(a == 1){
            cin >> b;
            // if(hoge[b].empty()) continue;
            for (auto it = hoge[b].begin(); it != hoge[b].end(); it++){
                if(it == hoge[b].begin()){
                    cout << *it;
                    continue;
                }
                cout << " " << *it;
            }
            cout << endl;
            continue;
        }

        if(a == 2){
            cin >> b >> c;
            hoge[c].splice(hoge[c].end(), hoge[b]);
            continue;
        }
    }
}


Measured memory_bytes: 18788
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
const int INF = 1e8;
using namespace std;
 
class Edge{
    public:
        int to, com, cost;
        Edge(int to, int com, int cost) : to(to) ,com(com) ,cost(cost) {}
};
 
class Node{
    public:
        int dis;
        bool isUsed;
        Node(){
            this->dis = INF;
            this->isUsed = 0;
        }
};
 
map<int, vector<Edge>> g[200001];
typedef pair<int,pair<int, int>> ppi;
map<int, Node> node[200001];
 
int dijkstra(int start, int n){
    priority_queue<ppi, vector<ppi>, greater<ppi>> q;
 
    q.push(make_pair(0, make_pair(start, -1)));
    node[start][-1].dis = 0;
 
    ppi u;
    while(not q.empty()){
        u = q.top(); q.pop();
        int cur = u.second.first;
        int pre = u.second.second;
        if(node[cur][pre].isUsed) continue;
        node[cur][pre].isUsed = 1;
 
		//cout << cur << ' ' << pre << endl;
		for(auto e : g[cur][pre]){
			int to = e.to;
			int to_com = e.com;
			if(node[to][to_com].isUsed == 0){
				if(not node[to].count(to_com) || node[to][to_com].dis > node[cur][pre].dis + e.cost){
					node[to][to_com].dis = node[cur][pre].dis + e.cost;
					q.push(make_pair(node[to][to_com].dis, make_pair(to, to_com)));
				}
			}
        }
    }
 
    int mini = INF;
    for(auto it : node[n - 1]){
        mini = min(mini, it.second.dis);
    }
    return mini;
}
 
int main(){
    int n, m;
	cin >> n >> m;

	rep(i,m){
		int a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		g[a][c].emplace_back(Edge{b, c, 0}); //同じ会社間の移動コストは0
		g[b][c].emplace_back(Edge{a, c, 0}); //同じ会社間の移動コストは0
		g[a][c].emplace_back(Edge{a, -1, 0}); //乗り換える
		g[b][c].emplace_back(Edge{b, -1, 0});
		g[a][-1].emplace_back(Edge{a, c, 1}); //乗り換える
		g[b][-1].emplace_back(Edge{b, c, 1});
	}

    int ans = dijkstra(0,n);
    cout << (ans == INF ? -1 : ans) << endl;
}


Measured memory_bytes: 110388
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>
#include <iomanip>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <complex>
#include <ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

using Graph = vector<vector<ll>>;

#define ketasitei setprecision(15) //15桁表示

const ll MOD = 1000000007;

int main(void)

{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << ketasitei;

	double r;
	cin >> r;
	cout << 2.0 * r * 3.1415926535 << endl;

	return 0;
}

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

int main(){
  int A,N;
  cin>>N;
  
  int min=50;
  int count=0;
  
  for(int i=0;i<N;i++){
    count=0;
   	cin>>A ;
    while(A%2==0){
      A/=2;
      count++;
    }
    if(count<min){
      min=count; 
    }
  }
  

  cout<<min<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <cmath>
#include <iomanip>
#include <ctype.h>
#include <numeric>
#include <iterator>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi >;
using vl = vector<ll>;
using vvl = vector<vl >;
using pairi = pair<int, int>;
using pairl = pair<ll, ll>;

#define TR ","
#define TS " "
#define rep(i,N) for(ll i=0;i<(ll)N;++i)
#define rpt(i,a,b) for(ll i=a;i<(ll)b;++i)
#define all(v) v.begin(), v.end()
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

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

ll lcm(ll x, ll y) {
    return x / gcd(x, y) * y;
}

ll waz = 76543217;

void printVector(const vector<int>& vec) {
    for (int value : vec) {
        cout << value << " ";
    }
    cout << endl;
}

int main()
{
    IO;

    stack<int> S1;
    stack<pair<int, int> > S2;
    string str;
    cin >> str;
    char ch;
    int sum = 0;
    for (int i = 0; i<str.size(); i++) {
        ch = str[i];
        if (ch == '\\') S1.push(i);
        else if (ch == '/' && S1.size() > 0) {
            int j = S1.top(); S1.pop();
            sum += i - j;
            int a = i - j;
            while ( S2.size() > 0 && S2.top().first > j) {
                a += S2.top().second; S2.pop();
            }
            S2.push(make_pair(j, a));
        }
    }

    vi ans;
    while (S2.size() > 0) {
        ans.push_back(S2.top().second); S2.pop();
    }
    reverse(all(ans));
    cout << sum << endl;
    cout << ans.size();
    for (int i = 0; i < ans.size(); ++i) {
        cout << " ";
        cout << ans[i];
    }
    cout << endl;
}


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

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
// #define MOD 998244353 
#define MEM_SIZE 100010
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()


template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void solve(void)
{
  int m,k;
  cin>>m>>k;
  vector<int> res ;
  int n = pow(2,m);
  if(n  <= k || (m == 1 and k == 1))
  {
    cout<<-1<<endl;
    return;
  }
  if(k == 0)
  {
    for (int i = 0; i < n; i++)
    {
      res.push_back(i);
      res.push_back(i);
    }
    for (int i = 0; i < res.size(); i++)
    {
        if(i != 0)cout<<char(32);
        cout<<res[i];
    }
    cout<<endl;    
    return;
  }
  for (int i = 0; i <n; i++)
  {
    if(i == k)continue;
    res.push_back(i);
  }
  res.push_back(k);

  for (int i = n-1; i >= 0; i--) 
  {
    if(i == k)continue;
    res.push_back(i);
  }
  res.push_back(k);
  for (int i = 0; i < res.size(); i++)
  {
      if(i != 0)cout<<char(32);
      cout<<res[i];
  }
  cout<<endl;
  

  
  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


Measured memory_bytes: 5780
#include<stdio.h>
#include<string.h>
void show(int a[],int n)
{
    for(int i=0;i<n;i++)
    {
        if(i) putchar(' ');
        printf("%d",a[i]);
    }
}
 
void SelectionSort(int a[],int n)
{
    int i,j,min,t,count=0;
    for(i=0;i<n-1;i++)
    {
        min=i;
        for(j=i;j<n;j++)
            if(a[min]>a[j])
            {
                min=j;
            }
        t=a[min];a[min]=a[i];a[i]=t;
        if(min!=i) count++;
    }
    show(a,n);
    putchar('\n');
    printf("%d\n",count);
}
int main()
{
    int a[101];
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
        scanf("%d",&a[i]);
 
    SelectionSort(a,n);
 
}


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

#define hell 1e9


int main(){
	int h,w,m;
	cin>>h>>w>>m;
	int x[m],y[m];
	for(int i=0;i<m;i++){
		cin>>x[i]>>y[i];
	}
	int r[h],c[w];
	for(int i=0;i<h;i++){
		r[i]=0;
	}
	for(int i=0;i<w;i++){
		c[i]=0;
	}
	for(int i=0;i<m;i++){
		r[x[i]-1]++;
		c[y[i]-1]++;
	}
	int mx=0,mx1=0;
	for(int i=0;i<h;i++){
		mx=max(r[i],mx);
	}
	for(int i=0;i<w;i++){
		mx1=max(c[i],mx1);
	}
	int ans=mx+mx1;
	int p=0;
	for(int i=0;i<m;i++){
		if(ans==(r[x[i]-1]+c[y[i]-1])){
			p++;
		}
	}
	int cnt=0,cnt1=0;
	for(int i=0;i<h;i++){
		if(r[i]==mx){
			cnt++;
		}
	}
	for(int i=0;i<w;i++){
		if(c[i]==mx1){
			cnt1++;
		}
	}
	long long ll=(long long)cnt*cnt1;
	if(ll>p){
		cout<<ans;
	}
	else{
		cout<<ans-1;
	}


	return 0;
} 

Measured memory_bytes: 8320
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;
int N, K, mn;
int a[105];
int d[100005];

int main() {
    cin >> N >> K;
    for (int i = 1; i <= N; i++) {
        cin >> a[i];
        mn = min(mn, a[i]);
    }
    for (int i = 0; i < mn; i++) {
        d[i] = 0;
    }
    for (int i = mn; i <= K; i++) {
        d[i] = 0;
        for (int j = 1; j <= N; j++) {
            if (a[j] <= i && d[i - a[j]] == 0)d[i] = 1;
        }
    }
    if (d[K])cout << "First";
    else cout << "Second";
    return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <string.h>
#include <vector>
#include <tuple>

using namespace std;

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)
#define REPIT(i,x) for(auto i{(x).begin()}; i != (x).end(); i++)

#define PB push_back
#define MP make_pair
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

typedef int64_t ll;
typedef double dbl;
typedef vector<bool> Vb;
typedef vector<int> Vi;
typedef vector<ll> Vl;
typedef vector<string> Vs;
typedef vector<vector<int> > VVi;
typedef vector<vector<ll> > VVl;
typedef tuple<int, ll, int> mytup;
typedef tuple<int, int, ll> tupdata;
typedef pair<int, ll> mypair;

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

const ll linf = 1LL << 60;
multiset<ll> distances;
priority_queue<mypair, vector<mypair>, greater<mypair>> que;
vector<tupdata> operations;
int N, M;

int main() {
	cin >> N >> M;
	operations.reserve(M);
	REP(_i, M) {
		int l;
		int r;
		ll c;
		cin >> l >> r >> c;
		operations.emplace_back(tupdata(--l, --r, c));
	}
	sort(ALL(operations));

	/* que
			first : index
			second : distance
	*/
	/* operations
			first : l
			second : r
			third : c
	*/

	ll ans = linf;

	REP(i, M) {
		int l = get<0>(operations[i]);
		int r = get<1>(operations[i]);
		ll c = get<2>(operations[i]);

		while (!que.empty() && que.top().first < l) {
			auto erase_it = distances.find(que.top().second);
			distances.erase(erase_it);
			que.pop();
		}

		ll cur_min_dist;
		if (l == 0) {
			cur_min_dist = 0;
		} else {
			if (distances.empty())
				break;
			cur_min_dist = *distances.begin();
		}

		ll cur_dist = cur_min_dist + c;
		distances.insert(cur_dist);
		que.push(mypair(r, cur_dist));

		if (r == N - 1) {
			chmin(ans, cur_dist);
		}
	}

	if (ans == linf)
		cout << -1 << endl;
	else
		cout << ans << endl;
}


Measured memory_bytes: 5236
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(1000000) 
ans = 0
def main():
    N, M, Q = map(int, readline().split())
    query = []
    for _ in range(Q):
        a, b, c, d = map(int, readline().split())
        a -= 1
        b -= 1
        query.append((a, b, c, d))

    def slv(A):    
        s = 0
        for a, b, c, d in query:
            if A[b]-A[a] == c:
                s += d
        return s
    #数列Aを構築
    #数列Aを構築できたら計算処理
    from collections import deque 
    A = deque()
    def dfs(p):
        global ans
        if p == N:
            s = 0
            for a, b, c, d in query:
                if A[b]-A[a] == c:
                    s += d
            ans = max(s, ans)
            return
        if len(A) == 0:
            k = 1
        else:
            k = A[p-1]
        for i in range(k, M+1):
            A.append(i)
            dfs(p+1)
            A.pop()
    dfs(0)
    print(ans)
if __name__ == '__main__':
    main()


Measured memory_bytes: 9540
#include<iostream>

using namespace std;

int main(){
    int h,w, k;
    cin >> h >> w >> k;
    char f[h][w];
    int ans[h][w];

    int s = 0;
    bool ini = true;

    for(int i = 0; i<h; i++){
        for(int j =0 ; j <w ; j++){
            cin >> f[i][j];
            if(f[i][j] == '#' && ini){
                ini = false;
                s = i;
            }
        }
    }

    int num = 1;
    for(int i =s; i<h; i++){
        int cnt = 0;

        bool noberry = true;
        for(int j =0; j<w; j++){
            if(f[i][j] == '#') noberry = false;
        }

        if(noberry){
            for(int j =0 ;j<w; j++) ans[i][j] = ans[i-1][j];
        }
        else{
            for(int j =0 ; j<w; j++){
                char now = f[i][j];
                if(cnt == 0 && now == '#') cnt++;
                else if(now == '#'){
                    cnt++;
                    num++;
                }
                ans[i][j] = num;
            }
        }
        if(!noberry) num++;
    }
    for(int i =0; i<s; i++){
        for(int j =0 ;j<w; j++) ans[i][j] = ans[s][j];
    }

    for(int i =0; i<h; i++){
        for(int j =0 ; j<w ;j++){
            cout << ans[i][j] <<" ";
        }
        cout<< endl;
    }
    return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
    int N;cin >> N;
    int a[100];
    for (int i = 0; i < N;i++)  cin >> a[i] ;
    sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート
    int Alice = 0;int Bob = 0;
    for (int i = 0; i < N; ++i) {
        if (i % 2 == 0) {Alice += a[i];}
        else {Bob += a[i];}
    }
    cout << Alice - Bob << endl;
}

Measured memory_bytes: 3600
<?php
 
$s = trim(fgets(STDIN));
$s = explode(' ',$s);
$a = $s[0];
$b = $s[1];
 
if ($a < $b) {
  echo 'a < b' . PHP_EOL;
} elseif ($a > $b) {
  echo 'a > b' . PHP_EOL;
} else {
  echo 'a == b' . PHP_EOL;
}
exit;
 

Measured memory_bytes: 15368
#include<bits/stdc++.h>
using namespace std;int h,w,k,l,m,a,b,s,t,u,v,i,j,x[999][999];
main(){
while(1){
memset(x,0,sizeof(x));v=0;
cin>>k;if(!k){break;}
cin>>w>>h;
for(i=0;i<k;i++){cin>>a>>b;x[a][b]=1;}
cin>>s>>t;
for(i=1;i<=w;i++){
for(j=1;j<=h;j++){
u=0;
for(l=0;l<s;l++){
for(m=0;m<t;m++){
if(x[i+l][j+m]){
u++;
}
}
}
v=max(v,u);
}
}
cout<<v<<endl;
}
}

Measured memory_bytes: 5064
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

LL k;

LL calc(LL x){
    string s = to_string(x + 1);
    vector<pair<double, LL>> v;
    for(int i = (int)s.size() - 1;i >= 0;i--){
        LL a = 0,b = 1, c;
        REP(j, i){
            a *= 10;
            a += s[j] - '0';
        }
        for(int j = i;j < (int)s.size(); j++){
            a *= 10;
            b *= 10;
        }
        b /= 10;
        c = b - 1;
        for(int j = s[i] - '0'; j <= 9;j++){
            LL num = a + j * b + c;
            v.emplace_back(make_pair((double)num/ d_sum(num), num));
        }
    }
    sort(ALL(v));
    return v[0].second;
}

int main(){
    INIT;
    cin >> k;
    LL num = 0;
    while(k > 0){
        num = calc(num);
        cout << num << endl;
        k--;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    long long n,d,sum=0;
    cin>>n>>d;
    for(int i=0;i<n;i++){
        long long x,y;
        cin>>x>>y;
        if(x*x+y*y<=d*d)
            sum++;
    }
    cout<<sum<<endl;
}



Measured memory_bytes: 3632
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
const int INF = 1000000000;
const int MOD = 1000000009;

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	map<ll,ll> cnt;

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

	ll sum = 0;
	for(auto p:cnt)sum += p.second * (p.second - 1) / 2;

	for(int i = 0;i < n;i++){
		cout << sum - (cnt[a[i]] - 1) << endl;
	}
}


Measured memory_bytes: 11776
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <math.h>

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vc = vector<char>;
using vvc = vector<vc>;
template<class T> using hset = unordered_set<T>;
template<class Key, class T> using hmap = unordered_map<Key, T>;

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

int main() {
    int n, min;
    vi a;
    while (cin >> n) {
        if (n == 0) break;

        min = 1e9;
        a.resize(n);
        for (int i = 0; i < n; i++) cin >> a[i];

        sort(a.begin(), a.end());
        for (int i = 1; i < n; i++) {
            min = (a[i] - a[i-1] < min) ? a[i] - a[i-1] : min;
        }

        cout << min << endl;
    }

    return 0;
}

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

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

const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}

ll minll(ll a, ll b){
    if(a >= b)  return b;
    else    return a;
}

ll maxll(ll a, ll b){
    if(a >= b)  return a;
    else    return b;
}

ll n;
const int SIZE = 2e5+10;
ll a[SIZE];
ll cou;

int main(){
    cin >> n;
    ll min_num = LL_INF;
    ll ans = 0;

    for(int i = 0; i < n; i++){
        cin >> a[i];
        if(a[i] < 0) ++cou;
        ans += abs(a[i]);
        min_num = min(abs(a[i]),min_num);
    }
    if(cou % 2 != 0){
        ans -= 2*min_num;
    }

    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(void){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(15);

    string s,t;
    int ans=0;
    cin>>s>>t;
    for(int i=0; i<s.length(); i++){
        if(s[i]!=t[i]){
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3796
n,m=[int(x) for x in input().split()]
s=[]
for i in range(m):
  k=[int(x) for x in input().split()]
  s.append(k)
p=[int(x) for x in input().split()]

import itertools
l=[]
a=itertools.product(range(2),repeat=n)
for i in a:
  l.append(i)

ans=0
for i in range(2**n):
  ok=[]
  for j in range(m):
    on=0
    for t in range(1,s[j][0]+1):
      e=s[j][t]
      if l[i][e-1]==1:
        on+=1
    if on%2!=p[j]:
      ok.append(False)
  if False not in ok:
    ans+=1

print(ans)

Measured memory_bytes: 9284
import java.util.*;
public class Main{
  public static void main(String[] args)
  {
    Scanner input = new Scanner(System.in);
    int sum = 0;
    for(int i=1;i<=3;i++)
    {
      int a = input.nextInt();
      sum+=a;
    }
    if(sum>=22)
      System.out.println("bust");
    else
      System.out.println("win");
  }
}


Measured memory_bytes: 21716
import java.util.*;

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

      int A = 0;
      for(int i=0; i<M; i++){
		A += sc.nextInt();
      } 
 		if(N>=A){
          System.out.println(N-A);
       }else{
         System.out.println("-1");
    }
}
}

Measured memory_bytes: 46088
#include <iostream>
#include <map>
using namespace std;
int main() {
    int n;
    cin >> n;
    map<int, int> mp;
    for (int i=0; i<n; i++) {
        int a;
        cin >> a;
        mp[a]++;
    }
    int q;
    cin >> q;
    long long result, prevresult = 0;
    for (auto itr=mp.begin(); itr!=mp.end(); itr++) {
        prevresult += itr->first * itr->second;
    }
    for (int i=0; i<q; i++) {
        int b, c;
        cin >> b >> c;
        int tmp = mp[b];
        mp[c] += tmp;
        mp.erase(b);
        result = prevresult + (c-b)*tmp;
        cout << result << endl;
        prevresult = result;        
    }
}

Measured memory_bytes: 6564
#include<cstdio>
using namespace std;
int main()
{
	int n,m,x;
	scanf("%d %d %d",&n,&m,&x);
	int i,a,num = 0,num1 = 0;
	for(i = 0;i < m; i++)
	{
		scanf("%d",&a);
		if(a > 0 && a < x)
			num++;
		else if(a > x && a < n)
			num1++;
	}
	int min = num < num1 ? num : num1;
	printf("%d\n",min);
	return 0;
}

Measured memory_bytes: 128
A, B, K = map(int, input().split())

if K > (B - A) // 2:
    for i in range(A, B + 1):
        print(i)
else:
    for i in range(A, A + K):
        print(i)
    for i in range(B - K + 1, B + 1):
        print(i)

Measured memory_bytes: 9104
#include<bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

	void Solve() {
		UL P; cin >> P;
		vector<UL> A(P); rep(i, P) cin >> A[i];
		if (P == 2) { cout << A[0] << " " << (A[0] ^ A[1]) << endl; return; }
		UL R;
		for (UL r = 2; r < P; r++) {
			UL tmp = 1;
			rep(i, P - 1) {
				tmp *= r; tmp %= P;
				if (tmp == 1) { tmp = i + 1; break; }
			}
			if (tmp == P - 1) { R = r; break; }
		}
		vector<UL> Q(P); Q[0] = 1;
		rep(i, P - 1) Q[i + 1] = Q[i] * R % P;
		vector<UL> F(P);
		rep(i, P - 1) F[Q[i]] = i;
		reverse(Q.begin(), Q.end());

		vector<UL> B(P); B[0] = A[0];
		for (UL i = 1; i < P; i++) A[i] = (A[i] + P - A[0]) % P;

		for (UL i = 1; i < P; i++) {
			for (UL j = 1; j < P; j++) {
				B[i] += A[j] * Q[F[j] * i % (P - 1)];
				B[i] %= P;
			}
			B[i] = B[i] * (P - 1) % P;
		}
		rep(i, P) { if (i) cout << " "; cout << B[i]; }
		cout << endl;

		/*
		rep(i, P) {
			vector<UL> X(P); X[0] = 1;
			rep(j, P - 1) X[j + 1] = X[j] * i % P;
			UL ans = 0;
			rep(j, P) ans += B[j] * X[j] % P;
			ans %= P;
			cout << ans << " ";
		} cout << endl;
		*/
	}

	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    cout << fixed << setprecision(10);
    int n;
    cin >> n;
    cout << n + n*n + n*n*n << endl;
    return 0;
}

Measured memory_bytes: 3572
#include <iostream>

using namespace std;

int main()
{
  int j = 0;
  int data[10000];
  
  while(1)
  {
      cin >> data[j];
      if(data[j] == 0)
      {
          break;
      }
      j++;
  }
  for(int k = 0;k < j;k++)
  {
      cout << "Case " << k+1 << ": " << data[k] << endl; 
  }
  
  return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define inf (ll)1e9
#define d(x) cerr<<#x<<"="<<x<<endl;
#define p(x) cout<<x<<endl
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define minel(v) *min_element(all(v))
#define minind(v) distance((v).begin(), min_element(all(v)))
#define maxel(v) *max_element(all(v))
#define maxind(v) distance((v).begin(), max_element(all(v)))
typedef vector<int> vi;

string s;
int n,k,c,subsum;
vi v;
int main(void){
    cin>>n>>k>>s;
    char init = s[0];
    char now = init;
    rep(i,s.size()){
        if(now != s[i]){
            v.pb(c);
            now=s[i];
            c=0;
        }
        c++;
    }
    v.pb(c);
    int i=0;
    for(c=0;c<k;){
        subsum+=v[i];
        if(init=='1'&&i%2==1)c++;
        else if(init=='0'&&i%2==0)c++;
        i++;
        if(i>=v.size()-1)break;
    }
    d(subsum);
    int maxv = subsum;
    int l=0;
    d(i);
    d(v.size());
    if(i<v.size()){
        d(v[i]);
        subsum+=v[i];
        d(subsum);
        maxv = subsum;
        while(i+1<v.size()){
            if(init=='1' && l+1<v.size()){subsum-=(v[l]+v[l+1]);l+=2;}
            else {subsum-=v[l];l+=1;init='1';}
            d(v[i+1]);
            if(i+2<v.size())subsum+=(v[i+1]+v[i+2]);
            else if(i+1<v.size())subsum+=v[i+1];
            i=i+2;
            d(v.size());
            if(maxv<subsum)maxv=subsum;
        }
    }
    p(maxv);
    return 0;
}

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

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
using System;
// using System.Collections.Generic;
// using System.Linq;

class Program
{
    static void Main()
    {
        String[] arr = Console.ReadLine().Split();
        int A, B, K;
        A = int.Parse(arr[0]);
        B = int.Parse(arr[1]);
        K = int.Parse(arr[3]);
        Console.WriteLine(K <= A ? K : K <= A + B ? A : A - (K - A - B));
        return;
    }
}

Measured memory_bytes: 27528
/* 
	Author: ankrypt
*/

#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;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int
#define ff first
#define ss second
#define all(x) x.begin(), x.end() 
#define ub upper_bound
#define lb lower_bound
#define MAX_INT 100005
#define PI 3.141592653589793
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fi(a, b, c, d) for(int a = b; a < c; a += d)
#define fl(a, b, c, d) for(ll a = b; a < c; a += d)
#define fei(a, b, c, d) for(int a = b; a <= c; a += d)
#define fel(a, b, c, d) for(ll a = b; a <= c; a += d)
#define quit exit(0)
#define mem(x, a) memset(x, a, sizeof x)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pcl pair<char, ll>
#define psl pair<string, ll>


ll N, M, A, B, C;
ll arr[MAX_INT], arr1[MAX_INT], data[MAX_INT];
vector<ll> V;
unordered_map<ll, ll> mp;
set<ll> s;
string S = "";
ll cases;
ll cache[MAX_INT];

ll rec(ll ind) {
	if(ind >= N - 1) {
		return 0;
	}
	ll &ans = cache[ind];
	if(ans != -1) {
		return ans;
	}
	ans = 1e15;
	ans = min({(ans, arr[ind + 1] - arr[ind]) * A + rec(ind + 1), B + rec(ind + 1)});
	return ans;
} 

int main() {
	go;
    cin >> N >> A >> B;
    fi(i, 0, N, 1) {
    	cin >> arr[i];
    }
    mem(cache, -1);
    cout << rec(0) << "\n";
    
	return 0;
}
/*
	Powered by Buggy Plugin
*/




Measured memory_bytes: 9820
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)

const LL MOD = 1000000007;
LL combi(LL N_, LL C_) {
	const int NUM_ = 1010101;
	static LL fact[NUM_ + 1], factr[NUM_ + 1], inv[NUM_ + 1];
	if (fact[0] == 0) {
		inv[1] = fact[0] = factr[0] = 1;
		for (int i = 2; i <= NUM_; ++i) inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;
		for (int i = 1; i <= NUM_; ++i) fact[i] = fact[i - 1] * i%MOD, factr[i] = factr[i - 1] * inv[i] % MOD;
	}
	if (C_<0 || C_>N_) return 0;
	return factr[C_] * fact[N_] % MOD*factr[N_ - C_] % MOD;
}


struct INIT{
    INIT(){
        std::ios::sync_with_stdio(false);
        std::cin.tie(0);
        cout << fixed << setprecision(13);
    }
}INIT;

int x, y;

int main(){
    cin >> x >> y;
    int cnt = x + y;
    if(cnt % 3 != 0){
        cout << 0 << endl;
        return 0;
    }
    cnt /= 3;
    x -= cnt;
    y -= cnt;
    cout << combi(x + y, x) << endl;
}

Measured memory_bytes: 23936
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
  int const N  = 300001;
  vector<int> pr(N,1);
  pr[0]=pr[1]=0;
  REP(i,N)
    if (i%7!=1&&i%7!=6)
      pr[i] = 0;
  for(int i=8;i<N;i+=7)
    if (pr[i])
      for(int j=i*2;j<N;j+=i)
        pr[j]=0;
  for(int i=6;i<N;i+=7)
    if (pr[i])
      for(int j=i*2;j<N;j+=i)
        pr[j]=0;
  
  int n;
  while(cin>>n,n!=1) {
    printf("%d:",n);
    for(int i=2;i<n+1;i++) {
      if(pr[i] && n%i==0) {
        cout << " " << i;
      }
    }
    cout << endl;
  }
}

Measured memory_bytes: 2104
n = int(input())
a = list(map(int, input().split()))


count = 0

for i in range(n):
    m = i
    for j in range(i+1, n):
        if a[j] < a[m]:
            m = j
    a[i], a[m] = a[m], a[i]
    if i != m:
        count += 1

print(' '.join(map(str, a)))
print(count)



Measured memory_bytes: 5600
package main

import (
	"fmt"
	"log"
)

func main() {
	var n int
	if _, err := fmt.Scan(&n); err != nil {
		log.Fatal(err)
	}

	var args []int
	for i := 0; i < n; i++ {
		var x int
		if _, err := fmt.Scan(&x); err != nil {
			log.Fatal(err)
		}
		args = append(args, x)
	}

	var execCnt int
	for {
		var hasOdd bool
		for _, val := range args {
			if val % 2 == 1 {
				hasOdd = true
			}
		}
		if hasOdd {
			break
		}

		for i := 0; i < n; i++ {
			args[i] = args[i] / 2
		}
		execCnt++
	}

	fmt.Println(execCnt)
}


Measured memory_bytes: 512
n = int(input())
cl = list(input())

ans = cl.count('R')
r = cl.count('R')
w = 0
for i in range(n):
    if cl[i] == 'W':
        w += 1
    else:
        r -=1
    ans=min(max(r,w),ans)
print(ans)

Measured memory_bytes: 10768
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    string s; cin >> s;
    string t; cin >> t;

    int ns = s.size();
    int nt = t.size();

    bool flag_found = false;
    repr(i, ns - nt + 1){
        
        reps(j, i, i + nt){

            // cout << i << " " << j << endl;
            if(s[j] != '?' && s[j] != t[j-i]){
                break;
            }
            
            if(j == i + nt - 1){
                flag_found = true;
                break;
            }
        }

        if(flag_found){
            reps(j, i, i + nt){
                s[j] = t[j-i];
            }
            rep(j, ns){
                if(s[j] == '?'){
                    s[j] = 'a';
                }
            }
            break;
        }
    }

    if(flag_found){
        cout << s << endl;
    }
    else{
        cout << "UNRESTORABLE" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(500000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n=int(input())
a=list(map(int,input().split()))

a.sort()
dic=dict(Counter(a))

ans=0
for i in range(n):
    if dic[a[i]]==1:
        ans+=1
    if dic[a[i]]==0:
        continue
    dic[a[i]]=0
    j=1
    while 1:
        j+=1
        if j*a[i]>10**6+10:
            break
        if j*a[i] in dic:
            dic[j*a[i]]=0

print(ans)

Measured memory_bytes: 145492
def solve(N ,Xs):
    ans = float('inf')
    for i in range(100):
        _sum = sum([(x - i) ** 2 for x in Xs])
        ans = min(ans, _sum)

    print(ans)


if __name__ == '__main__':
    N = int(input())
    Xs = [int(i) for i in input().split()]
    solve(N, Xs)


Measured memory_bytes: 2940
#include<stdio.h>

int main()
{
    long int a,b,c,k;
    scanf("%ld %ld %ld %ld",&a,&b,&c,&k);
    long int out=0;
    if (k<=a) {
        out=k;
    } else {
        if (k<=a+b) {
            out=a;
        } else {
            if (k<=a+b+c) {
                out=a-(k-a-b);
            }
        }
    }
    printf("%ld",out);
    return 0;
}

Measured memory_bytes: 1736
def q2():
    _ = input()
    A = [int(i) for i in input().split(" ")]
    if 0 in A:
        print(0)
        return
    ans = 1
    max_val = pow(10, 18)
    for a in A:
        ans *= a
        if max_val < ans:
            print(-1)
            return
    print(ans)

q2()


Measured memory_bytes: 21692