akhauriyash/Code-Regression huggingface dataset:
//#define _GRIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;

// ?????¬???????????¬??????
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// ???
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long double> vld;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T> int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F> int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T> void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C> void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U> void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U> void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C> void reverse(C& c) { reverse(ALL(c)); }
template<typename C> void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred> void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// ?????°
#pragma region CONST_VAL
constexpr int PI = (2*acos(0.0));
constexpr int EPS = (1e-9);
constexpr int MOD = (int)(1e9+7);
constexpr int INF = 100000000;
#pragma endregion

#define int long long

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
int w, h, res;
string a[55];
bool is_while = false;
bool is_black = false;

int dfs(int y, int x) {
    a[y][x] = '#';
    res++;
    for(int i=0; i<4; ++i) {
        int nx = x + dx[i];
        int ny = y + dy[i];
        if(nx>=0&&nx<w&&ny>=0&&ny<h) {
            if(a[ny][nx]=='.') dfs(ny, nx);
            if(a[ny][nx]=='W') is_while = true;
            if(a[ny][nx]=='B') is_black = true;
        }
    }

    return res;
}

signed main()
{
    while(cin>>w>>h, w) {
        for(int i=0; i<h; ++i) cin >> a[i];
        int nw = 0;
        int nb = 0;
        for(int i=0; i<h; ++i) {
            for(int j=0; j<w; ++j) {
                if(a[i][j]=='.') {
                    is_while = false;
                    is_black = false;
                    res = 0;
                    dfs(i, j);
                    if(is_while&&!is_black) nw += res;
                    else if(!is_while&&is_black) nb += res;
                }
            }
        }
        cout << nb << " " << nw << endl;
    }
    return 0;
}

Measured memory_bytes: 3288
n=int(input())
nums=list(map(int,input().split()))
nums.sort(reverse=True)
Alice_sum=0
Sum=sum(nums)

if n%2==0:
    for i in range(0,n,2):
        Alice_sum += nums[i]
    print(Alice_sum*2-Sum)
else:
    for i in range(0,n,2):
        Alice_sum += nums[i]
    print(Alice_sum*2-Sum)


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

int main(){
    int n,d;
    cin >> n >> d;
    if(n%(1+2*d) == 0){
      cout << n/(1+2*d) << endl;
    }else{
      cout << n/(1+2*d)+1 << endl;
    }
}






Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
using namespace std;
typedef pair<int,pair<int,int>> P;
int main(){
  int H,W;
  cin>>H>>W;
  string s[100];
  int cost[100][100];
  for(int i=0;i<H;i++){
    cin>>s[i];
    for(int j=0;j<W;j++) cost[i][j]=999999;
  }
  priority_queue<P,vector<P>,greater<P>> que;
  que.push(make_pair(0,make_pair(0,0)));
  cost[0][0]=0;
  while(!que.empty()){
    int y=que.top().second.first;
    int x=que.top().second.second;
    que.pop();
    if(y!=H-1&&cost[y+1][x]==999999){
      if(s[y][x]!=s[y+1][x]) cost[y+1][x]=cost[y][x]+1;
      else cost[y+1][x]=cost[y][x];
      que.push(make_pair(cost[y+1][x],make_pair(y+1,x)));
    }
    if(x!=W-1&&cost[y][x+1]==999999){
      if(s[y][x]!=s[y][x+1]) cost[y][x+1]=cost[y][x]+1;
      else cost[y][x+1]=cost[y][x];
      que.push(make_pair(cost[y][x+1],make_pair(y,x+1)));
    }
  }
  if(s[0][0]=='#'&&s[H-1][W-1]=='#') cout<<cost[H-1][W-1]/2+1<<endl;
  else cout<<(cost[H-1][W-1]+1)/2<<endl;
  
  return 0;
}

Measured memory_bytes: 3692
import math

def mgcd(a, b, c):
    g = math.gcd(a, b)
    g = math.gcd(g, c)
    return g
    
memo={}
cnt = 0

K = int(input())

for a in range(1, K+1):
    for b in range(1, K+1):
        p = [a, b]
        #p.sort()
        key = str(p)
        if memo.get(key):
            #cnt += memo[key]
            continue
        else:
            g = math.gcd(a, b)
            memo[key] = g
            #cnt += g

#print(memo)
for c in range(1, K+1):
    for v in memo.values():
        #print(v, c)
        cnt += math.gcd(v, c)
        
print(cnt)

Measured memory_bytes: 12928
import numpy as np

N, K = map(int, input().split(' '))
A = np.array(list(map(int, input().split(' '))))

if N == 1:
    print(abs(A[0]))
else:
    distances = np.array([0, *(A[1:] - A[:-1])])
    cumsum = distances.cumsum()
    to_left = abs(A[:-(K - 1)])
    to_right = abs(A[(K - 1):])
    to_start = np.minimum(to_left, to_right)
    to_goal = cumsum[(K - 1):] - cumsum[:-(K - 1)]

    print(min(to_start + to_goal))


Measured memory_bytes: 38272
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long A[] = new long[N];
        long ans = 1;
        int zero = 2;
        
        for(int i = 0; i < N ; i++){
            A[i] = sc.nextLong();
            if(A[i] == 0){
                zero = 0;
                break;
            }
        }
        try{
        if(zero == 0){
            ans = 0;
        }else{for(int i = 0; i < N ; i++){
            ans = Math.multiplyExact(ans, A[i]);
                if(ans > 1000000000000000000L){
                    ans = -1;
                    break;
                }
            }
        }
        }catch(ArithmeticException e){
            ans = -1;
        }
        System.out.println(ans);
        
        
    }    
}

