akhauriyash/Code-Regression huggingface dataset:
// AOJ GRL_6_A
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>

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

using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vc;

const int INF = 0x3fffffff;

// ?????§???????±???????(Dinic??????bfs()??????????????¨Ford-Fulkerson???)
class Flow{
	public:
		int N;	// ????????°
		vector<vc> F, C, edge;	// F:????????°?????? C:???????????? edge:??£??\????????????
		vector<bool> bf;	// ??????????????£???????????????
		vector<int> lv;	// S??????????????¢

		// ????????????????????? n:????????°
		Flow(int n): F(n,vc(n)), C(n,vc(n)), N(n), edge(n) {}

		// ??????????????????
		void addEdge(int f, int t, int c){
			F[f][t] = C[f][t] = c;
			edge[f].push_back(t);
			edge[t].push_back(f);
		}

		// s????????????????????¢????±?????????????????????????????????¨DFS??§?????????????????????????????¢?´¢??????
		int bfs(int S, int T){
			lv.assign(N, 0);
			queue<int> que;
			que.push(S);
			lv[S] = 1;
			while( !que.empty() ){
				int n = que.front(); que.pop();
				for(auto v: edge[n]) if( !lv[v] && F[n][v] ){
					lv[v] = lv[n] + 1;
					que.push(v);
				}
			}
			return lv[T];
		}

		// ?¢?????????????DFS??§??¢???
		int flow(int n, int c, int T){
			if( n == T ) return c;
			bf[n] = true;
			for(int v: edge[n]) if( F[n][v] && !bf[v] && lv[v] > lv[n] ){	// ??????????????¶??????????????¨bfs()?????????????????????
				int f = flow(v, min(c, F[n][v]), T);
				F[n][v] -= f;
				F[v][n] += f;
				if( f > 0 ) return f;
			}
			return 0;
		}

		// ?????§???????±???????
		int maxFlow(int S, int T){
			int ret = 0;
			while( bfs(S,T) )	// bfs()???????????´?????????????????????????????????
				for(int add; bf.assign(N,0), add = flow(0, INF, T);) ret += add;
			return ret;
		}

		// ??°???????????????????????????
		void clear(){ rep(i,N) rep(j,N) F[i][j] = C[i][j]; }
};

int main(){
	int V, E;
	cin >> V >> E;
	Flow fl(V);
	rep(i, E){
		int u, v, c;
		cin >> u >> v >> c;
		fl.addEdge( u, v, c );
	}

	cout << fl.maxFlow(0, V-1) << endl;

	return 0;
}

Measured memory_bytes: 3228
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <ctime>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <deque>
#include <complex>
#include <string>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <valarray>
#include <iterator>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) container.begin(), container.end()
#define RALL(container) container.rbegin(), container.rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

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 (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;

inline ll mod_inverse(ll a, ll m){
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    swap(a -= t * b, b);
    swap(u -= t * v, v);
  }
  return (u % m + m) % m;
}

int N, M, K;
ll frac[250005];
ll rfrac[250005];
ll C(ll n, ll r){
	return frac[n]*rfrac[r]%MOD*rfrac[n-r]%MOD;
}
ll H[10001];
ll W[10001];
ll dp[2][10001];

inline int add(int a, int b){
	a += b;
	if(a >= MOD) a-= MOD;
	return a;
}

main(){
	
	frac[0] = 1;
	REP(i, 250000) frac[i+1] = (frac[i]*(i+1)) % MOD;
	REP(i, 250000) rfrac[i] = mod_inverse(frac[i], MOD);
	while(cin >> N >> M >> K){
		dp[0][0] = 1;
		W[0] = H[0] = 1;
		REPS(i, K)REP(j, i+1){
			dp[i&1][j] = add((j?dp[i&1][j-1]:0), dp[1^i&1][j]);
			W[i] = add(W[i], (ll)dp[i&1][j]*C(M+i-j-1, M-1)%MOD);
			H[i] = add(H[i], (ll)dp[i&1][j]*C(N+i-j-1, N-1)%MOD);
		}
		ll ans = 0;
		REP(i, K+1){
			ans += W[i]*H[K-i]%MOD*C(M+i*2+N+(K-i)*2, M+i*2)%MOD;
		}
		cout << ans % MOD << endl;
	}
	return 0;
}

Measured memory_bytes: 5380
num_list = []
while True:
    values = [int(x) for x in input().split()]
    if 0 == values[0] and 0 == values[1]:
        break
    num_list.append(values)

for n, t in num_list:
    ret = ' '.join(str(x + y + z) for x in range(1, n + 1) for y in range(x + 1, n + 1) for z in range(y + 1, n + 1))
    cnt = 0
    for x in ret.split():
        if str(t) == x:
            cnt += 1
    print(cnt)

Measured memory_bytes: 19480
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}

