akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include <iterator>
#include<queue>
#include <functional>
#include <string>
#include <numeric>
#include<stack>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) v.begin(),v.end()
using namespace std;
const int dx[4] = { -1, 1, 0, 0 };
const int dy[4] = { 0, 0, -1, 1 };
struct aaa{
	int x;
	int y;
	int d;
	int m;
};

struct data
{
	bool memo[20][20][16][4];
	data(){
		REP(i, 20)
			REP(j, 20)
			REP(k, 16)
			REP(l, 4)
			memo[i][j][k][l] = false;
	}
};
stack<aaa> az;
bool memo[20][20][16][4] = {};
vector<string> Fi;
int R=0, C=0;
bool a(int ax, int ay,int Memory, int Muki){
	az.push({ ax, ay, Memory, Muki });
	while (!az.empty()){
		int ax = (az.top().x + C) % C, ay = (az.top().y + R) % R, Memory = az.top().d, Muki = az.top().m;
		az.pop();
		if (memo[ax][ay][Memory][Muki])continue;
		memo[ax][ay][Memory][Muki] = true;
		switch (Fi[ay][ax]){
		case '<':Muki = 0; ax += dx[Muki], ay += dy[Muki]; az.push({ ax, ay, Memory, Muki }); break;
		case '>':Muki = 1; ax += dx[Muki], ay += dy[Muki]; az.push({ ax, ay, Memory, Muki }); break;
		case '^':Muki = 2;  ax += dx[Muki], ay += dy[Muki]; az.push({ ax, ay, Memory, Muki }); break;
		case 'v':Muki = 3; ax += dx[Muki], ay += dy[Muki]; az.push({ ax, ay, Memory, Muki }); break;
		case '_':Muki = Memory ? 0 : 1;  ax += dx[Muki], ay += dy[Muki]; az.push({ ax, ay, Memory, Muki }); break;
		case '|':Muki = Memory ? 2 : 3;  ax += dx[Muki], ay += dy[Muki]; az.push({ ax, ay, Memory, Muki }); break;
		case '?':REP(i, 4){
			az.push({ ax + dx[i], ay + dy[i], Memory, i });
		}
				 break;
		case '.': ax += dx[Muki], ay += dy[Muki]; az.push({ ax, ay, Memory, Muki }); break;
		case '@':return true;
		case '+':Memory = (Memory + 1) % 16; ax += dx[Muki], ay += dy[Muki]; az.push({ ax, ay, Memory, Muki }); break;
		case '-':Memory = (Memory + 15) % 16; ax += dx[Muki], ay += dy[Muki]; az.push({ ax, ay, Memory, Muki }); break;
		default:Memory = Fi[ay][ax] - 48; ax += dx[Muki], ay += dy[Muki]; az.push({ ax, ay, Memory, Muki }); break;
		}
	}
	return false;
}

int main(){
	cin >> R >> C;
	Fi.resize(20);
	REP(i, R){
		string st;
		cin >> Fi[i];
	}
	data adata;
	if (a(0, 0, 0, 1)){
		cout << "YES" << endl;
	}
	else{
		cout << "NO" << endl;
	}
		
	return 0;
}

Measured memory_bytes: 1744
// Original macro is in https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#![allow(non_snake_case)]

macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = || -> String {
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
 
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
 
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
    
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
 
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
 
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [$t:tt]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

// for adhoc read (ex. https://atcoder.jp/contests/abc112/tasks/abc112_a)
#[allow(dead_code)]
fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
fn gcd(a: i64, b: i64) -> i64 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}

#[allow(dead_code)]
fn lcm(a: i64, b: i64) -> i64 {
    a*b / gcd(a, b)
}