Measured memory_bytes: 49840
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

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

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100000;

int main() {
	int n,k;cin>>n>>k;
	int h[N];
	rep(i,n) cin>>h[i];
	sort(h,h+n);
	int ans=INF;
	for(int i=0;i<=n-k;i++) ans=min(h[i+k-1]-h[i],ans);
	cout<<ans<<endl;
}


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

int gcd(int x,int y){
	if(y)return gcd(y,x%y);
	else return x;
}

int main(){
	int K;
	cin>>K;
	ll s=0;
	for(int i=1;i<=K;i++){
		for(int j=1;j<=K;j++){
			for(int k=1;k<=K;k++){
				s+=gcd(gcd(i,j),k);
			}
		}
	}
	cout<<s<<endl;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,r,k;
  cin>>n>>r;
  if(n>=10)
  {
    cout<<r<<endl; 
  }
  else
  {
     k=(100*(10-n))+r; 
    cout<<k<<endl;
  }
  return 0;
}

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

typedef long long ll;

void calc(ll &p, ll &q, ll n, bool isNorth){
  if(isNorth && p == 0) return;
  if(!isNorth && p == 90 && q == 1) return;

  ll nq = q * (1LL << n);

  p *= (1LL << n);
  p += isNorth ? -90 * q : 90 * q;
  q = nq;

  ll g = __gcd(p, q);
  p /= g;
  q /= g;
}

int main(){
  string s;

  while(cin >> s){
    if(s == "#"){
      break;
    }

    ll n = 0;
    ll p = 0, q = 1;

    for(int i = s.size() - 1; i >= 0; n++){
      if(s[i] == 'h'){
        i -= 5;
        calc(p, q, n, true);
      } else{
        i -= 4;
        calc(p, q, n, false);
      }
    }

    cout << p;
    if(q != 1) cout << "/" << q;
    cout << endl;
  }
}

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

using namespace std;

auto main () -> int
{
  cin.tie (nullptr);
  ios::sync_with_stdio (false);
  
  int a, b;
  cin >> a >> b;
  int sum = a + b;
  if (sum % 2 == 0)
  	cout << sum / 2 << endl;
  else
    cout << "IMPOSSIBLE" << endl;

}



Measured memory_bytes: 256
package main

import "fmt"

func main(){
	var N, M, X int
	fmt.Scan(&N, &M, &X)
	var A, To0, ToN int
	for i:=0; i < M; i++ {
		fmt.Scan(&A)
		if A < X {
			To0++
		}else{
			ToN++
		}
	}
	if To0 < ToN {
		fmt.Print(To0)
	}else{
		fmt.Print(ToN)
	}
}

Measured memory_bytes: 512
C = []
for _ in range(3):
    C.append(list(map(int,input().split())))
flag = 1
for i in range(2):
    if C[i+1][0] - C[i][0] != C[i+1][1] - C[i][1] or C[i+1][1] - C[i][1] != C[i+1][2] - C[i][2]:
        flag = 0
    if C[0][i+1] - C[0][i] != C[1][i+1] - C[1][i] or C[1][i+1] - C[1][i] != C[2][i+1] - C[2][i]:
        flag = 0

if flag:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int gcd(int a,int b){
	if(!b)return a;
	return gcd(b,a%b);
}

set<int>se[6];

signed main(){
	for(int i=1;i<=30000;i++){
		if(i%2==0||i%3==0){
			if(i==2||i==3||i==4||i==9)continue;
			se[i%6].insert(i);
		}
	}
	int n;scanf("%d",&n);
	if(n==3){
		puts("2 5 63");return 0;
	}
	printf("2 3 4 9");
	n-=4;
	while(n>=2){
		if(se[2].size()){
			printf(" %d %d",*se[2].begin(),*se[4].begin());
			se[2].erase(se[2].begin());
			se[4].erase(se[4].begin());
			n-=2;
		}
		else break;
	}
	while(n>=2){
		if(se[3].size()>=2){
			printf(" %d %d",*se[3].begin(),*++se[3].begin());
			rep(i,2)se[3].erase(se[3].begin());
			n-=2;
		}
		else break;
	}
	while(n){
		printf(" %d",*se[0].begin());
		se[0].erase(se[0].begin());
		n--;
	}
	cout<<endl;
}

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

using ll = long long;
ll INF = 1e16;

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

  ll m = INF;
  for(ll n = 1; n * n <= N; ++n) {
    if(N % n == 0) {
      ll a = n;
      ll b = N / n;
      m = min(m, a + b);
    }
  }
  cout << m - 2 << endl;
  return 0;
}

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

int main() {
  int n,m; cin>>n>>m;
  int res=0;
  res+=max(0, (n-1)*n/2);
  res+=max(0, (m-1)*m/2);
  cout<<res<<endl;
}


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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define debug_print(var) cerr << #var << "=" << var <<endl;
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

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

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

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

struct UnionFind{
  ll N;
  llvec p;
  llvec cnt;
  UnionFind(ll n){
    N = n;
    p=llvec(N);
    cnt=llvec(N, 0);
    rep(i, N){
      p[i] = i;
      cnt[i] = 1;
    }
  }