int main() {
  int N;
  cin>>N;
  vector<int>a(N);
  for(int i=0;i<N;i++){
    cin>>a[i];
  }
  vector<int64_t>table(N);
  int64_t sum=0;
  for(int i=0;i<N;i++){
    sum+=a[i];
    table[i]=sum;
  }
  int64_t ans=9999999999999999;
  for(int i=0;i<N-1;i++){
    int64_t r=sum-table[i];
    if(abs(table[i]-r)<ans){ans=abs(table[i]-r);}
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 5576
#include <bits/stdc++.h>
#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++)
using namespace std;
using P = pair<int, int>; 
using ll = long long;

int main()
{

  int a[3];
  rep(i,3) cin >> a[i];
  sort(a,a+3);
  if(a[0] == 5 && a[1] == 5 && a[2] == 7) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


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


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<int> A;
    vector<int> B;
    rep(i, N) {
        int tmp; cin >> tmp;
        A.push_back(tmp);
    }
    rep(i, N) {
        int tmp; cin >> tmp;
        B.push_back(tmp);
    }
    vector<int> C;
    rep(i, N) C.push_back(i + 1);
    int cnt = 1;
    int a = 1, b = 1;
    do {
        bool flag1 = true;
        bool flag2 = true;
        rep(i, N) {
            if (A[i] != C[i]) flag1 = false;
        }
        rep(i, N) {
            if (B[i] != C[i]) flag2 = false;
        }
        if (flag1) a = cnt;
        if (flag2) b = cnt;
        cnt++;
    }while(next_permutation(C.begin(), C.end()));
    cout << abs(a - b) << endl;

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;

static class CodeJam
{
    static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());
        Console.WriteLine(Math.BigMul(N, N + 1) / 2 - N);
    }
}


Measured memory_bytes: 11092
#include <algorithm>
#include <cstdio>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <iostream>
#include <cmath>
#include <map>
#include <cstdlib>
using namespace std;
#define ABS(x) ((x)>=0?(x):(-x))
int main()
{
	int n;
	scanf("%d", &n);
	set<pair<int, int> >sp;
	for (int i = 1; i <= n / 2; i++)
	{
		int ta = i, tb = n - i;
		if (ta == tb)
			continue;
		if(ta>tb)
			swap(ta, tb);
		sp.insert(make_pair(ta, tb));


	}
	printf("%d\n", sp.size());
	return 0;
}
//1000000000000

Measured memory_bytes: 23680
#include <cmath>
#include <iostream>
#include <vector>

template<typename T>
int dfs(T& t_arr, int current, int parent, int length, int dest, int& cut_node){
  int ans_length = length;
  if(current != dest){
    ans_length = -1;
    for(auto&& it: t_arr[current]){
      if(it == parent) continue;
      ans_length = std::max(ans_length, dfs(t_arr, it, current, length+1, dest, cut_node));
    }
  }
  if(ans_length != -1 and length == (ans_length/2)+1) cut_node = current;
  return ans_length;
}

template<typename T>
int dfs_size(T& t_arr, int current, int parent, int cut_node){
  int ans_size = 1;
  for(auto&& it: t_arr[current]){
    if(it == parent || it == cut_node) continue;
    ans_size += dfs_size(t_arr, it, current, cut_node);
  }
  return ans_size;
}


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

  std::vector<std::vector<int>> t_arr(N);
  for(int i = 0; i < N-1; i++){
    int a,b;
    std::cin >> a >> b;
    a--; b--;
    t_arr[a].push_back(b);
    t_arr[b].push_back(a);
  }

  int cut_node = -1;
  dfs(t_arr, 0, -1, 0, N-1, cut_node);
  int f_size = dfs_size(t_arr, 0, -1, cut_node);

  if(f_size*2 > N) std::cout << "Fennec" << std::endl;
  else std::cout << "Snuke" << std::endl;

  return 0;
}



Measured memory_bytes: 15104
#include <cstdio>
#include <cmath>
#include <complex>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;

typedef complex<double> P;
typedef const P &rP;

#define EPS 1e-7

struct UFO{
	double dist, arg, r, v;
	bool alive;
	int idx;

	bool operator< (const UFO &u) const{
		return dist < u.dist;
	}
};

double dot(rP va, rP vb){
	return real(va) * real(vb) + imag(va) * imag(vb);
}

double cross(rP va, rP vb){
	return real(va) * imag(vb) - imag(va) * real(vb);
}

double distance_l_p(rP a, rP b, rP c){
	return abs(cross(b - a, c - a)) / abs(b - a);
}

double distance_hl_p(rP a, rP b, rP c){
	if( dot(b - a, c - a) <= 0.0 ) return abs(c - a);
	return distance_l_p(a, b, c);
}

bool dead(const UFO &u){
	return !u.alive;
}

int solve(double R, int n){
	vector<UFO> u;
	u.reserve(n);
	for(int i = 0; i < n; ++i){
		double x, y, r, v;
		scanf("%lf%lf%lf%lf", &x, &y, &r, &v);
		P z(x, y);
		u.push_back((UFO){abs(z), arg(z), r, v, true, i});
	}

	int ans = 0;
	while(!u.empty()){
		for(int i = 0; i < u.size(); ++i){
			u[i].dist -= u[i].v;
			if(u[i].alive && u[i].dist < R + EPS){
				++ans;
				u[i].alive = false;
			}
		}

		u.erase(remove_if(u.begin(), u.end(), dead), u.end());
		if(u.empty()) break;

		UFO &t = *min_element(u.begin(), u.end());
		P from = polar(R, t.arg);
		P target = polar(R + 1.0, t.arg);

		for(int i = 0; i < u.size(); ++i){
			P c = polar(u[i].dist, u[i].arg);
			if(distance_hl_p(from, target, c) < u[i].r + EPS){
				u[i].alive = false;
			}
		}
	}

	return ans;
}

int main(){
	double R;
	int N;
	while(scanf("%lf%d", &R, &N), N){
		printf("%d\n", solve(R, N));
	}
}

Measured memory_bytes: 1304
//code by lynmisakura.wish to be accepted!
/****************************/
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<bitset>
#include <climits>
#include<set>
#include<bitset>
using namespace std;
/***************************/
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<pair<int,int>> vpi;

