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


#define int  long long
#define rep(i,begin,end) for(__typeof(end)i=(begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
// rep(i,1,10) is from 1 to 9 and rep(I,10,1) is from 9 to 1
#define repn(i,a,b)   for(int i=a;i>=b;i--)
#define F first
#define S second
#define sz(x) ((int)x.size())
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define pf push_front
#define eb emplace_back //FASTER THAN PUSH BACK!
#define all(v) (v).begin(), (v).end()
#define mod 1000000007
#define mi multiset<int>
#define mii multiset<pii>
#define what_is(x) cerr << #x << " is " << x <<"\n";
#define sortA(v) sort(v.begin(), v.end())
#define sortD(v) sort(v.rbegin(), v.rend())
#define PI 3.14159265358979323846
#define vout(a) for(auto x:a) cout<<x<<" ";

// #define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>


// using namespace __gnu_pbds;
using namespace std;

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

int modp(int a,int n)
{
    if(n==0) return 1;
    if(n==1) return a;
    int res=modp(a,n/2);
    if(n%2==0) return (res*res);
    else return (a*res*res);
}



void solve()
{
    int t,n,m,i,k,l,r,u,v,w,j,s,sum=0,pos=-1,flag=0,count=0;
    string S,T,U;
    // int a,b;
    cin>>n>>k;
    vi a(n+1,0);
    rep(i,1,k+1)
    {
        cin>>t;
        while(t--)
        {
            cin>>m;
            a[m]++;
        }
    }
    rep(i,1,n+1)
    {
        if(!a[i]) count++;
    }
    cout<<count;
}


signed main()
{
    #ifndef ONLINE_JUDGE 
       freopen("input.txt","r",stdin);
       freopen("output.txt","w",stdout);
    #endif
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--)
    {
        solve();
        cout<<"\n";
    }
    return 0;
}


