akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n, S, M[22];
int dp[1<<15][22];
signed main(){
  while(cin >> n, n) {
    cin >> S;
    for(int i = 0; i < 2*n; i++) cin >> M[i];
    memset(dp, -1, sizeof(dp));
    for(int i = 0; i < 2*n; i++) dp[1][i] = 0;
    for(int i = 2; i <= S; i++){
      for(int j = 0; j < 2*n; j++) {
	bool flag = false;	
	for(int k = 1; k <= min(i, M[j]); k++) {
	  if(!dp[i-k][(j+1)%(2*n)]) flag = true;
	}
	dp[i][j] = (int)flag;
      }
    }
    cout << dp[S][0] << endl;
  }
  return 0;
}

Measured memory_bytes: 8716
#include<stdio.h>
#include<math.h>


long long solve(int x){
    int ans[] = {9, 0, 9, 0, 9, 0, 9, 0, 9, 0, 9, 0};
    long long now = -909090909090;
    now = (long long)x - now;
    int p = 11, i;
    while(now){
	ans[p] = abs(ans[p] - (now % 10));
	p--;now/=10;
    }
    char res[100];
    for(i = 0;i < 12;i++)res[i] = ans[i] + '0';
    res[12] = 0;
    sscanf(res, "%lld", &now);
    return now;
}


int main(){
    int n;
    while(scanf("%d", &n), n)
	printf("%lld\n", solve(n));
    return 0;
}

Measured memory_bytes: 608
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define endl "\n"
#define sz(u) (int)(u.size())
typedef long long ll;
using namespace std;
map<int , pair<int,int> > t;
double sum=0;
double distance(int x1,int y1,int x2,int y2){
        return (double)(sqrt((double)(pow(x1-x2,2)+pow(y1-y2,2))));
    }
void calc(string s){
        for(int i=0;i<s.size()-1;i++){
            sum+=distance(t[s[i]].F,t[s[i]].S,t[s[i+1]].F,t[s[i+1]].S);
        }
    }
void permute(string a, int l, int r)  {

    if (l == r)
        calc(a);
    else{
         for (int i = l; i <= r; i++)  {
            swap(a[l], a[i]);
            permute(a, l+1, r);
            swap(a[l], a[i]);
        }
    }
}
double fact(int n){
    double prod=1;
    for(int i=2;i<=n;i++){
        prod*=i;
    }
    return prod;
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    string ans="";
    for(int i=0;i<n;i++){
        ans+=to_string(i);
    }
    for(int i=0;i<n;i++){
        int a,b;
        cin>>a>>b;
        t[ans[i]]=MP(a,b);
    }
    permute(ans,0,n-1);
    sum/=fact(n);
    cout<<setprecision(14)<<sum<<endl;
}


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

