akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <utility>
#include <numeric>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <limits>
#include <cassert>
#include <bitset>

#define for0(i, N)    for (int i = 0  ; i <  (N); ++i)
#define for1n(i, N)   for (int i = 1  ; i <= (N); ++i)
#define for1(i, N)    for (int i = 1  ; i <  (N); ++i)
#define forn(i, N)    for (int i = 0  ; i <= (N); ++i)
#define forx(i, N, x) for (int i = (x); i <  (N); ++i)
#define forl(i, N, x, a) for (int i = (x), a = 0; a < (N);  \
                              i = (i + 1) % (N), ++a)

template<size_t i>
std::bitset<i> operator++(std::bitset<i> b, int){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    return b = (unsigned long long)b + 1;
}

template<size_t i>
std::bitset<i> operator++(std::bitset<i> b){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    auto temp = b;
    b++;
    return temp;
}

template<size_t i>
std::bitset<i> operator--(std::bitset<i> b, int){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    return b = (unsigned long long)b - 1;
}

template<size_t i>
std::bitset<i> operator--(std::bitset<i> b){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    auto temp = b;
    b--;
    return temp;
}

using namespace std;

typedef long long ll;
typedef long double ld;
typedef priority_queue<ll> pq;
typedef priority_queue<ll,vector<ll>, greater<ll>> pql;
typedef stack<ll> stk;
typedef queue<ll> qu;
typedef pair<ll, ll> pll;
typedef map<ll, ll> mll;
typedef unordered_map<ll, ll> umll;
typedef set<ll> sll;
typedef unordered_set<ll> usll;


int main(void){
    cin.tie(0); ios::sync_with_stdio(false);
    int k, x;
    cin >> k >> x;
    cout << (500 * k >= x ? "Yes" : "No") << "\n";

    return 0;
}


Measured memory_bytes: 256
//{
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define FILL(i,n) memset(i,n,sizeof i)
#define X first
#define Y second
#define SZ(_a) (int)_a.size()
#define ALL(_a) _a.begin(),_a.end()
#define pb push_back
#ifdef brian
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // brian
//}


const ll MAXn=3e3+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=ll(1e15);

ll dp[MAXn][MAXn], p[MAXn][MAXn];


int main()
{
    IOS();
    string s,t;
    cin>>s>>t;
    ll n, m;
    n = SZ(s), m = SZ(t);
    s = " " + s;
    t = " " + t;
    REP1(i,n)REP1(j, m)
    {
        if(s[i] == t[j])
        {
            dp[i][j] = dp[i-1][j-1] + 1;
            p[i][j] = 0;
        }
        else if(dp[i-1][j] >= dp[i][j-1])
        {
            dp[i][j] = dp[i-1][j];
            p[i][j] = 1;
        }
        else
        {
            dp[i][j] = dp[i][j-1];
            p[i][j] = 2;
        }
    }
    string r = "";
    ll i = n, j = m;
    while(i && j)
    {
        if(p[i][j] == 0)r.pb(s[i]), i--, j--;
        else if(p[i][j] == 1)i--;
        else j--;
    }
    reverse(ALL(r));
    cout<<r<<endl;
}


Measured memory_bytes: 141312
#include <bitset>
#include <iostream>
#include <stdio.h>
#include <string>

#define MAX_S 10

using namespace std;

int main() {
  string S;
  cin >> S;
  int N = S.size();
  int64_t s = 0;
  for (int i = 0; i < (1 << (N - 1)); ++i) {
    bitset<MAX_S> b(i);
    string u;
    u += S[0];
    for (int j = 0; j < N - 1; ++j) {
      if (b.test(j)) {
        s += stoll(u);
        u = S[j + 1];
      } else {
        u += S[j + 1];
      }
    }
    s += stoll(u);
  }
  printf("%lld\n", s);
}

Measured memory_bytes: 3220
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define pii pair<int,int>
#define pll pair<ll,ll>
#define PB push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
using namespace std;
const int N=200005;
int mx1[N],mx2[N];
int fa[N],dfn[N],ed[N];
int n,ans[N],t[N],sub[N];
vector<int> vec1[N],vec2[N],e[N];
void change(int x,int y){
	for (;x<=n;x+=x&(-x)) t[x]+=y;
}
int ask(int x){
	int ans=0;
	for (;x;x-=x&(-x)) ans+=t[x];
	return ans;
}
void update(int x,int v){
	if (!x) return; 
	change(dfn[x],v);
	change(ed[x]+1,-v);
}
void dfs(int x){
	mx1[x]=mx1[fa[x]];
	mx2[x]=mx2[fa[x]];
	int tmp=x;
	if (tmp>mx1[x]) swap(mx1[x],tmp);
	if (tmp>mx2[x]) swap(mx2[x],tmp);
	if (x!=mx1[x])
		vec1[mx1[x]].PB(x);
	vec2[sub[mx1[x]]].PB(x);
	dfn[x]=++*dfn;
	for (auto i:e[x])
		if (i!=fa[x]){
			fa[i]=x;
			sub[x]=i;
			dfs(i);
		}
	ed[x]=*dfn;
	//printf("%d %d %d %d %d\n",x,mx1[x],mx2[x],dfn[x],ed[x]);
}
void getans(int x){
	for (auto i:vec1[x]){
		update(mx1[i],-1);
		update(mx2[i],1);
	}
	ans[x]=ask(dfn[x]);
	for (auto i:e[x]) if (i!=fa[x]){
		for (auto j:vec2[i]){
			update(mx2[j],-1);
			update(mx1[j],1);
		}
		getans(i);
		for (auto j:vec2[i]){
			update(mx2[j],1);
			update(mx1[j],-1);
		}
	}
	for (auto i:vec1[x]){
		update(mx1[i],1);
		update(mx2[i],-1);
	}
}
int main(){
	scanf("%d",&n);
	For(i,1,n-1){
		int x,y;
		scanf("%d%d",&x,&y);
		e[x].PB(y); e[y].PB(x);
	}
	dfs(1);
	For(i,2,n)
		update(mx1[i],1);
	getans(1);
	For(i,2,n)
		printf("%d ",ans[i]);
}