  void con(ll a, ll b){
    P at = root(a);
    P bt = root(b);
    if(at.second!=bt.second){
      if(at.first>bt.first){
        swap(at, bt);
        swap(a, b);
      }
      p[at.second] = bt.second;
      cnt[bt.second]+=cnt[at.second];
      p[a]=bt.second;
    }
  }

  P root(ll a){
    ll atmp = a;
    ll c=0;
    while(atmp!=p[atmp]){
      atmp = p[atmp];
      c++;
    }
    p[a] = atmp;
    return {c, atmp};
  }

  bool is_con(ll a, ll b){
    P at=root(a);
    P bt=root(b);
    return at.second == bt.second;
  }
  
};

struct dijkstra{
  ll N;
  llvec d;
  vector<vector<edge>> e;
  dijkstra(ll n){
    N = n;
    //d = llvec(N, 1e18);
    e = vector<vector<edge>>(N);
  }

  void add_edge(ll from, ll to, ll cost){
    e[from].push_back({to, cost});
  }

  void run(ll start){
    priority_queue<P, vector<P>, greater<P>> que;
    que.push({0, start});
    d = llvec(N, 1e18);
    d[start]=0;
    while(!que.empty()){
      P q = que.top();que.pop();
      ll dc = q.first;
      ll x = q.second;
      if(dc>d[x]){
        continue;
      }else{
        for(auto ip: e[x]){
          if(d[ip.x]<=d[x]+ip.c){
            continue;
          }else{
            d[ip.x]= d[x]+ip.c;
            que.push({d[ip.x], ip.x});
          }
        }
      }
    }
  }  
};


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll X, A;
  cin >> X >> A;
  if(X<A)cout << 0;
  else cout << 10;
  return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using ull = unsigned long long;
//#define int ll
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<V<T>>;
#define fi first
#define se second
#define maxs(x,y) (x=max(x,y))
#define mins(x,y) (x=min(x,y))
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(ll i = (ll)(b)-1;i >= a;--i)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1), EPS = 1e-10;
const ll MOD = 1e9+7;
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vi a(n);
  REP(i,n) cin >> a[i];
  sort(ALL(a));
  int ng = 0;
  int m = a.back()-a.front();
  FOR(i,1,n-1){
    if(a[i]>=0){
      m += a[i];
    }else{
      m -= a[i];
      ng = i;
    }
  }
  cout << m << endl;
  int mx = a.back();
  int mn = a.front();
  FOR(i,1,ng+1){
    cout << mx << " " << a[i] << endl;
    mx -= a[i];
  }
  FOR(i,ng+1,n-1){
    cout << mn << " " << a[i] << endl;
    mn -= a[i];
  }
  cout << mx << " " << mn << endl;
  assert(mx-mn==m);
}



Measured memory_bytes: 2304
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int x = scanner.nextInt();
        int x500 = x / 500;
        int x5 = (x % 500) / 5;

        System.out.println(x500 * 1000 + x5 * 5);
    }
}


Measured memory_bytes: 23380
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<queue>
#include<cstring>
using namespace std;

const int N=100010;

int a[N];
int n;

int main()
{
    cin>>n;
    int cnt=0;
    memset(a,0,sizeof a);
    for(int i=1;i<=n;i++)
    {
        int tem;
        cin>>tem;
        if(a[tem]==0){
            a[tem]++;
            cnt++;
        }
    }
    if(cnt%2==0)cnt--;
    cout<<cnt<<endl;
}

Measured memory_bytes: 640
N, K = [int(input()) for _ in range(2)]
listn = list(str(N))
a = []
if len(str(N)) < K:
    for i in range(len(str(N))):
        if listn[i] != str(1):
            a.append(str(listn[i]))
else:
    for i in range(K):
        if listn[i] != str(1):
            a.append(str(listn[i]))
if a == []:
    print(1)
else:
    print(a[0])

Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<(n);i++)
#define Rep(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define eb emplace_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
// const int mod=998244353;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int h,w;
    cin>>h>>w;
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    a--,b--,c--,d--;
    vs s(h);
    rep(i,h)cin>>s[i];
    vvi cost(h,vi(w,inf));
    deque<pair<int,pi>> q;
    q.push_back({0,{a,b}});
    while(!q.empty()){
        auto p=q.front();
        q.pop_front();
        int t=p.fi;
        int y=p.se.fi,x=p.se.se;
        if(cost[y][x]<=t)continue;
        cost[y][x]=t;
        REP(i,-2,2)REP(j,-2,2){
            if(i==0&&j==0)continue;
            int ny=y+i,nx=x+j;
            if(ny<0||ny>=h||nx<0||nx>=w)continue;
            if(s[ny][nx]=='#')continue;
            if(abs(i)+abs(j)==1){
                q.push_front({t,{ny,nx}});
            }
            else{
                q.push_back({t+1,{ny,nx}});
            }
        }
    }
    cout<<(cost[c][d]==inf?-1:cost[c][d])<<endl;
}


