akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
using namespace std;
#define mp make_pair
#define pb push_back
#define pf push_fron
#define INF 1e9
typedef long long ll;

#define PI acos(-1)

int main() {
	
	int a, b, c, d;
	int bus, train;
	cin >> a >> b >> c >> d;
	if (a > b) train = b;
	else train = a;

	if (c > d)bus = d;
	else bus = c;

	cout << train + bus << endl;

	return 0;
}

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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(i = 0; i < n; i++)

const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

typedef long long ll;

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

/*
int N;
ll h[100010];

// DP テーブル
ll dp[100010];
*/

int main()
{
	int a, b; cin >> a >> b;
	int max_ = -1200;
	max_ = max(max_, a + b);
	max_ = max(max_, a - b);
	max_ = max(max_, a * b);

	cout << max_ << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vp;
typedef pair<int,int> pii;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
/*--------------------------------------------*/

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

    string s,t;
    cin >> s >> t;
    cout << t << s << endl;

}


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


int main() {
  int n;
  scanf("%d", &n);
  int c1, c2, c3, c4;
  c1 = n % 10;
  n = n / 10;
  c2 = n % 10;
  n = n / 10;
  c3 = n % 10;
  n = n / 10;
  c4 = n % 10;


  if ((c1 == c2 && c2 == c3) || (c2 == c3 && c3 == c4)) {
    printf("Yes");
  } else {
    printf("No");
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
        new Main().run();
    }
	public void run(){
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			int n = scan.nextInt();
			for(int k = 0;k < n;k++){
				String str = scan.next();
				String train = str.charAt(0) + "";
				int now = 0;
				for(int i = 1;i < str.length();i+=3){
					if(str.charAt(i) == '-'){
						if(now == train.length()-1){
							train += str.charAt(i+2);
						}
						now++;
					}else if(str.charAt(i) == '<'){
						if(now == 0){
							train = str.charAt(i+2) + train;
						}else{
							now--;
						}
					}
				}
				System.out.println(train);
			}
		}
	}
}

Measured memory_bytes: 21232
#include"bits/stdc++.h"
//#include<bits/stdc++.h>
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
typedef long long ll;
const int mod = 100000003;


