akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main(){
  
  string S; cin >> S;
  int N = S.size();
  
  int mod[200001];
  mod[1] = 1;
  for(int i=2; i<=N; i++) mod[i] = (mod[i-1]*10) % 2019;
  
  int data[200001];
  data[0] = 0;
  for(int i=1; i<=N; i++) data[i] = (data[i-1] + ((int) S[N-i] - '0') * mod[i]) % 2019;
  
  int count[2019] = {};
  for(int i=0; i<=N; i++) count[data[i]]++;
  
  int ans = 0;
  for(int x: count) ans += (x*(x-1)) / 2;
  
  cout << ans << endl;
  
}

Measured memory_bytes: 5276
#include<stdio.h>
#include<string.h>
/*
a-z=97-122
A-Z=65-90

A=a-32
*/

int main(void){
	char a[1000];
	int i;
	
	for(i=0;i<1000;i++)a[i]=NULL;
	
	for(i=0;;i++){
		scanf("%c",&a[i]);
		if(a[i]=='\n')break;
	}
	
	for(i=0;i<(int)strlen(a);i++){
		if(a[i]>96 && a[i]<123)a[i]-=32;
	}
	
	for(i=0;i<(int)strlen(a);i++)printf("%c",a[i]);
	
	
	return 0;
}

Measured memory_bytes: 0
n,y = map(int,input().split())
a = y//10000
for i in range(n+1):
  for j in range(max(a+1,1)):
    cnt = 10000*j+5000*i+1000*(n-j-i)
    if (cnt == y) and (n-j-i >= 0):
      print(j,i,n-j-i)
      exit()  
print('-1 -1 -1')

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

void solve() 
{
    int a,b;
    cin>>a>>b;
    int amin=ceil(a*12.5);
    int amax=ceil(++a*12.5-1);
    int bmin=b*10;
    int bmax=++b*10-1;
    if(amax<bmin||bmax<amin)cout<<-1<<endl;
    else cout<<max(amin,bmin)<<endl;
}

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    string n;
    cin>>n;
    if(n[0]=='7'||n[1]=='7'||n[2]=='7') cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	vector<char> s;
	for (int i = 0;i <9;i++){
		char l;
		cin >> l;
		s.pb(l);
	}
	cout << s[0] << s[4] << s[8] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1LL << 60;

int N;

long long h[100010];
long long dp[100010];