const long long MOD = 998244353;
const long long mod = 1000000007;
const long long INF = 10000000000000;
 
#define itn int
#define endl "\n"
#define pb push_back
#define mp make_pair
#define ss second
#define ff first
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()
#define Rep(n) for(int i = 0;i < n;i++)
#define rep(i,n) for(int i = 0;i < n;i++)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
 
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll qp(ll a, ll b) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
ll qp(ll a, ll b, int mo) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }
 
#define _GLIBCXX_DEBUG
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
/**************************************************/
int n,m,r;
int R[8];
#define MAX_V 1000
ll d[MAX_V][MAX_V]; //隣接行列辺が存在しなければINF、d[i][i] = 0n
ll ans = INF;
/*****************************************************/
void WF(){
   for(int i = 0;i < n;i++){
      for(int j = 0;j < n;j++){
         if(i == j) d[i][j] = 0LL;
         else if(d[i][j] == 0) d[i][j] = INF;
      }
   }
    for(int k = 0;k < n;k++){
        for(int i = 0;i < n;i++){
            for(int j = 0;j < n;j++) d[i][j] = min(d[i][j],d[i][k] + d[k][j]);
        }
    }
}
//グラフを作成する
void make_graph(){
   int a,b,c;cin>>a>>b>>c;
   a--;b--;
   d[a][b] = c;
   d[b][a] = c;
}
//フロイドワーシャルで全部の点の間の距離を測っておく
void do_wf(){
   WF();
   /*for(int i = 0;i < n;i++){
      for(int j = 0;j < n;j++) cout << d[i][j] << " ";
      cout << endl;
   }*/
}
//next_permutation
void do_np(){
   const int sz = r;
   vector<int> v(sz);
   rep(i,sz) v[i] = i + 1;
   do{
      ll res = 0LL;
      for(int i = 0;i < r-1;i++){
         int from = v[i] - 1;
         int to = v[i+1] - 1;
         res += d[R[from]][R[to]];
      }
      mins(ans,res);
   }while(next_permutation(all(v)));
}
void solve(){
   //cin >> n >> m >> r;
   rep(i,m)make_graph();
   do_wf();
   do_np();
   cout << ans << endl;
}

int main(void){
   cin >> n >> m >> r;
   rep(i,r){
      int x;cin >> x;
      R[i] = --x;
   }
   solve();
   return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define FOR(i, l, r) for(int i = (int)l; i <= (int)r; ++i)
#define REP(i, r) for(int i =(int)0; i < (int)r; ++i)

using namespace std;
typedef long long ll;
const int Nmax = 1e5 + 11;

int n, m, f[Nmax], ans;
vector<int> a[Nmax];

int dp(int u) {
    if (f[u] != -1) return f[u];
    int res = 0;
    REP(i, a[u].size()) {
        int v = a[u][i];
        res = max(res, dp(v) + 1);
    }
    return f[u] = res;
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> m;
    FOR(i, 1, m) {
        int u, v; cin >> u >> v;
        a[v].push_back(u);
    }
    memset(f, -1, sizeof(f));
    FOR(i, 1, n) {
        ans = max(ans, dp(i));
    }
    cout << ans;
}


Measured memory_bytes: 12160
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

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

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

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

typedef long long ll;
//typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define revrep(i, n) for(ll i = n-1; i >= 0; i--)
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll Mypow(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}

ll INFL = 1LL << 60;//10^18 = 2^60
int INF = 1 << 30;//10^9
ll MOD  = 1000000007;
//vector<int> dy = {0,0,1,-1};
//vector<int> dx = {1,-1,0,0};


int main(){
  char a, b;
  cin >> a >> b;
  if(a == b) cout << "H" << endl;
  else cout << "D" << endl;
}


Measured memory_bytes: 256
n = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]

mon = 0
for i in range(n):
    if a[i] >= b[i]:
        mon += b[i]
        a[i] -= b[i]
        b[i] = 0
    else:
        mon += a[i]
        b[i] -= a[i]
        a[i] = 0
    if b[i] > 0:
        if a[i+1] > b[i]:
            mon += b[i]
            a[i+1] -= b[i]
            b[i] = 0
        else:
            mon += a[i+1]
            b[i] -= a[i+1]
            a[i+1] = 0
print(mon)

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

struct Card{
	char name;
	int value;
};
void Mao(struct Card A[],int n)
{
	int flag=1,i;
	while(flag)
	{
		flag=0;
		for(i=n-1;i>0;i--)
		{
			if(A[i].value<A[i-1].value)
			{
				struct Card k=A[i];
				A[i]=A[i-1];
				A[i-1]=k;
				flag=1;
			}
		}
	}
}
void Xuan(struct Card A[],int n)
{
	int i,j;
	for(i=0;i<n;i++)
	{
	    int	min=i;
		for(j=i;j<n;j++)
		{
			if(A[min].value>A[j].value)
			{
				min=j; 
			} 
		}
		struct Card p=A[min];
		A[min]=A[i];
		A[i]=p; 
	}
}
bool Isstable(struct Card A[],struct Card B[],int n)
{
	int i;
	for(i=0;i<n;i++)
	{
		if(A[i].name!=B[i].name)
		{
			return false;
		}
	}
	return true;
}
int main()
{
	int n,i;
	struct Card A[40],B[40];
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>A[i].name>>A[i].value;
		B[i]=A[i];
	}
	Mao(A,n);
	Xuan(B,n);
	for(i=0;i<n-1;i++) cout<<A[i].name<<A[i].value<<" ";
	cout<<A[n-1].name<<A[n-1].value<<endl;
	cout<<"Stable"<<endl;
	for(i=0;i<n-1;i++) cout<<B[i].name<<B[i].value<<" ";
	cout<<B[n-1].name<<B[n-1].value<<endl;

	int p=1;
	for(i=0;i<n;i++)
	{
		if(!Isstable(A,B,n))
		{
			p=0;
		}
	}
	if(p)
	{
		cout<<"Stable"<<endl;
	}
	else
	cout<<"Not stable"<<endl;
	return 0;
} 