int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a <= c&&b >= c) { print("Yes"); }
	else { print("No"); }
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    long x, y;

    public static void main(String args[]) {
        new Main().run();
    }

    void run() {
        FastReader sc = new FastReader();
        x = sc.nextLong();
        y = sc.nextLong();
        solve();
    }

    void solve() {
        int length = 0;
        long num = x;
        while (num <= y) {
            num *= 2;
            length++;
        }
        System.out.println(length);
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 21076
#include <bits/stdc++.h>
#include<algorithm>
#include<math.h>
using namespace std;
 
template <class T> using V = vector<T>;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(ll)(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
ll combi(ll n,ll m) {
  ll ans=1;
  rFOR(i,n,n-m){
    ans*=i;
  }
  FOR(i,1,m+1){
    ans/=i;
  }
  return ans;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll n,m;
    ci(n>>m)
  ll ans=0;
  FOR(i,0,100){
    if(n<=m) {
      ans++;
    n*=2;
  }
    else break;
  }
  co(ans)
}

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

int main(){
    int N;
    cin >> N;
    if (N % 1000 == 0){
        cout << 0 << endl;
    }
    else{
        cout << 1000 - N % 1000 << endl;
    }
   return 0;
}

Measured memory_bytes: 3620
long d['~~'];A,x,i,j;main(n){for(scanf("%d%d",&n,&A),d[n*=A]=1;~scanf("%d",&x);i=5e3-i)for(x-=A,j=2*n;j--;)d[5000-i+j]=d[i+j]+d[j<x?:i+j-x];printf("%ld",d[i+n]-1);}

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

using namespace std;

typedef long long ll;
typedef long double ld;

const int N = 1e5 + 5;
int dp[N][2];
string s;

int solve(int idx, int prv){
	if(idx == s.size())
		return 0;
	int &ans = dp[idx][prv];
	if(~ans)
		return ans;
	if(s[idx] - '0' == prv)
		return ans = solve(idx + 1, !prv) + 1;
	else
		return ans = solve(idx + 1, !prv);
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifdef ONLINE_JUDGE
    // freopen("", "r", stdin);
    // freopen("", "w", stdout);
#endif
	cin >> s;
	memset(dp, -1, sizeof dp);
	cout << min(solve(0, 0), solve(0, 1));
	return 0;
}


Measured memory_bytes: 7700
#include<iostream>
#include<cctype>
#include<cstring>
using namespace std;

int main(){
    char x;
    int alp['z'-'a' + 1] = {};
    int p = 1000000;
    while(p){
        scanf("%c",&x);
        if(isalpha(x)){ 
            if(isupper(x)){
                x = tolower(x);
            }

            for(char y = 'a'; y <= 'z'; y++){
                if(y == x){
                    alp[y-'a']++;
                }
            }
        }
        p--;
    }

    for(int i = 0; i < 'z'-'a' + 1; i++){
        cout << (char)('a'+i) << " : " << alp[i] << endl;
    }

    return 0;
}


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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >=0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

typedef long long ll;
#define INF 1e9

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



int main(){
  int N;
  cin >> N;
  vector<int> s(N+1, 0), so(1,0);
  int sum10 = 0;
  FOR(i, 1, N+1){
    cin >> s[i];
    if(s[i] % 10 == 0){
      sum10 += s[i];
    }
    else{
      so.push_back(s[i]);
    }
  }
  int ans = 0;
  sort(so.begin(), so.end());
  REP(i, so.size()){
    ans += so[i];
  }
  if(ans % 10 == 0){
    ans -= so[1];
  }
  if(ans != 0)
    ans += sum10;
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
import sys
f = sys.stdin

def is_leapyear(year):
    return year % 4 == 0 and (year % 100 != 0 or year % 400 == 0)
i = 0
while True:
    a, b = map(int, f.readline().split())
    if a == b == 0:
        break
    if i:
        print()
    leapyear = [year for year in range(a, b + 1) if is_leapyear(year)]
    print('\n'.join(map(str, leapyear)) if leapyear else 'NA')
    i += 1

Measured memory_bytes: 6720
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
 
struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};



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

    vvec<int> fr_d(n);
    vvec<int> bl(n);
    UnionFind uf(n);

    rep(i, m) {
        int a, b; cin >> a >> b;
        a--, b--;
        uf.unite(a, b);
        fr_d[a].push_back(b);
        fr_d[b].push_back(a);
    }
    rep(i, k) {
        int c, d; cin >> c >> d;
        c--, d--;
        bl[c].push_back(d);
        bl[d].push_back(c);       
    }

    vec<set<int>> fr(n);
    rep(i, n) {
        fr[uf.find(i)].insert(i);
    }    

    rep(i, n) {
        int ans = fr[uf.find(i)].size() - 1;
        rep(j, bl[i].size()) {
            set<int>::iterator it = fr[uf.find(i)].find(bl[i][j]);
            if (it != fr[uf.find(i)].end()) { // 見つかった
                ans--;
            }
        }
        rep(j, fr_d[i].size()) {
            set<int>::iterator it = fr[uf.find(i)].find(fr_d[i][j]);
            if (it != fr[uf.find(i)].end()) { // 見つかった
                ans--;
            }            
        }
        cout << ans << " ";
    }
    cout << endl;
    
}

Measured memory_bytes: 21624
#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int n;
	cin>>n;
	cout<<int ((n-1)/2);
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

    int n; cin>>n;
    vector<int> a(n);
    for(int i=0; i<n; i++) cin>>a[i];

    multiset<int> st;
    st.emplace(-1);

    for(int i=0; i<n; i++){
        auto itr = st.lower_bound(a[i]);
        itr--;

        if(*itr != -1) st.erase(itr);
        st.emplace(a[i]);
    }

    cout << st.size() - 1 << endl;

    return 0;
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

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

    vector<vector<P>> e(n);
    vll a(m), b(m);
    ll ma = 0;
    REP(i, m) {
        ll u, v;
        cin >> u >> v;
        u--, v--;
        e[u].push_back({v, i});
        e[v].push_back({u, i});
        cin >> a[i] >> b[i];
        ma = max(ma, a[i]);
    }
    vll p(n), q(n);
    REP(i, n) {
        cin >> p[i] >> q[i];
    }

    // d[i][yen] : i で yen 円持っている状態までの最短時間
    // ub 円以上持っているときもう両替せずともどこにでも行ける
    ll ub = (n - 1) * ma + 10;
    vvll d(n, vll(ub + 1, inf)), used(n, vll(ub + 1));
    s = min(s, ub);
    ll cur = 0, yen;
    d[cur][s] = 0;
    used[cur][s] = 1;

    queue<P> que;
    que.push({cur, s});

    vll res(n, inf);
    res[0] = 0;

    while (!que.empty()) {
        cur = que.front().first;
        yen = que.front().second;
        que.pop();
        res[cur] = min(res[cur], d[cur][yen]);
        for (auto ee : e[cur]) {
            ll to = ee.first, id = ee.second;
            if (yen < a[id]) continue;
            if (d[cur][yen] + b[id] < d[to][yen - a[id]]) {
                used[to][yen - a[id]] = 1;
                d[to][yen - a[id]] = d[cur][yen] + b[id];
                que.push({to, yen - a[id]});
            }
        }
        ll buy = min(ub, yen + p[cur]);
        if (d[cur][yen] + q[cur] < d[cur][buy]) {
            used[cur][buy] = 1;
            d[cur][buy] = d[cur][yen] + q[cur];
            que.push({cur, buy});
        }
    }
    REP(i, n - 1) {
        cout << res[i + 1] << endl;
    }
    return 0;
}

Measured memory_bytes: 6260
#include <iostream>
#include <algorithm>
#include <math.h>
#include <stdio.h>
using namespace std;
typedef long long ll;