Measured memory_bytes: 3652
#include <iostream>
using namespace std;
const int MAX=100;
int main(){
    int n,t[MAX],m,p[MAX],x[MAX];
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>t[i];
    }
    
    cin>>m;
    for(int i=0;i<m;i++){
        cin>>p[i];
        cin>>x[i];
    }
    
    int sum=0;
    for(int i=0;i<n;i++){
        sum+=t[i];
    }
    int index;
    for(int i=0;i<m;i++){
        index=p[i]-1;
        cout<<sum-t[index]+x[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdio>
#define N 100005
using namespace std;
const int Mod = 1e9 + 7;

int n;
long long f[N][2];
int tot = 0, fir[N], nxt[N << 1], to[N << 1];

inline void addEdge(int u, int v) {
    nxt[++tot] = fir[u], fir[u] = tot, to[tot] = v;
}

inline void dfs(int u, int p) {
    int cnt = 0;
    f[u][0] = f[u][1] = 1;
    for (int i = fir[u], v; i; i = nxt[i]) {
        v = to[i]; if (v == p) continue;
        ++cnt; dfs(v, u);
        (f[u][0] *= f[v][0] + f[v][1]) %= Mod;
        (f[u][1] *= f[v][0]) %= Mod;
    }
}

int main() {
#ifdef whyqx
    freopen("work.in", "r", stdin);
    freopen("work.out", "w", stdout);
#endif
    cin >> n;
    for (int i = 1, u, v; i < n; ++i)
        scanf("%d%d", &u, &v),
        addEdge(u, v), addEdge(v, u);
    dfs(1, 0);
    cout << (f[1][0] + f[1][1]) % Mod;
    return 0;
}


Measured memory_bytes: 6528
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
using namespace std;

#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define triplerep(i,j,k,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)

#define scnd1(a) scanf("%d", &a)
#define scnd2(a,b) scanf("%d%d", &a,&b)
#define scnd3(a,b,c) scanf("%d%d%d", &a,&b,&c)
#define scnd4(a,b,c,d) scanf("%d%d%d%d", &a,&b,&c,&d)

#define prtd1(a) printf("%d\n", a)
#define prtd2(a,b) printf("%d %d\n", a,b)
#define prtd3(a,b,c) printf("%d %d %d\n", a,b,c)
#define prtd4(a,b,c,d) printf("%d %d %d %d\n", a,b,c,d)

#define mem(a,n) memset( a, n, sizeof(a))

typedef long long ll;

int K;
string s;

void dfs(string st) {
    
    for( char  c = 'a'; c <= 'z'; c++) {
        if (s.find(st+c) != string::npos) {
           if ( --K == 0 ) {
               cout << st+c << endl;
               return;
           }
           if(K<=0) return;
           dfs(st+c);
        }
    }
}

int main(void){
    
    cin >> s >> K;
    
    dfs("");
}


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

using namespace std;

int main() {
	int N, K;
	cin >> N >> K;
	
	int ans = K;  // 2^32 - 1

	for (int i = 1; i < N; i++) {
		ans *= (K - 1);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
using namespace std;
#define DEBUG(x) cout<<#x<<"="<<x<<endl
#define DEBUG2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
typedef long long ll;
const int MAXN=3e3+10;
int n,t;
int a[MAXN];
int b[MAXN];
int dp1[MAXN][MAXN];
int dp2[MAXN][MAXN];
int main()
{
    // freopen("in.txt","r",stdin);
    ios::sync_with_stdio(false);
    cin>>n>>t;
    for(int u=1;u<=n;u++){
        cin>>a[u]>>b[u];
    }
    for(int u=1;u<=n;u++){
        for(int tm=1;tm<=t-1;tm++){
            dp1[u][tm]=dp1[u-1][tm];
            if(tm>=a[u])
            dp1[u][tm]=max(dp1[u][tm],dp1[u-1][tm-a[u]]+b[u]);
        }
        int v=n-u+1;
        for(int tm=1;tm<=t-1;tm++){
            dp2[v][tm]=dp2[v+1][tm];
            if(tm>=a[v])
            dp2[v][tm]=max(dp2[v][tm],dp2[v+1][tm-a[v]]+b[v]);
        }
    }
    int ans=0;
    for(int u=1;u<=n;u++){
        for(int tm=0;tm<=t-1;tm++)
        ans=max(ans,dp1[u-1][tm]+dp2[u+1][t-1-tm]+b[u]);
    }
    cout<<ans<<"\n";
}

Measured memory_bytes: 70912
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  long long int a,b,x;
  cin>>a>>b>>x;
  
  long long int d=min(b-1,x);
  cout<<(a*d)/b;
  

}

Measured memory_bytes: 3648
n = input()
ans = 0
for i in range(len(n)):
    tmp = [9]*len(n)
    for j in range(9, -1, -1):
        tmp[i] = j
        s = int(''.join(map(str, tmp)))
        if s <= int(n):
            ans = max(ans, sum(map(int, str(s))))
            break
print(ans)

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

using std::string;
using std::vector;
using std::cin;
using std::cout;
using std::endl;

using Tuple = std::tuple<string, int, int>;

bool compare(const Tuple& t1, const Tuple& t2)
{
  const auto& s1 = std::get<0>(t1);
  const auto& s2 = std::get<0>(t2);
  const auto& p1 = std::get<1>(t1);
  const auto& p2 = std::get<1>(t2);
  if (s1 != s2) {
    return s1 < s2;
  } else {
    return p1 > p2;
  }
}

void solve(void)
{
  int N; cin >> N;
  vector<Tuple> A{};
  for (int i = 1; i <= N; ++i) {
    string s; cin >> s;
    int p; cin >> p;
    A.push_back(Tuple{s, p, i});
  }
  std::sort(A.begin(), A.end(), compare);

  for (const auto& a : A) {
    cout << std::get<2>(a) << endl;
  }

  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)


class UF_tree:
    def __init__(self, n):
        self.root = [-1] * (n + 1)  # -1ならそのノードが根,で絶対値が木の要素数
        self.rank = [0] * (n + 1)

    def find(self, x):  # xの根となる要素番号を返す
        if self.root[x] < 0:
            return x
        else:
            self.root[x] = self.find(self.root[x])
            return self.root[x]

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

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        elif self.rank[x] < self.rank[y]:
            self.root[y] += self.root[x]
            self.root[x] = y
        else:
            self.root[x] += self.root[y]
            self.root[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def getNodeLen(self, x):
        return -self.root[self.find(x)]


if __name__ == "__main__":
    N, M = map(int, input().split())
    AB = tuple(tuple(map(int, input().split())) for _ in range(M))
    score = N * (N - 1) // 2

    ans = [score]
    uf = UF_tree(N)
    for a, b in AB[::-1]:
        if uf.isSame(a, b):
            ans.append(score)
            continue
        x = uf.getNodeLen(a)
        y = uf.getNodeLen(b)
        uf.unite(a, b)
        score -= x * y
        ans.append(score)
    ans.reverse()
    print(*ans[1:], sep="\n")

Measured memory_bytes: 25576
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "No" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl

signed main(void){
    int N,Q,K[100];
    string S;
    cin >> N >> S >> Q;
    REP(i,Q){
        cin >> K[i];
    }
    
    int D[1114514]={},M[1114514]={};
    REP(i,N){
        if(S[i]=='D'){D[i]++;}
        if(S[i]=='M'){M[i]++;}
        if(i!=0){
            D[i]+=D[i-1];
            M[i]+=M[i-1];
        }
        
    }
    
    REP(_,Q){
        int k=K[_];
        int A=0,C=0;
        REP(i,N){
            if(S[i]=='M'){if(i>=k){A-=D[i-k];}if(i!=0){A+=D[i-1];}}
            if(S[i]=='C'){C+=A;}
            if(i-k+1>=0 && S[i-k+1]=='D'){A+=M[i-k+1];if(i!=0){A-=M[i];}}
        }
        cout << C << endl;
    }
    return 0;
}



Measured memory_bytes: 18820
#include <bits/stdc++.h>
using namespace std;
# define ll long long
//knapsack
struct item{
    int wt,val;
};
ll solve(vector<item> ar, int n, int W){
    ll dp[n+1][W+1];
    for(ll w=0;w<=W;w++){
        dp[1][w] = 0;
    }
    dp[1][ar[1].wt] = ar[1].val;
    for(ll i=2;i<=n;i++){
        for(ll w=0;w<=W;w++){
            dp[i][w] = dp[i-1][w];
            if(ar[i].wt > w){
                continue;
            }
            dp[i][w] = max(dp[i][w], ar[i].val + dp[i-1][w-ar[i].wt]);
        }
    }
    return *max_element(dp[n], dp[n] + W + 1);
}
int main() {
	ll n, w;
	cin>>n>>w;
	vector<item> ar(n+1);
	for(ll i=1;i<=n;i++){
	    cin>>ar[i].wt>>ar[i].val;
	}
	cout<<solve(ar, n, w);
	
	return 0;
}


Measured memory_bytes: 81704
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) noexcept {
  return std::vector<T>(n, std::forward<T>(val));
}

template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) noexcept {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}

template<class T, class Cond>
struct chain {
  Cond cond; chain(Cond cond) : cond(cond) {}
  bool operator()(T& a, const T& b) const {
    if(cond(a, b)) { a = b; return true; }
    return false;
  }
};
template<class T, class Cond>
chain<T, Cond> make_chain(Cond cond) { return chain<T, Cond>(cond); }

int main() {
  i64 a, b, c, d;
  cin >> a >> b >> c >> d;
  i64 A = (c + b - 1) / b;
  i64 B = (a + d - 1) / d;
  if(A <= B) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define pii pair<ll,ll>
#define inf 1000000000000000000
#define bpc(x) __builtin_popcountll(x)
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());

#define N 300005

ll que(ll st[], ll l, ll r, ll l1, ll r1, ll i)
{
    if(l>r1 || l1>r || l1>r1)
        return 0;
    if(l>=l1 && r<=r1)
        return st[i];
    ll mid = (l+r)/2;
    
    return max(que(st,l,mid,l1,r1,2*i+1),que(st,mid+1,r,l1,r1,2*i+2));
}
 
void upd(ll st[], ll l, ll r, ll l1, ll i, ll val)
{
    if(l>l1||r<l1)
        return;
    if(l == r)
    {
        st[i] = max(val,st[i]);
        return;
    }
    
    ll mid = (l+r)/2;
    upd(st,l,mid,l1,2*i+1,val);
    upd(st,mid+1,r,l1,2*i+2,val);
    
    st[i] = max(st[2*i+1], st[2*i+2]);
}

int main()
{
  FAST/**/
   
   ll n,k;
   cin>>n>>k;
   
   ll arr[n];
   rep(n)
        cin>>arr[i];
   
   ll lim = N;
   ll ht = ceil(log2(lim));
   ht = (1ll<<(ht+1)) - 1;
   ll st[ht];
   memset(st,0,sizeof(st));
   
   rep(n)
   {
       ll q = que(st,0,lim-1,max(0ll,arr[i]-k),min(lim-1,arr[i]+k),0)+1;
       //cout<<"q = "<<q<<'\n';
       upd(st,0,lim-1,arr[i],0,q);
   }
   
   cout<<st[0];
   
   return 0;        
}  

  
          
   

Measured memory_bytes: 14164
package main

import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)

	fmt.Print(getStr(a, b))
}