Measured memory_bytes: 3104
#include<cstdio>
#include<algorithm>
#include<map>

using std::map;
using std::max;

typedef map<int,int>::iterator It;

const int maxn=1e5+1000;

int a[maxn],b[maxn],c[maxn];

int main()
{
	int n,cntb=0,cntc=0;
	map<int,int> mpeven,mpodd;
	scanf("%d",&n);
	for (int i=1;i<=n;++i)
		scanf("%d",a+i);
	for (int i=1;i<=n-1;i+=2)
		mpeven[a[i]]++,b[++cntb]=a[i];
	for (int i=2;i<=n;i+=2)
		mpodd[a[i]]++,c[++cntc]=a[i];
	int mxeven=0,elemeven;
	for (It it=mpeven.begin();it!=mpeven.end();++it)
		if (it->second>mxeven) mxeven=it->second,elemeven=it->first; 
	int mxodd=0,elemodd;
	for (It it=mpodd.begin();it!=mpodd.end();++it)
		if (it->second>mxodd) mxodd=it->second,elemodd=it->first;
	int ans=0;
	if (elemeven!=elemodd) 
	{
		ans+=n-mxeven-mxodd;
		printf("%d",ans);
		return 0;
	}
	else
	{
		int maxx=0;
		ans+=n/2-mxeven;
		for (int i=1;i<=n/2;++i)
			if (c[i]!=elemeven)
				maxx=max(maxx,mpodd[c[i]]);
		for (int i=1;i<=n/2;++i)
			if (b[i]!=elemodd)
				maxx=max(maxx,mpeven[b[i]]);
		ans+=n/2-maxx;
	}
	printf("%d",ans);
}

Measured memory_bytes: 5760
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <utility>
#include <string>
#include <cstring>
#include <queue>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <numeric>
#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(auto it=(X).begin();it!=(X).end();it++)
#define numa(x,a) for(auto x: a)
#define ite iterator
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define pf push_front
#define sec second
#define sz(x) ((int)(x).size())
#define ALL( c ) (c).begin(), (c).end()
#define gcd(a,b) __gcd(a,b)
#define mem(x,n) memset(x,n,sizeof(x))
#define endl "\n"
using namespace std;
template <int POS, class TUPLE> void deploy(std::ostream &os, const TUPLE &tuple){}
template <int POS, class TUPLE, class H, class ...Ts> void deploy(std::ostream &os, const TUPLE &t){ os << (POS == 0 ? "" : ", ") << get<POS>(t); deploy<POS + 1, TUPLE, Ts...>(os, t); }
template <class T,class U> std::ostream& operator<<(std::ostream &os, std::pair<T,U> &p){ os << "(" << p.first <<", " << p.second <<")";return os; }
template <class T> std::ostream& operator<<(std::ostream &os, std::vector<T> &v){ int remain = v.size(); os << "{"; for(auto e: v) os << e << (--remain == 0 ? "}" : ", "); return os; }
template <class T> std::ostream& operator<<(std::ostream &os, std::set<T> &v){ int remain = v.size(); os << "{"; for(auto e: v) os << e << (--remain == 0 ? "}" : ", "); return os; }
template <class T, class K> std::ostream& operator<<(std::ostream &os, std::map<T, K> &mp){ int remain = mp.size(); os << "{"; for(auto e: mp) os << "(" << e.first << " -> " << e.second << ")" << (--remain == 0 ? "}" : ", "); return os; }
#define DEBUG1(var0) { std::cerr << (#var0) << "=" << (var0) << endl; }
#define DEBUG2(var0, var1) { std::cerr << (#var0) << "=" << (var0) << ", ";DEBUG1(var1); }
#define DEBUG3(var0, var1, var2) { std::cerr << (#var0) << "=" << (var0) << ", ";DEBUG2(var1,var2); }
#define DEBUG4(var0, var1, var2, var3) { std::cerr << (#var0) << "=" << (var0) << ", ";DEBUG3(var1,var2,var3); }
using ll = long long;

bool memo[10110];

int main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  int N;
  cin >> N;
  memo[0] = true;
  rep(i,N){
    int x;
    cin >> x;
    for (int j = 10000; j >= 0; j--) {
      if (memo[j]) {
        memo[j+x] = true;
      }
    }
  }
  for (int j = 10000; j >= 0; j--) {
    if (memo[j]) {
      if (j % 10 != 0) {
        cout << j << endl;
        return 0;
      }
    }
  }
  cout << 0 << endl;
  return 0;
}