int main(){
  int n;
  cin >> n;
  
  ll tmp;
  ll odd=0;
  ll two=0;
  ll four=0;
  for(int i=0; i<n;i++){
    cin >> tmp;
    if(tmp % 4 == 0){
      four++;
      continue;
    }
    if(tmp % 2 == 0){
      two++;
    }
    else{
      odd++;
    }
  }
  
  if(two == 0){
    if(odd <= four+1){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
  }
  else{
    if(odd <= four){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
  ll n;
  cin >> n;
  ll ans=1000000000000000000;
  for(ll i=1;i*i<=n;i++){
    if(n%i==0 && ans>i+(n/i)-2){
      ans=min(ans,(n/i)+i-2);
    }
  }
  cout << ans << endl;
  return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) (1 + (int)((a) - 1)/(int)(b))
//#define int long long

signed main(){
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    
    int ans = 0;
    reps(x,0,k)reps(y,0,k-x){
        int z = k - x - y;
        ans = max(ans, a*(1<<x) + b*(1<<y) + c*(1<<z));
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(){
  int POIUYTREWQ,QWERTYUIOP;
  cin>>POIUYTREWQ>>QWERTYUIOP;
  for(int i=0;i<365;i++){
    int N;
    cin>>N;
    cout<<N%26+1<<endl;
  }
}


Measured memory_bytes: 3624
a, b, c = map(int, input().split())
def gcd(x,y):
    p = max(x,y)
    q = min(x,y)
    while p % q != 0:
        r = p % q
        p = q
        q = r
    c = q
    return q
if c % gcd(a,b) == 0:
    print("YES")
else:
    print("NO")

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
  int N, K; cin >> N >> K;
  ll ans = 0;
  for(int k = 1; k <= N; ++k) {
    if(k - K <= 0) continue;
    ans += (k - K) * (N / k);
    ll A;
    if(K != 0) A = N % k - K + 1;
    else if(K == 0) A = N % k;
    if(A >= 0) ans += A;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3628
#include <stdio.h>

int main(){
  int h,w;
  scanf("%d%d\n",&h,&w);
  int s[h+1][w+1];
  char c;
  for(int i = 0; i < h; ++i){
    for(int j = 0; j < w; ++j){
      scanf("%c",&c);
      if(c == '.') s[i][j] = 0;
      else if(c == '#'){
        s[i][j] = i + 3000 * j + 1;
      }
    }
    s[i][w] = i + 3000 * w + 1;
    scanf("%c",&c);
  }
  for(int j = 0; j < w; ++j){
    s[h][j] = h + 3000 * j + 1;
  }
  int num[h][w];
  for(int i = 0; i < h; ++i){
    for(int j = 0; j < w; ++j) num[i][j] = 0;
  }
  int prev;
  for(int i = 0; i < h; ++i){
    prev = -1;
    for(int j = 0; j < w+1; ++j){
      if(s[i][j] > 0){
        for(int k = prev + 1; k < j; ++k){
          num[i][k] += j - prev - 1;
        }
        prev = j;
      }
    }
  }
  int answer = 1;
  for(int j = 0; j < w; ++j){
    prev = -1;
    for(int i = 0; i < h+1; ++i){
      if(s[i][j] > 0){
        for(int k = prev + 1; k < i; ++k){
          num[k][j]--;
          num[k][j] += i - prev - 1;
        }
        prev = i;
      }
    }
  }
  for(int i = 0; i < h; ++i){
    for(int j = 0; j < w; ++j){
      if(answer < num[i][j]) answer = num[i][j];
    }
  }
  printf("%d",answer);
  return 0;
}

Measured memory_bytes: 31488
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mod 1000000007
ll pow5(ll a){
	return a*a*a*a*a;
}
	
int main() {
   ll x;
cin>>x;

for(int i=-1000;i<=1000;i++)
{
	for(int j=-1000;j<=1000;j++)
	{
		if(pow5(i)-pow5(j)==x)
		{
			cout<<i<<" "<<j<<endl;
			return 0;
		}
	}
}
    return 0;
}

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

#ifdef __WIN32
#define LLFORMAT "I64"
#else
#define LLFORMAT "ll"
#endif

using namespace std;

const int maxn = 2e5 + 10, lgn = 18;

int dep[maxn], par[maxn][lgn], x[maxn][lgn], y[maxn], z[maxn], dfn[maxn], End[maxn], rem[maxn];

int main() {
	ios::sync_with_stdio(false);
	int n, m = 0;
	cin >> n;
	vector<vector<int> > g(n + 1);
	for (int i = 1; i < n; ++i) {
		int u, v;
		cin >> u >> v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	function<void(int, int)> dfs = [&](int u, int p) {
		dfn[u] = ++m;
		par[u][0] = p;
		x[u][0] = u;
		dep[u] = dep[p] + 1;
		for (int i = 1; i < lgn; ++i) {
			par[u][i] = par[par[u][i - 1]][i - 1];
			x[u][i] = max(x[u][i - 1], x[par[u][i - 1]][i - 1]);
		}
		int v = u, a = 0;
		for (int i = lgn - 1; ~i; --i) {
			int nv = par[v][i], na = max(a, x[v][i]);
			if(na < y[nv]) v = nv, a = na;
		}
		rem[u] = v;
		for (int v: g[u]) if(v != p) y[v] = max(y[u], u), dfs(v, u);
		End[u] = m;
		return;
	};
	dfs(1, 0);
	for (int u = 2; u <= n; ++u) {
		int v = rem[u];
		++z[dfn[v]];
		--z[End[v] + 1];
	}
	for (int i = 1; i <= n; ++i) z[i] += z[i - 1];
	for (int u = 2; u <= n; ++u) {
		if(u > 2) cout << ' ';
		cout << z[dfn[u]];
	}
	cout << endl;
	return 0;
}


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

using namespace std;



void solver() {
    char x;
    cin >> x;

    if (x == tolower(x)) {
        cout << "a";
    }
    else {
        cout << "A";
    }
}

int main() {

    ios_base :: sync_with_stdio(0); cin.tie(NULL);

    int t = 1;
    //cin >> t;
    
    while(t--)
        solver();

    return 0;
}

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

s = []

for _ in range(n):
    x = input()
    s.append(x)

s.sort()

l = [1] * n

for i in range(1, n):
    if s[i] == s[i - 1]:
        l[i] = l[i - 1] + 1

m = max(l)

for i in range(n):
    if l[i] == m:
        print(s[i])

Measured memory_bytes: 75992
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
#include<string>

#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

using namespace std;

int main() {
	int x,h, sum=0,i,j,k;
	string seq;
	vector<int> A, H, S;
	cin >> seq;
	H.push_back(10);
	rep(i,seq.size()) {
		if (seq[i] == '/') {
			H.push_back(H.back()+1);
			S.push_back(1);
		} else if (seq[i] == '\\') {
			H.push_back(H.back()-1);
			S.push_back(-1);
		} else if (seq[i] == '_') {
			H.push_back(H.back());
			S.push_back(0);
		} else cout << "Input Error" << endl;
	}
	rep(i,H.size()) {
		h = 0;
		if (H[i] <= H[i+1]) continue;
		for(j=i+1;j<H.size();j++) {
			if (H[i] == H[j]) {
				x = 0;
				for(k=i;k<j;k++) {
					switch (S[k]) {
						case -1:
							x += h+1;
							h += 1;
							break;
						case 1:
							h -= 1;
							x += h;
							break;
						case 0:
							x += h;
							break;
					}
				}
				A.push_back(x);
				i += j-i-1;
				break;
			}
		}
	}
	rep(i,A.size()) sum += A[i];
	cout << sum << "\n" << A.size() << (A.size() > 0 ? " ":"\n");
	if (A.size() > 0) rep(i,A.size()) cout << A[i] << (i < A.size()-1 ? " ":"\n");
}

Measured memory_bytes: 1524
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  vector<int> vec(n);
  for (int i=0;i<n+1;i++){
    cin >> vec[i];
  }
  sort(vec.begin(), vec.end());
  cout << abs(vec[0]-vec[n-1]) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
typedef long long ll;
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif
#define LAR(a, b) ((a)=max((a), (b)))
#define SML(a, b) ((a)=min((a), (b)))

#define MOD 1'000'000'007LL

#define N 2048
int n, m;
int s[N], t[N];
// ll memo[N][N];
// ll DP(int, int);
// inline ll dp(int a, int b){
// 	if(~memo[a][b]) return memo[a][b];
// 	else return memo[a][b]=DP(a, b);
// }
// ll DP(int a, int b){
// 	ll ret;
// 	if(a == n || b == m){
// 		ret = 1;
// 	}else if(s[a] == t[b]){
// 		ret = dp(a+1, b+1) + dp(a, b+1) + dp(a+1, b);
// 	}else{
// 		ret = dp(a, b+1) + dp(a+1, b);
// 	}
// 	ret %= MOD;
// 	return ret;
// }

ll a[N][N]={};

int main(){
	scanf("%d%d", &n, &m);
	REP(i, n) scanf("%d", s+i);
	REP(i, m) scanf("%d", t+i);
	a[n][m]=1;
	REP(i, n) a[i][m]=1;
	REP(j, m) a[n][j]=1;
	for(int i=n-1; i>=0; i--){
		for(int j=m-1; j>=0; j--){
			ll &p = a[i][j];
			if(s[i]==t[j]){
				p = a[i+1][j+1];
			}
			p += a[i][j+1];
			p += a[i+1][j];
			p -= a[i+1][j+1];
			p = (p+MOD*10)%MOD;
		}
	}
	printf("%lld\n", a[0][0]);

//	REP(i, N) REP(j, N) memo[i][j]=-1;
//	printf("%lld\n", dp(0, 0));
}


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

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template <typename T> using pq = priority_queue<T>;
template <typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template <typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for (auto &i : mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template <class T> ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template <class T> istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template <class T> ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    ll n;
    string s;
    cin >> n;
    cin >> s;
    map<char, ll> mp;
    rep(i, n) { mp[s[i]]++; }
    ll ans = mp['R'] * mp['G'] * mp['B'];
    rep(i, n) {
        for (ll j = i + 1; j < n; j++) {
            ump<char, ll> mp;
            if (j + j - i > n - 1) continue;
            mp[s[i]]++, mp[s[j]]++, mp[s[j + j - i]]++;
            if (mp['R'] == 1 && mp['B'] == 1 && mp['G'] == 1) ans--;
        }
    }
    cout << ans << '\n';
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 3636
// https://qiita.com/ytanto/items/caf7bf0ba287da81b20f

function main(input) {
    var args = input.split(" ");
    var a = parseInt(args[0]);
    var b = parseInt(args[1]);

    console.log((a * b) % 2 === 0 ? 'Even' : "Odd");
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


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

int main()
{
  int A[3][3];
  int N; 
  for(int i=0; i<3; i++)
  {
    for(int j=0; j<3; j++)
    {
      cin >> A[i][j];
    }
  } 
  cin >> N;
  int B[N];
  for(int i=0; i<N; i++)
  {
    cin >> B[i];
  }
    for(int i=0; i<3; i++)
  {
    for(int j=0; j<3; j++)
    {
      for(int k=0; k<N; k++)
      {
        if(B[k]==A[i][j])
        {
          A[i][j]=0;
        }
      }
    }
  } 
  if((A[0][0]==0)&&((A[0][1]==0)&&(A[0][2]==0)))
  {
    cout <<"Yes"<<endl;
    return 0;
  }
  if((A[1][0]==0)&&((A[1][1]==0)&&(A[1][2]==0)))
  {
    cout <<"Yes"<<endl;
    return 0;
  }
  if((A[2][0]==0)&&((A[2][1]==0)&&(A[2][2]==0)))
  {
    cout <<"Yes"<<endl;
    return 0;
  }
  if((A[0][0]==0)&&((A[1][0]==0)&&(A[2][0]==0)))
  {
    cout <<"Yes"<<endl;
    return 0;
  }
  if((A[0][1]==0)&&((A[1][1]==0)&&(A[2][1]==0)))
  {
    cout <<"Yes"<<endl;
    return 0;
  }
  if((A[0][2]==0)&&((A[1][2]==0)&&(A[2][2]==0)))
  {
    cout <<"Yes"<<endl;
    return 0;
  }
  if((A[0][0]==0)&&((A[1][1]==0)&&(A[2][2]==0)))
  {
    cout <<"Yes"<<endl;
    return 0;
  }
  if((A[2][0]==0)&&((A[1][1]==0)&&(A[0][2]==0)))
  {
    cout <<"Yes"<<endl;
    return 0;
  }
  cout <<"No"<<endl;
}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>

using namespace std;
typedef long long LL;

const int L=2001;

const LL inf=1LL<<60;
int N,M;
LL dist[L];
LL a[L];
LL b[L];
LL c[L];
int main() {
	scanf("%d%d",&N,&M);

	for(int i=0;i<M;i++){
		scanf("%lld%lld%lld",a+i,b+i,c+i);
		a[i]--;b[i]--;
	}
	fill(dist,dist+N,-inf);
	dist[0]=0;
	for(int i=0;i<=2*N;i++){
		for(int j=0;j<M;j++){
			if(dist[a[j]]!=-inf&&dist[b[j]]<dist[a[j]]+c[j]){
				dist[b[j]]=dist[a[j]]+c[j];
				if(b[j]==N-1&&i>=N){
					puts("inf");
					return 0;
				}
			}
		}
	}
	printf("%lld\n",dist[N-1]);

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define mrep(i,from,n) for(int i = from; i < n; i++)
#define mreps(i,from,n) for(int i = from; i <= n; i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())
typedef long long ll;
typedef pair<ll, ll> P;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
ll mod = 1000000007;

void solve()
{
	string s; cin >> s;
	set<char> alp;
	rep(i,sz(s))alp.insert(s[i]);
	int ans = sz(s);
	for (char c : alp)
	{
		vector<int> index(1,-1);
		rep(i,sz(s))if(s[i]==c)index.push_back(i);
		index.push_back(sz(s));
		int tmp = 0;
		rep(i,sz(index)-1)chmax(tmp,index[i+1]-index[i]-1);
		chmin(ans,tmp);
	}
	cout << ans << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int MAXN = 1e5+7;

LL covered(const vector< LL > &A, LL z) {
    LL ans = 0;
    for (LL i = 0; i < A.size(); i++) {
        LL y = z-A[i];
        ans += A.end() - lower_bound(A.begin(), A.end(), y);
    }
//    cout << z << " -> " << ans << endl;
    return ans;
}

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

    LL n, m;
    cin >> n >> m;

    vector< LL >A(n);
    for (LL i = 0; i < n; i++) cin >> A[i];

    sort(A.begin(), A.end());

    LL lo = A.front()*2, hi = A.back()*2;

    while (lo <= hi) {
        LL mid = (lo+hi)/2;

        if (covered(A, mid) < m) hi = mid-1;
        else lo = mid+1;
    }

    ///hi has ans
    vector< LL >suffix(A);
    suffix.push_back(0);
    for (LL i = n-1; i >= 0; i--) suffix[i] += suffix[i+1];

    LL ans = 0;
    for (LL i = 0; i < n; i++) {
        LL idx = upper_bound(A.begin(), A.end(), hi-A[i])-A.begin();
        m -= n-idx;
        ans += suffix[idx]+(n-idx)*A[i];
//        cout << i << " -> " << idx << endl;
    }

    assert(m >= 0);
    ans += m*hi;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2560
<?php
$n = fgets(STDIN);
$a = explode(' ', fgets(STDIN));
$min = 30;
for ($i = 0; $i < $n; $i++) {
    for ($j = 0; $a[$i] % 2 == 0; $j++) {
        $a[$i] /= 2;
    }
    $min = min($j, $min);
}
echo $min;
?>

Measured memory_bytes: 3576
using System;

using System.Collections.Generic;
using System.Linq;

class Procon
{
    public Procon() { }
    static void Main(string[] agrs)
    {
        new Procon().Do();
    }

    Scanner cin;

    public void Do()
    {
        cin = new Scanner();
        int A = cin.nextInt();
        int B = cin.nextInt();
        int C = cin.nextInt();
        int X = cin.nextInt();
        int Y = cin.nextInt();

        int ans = 0;

        int XY = Math.Min(X, Y);

        ans += Math.Min(XY * (A + B), XY * 2 * C);
        X -= XY;
        Y -= XY;

        for (int i = 0; i < X; i++)
        {
            ans += Math.Min(A, 2 * C);
        }

        for (int i = 0; i < Y; i++)
        {
            ans += Math.Min(B, 2 * C);
        }

        Console.WriteLine(ans);
    }
}

class Scanner
{
    string[] s;
    int i;
    int max_i;

    public Scanner()
    {
        s = new string[0];
        max_i = 0;
        i = 0;
    }

    public string nextString()
    {
        if (i >= s.Length)
        {
            s = Console.ReadLine().Split(' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0)
            {
                return "";
            }
            return s[i++];
        }
        else
        {
            return s[i++];
        }
    }

    public int nextInt()
    {
        return int.Parse(nextString());
    }


    public long nextLong()
    {
        return long.Parse(nextString());
    }

    public double nextDouble()
    {
        return double.Parse(nextString());
    }

    public string[] arrayString()
    {
        return Console.ReadLine().Split(' ');
    }

    public int[] arrayInt()
    {
        string[] str = Console.ReadLine().Split(' ');
        int[] array = new int[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = int.Parse(str[i]);
        }
        return array;
    }

    public long[] arrayLong()
    {
        string[] str = Console.ReadLine().Split(' ');
        long[] array = new long[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = long.Parse(str[i]);
        }
        return array;
    }

    public double[] arrayDouble()
    {
        string[] str = Console.ReadLine().Split(' ');
        double[] array = new double[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = double.Parse(str[i]);
        }
        return array;
    }
}

Measured memory_bytes: 11220
#include <algorithm>
#include <bitset>
//#include <boost/multiprecision/cpp_int.hpp>
#include <climits>
#include <cmath>
#include <cstring>
#include <functional>
#include <algorithm>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <sstream>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
//namespace mp = boost::multiprecision;
using namespace std;
using ull = unsigned long long;
using ld = long double;
// using ll = boost::multiprecision::cpp_int;
using ll = long long;
#define FOR(i,N) for(ll i = 0; i < N; ++i)

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
// using int = ll;
ll gcd(ll m, ll n) {
    if(n == 0)
        return abs(m);
    return (gcd(n, m % n));
}
void putYN(bool b) {
    if(b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}
void swap(ll &a, ll &b) {
    ll tmp = a;
    a = b;
    b = tmp;
}
ll combi(ll n, ll k) {
    ll r = 1, rr = 1;
    for(ll i = 0; i < k; ++i) {
        r *= (n - i);
        rr *= (i + 1);
        // r %= 1000000007;
        // rr %= 1000000007;
    }
    r /= rr;
    // r %= 1000000007;
    return r;
}

int main() {
    ll A,B;
    cin >> A >> B;
    if((A+B)%2==0){
        cout << (A + B) / 2 << endl;
    }else{
        cout << "IMPOSSIBLE" << endl;
    }
    return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef pair<int,int> P;

int main(){
    
    int N;
    cin>>N;
    
    if(N<105){
        cout <<0<<endl;
    }else if(N>=105&&N<135){
        cout <<1<<endl;
    }else if(N>=135&&N<165){
        cout <<2<<endl;
    }else if(N>=165&&N<189){
        cout <<3<<endl;
    }else if(N>=189&&N<195){
        cout<<4<<endl;
    }else{
        cout <<5<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		if(a < b){
			if(b < c){
				System.out.println("Yes");
			}else{
				System.out.println("No");
			}
		}else{
			System.out.println("No");
		}
	}
}


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

using namespace std;

#define ll long long

const int N = 1e5 + 5;
const ll INF = 2e11;
ll n, w[N], v[N], W, dp[N][105];

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

	cin>>n>>W;
	for(int i=1;i<=n;++i)cin>>w[i]>>v[i];

	for(int i=0;i<N;++i)
		for(int j=0;j<105;++j)dp[i][j] = INF;

	dp[0][0] = 0;
	for(int i=1;i<=n;++i)
		for(int j=0;j<N;++j){
			dp[j][i] = dp[j][i - 1];

			if(j - v[i] >= 0)
				dp[j][i] = min(dp[j][i], dp[j - v[i]][i - 1] + w[i]);
		}

	for(int j=N - 1;j>=0;--j)if(dp[j][n] <= W){
		cout<<j<<"\n";
		return 0;
	}
}

Measured memory_bytes: 82304
#include <iostream>
using namespace std;
int n,W;
int dp[101][10001];
int v[101],w[101];

int solve(int i,int j){
	if(dp[i][j]>0) return dp[i][j];
	int res;
	if(i==n){
		res=0;
	}else if(w[i]> j){
		res=solve(i+1,j);
	}else{
		res=max(solve(i+1,j),solve(i+1,j-w[i])+v[i]);
	}
	return dp[i][j]=res;
}

int main(void){
	cin>>n>>W;
	for(int i=0;i< n ;i++){
		cin>>v[i]>>w[i];
	}
	
	
	cout<<solve(0,W)<<endl;
}


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

h = list(map(int,input().split()))
ma = 0
l = 0
for i in range(1,n):
    if(h[i] <= h[i-1]):l+=1
    else:
        ma = max([ma,l])
        l = 0
ma = max([ma,l])

print(ma)

Measured memory_bytes: 14224
#include<bits/stdc++.h>
using namespace std;
long long n,a,b,MIN,sum,bo;
int main()
{
	cin>>n;
	MIN=2000000000;
	while(n--)
	{
		cin>>a>>b;
		if(a>b)MIN=min(MIN,b);
		if(a!=b)bo=1;
		sum+=b;
	}
	if(bo)cout<<sum-MIN;
	  else cout<<0;
	return 0;
}

Measured memory_bytes: 3588
#include <iostream>
using namespace std;
int main()
{
	int n,maxv=-1,f=1;
	cin>>n;
	long long a[n+1];
	for (int i=1;i<=n;i++)  cin>>a[i];
	for (int i=1;i<=n;i++)
	{
		if (i==1)  maxv=a[i];
		if (a[i]>maxv)  maxv=a[i];
		else
		{
			if (maxv-a[i]>=2)
			{
				f=0;
				break;
			}
		}
	}
	if (f==0)  cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
	return 0;	
}

Measured memory_bytes: 1024
import sys
N,M=map(int,input().split())
dp=[1]*N
listA=[]
for i in range(M):
  a=int(input())
  listA+=[a]
  dp[a-1]=0
for i in range(1,M):
  if listA[i]==listA[i-1]:
    print(0)
    sys.exit()
setA=set(listA)    
if (1 not in setA) and (2 not in setA) and N!=1:
  dp[1]=2
for i in range(2,N):
  if i+1 not in setA:
    dp[i]=dp[i-1]+dp[i-2]
ans=dp[-1]%(10**9+7)
print(ans)

Measured memory_bytes: 460020
#include<stdio.h>

int main(void)
{
    int W, H, x, y,r;

    scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);

    if(x - r < 0 || W < x + r || y - r < 0 || H < y + r)
      puts("No");
    else
      puts("Yes");

    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> L(N);
  for (int i = 0; i < N; i++) {
    cin >> L.at(i);
  }
  int count = 0;
  sort(L.begin(), L.end());
  for (int i = 0; i < N-2; i++) {
    for (int j = i + 1; j < N-1; j++) {
      for (int k = j + 1; k < N; k++) {
        if (L.at(i) != L.at(j) && L.at(j) != L.at(k)) {
          if (L.at(i) + L.at(j) > L.at(k) && 
              L.at(j) + L.at(k) > L.at(i) && 
              L.at(k) + L.at(i) > L.at(j)) {
            count++;
          }
        }
      }
    }
  }
  
  cout << count << endl;
}

Measured memory_bytes: 3596
from collections import defaultdict,deque
import numpy as np
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

N,D = inpl()
xx = [inpl() for _ in range(N)]

db = [i**2 for i in range(1,500)]

def dist(i,j):
    tmp = 0
    for k in range(D):
        tmp += (xx[i][k]-xx[j][k])**2
    return tmp

ans = 0
for i in range(N):
    for j in range(i+1,N):
        tmp = dist(i,j)
        if tmp in db:
            ans += 1
print(ans)


Measured memory_bytes: 21352
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
int INF = 100100101;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n,a,b;
  cin>>n>>a>>b;
  int ans = 0;
  for(int i = 1; i <=n; i++){
    string s = to_string(i);
    int sum = 0;
    rep(j, s.length()){
      sum +=(int)(s[j]-48);
    }
    if(sum >=a && sum <= b){
      ans += i;
    }
  }
  cout << ans << endl;
}
	

Measured memory_bytes: 256
#include <iostream>

using namespace std;

bool G[8][8] = {{false}};
bool visited[8] = {false};

bool IsComplete(int N) {
  for (int i = 0; i < N; ++i)
    if (!visited[i])
      return false;
  return true;
}

int DFS(int u, int N) {
  if (IsComplete(N))
    return 1;

  int ret = 0;
  for (int v = 0; v < N; ++v) {
    if (!G[u][v])
      continue;
    if (visited[v])
      continue;
    visited[v] = true;
    ret += DFS(v, N);
    visited[v] = false;
  }
  return ret;
}

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

  int N, M;
  cin >> N >> M;

  int a, b;
  for (int i = 0; i < M; ++i) {
    cin >> a >> b;
    a--;
    b--;
    G[a][b] = G[b][a] = true;
  }
  visited[0] = true;
  cout << DFS(0, N) << endl;

  return 0;
}


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

#define QUE_SIZE 1000000
typedef struct {
    char name[10];
    int time;
} QUE;
QUE que[QUE_SIZE];

int main() {
    int i,j,n,q,time=0,head=0,tail;
    char name[10];
    scanf("%d %d", &n, &q);
    tail=n;
    for(i=0;i<n;i++) scanf("%s %d", que[i].name, &que[i].time);
    time=0;
    while(head!=tail){
        if(que[head].time <= q || (QUE_SIZE+tail-head)%QUE_SIZE == 1) {
            time += que[head].time;
            printf("%s %d\n", que[head].name, time);
            head = (head+1)%QUE_SIZE;
        } else {
            time += q;
            que[head].time -= q;
            que[tail] = que[head];
            head = (head+1)%QUE_SIZE;
            tail = (tail+1)%QUE_SIZE;
        }
    }
    return 0;
}


Measured memory_bytes: 5160
a, b = map(int, raw_input().split())
n = 0

if a == 1:
  n += 300000
elif a == 2:
  n += 200000
elif a == 3:
  n += 100000

if b == 1:
  n += 300000
elif b == 2:
  n += 200000
elif b == 3:
  n += 100000

if a == 1 and b == 1:
  n += 400000

print(n)

Measured memory_bytes: 2692
#include<iostream>
using namespace std;
int main(){
long n,x,y,z,k;
while(cin>>x>>y){
if(x==0)break;
if(x<y){z=x;x=y;y=z;}
k=0;
while(y>0){
x%=y;
z=x;x=y;y=z;
k++;
}
cout<<x<<" "<<k<<endl;
}
return 0;
}

Measured memory_bytes: 1160
#include <cstdio>

int main()
{
    int n, ans = 0;
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        int l, r;
        scanf("%d%d", &l, &r);
        ans += (r - l + 1);
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 128
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#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)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {
	int n; cin >> n;
	vector<int> a(n), b(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
	}
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());

	if (n % 2 == 0) {
		int mida = (a[n / 2] + a[n / 2 - 1]) ;
		int midb = (b[n / 2] + b[n / 2 - 1]) ;

		cout << (abs(mida - midb) + 1) << endl;
	}
	else {
		int mida = a[(n - 1) / 2];
		int midb = b[(n - 1) / 2];
		cout << (abs(mida - midb) + 1) << endl;
	}
	return 0;
}

Measured memory_bytes: 4844
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(a) (a).begin(), (a).end()
typedef vector<int> vi;
const int INF = 1LL << 60; //10e18+10e17ちょっとくらい
const int MOD = 1000000007;
const int MAX_N = 200100;

bool memo[1000010];
signed main()
{
    //  以降 cin の入力元が 'input.txt' になる
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    int n;
    cin >> n;
    vi v;
    rep(i,n){
        int t;
        cin >> t;
        v.emplace_back(t);
    }
    sort(all(v));
    map<int, bool> mp;
    int ans = 0;
    rep(i, n){
        if(mp.find(v[i]) != mp.end()){
            if(mp[v[i]]){
                ans--;
                mp[v[i]] = false;
            }
        }
        else{
            mp[v[i]] = true;
            if(memo[v[i]]){
                mp[v[i]] = false;
                continue;
            }
            else{
                ans++;
                int t = v[i];
                while(t < 1000010){
                    memo[t] = true;
                    t+= v[i];
                } 
            }
        }
    } 
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 18056
#include<bits/stdc++.h>
using namespace std;
using ll = long long;

#define debug(x) cerr << #x << " = " << x << endl;
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define FOR(it, b, e) for (typeof(b) it = (b); it != (e); ++it)
#define MSET(c, v) memset(c, v, sizeof(c))

const int INF = 0x3F3F3F3F; 
const int NEGINF = 0xC0C0C0C0;
const int NULO = -1;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;

inline int cmp(double x, double y = 0) 
{  
  if(fabs(x - y) < EPS)
    return 0;
  return x > y ? 1 : -1;
}

ll exp(ll a, ll b)
{
  ll ans = 1;
  while(b)
  {
    if(b & 1)
      ans = (ans * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return ans;
}

const int maxn = 2e5 + 10;
ll fat[maxn], inv[maxn];

ll C(int n, int k)
{
  if(n < k) 
    return 0;
  if(n < 0 || k < 0) 
    return 0;
  return (((fat[n] * inv[k]) % mod) * inv[n - k]) % mod;
}

void initFactorials()
{
  fat[0] = 1;
  inv[0] = 1;
  for(int i = 1; i < maxn; i++)
  {
    fat[i] = (i * fat[i-1]) % mod;
    inv[i] = exp(fat[i], mod - 2);
  }
}

vector<int>job[maxn];

int main()
{
  ios::sync_with_stdio(0);
  int n,m;
  cin >> n >> m;
  for(int i = 1; i <= n ; i++)
  {
    int a,b;
    cin >> a >> b;  
    job[a].push_back(b);
  }

  ll ans = 0;
  priority_queue<int>pq;
  for(int i = m - 1; i >= 0; i--)
  {
    for(const auto &x : job[m - i])
    {
      pq.push(x);
    }
    if(pq.size())
    {
      ans += pq.top();
      pq.pop();
    }
  }

  cout << ans << endl;

  return 0;
}

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

def solve(N: int, K: int, a: "List[int]", b: "List[int]"):
    ab = list(zip(a,b))
    ab.sort(key=lambda x: x[0])
    sumb =0
    123334
    for i in range(N):
        sumb+=ab[i][1]
        if sumb>=K:
            print(ab[i][0])
            return 
        
    

    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
    K = 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, K, a, b)

if __name__ == '__main__':
    main()


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

using ll = long long;
using ull = unsigned long long;
using namespace std;
constexpr int inf = 1<<30;
constexpr int mo = 1e9+7;
constexpr ll infl = 1ll<<60;

int main(){
    cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    
    int n;
    cin>>n;
    vector<ll> v(n);
    for(auto & a : v) cin>>a;
    sort(v.rbegin(),v.rend());
    multiset<ll> st;
    st.insert(v[0]);
    ll ret = 0;
    for(int i=1;i<n;++i){
        auto  ma = *st.rbegin();
        ret += ma;
        st.erase(st.find(ma));
        st.insert(v[i]);
        st.insert(v[i]);
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 14288
X, K, D = map(int, input().split())
tmp = abs(X)//D
if tmp >= K:
    print(abs(abs(X)-K*D))
    exit()
ans = abs(abs(X)-tmp*D)
if K % 2 == tmp % 2:
    print(ans)
else:
    print(abs(ans-D))


Measured memory_bytes: 61560
#include <bits/stdc++.h>
#define INF 1e18
#define PI M_PI
#define ll long long
#define vi vector<int>
#define all(v) v.begin(), v.end()
#define REP(i, n) for (int i=0; i<n; i++)
#define REPD(i, n) for (int i=n-1; i>=0; i--)
#define print(x) cout << x << endl;
#define debug(x) cout << #x << " = " << endl;

using namespace std;

void solve()
{
    int A, B, C;
    cin >> A >> B >> C;
    print(max({0, C - A + B}));
}

int main()
{
    solve();

    return 0;
}


Measured memory_bytes: 256
using System;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string input = Console.ReadLine();
                if (input == null)
                    break;
                string[] split = input.Split();
                double a = double.Parse(split[0]);
                double b = double.Parse(split[1]);
                double c = double.Parse(split[2]);
                double d = double.Parse(split[3]);
                double e = double.Parse(split[4]);
                double f = double.Parse(split[5]);

                //x = (c-by)/a
                //y = (f-dx)/e
                //ey = f-dx
                //ey = f-d((c-by)/a)
                //ey = f-(dc-dby)/a
                //f-ey= (dc-dby)/a
                //fa-aey = dc-dby
                //dby-aey = dc-fa
                //y(db-ae) = dc-fa
                //y = (dc-fa)/(db-ae)

                double y = (d * c - f * a) / (d * b - a * e);
                double x = (c - b * y) / a;

                string ans = x.ToString("0.000") + " " + y.ToString("0.000");
                Console.WriteLine(ans);
            }
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 5820
import java.util.Scanner;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
  int a = sc.nextInt();
  int b = 0;
  for(int i = 1;i <= 9;i++){
    if(a % Math.pow(10,i) == 0){
      b += (a % Math.pow(10,i+1))/Math.pow(10,i);
    }
    else{
      b += (a % Math.pow(10,i))/Math.pow(10,i-1);
    }
  }
  if(a % b == 0)System.out.println("Yes");
  else System.out.println("No");
}}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
//g++ -std=c++11 

using namespace std;
typedef long long ll;

#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define DIV 1000000007 //10^9+7

int main(){
	ll N;
	cin >> N;
	cout << N * N * N << endl;

}

Measured memory_bytes: 3640
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <cmath>

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

constexpr ll LLINF {1001002003004005006};//ll = 9*LLINF
constexpr int INTINF {1000000000};//int = 2*INTINF

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

template<typename T>
void maxs(T& x, T&& y) {
  x=std::max(x,y);
}
template<typename T>
void maxs(T& x, T& y) {
  x=std::max(x,y);
}

template<typename T>
void mins(T& x, T&& y) {
  x=std::min(x,y);
}
template<typename T>
void mins(T& x, T& y) {
  x=std::min(x,y);
}

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

  int n;
  cin >> n;
  vector<ll> A(n);
  rep(i, n) cin >> A[i];


  ull ans {1};
  constexpr ll max_ans {1000000000000000000};
  sort(A.begin(), A.end());
  if (A[0] == 0) {
    cout << "0\n";
    return 0;
  }

  rep(i, n) {
    if (ans*A[i] < ans || ans*A[i] > max_ans) {
      cout << "-1\n";
      return 0;
    } else {
      ans *= A[i];
    }
  }
  cout << ans << '\n';
}


Measured memory_bytes: 3992
process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = [];
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on('line', (line) => {
  lines.push(line);
});
reader.on('close', () => {
  let num1 = parseInt(lines[0].split(' ')[0]);
  let num2 = parseInt(lines[0].split(' ')[1]);
  if (num1 % 2 === 0 || num2 % 2 === 0) {
    console.log('Even');
  } else {
    console.log('Odd');
  }
});

Measured memory_bytes: 29892
// AtCoder My Practice
// author: Leonardone @ NEETSDKASU

fn main() {
	let mut stdin = String::new();
    std::io::Read::read_to_string(
    	&mut std::io::stdin(),
        &mut stdin).unwrap();
	let mut stdin = stdin.split_whitespace();
	let mut get = || stdin.next().unwrap();
    macro_rules! get {
    	() => (get().parse::<i64>().unwrap());
    }
    
    let n = get!() as usize;
    let mut sum = vec![0; n+1];
    for i in 0..n {
        sum[i+1] = sum[i] + get!();
    }
    sum.sort();
    let mut p = sum[0];
    let mut c = 1_i64;
    let mut ans = 0_i64;
    for i in 1..n+1 {
    	if p == sum[i] {
        	c += 1;
        } else {
        	if c > 1 {
            	ans += c * (c - 1) / 2;
            }
            c = 1;
            p = sum[i];
        }
    }
    if c > 1 {
    	ans += c * (c - 1) / 2;
    }
    println!("{}", ans);
}

Measured memory_bytes: 8444
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }
template<typename T> bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool mmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first - r.first, l.second - r.second); }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;

int main()
{
    int N;
    cin >> N;
    map<int, int> m;
    REP(_, N)
    {
        int a;
        cin >> a;
        m[a]++;
    }
    vector<int> cou(N + 2);
    for (auto p : m) cou[p.second]++;

    int nbad = 0;
    int h = N + 1;

    int taken = 0;

    vector<int> ret(N + 1);
    IFOR(k, 1, N + 1)
    {
        while (h > k)
        {
            nbad += cou[h];
            taken += cou[h] * h;
            h--;
        }
        ret[k] = nbad + (N - taken) / k;
    }
    int ans = N;
    FOR(k, 1, N + 1)
    {
        while (ret[ans] < k and ans > 0) ans--;
        cout << ans << endl;
    }
}


Measured memory_bytes: 16640
using System;

namespace ITP1_6_C
{
    class Program
    {
        static void Main(string[] args)
        {
            var memo = new int[4, 3, 10];
            var n = int.Parse(Console.ReadLine());
            for(int i = 0; i < n; i++)
            {
                var input = Console.ReadLine().Split(' ');
                var b = int.Parse(input[0]) - 1;
                var f = int.Parse(input[1]) - 1;
                var r = int.Parse(input[2]) - 1;
                var v = int.Parse(input[3]);
                memo[b, f, r] += v;
            }

            for(int i = 0; i < 4; i++)
            {
                for(int j = 0; j < 3; j++)
                {
                    for(int k = 0; k < 10; k++)
                    {
                        Console.Write(" {0}", memo[i, j, k]);
                    }
                    Console.WriteLine();
                }
                if (i < 3)
                    Console.WriteLine(new string('#', 20));
            }
        }
    }
}

Measured memory_bytes: 9212
level=["heavy","light heavy","middle","light middle","welter",
"light welter","light","feather","bantam","fly"]
weight=[91,81,75,69,64,60,57,54,51,48]
while True:
    try:
        w=float(input())
    except:
        break
    f=False
    for wei,lev in zip(weight,level):
        if w>wei:
            print(lev)
            f=True
            break
    if not f:
        print("light fly")

Measured memory_bytes: 7352
#include <cmath>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
int A[100000];
int main(){
    int n;
    cin >> n;
    bool neg = false;
    bool zero = false;
    for(int i=0;i<n;i++){
        cin >> A[i];
        neg ^= A[i] < 0;
        if(A[i] == 0){
            zero = true;
        }
    }
    ll ans = 0;
    for(int i=0;i<n;i++){
        ans += abs(A[i]);
        A[i] = abs(A[i]);
    }
    if(!zero && neg){
        ans -= *min_element(A,A+n)*2;
    }
    cout << ans;
    return 0;
}

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

int n;
int a[10000];

bool is_prime(int n) {
	if (n <= 1) { return false; }
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0) {
			return false;
		}
	}
	return true;
}

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i];
	
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (is_prime(a[i])) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3112
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N,ans;
    int all=0;
    cin >> N;
    int A[N];
    for(int i=0; i<N; i++){
        cin >> A[i];
        all ^=A[i];
    }
    for(int i=0; i<N; i++){
        ans=0;
        ans ^= all;
        ans ^= A[i];
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 4324
n = int(input())
s = list(input().strip())

l, r = 0, n - 1
ans = 0
while l < r:
    while l < r and s[l] == 'R':
        l += 1
    while l < r and s[r] == 'W':
        r -= 1
    if l >= r:
        break
    ans += 1
    l += 1
    r -= 1
print(ans)


Measured memory_bytes: 82344
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 998244353 #出力の制限
N = 2*(10**5)
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

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

dp = [0]*(N+1)

dp[1] = M
for i in range(2,N+1):
    dp[i] = dp[i-1]*(M-1)
    dp[i] %= mod

ans = 0

for i in range(0,K+1):
    ans += cmb(N-1,i,mod)*dp[N-i]
    ans %= mod

print(ans)

Measured memory_bytes: 114488