func getStr(a, b int) string {
	var s string
	if a > b {
		tmp := fmt.Sprintf("%d", b)
		for i := 1; i <= a; i++ {
			s += tmp
		}
	} else {
		tmp := fmt.Sprintf("%d", a)
		for i := 1; i <= b; i++ {
			s += tmp
		}
	}
	return s
}

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

bool is_prime(int x) {
	bool prime = true;
	for (int i = 2; i <= sqrt(x); i++) {
		if (x % i == 0) prime = false;
	}
	return prime;
}

int main() {
	int x; cin >> x;
	bool flag = false;
	while (!flag) {
		if (is_prime(x)) flag = true;
		if (!flag) x++; 
	}
	cout << x << endl;
}

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

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

int main(void)
{
    int n; cin>>n;
    int x=n%10;
    switch(x)
    {
    case 3: cout<<"bon"<<endl;
            break;
    case 0:
    case 1:
    case 6:
    case 8: cout<<"pon"<<endl;
            break;
    default: cout<<"hon"<<endl;
            break;
    }
    return 0;
}

Measured memory_bytes: 3564
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define REP(i, b, n) for (Int i = b; i < Int(n); i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;
using Int = long long;
Int inf = 1000000000000000001LL;
using vi = vector<Int>;
using vvi = vector<vi>;
using mapis = unordered_map<Int,string>;
using mapii = unordered_map<Int,Int>;
using pii = pair<Int,Int>;

Int GCD(Int a, Int b){
    if(b==0) return a;
    if(a < b) return GCD(b, a);
    unsigned r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}
Int printX(Int r, Int D, Int X, int count){
    if(count == 10){
        return 0;
    }
    Int nextX = r*X - D;
    cout<< nextX <<endl;
    printX(r,D,nextX,count+1);

}

int myPow(int x, int p) {
    if (p == 0) return 1;
    if (p == 1) return x;
    return x * myPow(x, p-1);
}

int main() {
    string s,ans;
    ans = "Yes";
    cin >> s;

    vector<char> odd;
    vector<char> even;
    rep(i,s.size()){
       if( (i+1)%2 == 0 ){
           even.push_back(s[i]);
       }else{
           odd.push_back(s[i]);
       }
    }

    rep(i,even.size()){
        if(even[i] == 'R'){
            ans = "No";
        }
    }

    rep(i,odd.size()){
        if(odd[i] == 'L'){
            ans = "No";
        }
    }


    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#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 n;
  cin >> n;
  int a = n%1000;
  if(a==0) {
    cout << 0 << endl;
    return 0;
  }
  cout << 1000 - a  << endl;

}

Measured memory_bytes: 3640
#include <iostream>
using namespace std;
typedef long long ll;
ll dp[4000][4000],n,a,b,ans,x;
ll f(ll a,ll b,ll cnt){
    if(a==b&&cnt%2==0)return 0;
    if(dp[a][b]>0&&cnt%2==1)return dp[a][b];
    if(cnt%2==1){
        x=max(f(a+1,b,cnt+1)+dp[a][a],f(a,b-1,cnt+1)+dp[b][b]);
        dp[a][b]=x;
        return x;
    }
    else{
        if(dp[a][a]>dp[b][b])x=f(a+1,b,cnt+1);
        else x=f(a,b-1,cnt+1);
        dp[a][b]=x;
        return x;
    }
}
int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a;
        dp[i][i]=a;
        dp[i+n][i+n]=a;
    }
    for(int i=0;i<n;i++){
        ans=max(ans,dp[i][i]+f(i+1,i+n-1,0));
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 65084
function Main(input) {
    var N = parseInt(input[0], 10);
    var P = input[1].split(/\s/).map(p => parseInt(p, 10))

    var min = P[0];
    var result = 0;

    for (var i = 0; i < N; i++) {
        if (min >= P[i]) {
            result++;
            min = P[i];
        }
    }

    console.log(result);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n/));

Measured memory_bytes: 33364
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
  string S;
  cin >> S;
  vector<int> A(3);
  vector<char> B={'a','b','c'};
  for (int i=0; i<3; i++) {
    for (int j=0; j<3; j++) {
      if (S[i] == B[j]) {
        A[j]++;
      }
    }
  }
  int cnt = 0;
  for (int i=0; i<3; i++) {
    if (A[i] == 1) {
      cnt++;
    }
  }
  if (cnt == 3) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>

