akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<iostream>
#include<stdio.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fr(i,j,n)   for(long long i=j;i<(n);++i)
#define bk(i,j,n)   for(long long i=j;i>=n;--i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define endl "\n"
#define MOD 1000000007
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define srt(x) sort(x.begin(),x.end());
#define run ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ordered_set tree<ll , null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>

typedef long long ll;
ll modpower(ll a,ll b,ll c)
{
	ll res=1;
	while(b)
	{
		if(b&1LL)
			res=(res*a)%c;
		a=(a*a)%c;
		b>>=1;
	}
	return res;
}


int main()
{
    run;
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    if(a+b>=k)
    {
        if(k<=a)
        {
            cout<<k<<endl;
        }else
        cout<<a<<endl;
    }else{

    ll o=k-a-b;
    a-=o;
    cout<<a<<endl;

    }


}


Measured memory_bytes: 3652
#include <cstdio>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int main(){
	int n,a[50],b[50],c[49];
	scanf("%d",&n);
	rep(i,n) scanf("%d",a+i), a[i]--;
	rep(i,n) scanf("%d",b+i);
	rep(i,n-1) scanf("%d",c+i);

	int ans=0;
	rep(i,n){
		ans+=b[a[i]];
		if(i<n-1 && a[i]+1==a[i+1]) ans+=c[a[i]];
	}
	printf("%d\n",ans);

	return 0;
}


Measured memory_bytes: 256
n,m = gets.chomp.split(" ").map(&:to_i)
sta = gets.chomp.split(" ").map(&:to_i)
dp = Array.new(n,0)
for i in 1..n-1
  inst = 10**10
  for j in 1..i
    if inst > dp[i-j] + ((sta[i] - sta[i-j]).abs)
      inst = dp[i-j] + ((sta[i] - sta[i-j]).abs)
    end
    if j == m
      break
    end
  end
  dp[i] = inst
end
puts dp[-1]


Measured memory_bytes: 12044
from sys import stdin

[K, S] =  [int(x) for x in (stdin.readline().rstrip().split())]

# combination of given X, Y, Z, that satisfy
# 0<= X, Y, Z <= K
# 0<= S <=3K
# X+Y+Z = S
# 2<= K<=2500

count = 0

#for i in range(K+1):
#    for j in range(K+1):
#        if i+j<=S and K+i+j>=S:
#            count+=1
for i in range(K+1):
    S_rest = S-i
    if S_rest>2*K:
        continue
    if S_rest<0:
        break
    if S_rest>=K:
        count += 2*K- S_rest +1
    else:
        count += S_rest+1

print(count)






Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

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

int main()
{
    int N, a, b;
    cin >> N >> a >> b;
    N -= 2;
    a = lcm(a, b);
    for (int i = 0; i < N; i++)
    {
        cin >> b;
        a = lcm(a, b);
    }
    cout << a << endl;
}