int main(){
  int n, x, y;
  int card[4][13] = {};
  string s, t;
  t = "SHCD";
  cin >> n;
  for (int i = 0; i < n; i++){
  	cin >> s >> y;
    x = t.find(s);
    card[x][y-1] = 1;
  }
  
  for (int i = 0; i < 4; i++){
  	for (int j = 0; j < 13; j++){
    	if (card[i][j] == 0) cout << t[i] << " " << j+1 << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repp(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)
#define p(s) cout << s << endl;
typedef long long LL;
template <class T>
bool contain(const std::string &s, const T &v)
{
    return s.find(v) != std::string::npos;
}

int main()
{
    int a[12] = {0,2,0,1,0,1,0,0,1,0,1,0};
    int x,y; cin>>x>>y;
    if(a[x-1]==a[y-1]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#define SENTINEL 1000000009; 
#define MAX 500000
using namespace std;
int A[MAX];
int _count=0;


void Merge(int left, int mid, int right){
    int n1 = mid-left;
    int n2 = right - mid;
    int L[n1], R[n2];
    for(int i=0;i<=n1-1; i++)L[i]=A[left+i];
    for(int i=0;i<=n2-1; i++)R[i]=A[mid+i];
    L[n1]=SENTINEL;
    R[n2]=SENTINEL;
    int i=0;
    int j=0;
    for(int k=left;k<=right-1;k++){
        _count+=1;
        if(L[i]<=R[j]){
            A[k]=L[i];
            i++;
        }
        else {
            A[k]=R[j]; j++;
            }
    }
}

void MergeSort(int left, int right){
    if (left+1<right){
        int mid=(left+right)/2;
        MergeSort(left, mid);
        MergeSort(mid, right);
        Merge(left,mid,right);
    }
}


int main(){
    int n;
    cin >> n;
    for(int i=0;i<=n-1;i++){
        cin >> A[i];
    }
    MergeSort(0, n);
    for(int i=0;i<=n-1; i++){
        cout << A[i];
        if (i==n-1){
            cout << "\n";
        }
        else cout <<' ';
    }
    cout << _count << "\n";
}


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

int main() {
	int N; cin >> N;
	int a[2][110];
	int su1 = 0, su2 = 0;
	int z[110];
	for (int i = 0; i < N; i++) {
		cin>>a[0][i];
		z[i] = 0;
	}
	for (int i = 0; i < N; i++) {
		cin>>a[1][i];
	}
	int ans = 0;
	for (int i = 0; i < N; i++) {
		su1 += a[0][i];
		z[i] += su1;
		su2 += a[1][N - 1 - i];
		z[N-i-1] += su2;
	}
	sort(z, z + N);
	cout << z[N - 1];
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define taskname "A"
#define pb push_back
#define mp make_pair
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
const int maxn = 3e3 + 5;
const int logn = log2(maxn) + 1;
const int mod = 1e9 + 7;
int n , m;
string s;
int r[maxn];
int dp[maxn][maxn];
int sum[maxn];

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    if(fopen(taskname".INP", "r")) {
        freopen(taskname".INP", "r", stdin);
        freopen(taskname".OUT", "w", stdout);
    }
    cin >> n >> m;
    cin >> s;
    for(int i = 1 ; i <= n ; ++i){
        sum[i] = sum[i - 1] + (s[i - 1] == '1');
        r[i] = i;
    }
    for(int i = 1 ; i <= m ; ++i){
        int l , rr;cin >> l >> rr;
        r[l] = max(r[l] , rr);
    }
    for(int i = 1 ; i <= n ; ++i)r[i] = max(r[i] , r[i - 1]);
    r[n + 1] = r[n];
    dp[1][sum[r[1]]] = 1;
    for(int i = 1 ; i <= n ; ++i){
        for(int j = 0 ; j <= n ; ++j){
            auto add = [&](int & x , int y){
                x += y;
                if(x >= mod)x-=mod;
            };
            if(j > 0)add(dp[i + 1][j + sum[r[i + 1]] - sum[r[i]] - 1] , dp[i][j]);
            if(r[i] - i + 1 > j)add(dp[i + 1][j + sum[r[i + 1]] - sum[r[i]]] , dp[i][j]);
        }
    }
    cout << dp[n + 1][0];
}


Measured memory_bytes: 35456
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <map>
 
using namespace std;
typedef long long ll;


ll ans,mx,sum;
int main(){
	ll x;
	cin>>x;
	ll cnt=1;
	while(x!=0){
		if(x < cnt) {
			ans++;
			break;
		}
		if(x >= cnt){
			x-=cnt;
			cnt++;
			ans++;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <complex>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <stack> 
#include <bitset>
#include <queue>
#include <assert.h>
#include <unordered_map>
using namespace std;

long long a[100010];
int main()
{
	int n;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
		scanf("%lld", &a[i]);
	sort(a + 1, a + n + 1);
	if (a[1] == 0) {
		printf("0\n");
		return 0;
	}

	long long ans = 1;
	for (int i = 1; i <= n; i++) {
		if (1000000000000000000LL / ans < a[i]) {
			printf("-1\n");
			return 0;
		}
		ans *= a[i];
	}

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


Measured memory_bytes: 4012
H,W = map(int,input().split())
A = [input() for _ in range(H)]
A = list(filter(lambda a: any(x=='#' for x in a), A)) 
A = list(filter(lambda a: any(x=='#' for x in a), zip(*A)))

for a in zip(*A):
  print("".join(a))

Measured memory_bytes: 9260
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,r,min1;
cin>>r>>n;
int a[n];
for(int i=0;i<n;i++)
cin>>a[i];

min1=a[n-1]-a[0];
for(int i=0;i<n-1;i++){
	min1=min(min1,r-(a[i+1]-a[i]));
}
cout<<min1<<endl;
return 0;
}


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

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    int l1 = 100*a;
    if(l1 % 8) {
        l1 /= 8;
        l1++;
    }
    else{
        l1 /=8;
    }
    int r1 = 100*(a+1);
    if(r1 % 8 == 0)
        r1 /= 8;
    else{
        r1 /= 8;
        r1++;
    }
    int l2 = 100 * b;
    if(l2 % 10) {
        l2 /= 10;
        l2 ++;
    }
    else{
        l2 /= 10;
    }
    int r2 = 100*(b+1);
    if(r2 % 10 == 0)
        r2 /= 10;
    else{
        r2 /= 10;
        r2++;
    }
    r1--;r2--;
    //cout << l1 << ' ' << r1 << ' ' <<l2 << ' ' << r2 << endl;
    for(int i = l1; i <= r1; i++){
        if(i >= l2 and i <= r2){
            cout << i;
            return 0;
        }
    }
    cout << "-1";
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
int gi() { 
	int res = 0, w = 1; 
	char ch = getchar(); 
	while (ch != '-' && !isdigit(ch)) ch = getchar(); 
	if (ch == '-') w = -1, ch = getchar(); 
	while (isdigit(ch)) res = res * 10 + ch - '0', ch = getchar(); 
	return res * w; 
} 
const int INF = 1e9; 
const int MAX_N = 2e5 + 5;
int N, a[MAX_N], val[MAX_N]; 
#define lson (o << 1)
#define rson (o << 1 | 1)
struct SGT { 
	int mx[MAX_N << 2]; 
	void pushup(int o) { mx[o] = max(mx[lson], mx[rson]); } 
	void build(int o = 1, int l = 1, int r = N) { 
		if (l == r) return (void)(mx[o] = -INF);
		int mid = (l + r) >> 1; 
		build(lson, l, mid), build(rson, mid + 1, r); 
		pushup(o); 
	} 
	void mdf(int pos, int v, int o = 1, int l = 1, int r = N) { 
		if (l == r) return (void)(mx[o] = v); 
		int mid = (l + r) >> 1; 
		if (pos <= mid) mdf(pos, v, lson, l, mid); 
		else mdf(pos, v, rson, mid + 1, r); 
		pushup(o); 
	} 
	int qry(int ql, int qr, int o = 1, int l = 1, int r = N) { 
		if (ql <= l && r <= qr) return mx[o]; 
		int mid = (l + r) >> 1, res = -INF; 
		if (ql <= mid) res = max(res, qry(ql, qr, lson, l, mid)); 
		if (qr > mid) res = max(res, qry(ql, qr, rson, mid + 1, r)); 
		return res; 
	} 
} t[2]; 
int cnt[MAX_N]; 
bool check(int mx, int v) {
	if (v < 0) return 0; 
	int len = t[v & 1].qry(mx, N); 
	return len >= v; 
}

int main () { 
	N = gi(); 
	for (int i = 1, mx = 0; i <= N; i++) { 
		a[i] = gi(); 
		if (a[i] > mx) mx = a[i], val[i] = 2; 
		else val[i] = 1; 
	} 
	t[1].build(); 
	for (int i = N; i; i--) { 
		int mx0 = t[0].qry(a[i], N), mx1 = t[1].qry(a[i], N); 
		if (val[i] & 1) t[0].mdf(a[i], mx1 + 1), t[1].mdf(a[i], mx0 + 1); 
		else t[0].mdf(a[i], mx0 + 2), t[1].mdf(a[i], mx1 + 2); 
	} 
	for (int i = N; i; i--) cnt[i] = cnt[i + 1] + (val[i] == 2); 
	vector<int> ans; 
	int cntX = 0, cntY = 0, mxX = 0, mxY = 0; 
	for (int i = 1; i <= N; i++) { 
		t[1].mdf(a[i], -INF), t[0].mdf(a[i], 0); 
		int _1 = cntX, _2 = mxX; 
		if (a[i] > mxX) mxX = a[i], ++cntX; 
		if (check(mxY, cntX + cnt[i + 1] - cntY) || check(mxX, cntY + cnt[i + 1] - cntX)) ans.push_back(0); 
		else { 
			cntX = _1, mxX = _2; 
			if (a[i] > mxY) mxY = a[i], ++cntY; 
			ans.push_back(1); 
		} 
	}
	if (cntX != cntY) return puts("-1") & 0; 
	for (int i = 0; i < (int)ans.size(); i++) putchar(ans[i] + '0'); 
	putchar('\n'); 
    return 0; 
} 

Measured memory_bytes: 10732
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#define REP(i,n) for(int i = 0; i < (int)n; i++)
using namespace std;

int main(){
  string s;
  cin >> s;
  if(s[0]==s[2]){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

int main(){
  int n; cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  rep(i,n){
    if(a[i] == 0){
      cout << 0 << endl;
      return 0;
    }
  }
  double now1 = 1;
  ll now2 = 1;
  rep(i,n){
    now1 *= a[i];
    now2 *= a[i];
    if(now1 > 1000000000000000000 || now2 > 1000000000000000000){
      cout << -1 << endl;
      return 0;
    }
  }
  cout << now2 << endl;
}


Measured memory_bytes: 4052
# デバッグ用
GBN_DEBUG = False
GBN_DEBUG = True
def dprn(s, i):
    if GBN_DEBUG: print(", " + s + " = " + str(i), end = "")
def dprns(s):
    if GBN_DEBUG: print(", " + s, end = "")
def dprni(i):
    if GBN_DEBUG: print(i, end=" ")
def endl(): 
    if GBN_DEBUG: print('')
def puts(s): print(s)

#本体ここから

#S = input()
#N = int(input())
#S, T = input().split()
N, M = map(int, input().split())
#W = [input() for _ in range(N)]
#A = A = list(map(int, input().split()))

ans = N * (N - 1) // 2 + M * (M - 1) // 2
print(ans)


Measured memory_bytes: 3060
import java.util.Scanner;


public class Main{
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNextInt()) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			int n = sc.nextInt();
			System.out.println(sumOfDecimalPlaces(a, b, n));
		}
		sc.close();
	}
	
	static int sumOfDecimalPlaces(int a, int b, int n) {
		int result = 0;
		int remain = a % b;
		int i = 0;
		while(remain != 0 && i < n) {
			remain = remain * 10;
			result += remain / b;
			remain = remain % b;
			i++;
		}
		return result;
	}
}

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

int main() {
    set<int> st;
    int a,b,c;
    cin >> a >> b >> c;
    st.insert(a);
    st.insert(b);
    st.insert(c);
    cout << (st.size() == 2? "Yes":"No") << endl;
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  rep(i,n) cin >> s.at(i);
  
  map<string,int> a;
  rep(i,n) a[s.at(i)]++;
  
  cout << a.size() << endl;
}

Measured memory_bytes: 25084
#include <bits/stdc++.h>
using namespace std;
int main(){
    int X,Y,Z,K;
    cin>>X>>Y>>Z>>K;
    vector<long long>A(X);
    vector<long long>B(Y);
    vector<long long>C(Z);
    for(int i=0;i<X;i++){
        cin>>A[i];
    }
    for(int i=0;i<Y;i++){
        cin>>B[i];
    }
    for(int i=0;i<Z;i++){
        cin>>C[i];
    }
    vector<long long>AB;
    for(int i=0;i<X;i++){
        for(int j=0;j<Y;j++){
            AB.push_back(A[i]+B[j]);
        }
    }
    vector<long long>ABC;
    sort(AB.begin(),AB.end(),greater<long long>());
    int sz=AB.size();
    int m=min(sz,K);
    for(int i=0;i<m;i++){
        for(int j=0;j<Z;j++){
            ABC.push_back(AB[i]+C[j]);
        }
    }
    sort(ABC.begin(),ABC.end(),greater<long long>());
    for(int i=0;i<K;i++){
        cout<<ABC[i]<<endl;
    }
}

Measured memory_bytes: 43368
dice1 = input().split()
dice2 = input().split()

# 上面を合わせる
d1 = {dice2[0]: "123456", dice2[1]: "263415", dice2[2]: "326154", dice2[3]: "421653", dice2[4]: "513462",
      dice2[5]: "653421"}
dice2 = [dice2[int(i) - 1] for i in d1[dice1[0]]]
# 側面を合わせる
d2 = {dice2[1]: "123456", dice2[2]: "135246", dice2[3]: "142536", dice2[4]: "154326"}
dice2 = [dice2[int(i) - 1] for i in d2[dice1[1]]]
# 裏表でセットにする
dice1 = sorted([[dice1[0], dice1[3]], [dice1[1], dice1[4]], [dice1[2], dice1[5]]])
dice2 = sorted([[dice2[0], dice2[3]], [dice2[1], dice2[4]], [dice2[2], dice2[5]]])
if dice1 == dice2:
    print("Yes")
else:
    print("No")



Measured memory_bytes: 5620
package main

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

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func minInt(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

func absInt(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func absFloat64(a float64) float64 {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func maxFloat64(a, b float64) float64 {
	if a > b {
		return a
	} else {
		return b
	}
}

func minFloat64(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}

func str2Int(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	if x == 2 {
		return true
	}
	if x%2 == 0 {
		return false
	}

	b := true
	rootx := int(math.Sqrt(float64(x)))
	i := 3
	for i <= rootx {
		if x%i == 0 {
			b = false
			break
		}
		i += 2
	}
	return b
}

func PrimeFactors(n int) (pfs []int) {
	// Get the number of 2s that divide n
	for n%2 == 0 {
		pfs = append(pfs, 2)
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			pfs = append(pfs, i)
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs = append(pfs, n)
	}

	return
}

//Main
const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		return sc
	}()
)

var N, M, L, R int

func main() {
	sc.Split(bufio.ScanWords)

	N, M = nextInt(), nextInt()

	maxL := 0
	minR := 100000 + 2
	for i := 0; i < M; i++ {
		L, R = nextInt(), nextInt()
		maxL = maxInt(maxL, L)
		minR = minInt(minR, R)
	}

	if maxL > minR {
		fmt.Println(0)
	} else {
		fmt.Println(minR - maxL + 1)
	}
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;


const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()


int main(){
    int N;
    cin>>N;
    vector<ll> A(N);
    ll M=0,ans=0;
    map<int,ll> mp;
    rep(i,N){
        cin>>A[i];
        mp[A[i]]++;
        M=max(M,A[i]);
    }

    for(auto x:mp){
        ll i=x.first;
        if(i==mp[i])continue;
        else if(mp[i]>i)ans+=(mp[i]-i);
        else ans+=mp[i];
    }

    cout<<ans<<endl;

    return 0;
}

//a=97,z=122

Measured memory_bytes: 7040
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

#############
# Main Code #
#############

def or_less(array, x):
    # arrayの中のx以下のものの個数
    # arrayの中のx以下のもののうちの最大値
    index = bisect_right(array, x)
    if index == 0:
        or_less_int = -float('inf')
    else:
        or_less_int = array[index - 1]
    return [index, or_less_int]

N, M, K = getNM()
A = getList()
A.insert(0, 0)
B = getList()

A_imos = copy.deepcopy(A)
for i in range(N):
    A_imos[i + 1] += A_imos[i]

B_imos = copy.deepcopy(B)
for i in range(M - 1):
    B_imos[i + 1] += B_imos[i]

ans = 0
for i in range(N + 1):
    if A_imos[i] > K:
        continue
    index = or_less(B_imos, K - A_imos[i])[0]
    ans = max(ans, i + index)
print(ans)

Measured memory_bytes: 127856
from collections import deque
n,m=map(int,input().split())
G=[[] for i in range(n)]
dist=[None]*n
for i in range(m):
    l,r,d=map(int,input().split())
    G[l-1].append([r-1,d])
    G[r-1].append([l-1,-d])

for i in range(n):
    q=deque()
    if dist[i]==None:
        dist[i]=0
        q.append(i)
    while q:
        cur=q.popleft()
        for nx,d in G[cur]:
            if dist[nx]==None:
                dist[nx]=dist[cur]+d
                q.append(nx)
            elif dist[nx]!=dist[cur]+d:
                print('No')
                exit()
print('Yes')


Measured memory_bytes: 77320
while True:
    d, w, h = (int(x) for x in input().split())
    if d == 0: break
    q = int(input())
    vmin = min(d * d + w * w, d * d + h * h, w * w + h * h)
    
    for i in range(0,q):
    	r = int(input())
    	ans = 'NA'
    	if (2 * r) ** 2 > vmin:
    	    ans = 'OK'
    	print(ans)


Measured memory_bytes: 5600
def main():
    import sys
    input = sys.stdin.buffer.readline
    H, W = (int(i) for i in input().split())
    A = [[int(i) for i in input().split()] for j in range(H)]
    ans = []
    for h in range(H):
        for w in range(W):
            if A[h][w] % 2 == 1:
                if w != W-1:
                    A[h][w] -= 1
                    A[h][w+1] += 1
                    ans.append((h+1, w+1, h+1, w+2))
                elif h != H-1:
                    A[h][w] -= 1
                    A[h+1][w] += 1
                    ans.append((h+1, w+1, h+2, w+1))
                else:
                    if h != 0 and A[h-1][w] % 2 == 1:
                        A[h-1][w] += 1
                        A[h][w] -= 1
                        ans.append((h+1, w+1, h, w+1))
                    elif w != 0 and A[h][w-1] % 2 == 1:
                        A[h][w-1] += 1
                        A[h][w] -= 1
                        ans.append((h+1, w+1, h+1, w))

    print(len(ans))
    for a in ans:
        print(*a)


if __name__ == '__main__':
    main()


Measured memory_bytes: 74844
(let ((a (read))
      (b (read))
      (c (read))
      (d (read)))

  (format t "~A~%"
          (if (or (<= (abs (- a c)) d)
                  (and (<= (abs (- a b)) d) (<= (abs (- b c)) d)))
            "Yes"
            "No")))


Measured memory_bytes: 24144
'use strict'

const main = input => {
	const args = input.split('\n')
	const n = parseInt(args[0], 10)
	const l = args[1].split(' ').map(Number).sort((a, b) => b - a)
	let max = 0
	let sum = 0
	
	for (let i = 0; i < n; i++) {
		if (i === 0) max = l[i]
		else sum += l[i]
	}

	if (max < sum) console.log('Yes')
	else console.log('No')
}

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


Measured memory_bytes: 9420
//Written by Rhitwik Saha//
#include <bits/stdc++.h>
using namespace std;
#define int         long long
#define mp          make_pair
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vb          vector<bool>
#define vc          vector<char>
#define vii         vector<pii>
//#define mi          map<int,int>
//#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define ub(x)       upper_bound(x)
#define lb(x)       lower_bound(x)
#define endl        '\n'
#define file        freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)
#define fastio      ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
// #define N 			1e5+5
#define M           1000000007
#define MAX         100005
#define mem0(a)     memset(a,0,sizeof(a))
#define prec        cout<<std::setprecision(9)<<std::fixed
#define forn(i,a,b)  for(int i=a;i<b;i++)
int i,j,k;

void Anon_mouS(){
	int h,n;
	cin>>h>>n;
	while(n--){
		int x;
		cin>>x;
		if((h-=x)<=0){
			cout<<"Yes"<<endl;
			return;
		}
	}
	cout<<"No"<<endl;
}
int32_t main(){
    fastio;
    // file;
    // sieve();
    int q=1;
    // cin>>q;
    while(q--)Anon_mouS();
    return 0;
}


Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> 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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };
}
#[allow(unused_macros)]
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, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!(a: usize, b: usize,);
    let mut ans = "No";

    if a * b * 1 % 2 != 0 {
        ans = "Yes"
    } else if a * b * 2 % 2 != 0 {
        ans = "Yes"
    } else if a * b * 3 % 2 != 0 {
        ans = "Yes"
    }
    println!("{}", ans);
}

Measured memory_bytes: 4352
import collections
N = int(input())

g = [dict() for _ in range(N+1)]
for i in range(1, N):
    u, v, w = map(int, input().split())
    w = 0 if w % 2 == 0 else 1
    g[u][v] = w
    g[v][u] = w

ret = {1:0}
q = collections.deque()
q.append(1)
while len(q):
    d = q.pop()
    for h in g[d]:
        if ret.get(h, -1) < 0:
            ret[h] = ret[d] ^ g[d][h]
            q.append(h)

for i in range(1, N+1):
    print(ret[i])


Measured memory_bytes: 49920
// 20:47
#include <iostream>
using namespace std;
typedef long long LL;
const int N = 1000000 + 10;
int n,a[N],c[N];
const LL MOD = 998244353;
LL f[N],g[N];

LL mpow(LL a, LL x) {
    if (x == 0) return 1;
    LL t = mpow(a, x>>1);
    if (x % 2 == 0) return t * t % MOD;
    return t * t % MOD * a % MOD;
}
int main() {
    scanf("%d",&n);
    for(int i=1;i<=n;i++) {
        scanf("%d",&a[i]); c[a[i]] ++;
    }
    for(int i=1;i<N;i++) {
        for(int j=i;j<N;j+=i) {
            (f[i] += 1LL * c[j] * j) %= MOD;
        }
    }
    for(int i=1;i<N;i++) {
        f[i] = f[i] * f[i] % MOD;
    }
    for(int i=N-1;i>=1;i--) {
        g[i] = f[i];

        for(int j=i+i;j<N;j+=i) {
            g[i] -= g[j];
            g[i] = (g[i] % MOD + MOD) % MOD;
        }
    }
    LL ans = 0;
    for (int i = 1; i < N; i ++) {

        ans = ans + g[i] * mpow(i, MOD-2) % MOD;
        ans = (ans % MOD + MOD) % MOD;
    }
    for (int i = 1; i <= n; i ++) {
        ans = ans - a[i];
        ans = (ans % MOD + MOD) % MOD;
    }
    ans = ans * mpow(2, MOD-2) % MOD;

    cout << ans << endl;
}


Measured memory_bytes: 20736
//#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<cmath>
#include<map>
#include<unordered_map>
#include<functional>
#include<queue>
#include<set>
#include<stack>
#include<iomanip>
#include<algorithm>
#include<numeric>
#include<memory>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a)   a.begin(),a.end()
template<typename T =ll> using v = vector<T>;
template<typename T =ll> using vv = v<v<T>>;
template<typename T =ll,typename U =ll> using p = pair<T,U>;
template<typename T> T chmin(T &a,T b) {return a=min(a,b);}
template<typename T> T chmax(T &a,T b) {return a=max(a,b);}
const ll INF = (ll)1e9;
template <int MOD>
struct ModInt {
    using lint = long long;
    int val;

    // constructor
    ModInt(lint v = 0) : val(v % MOD) {
        if (val < 0) val += MOD;
    };

    // unary operator
    ModInt operator+() const { return ModInt(val); }
    ModInt operator-() const { return ModInt(MOD - val); }
    ModInt inv() const { return this->pow(MOD - 2); }

    // arithmetic
    ModInt operator+(const ModInt& x) const { return ModInt(*this) += x; }
    ModInt operator-(const ModInt& x) const { return ModInt(*this) -= x; }
    ModInt operator*(const ModInt& x) const { return ModInt(*this) *= x; }
    ModInt operator/(const ModInt& x) const { return ModInt(*this) /= x; }
    ModInt pow(lint n) const {
        auto x = ModInt(1);
        auto b = *this;
        while (n > 0) {
            if (n & 1) x *= b;
            n >>= 1;
            b *= b;
        }
        return x;
    }

    // compound assignment
    ModInt& operator+=(const ModInt& x) {
        if ((val += x.val) >= MOD) val -= MOD;
        return *this;
    }
    ModInt& operator-=(const ModInt& x) {
        if ((val -= x.val) < 0) val += MOD;
        return *this;
    }
    ModInt& operator*=(const ModInt& x) {
        val = lint(val) * x.val % MOD;
        return *this;
    }
    ModInt& operator/=(const ModInt& x) { return *this *= x.inv(); }
    //
    ModInt operator++(int) {
        auto t = *this;
        *this += 1;
        return t;
    }

    ModInt operator--(int) {
        auto t = *this;
        *this -= 1;
        return t;
    }
    ModInt operator<<(const int n){
        return ModInt(*this)*ModInt(2).pow(n);
    }
    // compare
    bool operator==(const ModInt& b) const { return val == b.val; }
    bool operator!=(const ModInt& b) const { return val != b.val; }

    // I/O
    friend std::istream& operator>>(std::istream& is, ModInt& x) noexcept { return is >> x.val; }
    friend std::ostream& operator<<(std::ostream& os, const ModInt& x) noexcept { return os << x.val; }
};

constexpr int MOD = 1e9 + 7;
using mint = ModInt<MOD>;

void a(){
   string S; cin >> S;
   ll ofW = 0;
   ll sum = 0;
   rep(i,S.size()){
       if(S[i]=='W'){
           sum+=i-ofW++;
       }
   }
    cout << sum << endl;
}


int main(){
    a();
}


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

int main() {
  int N;
  cin >> N;
  int odd = 0;
  for (int i = 0; i < N; ++i) {
    int tmp;
    cin >> tmp;
    if (tmp % 2 == 1) ++odd;
  }
  if (odd % 2 == 0) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.stream.Stream;

public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		String str = br.readLine();
		String[] array1 = str.split(" ");
		int[] array2 = Stream.of(array1).mapToInt(Integer::parseInt).toArray();

		Arrays.sort(array2);

		int m = 0;
		for (int i = 0; i < 2 * n; i += 2) {
			m = m + array2[i];
		}
		System.out.println(m);
	}
}


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

int gcd(int a,int b){
    if(a%b==0){
        return b;
    }
    else{
        return(gcd(b,a%b));
    }
}
int main(){
  long int a,b;
  cin>>a>>b;
  long int ans;
  long int kouyaku;
  kouyaku=gcd(a,b);
  ans=a*b/kouyaku;
  cout<<ans<<endl;
}
  

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

char s[1000][1001];
int d[1000][1000],cnt[1000][1000];
int main(){
	int h,w;scanf("%d%d",&h,&w);
	memset(d,-1,sizeof(d));
	rep(i,h)scanf("%s",s[i]);
	int Max=0;
	queue<P>que;
	rep(i,h)rep(j,w){
		if(s[i][j]=='.')continue;
		for(int k=-1;k<=1;k++){
			for(int l=-1;l<=1;l++){
				int nx=i+k,ny=j+l;
				if(0<=nx&&nx<h&&0<=ny&&ny<w&&s[nx][ny]=='.')cnt[i][j]++;
			}
		}
		if(cnt[i][j]>=s[i][j]-'0'){
			d[i][j]=Max=1;que.push(P(i,j));
		}
	}
	while(!que.empty()){
		P p=que.front();que.pop();
		for(int i=-1;i<=1;i++)for(int j=-1;j<=1;j++){
			int x=p.first+i,y=p.second+j;
			if(0<=x&&x<h&&0<=y&&y<w&&s[x][y]!='.'&&d[x][y]==-1){
				if(++cnt[x][y]>=s[x][y]-'0'){
					d[x][y]=Max=d[p.first][p.second]+1;que.push(P(x,y));
				}
			}
		}
	}
	printf("%d\n",Max);
}

Measured memory_bytes: 12068
use std::io;
use std::cmp::min;

macro_rules! parse_line {
    ($($t: ty),+) => ({
        let mut a_str = String::new();
        io::stdin().read_line(&mut a_str).expect("read error");
        let mut a_iter = a_str.split_whitespace();
        (
            $(
                a_iter.next().unwrap().parse::<$t>().expect("parse error"),
            )+
        )
    })
}

fn main() {
    let (n,) = parse_line!(u32);
    let mut dp = Vec::new();
    dp.resize((n as usize) + 1, n);
    for i in 0..min(n as usize, 3) {
        dp[i] = i as u32;
    }

    let max_log6 = (n as f32).log(6.0).floor() as usize + 1;
    let max_log9 = (n as f32).log(9.0).floor() as usize + 1;
    for i in 3..((n + 1) as usize) {
        let mut t = 1;
        for _ in 1..max_log6 {
            t *= 6;
            if i < t {
                break
            }
            dp[i] = min(dp[i], dp[i - t] + 1);
        }

        t = 1;
        for _ in 1..max_log9 {
            t *= 9;
            if i < t {
                break
            }
            dp[i] = min(dp[i], dp[i - t] + 1);
        }
    }

    println!("{}", dp[n as usize]);
}

Measured memory_bytes: 4352