Measured memory_bytes: 45548
import java.util.*;

class Main {
        public static void main(String args[]) {
                try (Scanner sc = new Scanner(System.in)) {
                        int N = sc.nextInt();
                        double[] A = new double[N], B = new double[N];
                        for (int i = 0; i < N; i++) {
                                A[i] = sc.nextDouble();
                        }
                        for (int i = 0; i < N; i++) {
                                B[i] = sc.nextDouble();
                        }
                        double[] ans = new double[4];
                        for (int i = 0; i < N; i++) {
                                double num = Math.abs(A[i] - B[i]);
                                ans[0] += num;
                                ans[1] += num * num;
                                ans[2] += num * num * num;
                                ans[3] = Math.max(ans[3], num);
                        }
                        ans[1] = Math.sqrt(ans[1]);
                        ans[2] = Math.cbrt(ans[2]);
                        System.out.println(ans[0]);
                        System.out.println(ans[1]);
                        System.out.println(ans[2]);
                        System.out.println(ans[3]);
                }
        }
}

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

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, m;
  string s, t;
  cin >> n >> m >> s >> t;
  ll g = gcd(n, m);
  ll nn = n / g, mm = m / g;
  ll ans = m / g * n;
  for (ll i = 0; i < g; i++) {
    if (s[i * nn] != t[i * mm]) {
      ans = -1;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
//参考資料まんまの保存用
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main() {
	int h;
	cin >> h;
	int w;
	cin >> w;
	vector<string> a(h);
	for (int i = 0; i < h; i++) {
		cin >> a[i];
	}

	vector<bool> row(h, false);
	vector<bool> col(w, false);
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (a[i][j] == '#') {
				row[i] = true;
				col[j] = true;
			}
		}
	}

	for (int i = 0; i < h; i++) {
		if (row[i]) {
			for (int j = 0; j < w; j++) {
				if (col[j]) {
					cout << a[i][j];
				}
			}
			cout << endl;
		}
	}
}


Measured memory_bytes: 256
import sys
from itertools import combinations_with_replacement

input = sys.stdin.buffer.readline


def main():
    n_ints, max_int, n_queries = map(int, input().split())

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

    possible_sequences = combinations_with_replacement(range(1, max_int+1), n_ints)

    max_score = 0
    for sequence in possible_sequences:
        score = 0

        for i, q in enumerate(queries):
            a, b, c, d = q
            if sequence[b-1] - sequence[a-1] == c:
                score += d

        max_score = max(max_score, score)

    print(max_score)


if __name__ == "__main__":
    main()


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