Measured memory_bytes: 14940
/*
        _            _                  _            _       _     _         _   _          _          _             _        
       / /\         / /\               / /\         / /\    / /\  /\ \      /\_\/\_\ _     /\ \       /\ \     _    /\ \      
      / /  \       / /  \             / /  \       / / /   / / /  \ \ \    / / / / //\_\   \ \ \     /  \ \   /\_\ /  \ \     
     / / /\ \__   / / /\ \           / / /\ \__   / /_/   / / /   /\ \_\  /\ \/ \ \/ / /   /\ \_\   / /\ \ \_/ / // /\ \_\    
    / / /\ \___\ / / /\ \ \         / / /\ \___\ / /\ \__/ / /   / /\/_/ /  \____\__/ /   / /\/_/  / / /\ \___/ // / /\/_/    
    \ \ \ \/___// / /  \ \ \        \ \ \ \/___// /\ \___\/ /   / / /   / /\/________/   / / /    / / /  \/____// / / ______  
     \ \ \     / / /___/ /\ \        \ \ \     / / /\/___/ /   / / /   / / /\/_// / /   / / /    / / /    / / // / / /\_____\ 
 _    \ \ \   / / /_____/ /\ \   _    \ \ \   / / /   / / /   / / /   / / /    / / /   / / /    / / /    / / // / /  \/____ / 
/_/\__/ / /  / /_________/\ \ \ /_/\__/ / /  / / /   / / /___/ / /__ / / /    / / /___/ / /__  / / /    / / // / /_____/ / /  
\ \/___/ /  / / /_       __\ \_\\ \/___/ /  / / /   / / //\__\/_/___\\/_/    / / //\__\/_/___\/ / /    / / // / /______\/ /   
 \_____\/   \_\___\     /____/_/ \_____\/   \/_/    \/_/ \/_________/        \/_/ \/_________/\/_/     \/_/ \/___________/    
                                                                                                                              
*/
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for(int i = 0;i < (n);++i)

#define endl '\n'
#define pb emplace_back
#define mkp make_pair
#define p_q priority_queue
#define INF 2000000000
#define PI 3.1415926
#define coutdb cout << fixed << setprecision(13)

const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};
const int dx_8[]={1,1,0,-1,-1,-1,0,1}, dy_8[]={0,-1,-1,-1,0,1,1,1};
const long long MOD = 1e9+7;

// typedef long long ll;
#define int long long

template <typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

vector<int> graph[100000];
int type[100000];
int N, M;
bool isdivide = 1;

void dfs(int pos){
  REP(i, graph[pos].size()){
    int nx = graph[pos][i];
    if(type[pos] == type[nx]){
      isdivide = 0;
      return;
    } else if(type[nx] == -1) {
      type[nx] = !type[pos];
      dfs(nx);
    }
  }
}

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

  int a, b; cin >> N >> M;
  REP(i, M){
    cin >> a >> b;
    graph[a-1].pb(b-1);
    graph[b-1].pb(a-1);
  }

  fill(type, type+N, -1);
  type[0] = 0;

  dfs(0);

  if(isdivide){
    int zero = 0, one = 0;
    REP(i, N){
      if(type[i]) one++;
      else zero++;
    }
    cout << zero*one - M << endl;
  } else {
    cout << N*(N-1)/2 - M << endl;
  }
}

Measured memory_bytes: 7936
w, h, n = map(int, input().split())


X=Y= 0
for i in range(n):
    x, y, a = map(int, input().split())
    
    if a==1 and X<x:
        X=x
    if a==2 and w>x:
        w=x
    if a==3 and Y<y:
        Y=y
    if a==4 and h>y:
        h=y


print(max(w-X,0)*max(h-Y,0))

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

using ll = long long;
const ll MIN = -1e12 - 5;

int main()
{
    int n;
    cin >> n;
    vector<ll> a(n);
    for(ll& x : a) {
        cin >> x;
    }

    vector<vector<ll>> dp(n, vector<ll>(n, MIN));
    for(int i = n-1; i >= 0; i--) {
        for(int j = i; j < n; j++) {
            if(i == j) {
                dp[i][j] = a[i];
                continue;
            }
            dp[i][j] = max(a[i]-(i < n-1 ? dp[i+1][j] : 0), a[j]-(j > 0 ? dp[i][j-1] : 0));
        }
    }
    cout << dp[0][n-1] << endl;
}


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