Measured memory_bytes: 256
import java.io.FileNotFoundException;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

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

	void run() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long K = sc.nextLong();
		String s = sc.next();
		ArrayDeque<Integer> dq = new ArrayDeque<>();
		for (int i = 0; i < s.length(); ++i) {
			dq.add(s.charAt(i) == 'A' ? 1 : -1);
		}
		int cur = 1;
		long res = 0;
		HashMap<String, Integer> map = new HashMap<>();
		HashMap<Integer, String> map2 = new HashMap<>();
		int id = 0;
		for (long i = 0; i < K; ++i) {
			int v = dq.pollFirst();
			if (v * cur == 1) {
				dq.addFirst(cur * (-1));
			} else {
				cur *= -1;
				dq.addLast(cur);
			}
			if (i > 2 * N) {
				res = K - i - 1;
				String str = getans(dq, cur);
				if (map.containsKey(str)) {
					int ansid = (int) res % id;
					String ans = map2.get(ansid);
					System.out.println(ans);
					return;
				} else {
					map.put(str, id);
					map2.put(id, str);
					++id;
				}
			}
		}

		StringBuilder sb = new StringBuilder();
		while (!dq.isEmpty()) {
			sb.append(dq.pollFirst() * cur == 1 ? 'A' : 'B');
		}
		System.out.println(sb);
	}

	String getans(ArrayDeque<Integer> dq, int cur) {
		StringBuilder sb = new StringBuilder();
		ArrayDeque<Integer> tmp = new ArrayDeque<>();
		tmp.addAll(dq);
		while (!tmp.isEmpty()) {
			sb.append(tmp.pollFirst() * cur == 1 ? 'A' : 'B');
		}
		return sb.toString();

	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

}

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

static const int MAX_NUM = 100000;
static const int NOELEM  = -1;

struct stNode {
    int parent;
    int left;
    int right;
};

int main(void)
{
    int i, j;
    int key;
    int nums;
    int num;
    int sun;
    stNode elem[MAX_NUM];
    stNode *pNode;

    scanf("%d", &num);
    for (i = 0; i < num; i++) {
        elem[i].parent = NOELEM;
        elem[i].left   = NOELEM;
        elem[i].right  = NOELEM;
    }
    for (i = 0; i < num; i++) {
        scanf("%d %d", &key, &nums);

        for (j = 0; j < nums; j++) {
            scanf("%d", &sun);
            if (j == 0) {
                elem[key].left = sun;
            }
            else {
                pNode->right = sun;
            }
            pNode = elem + sun;
            pNode->parent = key;
        }
    }

    for (i = 0; i < num; i++) {
        printf("node %d: parent = %d, ", i, elem[i].parent, i);
        nums = 0;
        key = elem[i].parent;
        while (key != NOELEM) {
            ++nums;
            key = elem[key].parent;
        }
        printf("depth = %d, ", nums);

        if (elem[i].parent == NOELEM) {
            printf("root, ");
        }
        else if (elem[i].left == NOELEM) {
            printf("leaf, ");
        }
        else {
            printf("internal node, ");
        }
        printf("[");
        key = elem[i].left;
        if (key != NOELEM) {
            printf("%d", key);
            key = elem[key].right;
            while (key != NOELEM) {
                printf(", %d", key);
                key = elem[key].right;
            }
        }
        printf("]\n");
    }

    return 0;
}

Measured memory_bytes: 2372
#include <bits/stdc++.h>
using namespace std;
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#define debug(x...) cout << #x << " = "; _print(x)
typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll;
#define rep(i,a,b) for (ll i = (a); i < (b); ++i)
#define per(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define all(x) begin(x), end(x)
#define mp make_pair 
#define pb push_back
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL) 

int solve(){
    ll n, k;
    cin>> n>> k;
    vll v(n + 1), tel(n + 1);
    map<int, int> m;
    vi non_rep, rep;
    rep(i, 1, n + 1){
        cin>> v[i];
        tel[v[i]] = i;
    }
    int curr = 1;
    while(true){
        if(m[curr])
            break;
        non_rep.pb(curr);
        m[curr] = 1;
        curr = v[curr];
    }
    m.clear();
    while(true){
        if(m[curr])
            break;
        rep.pb(curr);
        m[curr] = 1;
        curr = v[curr];
    }
    //debug(non_rep);
    //debug(rep);
    if(k < (ll)non_rep.size())
        cout<< non_rep[k]<< "\n";
    else{
        k -= (ll)non_rep.size();
        ll tmp = (k - 1)%(ll)rep.size();
        int x = (int)tmp + 1;
        x %= rep.size();
        cout<< (ll)rep[x]<< "\n";
    }
    return 0;
}
 
int main()
{
    fast;
    int t = 1;
    //cin>> t;
    while(t--){  
        solve();
    }
    return 0;
}
//v.clear(), vis.clear(); vis.resize(n + 1, 0), v.resize(n + 1);
 
/*  inv[1] = 1; // inv is ll
    for(int i=2; i<=mxn; ++i)
        inv[i]=mod-mod/i*inv[mod%i]%mod;*/


Measured memory_bytes: 17056
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
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 main(){
   int N;
   cin>>N;
   vector<int> A(N);
   for(int i=0;i<N;i++){
       cin>>A.at(i);
   }
   sort(A.begin(),A.end());
   A.at(N-1)/=2;
   int sum=0;
   for(int i=0;i<N;i++){
       sum+=A.at(i);
   }
   cout<<sum<<endl;
}    

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

typedef long long ll;
const int N=2e5+5;
const ll inf=4557430888798830399ll;
vector<pair<int,int> > q[N];
struct tn {
	ll mx,tag;
}t[N*4];