using namespace std;

int main() {

	//幹線道路

	int h, w;
	cin >> h >> w;

	int A[100][100];
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> A[i][j];
		}
	}

	int ans = 999999;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			int temp = 0;
			for (int k = 0; k < h; k++) {
				for (int l = 0; l < w; l++) {
					temp += A[k][l] * min(abs(i - k), abs(j - l));
				}
			}
			ans = min(temp, ans);
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3136
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
	int K; cin >> K;
	cout << (K / 2) * ((K + 1) / 2) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  long long mul=1;
  long long a[n];
  long long z = 0;
  for(int i=0;i<n;i++) {
    cin>>a[i];
    if(a[i]==0) z =1;
  }
  if(z==1){
    cout<<0;
    return 0;
  }
  for(int i=0;i<n;i++){
    if(a[i]<=1000000000000000000/mul){
    	mul*=a[i];
    }
    else{
   		cout<<-1;
        return 0;
    }
  	
    
  }
  cout<<mul;
}
    


Measured memory_bytes: 4392
#define ENABLE_DEBUG 1
// Kana's kitchen {{{
#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
#define LOOP(k) for(i64 ngtkana_is_a_genius=0; ngtkana_is_a_genius<(i64)k; ngtkana_is_a_genius++)

using i32 = std::int_least32_t;
using i64 = std::int_least64_t;
using u32 = std::uint_least32_t;
using u64 = std::uint_least64_t;
using usize = std::size_t;

template <class T, class U> using pair = std::pair<U, T>;
template <class T> using diag_pair = std::pair<T, T>;
template <class... Args> using tuple = std::tuple<Args...>;
template <class T> using vec = std::vector<T>;
template <class T> using numr = std::numeric_limits<T>;

#ifdef NGTKANA
#include<debug.hpp>
#else
#define DEBUG(...)(void)0
#endif
/*}}}*/

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::setprecision(15) << std::fixed;

    std::string s;
    std::cin >> s;
    usize n=s.length();
    usize l=n, r=0;
    for (usize i=0; i<n; i++) if (s.at(i)=='Z') r = i;
    for (usize i=n-1; i!=-1; i--) if (s.at(i)=='A') l = i;
    std::cout << r-l+1 << '\n';
}


Measured memory_bytes: 720
using System;
using System.Collections.Generic;
using System.Linq;

class Pg
{
    static void Main()
    {
        var c = new Calq();
        string line;
        while ((line = Console.ReadLine()) != null)
        {
            var n = double.Parse(line);
            Console.WriteLine(c.Cal(n).Sum());
        }
    }
}
class Calq
{
    const int MAX = 10;
    internal List<double> Cal(double n)
    {
        var Sum = new List<double> { n };
        for (int i = 2; i <= MAX; ++i)
        {
            if (i % 2 == 1)
            {
                n /= 3;
            }
            else
            {
                n *= 2;
            }
            Sum.Add(n);
        }
        return Sum;
    }
}


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

int main () {
    int a, b;
    cin >> a >> b;
    while (0 <= a <= b <= 20){
        if (b%a==0){
            cout << a+b;
            break;
        } else {
            cout << b-a;
            break;
    }
    }
    return 0;
}

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

int main() {
  long long int q,h,s,d,n,x,y,ans;
  cin>>q>>h>>s>>d>>n;
  x=min(8*q,min(4*h,min(2*s,d)));
  y=min(4*q,min(2*h,s));

  ans=(n/2)*x+(n%2)*y;
  cout<<ans<<endl;
}

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

ans = 1

if 0 in A:
    print(0)
else:
    flag = 0

    for i in range(N):
        ans *= A[i]
        if(ans > 10**18):
            print(-1)
            flag = 1
            break

    if flag == 0:
        print(ans)


Measured memory_bytes: 21652
if __name__ == '__main__':
   n, m = map(int,input().split())
   a = set([int(input()) for i in range(m)])

   MOD = 1000000007

   dp = [0 for i in range(n+1)]
   dp[0] = 1
   if 1 in a:
      dp[1] = 0
   else:
      dp[1] = 1

   for i in range(2,n+1):
      if (i-1 in a) and (i-2 in a):
         dp[i] = 0
      elif i-1 in a:
         dp[i] = dp[i-2] % MOD
      elif i-2 in a:
         dp[i] = dp[i-1] % MOD
      else:
         dp[i] = (dp[i-1] + dp[i-2]) % MOD

   print(dp[n])


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

int main() {
long int n,w;
cin>>n>>w;
long int p[n],wt[n];
for(int i=0;i<n;i++){
    cin>>wt[i]>>p[i];
}
long long int dp[n+1][w+1];
for(int i=0;i<=n;i++){
    for(int j=0;j<=w;j++){
        if(i==0||j==0){
            dp[i][j]=0;
        }
        else if(wt[i-1]<=j){
            dp[i][j]=max(p[i-1]+dp[i-1][j-wt[i-1]],dp[i-1][j]);
        }
        else{
            dp[i][j]=dp[i-1][j];
        }
    }
}
cout<<dp[n][w];
	return 0;
}


Measured memory_bytes: 82484
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <iomanip>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <sstream>
#include <complex>

using namespace std;

using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
using vvi = vector<vi>;
using iii = pair<int, ii>;
using viii = vector<iii>;

using ll = long long int;
using vc = vector<char>;
using vb = vector<bool>;
using ib = pair<int, bool>;
using vib = vector<ib>;

#define MOD 1000 * 1000 * 1000 + 7
#define INF 1000 * 1000 * 1000
#define EMPTY -10
#define mp(a, b) make_pair(a,b)