int main()
{
  int N, SUM;
  SUM = 0;
  cin >> N;
  vector<int> C(N);
  vector<int> V(N);
  for (int i = 0; i < N; i++)
  {
    cin >> V.at(i);
  }
  for (int i = 0; i < N; i++)
  {
    cin >> C.at(i);
  }
  // ここにプログラムを追記
  for (int i = 0; i < N; i++)
  {
    if (V.at(i) > C.at(i))
    {
      SUM = SUM + (V.at(i) - C.at(i));
    }
  }
  cout << SUM << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int N,M,P[105][105],i,j,r,t;
int main()
{
	for(;scanf("%d",&N),N;)
	{
		memset(P,0,sizeof(P));
		for(i=1;i<N+2;i++)
			for(scanf("%d",&M),j=0;j<M;j++)
			{
				scanf("%d",&t);
				P[i][t]=1;
			}
		for(i=1,r=-1;i<=N;i++)
		{
			for(j=1;j<=100;j++)
				if(P[N+1][j]&&!P[i][j])
					break;
			if(j==101)
			{
				if(r!=-1)
				{
					r=-1;
					break;
				}
				r=i;
			}
		}
		printf("%d\n",r);
	}
	return 0;
}

Measured memory_bytes: 648
a,b,m=map(int,input().split())
aa=list(map(int,input().split()))
bb=list(map(int,input().split()))
#print(aa,bb)

mini=min(aa)+min(bb)

for _ in range(m):
  x,y,c=map(int,input().split())
  mini=min(mini,aa[x-1]+bb[y-1]-c)
print(mini)

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

const int N = 2e5 + 10;

int k, l, n, c, comp[N], comp2[N], comps[N];
vector <int> adjk[N], adjl[N];
bool mark1[N], mark2[N];
map<pair<int, int>, int> mp;

void input();
void dfs1(int);
void dfs2(int);

int main() {
	input();
	for (int i = 0; i < n; i++) {
		if (!mark1[i]) {
			dfs1(i);
			c++;
		}	
	}
	c = 0; 
	for (int i = 0; i < n; i++) {
		if (!mark2[i]) {
			dfs2(i);
			c++;
		}
	}
//	cout << c << " :)) \n";	
/*	for (int i = 0; i < c; i++) {
//		cout << comps[i] << ' '; 
		comps[i] = (comps[i] * (comps[i] - 1)) / 2;
	} */
	for (int i = 0; i < n; i++)
		mp[{comp[i], comp2[i]}]++;
	for (int i = 0; i < n; i++)
		cout << mp[{comp[i], comp2[i]}] << " ";
	/*for (int i = 0; i < n; i++) {
//		cout << i << "    " << comp[i] << " **  " << comp2[i] << "  === > ";
		cout << comps[comp2[i]] << " ";
	}*/
	
}

void input() {
	
	cin >> n >> k >> l;
	
	for (int i = 0; i < k; i++) {
		int u, v;
		cin >> u >> v;
		u--, v--;
		adjk[u].push_back(v);
		adjk[v].push_back(u);
	}
	
	for (int i = 0; i < l; i++) {
		int u, v;
		cin >> u >> v;
		u--, v--;
		adjl[u].push_back(v);
		adjl[v].push_back(u);
	}		
}

void dfs1(int u) {
	
	mark1[u] = true;
	comp[u] = c;
	
	for (auto v: adjk[u]) {
		if (!mark1[v])
			dfs1(v);
	}
	
}

void dfs2(int u) {
	
	mark2[u] = true;
	comp2[u] = c;
//	comps[c]++;
	
	for (auto v: adjl[u]) {
		if (!mark2[v]) // && comp[u] == comp[v])
			dfs2(v);
	}
	
}

Measured memory_bytes: 28800
#include<bits/stdc++.h>
#define rep(i,x,y) for(int i=x,i##end=y;i<=i##end;++i)
#define _rep(i,x,y) for(int i=x,i##end=y;i>=i##end;--i)
#define ll long long
#define N 100005
ll sum[N],st,n,m;
int cnt[N],now;
int main(){
	std::cin>>n>>st>>m;
	int lst=0;
	while(1){
		if(cnt[st]){lst=cnt[st]; break;}
		cnt[st]=++now,sum[now]=sum[now-1]+st,st=st*st%m;
	}
	if(now==n) return std::cout<<sum[now]<<'\n',0;
	n-=lst-1;
	std::cout<<(sum[now]-sum[lst-1])*(n/(now-lst+1ll))+sum[n%(now-lst+1)+lst-1]<<'\n';
	return 0;
}

Measured memory_bytes: 4396
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var scanner = bufio.NewScanner(os.Stdin)

func init() {
	scanner.Split(bufio.ScanWords)
}

func ScanInt() int {
	scanner.Scan()
	t := scanner.Text()
	n, _ := strconv.Atoi(t)
	return n
}

func main() {
	n := ScanInt()

	hs := make([]int, n)
	for i := 0; i < n; i++ {
		hs[i] = ScanInt()
	}

	maxH := 0
	for _, h := range hs {
		if maxH < h {
			maxH = h
		}
	}

	cnt := 0
	for h := 1; h <= maxH; h++ {
		b := false
		for i := 0; i < n; i++ {
			if hs[i] >= h && !b {
				cnt++
				b = true
			} else if hs[i] < h {
				b = false
			}

		}
	}
	fmt.Println(cnt)
}


Measured memory_bytes: 1776
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int A,B,C;
  vector<int>vec(3);
  for(int i=0;i<3;i++) cin>>vec.at(i);
  sort(vec.begin(),vec.end());
  if(vec.at(0)+vec.at(1)==vec.at(2))cout<<"Yes";
  else cout<<"No";
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void){
    char a,b;
    string s;
    cin >> a;
  if(a == 'A'){
    b = 'T';
  }else if(a == 'C'){
    b = 'G';
  }else if(a == 'G'){
    b = 'C';
  }else if(a == 'T'){
    b = 'A';
  }
    
    cout << b;
}

Measured memory_bytes: 256
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

// vectorの重複削除
// std::sort(test.begin(), test.end());
// test.erase(std::unique(test.begin(), test.end()), test.end());

using namespace std;
using ll = long long;
using P = pair<int, int>; // vector<P> ba(n); みたいな感じですぐ使える ba[i] = P(a, b); make_pairをしなくてもいい
// typedef vector<int> v;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}
#define rep(i, c) for(int i = 0; i < int(c); i++)
#define ALL(x) (x).begin(), (x).end() //sort(ALL(obj))みたいな
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値
#define pb push_back //
// const int MOD = 1000000007;
// string alpha="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
// printf("%.20f\n", ans); あれ
// const double PI = 3.141592653589793238462643383;


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


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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"
*/