Measured memory_bytes: 3084
#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>;
  
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int n; cin >> n;
  int a[n];
  vector<vector<P> > xy(n);
  rep(i, n) {
    int x; cin >> x;
    a[i] = x;
    rep(j, x) {
      int x, y; cin >> x >> y;
      --x;
      xy[i].push_back(make_pair(x, y));
    }
  }

  int ans = 0;
  rep(i, 1<<n) {
    vector<int> v(n), tf(n, -1);
    rep(j, n) {
      v[j] = i>>j&1;
    }
    bool flag = 1;
    rep(j, n) {
      if(tf[j] != -1) {
	if(v[j] ^ tf[j]) {
	  flag = 0;
	  break;
	}
      }
      if(v[j]) tf[j] = 1;
      else {
	tf[j] = 0;
	continue;
      }
    
      rep(k, a[j]) {
	if(tf[xy[j][k].first] == -1) {
	  tf[xy[j][k].first] = xy[j][k].second;
	} else if(tf[xy[j][k].first] != xy[j][k].second) {
	  flag = 0;
	  break;
	}
      }
    }
    if(flag) {
      int cnt = 0; rep(j, n) cnt += v[j];
      ans = max(ans, cnt);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
// Author: getharshkumar

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t

int main()
{
    ll n, m, x;
    string s;
    cin >> n >> m >> s;
    vector<ll> a(n + 5), v;
    for (ll i = n; ~i; i--)
    {
        if (s[i] == '0')
            x = i;
        a[i] = x;
    }
    for (ll i = n;;)
    {
        if (i <= m)
        {
            v.push_back(i);
            v.push_back(0);
            break;
        }
        if (a[i - m] == i)
            return cout << -1, 0;
        v.push_back(i);
        i = a[i - m];
    }
    for (ll i = (ll)v.size() - 1; i; i--)
        cout << v[i - 1] - v[i] << " ";
    return 0;
}

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

int main(){
  int tmp = 0, num = 0;
  string s;
  cin >> s;
  for (int i = 0; i < s.size(); i++){
    if (s.at(i) == 'A' || s.at(i) == 'T' || s.at(i) == 'G' || s.at(i) == 'C'){
      tmp++;
    }
    else{
      tmp = 0;
    }
    if(num < tmp) num = tmp;
  }
  cout << num;
}

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

main(){
  string s;
  cin>>s;
  int n=s.size();
  int ans=0;
  int right=0, left=0;
  rep(i,n){
    if(s[i]=='<'){
      if(right!=0){
        int x=max(right,left),y=min(right,left);
        ans+=x*(x+1)/2+y*(y-1)/2;
        right=0; left=0;
      }
      left++;
    }
    if(s[i]=='>'){
      right++;
    }
  }
  int x=max(right,left),y=min(right,left);
  ans+=x*(x+1)/2+y*(y-1)/2;
  cout<<ans<<endl;
}

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

int main()
{
    int a,b,cb,zece=0,b2;
    cin>>a>>b;
    cb=0;
    b2=b;
    while(b%10==0)
    {
        b/=10;
        zece++;
    }
    while(b)
    {
        cb*=10;
        cb+=b%10;
        b/=10;
    }
    while(cb)
    {
        a*=10;
        a+=cb%10;
        cb/=10;
    }
    if(int(sqrt(a))*int(sqrt(a))==a && zece%2==0)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}


Measured memory_bytes: 256
import bisect as bi

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

ans=0

for i in reversed(range(2,N)):
    a=L[i]
    for j in reversed(range(1,i)):
        b=L[j]
        ans+=j-bi.bisect_left(L[:j],a-b+1)

print(ans)

Measured memory_bytes: 51420
#include<iostream>
#include<vector>
#include<string>
#include<unordered_map>
#include<cmath>
using namespace std;
typedef long long int lli;
unordered_map<char, int> h;

lli calc(char a, char b){
  return h[a]*16 + h[b];
}

lli calc(string s){
  lli res = 0;
  for (lli i = 0; i < 3; i++) {
    res *= (16*16);
    res += calc(s[2*i + 1], s[2*i + 2]);
  }
  return res;
}

int main(){
  string s;
  h['0'] = 0;
  h['1'] = 1;
  h['2'] = 2;
  h['3'] = 3;
  h['4'] = 4;
  h['5'] = 5;
  h['6'] = 6;
  h['7'] = 7;
  h['8'] = 8;
  h['9'] = 9;
  h['a'] = 10;
  h['b'] = 11;
  h['c'] = 12;
  h['d'] = 13;
  h['e'] = 14;
  h['f'] = 15;
  vector<lli> val(8);
  string color[] = {"#000000",
                    "#0000ff",
                    "#00ff00",
                    "#00ffff",
                    "#ff0000",
                    "#ff00ff",
                    "#ffff00",
                    "#ffffff"};
  string name[] = {"black",
                   "blue",
                   "lime",
                   "aqua",
                   "red",
                   "fuchsia",
                   "yellow",
                   "white"};
  for (int i = 0; i < 8; i++) {
    val[i] = calc(color[i]);
  }
  while(std::cin >> s, s != "0"){
    lli diff = 1e18, ans = -1;
    for (int i = 0; i < 8; i++) {
      lli hoge = 0;
      for (int j = 0; j < 3; j++) {
        int tmp = 0;
        tmp = calc(s[2*j + 1], s[2*j + 2]) -
          calc(color[i][2*j + 1], color[i][2*j + 2]);
        tmp *= tmp;
        hoge += tmp;
      }
      if(diff > hoge){
        diff = hoge;
        ans = i;
      }
    }
    std::cout << name[ans] << std::endl;
  }
  return 0;
}

Measured memory_bytes: 3204
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
#include <map>
#include <utility>
#include <set>
#include <unordered_map>
#include <cassert>

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define IPSILON 1e-9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main(){
  int N;
  string S;
  cin >> N;
  cin >> S;
  if(S.size() % 2 == 1){
    cout << "No" << endl;
    return 0;
  }
  string first = S.substr(0, S.size() /2);
  string last = S.substr(S.size() /2 , S.size()/2);
  if(first.compare(last) == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 888
/*program from Wolfycz*/
#include<cmath>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
#define inf 0x7f7f7f7f
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
inline char gc(){
	static char buf[1000000],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,1000000,stdin),p1==p2)?EOF:*p1++;
}
inline int frd(){
	int x=0,f=1; char ch=gc();
	for (;ch<'0'||ch>'9';ch=gc())	if (ch=='-')	f=-1;
	for (;ch>='0'&&ch<='9';ch=gc())	x=(x<<3)+(x<<1)+ch-'0';
	return x*f;
}
inline int read(){
	int x=0,f=1; char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar())	if (ch=='-')	f=-1;
	for (;ch>='0'&&ch<='9';ch=getchar())	x=(x<<3)+(x<<1)+ch-'0';
	return x*f;
}
inline void print(int x){
	if (x<0)	putchar('-'),x=-x;
	if (x>9)	print(x/10);
	putchar(x%10+'0');
}
const int N=2e5;
vector<int>vec[N+10];
struct S1{
	#define ls (p<<1)
	#define rs (p<<1|1)
	int tree[(N<<2)+10],Lazy[(N<<2)+10];
	void Add_cnt(int p,int v){
		tree[p]+=v;
		Lazy[p]+=v;
	}
	void pushdown(int p){
		if (!Lazy[p])	return;
		Add_cnt(ls,Lazy[p]);
		Add_cnt(rs,Lazy[p]);
		Lazy[p]=0;
	}
	void build(int p,int l,int r){
		if (l==r){
			tree[p]=l;
			return;
		}
		int mid=(l+r)>>1;
		build(ls,l,mid),build(rs,mid+1,r);
		tree[p]=max(tree[ls],tree[rs]);
	}
	void Modify(int p,int l,int r,int x,int y){
		if (x<=l&&r<=y){
			Add_cnt(p,1);
			return;
		}
		pushdown(p);
		int mid=(l+r)>>1;
		if (x<=mid)	Modify(ls,l,mid,x,y);
		if (y>mid)	Modify(rs,mid+1,r,x,y);
		tree[p]=max(tree[ls],tree[rs]);
	}
	int Query(int p,int l,int r,int x,int y){
		if (x<=l&&r<=y)	return tree[p];
		pushdown(p);
		int mid=(l+r)>>1,res=-inf;
		if (x<=mid)	res=max(res,Query(ls,l,mid,x,y));
		if (y>mid)	res=max(res,Query(rs,mid+1,r,x,y));
		return res;
	}
	#undef ls
	#undef rs
}ST;//Segment Tree
int main(){
	int n=read(),m=read(),Ans=max(0,n-m);
	for (int i=1;i<=n;i++){
		int l=read(),r=read();
		vec[l].push_back(r);
	}
	ST.build(1,0,m+1);
	for (int i=0;i<=m;i++){
		for (vector<int>::iterator it=vec[i].begin();it!=vec[i].end();it++)	ST.Modify(1,0,m+1,i,*it);
		Ans=max(Ans,ST.Query(1,0,m+1,i+1,m+1)-m-i-1);
	}
	printf("%d\n",Ans);
	return 0;
}

Measured memory_bytes: 14720
#include<stdio.h>

int main(void){
    int n;
    scanf("%d",&n);

    int count = 0;

    for(int i=1; i<=n; i++){
        if(i<10){
            count++;
        }else if(99<i && i<1000){
            count++;
        }else if(9999<i && i<100000){
            count++;
        }
    }

    printf("%d",count);

    return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#if __cplusplus >= 201103L
#include <chrono>
using namespace std::chrono;
#endif
using namespace std;
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pb push_back
#define fi first
#define se second
#ifdef LOCAL
#define prln(x) (cout << #x << ' ' << x << endl)
#define pr(x) (cout << #x << ' ' << x << ' ' )
#define prv(x) (cout << x << ' ')
#else
#define prln(x) 
#define pr(x)
#define prv(x)
#endif
#define clr(x) memset((x), 0, sizeof((x)))
#define clr1(x) memset((x), -1, sizeof((x)))
#define endl "\n"
#define pi acos(-1)
#define rep(i, st, ed) for (int i = (st); i <= (ed); ++i)
#define rep0(i, st, ed) for (int i = (st); i < (ed); ++i)
#define per(i, st, ed) for (int i = (st); i >= ed; --i)
template<class T> void _sf(T &x) {cin >> x;}
void _sf(int &x) {scanf("%d", &x);}
void _sf(ll &x) {scanf("%lld", &x);}
void _sf(double &x) {scanf("%lf", &x);}
void _sf(char &x) {scanf(" %c", &x);}
void _sf(char *x) {scanf("%s", x);}
void sf() {}
template <class T, class...U> void sf(T & head, U&... tail) { _sf(head); sf(tail...);}
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;

int read() {
	int x = 0, f = 1;
	char ch = getchar();
	while (ch < '0' || ch > '9') {
		if (ch == '-') f = -1;
		ch = getchar();
	}
	while (ch >= '0' && ch <= '9') {
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	return x * f;
}


int main(){
	#ifdef LOCAL
		freopen("in.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
		#if __cplusplus >= 201103L
		auto start = steady_clock::now();
		#endif
	#endif
	string s;sf(s);
	int cnt = 0;
	for (auto ele : s) {
		if (ele == 'o') ++cnt;
	}
	int las = 15 - s.size();
	if (cnt + las >= 8) puts("YES");
	else puts("NO");
	#ifdef LOCAL
		#if __cplusplus >= 201103L
		auto end = steady_clock::now();
		duration<double> time_span = duration_cast<duration<double>>(end - start);;
		printf("Total time: %.6fs\n", time_span.count());
		#endif
	#endif
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>

using namespace std;

typedef long long int ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, int> pli;
typedef std::pair<ll, ll> pll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

struct DivisorList
{
	DivisorList() {};
	~DivisorList() {};

	void init(long long int N)
	{
		for (int i = 1; i*i <= N; ++i)
		{
			if (N%i != 0)continue;
			divisor.push_back(i);
		}
		for (int i = divisor.size() - 1; i >= 0; --i)
		{
			long long int d = divisor[i];
			if (d != N / d)divisor.push_back(N / d);
		}
	}

	std::vector<long long int> divisor;
};

int main()
{
	ll N, M;
	cin >> N >> M;

	DivisorList d;
	d.init(M);

	ll ans = 1;

	REP(i, d.divisor.size())
	{
		if (d.divisor[i] * N <= M)ans = std::max(ans, d.divisor[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	int Q,H,S,D,N;
	scanf("%d%d%d%d%d",&Q,&H,&S,&D,&N);
	H=min(H,Q+Q);
	S=min(S,H+H);
	D=min(D,S+S);
	printf("%lld\n",N/2ll*D+((N&1)*S));
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
int main(){
	long long int n, a[5];
	scanf("%lld", &n);
	for (int i = 0; i < 5; i++){
		scanf("%lld", &a[i]);
	}
	long long int m = *min_element(a, a + 5);
	if (n % m == 0){
		printf("%lld\n", n / m + 4);
	}else{
		printf("%lld\n", n / m + 5);
	}
}

Measured memory_bytes: 128
<?php
$s = trim(fgets(STDIN));

if ($s === "Sunny") {
    echo "Cloudy" . PHP_EOL;
} else if ($s === "Cloudy") {
    echo "Rainy" . PHP_EOL;
} else if ($s === "Rainy") {
    echo "Sunny" . PHP_EOL;
}


Measured memory_bytes: 4728
import java.util.Scanner;

class Main{

public static void main(String[] args){
Scanner stdIn = new Scanner(System.in);
int s = stdIn.nextInt();
if(s >= 0 &&  s <= 1199) 
System.out.println("ABC");

else if(s >=1200 && s <= 2799)
System.out.println("ARC");

else if(s >= 2800 && s <= 4208)
System.out.println("AGC");
}
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define all(v) ((v).begin()),((v).end())
#define rall(v) ((v).rbegin()),((v).rend())
#define clr(v,line) memset(v,line,sizeof(v))
#define endl '\n'
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 <<endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* coma = strchr(names + 1, ',');cerr.write(names, coma - names) << " : " << arg1<<" | ";__f(coma+1, args...);
}
#else
#define trace(...)
#endif
 
void file() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

void fast()
{
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL); cout.tie(NULL);
}

const int MX = 1e5 + 5;

int n, w;

ll u[105], v[105], dp[105][MX];


int main(int argc, char const *argv[])
{
    // file();
    fast();

    cin>>n>>w;

    for (int i = 1; i <= n; ++i)
    {
        cin>>u[i]>>v[i];
    }
    
    clr(dp, 0);

    for (int i = 1; i <= n; ++i)
    {
        for (int j = 1; j <= w; ++j)
        {
            if(j < u[i]) dp[i][j] = dp[i - 1][j];
            else dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - u[i]] + v[i]);
        }
    }
  cout<<dp[n][w];
}

Measured memory_bytes: 82944
//
// Created on 2020/04/22.
//


#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;


int main() {
    int ans = 100;
    int n;
    int a,b;
    cin>>n>>a>>b;
    ans = min(n*a,b);

    cout<<ans<<endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace AtCoder {
    class Program {
        static void Main(string[] args) {
            var S = Console.ReadLine();

            var nowBox = 'R';
            var count = 1;
            var propSList = new List<PropS>();
            // マスを文字、開始index、連続登場回数に分割
            for (int i = 1; i < S.Length; i++) {
                if (S[i] != nowBox) {
                    propSList.Add(new PropS {
                        box = nowBox,
                        index = i - count,
                        count = count
                    });
                    nowBox = S[i];
                    count = 0;
                }
                count++;
            }

            //最後の要素を詰める
            propSList.Add(new PropS {
                box = nowBox,
                index = S.Length - count,
                count = count
            });

            var children = new int[S.Length];
            foreach (var prop in propSList) {
                if (prop.box == 'R') {
                    children[prop.index + prop.count] += prop.count / 2;
                    children[prop.index + prop.count - 1] += prop.count / 2 + prop.count % 2;
                } else if (prop.box == 'L') {
                    children[prop.index] += prop.count / 2 + prop.count % 2;
                    children[prop.index - 1] += prop.count / 2;
                }
            }
            Console.WriteLine(string.Join(" ", children));
        }
    }

    class PropS {
        public char box;
        public int index;
        public int count;
    }
}


Measured memory_bytes: 22364
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
	int N =	sc.nextInt();
	int L =	sc.nextInt();
	String[] a = new String[N];
	for(int i = 0; i<N;i++)	{
            a[i] = sc.next();
	}
	Arrays.sort(a);
	for(String s:a)	{
            System.out.print(s);
	}
	System.out.println();
    }
}

Measured memory_bytes: 23124
let split_string ?(pattern="") = Str.split @@ Str.regexp pattern
let n = Scanf.sscanf (read_line ()) "%d" @@ fun n -> n
let a = read_line () |> split_string ~pattern:" " |> List.map int_of_string |> List.sort compare |> List.rev

let x = List.hd a
let y = List.map (fun i -> (Float.abs (float i -. float x /. 2.), i)) a |> List.sort compare |> List.hd |> snd

let () = Printf.printf "%d %d\n" x y

Measured memory_bytes: 27184
#include<bits/stdc++.h>
#define H 65
using namespace std;
bool used[H][H],used2[H][H],ans;
int dy[4]={-1,0,1,0};
int dx[4]={0,1,0,-1};
int w,h,xmin,xmax;
string s[H];
double l,r;

void dfs(int y,int x){
  used[y][x]=true;
  if(y+1==h||(s[y][x]!=s[y+1][x]&&s[y+1][x]!='.')){
    xmin=min(xmin,x);
    xmax=max(xmax,x);
  }
  for(int i=0;i<4;i++){
    int ny=y+dy[i],nx=x+dx[i];
    if(ny<0||nx<0||h<=ny||w<=nx)continue;
    if(used[ny][nx]||s[y][x]!=s[ny][nx])continue;
    dfs(ny,nx);
  }
}

void dfs2(int y,int x,int idx){
  used2[y][x]=true;
  if(x<=idx)l+=(idx-x+1)-0.5;
  else r+=(x-idx)-0.5;
  for(int i=0;i<4;i++){
    int ny=y+dy[i],nx=x+dx[i];
    if(ny<0||nx<0||h<=ny||w<=nx)continue;
    if(used2[ny][nx])continue;
    if(!i&&s[y][x]!=s[ny][nx]&&s[ny][nx]!='.')dfs2(ny,nx,idx);
    if(s[y][x]==s[ny][nx])dfs2(ny,nx,idx);
  }
}

int check(int y,int x,int idx){
  l=r=0;
  memset(used2,0,sizeof(used2));
  dfs2(y,x,idx);
  if(l>r)return -1;
  if(l<r)return 1;
  return 0;
}

int main(){
  int c=0;
  while(1){
    c++;
    cin>>w>>h;
    if(!w&&!h)break;
    memset(used,0,sizeof(used));
    ans=true;
    for(int i=0;i<h;i++)cin>>s[i];
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	if(s[i][j]!='.'&&!used[i][j]){
	  bool flag=false;
	  xmin=w;
	  xmax=0;
	  dfs(i,j);
	  vector<int> v;
	  for(int k=xmin-1;k<=xmax;k++)
	    v.push_back(check(i,j,k));
	  for(int k=0;k<(int)v.size()-1;k++){
	    int a=xmin-1+k;
	    if(v[k]==1&&v[k+1]==-1)flag=true;
	    if(xmin<=a&&!v[k])flag=true;
	  }
	  if(!flag)ans=false;
	}
      }
    }
    if(ans)cout<<"STABLE"<<endl;
    else cout<<"UNSTABLE"<<endl;
  }
  return 0;
}

Measured memory_bytes: 3208
import sys
from collections import defaultdict, Counter, deque
from itertools import accumulate, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right, bisect
from heapq import heappop, heappush
from fractions import gcd
from math import ceil, floor, sqrt, cos, sin, pi
from copy import deepcopy

# If you use recursive call, uncomment this code
#sys.setrecursionlimit(10**6)

def main():
    N = int(input())
    A = list(map(int, input().split()))
    ans = 1
    threshold = 10**18
    if 0 in A:
        return 0
    for a in A:
        ans *= a
        if ans > threshold:
            return -1
    return ans

if __name__ == '__main__':
    print(main())


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

#整数をばらけさせてリスト化
list_n = list(range(1,n+1))
#print(list_n)

#桁の長さが奇数なら数え上げる
cnt = 0
for i in list_n:
     if (len(str(i)))%2 == 1:
            cnt += 1
     else: pass
print(cnt)

Measured memory_bytes: 6900
S = list(input())
N = len(S)
T = [i for i in S[::-1]]
U = []
for i in range(int((N-1)/2)):
    U.append(S[i])
V = [i for i in U[::-1]]
W = []
for i in range(int((N + 3)/2 -1),N):
    W.append(S[i])
X = [i for i in W[::-1]]
if S != T:
    print('No')
elif U != V:
    print('No')
elif W != X:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 38256
/* Bismillahirrahmanirrahim */
/* Author : Jehian Norman Saviero (@Reiva5) */
#include <bits/stdc++.h>
 
// MACROS SAMPAH
#define Jehian using
#define Norman namespace
#define Saviero std
 
Jehian Norman Saviero;
 
// MACROS TYPE
typedef long l;
typedef long long ll;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<l,l> pl;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<l> vl;
typedef vector<ll> vll;
 
// MACROS FOR PRINT
#define nl printf("\n")
#define sp printf(" ")
 
// MACROS FOR ATTRIBUTE
#define fi first
#define se second
 
// MACROS FOR FUNCTION AND METHOD
#define eb emplace_back
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define ALL(x) (x).begin(), (x).end()
#define ALLN(x,n) (x), (x)+(n)
#define CUBE(x) (SQR(x)*(x))
#define SET(x,y) for (int _qwe = sizeof(x)/sizeof(x[0]); _qwe; ) x[--_qwe] = (y)
#define SQR(x) ((x)*(x))
#define SSORT(x,sz) sort(ALLN(x,sz))
#define RESET(x) memset((x), 0, sizeof(x))
#define VSORT(x) sort(ALL(x))
 
// MACROS READ INPUT
#define sci(x) scanf("%d", &x)
#define scl(x) scanf("%ld", &x)
#define scll(x) scanf("%lld", &x)
#define scul(x) scl(x)
#define scull(x) scll(x)

vi pset;

void initSet(int n) {
	pset.resize(n+1);
	for (int i = 0; i < pset.size(); ++i) {
		pset[i] = i;
	}
}

int findSet(int p) {
	return pset[p] == p ? p : pset[p] = findSet(pset[p]);
}

void joinSet(int u, int v) {
	pset[findSet(u)] = findSet(v);
}

bool isSameSet(int u, int v) {
	return findSet(u) == findSet(v);
}

int main() {
	int N, M;
	sci(N), sci(M);
	initSet(N);
	for (int i = 0; i < M; ++i) {
		int u, v;
		sci(u), sci(v);
		joinSet(u,v);
	}
	int groups[N+1];
	RESET(groups);
	for (int i = 1; i <= N; ++i) {
		++groups[findSet(i)];
	}
	printf("%d\n", *max_element(ALLN(groups, N+1)));
	return 0;
}

Measured memory_bytes: 7864
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>


using namespace std;

#define INF 1000000000
#define EPS 1e-9
#define PI acos(-1)

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

#define MAX_N 8
#define MAX_M 30

int n, m, p, a, b;
vector<int> t;

vector<P> d[MAX_M]; 

vector<double> ans_list;

double solve(){

  double dp[MAX_M][1 << 8];
  bool used[MAX_M][1 << 8];

  for(int i = 0; i < m; i++){
    for(int j = 0; j < 1 << 8; j++){
      dp[i][j] = INF;
      used[i][j] = false;
    }
  }

  dp[a][0] = 0;

  while(true){
    int v = -1;
    int S = -1;
    for(int i = 0; i < m; i++){
      for(int j = 0; j < 1 << n; j++){
	if(!used[i][j] && (v == -1 || dp[v][S] > dp[i][j])){
	  v = i;
	  S = j;
	}
      }
    }

    if(v == -1)
      break;

    used[v][S] = true;

    for(int i = 0; i < d[v].size(); i++){
      int to = d[v][i].first;
      int cost = d[v][i].second;
      for(int j = 0; j < n; j++){
	if(!(S >> j & 1)){
	  dp[to][S | 1 << j] = min(dp[to][S | 1 << j], dp[v][S] + (double)cost/t[j]);
	}
      }
    }

  }

  double tmp = INF;

  for(int i = 0; i < 1 << n; i++){
    tmp = min(tmp, dp[b][i]);
  }
  
  if(tmp != INF)
    return tmp;
  else
    return -1.0;
  
}


int main(){
  
  while(true){
    cin >> n >> m >> p >> a >> b;
    a--;
    b--;
    if(n == 0)
      break;
    vector<int> pre_t;
    for(int i = 0; i < n; i++){
      int tmp;
      cin >> tmp;
      pre_t.push_back(tmp);
    }
    t = pre_t;
    
    vector<P> pre_d[MAX_M];
    for(int i = 0; i < p; i++){
      int from,to,cost;
      cin >> from >> to >> cost;
      from--;
      to--;
      pre_d[from].push_back(P(to,cost));
      pre_d[to].push_back(P(from,cost));
    }
    
    for(int i = 0; i < MAX_M; i++){
      d[i] = pre_d[i];
    }
    
    ans_list.push_back(solve());
    
  }
  
  for(int i = 0; i < ans_list.size(); i++){
    if(ans_list[i] < 0)
      cout << "Impossible" << endl;
    else
      cout << ans_list[i] << endl;
  }
  
  return 0;
  
}

Measured memory_bytes: 1372
#include <iostream>

using namespace std;

int gcd(int a, int b){
	return (b > 0)? gcd(b, a % b) : a ;
}

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

int main(void) {
    int N;
    cin >> N;
    cout << lcm(2, N) << endl;
    return 0;
}


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

int main() {
	int n, m;
	cin >> n >> m;

	if (n < 2 && m < 2) {
		cout << 0 << endl;
		return 0;
	}

	int answer = 0;
	if (n >= 2) {
		answer += n * (n - 1) / 2;
	}
	if (m >= 2) {
		answer += m * (m - 1) / 2;
	}

	cout << answer << endl;
	
	return 0;
}

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

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

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

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

int main(){
    ll s;
    cin >> s;
    int mod = (int)(1e9), y2 = (s+mod-1) / mod, x2 = (ll)y2*mod - s;
    printf("%d %d %d %d %d %d\n", 0, 0, mod, 1, x2, y2);
    return 0;
}


Measured memory_bytes: 3724
import math
import string
import collections
from collections import Counter


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]

n = int(input())
a = [None]*100
a[0] = 2
a[1] = 1
for i in range(2, 100):
    a[i] = a[i-1]+a[i-2]
print(a[n])


Measured memory_bytes: 3896
#include <cstdio>
#include <iostream>
#include <cstring>
#include <utility>
#include <queue>
using namespace std;

int main(){

  int n;
  cin >> n;
  int a[100];
  int b[100];
  int ab[100];
  int c[100];
  int d[100];
  int cd[100];
  int p[100][100];
  for (int i = 0; i < n; i++){
    scanf("%d %d", &a[i], &b[i]);
    ab[i] = 0;
  }
  for (int i = 0; i < n; i++){
    scanf("%d %d", &c[i], &d[i]);
    cd[i] = 0;
  }
  priority_queue<pair<int, int> >q;
  for (int i = 0; i < n; i++){
    for (int j = 0; j < n; j++){
      if (a[i] < c[j] && b[i] < d[j]){
        ab[i] += 1;
        cd[j] += 1;
        p[i][j] = 1;
      } else p[i][j] = 0;
    }
  }

  for (int i = 0; i < n; i++){
    q.push(make_pair(-ab[i], i));
  }
  int count = 0;
  while(!q.empty()){
    pair<int, int> u = q.top(); q.pop();
    int w = u.second;
    int mind = 1000;
    int mini = -1;
    for (int i = 0; i < n; i++){
      if (p[w][i] == 1 && cd[i] != 0){
        if (mind > cd[i]) {
          mind = cd[i];
          mini = i;
        }
        cd[i]--;
      }
    }
    if (mini != -1){
      cd[mini] = 0;
      count++;
    }
  }

  printf("%d\n", count);
  return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String args[]) {
		FastScanner scanner = new FastScanner();
		int n=scanner.nextInt();
		int c=scanner.nextInt();
		int k=scanner.nextInt();
		int[] t=new int[n];
		int[] s=new int[n];
		for(int i=0;i<n;i++) {
			t[i]=scanner.nextInt();
		}
		Arrays.sort(t);
		for(int i=0;i<n;i++) {
			s[i]=t[i]+k;
		}
		int ans=0;
		int j=0;
		for(int i=0;i<n;i++) {
			if(t[i]<=s[j]&&i-j+1<=c)continue;
			j=i;
			ans++;
		}
		System.out.println(ans+1);
	}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}


Measured memory_bytes: 22968
#include<bits/stdc++.h>
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);

	freopen("output.txt", "w", stdout);