#define lson (Node*2)
#define rson (lson|1)
void pushdown(int Node) {
	if(t[Node].tag==0) return;
	t[lson].tag+=t[Node].tag,t[rson].tag+=t[Node].tag;
	t[lson].mx+=t[Node].tag,t[rson].mx+=t[Node].tag;
	t[Node].tag=0;
}
void modify(int Node,int l,int r,int L,int R,ll v) {
	if(L<=l&&r<=R) {
		t[Node].tag+=v,t[Node].mx+=v;
		return;
	}
	pushdown(Node);
	int mid=(l+r)/2;
	if(L<=mid) modify(lson,l,mid,L,R,v);
	if(mid+1<=R) modify(rson,mid+1,r,L,R,v);
	t[Node].mx=max(t[lson].mx,t[rson].mx);
}
ll query(int Node,int l,int r,int L,int R) {
	if(L<=l&&r<=R) return t[Node].mx;
	pushdown(Node);
	int mid=(l+r)/2; ll ret=-inf;
	if(L<=mid) ret=query(lson,l,mid,L,R);
	if(mid+1<=R) ret=max(ret,query(rson,mid+1,r,L,R));
	return ret;
}

int main() {
	//freopen("1.in","r",stdin);
	//freopen("1.ans","w",stdout);
	
	int n,m; scanf("%d%d",&n,&m);
	for(int i=1,l,r,a;i<=m;++i) {
		scanf("%d%d%d",&l,&r,&a);
		q[r].emplace_back(l,a);
	}
	for(int i=1;i<=n;++i) {
		modify(1,1,n,i,i,query(1,1,n,1,i));
		for(auto x:q[i]) modify(1,1,n,x.first,i,x.second);
		//for(int j=1;j<=n;++j) cerr<<query(1,1,n,j,j)<<' '; cerr<<endl;
	}
	printf("%lld\n",max(t[1].mx,0ll));
	
	return 0;
}


Measured memory_bytes: 21632
import itertools

switch = 0

while(switch == 0):
    count = 0
    arr = []
    n = 0
    
    nx = list(map(int, input().split(' ')))
    
    if nx[0] == nx[1] == 0:
        break
    
    for i in range(nx[0] + 1):
        arr.append(i)
        n += 1
        
    numbers = list(itertools.combinations(arr[1:], 3))

    for i in range(len(numbers)):
        if int(numbers[i][0]) + int(numbers[i][1]) + int(numbers[i][2]) == nx[1]:
            count = count + 1
            
    print(count)


Measured memory_bytes: 31432
# -*- coding: utf-8 -*-

## Library

import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
import itertools
import copy

## input

# N=int(input())
# A,B,C,D=map(int, input().split())
# S = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]
#    S = []
#    for _ in range(N):
#        S.append(list(input()))

N=int(input())

if N%1000 == 0:
    print(0)
else:
    print(1000-N%1000)

Measured memory_bytes: 72796
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>  
#include <stdbool.h>   
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define PI 3.14159265358979323846;
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
/*
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r)
*/
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r)
#define TYPE long long
#define ll long long
#define MEMSET(a) memset(a,0,sizeof(a))
#define MEMSET_U(a) memset(a,-1,sizeof(a))
#define bool    _Bool
const int mod = (int)1e09 + 7;

//#define DEBUG1
//#define DEBUG2
//#define DEBUGF
#define DUMMY

int in(void) { int i; scanf("%d", &i); return i; }
long long llin(void) { long long i; scanf("%lld", &i); return i; }
double din(void) { double i; scanf("%lf", &i); return i; }
void chin(char s[]) { scanf("%s", s); }

void print(int a) { printf("%d\n", a); }
void llprint(long long a) { printf("%lld\n", a); }
void dprint(double a) { printf("%.10f\n", a); }
void print2(int a, int b) { printf("%d %d\n", a, b); }
int Max(int a, int b) { if (a > b) { return a; }return b; }
int Min(int a, int b) { if (a < b) { return a; }return b; }
long long llmax(long long a, long long b) { return a > b ? a : b; }
long long llmin(long long a, long long b) { return a < b ? a : b; }
double dmax(double a, double b) { return a > b ? a : b; }
double dmin(double a, double b) { return a < b ? a : b; }
//long long llmax(long long a, long long b) { return a > b ? a : b; }
//long long llmin(long long a, long long b) { return a < b ? a : b; }
//double dmax(double a, double b) { return a > b ? a : b; }
int cmp(const void *a, const void *b) { return *(TYPE *)a - *(TYPE *)b; }
int cmp_r(const void *a, const void *b) { return *(TYPE *)b - *(TYPE *)a; }
int char_cmp(const void *a, const void *b) { return strcmp((char *)a, (char *)b); }
int char_cmp_r(const void *a, const void *b) { return strcmp((char *)b, (char *)a); }
void swap(int *a, int *b) { int t = *a; *a = *b; *b = t; }



int main() {
	double D, N;
	scanf("%lf%lf", &D, &N);
	int ans;
	if (N != 100) {
		ans = (int)(pow(100, D)*N);
	}
	else if (D == 0) {
		ans = 101;
	}
	else if (D == 1) {
		ans = 10100;
	}
	else if (D == 2) {
		ans = 1010000;
	}

	printf("%d\n", ans);




#ifdef DEBUGF
	getch();
#endif
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
using namespace std;
int a[1000],b[1000],leng=0;
int f(){
    int i,j;
    for(i=1;i<=leng;i++)
    if(b[a[i]]>0)
	return 1;
    return 0;
}
int main(){
    int i,j,l;
    long long k,n,m;
    cin>>k>>n;
    for(i=1;i<=n;i++)
	{
		cin>>l;
		b[l]++;
	}
    m=k;
    while(m>0)
	{
        a[++leng]=m%10;
        m/=10;
    }
    while(f()){
        int s1=f();
        a[s1]++;
        k++;
        while(a[s1]>=10)
		{
			a[s1]=0;
			s1++;
			a[s1]++;
	    }
        leng=max(leng,s1);
    }
    cout<<k;
    return 0;
}

Measured memory_bytes: 256
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
#include<bitset>
#include<random>
#include<cstdint>
#include<math.h>
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
#define shosu setprecision(17)
#define hayai cin.tie(0);ios::sync_with_stdio(false);
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<char,P> Q;
ll longinf=(1ll<<60);
ll inf=1ll<<29;
ll mod=998244353;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    pair<ll,ll> p[n];
    rep0(i,n){
      ll a,b;
      cin>>a>>b;
      p[i].first=a;
      p[i].second=b;
    }
    sort(p,p+n);
    cout<<p[n-1].first+p[n-1].second<<endl;
      return 0;
}