bool resuelveCaso() {
	int n;
	cin >> n;
	if (!cin) return false;
	int m;
	cin >> m;


	vvi mat(n, vi(m));
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < m; ++j) {
			cin >> mat[i][j];
		}
	}


	vi sol;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < m; ++j) {
			if (mat[i][j] % 2 == 0) {}
			else {
				if (j != m - 1) {
					sol.push_back(i);
					sol.push_back(j);
					sol.push_back(i);
					sol.push_back(j + 1);
					--mat[i][j];
					++mat[i][j + 1];
				}
				else if (j == m - 1 && i != n - 1) {
					sol.push_back(i);
					sol.push_back(j);
					sol.push_back(i + 1);
					sol.push_back(j);
					--mat[i][j];
					++mat[i + 1][j];
				}
			}
		}
	}

	cout << sol.size() / 4 << '\n';
	for (int i = 0; i < sol.size(); ++i) {
		if (i == 0) {}
		else if (i % 4 == 0) cout << '\n';
		else cout << ' ';
		cout << sol[i] + 1;
	}
	cout << '\n';

	return true;
}

int main() {
	while (resuelveCaso()) {}
	return 0;
}

Measured memory_bytes: 5232
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <iomanip>
#include <numeric>
 
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
ll N,K;
ll m;
string S,T;
ll d;
ll ans;
ll A[10000001];
ll B[10000001];
vector<ll> so;

int main() {
    for(int i=2;i<4000;i++){
        bool found = false;
        for(int j=0;j<so.size();j++){
            if(i%so[j]==0){
                found = true;
            }
        }
        if(!found){
            so.push_back(i);
        }
    }
    cin >> N;
    for(ll i=1;i<=N;i++){
        A[i] = 1;
        B[i] = i;
    }
    for(int j=0;j<550;j++){
        ll i=0;
        i += so[j];
        while(i<=N){
            ll k = 0;
            while(B[i]%so[j]==0){
                B[i]/=so[j];
                k++;
            }
            A[i] *= (k+1);
            i += so[j];
        }
    }
    for(ll i=1;i<=N;i++){
        if(B[i]!=1){
            A[i]*=2;
        }
        ans += i*A[i];
        
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 159876
N = int(input())
def dfs(s):
    if int(s) > N:
        return 0
    else:
        if '7' in s and '5' in s and '3' in s:
            ret = 1
        else:
            ret = 0
        for i in '357':
            ret += dfs(s + i)
        return ret
print(dfs("0"))

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

import sys

sys.setrecursionlimit(10 ** 6)


S = input()

res = 0
if S == 'RSS' or S == 'SRS' or S == 'SSR' or S == 'RSR':
    res = 1
elif S == 'RRS' or S == 'SRR':
    res = 2
elif S == 'RRR':
    res = 3

print(res)


Measured memory_bytes: 61580
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }




int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int h, w;
    cin >> h >> w;
    
    char c[h][w];
    rep(i, h) rep(j, w) cin >> c[i][j];
    
    int table[h][w];
    {
        rep(i, h) rep(j, w) table[i][j] = 0;
        
        rep(i, h) rep(j, w) {
            if (c[i][j] == '.') {
                if (j == 0 || c[i][j - 1] == '#') table[i][j] = 1;
                else {
                    table[i][j] = table[i][j - 1] + 1;
                }
            }
        }
        rep(i, h) for (int j = w - 2; j >= 0; --j) {
            if (c[i][j] == '#') continue;
            chmax(table[i][j], table[i][j + 1]);
        }
        // rep(i, h) { rep(j, w) cout << table[i][j] << " "; cout << endl; }
        
    }
    
    int table2[h][w];
    {
        rep(i, h) rep(j, w) table2[i][j] = 0;
        
        rep(j, w) rep(i, h) {
            if (c[i][j] == '.') {
                if (i == 0 || c[i - 1][j] == '#') table2[i][j] = 1;
                else {
                    table2[i][j] = table2[i - 1][j] + 1;
                }
            }
        }
        rep(j, w) for (int i = h - 2; i >= 0; --i) {
            if (c[i][j] == '#') continue;
            chmax(table2[i][j], table2[i + 1][j]);
        }
        // rep(i, h) { rep(j, w) cout << table2[i][j] << " "; cout << endl; }
        
    }
    rep(i, h) rep(j, w) table[i][j] += table2[i][j];
    rep(i, h) rep(j, w) table[i][j]--;
    // rep(i, h) { rep(j, w) cout << table[i][j] << " "; cout << endl; }
    int ans = 0;
    rep(i, h) rep(j, w) chmax(ans, table[i][j]);
    cout << ans << endl;
}


Measured memory_bytes: 35456
def main():
    N=input()
    A=list(map(int, input().split()))

    mod_value = 10**9 + 7
    sum_ = 0
    b_sum = 0
    for i in range(len(A)-1):
        b_sum = b_sum + A[len(A)-i-1]
        sum_ = sum_ + (A[len(A)- i - 2]*b_sum) % mod_value
    print(sum_%mod_value)
main()

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

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

	vector<double> x(N);
	vector<string> u(N);
	double ans = 0;

	for (int i = 0; i < N; i++) {
		cin >> x.at(i) >> u.at(i);
	}

	for (int i = 0; i < N; i++) {
		if (u.at(i) == "BTC") {
			ans += x.at(i) * 380000;
		}
		else {
			ans += x.at(i);
		}
	}

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

Measured memory_bytes: 256
# frozen_string_literal: true

n = gets.to_i
a = gets.split.map(&:to_i)
a.push 0
m = 1000
k = 0
(0..(n-1)).each do |i|
  if a[i] < a[i + 1]
    dk = m / a[i]
    m -= dk * a[i]
    k += dk
  elsif a[i] > a[i + 1]
    dk = k
    m += dk * a[i]
    k -= dk
  end
end
puts m


Measured memory_bytes: 14312
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <stack>
#include <vector>
#include <set>
#include <queue>
#define maxn 50005
#define MAXN 200005
#define mod 1000000007
#define INF 0x3f3f3f3f
#define eps 1e-6
const double pi=acos(-1.0);
typedef long long ll;
using namespace std;

