akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <iostream>

using namespace std;

#define fo(i,CApiTaL_N) for(int i=0; i<CApiTaL_N; i++)
#define Fo(i,k,CApiTaL_N) for(int i=k; i<CApiTaL_N; i++)
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define clr(x) memset(x, 0, sizeof(x))
#define tr(it, a) for(auto it=a.begin(); it!=a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vl> vvl;

int t;
const int mxN=100, mxK=1e5, mod=1e9+7;
int n,k;
vl dp(mxK+1),a(mxN+1),cumsum(mxK+1);

void test_case(){
    cin>>n>>k;
    fo(i,n)cin>>a[i];
    dp[0]=1;
    cumsum[0]=1;
    for(auto e=1; e<k+1; e++){
        cumsum[e]=(cumsum[e-1]+dp[e]);
    }
    Fo(i,0,n){
        auto lim=a[i];
        for(int j=k; j>=0; j--){
            // Fo(p,1,lim+1){
            //     if(j-p<0)continue;
            //     dp[j]=(dp[j]+dp[j-p])%mod;
            // }
            ll total=0;
            if(!j)total=0;
            else{
                if(j-lim<=0){
                    total=cumsum[j-1];
                }else{
                    total=cumsum[j-1]-cumsum[j-lim-1];
                }
            }
            // cout<<j<<" "<<lim<<" "<<total<<" "<<i<<endl;
            dp[j]=(dp[j]+total)%mod;
        }
        for(auto e=1; e<k+1; e++){
            cumsum[e]=(cumsum[e-1]+dp[e]);
        }
    }
    cout<<dp[k]<<endl;
}

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

    t=1;
    while(t--){
        test_case();
    }
    
    return 0;
}

Measured memory_bytes: 4624
a, b ,k = map(int, input().split())

if a > k:
    a = a - k
elif a > k and k <= a+b:
    fa = abs(a-k)
    a = 0
    b = b - fa
else:
    fa = abs(a-k)
    a = 0
    b = b - fa
    if b < 0:
        b = 0

print(a, b)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define lli long long int
#define f(i,a,b) for(i=a;i<b;i++)
#define ff first
#define sc second
#define pb push_back
#define full(v) v.begin(),v.end()
#define ms(a) memset(a,0,sizeof(a))
#define mod 1000000007
#define mod2 998244353
#define msb(b) memset(b,true,sizeof(b))
#define msf(b) memset(b,false,sizeof(b))
#define MAXN 100005

int main()
{
    fio;
    lli n, i,j;
    cin >> n;
    string ans = "";
    f(i,1,99)
    {
      if(n <= pow(26, i))
      {
        n--;
        for(int j = 0; j < i; j++)
        {
          ans += 'a' + n % 26;
          n/=26;
        }
        break;
      }
      else
        n -= pow(26, i);
    }
    reverse(ans.begin(), ans.end());
    f(i,0,ans.length())
    {
      if(ans[i] < 'a' || ans[i] > 'z')
        break;
      cout << ans[i];
    }

}


Measured memory_bytes: 4068
function main(input){
  const n = parseInt(input.trim());

  const abcs = [0,111,222,333,444,555,666,777,888,999];

  for(var i=0;i<9;i++){
    if(abcs[i]<n && n<=abcs[i+1]){
      console.log(abcs[i+1]);
    }
  }
}

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

Measured memory_bytes: 7372
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

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

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main(){
  string s;
  int n;

  cin >> s;
  n = s.size();
  s = "0" + s;

  bool ok = s[1] == '1';

  for(int i=0;i*2<=n;i++){
    ok &= s[i] == s[n-i];
  }

  if (!ok) {
    puts("-1");
    return 0;
  }

  int p = 1;
  int now = 2;

  for(int i=1; i*2<=n; i++){
    printf("%d %d\n", p, now);

    if(i > 1 && s[i] == '1') {
      p = now;
    }

    now++;
  }

  while (now <= n) {
    printf("%d %d\n", p, now++);
  }



  return 0;
}


Measured memory_bytes: 1660
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
    int n;
    cin >> n;
    long long f[n], a, s = 0, mn = 1000000000000000007;
    for (int j = 0; j < n; j++) {
        cin >> a;
        s += a;
        f[j] = s;
    }
    for (int j = 0; j < n - 1; j++) {
        mn = min(mn, (long long)abs(s - (f[j] << 1)));
    }
    cout << mn;
}


Measured memory_bytes: 1792
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include "bits/stdc++.h"

using namespace std;
typedef unsigned long long ll;
typedef int                     integer;
#define int                     long long
#define ii                      pair<int,int>
#define vii                     vector<pair<int,int>>
#define vi                      vector<int>
#define vvi                     vector<vector<int>>
#define f(a,b,c)                for(int a=b;a<c;a++)
#define s(x)                    in>>x
#define s2(x,y)                 in>>x>>y
#define s3(x,y,z)               in>>x>>y>>z
#define s4(x,y,z,w)             in>>x>>y>>z>>w
#define p(x)                    out<<x<<endl
#define p2(x,y)                 out<<x<<' '<<y<<endl
#define p3(x,y,z)               out<<x<<' '<<y<<' '<<z<<endl
#define p4(x,y,z,w)             out<<x<<' '<<y<<' '<<z<<' '<<w<<endl
#define pl(x)                   out<<x
#define pll(x)                  out<<x<<' '
#define range(v)                v.begin(),v.end()
#define rst(x)                  memset(x, -1, sizeof(x))
#define UNVISITED               -1
#define VISITED                 0
#define EXPLORED                2

#define EACH(x, a) for (auto& x: a)
template<class T> void read_v(T& x, std::istream& in) {
    in >> (x);
}
template<class A> void read_vec(vector<A>& x, std::istream& in) {
    EACH(a, x)
        read_v(a, in);
}