fn main() {
    input! { 
         N: usize, 
         M: usize,
         denkyus: [[usize]; M],
         p: [usize; M]
    }
    let mut ans = 0; 
    for bit in 0..1<<N {
        let mut is_incr = true;
        for (i, switches) in denkyus.iter().enumerate() {
            let mut cnt = 0;
            for switch in switches {
                if (bit & 1<<switch-1) > 0 {
                    cnt += 1;
                }
            }
            if cnt % 2 != p[i] {
                is_incr = false;
                break;
            }
        }
        if is_incr {
            ans += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
s = input()
count = 0
count_max = 0

for k in range(len(s)):
    if s[k] == "A" or s[k] == "C" or s[k] == "G" or s[k] == "T":
        count += 1
        if count > count_max:
             count_max = count
    else:
        if count_max < count:
            count_max = count
        else:
            count = 0
print(count_max)

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

int n;
string s;
int main() {
	int i;
	cin >> s;
	for(i=s.size()-1; i>=0; ) {
		if(i>=4 && s.substr(i-4, 5) == "dream") i -= 5;
		else if(i>=4 && s.substr(i-4, 5) == "erase") i -= 5;
		else if(i>=6 && s.substr(i-6, 7) == "dreamer") i -= 7;
		else if(i>=5 && s.substr(i-5, 6) == "eraser") i -= 6;
		else break;
	}
	puts(i<0 ? "YES" : "NO");
	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define   ll   long long int
#define   sz   200010

using namespace std;


ll num[sz];

ll vis[sz];

int main()
{


    ll n,m,i,j,k,p,a,b;

    string s;

    cin>>n>>m;
    a=b=0;


    while(m--)
    {
        cin>>p>>s;
        if(s=="AC" && vis[p]==0)
        {
            vis[p]=1;
            a++;
            b+=num[p];
        }
        else if(s=="WA" && vis[p]==0)
        {
           num[p]++;
        }

    }

    cout<<a<<" "<<b<<endl;

    return 0;
}



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

int main() {
    int N;
    cin >> N;
    double div = 0;
    // vector<int> A(N);
    for (int i = 0; i < N; i++) {
        double a;
        cin >> a;
        div += (1 / a);
    }
    printf("%.8f", (1 / div));
    // cout << 1 / div << endl;
}

Measured memory_bytes: 256
n = gets.to_i
a = gets.split.map(&:to_i)
c = Hash.new { |h, k| h[k] = 0 }

a.each do |x|
  c[x] += 1
end

ps = []
c.each_pair do |k, v|
  if v >= 2
    ps += [k] * (v / 2)
  end
end

ps = ps.sort.reverse

if ps.size.zero?
  puts 0
else
  puts ps[0] * ps[1]
end

Measured memory_bytes: 97408
from collections import deque

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

b = deque()

if n%2 == 0:
  for i in range(n):
    ai = a[i]
    if i%2 == 0:
      b.append(ai)
    else:
      b.appendleft(ai)
else:
  for i in range(n):
    ai = a[i]
    if i%2 == 0:
      b.appendleft(ai)
    else:
      b.append(ai)
print(' '.join(map(str, b)))

Measured memory_bytes: 123476
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define veci(x,n) vector<int> x((int) (n))
#define vecs(x,n) vector<string> x((int) (n))
#define vecbf(x,n) vector<bool> x((int) (n), false)

int main(){
  int a,b;
  cin >> a >> b;
  if(a == b) cout << 2*a << endl;
  else{
    int n = max(a,b);
    cout << n + n - 1 << endl;
  }
}

Measured memory_bytes: 256
#--import&define---------------------
import math

def yes():
    print("Yes")
def no():
    print("No")
#--my_library--------------------------------
#mapを利用した入力
# x,y = map(int,input().split())

#forを利用した入力
#l = []
#for i in range():
#    l.append(int(input()))

#intの最大値
#x = 2147483647
#--以下解答---------------------------------
l = []
x = 2147483647
index = 0
for i in range(5):
   l.append( int(input()) )
   n = int(l[i]%10)
   if n>0 and n<x:
      x = n
      index = i

ans = 0
for i in range(5):
    if i == index:
        ans += l[i]
    elif l[i]%10 != 0:
        ans += int(l[i]/10)*10 +10
    else:
        ans += l[i]

print(ans)


Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
*this << "[";
for (auto it = d.b; it != d.e; ++it)
*this << ", " + 2 * (it == d.b) << *it;
ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int  long long int
#define pb push_back
#define fe first
#define lb lower_bound 
#define ub upper_bound
#define pii pair<pair<int,int>,pair<int,int> >
#define se second
#define endl "\n"
#define pi pair<int, int>
#define mi          map<int,int>
#define mii         map<pi,int>
#define vi vector<int> 
#define vvi vector<vi>
#define bs   binary_search
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,a,b) for(int i=a;i<=b;i++)	
#define all(c) (c).begin(),(c).end()
#define sz(x)       (int)x.size() 
#define PI 3.14159265358979323846

 const int N=5e5+5;

 int mod= 1e9+7;
 int dx[4]={0,0,+1,-1};
 int dy[4]={+1,-1,0,0};  
 
 
int po(int a, int b) {
	a %= mod;
	int res = 1;
	while (b > 0) {
		if (b & 1)
			res = (res * a) % mod;
		a =(a*a) % mod;
		b >>= 1;
	}
	 return res;	
  }


void solve() {
  int n;
  cin>>n;
  mi mp;
  rep(i,0,n) {
	     int x;
	     cin>>x;
	     mp[x]++;
	  }    
   int f=0;
   for(auto to:mp) {
	     if(to.se>1)  {
			    f=1;
			    break;
			 }
	   }		 
    if(f) cout<<"NO\n";
    else cout<<"YES\n";           
}

    
int32_t main() {
	cool;
	int t=1;	

	//cin>>t;
	while(t--)
	  solve();

  return 0;	   
}


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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}


int main() {
  int N;
  cin >> N;
  vector< int > P(N);
  cin >> P;
  vector< int > ord(N + 1);
  for(int i = 0; i < N; i++) {
    ord[P[i]] = i;
  }
  int64 ret = 0;
  multiset< int64 > used;
  used.emplace(-1);
  used.emplace(-1);
  used.emplace(N);
  used.emplace(N);
  for(int i = N; i >= 0; i--) {
    auto pre = used.lower_bound(ord[i]);
    --pre;
    auto nxt = pre;
    ++nxt;
    ret += (*next(nxt) - *nxt) * (ord[i] - *pre) * i;
    ret += (*pre - *prev(pre)) * (*nxt - ord[i]) * i;
    used.emplace(ord[i]);
  }
  cout << ret << endl;
}






Measured memory_bytes: 5760
package main

import (
	"fmt"
	"strconv"
	"strings"
)

var S string

func main() {
	fmt.Scan(&S)
	a := strings.Split(S, "")
	b := a[0] + a[1]
	c := a[2] + a[3]
	yy, _ := strconv.Atoi(b)
	mm, _ := strconv.Atoi(c)
	if yy >= 1 && yy <= 12 {
		if mm >= 1 && mm <= 12 {
			fmt.Println("AMBIGUOUS")
		} else {
			fmt.Println("MMYY")
		}
	} else {
		if mm >= 1 && mm <= 12 {
			fmt.Println("YYMM")
		} else {
			fmt.Println("NA")
		}
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define SLBIT __builtin_popcount

using namespace std;

const int oo = 1e9;
const int N = 5e5 + 100;
const int di[] = {-1,0,1,0};
const int dj[] = {0,1,0,-1};

typedef pair<int,int> i2;
typedef pair<int,i2> i3;
typedef pair<long long,int> i2ll;

int n;
long long C;
long long A[N],T[N],F1[N],F2[N],DP1[N],DP2[N];
int B[N];
void nhap()
{
    cin >> n >> C;
    for (int i = 1; i <= n; i++) {
        cin >> A[i] >> B[i];
    }
}

void solve() {
    long long Res = 0;
    long long Tong = 0;
    for (int i = 1; i <= n; i++) {
        Tong += 1ll * B[i];
        F1[i] = Tong - A[i];
        DP1[i] = max(DP1[i - 1],F1[i]);
    }
    Tong = 0;
    for (int i = n; i >= 1; i--) {
        Tong += 1ll * B[i];
        F2[i] = Tong - (C - A[i]);
        DP2[i] = max(DP2[i + 1],F2[i]);
    }
    Res = max(Res,DP1[n]);
    Res = max(Res,DP2[1]);
    for (int i = 1; i < n; i++) {
        Res = max(Res,F1[i] - A[i] + DP2[i + 1]);
    }
    for (int i = n; i > 1; i--) {
        Res = max(Res,F2[i] - (C - A[i]) + DP1[i - 1]);
    }
    cout << Res;
}
int main()
{
    nhap();
    solve();
}


Measured memory_bytes: 17152
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

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

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);

    int N; cin >> N;
    map<string,int> mp;
    int nmax = 0;
    REP(i,N){
        string s; cin >> s;
        mp[s]++;
        chmax(nmax,mp[s]);
    }
    vector<string> ans;
    for(auto p : mp){
        if(p.second == nmax){
            ans.eb(p.first);
        }
    }
    sort(ans.begin(),ans.end());
    for(auto s : ans){
        cout << s << endl;
    }

}


Measured memory_bytes: 25584
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
using namespace std;
    
int main(){
    string s;
    int c=0;
    cin>>s;;
    int t = (int)s.size();
    rep(i,t){
        s.pop_back();
        if(s.size()%2==0){
            rep(i,s.size()/2){
                if(s[i]==s[s.size()/2+i]) c++;
            }
            if(c==s.size()/2){
                cout<<s.size()<<endl;
                return 0;
            }
            c=0;
        }
    }
    return 0;
}


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

#define ll long long
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define SPEED ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define sz size()
#define all(x) x.begin(),x.end()
#define OO 1e18
#define iOO INT_MAX
#define Mdp memset(dp,-1,sizeof dp)
#define R return
#define Test int TT;cin>>TT;for(int T=1;T<=TT;T++)
using namespace std;
const int Mod = 1e9+7;
string k;
int d;
ll dp[10011][111][2];


ll Solve(int i=0,int m=0,int l=0)
{
    if(i == k.sz)
        R (m==0);

    ll &Res = dp[i][m][l];
    if(Res != -1)
        R Res;
    Res = 0;

    if(l)
    {
        for(int j = 0 ; j <= 9 ; j++)
        {
            Res += Solve(i+1,(m+j)%d,1);
            Res = ((Res%Mod)+Mod)%Mod;
        }
    }
    else
    {
        for(int j = 0 ; j <= k[i]-'0' ; j++)
        {
            Res += Solve(i+1,(m+j)%d,j<(k[i]-'0'));
            Res = ((Res%Mod)+Mod)%Mod;
        }
    }
    R Res;
}


int main()
{

    SPEED;
    cin >> k >> d;
    Mdp;
    ll Res = Solve()-1;
    Res = ((Res%Mod)+Mod)%Mod;
    cout << Res << endl;

    R 0;
}


Measured memory_bytes: 18432
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<queue>
#include<cmath>
#include<map>
#include<stack>
#define ll long long
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
static const int MAX = 100000;

int N, M, X;
int C[12], A[12][12];

int main(){
    cin >> N >> M >> X;
    vector<pair<int, int> > V[M];
    rep(i,N){
        cin >> C[i];
        rep(j,M){
            cin >> A[i][j];
            V[j].push_back( make_pair(A[i][j], i) );
        }
    }
    rep(i,M){
        sort(V[i].begin(), V[i].end());
    }
    int ans = 1<<30;

    rep(i,1 << N){
        int y = 0;
        int z[12];
        rep(j,12) z[j] = 0;
        rep(j,N){
            if((i >> j) & 1){
                rep(k,M) z[k] += A[j][k];
                y += C[j];
            }
        }
        bool flag = true;
        rep(j,M){
            if(z[j] < X) flag = false;
        }
        if(flag) ans = min(ans, y);
    }
    if(ans == 1<<30) ans = -1;

    cout << ans << endl;

    return 0;
}

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define int long long
#define itn int
#define pb push_back
#define m_p make_pair
#define m_t meke_tuple
#define p_p(a,b) pb(m_p(a,b))
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(all(a));reverse(all(a))
#define UNIQUE(a) a.erase(unique(all(a)),a.end())
#define SZ(a) (ll)(a.size())
#define ENDL cout<<endl
#define debg(a) cout<<#a<<" "<<a<<endl;
#define call(a) for(auto i:a)cout<<i<<" ";cout<<endl
#define show(a) rep(ghf,SZ(a)){rep(kjh,SZ(a[ghf])){cout<<(a[ghf][kjh]<10?" ":"")<<a[ghf][kjh]<<" ";}ENDL;}
#define out(a) cout<<(a)<<endl
#define fi first
#define se second
#define Vec vector
#define P pair
typedef long long ll;
typedef string str;
typedef vector<ll> V;
typedef pair<ll,ll> Pi;
typedef vector<Pi> VP;
const long long INF = 1LL<<60;
const long long MOD = 1e9+7;
int gcd(int a,int b){if(b==0)return a;return gcd(b,a%b);}
int lcm(int a,int b){return a/gcd(a,b)*b;}
int max(int a,int b){if(a>b)return a; return b;}
int min(int a,int b){if(a>b)return b; return a;}
void Yes(){cout<<"Yes"<<endl;}
void No(){cout<<"No"<<endl;}
void YN(bool b){cout<<(b?"Yes":"No")<<endl;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}

ll dp[101][4][4][4];
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int N;
  cin>>N;
  
  int a=0,g=1,c=2,t=3;
  rep(i,4){
    rep(j,4){
      rep(k,4){
        if(i==a && j==g && k==c)continue;
        if(i==g && j==a && k==c)continue;
        if(i==a && j==c && k==g)continue;
        dp[3][i][j][k]=1;
      }
    }
  }
  for(int n=4;n<=N;++n){
    rep(i,4){
      rep(j,4){
        rep(k,4){
          rep(l,4){
            if(i==a && j==g && k==c)continue; //AGC?
            if(j==a && k==g && l==c)continue; //?AGC
            if(i==g && j==a && k==c)continue; //GAC?
            if(j==g && k==a && l==c)continue; //?GAC
            if(i==a && j==c && k==g)continue; //ACG?
            if(j==a && k==c && l==g)continue; //?ACG
            if(i==a && k==g && l==c)continue; //A?GC
            if(i==a && j==g && l==c)continue; //AG?C
            dp[n][j][k][l]+=dp[n-1][i][j][k];
            dp[n][j][k][l]%=MOD;
          }
        }
      }
    }
  }
  int res=0;
  rep(i,4)rep(j,4)rep(k,4)res+=dp[N][i][j][k],res%=MOD;
  out(res);
  
  
  return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include<string.h>
#include<stdlib.h>
int cmpfunc(const void*a,const void*b){
    return(*(int*)a-*(int*)b);
}
int main()
{
    int n;
    scanf("%d",&n);
    int a[n];
    for(int i=0;i<n;i++)
    scanf("%d",&a[i]);
    qsort(a,n,sizeof(int),cmpfunc);
    printf("%d",(a[n/2]-a[(n/2)-1]));
}


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;


void add(ll& x, ll y) {
    if (x>=mod) x%=mod;
    if (y>=mod) y%=mod;
    x += y;
    if (x>=mod) x%=mod;
}



ll s;

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

    cin>>s;

    vector<ll> dp(s+1, 0);
    dp[0] = 1;

    ll res = 0;

    for (int len=1; len<=s; len++) {
	vector<ll> ndp(s+1,0);

	for (int i=0; i+3<=s; i++) {
	    add(ndp[i+3], dp[i]);
	}
	for (int i=1; i<=s; i++) {
	    add(ndp[i], ndp[i-1]);
	}

	swap(ndp,dp);
	add(res, dp[s]);
    }

    cout<<res<<endl;    
    return 0;
}


Measured memory_bytes: 3664
#include <stdio.h>
#include <stdlib.h>

long long fact(long long n)
{
  if(n == 0) return 1;
  return (n * (fact(n-1) % 1000000007)) % 1000000007;
}

int main()
{
  long long N, M;
  scanf("%lld %lld", &N, &M);
  if(abs(N-M) >= 2){
    printf("%lld\n", 0);
  }else if(N == M){
    printf("%lld\n", (2 * (fact(N) % 1000000007) * (fact(N) % 1000000007)) % 1000000007);
  }else{
    printf("%lld\n", ((fact(N) % 1000000007) * (fact(M) % 1000000007)) % 1000000007);
  }
  return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
int a[100001], ans=0;
int main ()
{
	int n, k;
	scanf("%d %d",&n,&k);
	for(int i=0;i<n;i++)
		cin>>a[i];
	
	sort(a,a+n);
	
	for(int i=n-1;i>=n-k;i--)
		ans+=a[i];
	printf("%d",ans);
	return 0;
}

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

// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();



#define int long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pii pair<int , int>
#define vi vector<int>
#define inf 1e18 //(10^18
#define pqmax priority_queue<int>
#define mii map<int , int>
#define ps(x, y) fixed<<setprecision(y)<<x
// double ans = 1.012345668992
//cout<<ps(ans , 6)
// ans = 1.012345 // 6 decimal places
#define pqmin priority_queue<int , vi , greater<int> >
#define mk(arr , n , type) type *arr = new type[n];
#define setbits(x) __builtin_popcountll(x)
#define zerobits(x) __builtin_ctzll(x)
// 48->11000(4) (returns no. of zeros after first one)
#define mod 1000000007 //1e9 +7
#define w(t) int t; cin>>t;while(t--)


void solve() {
	string s, t;
	cin >> s >> t;
	//int f = 0;
	string str = t.substr(0 , s.size() );
	for (int i = 0; i < s.size(); i++) {
		if (s[i] != str[i]) {
			cout << "No" << "\n";
			return;
		}
	}
	//cout << str << "\n";
	cout << "Yes" << "\n";
	return;


}


int32_t main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt" , "r", stdin);
//	freopen("output.txt" , "w", stdout);
#endif

	solve();
	return 0;


}





Measured memory_bytes: 3604
/**
*    created: 06.07.2020 18:17:15
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b) {if (b < a) {a = b; return 1;} return 0;}
const long double pi = acos(-1.0);
const int INF = 1LL << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

signed main() {

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

    int n, k; cin >> n >> k;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    sort(rall(a));
    int ans = 0;
    rep(i,k) ans += a[i];
    cout << ans << endl;
    return 0;
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define rep(i,N) for(int i=0;i<N;i++)

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

  int H,N;
  cin>>H>>N;
  vector<int>A(N),B(N);
  for(int i=0;i<N;i++)cin>>A[i]>>B[i];
  vector<vector<ll>>dp(N+1,vector<ll>(H+1,INT_MAX));
  dp[0][0]=0;
  for(int i=1;i<=N;i++){
    for(int j=0;j<=H;j++){
      dp[i][j]=min(dp[i-1][j],dp[i][max(j-A[i-1],0)]+B[i-1]);
      dp[i][j]=min(dp[i][j],dp[i-1][j]);
    }
  }
  cout<<dp[N][H]<<endl;
  return 0;
}



Measured memory_bytes: 78592
#include <cstring>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <numeric>
#include <stack>

using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);
typedef unordered_map<ll, ll> ump;
typedef pair<ll, ll> P;

ump mp;

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
        mp = ump();
#pragma clang diagnostic pop
#endif
        int n;
        cin >> n;
        vector<int> l(2 * n);
        rep(i, 2 * n) cin >> l[i];
        sort(l.begin(), l.end());
        int ans = 0;
        for (int i = 0; i < 2 * n; i += 2) {
            ans += l[i];
        }
        cout << ans << endl;


#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;
int enumd(int N){
    int res=0;
    for (int i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            res++;
            // 重複しないならば i の相方である N/i も push
            if (N/i != i) res++;
        }
    }
    return res;
}

int main() {
  int n,ans=0;
  cin>>n;
  for(int i=1;i<n;i++){
    long long N = n-i;
    const auto &res = enumd(N);
    ans += res;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;

int solver (vector<int> c, vector<vector<int>> s, vector<int> t){
    vector<int> last(26);
    ll st = 0, los = 0;
    REP(i, 365){
        st += s[i][t[i]-1];
        last[t[i]-1] = i+1;
        //cout << st << endl;   //満足度の低下を考えない場合
        REP(j, 365){
            los += c[j]*(i+1 - last[j]);
        }
        //cout << st << endl;
    }
    return st - los;
}

int main(){
    int D;
    cin >> D;
    vector<int> c(26);
    vector<vector<int>> s (D, vector<int>(26));    

    /// 入力部分 ///
    REP(i, 26){
        cin >> c[i];
    }
    REP(i, D){
        REP(j, 26){
            cin >> s[i][j];
        }
    }
    /// 入力部終わり ///

    random_device rnd;
    mt19937 mt(rnd());
    uniform_real_distribution<> rand(1, 27);

    vector<int> t(365);
    vector<int> best(365);
    ll st = 0, st_temp;
    int iii = 0;
    while (iii < 25e+2){
        for (int i = 0; i < 365; ++i) {
            t[i] = int(rand(mt));
            //cout << t[i] << endl;
        }

        st_temp = solver(c, s, t);
        //cout << st_temp << endl;
        if(st < st_temp){
            st = st_temp;
            best = t;
            //cout << st << endl;
        }
        iii++;
    }
    REP(i, D){
        cout << best[i] << endl;
    }
}


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

using namespace std;

const int INF = numeric_limits<int>::max();
const int MAXN = 5000+ 5;
const int MOD = 1e9 + 7;
const double res = 1e-9;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

int dp[MAXN][MAXN][2];

signed main() {
#if(DEBUG_LEVEL > 0)
    freopen("../input.txt", "r", stdin);
    freopen("../out.txt", "w", stdout);
#endif
    int n;
    cin >> n;
    string s;
    cin >> s;
    if(n < 3200) {
        cout << "red";
    }
    else {
        cout << s;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int n, m, x, y;
vector<int> Rank(100001, 0);
vector<int> parent(100001);

int find(int x);
bool isSame(int x, int y);
void unite(int x, int y);


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

    vector<int> p(n+1, 0);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &p[i]);
    }
    
    for (int i = 1; i <= n; i++ ) {
        parent[i] = i;
    }

    for (int i = 0; i < m; i++) {
        scanf("%d %d", &x, &y);
        
        if (!isSame(x, y)) 
            unite(x, y);
    }

    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if (isSame(i, p[i]))
                ans++;
    }

    cout << ans << '\n';


}


int find(int x) {
    if (x == parent[x]) return x;
    else {
        return parent[x] = find(parent[x]);
    }
}

bool isSame(int x, int y) {
    return find(x) == find(y);
}

void unite(int x, int y) {
    x = find(x);
    y = find(y);

    if (x == y) return;

    if (Rank[x] < Rank[y]) {
        parent[x] = y;
    } 
    else {
        parent[y] = x;
        if (Rank[x] == Rank[y]) 
            Rank[x]++;
    }
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
inline long long mod(long long n,long long m){return(n%m+m)%m;}
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int main(){
    int n,h,w; cin>>n>>h>>w;
    int cnt=0;
    rep(i,n){
        int a,b; cin>>a>>b;
        if(h<=a&&w<=b) cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}


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


typedef struct point{		//構造体を宣言
	double x;
	double y;
}p;

void kock(int n,p p1,p p2){
	if(n==0) return 0;		//０の場合直線
	p s,t,u;
	s.x=(2*p1.x+p2.x)/3;
	s.y=(2*p1.y+p2.y)/3;
	t.x=(p1.x+2*p2.x)/3;
	t.y=(p1.y+2*p2.y)/3;
	u.x=(t.x-s.x)*cos(M_PI*1/3)-(t.y-s.y)*sin(M_PI*1/3)+s.x;		//回転行列を用いる
	u.y=(t.x-s.x)*sin(M_PI*1/3)+(t.y-s.y)*cos(M_PI*1/3)+s.y;
	kock(n-1,p1,s);
	printf("%.8f %.8f\n",s.x,s.y);
	kock(n-1,s,u);
	printf("%.8f %.8f\n",u.x,u.y);
	kock(n-1,u,t);
	printf("%.8f %.8f\n",t.x,t.y);
	kock(n-1,t,p2);
}


int main(void){
	int n;
	scanf("%d",&n);
	p p1,p2;
	p1.x=0;
	p1.y=0;
	p2.x=100;
	p2.y=0;
	printf("%.8f %.8f\n",p1.x,p1.y);
	kock(n,p1,p2);
	printf("%.8f %.8f\n",p2.x,p2.y);
	return 0;
}


Measured memory_bytes: 2124
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

void dfs(int from, vector<vector<int>> &edges, vector<int> &a, vector<int> &ans, vector<int> &dp, int prev = -1) {

    int i = lower_bound(dp.begin(), dp.end(), a[from]) - dp.begin();
    int old = dp[i];
    dp[i] = a[from];

    ans[from] = i;
    if (prev != -1) ans[from] = max(ans[from], ans[prev]);

    for (int next : edges[from]) {
        if (next == prev) continue;
        dfs(next, edges, a, ans, dp, from);
    }
    dp[i] = old;
}

int main() {

    int n;
    cin >> n;

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

    vector<vector<int>> edges(n);

    rep(i, n - 1) {
        int u, v;
        cin >> u >> v;
        u--;
        v--;

        edges[u].push_back(v);
        edges[v].push_back(u);
    }
    vector<int> dp(n, INT_MAX);
    vector<int> ans(n);
    dp[0] = INT_MIN;

    dfs(0, edges, a, ans, dp);
    for (int now : ans) cout << now << endl;

}


Measured memory_bytes: 33568
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
long long n,a,b,c,d;
int main(){
	while(scanf("%lld",&n)==1){
	scanf("%lld %lld %lld %lld",&a,&b,&c,&d);
	for(int i=0;i<=n-1;i++){
		if((b-a)>=(i*c-(n-i-1)*d)&&(b-a)<=(i*d-(n-i-1)*c)){
			printf("YES");
			return 0;
			}
		}
	}
	printf("NO");
	return 0;	
}

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

int main()
{
  ll n, even, odd, four;
  even = odd = four = 0;
  cin >> n;
  vector<ll> a(n);
  for (ll i = 0; i < n; i++)
  {
    cin >> a.at(i);
    if (a.at(i) % 4 == 0)
    {
      four++;
    }
    else if (a.at(i) % 2 == 0)
    {
      even++;
    }
    else
    {
      odd++;
    }
  }
  if (four + 1 == odd && four + odd == n)
  {
    cout << "Yes" << endl;
  }
  else if (four < odd)
  {
    cout << "No" << endl;
  }
  else
  {
    cout << "Yes" << endl;
  }
}


Measured memory_bytes: 4032
#![allow(unused_imports)]
#![allow(unused_macros)]
#![allow(unused_variables)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(non_upper_case_globals)]
#![macro_use]
use std::cmp::*;
use std::collections::*;
use std::io::*;
use std::mem::*;
use std::num::*;
use std::ops::*;
use std::rc::*;
use std::str::*;
use std::string::*;
use std::*;

const MOD: usize = 1000000007;

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    // ========================================= //
    let N:usize = sc.read();
    let M:usize = sc.read();
    let H:Vec<usize> = sc.vec(N);
    let mut A:Vec<usize> = vec![0;M];
    let mut B:Vec<usize> = vec![0;M];
    let mut G: Vec<usize> = vec![0;N];
    for i in 0..M {
        // let a:usize = sc.read();
        // let b:usize = sc.read();
        let v:Vec<usize> = sc.vec(2);
        A[i] = v[0]-1;
        B[i] = v[1]-1;
        G[A[i]] = max(G[A[i]],H[B[i]]);
        G[B[i]] = max(G[B[i]],H[A[i]]);
    }

    let mut ans = 0;
    for (i,h) in G.iter().enumerate() {
        if H[i] > *h {
            ans += 1;
        }
    }
    
    sc.write(ans);

    

}


pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);
impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> Self {
        Self(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 5256
x,y,a,b,c = map(int,input().split())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))

p.sort(reverse = True)
q.sort(reverse = True)

p = p[:x]
q = q[:y]

s = p+q+r
s.sort(reverse = True)
print(sum(s[:x+y]))

Measured memory_bytes: 111980
import sys
import math
#import random
#sys.setrecursionlimit(100000000)
input = sys.stdin.readline
 
############ ---- USER DEFINED INPUT FUNCTIONS ---- ############
def inp():
    return(int(input()))
def inara():
    return(list(map(int,input().split())))
def insr():
    s = input()
    return(list(s[:len(s) - 1]))
def invr():
    return(map(int,input().split()))
################################################################
############ ---- THE ACTUAL CODE STARTS BELOW ---- ############

n=inp()
ara=inara()
for num in ara:
	if num==0:
		print(0)
		exit(0)

ans=1
for num in ara:
	ans*=num
	if ans>1000000000000000000:
		print(-1)
		exit(0)

print(ans)
	


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

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

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define LB lower_bound
#define UB upper_bound

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL INF = 1e9;
const LL MOD = 1e9+7;

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

//memo
// setprecision()

int main() {
  int a,b;
  cin >> a >> b;
  VS S(2);
  string A = toString(a);
  string B = toString(b);
  
  REP(i,b) S.at(0)+=A;
  REP(i,a) S.at(1)+=B;
  
  SORT(S);
  
  cout << S.at(0) << endl;
  
  return 0;
}

Measured memory_bytes: 256
X = int(input())

def prime_checker(x):
  for i in range(2, int(x**0.5)+1):
    if x%i == 0:
      return False
  return True

is_prime = False
while(not is_prime):
  is_prime = prime_checker(X)
  X += 1

X = X - 1
print(X)

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

int main(){
    int a,b;
    cin>>a>>b;
    if(a > b){
    	int t =a;
    	a = b;
    	b  = t;
	}
	for(int i = 1;i<=b;i++){
		cout<<a;
	}
	cout<<endl;
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e16+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}


vector<ll> divisor(ll n) {
    vector<ll> ret;
    for(ll i=1; i*i<=n; i++) {
        if(n%i==0) {
            ret.pb(i);
            if(i*i!=n) {
                ret.pb(n/i);
            }
        }
    }
    sort(ALL(ret));
    return ret;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);

    ll n,m;
    cin>>n>>m;

    ll ans=0;
    Vec ret = divisor(m);
    rep(i,ret.size()){
        if(m/ret[i] >= n){
            ans = ret[i];
        }
    }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(long long i=0; i<n; i++)
#define Rep(i,n) for(long long i=1; i<n; i++)
#define ll long long
#include <math.h>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <vector>


using namespace std;
#define PI acos(-1)
using P =pair<int,int>;

ll ketasu(ll a){
   ll num=1;
   while(a/10){
       num++;
       a/=10;
   }
   return num;
}

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

ll kosuu(ll a){
    ll sum=0;
    for(ll i=1;i*i<=a;i++){
        if(a%i==0){
            if(a!=1&&i*i!=a){
            sum+=2;
            }else{
             sum++;   
            }
        }
    }
    return sum;
}

ll n;



    vector<pair<ll,ll>>p;
void fs(ll a){
    for(ll i=2;i*i<=n;i++){
        ll cnt=0;
        while(n%i==0){
            n/=i;
            cnt++;
        }
        p.emplace_back(i,cnt);
    }
    return;
}

const int m=2019;
int main()
{


const int di[]={-1,0,1,0};
const int dj[]={0,-1,0,1};

    ll h,w;
    cin>>h>>w;
    ll si,sj;
    cin>>si>>sj;
    ll ti,tj;
    cin>>ti>>tj;
    si--;sj--;ti--;tj--;
    vector<string>s(h);
    rep(i,h)cin>>s[i];
    const int inf=1000000000;
    vector<vector<int>> dist(h,vector<int>(w,inf));
    deque<P>q;
    dist[si][sj]=0;
    q.emplace_back(si,sj);
    while(!q.empty()){
        int i=q.front().first;
        int j=q.front().second;
        q.pop_front();
        int d=dist[i][j];
        rep(v,4){
            int ni=i+di[v],nj=j+dj[v];
            if(ni<0||h<=ni||nj<0||w<=nj)continue;
            if(s[ni][nj]=='#')continue;
            if(dist[ni][nj]<=d)continue;
            dist[ni][nj]=d;
            q.emplace_front(ni,nj);
        }
        for(int ei=-2;ei<=2;++ei){
            for(int ej=-2;ej<=2;++ej){
                int ni=i+ei,nj=j+ej;
                if(ni<0||h<=ni||nj<0||w<=nj)continue;
                if(s[ni][nj]=='#')continue;
                if(dist[ni][nj]<=d+1)continue;
                dist[ni][nj]=d+1;
                q.emplace_back(ni,nj);
            }
        }
    }
    int ans=dist[ti][tj];
    if(ans==inf)ans=-1;
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 9472
from itertools import combinations

n, m, q = map(int, input().split())

a, b, c, d = [], [], [], []
for i in range(q):
    a_, b_, c_, d_ = map(int, input().split())
    a.append(a_ - 1)
    b.append(b_ - 1)
    c.append(c_)
    d.append(d_)

max_score = 0
for t in combinations(list(range(m-1+n)), n):
    cur = 1
    A = []
    for i in range(m-1+n):
        if i in t:
            A.append(cur)
        else:
            cur += 1

    score = 0
    for k in range(q):
        if A[b[k]] - A[a[k]] == c[k]:
            score += d[k]
    max_score = max(max_score, score)

print(max_score)

Measured memory_bytes: 68496
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define RFOR(i,a,b) for(int i=(b-1); i>=(a); i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
using ll = long long;
using D = double;
using LD = long double;
using P = pair<int, int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
    ll x,y,a,b,c; cin >> x >> y >> a >> b >> c;
    vector<ll> p(a), q(b), r(c);
    rep(i,a) cin >> p[i];
    rep(i,b) cin >> q[i];
    rep(i,c) cin >> r[i];
    sort(RALL(p)); sort(RALL(q)); sort(RALL(r));
    ll ans = 0;
    priority_queue<ll, vector<ll>, greater<ll> > que;
    rep(i,x) {
        ans += p[i];
        que.push(p[i]);
    }
    rep(i,y) {
        ans += q[i];
        que.push(q[i]);
    }
    rep(i,c){
        ll num = r[i];
        ll tmp = que.top();
        if(num > tmp){
            ans -= tmp;
            que.pop();
            que.push(num);
            ans += num;
        }
        else break;
    }
    cout << ans << endl;
}


Measured memory_bytes: 4724