int n,w;
int len[maxn],sum[maxn];
bool dp[maxn];

bool isok(int mid)
{
    int i,j,last=0;
    memset(dp,0,sizeof(dp));
    dp[0]=1;
    if(sum[n]+n-1<=w) return true ;
    for(i=0; i<n-1; i++)
    {
        if(!dp[i]) continue ;
        for(j=max(i+2,last); j<=n; j++)
        {
            if(w<sum[j]-sum[i]+j-i-1) break ;
            if(w>sum[j]-sum[i]+ll(j-i-1)*mid) continue ;
            last=j;
            dp[j]=1;
            if(sum[n]-sum[j]+n-j-1<=w) return true ;
        }
    }
    return false ;
}
void solve()
{
    int i,j,le=1,ri=w,mid,ans;
    while(le<=ri)
    {
        mid=(le+ri)>>1;
        if(isok(mid))
        {
            ans=mid;
            ri=mid-1;
        }
        else le=mid+1;
    }
    printf("%d\n",ans);
}
int main()
{
    int i,j;
    while(~scanf("%d%d",&w,&n))
    {
        if(w==0&&n==0) break ;
        sum[0]=0;
        for(i=1; i<=n; i++)
        {
            scanf("%d",&len[i]);
            sum[i]=sum[i-1]+len[i];
        }
        solve();
    }
    return 0;
}
/*
11 4
4 2 1 3
5 7
1 1 1 2 2 1 2
11 7
3 1 3 1 3 3 4
100 3
30 30 39
30 3
2 5 3
0 0
*/

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

using namespace std;

#define fr first
#define sc second
#define mp make_pair

typedef long long int64;
typedef pair< int, int > iP;
typedef pair< iP, int > iiP;

const int INF = 2 << 28;
const double EPS = 1e-10;

struct disk {
    int x, y, r, color;
};

int n;
map< int, int > dp;
vector< disk > disks;

int rec(int used) {
    if(dp[used]) return dp[used];
    vector< int > idx;
    for(int i = n - 1; i >= 0; i--) {
        if(!(used >> i & 1)) {
            bool judge = true;
            for(int j = i - 1; j >= 0; j--) {
                if(!(used >> j & 1)) {
                    if(pow(abs(disks[i].x - disks[j].x), 2) + pow(abs(disks[i].y - disks[j].y), 2) < pow(disks[i].r + disks[j].r, 2))
                        judge = false;
                }
            }
            if(judge) idx.push_back(i);
        }
    }

    int ret = 0;
    if(idx.size() < 2) return 0;
    else {
        for(int i = 0; i < idx.size(); i++) {
            for(int j = i + 1; j < idx.size(); j++) {
                if(disks[idx[i]].color == disks[idx[j]].color) {
                    ret = max(ret, rec(used | (1 << idx[i] | 1 << idx[j])) + 2);
                }
            }
        }
        return dp[used] = ret;
    }
}

int main() {

    while(cin >> n, n) {
        for(int i = 0; i < n; i++) {
            int x, y, c, r; cin >> x >> y >> r >> c;
            disks.push_back((disk){x, y, r, c});
        }

        cout << rec(0) << endl;
        disks.clear();
        dp.clear();
    }
}

Measured memory_bytes: 50432
class UnionFind:
    def __init__(self, N):
        self.N = N

        # the parent of all node is itself
        # self.parent = list(range(N))
        self.parent = [-1] * N

    def root(self, i):
        if self.parent[i] < 0:
            return i

        r = self.root(self.parent[i])
        self.parent[i] = r
        return r

    def unite(self, i, j):
        i = self.root(i)
        j = self.root(j)

        if i == j:
            return

        if i > j:
            i, j = j, i

        self.parent[i] += self.parent[j]
        self.parent[j] = i
        # print(self.parent)

    def same(self, i, j):
        return self.root(i) == self.root(j)

    def size(self, i):
        return -self.parent[self.root(i)]

    def roots(self):
        return [self.root(i) for i in range(self.N)]

    def groupcount(self):
        return len(set(self.roots()))

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

# init union find
forest = UnionFind(N)

edges = []
for _ in range(M):
    edges.append([int(e) - 1 for e in input().split()])

inconvenience = N * (N - 1) // 2
score = []
for a, b in edges[::-1]:
    score.append(inconvenience)

    if not forest.same(a, b):
        inconvenience -= forest.size(a) * forest.size(b)

    forest.unite(a, b)

for s in score[::-1]:
    print(s)

Measured memory_bytes: 31124
#include "bits/stdc++.h"
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 9e18
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}
string YN(bool y) { return (y ? "YES" : "NO"); }
string yn(bool y) { return (y ? "Yes" : "No"); }
string ON(bool y) { return (y ? "OK" : "NG"); }

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;

int dir4[4][2] = { {0,-1},{-1,0},{1,0},{0,1} };
int dir8[8][2] = { {-1,-1},{0,-1},{1,-1},{-1,0},{1,0},{-1,1},{0,1},{1,1} };

//=======ここまでテンプレート===============================================



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

	if (K % 2 == 0) {
		cout << K / 2 << " ";
		rep(i, N - 1) {
			cout << K << " ";
		}
		cout << endl;
		return 0;
	}
	vi ans(N, (K + 1) / 2);
	
	rep(i, N / 2) {
		if (ans.back() == 1)ans.pop_back();
		else {
			ans.back()--;
			while(ans.size() < N){
				ans.push_back(K);
			}
		}
	}

	rep(i, ans.size()) {
		cout << ans[i] << " ";
	}
	cout << endl;

	return 0;
}

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

#define fa(x,v) for(auto x:v)
#define f(i,a,b) for(ll i=(ll)a;i<=(ll)b;i++)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define spc " "
#define endl '\n'
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define len(s) (ll)int(s.length())
#define sz(v) (ll)int(v.size())
#define MOD 1000000007