bool sortpairbysec(const pair<int,int> &a,const pair<int,int> &b){return (a.second < b.second);}
template <typename T>
T factmod(T a, T modulus){ int res = 1, i; for (i = 2; i <= a; i++){ res *= i; res%=modulus;} return res; }
template <typename T>
int powmod(T a,T b,int m){ int ans=1; while(b>0){if(b&1){ans*=a;ans%=m;}a*=a;a%=m;b>>=1;} return ans; }
template <typename T>
int power(T a, T b){ int ans=1; while(b>0){if(b&1){ans*=a;}a*=a;b>>=1;}return ans;}


int dfs(int node, vector<int>& dp, const vector<vector<int>>& edges, vector<bool>& vis){
    vis[node] = true;
    int depth = 0;
    for(int children: edges[node]){
        if(!vis[children]){
            depth = dfs(children, dp, edges, vis) + 1;
        }else{
            depth = dp[children] + 1;
        }
        dp[node] = max(depth, dp[node]);
    }
    return dp[node];
}

void ssolve(std::istream& in, std::ostream& out){
    int n, m; s2(n, m);
    vector<vector<int>> edges(n + 1);
    f(i, 0, m){
        int from, to; s2(from, to);
        edges[from].emplace_back(to);
    }
    vector<int> dp(n + 1, 0);
    int ans = 0;
    vector<bool> vis(n + 1, false);
    for(int i = 1; i <= n; i++){
        ans = max(ans, dfs(i, dp, edges, vis));
    }
    p(ans);
}

class GLongestPath {
public:
void solve(std::istream& in, std::ostream& out) {
    ios_base::sync_with_stdio(false);
    in.tie(nullptr);out.tie(nullptr);
    int t;
    int READ = 0;
    if(READ) s(t);
    else t = 1;
    while(t--){
        ssolve(in, out);
    }
}
};

integer main() {
    GLongestPath solver;
    std::istream& in(std::cin);
     std::ostream& out(std::cout);
     solver.solve(in, out);
}

Measured memory_bytes: 13776
#include <bits/stdc++.h>
        using namespace std;
        #define int long long