Measured memory_bytes: 2428
#include<iostream>
#include<vector>
#include<algorithm>
#include<unordered_map>
#include<stack>
#include<queue>
#include<limits>

using namespace std;


int main(){
    int a, b,c,d;
    cin >> a >> b >> c>> d;
    cout << max(a*b, c*d) <<endl;
    return 0;
}


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

using namespace std;

int main()
{
     int n,x[101],i,j,minn=1<<30,sum=0;
     cin>>n;
     for(i=0;i<n;i++)
     {
         cin>>x[i];
     }
     for(j=1;j<=100;j++)
     {
         sum=0;
         for(i=0;i<n;i++)
         {
             sum+=(x[i]-j)*(x[i]-j);
         }
         if(sum<minn)
            minn=sum;
     }
     cout<<minn<<endl;
    return 0;

}


Measured memory_bytes: 256
def solve(m, a) -> int:
    from bisect import bisect_left
    from itertools import accumulate

    *a, = sorted(a)
    n = len(a)

    acc = (0,) + tuple(accumulate(a))

    def is_ok(h):
        ret = 0
        for x in a:
            j = bisect_left(a, h - x)
            ret += (n - j)
            if ret >= m:
                return True
        return False

    def binary_search():
        """M通り以上の握手ができる幸福度の上限"""
        ok = 0
        ng = a[-1] * 2 + 1
        while abs(ng - ok) > 1:
            mid = (ok + ng) // 2
            if is_ok(mid):
                ok = mid
            else:
                ng = mid
        return ok

    sup = binary_search()  # 上限

    ret = 0
    rest = m
    for x in a:
        j = bisect_left(a, sup + 1 - x)  # 前の投稿はsup+1に直していなかった
        # sup+1以上になるような握手を全て行った残りの握手回数restはすべてsupになるはず
        use = n - j
        rest -= use

        ret += use * x + (acc[n] - acc[n - use])

    ret += rest * sup

    return ret


def main():
    n, m = map(int, input().split())
    *a, = map(int, input().split())
    print(solve(m, a))


if __name__ == '__main__':
    main()

# k 回目の握手で、左手でゲスト xk と、右手でゲスト yk と手を握ったとする。
# このとき、 (xp,yp)=(xq,yq) を満たすような p,q(1≤p<q≤M) が存在しない。
#
# サンプル2の3,5は重複があるが、3a,3bとおくと
# (3a,v)と(3b,v)は値が等しい組なので、両方選べない
# よって、Aをset(A)に変換する必要がある
# と考えたが、それだとサンプルが合わない
#
# (3a,v)と(3b,v)を区別する場合の値を返すコードを提出してみる


Measured memory_bytes: 15412
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=998244353,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n;
  R n;
  ll a[n];
  rep(i,n) R a[i];
  ll d[n];
  mem(d);
  rep(i,n) d[a[i]]++;
  if(a[0]||d[0]>1) {
    pr(0);
    return;
  }
  sort(a,a+n);
  ll ans=1;
  REP(i,1,n) {
    ans*=d[a[i]-1];
    ans%=MAX;
  }
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 1792
N = int(input())
A = list(map(int, input().split()))
limit = 10**18+1

mul = 1
if 0 in A:
    print("0")
else:
    for i in A:
        mul *= i
        if mul >= limit:
            print("-1")
            break
    if mul < limit:
        print(mul)


Measured memory_bytes: 21580
#include <stdio.h>
 
int rot[24][7] = {
    { 0,1,2,3,4,5,6 },{ 0,1,3,5,2,4,6 },{ 0,1,4,2,5,3,6 },{ 0,1,5,4,3,2,6 },
    { 0,2,6,3,4,1,5 },{ 0,2,3,1,6,4,5 },{ 0,2,1,4,3,6,5 },{ 0,2,4,6,1,3,5 },
    { 0,3,1,2,5,6,4 },{ 0,3,2,6,1,5,4 },{ 0,3,5,1,6,2,4 },{ 0,3,6,5,2,1,4 },
    { 0,4,1,5,2,6,3 },{ 0,4,2,1,6,5,3 },{ 0,4,5,6,1,2,3 },{ 0,4,6,2,5,1,3 },
    { 0,5,1,3,4,6,2 },{ 0,5,3,6,1,4,2 },{ 0,5,4,1,6,3,2 },{ 0,5,6,4,3,1,2 },
    { 0,6,2,4,3,5,1 },{ 0,6,3,2,5,4,1 },{ 0,6,5,3,4,2,1 },{ 0,6,4,5,2,3,1 } };
int assign[7];
 