#endif

	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

	ll n;
	cin >> n;
	ll a = n%10;
	if(a==3)
	{
		cout<<"bon";
	}
	else if(a==0 || a==1 || a==6 || a==8)
	{
		cout<<"pon";
	}
	else
	{
		cout<<"hon";
	}
}




Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <int,int> PAIR;
const int N = 1e4+5;
const int M = 1e4;
const int INF = 0x3f3f3f3f;

struct node{
	int A,B,C,D;
} p[55];
int n,m,q,ans,a[15];

inline int cal(){
	int res = 0;
	for(int i = 1;i <= q;++i){
		if(a[p[i].B] - a[p[i].A] == p[i].C)
			res += p[i].D;
	}
	return res;
}

inline void dfs(int now,int st){
	if(now > n){
		ans = max(ans,cal());
		return ;
	}
	
	for(int i = st;i <= m;++i){
		a[now] = i;
		dfs(now+1,i);
	}
	return ;
}

int main() {
	scanf("%d%d%d",&n,&m,&q);
	for(int i = 1;i <= q;++i)
		scanf("%d%d%d%d",&p[i].A,&p[i].B,&p[i].C,&p[i].D);
	
	ans = 0;
	dfs(1,1);
	printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 3812
#include<cstdio>

using namespace std;

int main(){
    int h, n;

    scanf("%d %d", &h, &n);

    int a[n];
    for(int i = 0; i < n; i++){
        scanf("%d", &a[i]);
    }
    
    int sm = 0;

    for(int i = 0; i < n; i++){
        sm += a[i];
    }
    
    if (sm >= h) puts("Yes");
    else puts("No");
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define x first
#define y second
using namespace std;
int main()
{   int x;
    cin>>x;
    int hap(0);
    hap+=x/500;
    cout<<hap*1000+((x-hap*500)/5)*5;
    return 0;
}


Measured memory_bytes: 256
n, m, c = map(int, input().split())
b = list(map(int, input().split()))
a = [list(map(int, input().split())) for _ in range(n)]
ans = 0
for i in range(n):
    cnt = 0
    for j in range(m):
        cnt += a[i][j]*b[j]
    if cnt + c > 0:
        ans += 1
print(ans)

Measured memory_bytes: 9196
#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>;

int main() {
    int a, b, h;
    cin >> a >> b >> h;
    cout << (a+b)*h/2 << endl;
    return 0;
}

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

long long pw(int a, int b) 
{
	long long r = a;
	if (b == 0) return 1;
	while (--b) r *= a;
	return r;
}

int main() 
{
	long long n;
	scanf("%lld", &n);
	long long l = 1, r = 26;
	int i = 1;
	while (n > r) {
		++i;
		l = r + 1;
		r = l + pw(26, i) - 1;
	}
	r -= l;
	n -= l;
	long long t = 0;
	for (int j = i - 1; j >= 0; --j) {
		long long p = pw(26, j);
		int amt = 0;
		while (t <= n) {
			t += p;
			++amt;
		}
		t -= p;
		printf("%c", 'a' + amt - 1);
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 1644
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
    int N,M,C;
    cin >> N >> M >> C;
    int ans=0;
    int i,j;
    int A,B[M];
    for(j=0;j<M;j++){
      cin >> B[j];
    }
    int tmp;
    for(i=0;i<N;i++){
      tmp=C;
      for(j=0;j<M;j++){
        cin >> A;
        tmp+=A*B[j];
      }
      if (tmp>0)ans++;
    }
    cout <<ans;
    return 0;
}


Measured memory_bytes: 256
#include<map>
#include<cmath>
#include<ctime>
#include<stack>
#include<queue>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
template<class Read>void in(Read &x){
    x=0;
    int f=0;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        f|=(ch=='-');
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    x=f?-x:x;
    return;
}
string s[10005],c;
int n,ans,a[100005];
int main(){
    in(n);
    for(int i=1;i<=n;i++)cin>>s[i]>>a[i];
    cin>>c;
    for(int i=n;i>=1;i--){
        if(s[i]==c)break;
        ans+=a[i];
    }
    cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 384
#include<cstdio>
#include<sstream>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<algorithm>
#include<set>
#include<queue>
#include<stack>
#include<list>
#include<iostream>
#include<fstream>
#include<numeric>
#include<string>
#include<vector>
#include<cstring>
#include<map>
#include<iterator>
using namespace std;
int main() {
    long long int a,b;
    cin>>a;
    b=a%10;
    if(b==2 || b==4 || b==5 || b==7 ||b==9)
    cout<<"hon\n";
    else if(b==0 || b==1 || b==6 || b==8)
    cout<<"pon\n";
    else cout<<"bon\n";
    return 0;
}

Measured memory_bytes: 3128
//==========================================
// ABC129a
//
// 2019/08/26
//==========================================

#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>

using namespace std;

int main(int argc, char* argv[])
{
  vector<int> p(3);
  for(int i=0; i<3; i++) cin >> p[i];

  sort(p.begin(), p.end());
  cout << p[0]+p[1] << endl;

  return 0;
}

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

using namespace std;

#define ll long long 
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mkp make_pair
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define ff first
#define ss second
#define endl "\n"
#define MOD 1000000007
#define MOD1 998244353
#define inf LLONG_MAX

ll GCD(ll x,ll y){if(y==0)return x;return GCD(y,x%y);}
ll LCM(ll x,ll y){return (x*y)/(GCD(x,y));}
ll LOGK(ll x,ll k){if(x>=k)return 1+LOGK(x/k,k);return 0;}
ll MPOW( ll a, ll b, ll m) { if(b==0) return 1; ll x=MPOW(a,b/2,m); x=(x*x)%m; if(b%2==1) x=(x*a)%m; return x;}
ll MINV(ll a,ll m) {return MPOW(a,m-2,m);}

class pnc{
  ll FACT_MAX,MODU;
  vector<ll> fact;
public:
  pnc( ll n, ll m) { FACT_MAX = n; fact.resize(FACT_MAX); MODU = m; MFACT_INIT(MODU);}
  void MFACT_INIT( ll m) { fact[0]=1; for(ll i=1;i<FACT_MAX;++i) fact[i]=(i*fact[i-1])%MODU;}
  ll MFACT( ll n) { return fact[n];}
  ll PERM( ll n, ll r) { return (fact[n]*::MINV(fact[n-r],MODU))%MODU;}
  ll COMB( ll n , ll r) { return (PERM(n,r)*::MINV(fact[r],MODU))%MODU;}
};

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

    ll test=1;
    //cin>>test;
    while(test--)
    {
        ll n;
        cin>>n;

        ll ar[n];
        ll zero=0;

        for(ll i=0;i<n;i++)
        {
            cin>>ar[i];
            if(ar[i]==0)
            {
                zero=1;
            }
        }

        if(zero)
        {
            cout<<0;
            continue;
        }

        ll ans=1;

        ll check=1e18;

        ll prev=ans;

        for(ll i=0;i<n;i++)
        {
            ans*=ar[i];

            if(ans>check || prev>ans)
            {
                ans=-1;
                break;
            }

            prev=ans;
        }
        
        cout<<ans;
    }
}













Measured memory_bytes: 4424
#include <iostream>
#include <string>
using namespace std;
int main() {
    int a, b;
    cin >> a >> b;
    string ans = "";
    if (a < b) {
        for (int i = 0; i < b; ++i) {
            ans += to_string(a);
        }
    } else {
        for (int i = 0; i < a; ++i) {
            ans += to_string(b);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vec = vector<ll>;
using vecp = vector<P>;
using mat = vector<vec>;
using matp = vector<vecp>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define all(v) v.begin(), v.end()

ll modPow(ll a, ll n) {
  if (n == 0) return 1; // 0乗にも対応する場合
  if (n == 1) return a % MOD;
  if (n % 2 == 1) return (a * modPow(a, n - 1)) % MOD;
  ll t = modPow(a, n / 2);
  return (t * t) % MOD;
}



int main(){
  ll N,K,ans=0;
  cin >> N >> K;
  vec A(K,0);
  for(ll i=K;i>0;i--){
    A.at(i-1)=modPow(K/i,N);
    ll t=2;
    while(i*t<=K){
      A.at(i-1)+=MOD;
      A.at(i-1)-=A.at(i*t-1);
      A.at(i-1)%=MOD;
      t++;
    }
  }
  rep(i,K){
    ans+=(i+1)*A.at(i);
    ans%=MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3972
// AC -> Aizu CGL 4B

#include <bits/stdc++.h>

#define forn(i,n) for(int i = 0; i < int(n); i++)
#define forsn(i,s,n) for(int i = int(s); i < int(n); i++)
#define dforn(i,n) for (int i = int(n)-1; i >= 0; i--)
#define dforsn(i,s,n) for(int i = int(n)-1; i >= int(s); i--)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define fst first
#define snd second
#define FAST_IO ios::sync_with_stdio(false);cin.tie(nullptr);

using namespace std;
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> ii;

const double EPS = 1e-6; // margin of error

struct pt {
    double x,y;
    pt(double x, double y) : x(x),y(y){}
    pt(){}

    double norm2() {return (*this) * (*this);} // modulo of vector, squared
    double norm() {return sqrt(norm2());}
    pt operator* (const double &t) const {return pt(x*t,y*t);}
    pt operator- (const pt &o) const {return pt(x-o.x, y-o.y);}
    double operator% (const pt &o) const {return x*o.y - y*o.x;} // cross product
    double operator* (const pt &o) const {return x*o.x + y*o.y;} // dot product
    bool operator< (const pt &o) const { // chull sort cmp
        return (x < o.x || (x == o.x && y < o.y));
    }
    bool left (const pt &a, const pt &b) {return (b-a)%(*this-a) >= 0;}
};

vector<pt> chull (vector<pt> &p) {
    vector<pt> r;
    sort(all(p));
    forn (i,p.size()) { // lower hull
        while (r.size() >= 2 and r.back().left(r[r.size()-2],p[i])) r.pop_back();
        r.pb(p[i]);
    }
    r.pop_back(); int k = r.size();
    dforn (i,p.size()) { // upper hull
        while (r.size() >= k+2 and r.back().left(r[r.size()-2],p[i])) r.pop_back();
        r.pb(p[i]);
    }
    r.pop_back();
    return r;
}

struct poly {
    int n; vector<pt> p;
    poly(){}
    poly(vector<pt> _p) {p=_p; n=p.size();}

    double callipers() { // returns square of max dist
        double r = 0;
        int j = (n >= 2); // doesn't exist if there's no such pair of points
        forn (i,j) {
            for(;;j=(j+1)%n) {
                r = max(r,(p[i]-p[j]).norm2());
                if ( ((p[(i+1)%n] - p[i]) % (p[(j+1)%n] - p[j])) <= 0) break;
            }
        }
        return r;
    }
};

vector<pt> p;

int main() {
    FAST_IO;

    int n; cin >> n;

    forn (i,n) {
        double x,y; cin >> x >> y;
        p.pb({x,y});
    }

    cout << setprecision(10) << sqrt(poly(chull(p)).callipers());

    return 0;
}

/// ESCRIBÍ en vez de tanto dar vueltas
/// si te parece que no va PROBALO PRIMERO!
/// CODEA LO BÁSICO PRIMERO!
/// HACE C-A-S-O-S D-E P-R-U-E-B-A.A.A.A.A!!!



Measured memory_bytes: 5076
#include <iostream>
#include <vector>
using namespace std;
const long long int mod = 1e9+7;
long long dfs(int K, const vector<vector<int>> &tree, int now, int from) {

  int can_use_color_num;
  if (from == -1) {
    can_use_color_num = K - 1;
  } else {
    can_use_color_num = K - 2;
  }

  if (K < tree[now].size()) {
    return 0;
  }
  else {
    long long int case_num=1;
    for (auto e : tree[now]) {
      if (e == from) continue;
      case_num *= can_use_color_num;
      can_use_color_num--;
      case_num %= mod;
    }
    for (auto e : tree[now]) {
      if (e==from) continue;
      case_num *= dfs(K, tree, e, now);
      case_num %= mod;
    }
    return case_num;
  }
}



int main() {
  int N, K;
  cin >> N >> K;

  vector<vector<int>>tree(N);

  for (int i = 0; i < N - 1; ++i) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;

    tree[a].push_back(b);
    tree[b].push_back(a);
  }

  long long int answer = K*dfs(K, tree, 0, -1);
  answer %= mod;
  cout << answer << endl;
  return 0;
}

Measured memory_bytes: 11520
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#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 all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int DIV = 1e9+7;

int n;
vi a;

int main()
{
    cin >> n; a.resize(n);
    rep(i, n) cin >> a[i];

    int ans = 0;
    rep(i, n){
        int val = a[i];
        while(val % 2 == 0){
            ans++;
            val /= 2;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 892