const int MAX = 200001;
const int MOD = 1000000007;
//
int fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
int COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int modpow(int a, int n, int mod) {
    int res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
        signed main() {
    int x;
    cin>>x;
    int ans=1;
    for(int i=2;i<=x;i++){
            for(int j=i*i;j<=x;j*=i)ans=max(ans,j);
    }
    cout<<ans;
    
      }

        


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
#define F first
#define S second
using namespace std;
using ll = long long int;
using vi = vector<pair<int, int> >;
using graph = vector<vi>;
const int MAXN = 212345;
int pai[MAXN], ans[MAXN];
graph g;
void sol(int u, int cor) {
    ans[u] = cor; 
    for (auto v : g[u]) if (pai[u] != v.F) {
        pai[v.F] = u;
        sol(v.F, cor^v.S);
    }
}
int main() {
    int n, m, k;
    scanf("%d", &n);
    int u, v, w;
    g.assign(n+1, vi());
    for (int i = 1; i<n; ++i) {
        scanf("%d %d %d", &u, &v, &w);
        g[u].emplace_back(v, w&1);
        g[v].emplace_back(u, w&1);
    }
    sol(1, 0);
    for (int i = 1; i<=n; ++i) {
        printf("%d\n", ans[i]);
    }
}


Measured memory_bytes: 8576
#include <cstdio>
const int MAXN=330;
int c[3];
double f[MAXN][MAXN][MAXN];
int main()
{
//	freopen("J.in", "r", stdin);
//	freopen("J.out", "w", stdout);
	int n;
	scanf("%d", &n);
	for (int i=1; i<=n; i++)
	{
		int a;
		scanf("%d", &a);
		c[a-1]++;
	}
	for (int k=0; k<=n; k++)
		for (int j=0; j<=n; j++)
			for (int i=0; i<=n; i++)
			{
				f[i][j][k]=0.0;
				if (i==0&&j==0&&k==0) continue;
				if (i>0) f[i][j][k]+=f[i-1][j][k]*i/n;
				if (j>0) f[i][j][k]+=f[i+1][j-1][k]*j/n;
				if (k>0) f[i][j][k]+=f[i][j+1][k-1]*k/n;
				f[i][j][k]=(f[i][j][k]+1)*n/(i+j+k);
			}
	printf("%.10lf\n", f[c[0]][c[1]][c[2]]);
	return 0;
}

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

#define ll long long
#define rep(i, n) for (ll i = 0; i < n; i++)
#define in(params) cin >> params;
#define p(params) cout << params << endl;
#define mod 1000000007LL
#define PS(p) cout << setprecision(15) << fixed << p << endl;

using namespace std;

int main() {
  double T, X;

  cin >> T >> X;

  PS(T / X);

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int n,m;
  scanf("%d%d", &n, &m);
  int i;
  int c[m];
  for(i=0;i<m;i++){
    c[i] = 1;
  }
  for(i=0;i<n;i++){
    int tmp[m];
    int j;
    for(j=0;j<m;j++){
      tmp[j] = 0;
    }
    int k;
    scanf("%d", &k);
    for(j=0;j<k;j++){
      int a;
      scanf("%d", &a);
      tmp[a-1] = 1;
    }
    for(j=0;j<m;j++){
      c[j] = tmp[j] * c[j];
    }
  }
  int ans = 0;
  for(i=0;i<m;i++){
    ans += c[i];
  }
  printf("%d\n", ans);
  return 0;
}


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

int main()
{
    int r,c;
    cin>>r>>c;
    vector<vector<char>>dp1(r+1,vector<char>(c+1));
    for(int i=1;i<=r;i++)
    {
        for(int j=1;j<=c;j++)
        {
            cin>>dp1[i][j];
        }
    }
    vector<vector<int>>dp(r+1,vector<int>(c+1,0));
    dp[1][0]=1;
    for(int i=1;i<=r;i++)
    {
        for(int j=1;j<=c;j++)
        {
            if(dp1[i][j]=='#')
            {dp[i][j]=0;}
            else dp[i][j]=(dp[i-1][j]+dp[i][j-1])%(int)(1e9+7);
        }
    }
    cout<<dp[r][c];
}

Measured memory_bytes: 5248
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
from fractions import gcd
MOD = 10**9 + 7

n = int(input())
a = [int(item) for item in input().split()]


lcm = 1
for item in a:
    lcm = lcm * item // gcd(lcm, item)
lcm %= MOD

ans = 0
for item in a:
    ans += lcm * pow(item, MOD-2, MOD)
    ans %= MOD

print(ans)

Measured memory_bytes: 6108
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll ZERO = 0;
const int Inf = 1000000000;
const ll INF= 1e18;
const ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<ll,ll> P;

int main() {
    int H,W;
    cin >> H >> W;
    vector<int> vec(26);
    for(int i = 0;i < H;i++) {
        for(int j = 0;j < W;j++) {
            char A;
            cin >> A;
            vec.at(A - 'a')++;
        }
    }
    int four = 0;
    int two = 0;
    int one = 0;
    for(int i = 0;i < 26;i++) {
        if(vec.at(i) != 0) {
            if(vec.at(i) % 4 == 0) {
                four++;
            }
            else if(vec.at(i) % 2 == 0) {
                two++;
            }
            else {
                one++;
                if((vec.at(i) - 1) % 4 == 0) {
                    four++;
                }
                else {
                    two++;
                }
            }
        }
    }
    if(H % 2 == 0 && W % 2 == 0) {
        if(two != 0 || one != 0) {
            cout << "No" << endl;
        }
        else {
            cout << "Yes" << endl;
        }
    }
    else if(H % 2 == 0) {
        if(two >= H / 2 + 1 || one != 0) {
            cout << "No" << endl;
        }
        else {
            cout << "Yes" << endl;
        }
    }
    else if(W % 2 == 0) {
        if(two >= W / 2 + 1 || one != 0) {
            cout << "No" << endl;
        }
        else {
            cout << "Yes" << endl;
        }
    }
    else {
        if(two >= H / 2 + W / 2 + 1 || one != 1) {
            cout << "No" << endl;
        }
        else {
            cout << "Yes" << endl;
        }
    }
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		FastScanner in = new FastScanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskC solver = new TaskC();
		solver.solve(1, in, out);
		out.close();
	}

	static class TaskC {
		public void solve(int testNumber, FastScanner in, PrintWriter out) {
			int n = in.nextInt();
			int m = in.nextInt();
			List<Integer>[] adj = new List[n];
			for (int i = 0; i < n; i++) {
				adj[i] = new ArrayList<>();
			}
			for (int i = 0; i < m; i++) {
				int a = in.nextInt() - 1;
				int b = in.nextInt() - 1;
				adj[a].add(b);
				adj[b].add(a);
			}
			int[] d = bfs(0, adj);
			out.println(d[n - 1] <= 2 ? "POSSIBLE" : "IMPOSSIBLE");
		}

		private int[] bfs(int s, List<Integer>[] adj) {
			int n = adj.length;
			int[] q = new int[n];
			int[] d = new int[n];
			Arrays.fill(d, n);
			d[s] = 0;
			q[0] = s;
			int qt = 0;
			int qh = 1;
			while (qt < qh) {
				int i = q[qt++];
				for (int j : adj[i]) {
					if (d[j] > 1 + d[i]) {
						d[j] = 1 + d[i];
						q[qh++] = j;
					}
				}
			}
			return d;
		}

	}

	static class FastScanner {
		private BufferedReader in;
		private StringTokenizer st;

		public FastScanner(InputStream stream) {
			in = new BufferedReader(new InputStreamReader(stream));
		}

		public String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					String rl = in.readLine();
					if (rl == null) {
						return null;
					}
					st = new StringTokenizer(rl);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return st.nextToken();
		}

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

	}
}



Measured memory_bytes: 86712
from collections import Counter

n=int(input())
s=[input() for _ in range(n)]

cnt=0
cnt_a=0
cnt_b=0
cnt_ab=0
for i in range(n):
    if s[i][0]=='B' and s[i][-1]=='A':
        cnt_ab+=1
    elif s[i][0]=='B':
        cnt_b+=1
    elif s[i][-1]=='A':
        cnt_a+=1
    cnt+=s[i].count('AB')
if cnt_ab==0:
    ans=cnt+min(cnt_a,cnt_b)
else:
    if cnt_a==0 and cnt_b==0:
        ans=cnt+cnt_ab-1
    else:
        ans=cnt+cnt_ab+min(cnt_a,cnt_b)