void Fast_IO() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.in","r",stdin);
    freopen("output.out","w",stdout);
    freopen("debug.out","w",stderr);
    #endif
} 

// Code Here

vector < pair<ll,ll> > primeFactorsWithCountOfLarge(ll n)
{
	 vector < pair<ll,ll> > ret;
	 if(n == 0) return ret;
	 for(ll i = 2; i * i <= n; i++) {
	 	if(n % i == 0) {
	 		ll currentFactor = i, currentCount = 0;
	 		while(n % currentFactor == 0) n /= currentFactor, currentCount++;
	 		ret.pb(mp(currentFactor,currentCount));
	 	}
	 }
	 if(n != 1) ret.pb(mp(n,1));
	 return ret;
}

ll calc(ll n)
{
	ll ret = 0, i = 1;
	while(n >= i) {
		ret++;
		n -= i;
		i++;
	}
	return ret;
}

int main()
{
    // Fast_IO();
    ll n; cin >> n;
    vector < pair<ll,ll> > v = primeFactorsWithCountOfLarge(n);
    ll ans = 0;
    fa(x,v) ans += calc(x.ss);
    cout << ans;
    return 0;
}

Measured memory_bytes: 3632
A = int(input())
B = int(input())
C = int(input())
X = int(input())
ans = 0
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if 500*i+100*j+50*k == X:
                ans += 1
print(ans)



Measured memory_bytes: 3060
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;