int main(){
  int N, K; cin >> N >> K;
  rep(i, N) cin >> h[i];

  rep(i, N) dp[i] = INF;

  dp[0] = 0;
  rep(i, N){
    rep(j, K) if(i-j-1 >= 0){
      chmin(dp[i], dp[i-j-1] + abs(h[i] - h[i-j-1]));
    }
  }

  cout << dp[N-1] << endl;

  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
    
#define IOS cin.sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define rep(i, n) for (int i = 0; i < n; i++)
#define repn(i, a, b) for (int i = a;i<=b;i++)
#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define mem(x) memset(x, 0, sizeof(x))
#define ritr(it, a) for (auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define pai pair < int, int> 
#define pal pair < ll, ll> 
#define vi vector <int> 
#define vl vector < ll > 
#define vpai vector < pii > 

const int mod = 1e9+7;
const int INF = INT_MAX;
const int sze = 3005;

void solve() {
    int n;
    cin>>n;
    int z=(int )ceil(n*1.0/1000);
    cout<<(z*1000-n)<<endl;
}

int main() {
    IOS;

    int t = 1;
    // cin >> t;
    while (t--) {
       solve();
    }

  return 0;
}

Measured memory_bytes: 3660
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <deque>
using namespace std;

#define next '\n'
#define sp " "
#define print(x) cout << (x)
#define println(x) cout << (x) << next
#define stop return(0)
#define rep(i, n) for(int (i) = (0); (i) < (n); (++i))
#define FOR(i, start, end) for(int (i) = (start); (i) < (end); (++i))
#define foreach(e, elem) for(auto& (e) : (elem))
#define FAST ios::sync_with_stdio(false); cin.tie(nullptr)
#define size(s) (s).size()
#define all(vec) (vec).begin(), (vec).end()
#define pb(e) push_back(e);
using ll = long long;
using ull = unsigned long long;

int main(){
    int n;
    cin >> n;
    int cnt = 0, maxh = 0;
    rep(i, n){
        int h;
        cin >> h;
        if(h >= maxh){
            cnt++;
            maxh = h;
        }
    }
    println(cnt);
}

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

using namespace std;

#define DIM 100007
#define DIMM 2007
#define INF 10000000000007.0
#define X 2000000007
#define epc 0.0000001
#define PI 3.14159265358979323846
#define MAX 25
#define MODULO 10009
const long double gr=(1+sqrt(5))/2;

typedef int I;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef pair<I,I> pII;
typedef pair<ll,ll> pllll;
typedef pair<ld,ld> pldld;
typedef pair<ll,pllll> pllpllll;

typedef vector<I> vI;
typedef vector<ll> vll;
typedef vector<pllll> vpllll;

typedef char cr;
typedef string str;

ll n,m;
ll res;
pllll a[DIM];

int main()
{
    //freopen("events.in", "r", stdin);
    //freopen("events.out", "w", stdout);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    //cout<<"ops"<<endl;

    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    //ll x1,y1,xs,ys,x2,y2,x3,x4,y3,y4;

    cin>>n>>m;
    for(int i=1;i<=n;i++)cin>>a[i].first>>a[i].second;
    sort(a+1,a+1+n);
    for(int i=1;i<=n;i++){
     if(a[i].second<=m){
      res+=(a[i].first*a[i].second);
      m-=a[i].second;
     }
     else{
      res+=(a[i].first*m);
      m=0;
     }
     if(m==0)break;
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
	static int pos=0;
	static int cnt=0;
	static int[] post,pre,in;
	public static void main(String[] args) {
		// TODO Auto-generated method stub

		Scanner scan=new Scanner(System.in);
		int n=scan.nextInt();
		
		pre=new int[n];
		in=new int[n];
		post=new int[n];
		for(int i=0;i<n;i++)
			pre[i]=scan.nextInt();
		for(int i=0;i<n;i++)
			in[i]=scan.nextInt();
		rec(0,n);
		
		for(int i=0;i<n-1;i++){
			System.out.print(post[i]+" ");
		}
		System.out.println(post[n-1]);
	}

	private static void rec(int l, int r) {
		// TODO Auto-generated method stub
		if(l>=r)
			return;
		int c=pre[pos++];
		int m=0;
	    
	    
		while(c!=in[m]){
				m++;
		}
		rec(l, m);
		rec(m+1, r);
		post[cnt++]=c;
	}
}



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

int main(void){
  int N;
  cin>>N;
  vector<int>P(N);
  vector<int>Q(N);
  for(int i=0;i<N;i++){
    cin>>P[i];
  }
  for(int i=0;i<N;i++){
    cin>>Q[i];
  }
  int a=1,b=1;
  vector<int> number(N);
  for(int i=0;i<N;i++){
    number[i]=i+1;
  }
  do{
    int count1=0;
    for(int i=0;i<N;i++){
      if(number[i]==P[i]) count1++;
    }
    if(count1==N) break;
    a++;
  }while(next_permutation(number.begin(),number.end()));

  for(int i=0;i<N;i++){
    number[i]=i+1;
  }
  do{
    int count2=0;
    for(int i=0;i<N;i++){
      if(number[i]==Q[i]) count2++;
    }
    if(count2==N) break;
    b++;
  }while(next_permutation(number.begin(),number.end()));
  cout<<abs(a-b)<<endl;
  return 0;
}


Measured memory_bytes: 256
import std.stdio;

struct Point {
    int t, x, y;
}

auto iabs(T)(T i) {
    return i >= 0 ? i : -i;
}

bool findPath(Point prev, Point next) {
    auto td = next.t - prev.t;
    auto xd = iabs(next.x - prev.x);
    auto yd = iabs(next.y - prev.y);
    if (td < xd + yd) return false;
    else return (xd + yd - td) % 2 == 0;
}

void main() {
    size_t n;
    readf("%d\n", &n);
    auto prev = Point(0, 0, 0);
    foreach (i; 0..n) {
        Point next;
        with (next) {
            readf("%d %d %d\n", &t, &x, &y);
        }
        if (!findPath(prev, next)) {
            writeln("No");
            return;
        }
        prev = next;
    }
    writeln("Yes");
}


Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <queue>
#include <map>
#include <vector>
#include <cstdio>
#include <string>
#include <climits>
#include <cmath>
#include <cstring>
#include <iomanip>

using namespace std;

long long int gcd(long long int n, long long int m){
    if(m == 0)return n;
    return gcd(m, n%m);
}

int main(){
    int n;
    cin>>n;
    long long int ans, x;
    for(int i = 1; i <= n; i++){
        cin>>x;
        if(i == 1){
            ans = x;
            continue;
        }
        long long int tmp = gcd(ans, x);
        ans /= tmp;
        ans *= x;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Boolean flg = true;
		String text = sc.next();
		String[] texts = text.split("");
		
		for(int i=0; i<texts.length; i++) {
			if((texts[i].equals("U")) || (texts[i].equals("D"))) {
				continue;
			}
			if(i%2==0) {
				if(!texts[i].equals("R")) {
					flg = false;
					break;
				}
			}else if(i%2==1) {
				if(!texts[i].equals("L")) {
					flg = false;
					break;
				}
			}
		}
		
		if(flg) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 22736
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;
// << fixed << setprecision(0) <<
// sort(ALL(),greater<int>());

int main() {
int n;
cin >> n;
vector<int> l(n);
REP(i,n) {
  cin >> l[i];
}
sort(ALL(l));
int temp;
int ans=0;
for(int i=n-1;i>=0;i--) {
  for(int j=i-1;j>=0;j--) {
    auto iter = upper_bound(ALL(l),l[i]-l[j]);
    temp = l.end() - iter - (n - j);
    if(temp>0) ans+=temp;
  }
}
cout << ans << endl;
return 0;
}


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

cnt = [0] * (n+1)
for v in a:
    cnt[v] += 1

tmp = 0
for c in cnt:
    tmp += c * (c-1) // 2
for v in a:
    print(tmp - cnt[v] + 1)

Measured memory_bytes: 81740
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>
#include<limits>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long int ll;

//define
#define INF 1e9 
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main(){
  int n;
  cin>>n;
  ll sum=0;
  rep(i,n+1){
    if(i%15!=0 && i%5!=0 && i%3!=0){
      sum+=i;
    }
  } 
  cout<<sum<<endl;
}

Measured memory_bytes: 3644
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;

procedure Solve is
   A : Integer;
   B : Integer;
   C : Integer;
   D : Integer;
begin
   Get (A);
   Get (B);
   Get (C);
   Get (D);
   if A+B > C+D then
      Put_Line ("Left");
   elsif A+B = C+D then
      Put_Line ("Balanced");
   else
      Put_Line ("Right");
   end if;
end Solve;

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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define _dec(i,N,j) for(int i = (N-1);i >= (j);i--)
#define _rec(i,N,j) for(int i = (N);i >=(j);i--)
#define ALL(x) x.begin(),x.end()
#define MEM(a,n) memset(a,n,sizeof(a))
#define fst first
#define scd second
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

int get_int(){int x;scanf("%d",&x);return x;}
LL get_ll(){LL x;scanf("%lld",&x);return x;}
double get_db(){double x;scanf("%lf",&x);return x;}

template<typename T> int chmin(T &a,T b){if(a > b){a = b;return 1;}else return 0;}
template<typename T> int chmax(T &a,T b){if(a < b){a = b;return 1;}else return 0;}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {_for(i,0,v.size()) os << v[i] << " ";return os;}
template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){for(auto a:v) os << a <<" ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& v){os << v.fst <<" "<<v.scd << " ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const map<T1,T2>& v){for(auto a:v) cout << a << endl;return os;}

static const int dx[8] = { -1,  0, 1, 0,  1, -1,  1, -1};
static const int dy[8] = {0,  1, 0,  -1,  1, -1, -1,  1};
const double pi  = acos(-1.0);
const double eps = 1e-8;
//const LL  INF  = 0x3f3f3f3f3f3f3f3f;
const int inf  = 0x3f3f3f3f;

int N;
int ok = 0;

int main()
{
    int cnt = 0;
    int a = -1,b = -1;
    cin >> N;
    _for(i,0,N){
        int A,B;
        cin >> A >> B;
        if(A == B){
            cnt++;
            if(cnt >= 3) ok = 1;
        }
        else{
            cnt = 0;
        }
    }
    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3592
char_list = list(input())
count1 = 0
count2 = 0
if len(char_list) == 1:
    print(0)
else:
    for i in range(len(char_list)):
        if i % 2 == 0:
            if char_list[i] is "0":
                continue
            else:
                count1 += 1
        else:
            if char_list[i] is "1":
                continue
            else:
                count1 += 1
    for i in range(len(char_list)):
        if i % 2 == 0:
            if char_list[i] is "1":
                continue
            else:
                count2 += 1
        else:
            if char_list[i] is "0":
                continue
            else:
                count2 += 1
    print(min(count1,count2))

Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
int main(){
    vector<string> week = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
    string day;
    cin >> day;
    
    for(int i=0; i<7; i++){
        if (week[i] == day) {
            cout << 7-i << endl;
        }
    } 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int MOD=1e9+7;
int n,x[3], dp[40][1<<16];
void printbin(int n, int b = 31) {
	for(int i=b-1; i>=0; i--) printf("%d", n>>i&1);
}
int Count(int p, int b) {
	if(p==n) return 1;
	int& res=dp[p][b];
	if(res!=-1) return res;
	res=0;
	int i,t=b,c=0,f=0;
	bool chk[11]={0};
	while(t>0) t>>=1,c++;
	for(i=0;i<c;i++) {
		if(i&&(~b>>(i-1)&1)) continue;
		if(~b>>(i+x[0]-1)&1) continue;
		if(~b>>(i+x[0]+x[1]-1)&1) continue;
		t=i+x[0]+x[1]+x[2]-c;
		if(t>=1&&t<=10)
			chk[t]=1;
	}
	t=b;
	for(int i=1;i<=10;i++) {
		if(chk[i]) continue;
		while(c+i>16) {
			while(t>0&&!(t&1))t>>=1,c--;
			t>>=1,c--;
		}
		res=(res+Count(p+1,t|(1<<(c+i-1))))%MOD;
	}
	//printf("dp[%d][%d]:%d\n",p,b,res);
	//printf("dp[%d][",p); printbin(b,16); printf("]:%d\n",res);
	return res;
}
int main() {
	memset(dp,-1,sizeof(dp));
	scanf("%d%d%d%d",&n,x,x+1,x+2);
	int p=1;
	for(int i=1;i<=n;i++) p=10ll*p%MOD;
	printf("%d", (p-Count(0,0)+MOD)%MOD);
	return 0;
}

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

int main() {
	long long N;
	cin>>N;
	int r = N%11;
	long long count = N/11*2;
	if (r==0){
		cout << count << endl;
	}
	else if (r<=6){
		cout << count+1 << endl;
	}
	else{
		cout << count+2 << endl;
	}
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

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

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

fn nth_bit(n: i64, bit: usize) -> i64 {
    (n >> bit) & 1
}

const MOD: i64 = 1000000000 + 7;

fn solve(n: i64) -> i64 {
    let digit = (n as f64).log2() as usize + 1;
    let mut dp = vec![vec![0; 3]; digit];
    dp[digit - 1][2] = 0;
    dp[digit - 1][1] = 1;
    dp[digit - 1][0] = 1;
    for i in (0..digit-1).rev() {
        let x = nth_bit(n, i);
            for j in 0..3 {
                for k in 0..3 {
                    let nj = j * 2 + x - k;
                    let i = i as usize;
                    let j = j as usize;
                    if nj >= 2 {
                        dp[i][2] = dp[i][2] % MOD + dp[i+1][j] % MOD;
                    } else if nj >= 0 {
                        dp[i][nj as usize] = dp[i][nj as usize] % MOD +  dp[i+1][j] % MOD;
                    }
                }
            }
    }

    (dp[0][0] % MOD + dp[0][1] % MOD + dp[0][2] % MOD) % MOD
}

fn main() {
    input! {
        n: i64,
    }
    println!("{}", solve(n));
}



Measured memory_bytes: 4476
from statistics import mean, median,variance,stdev
import sys
import math
import fractions
def j(a):
    if a==1: print("Yes")
    else :print("No")


def ct(x,y):
    if (x>y):print("")
    elif (x<y): print("")
    else: print("")

def ip():
    return int(input())

x = ip()                              #入力整数1つ
#x,y = (int(i) for i in input().split())      #入力整数横2つ
#x,y,z = (int(i) for i in input().split())    #入力整数横3つ
#a,b,c,k = (int(i) for i in input().split())  #入力整数横4つ
#a = [int(i) for i in input().split()]        #入力整数配列
a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
l = []
for i in range(len(a)):
    l.append(a[i])
x = l
max = 0
for i in range(1,len(x)):
    c = x[:i]
    d = x[i:]
    c.sort()
    d.sort()
    c = set(c)
    d = set(d)
    num = len(c & d)
    if num > max: max = num
print(max)

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

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 1; i < N; ++i) {
        int a;
        cin >> a;
        A[a-1]++;
    } // end i
    for (auto &&a : A) {
        cout << a << '\n';
    } // end a
}


Measured memory_bytes: 4036
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.
// insert #if<tab> by my emacs. #if DEBUG == 1 ... #end

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

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


Measured memory_bytes: 256
import java.util.*;
import static java.lang.Math.*;
public class Main {
	final Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		new Main().init();
	}
	void init(){
		new AOJ1142();
	}
	
	class AOJ1142{
		AOJ1142(){
			int n=sc.nextInt();
			while(--n>=0)	solve();
		}
		void solve(){
			StringBuilder line=new StringBuilder(sc.next());
			HashSet<String> set=new HashSet<String>();
			set.add(line.toString());
			for(int i=1; i<=line.length(); ++i){
				String s1=line.substring(0, i),
						s2=line.substring(i, line.length());
				String s1r=new StringBuilder(s1).reverse().toString(),
						s2r=new StringBuilder(s2).reverse().toString();
				set.add(s1+s2r);
				set.add(s1r+s2);
				set.add(s1r+s2r);
				set.add(s2+s1);
				set.add(s2+s1r);
				set.add(s2r+s1);
				set.add(s2r+s1r);
			}
//			System.out.println(set);
			System.out.println(set.size());
		}
	}
	
	class AOJ1144{
		AOJ1144(){
			while(sc.hasNext()){
				w=sc.nextInt();
				h=sc.nextInt();
				if((w|h)==0)	break;
				solve(w,h);
			}
		}
		final int INF=Integer.MAX_VALUE/4;
		final int[] vx={0,1,0,-1},vy={-1,0,1,0};
		int w,h;
		int sx,sy,ex,ey;
		void solve(int w,int h){
			boolean[][] b=new boolean[w][h];
			sx=0;	sy=0;	ex=0;	ey=0;
			for(int y=0; y<h; ++y)for(int x=0; x<w; ++x){
				int tmp=sc.nextInt();
				b[x][y]=(tmp!=1);
				if(tmp==2){
					sx=x;	sy=y;
				}else if(tmp==3){
					ex=x;	ey=y;
				}
			}
			
			int ans=-1;
			for(int cnt=0; cnt<=10; ++cnt){
				boolean[][] bc=new boolean[w][h];
				for(int x=0; x<w; ++x)for(int y=0; y<h; ++y)	bc[x][y]=b[x][y];
				int ret=DFS(sx,sy,0,cnt,bc);
				if(ret<INF){
					ans=ret;
					break;
				}
			}
			System.out.println(ans);
		}
		int DFS(int x,int y,int depth,int limit,boolean[][] b){
//			System.out.println(x+" "+y+" "+depth+" "+limit);
			if(depth>=limit)	return INF;
			if(x==ex&&y==ey)	return depth;
			
			int ret=INF;
			for(int v=0; v<4; ++v){
				int xx=x+vx[v],yy=y+vy[v];
				if(!(0<=xx&&xx<w && 0<=yy&&yy<h))	continue;
				if(!b[xx][yy])	continue;
				if(xx==ex&&yy==ey){
					ret=min(ret,depth+1);
					continue;
				}
				while(true){
					xx+=vx[v];
					yy+=vy[v];
					if(!(0<=xx&&xx<w && 0<=yy&&yy<h))	break;
					if(xx==ex&&yy==ey){
						ret=min(ret,depth+1);
						break;
					}
					if(!b[xx][yy]){
						xx-=vx[v];
						yy-=vy[v];
						b[xx+vx[v]][yy+vy[v]]=true;
						ret=min(ret, DFS(xx,yy,depth+1,limit,b));
						b[xx+vx[v]][yy+vy[v]]=false;
						break;
					}
				}
			}
			return ret;
			
		}
	}

}

Measured memory_bytes: 54600
#include <bits/stdc++.h>
#define ll int
#define ld long double
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define all(x) x.begin(),x.end()
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
using namespace std;
 



int main()
{
    fastio
    ll i,j;
    
    ll n,x;
    cin>>x>>n;
    
    ll a[n];
    set<ll>s;
    ll mn=10000;
    ll res=-1;
    
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        s.insert(a[i]);
        //cout<<a[i]<<" ";
    }
    
    for(i=-1;i<=101;i++)
    {
        if(s.find(i)!=s.end())
        continue;
        //cout<<i<<" ";
        
        if(abs(x-res)>abs(i-x))
        {
            res=i;
        }
    }
    
    
    cout<<res;
    
    
}


Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
int read(){
	int w=0,f=1;
	char c=' ';
	while(c<'0'||c>'9')c=getchar(),f=c=='-'?-1:f;
	while(c>='0'&&c<='9')w=w*10+c-48,c=getchar();
	return w*f;
}
signed main(){
	int n=read();
	cout<<(!n)<<endl;
	return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <cassert>
#include <memory>
#include <stack>
#include <set>
#include <map>

#define MAX_SIZE 100000000
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

int main() {
  int n; cin >> n;
  int sum = 0;
  for(int i = 0; i < n; i++) {
    int left,right; cin >> left >> right;
    for(; left <= right; left++) {
      sum++;
    }
  }

  cout << sum << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\b.txt"
 


int main() {
	int N, K; cin >> N >> K;
	vector<int>oks(10,1);
	for (int i = 0; i < K; ++i) {
		int a; cin >> a; oks[a] = false;
	}
	int ans = 0;
	for (int t = N;; ++t) {
		string st = to_string(t);
		bool ok = true;
		for (int i = 0; i < st.size(); ++i) {
			if (!oks[st[i] - '0']) {
				ok = false;
			}
		}
		if (ok) {
			ans = t;
			break;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 764
#include<stdio.h>

int main() {
	int i;
	char a[1200];

	scanf("%[^\r\n]", a);

	i = 0;
	while(a[i]!='\0'){
		if ('A' <= a[i] && a[i] <= 'Z') {
			a[i] = a[i] + ('a' - 'A');
		}
		else if ('a' <= a[i] && a[i] <= 'z') {
			a[i] = a[i] + ('A' - 'a');
		}
		i++;
	}
	printf("%s\n", a);
	return 0;
}


Measured memory_bytes: 2036
#include<bits/stdc++.h>
using namespace std;
int main()
{
    
    
    int n,k; cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++) cin>>a[i];
    
    int dp[n];
    for(int i=0;i<n;i++) dp[i]=INT_MAX;
    dp[0]=0;
 
    for(int i=1;i<n;i++)
    {
        for(int j=1;j<=k;j++){
            
            if((i-j)<0) break;
        dp[i]=min(dp[i-j]+abs(a[i]-a[i-j]),dp[i]);
        
        }
    }
    cout<<dp[n-1];
    
}

Measured memory_bytes: 1024
N = int(input())
A = list(map(int, input().split()))
bool = True

for i in range(N):
    if A[i]%2 == 0:
        if not (A[i]%3 == 0 or A[i]%5 == 0):
            bool = False
            break

if bool == True:
    print('APPROVED')
else:
    print('DENIED')


Measured memory_bytes: 2940
import fractions
n,x=map(int,input().split())

l=list(map(int,input().split()))
l.append(x)
l=sorted(l)
ll=[]
for j in range(1,len(l)):
    ll.append(l[j]-l[j-1])
a=ll[0]
ans=0
if len(ll)==1:
    print(ll[0])
    exit()
else:
    for i in range(1,len(ll)):
        ans=fractions.gcd(a,ll[i])
        a=ans
print(ans)


Measured memory_bytes: 16240
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
 
using lint=long long;
using pint=pair<int,int>;
template<class T> using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

int main()
{
   string s,t; cin>>s>>t;
   int a,b; cin>>a>>b;
   string u; cin>>u;
   (u==s? a:b)--;
   cout<<a<<' '<<b<<endl;
   return 0;
}



Measured memory_bytes: 256
n, x, y = map(int, input().split())
ans = [0] * n
for i in range(1, n + 1):
  for j in range(i + 1, n + 1):
    d = min(j - i, abs(i - x) + abs(j - y) + 1)
    ans[d] += 1
    
for i in range(1, n):
    print(ans[i])


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

using namespace std;

using int64 = long long;
//const int mod = (int) (1e9 + 7);
const int mod = 998244353;

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

int main() {
  char a;
  cin >> a;
  if(islower(a)) cout << 'a' << "\n";
  else cout << 'A' << "\n";
}








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

int main() {
  int N, i, j;
  cin >> N;
  string S, T, U;
  cin >> S >> T;
  U = S + T;
  
  
  i = 0;
  j = 0;
  	while(i < N){
      U.at(j) = S.at(i);
      U.at(j + 1) = T.at(i);
      
      i++;
      j += 2;
    }
  cout << U << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e5;
int n,tot_w;
int w[105],val[105];
int cache[105][N];


int dp(int idx,int price)
{
    if(price==0)
    return 0;
    if(idx==n)
    return 1e9+7;
    if(price<0)
    return 1e9+7;
    int &ans=cache[idx][price];
    if(ans!=-1)
    return ans;
    ans=min(dp(idx+1,price),w[idx]+dp(idx+1,price-val[idx]));
    return ans;
}

int main()
{
    cin>>n>>tot_w;
    memset(cache,-1,sizeof(cache));
    for(int i=0;i<n;++i)
        cin>>w[i]>>val[i];
    int ans=0;
    for(int i=1;i<=N;i++)
    {
        int min_wt=dp(0,i);
        if(min_wt<=tot_w)
        ans=i;
    }
    cout<<ans;
}

Measured memory_bytes: 41344
#include <iostream>
int main(void)
{
  int h, m, s;
  std::cin >> s;
  h = s / 3600;
  m = s / 60 % 60;
  s -= h * 3600 + m * 60;
  std::cout << h << ":" << m << ":" << s << std::endl;
}

Measured memory_bytes: 1168
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<string>
#include<sstream>
#include<cmath>
#include<climits>
#include<algorithm>
#include<bitset>
#include<set>
#include<stack>
#include<queue>
#include<iomanip>
#include<memory.h>
#include<complex>
#include<unordered_map>
using namespace std;  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef tuple<int,int> tii;
#define rep(i,n) for(int i=0;i<(n);i++)  
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second  
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
const double PI = M_PI;  
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define SHOWARRAY(ar,i,j) REP(a,i)REP(b,j)cerr<<ar[a][b]<<((b==j-1)?((a==i-1)?("\n\n"):("\n")):(" "))
#define DIV int(1e9+7)
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}
/* Coding Space*/ 
ll c[10][10];
typedef tuple<ll,ll> tll;
int main(){
  ll n,k; cin >> n >> k;
  vector<tll> mask;
  ll t = 1;
  mask.pb(tll{k,0});
  while(t <= k){
    if((t|k) == k)
      mask.pb(tll{(t^k)|(t-1),0});
    t *= 2;
  }
  ll ans = 0;
  rep(i,n){
    ll a,b; cin >> a >> b;
    rep(j,(int)mask.size()){
      ll maskk,value; tie(maskk,value) = mask[j];
      if((maskk | a) == maskk){
        value += b;
        mask[j] = tll{maskk,value};
        ans = max(ans,value);
      }
    }
  }
  cout <<ans << endl;
}

Measured memory_bytes: 384
#include<stdio.h>
bool f[3];
int t[5];
int i,j;
int w,l;

int main(){
	while(1){
		for(i=0;i<3;i++)f[i]=false;
		for(i=0;i<5;i++){
			scanf("%d",&t[i]);
			if(t[i]==0)return 0;
		}
		for(i=0;i<5;i++)f[t[i]-1]=true;
		if(f[0]&&f[1]&&f[2]){w=-1;l=-1;}
		else if(f[0]&&f[1]){w=1;l=2;}
		else if(f[0]&&f[2]){w=3;l=1;}
		else if(f[1]&&f[2]){w=2;l=3;}
		else{w=-1;l=-1;}
		for(i=0;i<5;i++){
			if(t[i]==w)printf("1\n");
			else if(t[i]==l)printf("2\n");
			else printf("3\n");
		}
	}
}

Measured memory_bytes: 1012
#define ONSPEED ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define f(i,x,n) for(i=x;i<n;i++)
#define rf(i,x,n) for(i=n;i>x;i--)
#define ll long long
#define GCD(a,b) __gcd(a,b)
#define adios return 0;

/*
SHERAJUL ARIFIN
Dept. of CSE,
IUT.
*/


#include <bits/stdc++.h>
using namespace std;

int main()
{
    ONSPEED;
    ll t,n,a,b,c,d,s=0,i,j,flag;
    string x,y;
    cin>>n;
    ll arr[n+5];
    ll ans[n+5]={0};
    for(i=2;i<=n;i++)
    {
        cin>>arr[i];
    }
    for(i=2;i<=n;i++)
    {
        ans[arr[i]]++;
    }
    for(i=1;i<=n;i++)
    {
        cout<<ans[i]<<endl;
    }



    adios;
}


Measured memory_bytes: 6680
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/








int A, B;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> A >> B;

	int ans = 0;
	if (A == B) ans = A + B;
	else ans = 2 * max(A, B) - 1;
	cout << ans << endl;
}


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

int main() {
    int N;
    cin >> N;
    
    vector<string> S(N);
    for (int i = 0; i < N; i++) {
        cin >> S[i];
    }

    for (int i = 'a'; i <= 'z'; i++) {
        int cnt = 50;
        for (int j = 0; j < N; j++) {
            int res = 0;
            for (int k = 0; k < S[j].size(); k++) {
                if (S[j][k] == i) {
                    res++;
                }
            }
            cnt = min(cnt, res);
        }
        std::cout << string(cnt, i);
    }

    std::cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  int x = c-a;
  int y = d-b;
  cout << c-y << " " << d+x << " " << a-y << " " << b+x << endl;
  return 0;
}


Measured memory_bytes: 256
line = readlines
len = line.length
i = 0

while i < len
    line[i] = line[i].chomp
    i += 1
end

N = line[0].to_i
votes = []
for i in 1..N do
  votes.push(line[i])
end

votes = votes.sort
univotes = votes.uniq

max = 0
place = 0
max_votes = []
univotes.each do |i|
  count = 0
  while votes[place] == i and place < N do
    count += 1
    place += 1
  end
  if count == max then
    max_votes.push(i)
  elsif count > max then
    max = count
    max_votes = []
    max_votes.push(i)
  end
end

for i in 1..max_votes.length do
  puts max_votes[i-1]
end


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repab(i, a, b) for (int i = a; i <= (int)(b); i++)
#define ll long long
#define vec vector
#define pb push_back
#define ft first
#define sd second
#define all(vec) vec.begin(), vec.end()
#define endl "\n"

typedef pair<int, int> P;

const int MOD = 1e9 + 7;
const int INF = 1001001001;
const int dx[4] = {1, 0,-1, 0};
const int dy[4] = {0, 1, 0,-1};

//--//--//--//--//--//--//--//--//--//--//--//



int main(){

	//input//
	int s;
	cin >> s;

	vector<int> dp(s+1);
	dp[0] = 1;
	int x = 0;
	repab(i, 1, s){
		if((i-3)>=0){
			x += dp[i-3];
			x %= MOD;
		}
		dp[i] = x;
	}
	cout << dp[s] << endl;

	return 0;
}

Measured memory_bytes: 3564
def main(N):
    A = list(map(int, input().split()))
    st_A = set(A)
    if 0 in st_A:
        print(0)
    else:
        x = 1
        for a in A:
            x *= a
            if x > 10 ** 18:
                print(-1)
                exit()
        else:
            print(x)





if __name__ == '__main__':
    N = int(input())
    main(N)

Measured memory_bytes: 21604
#include<iostream>
#include<iomanip>
#include<cassert>
#include<stdexcept>
#include<utility>
#include<functional>
#include<numeric>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<array>
#include<stack>
#include<queue>
#include<deque>
#include<vector>
#include<complex>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<bitset>
#include<memory>
using namespace std;
using ll=long long;

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

    ll sum=accumulate(a.begin(),a.end(),0LL);
    ll tmp=a[0];
    ll res=1e17;
    for(int i=1;i<n;i++){
        res=min(res,abs(sum-2*tmp));
        tmp+=a[i];
    }
    
    cout<<res<<endl;
    return 0;
}


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

using namespace std;

using ll = long long;

int main () {
	ll L, R, ans = 99999, c, s, g;
	cin >> L >> R;
	if (R - L >= 2018) {
		s = 0;
		g = 2018;
	} else {
		s = L;
		g = R;
	}
	// cout << s << " " << g << endl;
	for (ll i = s; i < g; i++) {
		for (ll j = i + 1; j <= g; j++) {
			// cout << i << " " << j << endl;
			c = (i * j) % 2019;
			if (c < ans) {
				ans = c;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
As = list(map(int, input().split()))

if 0 in As:
    print(0)
    exit(0)

EL = 1
for i in range(N):
    EL = EL * As[i]
    if EL > 1e+18:
        print(-1)
        exit(0)
print(EL)


Measured memory_bytes: 21652
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=nxt();
    if(n%10==3)
      cout<<"bon\n";
    else if(n%10==0||n%10==1||n%10==6||n%10==8)\
      cout<<"pon\n";
    else
      cout<<"hon\n";
    
    
    
    return 0;   
}




 
 


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int b=0,h,N,A=1;
  cin>>N;
  vector<int> a(N);
  for(int i=0;i<N;i++){cin>>a.at(i);}
  for(int i=1;i<N;i++){
    if(b==1){
      if(h<=a.at(i)){A++;b=0;}
    }
    else {if(a.at(i-1)<=a.at(i)){A++;}
    else{
      h=a.at(i-1);
      b=1;
    }}
  }
  cout<<A<<endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Sat Feb  9 13:24:45 2019

@author: Yamazaki Kenichi
"""

N,K = map(int,input().split())
A = list(map(int,input().split()))
a = ['{:040b}'.format(i) for i in A]
k = '{:040b}'.format(K)
res = 0
flg = False
for i in range(40):
    counta = 0
    for elem in a:
        if elem[i] == '1':
            counta += 1
    check = True if counta<N/2 else False
    if flg:
        if check:
            res += pow(2,39-i)
        continue
    if check and k[i]=='1':
        res += pow(2,39-i)
    else:
        if k[i]=='1':
            flg = True
ans =0
for elem in A:
    ans += elem^res
print(ans)


Measured memory_bytes: 19272
import itertools

S = input()
S_list = list(S)
keta = len(S)

plus=list(itertools.product([0,1], repeat = keta-1))

All = 0
for posi in plus:
    preserved = [S_list[0]]
    for k in range(len(posi)):
        if posi[k] == 1:
            preserved.append(S_list[k+1])
        else:
            All += int("".join(str(n) for n in preserved))
            preserved = [S_list[k+1]]
    All += int("".join(str(n) for n in preserved))

print(All)

Measured memory_bytes: 42460
/**
*    author:  souzai32
*    created: 01.08.2020 23:54:56
**/

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

int main() {

    string s;
    long long int k;
    cin >> s >> k;
    long long int n=s.size();
    bool all=true;
    long long int a=0,b=0;
    long long int p=0;

    rep(i,n-1) if(s.at(i)!=s.at(i+1)) all=false;

    if(!all){
        if(s.at(0)==s.at(n-1)){
            while(1){
                a++;
                if(s.at(0)!=s.at(a)) break;
            }
            while(1){
                b++;
                if(s.at(n-1)!=s.at(n-1-b)) break;
            }
        }

        rep(i,n-1){
            if(s.at(i)==s.at(i+1)){
                s.at(i+1)=' ';
                p++;
            }
        }
    }
    
    long long ans;
    if(all) ans=n*k/2;
    else ans=p+(k-1)*(p-a/2-b/2+(a+b)/2);

    cout << ans << endl;
    //cout << a << ' ' << b << ' ' << p << endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }
 
using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;
 
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};
 
const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod


#include <bits/stdc++.h>
using namespace std;
signed main(){
    int N; cin>>N;
    int sum = 0;
    vec A(N); 
    REP(i,N){
        cin>>A[i];
        sum += A[i];
    }
    int ans = sum, X = 0;
    FOR(i,0,N){
        X += A[i];
        ans = min(ans,abs(X-(sum-X)));
    }
    Out(ans);
}

Measured memory_bytes: 1792