int main()
{
    double R; cin >> R;
    printf("%.5f\n", 2.0*R*M_PI);
}

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

int main(void){
    long A,B,K;
    cin >> A >> B >> K;
    if(K <= A)
    {
        cout << A - K << " " << B << endl;
    }
    else if (K <= A+B)
    {
        cout << "0" << " " << B - K + A  << endl;
    }
    else {
        cout  << 0 << " " << 0 << endl;
    }
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
typedef long long ll;
using namespace std;
typedef pair<int,int> pint;
typedef vector<int> vint;
int INF=1e+9+1;
int main(){
	int N;
	int p[100000];
	scan(N);
	rep(i,N){
		scan(p[i]);
	}
	int count=0;
	int stock=0;
	rep(i,N){
		if(p[i]==i+1){
			if(stock==0&&i<N-1) stock++;
			else{
				count++;
				stock=0;
			}
		}
		else{
			if(stock==1){
				count++;
				stock=0;
			}
		}
	}
	prin(count);
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define dup(x,y) (((x)+(y)-1)/(y))
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pii> vp;
inline int getInt() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MX = 200005;
//---------------------------------------------------------------
#define fastio cin.tie(nullptr); std::ios::sync_with_stdio(false);
#define myio ifstream iofi; if(argc>1){iofi.open(argv[1]); std::cin.rdbuf(iofi.rdbuf());}
//--------------------------------------------------------------
#define int64_t ll
map< int64_t, ll > prime_factor(int64_t n) {
  map< int64_t, ll > ret;
  for(int64_t i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

void Main(){
  ll n,p;
  cin>>n>>p;
  auto mp = prime_factor(p);
  ll ans = 1;
  for(auto m:mp){
    while(m.second >= n){
        ans *= m.first;
        m.second-=n;
    }
  }
  cout<<ans<<endl;
} int main(int argc,char** argv)
{fastio; myio; Main();}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}

int main(int argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  ll ans = 0;
  // ll n;
  // cin >> n;
  // ll n, m;
  // cin >> n >> m;
  // ll n, m, k;
  // cin >> n >> m >> k;
  int m[3][3];
  fi(0, 3)
    fj(0, 3)
      cin >> m[i][j];
  int n;
  cin >> n;
  int a;
  while(n--) {
    cin >> a;
    fi(0, 3)
      fj(0, 3) {
        if(a == m[i][j]) {
          m[i][j] = 0;
          break;
        }
      }
  }
  fi(0, 3) {
    int win = 1;
    fj(0, 3) {
      if(m[j][i] != 0) {
        win = 0;
        break;
      }
    }
    if(win) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  fi(0, 3) {
    int win = 1;
    fj(0, 3) {
      if(m[i][j] != 0) {
        win = 0;
        break;
      }
    }
    if(win) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  if(m[0][0] == 0 && m[1][1] == 0 && m[2][2] == 0) {
      cout << "Yes" << endl;
      return 0;

  }
  if(m[2][0] == 0 && m[1][1] == 0 && m[2][0] == 0) {
      cout << "Yes" << endl;
      return 0;

  }
      cout << "No" << endl;
  // cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
n,a,b = map(int,input().split())
while True:
    if a + 1 == b:
        if a - 1 == 0:
            print('Borys')
            exit(0)
        else:
            a -= 1
    else:
        a += 1
    if b - 1 == a:
        if b + 1 == n + 1:
            print('Alice')
            exit(0)
        else:
            b += 1
    else:
        b -= 1    

Measured memory_bytes: 9124
#include<bits/stdc++.h>
using namespace std;
int main() 
{
    char a;
	cin>>a;
	if (a=='a' || a=='e' || a=='i' || a=='u' ||a=='o')
		cout<<"vowel"<<endl;
	else
		cout<<"consonant"<<endl;
    return 0;
}



Measured memory_bytes: 256
def p(x):
 for i in range(7,int(x**.5+1),2):
  if x%i==0:return 0
 return 1
def f():
 n,c=map(int,input().split());s='9'*n
 if c<0:return(11,s+s)[n>1]
 for h in'9731':
  if n-1:
   for m in range(int(10**~-n),0,-1):
    m=str(m-1)
    if(sum(int(k)for k in h+m)*2+c)%3:
     t=h+m.zfill(n-1);a=int(t+str(c)+t[::-1])
     if p(a):return a
  else:
   a=int(h+str(c)+h)
   if p(a):return a
print(f())


Measured memory_bytes: 5648
/*
 * Note: This template uses some c++11 functions , so you have to compile it with c++11 flag.
 *       Example:-   $ g++ -std=c++11 c++Template.cpp
 *
 * Author : Denzil Bernard  / Edgar Monis
 * Handle: 1_mn_RMY / the_king_in_the_north
 *
 */

// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
//#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

/*******  All Required define Pre-Processors and typedef Constants *******/
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert( B <= A && A <= C)
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define read(type) readInt<type>()
#define ll long long
typedef pair< ll, ll> PII;
typedef vector<ll> VI;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<ll,ll> MPII;
typedef set<ll> SETI;
typedef multiset<ll> MSETI;

ll SI(){
    ll x;
    cin>>x;
    return x;
}


ll mod(ll a){
	return a<0?-a:a;
}


/********** Main()  function **********/
int main()
{
	ll t = SI();
	VI v(t);
	REP(i,t){
		v[i]=SI();
	}
	sort(v.begin(),v.end());
	if(v[0]==0){
		cout<<0;
	}
	else{
		ll ans = v[t-1];
		RREP(i,t-2){
			if(v[i]<=(ll)1e18/ans){
				ans*=v[i];	
			}
			else{
				cout<<-1;
				return 0;
			}
		}
		cout<<ans<<"\n";
	}
    
    
    


    return 0;
}


Measured memory_bytes: 4048
#include<algorithm>
#include<iostream>
#include<tuple>
#include<vector>
using namespace std;

struct Point {int y, x, i;};

const int INF = 1e9;
const int NIL = -1;
const int BIT = 1 << 5;
const vector<pair<int, int>> EAST  = {{1, 0}, {3, 2}, {5, 3}, {6, 4}};
const vector<pair<int, int>> SOUTH = {{3, 0}, {5, 1}, {4, 2}, {6, 3}};

int H, W;
vector<vector<int>> S;

vector<Point> neighbor(int y, int x) {
//   return {{y-1, x, 0}, {y, x-1, 2}, {y, x+1, 5}, {y+1, x, 6}};
  vector<Point> res;
  res.push_back({y-1, x, 0});
  res.push_back({y, x-1, 2});
  res.push_back({y, x+1, 5});
  res.push_back({y+1, x, 6});
  return res;
}
auto valid(int y, int x) {return 0 <= y && y < H && 0 <= x && x < W;}
auto set(int b, int i) {return b | (1 << i);}
auto get(int b, int i) {return b & (1 << i);}
auto east(int b) {
  auto res = 0;
  for(auto i: EAST) if(get(b, i.first)) res = set(res, i.second);
  return res;
}
auto south(int b) {
  auto res = 0;
  for(auto i: SOUTH) if(get(b, i.first)) res = set(res, i.second);
  return res;
}

int dfs(int y, int x, int b) {
  static vector<vector<vector<int>>> memo(H, vector<vector<int>>(W, vector<int>(BIT, NIL)));
  if(!valid(y, x)) return INF;
  if(y == H-1 && x == W-1) return 0;
  if(~memo[y][x][b]) return memo[y][x][b];

  auto buy = 0, nb = b;

  if(S[y][x] && !get(nb, 3)) {
    buy = S[y][x];
    nb = set(nb, 3);
  }

  vector<Point> store;
  for(auto nex: neighbor(y, x)) {
    if(!valid(nex.y, nex.x)) continue;
    if(!S[nex.y][nex.x]) continue;
    if(get(nb, nex.i)) continue;
    store.emplace_back(nex);
  }

  if(store.empty()) return memo[y][x][b] = min(buy + dfs(y, x+1, east(nb)), buy + dfs(y+1, x, south(nb)));

  memo[y][x][b] = INF;
  for(auto ex = 0; ex < store.size(); ++ex) {
    auto dup_buy = buy;
    auto dup_nb  = nb;
    for(auto i = 0; i < store.size(); ++i) if(i != ex) {
      auto nex = store[i];
      dup_buy += S[nex.y][nex.x];
      dup_nb = set(dup_nb, nex.i);
    }
    memo[y][x][b] = min({memo[y][x][b], dup_buy + dfs(y, x+1, east(dup_nb)), dup_buy + dfs(y+1, x, south(dup_nb))});
  }
  return memo[y][x][b];
}

int main() {
  cin >> H >> W;

  for(auto i = 0; i < H; ++i) {
    S.emplace_back();
    string s;
    cin >> s;
    for(auto j: s) S[i].emplace_back(j == '.' ? 0 : j - '0');
  }

  cout << dfs(0, 0, 0) << endl;
}

Measured memory_bytes: 171764
#include <stdio.h>
typedef long long ll;
using namespace std;

int main(void) {
  ll i, j, k, n, m, a, b, c;
  scanf("%lld%lld", &a, &b);
  if(!(b % a)) printf("%lld", a + b);
  else printf("%lld", b - a);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

string s;
string s1 = " ',.!?',.!?',.!?";
string s2 = " abcABCabcABCabcABC";
string s3 = " defDEFdefDEFdefDEF";
string s4 = " ghiGHIghiGHIghiGHI";
string s5 = " jklJKLjklJKLjklJKL";
string s6 = " mnoMNOmnoMNOmnoMNO";
string s7 = " pqrsPQRSpqrsPQRSpqrtPQRS";
string s8 = " tuvTUVtuvTUVtuvTUV";
string s9 = " wxyzWXYZwxyzWXYZwxyzWZYZ";

int main(void){

  while( cin >> s ){

    int cnt = 0;

    for( int i = 0 ; i < s.size() ; i++ ){
      if( s[i] == '1' ){
	for( int j = i ; s[j] == '1' ; j++ , i++ ) cnt++;
	cout << s1[cnt];
	i--;
      }
      else if( s[i] == '2' ){
	for( int j = i ; s[j] == '2' ; j++ , i++ ) cnt++;
	cout << s2[cnt];
	i--;
      }
      else if( s[i] == '3' ){
	for( int j = i ; s[j] == '3' ; j++ , i++ ) cnt++; 
	cout << s3[cnt];
	i--;
      }
      else if( s[i] == '4' ){
	for( int j = i ; s[j] == '4' ; j++ , i++ ) cnt++;
	cout << s4[cnt];
	i--;
      }
      else if( s[i] == '5' ){
	for( int j = i ; s[j] == '5'; j++ , i++ ) cnt++;
	cout << s5[cnt];
	i--;
      }
      else if( s[i] == '6' ){
	for( int j = i ; s[j] == '6'; j++ , i++ ) cnt++;
	cout << s6[cnt];
	i--;
      }
      else if( s[i] == '7' ){
	for( int j = i ; s[j] == '7' ; j++ , i++ ) cnt++;
	cout << s7[cnt];
	i--;
      }
      else if( s[i] == '8' ){
	for( int j = i ; s[j] == '8' ; j++ , i++ ) cnt++;
	cout << s8[cnt];
	i--;
      }
      else if( s[i] == '9' ){
	for( int j = i ; s[j] == '9' ; j++ , i++ ) cnt++;
	cout << s9[cnt];
	i--;
      }
      else if( s[i] == '0' && s[i + 1] == '0' && s[i + 2] == '0' ){
	cout << "  ";
	i += 2;
      }
      else if( s[i] == '0' && s[i + 1] == '0' ){
	cout << " ";
	i++;
      }
      cnt = 0;
    }
    cout << endl;
  }
  return 0;
}

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

int main() {
  bool check_prime[1000000] = {false};
  int n;

  for (int i=2; i < 1000; i++) {
    if (!check_prime[i]) {
      for (int j = i*i; j < 1000000; j+=i) {
        check_prime[j] = true;
      }
    }
  }

  while (cin >> n) {
    int answer = 0;
    for (int i = 2; i <= n; i++) {
      if (!check_prime[i]) { 
        answer++;
      }
    }
    cout << answer << endl;
  }

  return 0;
}

Measured memory_bytes: 2140
/*
 Abu Jafor Mohammad Saleh
 ios_base :: sync_with_stdio(false);
 cin.tie(NULL);
 
 */

#include<cstdio>
#include<iomanip>
#include<sstream>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<algorithm>
#include<set>
#include<queue>
#include<deque>
#include<stack>
#include<list>
#include<iostream>
#include<fstream>
#include<numeric>
#include<string>
#include<vector>
#include<cstring>
#include<map>
#include<iterator>
#include<limits>
#include <algorithm>
#include <unordered_map>
#include<fstream>
#define f first
#define s second
#define MOD 1000003

#define INF (int)1e9
#define PI 3.1415926535897932384626433832795
#define BOUNDARY(i, j) ((i >= 0 && i < rows) && (j >= 0 && j < coloums))

//#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
const int maxn = 100001;
using namespace std;
int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
int rows,coloums;
long long  gcd(long long  a, long long b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}


int main()
{
    fast;
    string s;
    cin>>s;
    if(s[2]==s[3] && s[4]==s[5])
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 256
/**
 *    author:  accesss_denied
**/
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
ll mod=1e9+7;			
ll inf=1e18;

int main() {
			fast
			// #ifndef ONLINE_JUDGE
			// freopen("input.txt","r",stdin);
			// freopen("output.txt","w",stdout);
			// #endif

			
				ll n,x,t;
				cin>>n>>x>>t;
				ll ans=(n+x-1)/x;
				ans*=t;
				cout<<ans;
                
			
			return 0;
		 }	




Measured memory_bytes: 3604
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
const ll mod=1000000007;
const ll INF=1e15;
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());
#define pb push_back
#define mp make_pair
typedef pair<ll,ll> P;
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};

ll USED[101];

int main(){
  REP(i,1,10){
    ll x; cin>>x;
    USED[x]=i;
  }
  ll N; cin>>N;
  vector<bool> d(10,false);
  rep(i,N){
    ll x; cin>>x;
    d.at(USED[x])=true;
  }

  bool ans=false;
  if(d.at(1)&&d.at(4)&&d.at(7)) ans=true;
  if(d.at(2)&&d.at(5)&&d.at(8)) ans=true;
  if(d.at(3)&&d.at(6)&&d.at(9)) ans=true;
  if(d.at(1)&&d.at(2)&&d.at(3)) ans=true;
  if(d.at(4)&&d.at(5)&&d.at(6)) ans=true;
  if(d.at(7)&&d.at(8)&&d.at(9)) ans=true;
  if(d.at(1)&&d.at(5)&&d.at(9)) ans=true;
  if(d.at(3)&&d.at(5)&&d.at(7)) ans=true;
  
  if(ans) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  

 
}

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

int main()
{
    string s;
    cin>>s;
    int k=0;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='1')
            k++;
    }
    cout<<k<<endl;
}


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

#define lg2(x) (x?63-__builtin_clzll(x):-1)
long long a,b,c;
int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>a>>b;c=a^b;
	if(!c){cout<<1<<'\n';return 0;}
	int k=lg2(c);a&=(1ll<<k)-1;b&=(1ll<<k)-1;
	int l=lg2(b);
	cout<<((1ll<<(k+1))+(1ll<<(l+1))-a-max(1ll<<(l+1),a))<<'\n';
	return 0;
}


Measured memory_bytes: 256