int main()
{
    int i, j;
    int a[7], b[7], dice[7];
 
    for (i = 1; i <= 6; i++) scanf("%d", assign+i);
    for (i = 1; i <= 6; i++) scanf("%d", a+i);
    for (j = 0; j < 24; j++) {
        for (i = 1; i <= 6; i++) dice[i] = rot[j][i];
        for (i = 1; i <= 6; i++) b[i] = assign[dice[i]];
        for (i = 1; ; i++) {
            if (i > 6) { puts("Yes"); return 0; }
            if (a[i] != b[i]) break;
        }
    }
    puts("No");
    return 0;
}



Measured memory_bytes: 2148
#include <iostream>

int main() {
    int n, y;
    std::cin >> n >> y;

    for(int i = 0; i <= n; i++) {
        for(int j = 0; j <= (n-i); j++) {
            int tmp = 10000 * i + 5000 * j + 1000 * (n-i-j);
            if(tmp == y) {
                std::cout << i <<" " << j <<  " " << (n-i-j) << std::endl;
                return 0;
            }
        }
    }

    std::cout << "-1 -1 -1" << std::endl;
    return 0;
}


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

using namespace std;
#define ll long long

const int N = 200000;
string ans;
ll a[N];

int main() {
    ll n;
    scanf("%lld", &n);
    for(int i=0; i<n; ++i){
        scanf("%lld", a + i);
    }

    ans = "YES";
    sort(a, a + n);
    for(int i = 0; i < n - 1; ++i){
        if(a[i] == a[i + 1]){
            ans = "NO";
            break;
        }
    }
    /*
    for(int i = 0; i < n - 1; ++i){
        for(int j = i + 1; j < n; ++j){
            if(a[i] == a[j]){
                ans = "NO";
                break;
            }
        }
    }
    */
    cout << ans << "\n";

    return 0;
}


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

int main(){
  string s;
  cin >> s;
  for(int i=0;i<3;i++){
    if(s.at(i)=='1'){
      s.at(i)='9';
    }else if(s.at(i)=='9'){
      s.at(i)='1';
    }
  }
  cout << s << endl;
}


Measured memory_bytes: 3560
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define ALL(a) (a).begin(), (a).end()
string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";

/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/

int main(void){
  int a1, a2, a3;
  cin >> a1 >> a2>>a3;
  if (a1+a2+a3 >=22) cout<<"bust" << endl;
  else cout<<"win" << endl;


}


Measured memory_bytes: 888
#include <iostream>

using namespace std;

int main(){
    int h,w;
    int i,j;
    
    while(1){
    
        cin >> h >> w;
        
        if(h == 0 && w == 0){
            break;
        }
    
        for(i = 0;i < h;i++){
            for(j = 0;j < w;j++){
                cout << '#';
            }
            cout << endl;
        }
        
        cout << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3080
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>
#include<queue>
#include<stack>
#include<set>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e8;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

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(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int a, b ;
	cin >> a >> b;
	if (a <= 9 && b <= 9)
	{
		cout << a * b << endl;
	}
	else
	{
		cout << -1 << endl;
	}

	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace ProgramingStydying
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            string[] seeds = { "maerd", "remaerd", "esare", "resare" };

            var s = new string(input.Reverse().ToArray());

            bool can = true;
            for(int i = 0; i < s.Length;)
            {
                bool can2 = false;
                for(int j = 0; j < 4; j++)
                {
                    if(s.Length - i < seeds[j].Length)
                    {
                        continue;
                    }

                    if (s.Substring(i, seeds[j].Length) == seeds[j])
                    {
                        can2 = true;
                        i += seeds[j].Length;
                        break;
                    }
                }
                if (!can2)
                {
                    can = false;
                    break;
                }
            }

            if (can)
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}

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

struct Point {
    int x, y;

    Point() = default;
    Point(int x, int y) : x(x), y(y) {}

    Point operator+(const Point &rhs) const {
        return Point(x + rhs.x, y + rhs.y);
    }

    Point operator-(const Point &rhs) const {
        return Point(x - rhs.x, y - rhs.y);
    }

    long long operator*(const Point &rhs) const {
        return 1ll * x * rhs.x + 1ll * y * rhs.y;
    }

    long long operator%(const Point &rhs) const {
        return 1ll * x * rhs.y - 1ll * y * rhs.x;
    }
};

bool intersect(Point p1, Point p2, Point p3, Point p4) {
    if (max(p1.x, p2.x) < min(p3.x, p4.x) || max(p3.x, p4.x) < min(p1.x, p2.x)) return false;
    if (max(p1.y, p2.y) < min(p3.y, p4.y) || max(p3.y, p4.y) < min(p1.y, p2.y)) return false;
    return ((p3 - p1) % (p4 - p1)) * ((p3 - p2) % (p4 - p2)) <= 0 &&
           ((p1 - p3) % (p2 - p3)) * ((p1 - p4) % (p2 - p4)) <= 0;
}

int main() {
    int q; cin >> q;
    while (q--) {
        Point p1, p2, p3, p4;
        cin >> p1.x >> p1.y;
        cin >> p2.x >> p2.y;
        cin >> p3.x >> p3.y;
        cin >> p4.x >> p4.y;
        cout << (intersect(p1, p2, p3, p4) ? 1 : 0) << endl;
    }
}



Measured memory_bytes: 3104
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)*}
    };
}

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

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize
    }
    match n % 10 {
        3 => {println!("bon");},
        0 | 1 | 6 | 8 => {println!("pon");},
        _ => {println!("hon");}
    }
}


Measured memory_bytes: 2108