int main(){
  lint a,b,c;
  cin>>a>>b>>c;
  if((c-a-b)>=0 and 4ll*a*b<(c-a-b)*(c-a-b))cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
use std::collections::*;
use std::io::*;
use std::*;
// template {{{
macro_rules! get {
    ($($t:tt),*; $n:expr) => {
        {
            let stdin = std::io::stdin();
            ret = std::io::BufRead::lines(stdin.lock()).take($n).map(|line| {
                let line = line.unwrap();
                let mut it = line.split_whitespace();
                _get!(it; $($t),*)
            }).collect::<Vec<_>>()
        }
    };
    ($($t:tt),*) => {
        {
            let mut line = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut it = line.split_whitespace();
            _get!(it; $($t),*)
        }
    };
}
macro_rules! _get {
    ($it:ident; [char]) => {
        _get!($it; String).chars().collect::<Vec<_>>()
    };
    ($it:ident; [u8]) => {
        _get!($it; String).bytes().collect::<Vec<_>>()
    };
    ($it:ident; usize1) => {
        $it.next().unwrap().parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1
    };
    ($it:ident; [usize1]) => {
        $it.map(|s| s.parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1).collect::<Vec<_>>()
    };
    ($it:ident; [$t:ty]) => {
        $it.map(|s| s.parse::<$t>().unwrap_or_else(|e| panic!("{}", e))).collect::<Vec<_>>()
    };
    ($it:ident; $t:ty) => {
        $it.next().unwrap().parse::<$t>().unwrap_or_else(|e| panic!("{}", e))
    };
    ($it:ident; $($t:tt),+) => {
        ($(_get!($it; $t)),*)
    };
}
// }}}

fn main() {
    let (a, b, c, d) = get!(i64, i64, i64, i64);
    println!("{}", (a*c).max(b*d).max(a*d).max(b*c));
}


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

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

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

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

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

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

int main(){
    int n; cin >> n;
    string s; cin >> s;
    vector<set<ll> > alset(26);
    REP(i, 0, n){
        int key = s[i] - 'a';
        alset[key].insert(i+1);
    }
    int q; cin >> q;
    REP(i, 0, q){
        int a; cin >> a;
        if(a == 1){
            int k; cin >> k;
            int key = s[k-1] - 'a';
            alset[key].erase(k);
            char x; cin >> x;
            alset[x-'a'].insert(k);
            s[k-1] = x;
            //cout << s << endl;
        }else{
            int s, e; cin >> s >> e;
            int count = 0;
            REP(l, 0, 26){
                if(alset[l].size() == 0)
                    continue;
                auto kk = alset[l].rbegin();
                if(*kk < s)
                    continue;
                auto it = alset[l].lower_bound(s);
                /*if( it - alset[l].begin() >= alset[l].size()){
                    continue;
                }*/
                if(*it <= e && *it >= s){
                    count++;
                }
            }
            cout << count << endl;
        }
    }
}

Measured memory_bytes: 27172
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

const int MOD = 998244353;
int mod_pow(int n,int p,int MOD){ // a/n ≡ a*n^(p-2) nとpは互いに素
  int r = 1;
  for(; p > 0; p >>= 1){
    if(p & 1LL) r = (r * n) % MOD;
    n = (n * n) % MOD;
  }
  return r; // r = n^p % MOD
}

signed main(){

  int n; cin >> n;
  vector<int> d(n);
  int Max = -1;
  for(int i = 0; i < n; i++){
    cin >> d[i];
    Max = max(Max, d[i]);
  }

  vector<int> dp(n+1, 0);
  for(int i = 0; i < n; i++){
    dp[d[i]]++;
  }
  if(dp[0] != 1 || d[0] != 0){
    cout << 0 << endl;
    return 0;
  }

  int ans = 1;
  for(int i = 1; i <= Max; i++){
    ans = (ans * mod_pow(dp[i-1], dp[i], MOD)) % MOD;
  }
  cout << ans << endl;

  return 0;
}


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

long long N,M;

int main(){
    cin >> N >> M;
    long long int ans = 
    (N-2) * (M-2);

    if(N == 2 || M == 2){
        ans = 0;
    }
    if(N == 1){
        ans = M - 2;
    }
    if(M == 1){
        ans = N - 2;
    }
    if(N == 1 && M == 1){
        ans = 1;
    } 

    cout << ans << endl;
}

Measured memory_bytes: 3632
#include<stdio.h>

int main(void){
    int Thp,Tat,Ahp,Aat;
    
    scanf("%d%d%d%d",&Thp,&Tat,&Ahp,&Aat);
    while((Thp>0)&&(Ahp>0)){
        Ahp=Ahp-Tat;
        if(Ahp>0){
            Thp=Thp-Aat;
        }
    }
    if(Ahp<=0){
        printf("Yes\n");
    }
    else if(Ahp>0){
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 1596
#include <stdio.h>
#include <vector>
#define trdef for (int z=1;z<n;z++)	scanf ("%d %d", &a, &b), tr[a].push_back(b), tr[b].push_back(a), ij[a]++, ij[b]++
using namespace std;
typedef long long ll;
const int C=100001;

vector <vector <int> > tr(C);
vector <vector <ll> > il(C), il1(C), il2(C);
int ij[C], a, b, n, mom[C], all[C];
ll M, dp[C], kk, cafu[C];

int s[C], is=0, ip=1, par[C], ji[C];
void proc_tree(int a, int n, vector <vector <int> > &tab, int ij[]){
	s[0]=a, is=1, dp[a]=1;
	int b, i, j;
	
	for(int z=1;z<=n;z++)	ji[z]=ij[z], par[z]=0;
	
	while (is>0){
		a=s[is-1];
		if (ji[a]>0&&tab[a][ji[a]-1]==par[a])	ji[a]--;
		if (ji[a]>0)	b=s[is]=tab[a][ji[a]-1], dp[b]=1, par[b]=a, is++, ji[a]--;
		else {
			if (is>1)	b=s[is-2];
			else b=0;
			mom[a]=all[b], all[b]++;
			dp[b]=(dp[b]*(dp[a]+1))%M;
			il[b].push_back(dp[a]+1);
			is--;
		}
	}
	
	for(int z=1;z<=n;z++)	ji[z]=ij[z];
	
	for (i=1;i<=n;i++){
		for (j=0;j<all[i];j++){
			if (j>0)	il1[i].push_back((il1[i][j-1]*il[i][j])%M), il2[i].push_back((il2[i][j-1]*il[i][all[i]-j-1])%M);
			else 		il1[i].push_back(il[i][0]), il2[i].push_back(il[i][all[i]-1]);
		}
	}
		
	s[0]=1, is=1, cafu[1]=1;
	while (is>0){
		a=s[is-1];
		if (ji[a]>0&&tab[a][ji[a]-1]==par[a])	ji[a]--;
		if (ji[a]>0)	{
			b=s[is]=tab[a][ji[a]-1];
			
			kk=1;
			if (mom[b]>0)	kk=(il1[a][mom[b]-1])%M;
			if (all[a]-mom[b]-1>0)	kk=(kk*il2[a][all[a]-mom[b]-2])%M;
			kk=(kk*cafu[a])%M;
			cafu[b]=(kk+1)%M;
			dp[b]=(dp[b]*cafu[b])%M;
			is++, ji[a]--;
		}
		else is--;
	}
	
}

int main(){
	int i;
	scanf ("%d %lld", &n, &M);
	trdef;
	proc_tree(1, n, tr, ij);
	for (i=1;i<=n;i++)	printf ("%lld\n", dp[i]%M);
	
return 0;}

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

using ll = long long;
using namespace std;
const int INFint = 1e9+1;
const ll INFll = (ll)1e18+1;
ll MOD=1e9+7;

int main(){
  int X;
  cin>>X;
  if(X>=400 && X<= 599) cout << 8 << endl;
  if(X>=600 && X<= 799) cout << 7 << endl;
  if(X>=800 && X<= 999) cout << 6 << endl;
  if(X>=1000 && X<= 1199) cout << 5 << endl;
  if(X>=1200 && X<= 1399) cout << 4 << endl;
  if(X>=1400 && X<= 1599) cout << 3 << endl;
  if(X>=1600 && X<= 1799) cout << 2 << endl;
  if(X>=1800) cout << 1 << endl;
  return 0;
}



Measured memory_bytes: 3672
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <complex>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>
#include <iterator>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) cin >> a[i];
    int ans = 0;
    for (int i = 1; i < n - 1; ++i) {
        ans += (a[i - 1] < a[i] && a[i] < a[i + 1]) || (a[i - 1] > a[i] && a[i] > a[i + 1]);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
n = gets.chomp.to_i
town = Array.new(n)
n.times do |i|
  town[i] = gets.chomp.split(' ').map(&:to_i)
end

arr = [*0..n-1].permutation(n).to_a

ans = 0.0

arr.size.times do |i|
  total = 0.0
  (n-1).times do |j|
    x_delta = town[arr[i][j]][0] - town[arr[i][j+1]][0]
    y_delta = town[arr[i][j]][1] - town[arr[i][j+1]][1]
    dist = (x_delta**2 + y_delta**2) ** 0.5
    total += dist
  end
  ans += total
end
puts ans/arr.size.to_f
    

Measured memory_bytes: 6780
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
const int MAXN = 4e5 + 5, MAXM = 2e5 + 5, BOUND = 1e7, MOD = 1e9 + 7, INF = 0x3f3f3f3f, base = 10000;
const ll INFL = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1.0), eps = 1e-9;
#define mid l + ((r-l)>>1)
#define lson o<<1,l,m
#define rson o<<1|1,m+1,r
#define lc(x) ch[x][0]
#define pii pair<int,int>
#define vi vector<int>
#define RR register int
#define rc(x) ch[x][1]
#define rep(i,a,b) for(RR i=(a);i<=(b);++i)
#define random(a,b) ((a)+rand()%((b)-(a)+1))
int n, m, k;
int main() {
	ios::sync_with_stdio(false); cin.tie(0);
	cin >> n >> k;
	cout << n - k + 1 << '\n';
	return 0;
}

Measured memory_bytes: 256