print(ans)


Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int n;
pair<int, int> p[N];
bool cmp(pair<int, int> a, pair<int, int> b) {
	if(a.second == b.second) return a.first < b.first;
	return a.second < b.second;
}
int main() {
	scanf("%d", &n);
	for(int i = 0; i < n; ++i)
		scanf("%d %d", &p[i].first, &p[i].second);
	sort(p, p + n, cmp);
	int ans = 0;
	int last = -1;
	for(int i = 0; i < n; ++i) {
		if(last < p[i].first) {
			ans++;
			last = p[i].second;
		}
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 4020
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	int n;
	cin>>n;
	vector<int>arr(n+1);
	for(int i=1; i<=n; i++)
	 cin>>arr[i];
	vector<int>pf1(n+1);
	vector<int>pf2(n+1);
	int gcd=arr[1];
	pf1[1]=gcd;
	for(int i=2; i<=n; i++){
		pf1[i]=__gcd(gcd,arr[i]);
		gcd=pf1[i];
	}
	gcd=arr[n];
	pf2[n]=gcd;
	for(int i=n-1; i>=1; i--){
		pf2[i]=__gcd(arr[i],gcd);
		gcd=pf2[i];
	}
	int ans=1;
	for(int i=1; i<=n; i++){
		if(i==1)
		{
			ans=max(ans,pf2[i+1]);
		}
		else if(i==n)
		{
			ans=max(ans,pf1[i-1]);
		}
		else{
			int temp=__gcd(pf1[i-1],pf2[i+1]);
			ans=max(ans,temp);
		}
	}
	cout<<ans;
	return 0;
	
	
}

Measured memory_bytes: 4576
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/rational.hpp>
using namespace std;
namespace mp = boost::multiprecision;
// 任意長整数型
using ll= mp::cpp_int;


#define REP(i,n) for(ll i=0; i<(n); i++)
#define REP2(i,x,n) for(ll i=x; i<(n); i++)
#define REP3(i,x,n) for(ll i=x; i>(n); i--)
#define zero_pad(num) setfill('0') << std::right << setw(num)
#define space_pad(num) setfill(' ') << std::right << setw(num)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();

int main(){
    int N;
    ll ans=1;
    cin >> N;
    ll A[N];
  	
    for (int i = 0; i < N; i++)
    {
        ll a;
        cin>>a;
        if(a==0){
            cout << "0" << endl;
            return 0;
        }
      	A[i] = a;
    }
    for(int i = 0; i < N;i++){    
        
      ans *= A[i];
      if(ans > 1000000000000000000){
              cout << "-1" << endl;
              return 0;
      }
    }

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


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

using namespace std;

using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;
  a--, b--, c--, d--;
  string s;
  cin >> s;
  int left = a;
  int right = max(c, d);
  for (int i = left; i < right; i++) {
    if (s[i] == '#' && s[i + 1] == '#') {
      cout << "No" << '\n';
      return 0;
    }
  }
  if (c < d) {
    cout << "Yes" << '\n';
    return 0;
  }
  for (int i = b; i <= d; i++) {
    if (s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.') {
      cout << "Yes" << '\n';
      return 0;
    }
  }
  cout << "No" << '\n';
  return 0;
}


Measured memory_bytes: 3744
#include<stdio.h>
#define N 200000
#define M 2000000000
#define O 0
#define I 1
#define W 2

typedef long long int llong;

int L[N/W+W],R[N/W+W];

llong merge(int*,int,int,int,int);
llong mergeSort(int*,int,int,int);

int main(){
  int A[N],n,i;
  llong a;

  scanf("%d",&n);
  for(i=O;i<n;i++){
    scanf("%d",&A[i]);
  }
  a=mergeSort(A,n,O,n);
  printf("%lld\n",a);
  return O;
}
llong merge(int A[],int n,int left,int mid,int right){
  int i,j,k;
  int n1,n2;
  llong c=O;
  n1=mid-left;
  n2=right-mid;
  for(i=O;i<n1;i++){
    L[i]=A[left+i];
  }
  for(i=O;i<n2;i++){
    R[i]=A[mid+i];
  }
  L[n1]=R[n2]=M;
  i=j=O;
  for(k=left;k<right;k++){
    if(L[i]<=R[j]){
      A[k]=L[i++];
    }
    else{
      A[k]=R[j++];
      c+=n1-i;
    }
  }
  return c;
}

llong mergeSort(int A[], int n, int left, int right){
  int mid;
  llong v1,v2,v3;
  if(left+I<right){
    mid=(left+right)/W;
    v1=mergeSort(A,n,left,mid);
    v2=mergeSort(A,n,mid,right);
    v3=merge(A,n,left,mid,right);
    return v1+v2+v3;
  }
  else return O;
}



Measured memory_bytes: 3384
N = int(input())
A = list(map(int, input().split()))
oddsum = 0
for index in range(1, len(A), 2):
	oddsum += A[index]

x=[]
x.append(sum(A) - 2*oddsum)
for a in A[:-1]:
	x.append((a - x[-1]//2)*2)
print(" ".join(map(str, x)))

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

int main() {
  long long a, b, k;
  cin >> a >> b >> k;
  // 高橋のみ
  if(k<=a) {
    a-=k;
  } else
  // 高橋+青木
  if(k<=a+b) {
    b-=k-a;
    a=0;
  } else
  // 食べきっちゃった
  if(k>a+b) {
    a=0;
    b=0;
  }
  cout << a << " " << b << endl;
}


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

int main(){
	int N;
	cin>>N;
	double x[N],ans=0;
	string u[N];
	for(int i=0;i<N;i++){
		cin>>x[i]>>u[i];
		if(u[i]=="JPY"){
			ans+=x[i];
		}else{
			ans+=x[i]*380000;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include <algorithm>
using namespace std;

int a[2001],b[2001];
long long f[2001][2001];
const long long Mod=1e9+7;

int main()
{
    int n,m;
   // printf("%lld\n",(-1)%Mod);
    scanf("%d%d",&n,&m);
    for (int i=1;i<=n;++i) scanf("%d",&a[i]);
    for (int j=1;j<=m;++j) scanf("%d",&b[j]);

    f[0][0]=1;
    for (int i=1;i<=n;++i) f[i][0]=1;
    for (int j=1;j<=m;++j) f[0][j]=1;

    for (int i=1;i<=n;++i)
    for (int j=1;j<=m;++j){
        f[i][j]=f[i-1][j]+f[i][j-1]-f[i-1][j-1];
        if (a[i]==b[j]) f[i][j]+=f[i-1][j-1];
        f[i][j]+=Mod;        f[i][j]%=Mod;
    }
   // for (int i=1;i<=n;++i,printf("\n")) for (int j=1;j<=n;++j) printf("\t%lld",f[i][j]);
    printf("%lld\n",f[n][m]);

}



Measured memory_bytes: 31488
#include <iostream>
#include <complex>
#include <cstdio>
#include <vector>
#include <map>

using namespace std;

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

typedef complex<double> P;

struct L : public vector<P> {
  L(const P &a, const P &b) {
    push_back(a); push_back(b);
  }
};

// ??????
double dot(const P& a, const P& b) {
    return real(conj(a)*b);
}

// ??????
double cross(const P& a, const P& b) {
    return imag(conj(a)*b);
}

// ???p2?????????p0, p1???????????´???????°???±?????????
P projection(const P& p0, const P& p1, const P& p2) {
    // ???????????????????????´???
    P vec1 = p1 - p0;
    P vec2 = p2 - p0;
    return p0 + vec1 * dot(vec1, vec2) / dot(vec1, vec1);
}

// ???p0, p1???????????´??????????§°?????¨????????????p2??¨????§°??????
P reflection(const P& p0, const P& p1, const P& p2) {
    P proj = projection(p0, p1, p2);
    return proj - (p2 - proj);
}

int ccw(P a, P b, P c) {
    b -= a; c -= a;
    if (cross(b, c) > 0)   return +1;       // counter clockwise
    if (cross(b, c) < 0)   return -1;       // clockwise
    if (dot(b, c) < 0)     return +2;       // c--a--b on line
    if (norm(b) < norm(c)) return -2;       // a--b--c on line
    return 0;                               // a--c--b on line
}

// 2??´?????????????????????
bool is_parallel(const L& l1, const L& l2) {
    P p1 = l1[1] - l1[0];
    P p2 = l2[1] - l2[0];
    auto res = ccw(p1, p2, P(0,0));
    return (res == 2 || res == -2 || res == 0);
}

// 2??´???????????´?????????
bool is_ortho(const L& l1, const L& l2) {
    P p1 = l1[1] - l1[0];
    P p2 = l2[1] - l2[0];
    return dot(p1, p2) == 0;
}

// // ????????¨???P??¨??????????????????????????¢
// double norm(const P& a, const P& b) {
//     return dot(
//     return real(conj(a)*b);
// }

int main(){
    int Q;
    cin >> Q;
    REP(q, Q) {
        double x0, y0, x1, y1, x2, y2, x3, y3;
        cin >> x0 >> y0 >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
        P p0(x0, y0);
        P p1(x1, y1);
        P p2(x2, y2);
        P p3(x3, y3);
        L l0(p0, p1);
        L l1(p2, p3);
        if (is_parallel(l0, l1)) {
            cout << 2 << endl;
        }
        else if (is_ortho(l0, l1)) {
            cout << 1 << endl;
        }
        else {
            cout << 0 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1260
W, a, b = map(int, input().split())
a_box = [i for i in range(a, a+W+1)]
b_box = [i for i in range(b, b+W+1)]

if a_box[0] in b_box or a_box[-1] in b_box:
    print(0)
else:
    if a < b:
        print(abs((a+W)-b))
    elif a > b:
        print(abs(a-(b+W)))


Measured memory_bytes: 11032
def checkheight(H, data, coordinate):
    cx, cy = coordinate

    for px, py, ph in data:
        if not ph == max(H - abs(px - cx) -  abs(py - cy), 0):
            return None

    return (cx, cy, H)

def makeheight(data, cx, cy):
    px, py, ph = list(filter(lambda dataset: dataset[2] > 0, data))[0]
    return ph + abs(px - cx) + abs(py - cy)


def main():
    N = int(input())

    data = [list(map(int, input().split())) for _ in range(N)]


    for cx in range(101):
        for cy in range(101):
            tmpch = makeheight(data.copy(), cx, cy)

            res = checkheight(tmpch, data, (cx, cy))

            if res:
                print(*res)
                return



if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007;
using ll = long long;
using namespace std;

/*
簡単な桁 DP をやればよい
dp[i][gleich] := (和がピッタリ L である組み合わせ)
dp[i][kleiner] := (和が L 未満である組み合わせ)

ある桁について 1 のとき:
gleich: (a[i], b[i]) = (1, 0) o. (0, 1)
kleiner: (a[i], b[i]) = (1, 0) o. (0, 1) o. (0, 0)
gleich → kleiner: (a[i], b[i]) = (0, 0)
 
ある桁について 0 のとき:
gleich: (a[i], b[i]) = (0, 0)
kleiner: (a[i], b[i]) = (1, 0) o. (0, 1) o. (0, 0)
*/

ll dp[100100][2];
const int gleich = 0;
const int kleiner = 1;

int main(){
	string l; cin >> l;
	int bound = l.l_ength();
	dp[0][gleich] = 2;
	dp[0][kleiner] = 1;
	for( int i = 0; i < bound-1; ++i ){
		if( l[i+1] == '1' ){
			dp[i+1][gleich] += ( dp[i][gleich] * 2 ) % mod;
			dp[i+1][kleiner] += ( dp[i][gleich] + dp[i][kleiner]*3 ) % mod;		
		} else {
			dp[i+1][gleich] += dp[i][gleich];
			dp[i+1][kleiner] += ( dp[i][kleiner] * 3 ) % mod;
		}
	}
	cout << ( dp[bound-1][gleich]+dp[bound-1][kleiner] ) % mod << endl;
	return 0;
}

Measured memory_bytes: 2048
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n; string s; cin>>n>>s;
	stack<char>	 stk;	
	for (const char & ch : s)	{
		if (stk.empty()) stk.push(ch);
		else {
			if (stk.top()==ch) continue;
			stk.push(ch); 
		}	
	}
	cout<<stk.size()<<endl;
	return 0;
}


Measured memory_bytes: 3808
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;

typedef pair<int,int> pii;

struct Edge{
    int to, length, num;
};

int main(){
    int n, m, l;
    while(cin >> n >> m >> l, n+m+l){
        vector<vector<int>> dp(n, vector<int>(l+1, 1<<30));
        vector<Edge> v[n];
        for(int i = 0; i < m; i++){
            int a, b, d, e;
            cin >> a >> b >> d >> e;
            a--, b--;
            v[a].push_back(Edge({b, d, e}));
            v[b].push_back(Edge({a, d, e}));
        }
        dp[0][l] = 0;
        priority_queue<pair<int, pii>> pq;
        pq.push({-0, {0, l}});
        while(!pq.empty()){
            auto p = pq.top();  pq.pop();
            int cost = -p.first, now = p.second.first, res = p.second.second;
            if(dp[now][res] != cost)    continue;
            if(now == n-1){
                cout << dp[now][res] << endl;
                break;
            }
            for(Edge e : v[now]){
                if(dp[e.to][res] > cost+e.num){
                    dp[e.to][res] = cost+e.num;
                    pq.push({-dp[e.to][res], {e.to, res}});
                }
                int nres = res-e.length;
                if(nres < 0)  continue;
                if(dp[e.to][nres] > cost){
                    dp[e.to][nres] = cost;
                    pq.push({-dp[e.to][nres], {e.to, nres}});
                }
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3192
H, W = map(int, input().split())
s = ["."*(W+2)]
for i in range(H):
    s.append("."+input()+".")
s.append("."*(W+2))

for i in range(1, H+1):
    res = ""
    for j in range(1, W+1):
        if s[i][j] == "#":
            res += "#"
            continue
        count = 0
        for k in [-1, 0, 1]:
            for l in [-1, 0, 1]:
                if s[i+k][j+l] == "#":
                    count += 1
        res += str(count)
    print(res)


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
#define LNF __LONG_LONG_MAX__;
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
//最小公倍数
int lcm(int x, int y) { return x / gcd(x, y) * y; }
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    int X,Y,Z; cin >> X >> Y >> Z;
    cout << Z << " " << X << " " << Y << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <functional>
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <sstream>
#include <cstring>
#include <bits/stdc++.h>
#include <iostream>
#define FAST ios::sync_with_stdio(0); cin.tie(0);
#define ll long long
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define for0(i, n) for (int i = 0; i < (int)(n); ++i) // 0 based indexing
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i) // 1 based indexing
#define forc(i, l, r) for (int i = (int)(l); i <= (int)(r); ++i) // closed interver from l to r r inclusive
#define forr0(i, n) for (int i = (int)(n) - 1; i >= 0; --i) // reverse 0 based.
#define forr1(i, n) for (int i = (int)(n); i >= 1; --i) // reverse 1 based
#define enterarray(a,n) for(int i=0;i<(int)(n);++i)cin>>a[i];
#define ins insert
const int MOD =998244353;
const int MX = int(2e6+9);
using namespace std;
ll f[200004];
int even(ll num){
    if(num%2==0)return 1;
    else return 0;
}
ll gcd(ll x,ll y){
    for(ll i=min(x,y);i>=1;i--){
        if(x%i==0&&y%i==0)return i;
    }
}
void printvector(vector<int> v){
    int i;
    for0(i,v.size())cout<<v[i]<<" ";
}
void solve(){
    ll n,m,i,j,k;
    ll a[200005],b[200005];
    ll ans=0,res=0;
    bool flag=true;
    vector<ll> v;
    string s1,s2;
    set<ll> s;
    cin>>n;
    for0(i,n)cin>>a[i]>>b[i];
    for(i=0;i<=n-3;i++){
        if(a[i]==b[i]&&a[i+1]==b[i+1]&&a[i+2]==b[i+2]){
            cout<<"Yes";
            return;
        }
    }
    cout<<"No";
}
 
int main()
{
    FAST;
   int t;
    t=1;
    while(t--)
    {
        solve();
        cout<<"\n";
    }
}

    

Measured memory_bytes: 3664
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;


int main(int argc, char* argv[])
{
    int n;
    scanf("%d", &n);

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

    ll sum=0;
    for(i=0; i<n; i++) {
        sum += b[a[i]-1];
        if(i>0) {
            if(a[i]==a[i-1]+1) {
                sum+=c[a[i-1]-1];
            }
        }
    }
    printf("%lld\n", sum);



    return 0;
}



Measured memory_bytes: 256
import numpy as np

A,B,H,M = list(map(int,input().split()))

time = H*60 + M

np.pi
omega_A = 2.0*np.pi/(12.0*60.0)
omega_B = 2.0*np.pi/60.0

theta_A = omega_A * time
theta_B = omega_B * time

x_A = A * np.sin(theta_A)
y_A = A * np.cos(theta_A)

x_B = B * np.sin(theta_B)
y_B = B * np.cos(theta_B)

distance = np.sqrt((x_A - x_B)**2.0 + (y_A - y_B)**2.0)
print(distance)



Measured memory_bytes: 27196
#include <stdio.h>

int x;
int is_cube_of(int x)
{
  if((x>=1)&&(x<=100))
     return x*x*x;
}

int main(int argc, char*argv[]) {
  scanf("%d",&x);
  printf("%d\n",is_cube_of(x));
  return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

int main() {
  ll n, a, g;
  cin >> n >> g;
  rep(i, n - 1) cin >> a, g = gcd(g, a);

  cout << g << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.List;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {
		PrintWriter out = new PrintWriter(System.out);
		FastScanner scan = new FastScanner();
		List<Character> odd = Arrays.asList('R', 'U', 'D');
		List<Character> even = Arrays.asList('L', 'U', 'D');

		String s = scan.next();
		boolean isEven;
		char t;
		for (int i = 1; i <= s.length(); i++) {
			isEven = i % 2 == 0;
			t = s.charAt(i - 1);
			if (!((!isEven && odd.contains(t))
					|| (isEven && even.contains(t)))) {
				out.println("No");
				out.flush();
				return;
			}

		}

		out.println("Yes");
		out.flush();
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

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

Measured memory_bytes: 21716
//#include <bits/stdc++.h>
//#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <tuple>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>

using namespace std;
using ll=long long;
using intpair=pair<int,int>;
using intpv=vector<intpair>;
using llpair=pair<ll,ll>;
using llpv=vector<llpair>;
using intvec=vector<int>;
using llvec=vector<ll>;
using intq=queue<int>;
using llq=queue<ll>;
using intmat=vector<intvec>;
using llmat=vector<llvec>;
using pairmat=vector<llpv>;

template<typename T>
using matrix=vector<vector<T>>;
template<typename T>
using pque=priority_queue<T>;
template<typename T>
using lpque=priority_queue<T,vector<T>,greater<T>>;

#define PI 3.141592653589793
#define INTINF 1<<30
#define LLINF 1LL<<60
#define MPRIME 1000000007
#define MPRIME9 998244353

#define len length()
#define pushb push_back
#define fi first
#define se second

#define setpr fixed<<setprecision(15)
#define all(name) name.begin(),name.end()
#define rall(name) name.rbegin(),name.rend()
#define gsort(vbeg,vend) sort(vbeg,vend,greater<>())
#define matin(mat,H,W) for(int i__=0; i__<H; i__++)for(int j__=0; j__<W; j__++) cin>>mat[i__][j__]
#define out(n) cout<<n<<endl

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>
inline void outmat(T& a, int y, int x) {
	for(int i=0; i<y; i++) {
		for(int j=0; j<x; j++) cout<<a[i][j]<<" ";
		cout<<endl;
	}
}

template<class T>
inline void init(T& v) {
	for(auto &a__: v) cin>>a__;
}
template<class T, class N>
inline void init(T& v, N n) {
	v.resize(n);
	for(auto &a__: v) cin>>a__;
}

template<class N> void resiz(N n) {} // empty
template<class N, class T, class... U>
void resiz(N n, T&& hd, U&&... tl) {
	hd.resize(n);
	resiz(n,forward<U>(tl)...);
}

ll GCD(ll a, ll b) { //最大公約数
	if(a==0||b==0) return 0;
	if(a<b) swap(a,b);
	ll tmp = a%b;
	while(tmp!=0) {
		a = b;
		b = tmp;
		tmp = a%b;
	}
	return b;
}

ll binpow(ll a, ll ex, ll p) { //繰り返し二乗法
	ll result=1;
	while(ex>0) {
		if(ex&1) result=result*a%p;
		ex>>=1;
		a=a*a%p;
	}
	return result;
}

ll Fact(ll x, ll p) { //階乗
	ll f=1;
	for(ll i=2; i<=x; i++) {
		f*=i;
		f%=p;
	}
	return f;
}

int DigitNum(ll n) { //桁数
	int digit=0;
	ll div=1LL;
	while(n/div) {
		digit++;
		div*=10;
	}
	return digit;
}

int N;
llvec A;
ll sum=1;

void input() {
	cin>>N;
	init(A,N);
}

void solve() {
	sort(all(A));
	if(A[0]==0) {
		cout<<0<<endl;
		return;
	}
	for(int i=0; i<N; i++) {
		if(1000000000000000000ll/sum < A[i]) {
			cout<<-1<<endl;
			return;
		}
		sum*=A[i];
	}
	cout<<sum<<endl;
}

int main() {
	while(1) {
		input();
		solve();
		break;
	}
}


Measured memory_bytes: 3988
import java.io.*;
import java.util.*;

class Main {
    static Scanner scanner = new Scanner();
    static PrintWriter out = new PrintWriter(System.out);

    void solve() {
        int n = scanner.nextInt();
        int[] q = new int[n];
        for (int i = 0; i < n; i++) {
            q[scanner.nextInt() - 1] = i;
        }
        int ans = n - 1;
        for (int i = 1, c = 1; i < n; i++) {
            if (q[i - 1] < q[i]) {
                c++;
            } else {
                c = 1;
            }
            ans = Math.min(ans, n - c);
        }
        out.println(ans);
    }

    public static void main(String[]$) {
        new Main().solve();
        out.close();
    }

    static class Scanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 32768);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            return tokenizer.nextToken();
        }

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

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

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

Measured memory_bytes: 45932
def create_prime_list(limit):
    x = limit**0.5
    primes = []
    #print('x={0}'.format(x))
    nums = [x for x in range(2, limit+1)]
    while nums[0]<=x:
        primes.append(nums[0])
        current_prime = nums[0]
        nums = [x for x in nums if x%current_prime != 0]
    primes.extend(nums)
    return primes
    
Q = int(input())

p = set(create_prime_list(10**5))

#今注目してる数より左に出てきた「2017に似た数」
n_of_p = [0]*(10**5+2)

for i in range(1,10**5+1):
    if i%2 == 1:
        if i in p and (i+1)//2 in p:
            n_of_p[i+1] = n_of_p[i] + 1
        else:
            n_of_p[i+1] = n_of_p[i]
    else:
        n_of_p[i+1] = n_of_p[i]
        
#print(n_of_p[0:20])

for _ in range(Q):
    l,r = map(int,input().split())
    print(n_of_p[r+1] - n_of_p[l])
    

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

int main()
{
    int tem,sum=0,m=-1;
    for(int i=0;i<3;i++)
    {
        cin>>tem;
        sum+=tem;
        m=max(tem,m);
    }
    cout<<m*10+(sum-m);
    return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;
const int kmax = 510000;

long long fact[kmax], fact_inv[kmax], inv[kmax];

void init_comb()
{
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < kmax; i++) {
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
    }
}

long long comb(int n, int r)
{
    if (n < r) {
        return 0;
    }

    if (n < 0 || r < 0) {
        return 0;
    }

    return fact[n] * (fact_inv[r] * fact_inv[n - r] % mod) % mod;
}

template <typename T, T N>
class UnionFind {
    T parent_[N];
    T rank_[N];
    T size_[N];

public:
    UnionFind();
    T Root(T idx);
    bool IsSame(T x, T y);
    void Unite(T x, T y);
    T GetSize(T idx);
};

template <typename T, T N>
UnionFind<T, N>::UnionFind()
{
    for (T i = 0; i < N; i++) {
        parent_[i] = i;
        rank_[i] = 0;
        size_[i] = 1;
    }
}

template <typename T, T N>
T UnionFind<T, N>::Root(T idx)
{
    return parent_[idx] == idx ? idx : parent_[idx] = Root(parent_[idx]);
}

template <typename T, T N>
bool UnionFind<T, N>::IsSame(T x, T y)
{
    return Root(x) == Root(y);
}

template <typename T, T N>
void UnionFind<T, N>::Unite(T x, T y)
{
    x = Root(x);
    y = Root(y);
    if (x == y) {
        return;
    }

    if (rank_[x] < rank_[y]) {
        parent_[x] = y;
        size_[y] += size_[x];
    } else {
        parent_[y] = x;
        size_[x] += size_[y];
        if (rank_[x] == rank_[y]) {
            rank_[x]++;
        }
    }
}

template <typename T, T N>
T UnionFind<T, N>::GetSize(T idx)
{
    return size_[Root(idx)];
}

long long pow_mod(long long n, long long p, long long m)
{
    if (p == 0) {
        return 1;
    }

    if (p % 2 == 0) {
        long long t = pow_mod(n, p / 2, m);
        return t * t % m;
    }
    return n * pow_mod(n, p - 1, m) % mod;
}

long long nCr_mod(long long n, long long r)
{
    long long x = 1;
    for (long long i = n - r + 1; i <= n; i++) {
        x *= i;
        x %= mod;
    }

    long long a = 1;
    for (long long i = 1; i <= r; i++) {
        a *= i;
        a %= mod;
    }

    long long y = pow_mod(a, mod - 2, mod) % mod;

    return x * y % mod;
}

int main()
{
    long long n;
    std::cin >> n;

    std::vector<long long> a(n);
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
    }

    std::vector<long long> stack;

    long long ans = 0;
    for (int i = 0; i < n; i++) {
        while (i + 1 < n && a[i] == a[i + 1]) {
            i++;
        }

        if (i + 1 < n && a[i] <= a[i + 1]) {
            while (i + 1 < n && a[i] <= a[i + 1]) {
                i++;
            }
        } else if (i + 1 < n && a[i] >= a[i + 1]) {
            while (i + 1 < n && a[i] >= a[i + 1]) {
                i++;
            }
        }
        ans++;
    }

    std::cout << ans << std::endl;
}


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

typedef pair<int, int> P;

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3
#define mod 1000000007

struct state{
  int d;
  P p;
};
bool operator<(const state& a,const state& b){
  return a.d > b.d;
}

int w,h,n;
int x[101],y[101];
int dist[105][1001];

int main(){
  scanf("%d%d%d",&w,&h,&n);
  rep(i,n)scanf("%d%d",x+i,y+i);
  priority_queue<state> que;
  rep(i,n+1)rep(j,w+h+1)dist[i][j]=INF;
  que.push((state){0,P(n,0)});
  int res=INF;
  while(que.size()){
    P p=que.top().p;
    int d=que.top().d;
    que.pop();
    if(dist[p.fi][p.se]!=INF)continue;
    dist[p.fi][p.se]=d;
    if(p.fi==n){ // start
      rep(i,n){
        int md=abs(x[i]-1)+abs(y[i]-1);
        que.push((state){d+md,P(i,md)});
      }
    }else{ // light
      rep(i,n){
        if(x[i]<x[p.fi]&&y[i]<y[p.fi])continue;
        if(i==p.fi)continue;
        int md=abs(x[i]-x[p.fi])+abs(y[i]-y[p.fi]);
        if(md<=p.se+1){
          que.push((state){d,P(i,0)});
        }else{
          md-=p.se+1;
          que.push((state){d+md,P(i,md)});
        }
      }
      { // -> end
        int md=abs(x[p.fi]-w)+abs(y[p.fi]-h);
        if(md<=p.se){
          minch(res,d);
        }else{
          md-=p.se;
          minch(res,d+md);
        }
      }
    }
  }
  cout<<res<<endl;
  return 0;
}



Measured memory_bytes: 27852
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S,T;
  cin>>S>>T;
  sort(S.begin(),S.end());
  sort(T.begin(),T.end());
  reverse(T.begin(),T.end());
  if(S<T){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}
  

Measured memory_bytes: 256
import itertools
n = int(input())
a = tuple(map(int, input().split()))
b = tuple(map(int, input().split()))


l = list(range(1,n+1))

p = itertools.permutations(l, n)
ans_a = 0
ans_b = 0
count = 0

for i in p:
    if i == a:
        ans_a = count
    if i == b:
        ans_b = count
    count += 1

print(abs(ans_b-ans_a))

Measured memory_bytes: 3064