int main() {
  int n; cin >> n;
  int64_t ans =0;
  for (int i = 0; i < n; i++) {
    int64_t a;
    cin >> a;
    --a;
    ans += a;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rel register ll
#define rec register char
#define gc getchar
//#define gc() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<23,stdin),p1==p2)?-1:*p1++)
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
char buf[1<<23],*p1=buf,*p2=buf;
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
template <typename mitsuha>
inline bool read(mitsuha &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return 0&pc(48);
  if (x<0) pc('-'),x=-x;
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  return 0;
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
const int yuzu=2e5;
typedef int fuko[yuzu|10];
fuko a,b,ta,tb,vis;
namespace dsu{
fuko fa;
void init(int n){for (int i=0;i<=n;++i) fa[i]=i;}
int find(int x){return x^fa[x]?fa[x]=find(fa[x]):x;}
int mg(int u,int v){
  int fu=find(u),fv=find(v);
  return fu^fv?fa[fu]=fv,1:0;
  }
}using dsu::find;

int main() {
int i,n=read();
for (i=1;i<=n;++i) *a^=a[i]=ta[i]=read();
for (i=1;i<=n;++i) *b^=b[i]=tb[i]=read();
*ta=*a,*tb=*b,sort(ta,ta+n+1),sort(tb,tb+n+1);
for (i=0;i<=n;++i) if (ta[i]^tb[i]) return write(-1);
int m=unique(ta,ta+n+1)-ta;
for (i=0;i<=n;++i) 
  a[i]=lower_bound(ta,ta+m,a[i])-ta,
  b[i]=lower_bound(ta,ta+m,b[i])-ta;
dsu::init(m);
int llx=0;
for (i=0;i<=n;++i) dsu::mg(a[i],b[i]),llx+=a[i]!=b[i]&&i;
for (i=0;i<m;++i) if (find(i)^i) vis[find(i)]=1;
for (i=0;i<m;++i) if (find(i)==i) llx+=vis[i]&&i!=find(*a);
write(llx);
}

Measured memory_bytes: 6656
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int h, w;
  cin >> h >> w;
  vector<char> G(w*h);
  for(int i=0; i<w*h; i++){
    cin >> G.at(i);
  }
  for(int i=0; i<w+2;i++){
    cout << '#';
  }
  cout << endl;
  
  int i=0;
  for(int j=0;j<h;j++){
    cout << '#';
  	for(i;i<w*(j+1);i++){
    	cout << G.at(i);
  	}
    cout << '#' << endl;
  }
  for(int i=0; i<w+2;i++){
    cout << '#';
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
import sys

def main():
  N = int(input())
  t, x, y = 0, 0, 0
  for i in range(N):
    next_t, next_x, next_y = [int(i) for i in input().split()]
    distance = abs(next_x-x)+abs(next_y-y)
    delta_t = next_t - t
    if distance > delta_t:
      print('No')
      sys.exit()
    elif (distance -delta_t)%2 != 0:
      print('No')
      sys.exit()   
    t, x, y = next_t, next_x, next_y
  print('Yes')
  
if __name__ == '__main__':
  main()

Measured memory_bytes: 3064
#include <stdio.h>
int sort(int *vlist,int *plist,int *qlist,int n){
  int i,j,k,l,m,s=0,p;
  for(i=0;i<n;i++){
    plist[i]=-1;
    qlist[i]=i+1;
  }
  qlist[n-1]=-1;
  while(qlist[s]!=-1){
    i=s;
    p=-1;
    while(i!=-1){
      j=i;
      k=qlist[j];
      if(k==-1) break;
      i=qlist[k];
      if(vlist[j]>vlist[k]){
        if(p==-1){
          s=k;
        }else{
          qlist[p]=k;
        }
        l=j;
        j=k;
        k=l;
      }
      qlist[j]=i;
      p=j;
      while(k!=-1){
        if((j==-1)|(vlist[j]>vlist[k])){
          l=plist[k];
          plist[k]=plist[m];
          plist[m]=k;
          m=k;
          k=l;
        }else{
          m=j;
          j=plist[m];
        }
      }
    }
  }
  return(s);
} 

int main(){
  int n,i,a[100005],p[100005],q[100005];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  for(i=sort(&a,&p,&q,n);i!=-1;i=p[i]){
    printf("%d ",i+1);
  }
  return(0);
}

Measured memory_bytes: 1920
n = int(input())
a = list(map(int, input().split()))
diff = [0]*(n**2 - n)
count = -1

for i in range(n):
  for ii in range(n-i-1):
    count = count + 1
    diff[count] = abs(a[i] - a[i+ii+1])
print(max(diff))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#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 all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    ll W, H, x, y; cin >> W >> H >> x >> y;
    double res = (double)(W) * H / 2;
    cout << fixed << setprecision(10) << res << " ";
    if (x*2 == W && y * 2 == H) cout << 1 << endl;
    else cout << 0 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <time.h>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <array>
#include <string>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define mp make_pair
#define eb emplace_back
#define F first
#define S second
using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ost;

const ll maxN = 1e7;
const ll INF = 1e17;
const ll MOD = 1e9 + 7;

ll xs[] = {-1, 1, 0, 0, -1, 1, 1, -1};
ll ys[] = {0, 0, -1, 1, -1, 1, -1, 1};

ll segtree[maxN << 2];
ll lazy[maxN << 2];
ll A[maxN];

inline ll left(ll x){
	return x << 1;
}

inline ll right(ll x){
	return (x<<1) + 1;
}

void build(ll node, ll start, ll end){
	if(start == end)
		segtree[node] = A[start];
	else{
		ll mid = (start + end)/2;
		build(left(node), start, mid);
		build(right(node), mid+1, end);
		segtree[node] = segtree[left(node)] + segtree[right(node)];
	}
}

void update(ll node, ll start, ll end, ll l, ll r, ll val){
	if(lazy[node] != 0){
		segtree[node] += (end-start+1)*lazy[node];
		if(start != end){
			lazy[left(node)] += lazy[node];
			lazy[right(node)] += lazy[node];
		}
		lazy[node] = 0;
	}
	if(start > end or l > start or r < end)
		return ;
	else if(start >= l and r >= end){
		segtree[node] += val;
		if(start != end){
			lazy[left(node)] += val;
			lazy[right(node)] += val;
		}
	}
	else{
		ll mid=(start + end)/2;
		update(left(node), start, mid, l, r, val);
		update(right(node), mid+1, end, l, r, val);
		segtree[node] = segtree[left(node)] + segtree[right(node)];
	}
}

ll sums(ll node, ll start, ll end, ll l, ll r){
	if(lazy[node] != 0){
		segtree[node] += (end-start+1)*lazy[node];
		if(start != end){
			lazy[left(node)] += lazy[node];
			lazy[right(node)] += lazy[node];
		}
		lazy[node] = 0;
	}
	if(l > end or r < start or start > end)
		return 0;
	if(l <= start and r >= end)
		return segtree[node];
	ll mid = (start+end)/2;
	return sums(left(node), start, mid, l , r) + sums(right(node), mid + 1, end, l , r);
}

int main(){
	cin.sync_with_stdio(false);
	cin.tie(0);
	ll t;
	cin >> t;
	cout << 48-t;
	return 0;
}

Measured memory_bytes: 3624
from collections import deque
D = [(1,0),(0,1),(-1,0),(0,-1)]

H,W = map(int,input().split())
maze = [input() for _ in range(H)]

def bfs(i,j):
  if maze[i][j] == '#':
    return 0
  queue = deque([(i,j,1)])
  distance = [[float('inf') for _ in range(W)] for _ in range(H)]
  distance[i][j] = 0
  
  while queue:
    x,y,d = queue.popleft()
    for dx,dy in D:
      nx,ny = x+dx,y+dy
      if not(0<= nx < H and 0 <= ny < W):
        continue
      if maze[nx][ny] == '#':
        continue
      if distance[nx][ny] != float('inf'):
        continue
      distance[nx][ny] = d
      queue.append((nx,ny,d+1))
  res = 0

  for i in range(H):
    for j in range(W):
      if distance[i][j] ==float('inf'):
        continue
      res = max(res,distance[i][j])
  return res

ans = 0
for i in range(H):
  for j in range(W):
    ans = max(ans,bfs(i,j))
print(ans)

Measured memory_bytes: 3316
import java.io.*;

class Main{
  public static void main(String[] args)throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String two_line = br.readLine();
    String[] line = two_line.split(" ");
    int length = Integer.parseInt(line[0]);
    int side = Integer.parseInt(line[1]);
    int area = length * side;
    int perimeter = length * 2 + side * 2;
    System.out.println(area + " " + perimeter);
  }
}



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

using namespace std;

int main()
{
    int N;
    string S;
    cin >> N;
    cin >> S;
    // cout << N << endl;
    // cout << S << endl;
    uint64_t ans = 0;
    char last = -1;
    for (auto s : S) {
        if (last != s) {
            ++ans;
            last = s;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 512
#include<stdio.h>


void swap(int *a, int *b){
	int w = *a;
	*a = *b;
	*b = w;
}


int main(){
	int num;
	scanf("%d", &num);

	int x, y, z, w;
	for(int i = 0; i < num; i++){
		scanf("%d %d %d", &x, &y, &z);
		if(x > z){
			swap(&x, &z);
		}
		if(y > z){
			swap(&y, &z);
		}
		if(x*x + y*y == z*z){
			printf("YES\n");
		}else{
			printf("NO\n");
		}

	}

	return 0;
}

Measured memory_bytes: 1008
// #pragma GCC optimize("unroll-loops", "omit-frame-pointer", "inline")
// #pragma GCC option("arch=native", "tune=native", "no-zero-upper")
// #pragma GCC
// target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("tree-vectorize","openmp","predictive-commoning")
// #pragma GCC option("D_GLIBCXX_PARALLEL","openmp")

// #pragma GCC optimize("O3")
// #pragma GCC target("avx2")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << endl;

template <class T>
void chmin(T &a, const T &b) {
  if (a > b) a = b;
}
template <class T>
void chmax(T &a, const T &b) {
  if (a < b) a = b;
}

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"

void solve() {
  int N;
  cin >> N;
  vector<ll> A(N);
  cin >> A;
  for (int i = 0; i < N; i++) {
    if (A[i] == 0ll) {
      cout << 0 << endl;
      return;
    }
  }
  ll ans = 1ll;
  for (int i = 0; i < N; i++) {
    if (ans > LLINF / A[i])
      ans = LLINF;
    else
      ans *= A[i];
  }
  if (ans > LLINF / 2ll)
    cout << -1 << endl;
  else
    cout << ans << endl;
  return;
}

signed main() {
  fastio();
  solve();
  // int t; cin >> t; while(t--)solve();

  // int t; cin >> t;
  // for(int i=1;i<=t;i++){
  //   cout << "Case #" << i << ": ";
  //   solve();
  // }
  return 0;
}


Measured memory_bytes: 3992
import heapq
N, M = map(int, input().split())
ABs = []
for i in range(N):
  A, B = map(int, input().split())
  ABs.append((A, B))
ABs.sort()
r = 0
q = []
i = 0
for m in range(1, M+1):
  while i < N:
    A, B = ABs[i]
    if A <= m:
      heapq.heappush(q, -B)
      i += 1
    else:
      break
  if q:
    B = -heapq.heappop(q)
    r += B
print(r)


Measured memory_bytes: 20772
import java.util.*;
public class Main {
	
	public static Boolean isOperator(String s) {
		
			return s.equals("+") || s.equals("-") || s.equals("*");
		
	}
	
	public static int calculate(int n, int n2, String op) {
		if(op.equals("+")) {
			return n + n2;
		}
		
		else if(op.equals("-")) {
			return n2 - n;
		}
		
		else return n * n2;
	}

	public static void main(String [] args) {
		
		Scanner in = new Scanner(System.in);
		Stack<Integer> nums = new Stack<Integer>();
		
		
		String s = in.nextLine();
		String [] input = s.split(" ");
		
		
		
		for(int i = 0; i < input.length; i++){
			String next  = input[i];
			
			
			if(isOperator(next)) {
				int n = nums.pop();
				int n2 = nums.pop();
				int newNum = calculate(n, n2, next);
				nums.push(newNum);
				
				
			}
			
			else {
				
				int n = Integer.parseInt(next);
				nums.push(n);
			}
			
		}
		
		System.out.println(nums.pop());
		
		
		
		
		
		
		
	
	}
}



Measured memory_bytes: 26116
import java.util.Arrays;
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int num = Integer.parseInt(scanner.nextLine());

		Dice[] dices = new Dice[num];
		boolean flag = true;

		loop: for (int i = 0; i < num; i++) {
			dices[i] = new Dice(scanner.nextLine());
			for (int j = 0; j < i; j++) {
				/*System.out.println(Arrays.toString(dices[i].a) + " -> "
						+ Arrays.toString(dices[j].a));*/
				if (dices[i].equals(dices[j])) {
					flag = false;
					break loop;
				}
			}
		}
		System.out.println(flag ? "Yes" : "No");
	}
}

class Dice {
	int[] a = new int[6];

	Dice(String s) {
		String[] b = s.split(" ");
		for (int i = 0; i < 6; i++) {
			a[i] = Integer.parseInt(b[i]);
		}
	}

	public void roll(char c) {
		int temp;
		switch (c) {
		case 'E':
			temp = a[0];
			a[0] = a[3];
			a[3] = a[5];
			a[5] = a[2];
			a[2] = temp;
			break;
		case 'N':
			temp = a[0];
			a[0] = a[1];
			a[1] = a[5];
			a[5] = a[4];
			a[4] = temp;
			break;
		case 'W':
			temp = a[0];
			a[0] = a[2];
			a[2] = a[5];
			a[5] = a[3];
			a[3] = temp;
			break;
		default:
			temp = a[0];
			a[0] = a[4];
			a[4] = a[5];
			a[5] = a[1];
			a[1] = temp;
			break;
		}
	}

	public boolean equals(Dice d) {
		char[] c = { 'E', 'E', 'E', 'N', 'W', 'W', 'W', 'S' };
		boolean flag = false;
		loop: for (int i = 0; i < 24; i++) {
			/*System.out.println(Arrays.toString(a) + "========"
					+ Arrays.toString(d.a));*/
			if (Arrays.equals(a, d.a)) {
				flag = true;
				break loop;
			}
			d.roll(c[i % 8]);
		}
		return flag;
	}
}

Measured memory_bytes: 21068
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
 
public class Main {
	private	static	BufferedReader	br = null;

	static {
		br = new BufferedReader(new InputStreamReader(System.in));
	}
 
    /**
     * @param args
     */
	public static void main(String[] args) {
		String  	stdin = null;
		boolean		first = true;
		char[][]	map   = new char[8][5];

		Arrays.fill(map[2], '=');

		while ((stdin = parseStdin()) != null) {
			int	l = stdin.length();
			int	d = 5-l;

			for (int i = 0; i < 5; i++) {
				map[0][i] = '*';
				map[1][i] = '*';
				map[3][i] = '*';
				map[4][i] = '*';
				map[5][i] = '*';
				map[6][i] = '*';
				map[7][i] = '*';
			}

			for (int i = 0; i < 5; i++) {
				int	cn = (i-d>=0) ? stdin.codePointAt(i-d)-'0' : 0;
				map[1-cn/5][i] = ' ';
				map[3+cn%5][i] = ' ';
			}

			if (!first) {
				System.out.println("");
			} else {
				first = false;
			}

			for (int i = 0; i < map.length; i++) {
				System.out.println(map[i]);
			}
		}
	}

	private static String parseStdin() {
		String  stdin = null;

		try {
			String  tmp = br.readLine();
			if (tmp != null) {
				if (!tmp.isEmpty()) stdin = tmp;
			}
		}
		catch (IOException e) {}

		return stdin;
	}
}

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

int main() {
    int a,b; cin >> a >> b;
    cout << a*b << " " << 2*a+2*b << endl;

    return 0;
}


Measured memory_bytes: 3060
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <algorithm>

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<double, double> Pdd;
typedef pair<ll, ll> P;
typedef pair<P, ll> PP;

const ll mod = 1e9+7;
const int INF = 2e9;
const double epsilon = 1e-7;
const double PI = 3.1415926535;

ll mi(ll x, ll y){
    if(x<y)return x;
    return y;
}

int main(void){
    int n, k; cin >> n >> k;
    if(k > (n-1)*(n-2)/2)cout << "-1" << endl;
    else{
        int a = (n-1)*(n-2)/2 - k;
        cout << a + n - 1 << endl;
        for(int i = 1;i < n;i++)printf("%d %d\n", i, n);
        for(int i = 1;i < n;i++)for(int j = i + 1;j < n;j++){
            a--;
            if(a == -1)return 0;
            printf("%d %d\n", i, j);
        }
    }
	return 0;
}


Measured memory_bytes: 256
object Main extends App {
  val in = new java.util.Scanner(System.in)
  val N = in.nextInt

  val dp = Array.tabulate(N + 1)(identity)

  def seq(i: Int): LazyList[Int] = i #:: seq(i).map(_ * i)

  def doDp(i: Int): Unit = {
    for {
      u <- seq(i).takeWhile(_ <= N)
      n <- 1 to i
      i <- 0 to (N - n * u)
    } {
      dp(i + n * u) = dp(i + n * u) min (dp(i) + n)
    }
  }

  doDp(6)
  doDp(9)
  println(dp(N))
}

Measured memory_bytes: 57420
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxx = 1e5 + 7;
const int Inf = 1 << 30;
int n;
ll a[maxx];

int main() {
	while(cin >> n && n) {
		ll ans = 0;
		memset(a, 0, sizeof(a));
		for(int i = 1; i <= n; i++) cin >> a[i];
		sort(a + 1, a + 1 + n);
		int l = 1, r = n;
		ans = abs(a[1] - a[n]);
		for(int i = 2; i <= n / 2; i++) {
			int dd = abs(a[l] - a[n - i + 1]);
			int pp = abs(a[r] - a[i]);
			ans += dd + pp;
			l++;
			r--;
		}
		if(n & 1) {
			int x = abs(a[n / 2 + 1] - a[r]);
			int y = abs(a[n / 2 + 1] - a[l]);
			ans += max(x, y);
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1024
//C
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

//C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//Others
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;
}
const int dx[8] = { -1, 0, 1, -1, 1, -1, 0, 1 };
const int dy[8] = { 1, 1, 1, 0, 0, -1, -1, -1 };
const int lr[4] = { 0, 1, 0, -1 };
const int ud[4] = { 1, 0, -1, 0 };



//LOVE Ayane Sakura



using namespace std;

long long GCD(long long a, long long b) {
	if (a < b) {
		swap(a, b);
	}
	long long r = -1;
	while (r != 0) {
		r = a % b;
		a = b;
		b = r;
	}
	return a;
}

int main() {
	int N;
	string S;
	cin >> N >> S;
	long long r, g, b;
	r = g = b = 0;
	for (int i = 0; i < N; i++) {
		if (S[i] == 'R') {
			r++;
		}
		else if (S[i] == 'G') {
			g++;
		}
		else {
			b++;
		}
	}
	long long ans = r * g * b;
	for (int i = 0; i <= N - 3; i++) {
		for (int j = i + 1; j <= N - 2; j++) {
			int k = 2 * j - i;
			if (k > N - 1) {
				break;
			}
			if (S[i] != S[j] && S[i] != S[k] && S[j] != S[k]) {
				ans--;
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3588
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
 
int main(){
    string s;
    cin>>s;
    int n=s.length()-1;
    vector<int> ss(s.length());
    for (int i=0; i<s.length();i++){
        ss[i]=s[i]-'0';
        
    }

    for (int bit=0;bit< (1<<n) ;bit++){
        vector<int> summation;
        for (int i=0; i<n ; i++){
            if(bit & (1<<i)){
                summation.push_back(i);
                }
            }
        vector<bool> check(n,false);

        for (int i=0; i<summation.size(); i++){
            check[summation[i]]=true;
        }
        long sum=ss[0];
        for (int i=0; i<n; i++){
            if(check[i]){
                sum+=ss[i+1];
            }
            else{
                sum-=ss[i+1];
            }
        }
        if(sum==7){
            cout<<ss[0];
            for (int i=0; i<n; i++){
                if(check[i])cout<<"+";
                else cout<<"-";
                cout<<ss[i+1];
            }
            break;
        }
    }
    cout<<"=7"<<endl;
    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 rep2(i,s,n) for(int i = (s); i < (n); ++i)
#define ll long long
#define ld long double
#define P pair<ll,ll>
#define all(v) v.begin(),v.end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll n,c,k; cin>>n>>c>>k;
    vector<ll> t(n);
    rep(i,n) cin>>t[i];
    sort(all(t));
    ll ans=0;
    for(int i=0;i<n;){
        ++ans;
        ll start=i;
        while(i<n && t[i] - t[start] <=k && i - start < c) ++i;
    }
    cout<<ans<<endl;
    return 0;
}

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

void print( const vector<int>& a, char sep = ' ' ) {
	size_t n = a.size();

	for( size_t i = 0; i < n; ++i ) {
		cout << a.at( i );

		if( i < n-1 ) { cout << sep; }
	}

	cout << endl;
}

int insertionSort( vector<int>& a, int n, int g ) {
	int cnt = 0;

	for( int i = g; i < n; ++i ) {
		int v = a.at( i );
		int j = i - g;

		while( j >= 0 && a.at( j ) > v ) {
			a.at( j+g ) = a.at( j );
			j -= g;
			cnt += 1;
		}

		a.at( j+g ) = v;
	}

	return cnt;
}

int shellSort( vector<int>& a, int n ) {
	int cnt = 0;

	int m = 1;
	for( int i = 1; i < n/3; i = 3*i+1 ) { m += 1; }

	vector<int> g( m, 1 );
	for( int i = m-2; i >= 0; --i ) {
		g.at( i ) = 3 * g.at( i+1 ) + 1;
	}

	cout << m << endl;
	print( g );

	for( int i = 0; i < m; ++i ) {
		cnt += insertionSort( a, n, g.at( i ) );
	}

	return cnt;
}

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

	vector<int> a( n );
	for( auto& v: a ) { cin >> v; }

	int cnt = shellSort( a, n );

	cout << cnt << endl;
	print( a, '\n' );
}



Measured memory_bytes: 6676
#include <iostream>
using namespace std;
int main()
{
    int i, j, k, h, w;

    cin >> h >> w;
    while(h>0 || w>0)
    {
        for(i=1; i<=h; i++)
        {
            for(j=1; j<=w; j++)
            {
                if (i>1 && i<h && j>1 && j<w)
                    cout << ".";
                else
                    cout << "#";
            }
            cout << endl;
        }
        cout << endl;
        cin >> h >> w;
    }
}


Measured memory_bytes: 3120
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.util.StringTokenizer;

public class Main {
	
	public static void main(String[] args) throws IOException {
		Main mainObj = new Main();
		mainObj.solve();
	}

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		
		BigDecimal a = new BigDecimal(fs.next());
		BigDecimal b = new BigDecimal(fs.next());
		
		
		long ans = a.multiply(b).longValue();
		System.out.println(ans);
	}
	

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}


}


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

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = 1;
    rep(i, n)
    {
        if (i == 0)
            continue;
        if (s[i] != s[i - 1])
            ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3732
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
  int n;
  string s;
  cin >> n >> s;
  if (n%2 == 1) {
    cout << "No" << endl;
    return 0;
  }
  if (s == s.substr(n/2)+s.substr(n/2)) {
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define endl '\n'

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int H1, M1, H2, M2, K;
    cin >> H1 >> M1 >> H2 >> M2 >> K;
    int hi;
    hi = H2 - H1;
    int me;
    me = M2 - M1;
    if(me>=0){
        if(hi>=0){
            hi = hi * 60;
            me = me + hi;
            me = me - K;
        }else
        {
            hi = hi+24;
            hi = hi * 60;
            me = me + hi;
            me = me - K;
        }
    }else
    {
        me = me + 60;
        if(hi>=0){
            hi--;
            hi = hi * 60;
            me = me + hi;
            me = me - K;
        }else
        {
            hi--;
            hi = hi + 24;
            hi = hi * 60;
            me = me + hi;
            me = me - K;
        }
    }
    if(me>0){
        cout << me << endl;
    }else{
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int n,dp[500100];
string s;
int main(){
    cin >> n >> s;
    s.resize(n+1);
    for(int i=n;i>=1;i--) s[i] = s[i-1];
    int prv = 0, prv2 = -1;
    for(int i=1;i<=n;i++){
        dp[i] = dp[i-1];
        if(s[i]=='0'){
            prv2 = prv;
            prv = i;
            continue;
        }
//        if(i<3) continue;
//        if(prv<=1) continue;
        if(prv2+1!=prv) dp[i] = max(dp[i],dp[prv-2]+i-prv);
        if(prv2+1!=prv && prv+1==i) dp[i] = max(dp[i],dp[prv2]+prv-prv2-1);
        if(prv2+2!=prv && prv+1==i) dp[i] = max(dp[i],dp[prv2+1]+prv-prv2-2);
    }
    cout << dp[n] << endl;
    return 0;
}


Measured memory_bytes: 2820
use std::io;
use std::cmp;
use io_ext::Reader;

fn main() {
    let stdin = io::stdin();
    let mut r = Reader::new(io::BufReader::new(stdin.lock()));
    let n: usize = r.read_line().parse().unwrap();
    let mut answer = false;
    for i in 1..10 {
        for j in 1..10 {
            if n == i * j {
                answer = true;
            }
        }
    }

    if answer {
        println!("Yes");
    } else {
        println!("No");
    }
}

/// Extension of io module.
pub mod io_ext {
    use std::io::BufRead;

    pub struct Reader<R> {
        buf: String,
        inner: R,
    }

    impl<R> Reader<R> {
        #[inline]
        pub fn new(inner: R) -> Self {
            Reader { buf: String::new(), inner: inner }
        }

        #[inline]
        pub fn into_inner(self) -> R {
            self.inner
        }
    }

    impl<R: BufRead> Reader<R> {
        #[allow(deprecated)]
        #[inline]
        pub fn read_line(&mut self) -> &str {
            self.buf.clear();
            self.inner.read_line(&mut self.buf).unwrap_or_else(|e| panic!("{}", e));
            self.buf.trim_right()
        }
    }
}

/// Module supporting to parse strings.
pub mod parse {
    use std::str::FromStr;
    use std::borrow::Borrow;

    pub trait ParseNext: Iterator {
        fn parse_next<F: FromStr>(&mut self) -> F;
    }

    impl<'a, S: Borrow<str>, I: Iterator<Item=S>> ParseNext for I {
        fn parse_next<F: FromStr>(&mut self) -> F {
            if let Some(s) = self.next() {
                match s.borrow().parse() {
                    Ok(x) => x,
                    Err(_) => panic!("provided string cannot be parsed")
                }
            } else {
                panic!("iterator has no next element")
            }
        }
    }
}


Measured memory_bytes: 4352
function main()
    N = parse(readline())
    l = Array{Int64,1}(zeros(N))
    r = Array{Int64,1}(zeros(N))
    ANSWER = Int64(0)
    for i = 1:N
        l[i], r[i] = parse.(split(readline()))
        ANSWER += r[i] - l[i] + 1
    end
    print(ANSWER)
end

main()

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  int oddn = 0;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    if (A[i] % 2 == 1) oddn++;
  }
  cout << (oddn % 2 == 0 ? "YES" : "NO") << '\n';
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
//#include<bits/stdc++.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<map> 
using namespace std ;
typedef long long ll ;
ll a[100005];
ll dp[100005];
ll n ; 
ll f(ll n ){
    if(n <= 1){
        return 0 ;
    }
    if (dp[n] !=  -1 )
    {
        return dp[n] ;
    }
    return dp[n] = min(f(n-1) + abs(a[n] - a[n - 1]),f(n-2) + abs(a[n] - a[n - 2])) ;
}
int main(){
    cin >> n ;
    
    for (ll i = 1; i <= n ; i++)
    {
        cin >> a[i] ;
        dp[i] = -1 ; 
    }
    dp[0] = 0 ;
    dp[1] = 0 ;
    a[0] = a[1] ;
    cout << f(n) << endl ;
    /*for (ll i = 0; i < 5; i++)
    {
        cout << "##  "   <<dp[i] << endl ;
    }
    */
   return 0 ;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
signed main(){
    int n; cin >> n;
    vector<int>v(n);
    for(auto & e : v) cin >> e;
    rep(i,n){
        int t ; cin >> t; v[i] -= t;
    }
    int ans = 0;
    for(auto e : v)if(e > 0)ans += e;
    cout << ans << endl;
}




Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(unused_macros)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_variables)]
#![allow(unused_mut)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::cmp::{max, min, Ordering};

macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
    ($t:ty ;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty ;; $n:expr) => {
        (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
    };
}

// N M => let (N, M) = get!(usize, usize)
// A1 B1
// ...
// AQ BQ => let A = get!(usize, usize; Q)

const MOD: u64 = 1000000007;

fn main() {
    let (N, K) = get!(usize, usize);

    let ans: usize = (N + 1) / 2;

    if ans >= K {
        println!("YES");
    } else {
        println!("NO");
    }

}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int n,a[100050],b[100050],s;
int main(){
	cin >> n;
	a[0]=0;
	for(int i=1 ; i<=n ; i++){
		cin >> a[i];
	}
	a[n+1]=0;
	for(int i=0 ; i<=n ; i++){
		s += abs(a[i] - a[i+1]);
	}
	for(int i=1 ; i<=n ; i++){
		b[i]=s;
		for(int j=-1 ; j<=0 ; j++){
			b[i]-=abs(a[i+j] - a[i+1+j]);
		}
		b[i]+=abs(a[i-1] - a[i+1]);
	}
	for(int i=1 ; i<=n ; i++){
		cout << b[i] << endl;
	}
}
// 0 3   3 5  5 -1  -1 0

Measured memory_bytes: 2048
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn = 10;
int n, m, k;
char mat[maxn][maxn];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cin >> n >> m >> k;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++)cin >> mat[i][j];
    }
    int rez = 0;
    for(int mask1=0;mask1<(1<<n);mask1++){
        for(int mask2=0;mask2<(1<<m);mask2++){
            int brojac = 0;
            for(int i=0;i<n;i++){
                for(int j=0;j<m;j++){
                    if(!(mask1 & (1 << i)) && !(mask2 & (1 << j)))brojac += mat[i][j] == '#';
                }
            }
//            cout << "brojac: " << brojac << endl;
            if(brojac == k)rez++;
        }
    }
    cout << rez << endl;
    return 0;
}


Measured memory_bytes: 3656
// -*- coding:utf-8-unix -*-

use proconio::input;

fn main() {
    input! {
        n: u16,
        m: u16,
    }

    let mut v = vec![0; n.into()];
    let mut appeared_degree = vec!();
    for _i in 0..m {
        input! {
            s: usize,
            c: u16,
        }

        if n != 1 && s == 1 && c ==0 {
            println!("-1");
            return;
        } else if appeared_degree.contains(&s) {
            if c == v[(s - 1) as usize] {
                continue;
            }
            else {
                // println!("s: {}, c: {}", s, c);
                // println!("{:?}", v);
                println!("-1");
                return;
            }
        }

        appeared_degree.push(s);
        v[(s - 1) as usize] = c
    }

    v.reverse();
    let mut ans: u16 = 0;
    for i in 0..v.len() {
        if n != 1 && (i == v.len() - 1) && v[i as usize] == 0 {
            ans += 1 * 10_u16.pow(i as u32);
        } else {
            ans += v[i as usize] * 10_u16.pow(i as u32);
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2136
#include <iostream>
#include <cmath>
using namespace std;
 
// int main(){
//   long long a, b, c;
 
//   cin >> a >> b >> c;
  
//   cout << c / 2;
//   cout << a + b;
//   if (a + b > c / 2)
//   {
//     cout << "No";
//   }
//   else
//   {
//     cout << "Yes";
//   }
//   return 0;
// }
 
 
 
// int main()
// {
 
//   unsigned long long h, w;
//   cin >> h >> w;
 
//   unsigned long long ans = h * w;
//   ans += 1;
//   cout << ans << "\n";
//   ans /= 2;
 
//   cout << ans;
// }
 
int main()
{
 
  unsigned long long h, w;
  cin >> h >> w;

  unsigned long long wa1 = (w + 1) / 2;
  unsigned long long wa2 = w / 2;
 
  unsigned long long ha1 = (h + 1) / 2;
  unsigned long long ha2 = h / 2;
 
  unsigned long long ans = wa1 * ha1 + wa2 * ha2;

  if( w == 1 || h == 1){
    ans = 1;
  }
  cout << ans;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        
        if(A * B % 2 == 1){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 22996