akhauriyash/Code-Regression huggingface dataset:
//Optional FAST

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define trav(x,A) for(auto &x:A)
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef vector<int> veci;
typedef vector<long long> vecl;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);

//Required Functions

ll power(ll x,ll y) 
{ 
	if (y == 0) 
		return 1; 
	ll p = power(x, y/2) % MOD; 
	p = (p * p) % MOD; 
  
	return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

int main()
{
	#ifndef ONLINE_JUDGE
	if (fopen("INPUT.txt", "r"))
	{
		freopen ("INPUT.txt" , "r" , stdin);
		//freopen ("OUTPUT.txt" , "w" , stdout);
	}
	#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	clock_t clk;
	clk = clock();
//-----------------------------------------------------------------------------------------------------------//

	READV(N);
	ll ans=(N/500)*1000+((N%500)/5)*5;
	cout<<ans<<endl;

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


	clk = clock() - clk;
	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << endl;

	return 0;
}

Measured memory_bytes: 384
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????


		Scanner scan = new Scanner(System.in);
		ArrayList<Integer> list = new ArrayList<Integer>();

		String a = null;
		String b = null;
		String c = null;


		while(scan.hasNext()){

			a = scan.next();
			b = scan.next();
			c = scan.next();

			if(!"?".equals(b)){

				int intA = 0;
				int intC = 0;
				try{
					intA = Integer.parseInt(a);
					intC = Integer.parseInt(c);
				}catch(NumberFormatException e){
					System.out.println(e);
				}

				int intAnser = 0;

				if("+".equals(b)){

					intAnser = intA + intC;
				}else if("-".equals(b)){

					intAnser = intA - intC;
				}else if("*".equals(b)){

					intAnser = intA * intC;
				}else{

					intAnser = intA / intC;
				}


				list.add(intAnser);

			}else{

				scan.close();
				break;
			}

		}

		for(int i = 0; i < list.size(); i++){

			int intResult =list.get(i);
			System.out.println(intResult);
		}


	}
}

Measured memory_bytes: 17164
#include <iostream>
#include<string.h>
#include<math.h>
using namespace std;

int main() {
	int n,i;
	string s1,s2;
	cin>>n>>s1>>s2;
	for(i=0;i<n;i++){
		int k=0;
		while(k<n-i){
			if(s1[i+k]!=s2[k])goto next;
			k++;
			if(k==n-i){
				cout<<i+n<<endl;
				goto end;
			}
		}
		next:
		k=1;
	}
	cout<<n*2<<endl;
	end:
	s1=1;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <stack>
#include <queue>
#include <bitset>
#include <numeric>
#include <cassert>
#ifdef DEBUG
#include "./Lib/debug.hpp"
#else
#define dump(...)
template<class T>inline auto d_val(T a, T b) { return a; }
#endif

/* (=＾o＾=) */
#define int ll

/* macro */
#define FOR(i, b, e) for(ll i = (ll)(b); i < (ll)(e); ++i)
#define RFOR(i, b, e) for(ll i = (ll)(e-1); i >= (ll)(b); --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define REPC(x,c) for(const auto& x:(c))
#define REPI2(it,b,e) for(auto it = (b); it != (e); ++it)
#define REPI(it,c) REPI2(it, (c).begin(), (c).end())
#define RREPI(it,c) REPI2(it, (c).rbegin(), (c).rend())
#define REPI_ERACE2(it, b, e) for(auto it = (b); it != (e);)
#define REPI_ERACE(it, c) REPI_ERACE2(it, (c).begin(), (c).end())
#define ALL(x) (x).begin(),(x).end()
#define cauto const auto&
/* macro func */
#define SORT(x) do{sort(ALL(x));}while(false)
#define RSORT(x) do{sort((x).rbegin(),(x).rend());}while(false)
#define UNIQUE(v) do{v.erase( unique(v.begin(), v.end()), v.end() );}while(false)
#define MAX(x,y) do{x = std::max(x,y);}while(false)
#define MIN(x,y) do{x = std::min(x,y);}while(false)
#define BR do{cout<<"\n";}while(false)

/* type define */
using ll = long long;
using PAIR = std::pair<ll, ll>;
using VS = std::vector<std::string>;
using VL = std::vector<long long>;
using VVL = std::vector<VL>;
using VVVL = std::vector<VVL>;
using VD = std::vector<double>;
template<class T>
using V = std::vector<T>;

/* using std */
using std::cout;
constexpr char endl = '\n';
using std::cin;
using std::sort;
using std::pair;
using std::string;
using std::stack;
using std::queue;
using std::vector;
using std::list;
using std::map;
using std::unordered_map;
using std::multimap;
using std::unordered_multimap;
using std::set;
using std::unordered_set;
using std::unordered_multiset;
using std::multiset;
using std::bitset;
using std::priority_queue;

/* constant value */
constexpr ll MOD = 1000000007;
//constexpr ll MOD = 998244353;

/* Initial processing  */
struct Preprocessing { Preprocessing() { std::cin.tie(0); std::ios::sync_with_stdio(0); }; }_Preprocessing;

/* Remove the source of the bug */
signed pow(signed, signed) { assert(false); return -1; }

/* define hash */
namespace std { template <>	class hash<std::pair<ll, ll>> { public:	size_t operator()(const std::pair<ll, ll>& x) const { return hash<ll>()(1000000000 * x.first + x.second); } }; }

/* input */
template<class T> std::istream& operator >> (std::istream& is, vector<T>& vec) { for (T& x : vec) is >> x; return is; }

//=============================================================================================


signed main() {
	ll m, d;
	cin >> m >> d;

	ll ans = 0;
	FOR(i, 1, m + 1)FOR(j, 1, d + 1) {
		ll d1 = j % 10;
		ll d2 = j / 10;
		if (d1 >= 2 && d2 >= 2 && d1 * d2 == i) { ++ans; }
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <memory.h>
int main(void){
  int n,t,ans[20],i;
  while(1){
    scanf("%d",&n);
    if(!n)
      break;
    memset(ans,0,sizeof(ans));
    i=0;
    while(n){
      t=n%8;
      if(t>=5)
	ans[i++]=t+2;
      else if(t==4)
	ans[i++]=t+1;
      else
	ans[i++]=t;
      n/=8;
    }
    for(i--;i>=0;i--)
      printf("%d",ans[i]);
    puts("");
  }
  return 0;
}

Measured memory_bytes: 612
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL)
typedef long long ll;
typedef long double ld;
#define rep(i,a)  for(ll i=0; i< a; i++)
#define pb push_back
#define vl vector<ll>
#define trace(x)  cerr << #x << ": " << x << endl;
const ll N=1e6+5;
ll mini;
int main()
{
	fast;
	ll n;cin>>n;ll ans=0;
	vector<ll> a(n);cin>>a[0];
	for(ll i=1;i<n;i++)
	{
		cin>>a[i];
		if(a[i]<a[i-1]){ans+=(a[i-1]-a[i]);a[i]=a[i-1];}
	}
	cout<<ans;
		
}

Measured memory_bytes: 4744
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in);) {
            solve(sc);
        }
    }

    public static void solve(Scanner sc) {
        int k = sc.nextInt();
        int s = sc.nextInt();
        int count = 0;
        for (int x = 0; x <= k; x++) {
            for (int y = 0; y <= k; y++) {
                int z = s - x - y;
                if (0 <= z && z <= k) {
                    count++;
                }
            }
        }
        System.out.println(count);
    }
}

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

using namespace std;

typedef long long ll;

int main(){
	int s;
	bool num[1000000] = {false};
	cin >> s;
	ll kai = 1;
	while(1){
		if(num[s])break;
		num[s] = true;
		if(s%2==1)s = 3*s+1;
		else s/=2;
		kai++;
	}
	cout << kai << endl;
    return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <string.h>

using namespace std;
#define ll long long int

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

	ll n,sum;
	cin>>n;
	sum=0;
	sum+=(n/500)*1000;
	n=n%500;
	n=n-(n%5);
	sum+=n;
	cout<< sum;

	return 0;
}


Measured memory_bytes: 256
while true do
  a, b, c = gets.split.map(&:to_i)
  break if [a, b, c].inject(:+) == 0
  if c == 0
    if a == 1 && b < 0
      printf "%d %d %d %d\n", 1, 0, a, b
    else
      printf "%d %d %d %d\n", a, b, 1, 0
    end
    next
  end
  ok = false
  a.downto(1) do |p|
    break if ok
    next if a % p != 0
    c.abs.downto(-1*c.abs) do |q|
      break if ok
      next if q == 0
      next if c % q != 0
      r = a / p
      s = c / q
      next if b != p * s + q * r
      ok = true
      printf "%d %d %d %d\n", p, q, r, s
    end
  end
  puts "Impossible" if !ok
end

Measured memory_bytes: 6132
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ll long long
#define inf 0x3f3f3f3f
#define fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int N = 2e5+5;
const ll mod =   1e9+7;

int main()
{  fast
ll x;
cin>>x;
ll cnt=0;
for(int i=1;i<=x;i++) {
	 cnt*=10;cnt+=7;//cout<<cnt<<endl;
	 cnt%=x;

	 if(cnt==0){
	 	cout<<i;return 0;
	 }
	 
}
cout<<"-1";
}

Measured memory_bytes: 3636
N =int(input())
A_n =list(map(int,input().split()))

maxh = A_n[0]
ans =0
for i  in range(1,N):
    if A_n[i] < maxh:
        sa = maxh - A_n[i]
        ans += sa
        maxh = A_n[i] +sa
    else:
        maxh = A_n[i]


print(ans)

Measured memory_bytes: 32160
def solve():
    def measurement(a, b, w):
        a_root = root[a]
        b_root = root[b]
        if a_root != b_root:
            a_member = member[a_root]
            b_member = member[b_root]
            offset = w - (weight[b] - weight[a])
            if len(a_member) > len(b_member):
                a_member.extend(b_member)
                for n in b_member:
                    root[n] = a_root
                    weight[n] += offset
            else:
                b_member.extend(a_member)
                for n in a_member:
                    root[n] = b_root
                    weight[n] -= offset
     
    def inquiry(a, b):
        if root[a] == root[b]:
            return weight[b] - weight[a]
        else:
            return 'UNKNOWN'
                     
    import sys
    file_input = sys.stdin.readlines()
    ans = []
     
    while True:
        N, M = map(int, file_input[0].split())
        if N == 0:
            break
         
        root = [i for i in range(N + 1)]
        member = [[i] for i in range(N + 1)]
        weight = [0] * (N + 1)
         
        for line in file_input[1:M+1]:
            if line[0] == '!':
                a, b, w = map(int, line[2:].split())
                measurement(a, b, w)
            else:
                a, b= map(int, line[2:].split())
                ans.append(inquiry(a, b))
         
        del file_input[:M+1]
    
    print(*ans, sep='\n')
 
solve()


Measured memory_bytes: 134640
import java.util.*;
class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int a = sc.nextInt();
	int b = sc.nextInt();
	int lnb = (int)Math.log10(b)+1;
	int num = a*(int)Math.pow(10,lnb) + b;
	for(int i = 1; i*i<=num; i++) {
	    if(i*i==num) {
		System.out.println("Yes");
		return;
	    }
	}
	System.out.println("No");
    }
}

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

int main()
{
  int64_t A, B, C, d1, d2, d3;
  cin >> A >> B >> C;
  int64_t a = A / 2, b = B / 2, c = C / 2;
  d1 = abs(a * B * C - (A - a) * B * C);
  d2 = abs(b * A * C - (B - b) * A * C);
  d3 = abs(c * A * B - (C - c) * A * B);
  cout << min(d1, min(d2, d3)) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define PI 3.14159265358979323846
#define int64 long long
#define uint64 unsigned long long
using namespace std;

int main()
{
	string ss, tt;
	cin >> ss >> tt;
	cout << tt << ss;
	return 0;
}

Measured memory_bytes: 3532
#include "bits/stdc++.h"
 
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<VVI> VVVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<VVLL> VVVLL;

#define SORT_ASC(c) sort((c).begin(), (c).end())
#define SORT_DESC(c) sort((c).begin(), (c).end(), greater<typeof((c).begin())>())
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SIZE(a) int((a).size())
 
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_LARGE = 1000000100;
 
 
//debug func
template<typename T>
void vecprint(vector<T> v) {
    for(auto x : v) {
        cerr << x << " ";
    }
    cerr << endl;
}
 
template<typename T>
void vecvecprint(vector<vector<T>> v) {
    for(auto x :v) {
        REP(i, x.size()-1) {
            cerr << x[i] << " ";
        }
        cerr << x[x.size()-1] <<endl;
    }
}
 
template<typename T>
void pqprint(priority_queue<T> q) {
    while(!q.empty()) {
        cerr << q.top() << " ";
        q.pop();
    }
    cerr << endl;
}
 
template<typename T>
void qprint(queue<T> q) {
    while(!q.empty()) {
        cerr << q.front() << " ";
        q.pop();
    }
    cerr << endl;
}
 
template<typename T>
void vecqprint(vector<queue<T>> v) {
    for(int i = 0; i < v.size(); i++) {
        qprint(v[i]);
    }
}
 
template <typename Iterator>
inline bool next_combination(const Iterator first, Iterator k, const Iterator last)
{
   /* Credits: Thomas Draper */
   if ((first == last) || (first == k) || (last == k))
      return false;
   Iterator itr1 = first;
   Iterator itr2 = last;
   ++itr1;
   if (last == itr1)
      return false;
   itr1 = last;
   --itr1;
   itr1 = k;
   --itr2;
   while (first != itr1)
   {
      if (*--itr1 < *itr2)
      {
         Iterator j = k;
         while (!(*itr1 < *j)) ++j;
         iter_swap(itr1,j);
         ++itr1;
         ++j;
         itr2 = k;
         rotate(itr1,j,last);
         while (last != j)
         {
            ++j;
            ++itr2;
         }
         rotate(k,itr2,last);
         return true;
      }
   }
   rotate(first,k,last);
   return false;
}

inline double get_time_sec(void){
    return static_cast<double>(chrono::duration_cast<chrono::nanoseconds>(chrono::steady_clock::now().time_since_epoch()).count())/1000000000;
}

int main(void) {
    int n;
    cin >> n;
    VI vd(n, 0);
    REP(i, n) cin >> vd[i];
    sort(vd.begin(), vd.end());
    cout << vd[n/2] - vd[n/2-1] << endl;
}

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

#define FOR(i,a,b)  for(ll (i)=a;(i)<(b);++(i))
#define RFOR(i,a,b) for(ll (i)=a;(i)>=(b);--(i))
#define REP(i,n)    FOR(i,0,n)
#define RREP(i,n)   RFOR(i,n,0)
#define ALL(v)      (v).begin(),(v).end()
#define BIT(n)      (1LL<<(n))
#define IN(x,l,r)   ((l)<=(x)&&(x)<=(r))
#define SHOW(x)     cout<<#x<<" = "<<x<<endl
#define SORT(v)     sort(ALL(v))
#define SZ(v)       (ll)(v).size()
#define UNIQ(v)     SORT(v);(v).erase(unique(ALL(v)),(v).end())
#define PERM(c)     for(bool p=1;p;p=next_permutation(ALL(c)))
#define PQ(T)       priority_queue<T,vector<T>,greater<T>>

template<typename T>string join(const vector<T>& v, string d=" ")
{stringstream s;REP(i,SZ(v))s<<d<<v[i];return s.str().substr(d.length());}

template<typename T> ostream& operator<<(ostream& s, const vector<T>& v)
{if(SZ(v))s<<join(v,", ");return s;}

const ll inf = 1e15;
const ll mod = 1e9+7;
const double eps = 1e-10;

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

struct edge { ll to, cost; };

int main() {
    ll N; cin >> N;
    
    map<ll, vector<edge>> mp;
    REP(i, N-1) {
        ll a, b, c; cin >> a >> b >> c;
        mp[b].push_back((edge){a, c});
        mp[a].push_back((edge){b, c});
    }
    
    ll Q, K; cin >> Q >> K;
    
    vector<ll> dist(N+1, 0);
    queue<pair<ll, ll>> que;
    que.push(make_pair(K, 0));
    while (!que.empty()) {
        pair<ll, ll> p = que.front(); que.pop();
        ll b = p.first;
        ll c = p.second;
        
        for (edge e : mp[b]) {
            if (dist[e.to] != 0) continue;
            dist[e.to] = e.cost + c;
            que.push(make_pair(e.to, dist[e.to]));
        }
    }
    
    REP(i, Q) {
        ll x, y; cin >> x >> y;
        cout << dist[x] + dist[y] << endl;
    }
    
    return 0;
}


Measured memory_bytes: 16240
#include <algorithm>
#include <cstdlib>
#include <iostream>

using namespace std;

void display(int n, int *p) {
  for (int i = 0; i < n; i++) {
    cout << p[i] << " ";
  }
  cout << endl;
}

int nth_permutation(int n, int *p) {
  int myints[] = {1, 2, 3, 4, 5, 6, 7, 8};
  int nth = -1;
  bool matched = false;
  std::sort(myints, myints + n);

  do {
    nth++;
    // display(n, myints);

    matched = true;
    for (int i = 0; i < n; i++) {
      if (p[i] != myints[i]) {
        matched = false;
        break;
      }
    }
  } while (!matched && std::next_permutation(myints, myints + n));
  return nth;
}

int main() {
  int N;
  int P[8];
  int Q[8];

  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> P[i];
  }
  for (int i = 0; i < N; i++) {
    cin >> Q[i];
  }
  int a = nth_permutation(N, P);
  // cout << a << endl;
  int b = nth_permutation(N, Q);
  // cout << b << endl;

  cout << abs(a - b) << endl;
  return 0;
}

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

int main() {
	// your code goes here
	int n,m,i,s[100005],ones=0,memo;
	char ss[100005];
	cin >> n >> m >> ss;
	for(i=0;i<=n;i++){
		if(ss[i]=='1') s[i]=1;
		else s[i]=0;
	}
	for(i=0;i<=n;i++){
		if(s[i]==0) memo=0;
		else{
			memo++;
			ones=max(ones,memo);
		}
	}
	if(ones>=m){
		cout << "-1" << endl;
		return 0;
	}
	vector<int> g;
	int pb1,pb2;
	pb1=n; pb2=n;
	for(i=n;i>=0;i--){
		if(s[i]==0){
			pb2=i;
		}
		if(pb1-i==m||i==0){
			g.push_back(pb1-pb2);
			pb1=pb2;
		}
	}
	int si=g.size();
	for(i=0;i<si;i++){
		cout << g[si-i-1];
		if(i!=si-1) cout << " ";
		else cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1404
#include<cstdio>
#include<vector>
std::vector<int>g[100005];
int disA[100005], disT[100005];
int vis[100005];
int Q[100005];

int max(int a,int b){ return a>b?a:b; }

int solve(int n,int A,int T){
    if(A==T) return 0;
    for(int i = 1; i <= n; i++) vis[i] = 0;
    vis[A] = 1;
    int h = 0, t = -1;
    Q[++t] = A;
    while(h<=t){
        int u = Q[h++];
        for(unsigned int i = 0; i < g[u].size(); i++){
            int v = g[u][i];
            if(vis[v]) continue;
            disA[v] = disA[u] + 1;
            vis[v] = 1;
            Q[++t] = v;
        }
    }
    int ans = disA[T]-1;
    for(int i = 1; i <= n; i++) vis[i] = 0;
    vis[T] = 1;
    h = 0, t = -1;
    Q[++t] = T;
    while(h<=t){
        int u = Q[h++];
        int cnt = 0;
        for(unsigned int i = 0; i < g[u].size(); i++){
            int v = g[u][i];
            if(vis[v]) continue;
            cnt++;
            vis[v] = 1;
            disT[v] = disT[u] + 1;
            Q[++t] = v;
        }
        //printf("u = %d\n",u);
        if(cnt==0 && disT[u]<disA[u]) ans = max(ans,disA[u]-1);
    }
    return ans;
}

int main(){
    int n, t, a;
    scanf("%d%d%d",&n,&t,&a);
    for(int i = 0; i < n-1; i++){
        int u,v;
        scanf("%d%d",&u,&v);
        g[u].push_back(v);
        g[v].push_back(u);
    }
    printf("%d\n",solve(n,a,t));
    return 0;
}


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

using namespace std;

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

int main()
{
	ios::sync_with_stdio(false);
	for (int i = 0; i < 3; i++) 
		for (int j = 0; j < 3; j++) cin >> c[i][j];
	for (int k = -1000; k <= 1000; k++)
	{
		a[0] = k;
		bool vis = true;
		for (int i = 0; i < 3; i++) b[i] = c[0][i] - a[0];
		for (int i = 0; i < 3; i++) a[i] = c[i][0] - b[0];
		for (int i = 1; i < 3; i++)
			for (int j = 1; j < 3; j++) 
				if (c[i][j] != a[i] + b[j]) { vis = false; break; }
		if (vis == true) { cout << "Yes" << endl; return 0; }
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    cin.tie(0);
    cout.tie(0);
    long long  a,b,c,k=0;
    cin>>a>>b>>c;
    if(a%c==0)
        k++;
    k+=((b/c)-(a/c));
    cout<<k<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) > (b) ? (b) : (a))
#define abs(x) ((x) > 0 ? (x) : -(x))
#define MOD (ll)1000000007 //10^9 + 7
#define endl printf("\n")
typedef long long ll;

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

  return 0;
}

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


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    if (N < 1000) {
        cout << "ABC" << endl;
    } else {
        cout << "ABD" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.stream.Collectors;

public class Main {
     public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        List<String> sList = new ArrayList<>();
        for (int i = 0; i < N; i++) {
            sList.add(sc.next());

        }
        int M = sc.nextInt();
        List<String> tList = new ArrayList<>();
        for (int i = 0; i < M; i++) {
            tList.add(sc.next());

        }
       
        Map<String, Long> sMap = sList.stream().collect(Collectors.groupingBy(s -> s, Collectors.counting()));
        Map<String, Long> tMap = tList.stream().collect(Collectors.groupingBy(s -> s, Collectors.counting()));
        long result = 0;
        for (Map.Entry<String, Long> entry : sMap.entrySet()) {
            long point = entry.getValue();
            if (tMap.containsKey(entry.getKey())) {
                point -= tMap.get(entry.getKey());

            }
            if (point > result) {
                result = point;
            }
        }
        System.out.println(result);
    } 
}

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

const long long INF = 1000000000;

int main() {
	string s, t;
	cin >> s >> t;
	int dp[3010][3010] = {0};
	for(int i=0; i<s.size(); i++){
		for(int j=0; j<t.size(); j++){
			if(s[i] == t[j] && dp[i][j]+1>dp[i+1][j+1]){
				dp[i+1][j+1] = dp[i][j] + 1;
			}
			if(dp[i+1][j] > dp[i+1][j+1]){
				dp[i+1][j+1] = dp[i+1][j];
			}
			if(dp[i][j+1] > dp[i+1][j+1]){
				dp[i+1][j+1] = dp[i][j+1];
			}
		}
	}
	string ans = "";
	int i = (int)s.size(); 
	int j = (int)t.size();
	while(i>0 && j>0){
		if(dp[i][j] == dp[i-1][j]){
			i--;
		}
		else if(dp[i][j] == dp[i][j-1]){
			j--;
		}
		else{
			ans = s[i-1] + ans;
			i--;
			j--; 
		}

	}

	cout << ans <<endl;
}






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

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

int main()
{
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++)
  {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  int now = gcd(a[0], a[1]);
  for(int i = 1; i < n - 1; i++)
  {
    now = gcd(now, a[i+1]);
  }
  cout << now << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <vector>
#include <string>
#include <cmath>
#include <map> 
#include <complex>
using namespace std;
 
const int MAX= 10000100;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()
#define ll long long int
#define gcd(a,b) __gcd(a,b)
#define P complex<double>

int GCD(int a, int b) {if(!b) return a; return gcd(b, a%b);}
int lcm(int a, int b) {return a*b / gcd(a, b);}

vector<P> g(4);
double cross(P a,P b){
  return a.real() * b.imag() - a.imag() * b.real();
}
int main(void){
  double x[4],y[4];
  char d;
  while(cin>> g[0].real() >> d >> g[0].imag(),!cin.eof()){
    loop(i,1,4){
      cin>>d>>g[i].real() >> d >> g[i].imag();
    }
    string res = "NO";
    rep(k,2){
      rep(i,4){
    P a = g[(i+1)%4] - g[i];
    P b = g[(i+2)%4] - g[i];
    if(cross(a, b) < 0.0) break;
    if(i+1 == 4) res = "YES";
      }
      reverse(g.begin(), g.end());
    }
    cout<<res<<endl;
  }
}

Measured memory_bytes: 1232
#include <iostream>

using namespace std;

const int N=100001;

int main(void){
    int n;
    int t[N],x[N],y[N];

    t[0] = x[0] = y[0] = 0;

    cin >> n;
    for (int i=0;i<n;i++){
        cin >> t[i+1] >> x[i+1] >> y[i+1];
    } 

    bool isPossible = true;
    for (int i=0;i<n;i++){
        int dt = t[i+1] - t[i];
        int dist = abs(x[i+1]-x[i]) + abs(y[i+1]-y[i]);
        if ( dist>dt ) isPossible = false;
        if ( (dist%2) != (dt%2) ) isPossible = false;
    }

    if (isPossible) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {

	public static void main(String args[]){

		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int min = -1;
		
		for(int i = 1; i<=10000;i++){
			if((int)(i*0.08) == a && (int)(i*0.1) == b){
				min = i;
				break;
			}
		}
		
		System.out.println(min);
		
	}
}

Measured memory_bytes: 23124
#include <stdio.h>
 
int main(){
    long long int w;
    scanf("%lld",&w);
 
    char name[100];
    int i=0;
    
    while(w!=0)
    {
        w--;
        int b = w%26;
        name[i] ='a'+ b;
        w/=26;
        i++;
    }
 
    for(int j=i-1;j>=0;j--)
    {
        printf("%c",name[j]);
    }
    
    return 0;
}

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

#ifdef DONLINE_JUDGE
//freopen("a.in", "r", stdin);
//freopen("a.out","w",stdout); // console output is better (in most cases)
#else
// add i/o method of specific testing system
#endif

using namespace std;

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

    int building[4][3][10];
    memset(building, 0, sizeof(building));
    int n;
    cin >> n;
    while (n--)
    {
        int b, f, r, v;
        cin >> b >> f >> r >> v;
        building[b - 1][f - 1][r - 1] += v;
    }
    for (int i = 0; i < 4; ++i)
    {
        for (int j = 0; j < 3; ++j)
        {
            for (int k = 0; k < 10; ++k)
            {
                cout << " " << building[i][j][k];
            }
            cout << endl;
        }
        if (i != 3)
            cout << "####################" << endl;
    }

    return 0;
}


Measured memory_bytes: 3156
#include <stdio.h>
#include <algorithm>
using namespace std;
int X, Y;
int n, m, u, v, w, in[2001][2001], cnt[2001];
int main()
{
	scanf("%d%d%d", &n, &X, &Y); X--, Y--;
	for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) if (i - j)in[i][j] = 1e9;
	for (int i = 0; i < n - 1; i++) in[i][i + 1] = in[i + 1][i] = 1;
	for (int i = 0; i < n-1; i++) for (int j = i+1; j < n; j++) in[i][j] = in[j][i] = j - i;
	for (int i = 0; i <= X; i++)for (int j = Y; j < n; j++) {
		in[i][j]-=Y-X-1;
	}
	in[X][Y] = in[Y][X] = 1;
	for (int i = 0; i <= X; i++)for (int j = X + 1; j < Y; j++) {
		in[i][j] = min(in[i][j], in[i][X] + in[X][Y] + in[j][Y]);
	}
	for (int i = X + 1; i < Y; i++)for (int j = Y; j < n; j++) {
		in[i][j] = min(in[i][j], in[X][i] + in[X][Y] + in[Y][j]);
	}

	for (int i = X + 1; i < Y; i++)for (int j = X + 1; j < Y; j++) {
		in[i][j] = min(in[i][j], in[X][i] + in[X][Y] + in[j][Y]);
	}


	for (int i = 0; i < n - 1; i++) for (int j = i + 1; j < n; j++)
		cnt[in[i][j]]++;
	for (int k = 0; k < n - 1; k++)
		printf("%d\n", cnt[k + 1]);
	return 0;
}

Measured memory_bytes: 15872
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mk make_pair
#define pp pair<ll,ll>
#define inf 1e9
using namespace std;

const int N=200005; 

vector<int> a[N];
 
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
    int n,m;
    cin>>n>>m;
    
    for(int i=0;i<m;i++)
    {
        int x,y;
        cin>>x>>y;
        a[x].pb(y);
        a[y].pb(x);
    }
    

    for(int i=2;i<n;i++)
    {
        int flg=0;
        for(int j=0;j<a[i].size();j++)
        {
            if(a[i][j]==1||a[i][j]==n)
            flg++;
        }
        
        if(flg==2)
        {
            cout<<"POSSIBLE\n";
            return 0;
        }
        
    }
    
    cout<<"IMPOSSIBLE\n";
    return 0;
} 

Measured memory_bytes: 12016
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) cerr << #x << "=" << static_cast<bitset<16> >(x) << endl;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)

const int INF = 10000000;
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};
using namespace std;
typedef long long  ll;
typedef pair<int, int> P;

/** Problem2000 : Misterious Gems **/
int main()
{
	P now;
	map<P, bool> gems;
	int N, M, got;
	
	while (cin>>N, N) {
		now = P(10, 10);
		got=0;
		gems.clear();
		rep(i, N) {
			int x, y;
			cin >> x >> y;
			gems[P(x, y)] = true;
		}
		cin >> M;
		rep(i, M) {
			char d; int a, dx=0, dy=0;
			cin >> d >> a;
			switch (d) {
				case 'N': dy=1; break;
				case 'E': dx=1; break;
				case 'S': dy=-1; break;
				case 'W': dx=-1; break;
			}
			rep(j, a) {
				now.first += dx;
				now.second += dy;
				
				if (gems[P(now.first, now.second)]) {
					got++;
					gems[P(now.first, now.second)] = false;
				}
			}
		}
		if (got==N)
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}
}

Measured memory_bytes: 1196
Y,X=map(int,input().split())
info=[]
for i in range(Y):
    line=list(input())
    info.append(line)
ans=0
def bfs(y,x):
    global nex
    global ok
    global visited
    if not((0<=y<Y) and (0<=x<X)):
        return
    if visited[y][x]==1 or info[y][x]=="#":
        return
    visited[y][x]=1
    ok+=1
    nex.append([y,x])
#各地点から幅優先探索をして、一番深いところにいけたら答え。
for i in range(Y):
    for j in range(X):
        if info[i][j]=="#":
            continue
        visited=[[0 for a in range(X)] for b in range(Y)] #訪れたことあるか
        visited[i][j]=1
        nex=[[i,j]]
        farthest=0 #一番遠い手数
        num=1 #次にスタートにする数
        while num>0:
            ok=0
            for k in range(num):
                bfs(nex[0][0]+1,nex[0][1])
                bfs(nex[0][0]-1,nex[0][1])
                bfs(nex[0][0],nex[0][1]+1)
                bfs(nex[0][0],nex[0][1]-1)
                del nex[0]
            if ok!=0:
                farthest+=1
            num=len(nex)
        if ans<farthest:
            ans=farthest
print(ans)

Measured memory_bytes: 3188
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<queue>
#include<string.h>
using namespace std;
int n,a[200005],fa[46][200005],u,l[200005],p[200005],s[200005],ins[200005],top,i,j;
long long k,leng[46][200005];
int main()
{
	scanf("%d",&n);
	cin>>k;
	for(i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		if(l[a[i]]==0)
			l[a[i]]=i;
		if(i==n)
			leng[0][p[a[i]]]++;
		fa[0][p[a[i]]]=i%n+1;
		p[a[i]]=i;
	}
	for(i=1;i<=n;i++)
		if(fa[0][i]==0)
		{
			fa[0][i]=l[a[i]]%n+1;
			leng[0][i]=1;
			if(l[a[i]]==n)
				leng[0][i]++;
		}
	for(i=1;i<=45;i++)
		for(j=1;j<=n;j++)
		{
			fa[i][j]=fa[i-1][fa[i-1][j]];
			leng[i][j]=leng[i-1][j]+leng[i-1][fa[i-1][j]];
		}
	u=1;
	for(i=45;i>=0;i--)
		while(k>leng[i][u])
		{
			k-=leng[i][u];
			u=fa[i][u];
		}
	while(1)
	{
		if(u>n)
		{
			u=1;
			k--;
		}
		if(k==0)
			break;
		if(ins[a[u]])
			while(ins[a[u]])
			{
				ins[s[top]]=0;
				top--;
			}
		else
		{
			s[++top]=a[u];
			ins[a[u]]=1;
		}
		u++;
	}
	for(i=1;i<=top;i++)
		printf("%d ",s[i]);
}


Measured memory_bytes: 113280
import sys
import math

H = int(input())
count = 0

if not 1 <= H or not H <= 10**12:
    print("error:1≤H≤10^12である必要があります")
    sys.exit()

while True:
    if H <= 0:
        break
    H = math.floor(H / 2)
    count = 1 + 2*count
print(count)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 200000 + 10;

int n, a[maxn], pos[maxn];

inline void fail() {
	puts("-1");
	exit(0);
}

int main() {
	scanf("%d", &n);
//	puts("-1");
//	return 0;
	for(int i = 1;i <= n;i ++) scanf("%d", &a[i]);
	if(a[1] != 0) fail();
	ll Ans = 0;
	for(int i = 1;i <= n;i ++) if(a[i] > 0) Ans ++;
	for(int i = 1;i < n;i ++) {
    if(a[i + 1] > a[i] + 1) fail();
		if(a[i + 1] <= a[i]) Ans += max(0,a[i + 1] - 1);
	}
	/*
	a[n + 1] = -1;
	for(int i = n;i >= 2;i --) {
		if(a[i + 1] != a[i] + 1) Ans += a[i];
	}
	*/
	printf("%lld\n", Ans);
	return 0;
}


Measured memory_bytes: 1024
// https://atcoder.jp/contests/apc001/tasks/apc001_b

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

void solve() {
  ll N;
  cin >> N;

  VL as(N);
  rep(i, N) cin >> as[i];

  VL bs(N);
  rep(i, N) cin >> bs[i];

  ll a_can_be_used = 0;
  ll b_must_be_used = 0;

  rep(i, N) {
    if (as[i] <= bs[i]) {
      a_can_be_used += (bs[i] - as[i]) / 2;
    } else {
      b_must_be_used += as[i] - bs[i];
    }
  }

  if (a_can_be_used >= b_must_be_used) drop("Yes");
  drop("No");
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

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

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

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;

int main(void) {
    string s;
    cin>>s;
    vector<int> l;
    int n = s.size();
    int res[n]={};
    int cnt=0,cur=0,cnt2=0;
    int point;
    while(true){
        cnt=0;
        while(cur<n&&s[cur]=='R'){
            cnt++;
            cur++;
        }
        point = cur;
        cur++;
        while(cur<n&&s[cur]=='L'){
            cnt2++;
            cur++;
        }
        res[point-1]=cnt/2+cnt%2+cnt2/2+cnt2%2;
        res[point]=cnt/2+cnt2/2+1;
        cnt=0;cnt2=0;
        if(cur>=n){break;}
    }
    rep(i,n){
        cout << res[i];
        if(i==n-1){cout << endl;}
        else{cout << " ";}
    }
    return 0;
}


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

int main(){
    string s;cin>>s;
    int k; cin>>k;
    int l=s.size();
    
    ll ans = 1;
    rep(i,k)ans *= 9*(l-1-i);
    rep(i,k)ans /= i+1;
    
    string t(l, '0');
    
    //1~l-1桁目からk-1個選ぶ->1~9を当てはめる
    if(k==1){
        for(int i=1; i<10; i++){
            t[0] = (char)i+'0';
            if(t<=s)ans++;
            t[0] = '0';
        }
        cout << ans << endl;
    }else if(k==2){
        for(int i=1; i<10; i++){
            t[0] = (char)i+'0';
            for(int j=1; j<l; j++){
                for(int dj=1; dj<10; dj++){
                    t[j] = (char)dj+'0';
                    if(t<=s)ans++;
                    t[j] = '0';
                }
            }
            t[0] = '0';
        }
        cout << ans << endl;
    }else{
        for(int i=1; i<10; i++){
            t[0] = (char)i+'0';
            for(int j=1; j<l; j++){
                for(int dj=1; dj<10; dj++){
                    t[j] = (char)dj+'0';
                    for(int q=j+1; q<l; q++){
                        for(int dq=1; dq<10; dq++){
                            t[q] = (char)dq+'0';
                            if(t<=s)ans++;
                            t[q] = '0';
                        }
                    }
                    t[j] = '0';
                }
            }
            t[0] = '0';
        }
        cout << ans << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3624
using System;
using System.Linq;
using System.Collections.Generic;

namespace AtCoder.Contests.AGC041
{
    /// <summary>
    /// 
    /// </summary>
    static class A
    {
        static void Main(string[] args)
        {
            var n = NextLong();
            var a = NextLong();
            var b = NextLong();

            if ((b - a) % 2 == 0)
            {
                Console.WriteLine((b - a) / 2);
                return;
            }

            Console.WriteLine(Math.Min(a +(b - a - 1) / 2, (n - b + 1) + (b - a - 1) / 2));
        }

        #region Console
        static int _index = 0;
        static string[] _buffer;

        static string Next()
        {
            if (_buffer == null || _index >= _buffer.Length)
            {
                _buffer = Console.ReadLine().Split();
                _index = 0;
            }

            return _buffer[_index++];
        }
        static int NextInt()
        {
            return int.Parse(Next());
        }
        static long NextLong()
        {
            return long.Parse(Next());
        }
        static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }
        static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }
        static int[] ReadIntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }
        static int[] ReadIntArray(int n)
        {
            var a = new int[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = ReadInt();
            }
            return a;
        }
        static long[] ReadLongArray()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }
        static long[] ReadLongArray(int n)
        {
            var a = new long[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = ReadLong();
            }
            return a;
        }
        static List<T> ReadObjects<T>(int n, Func<int[], T> creator)
        {
            var l = new List<T>(n);

            for (int i = 0; i < n; i++)
            {
                var a = ReadIntArray();
                l.Add(creator(a));
            }

            return l;
        }

        static int[,] ReadMatrix(int n, int m)
        {
            var r = new int[n, m];
            for (int i = 0; i < n; i++)
            {
                var a = ReadIntArray();
                for (int j = 0; j < m; j++)
                {
                    r[i, j] = a[j];
                }
            }
            return r;
        }
        #endregion
    }
}


Measured memory_bytes: 11092
n =int(input())
As = list(map(int,input().split()))
judge = False

for i in range(n):
    if As[i] == 0 :
        judge = True

ans = 1
if not judge:
    for i in range(n):
        ans *= As[i]
        if ans > 10**18:
            ans = -1
            break

if judge:
    print(0)
else:
    print(ans)


Measured memory_bytes: 21468
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P) 
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s; }


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

long long sqrt(long long n) {
    long long res = (long long)(pow(n, 1.0/2)) + 10;
    while (res >= 1) {
        if (n/res/res == 0) --res;
        else break;
    }
    return res;
}

long long a, b, c;

int main() {
    //freopen( "/Users/macuser/Dropbox/Contest/input.in", "r", stdin );
    
    while (cin >> a >> b >> c) {
        if (a == 0) break;
        long long han = b*b - a*c*4;
        
        if (han < 0) {
            puts("Impossible");
            continue;
        }
        
        long long sq = sqrt(han);
        if (han != sq*sq) {
            puts("Impossible");
            continue;
        }
            
        pll x[2];
        x[0] = pll(a*2, b+sq), x[1] = pll(a*2, b-sq);
        for (int i = 0; i < 2; ++i) {
            if (x[i].first == 0 && x[i].second == 0) continue;
            long long div = gcd(abs(x[i].first), abs(x[i].second));
            x[i].first /= div, x[i].second /= div;
        }
        sort( x, x+2 );
        cout << x[1].first << " " << x[1].second << " " << x[0].first << " " << x[0].second << endl;
    }
    return 0;
}


Measured memory_bytes: 1224
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) throws Exception {
        Thread thread = new Thread(null, new TaskAdapter(), "", 1 << 27);
        thread.start();
        thread.join();
    }

    static class TaskAdapter implements Runnable {
        @Override
        public void run() {
            InputStream inputStream = System.in;
            OutputStream outputStream = System.out;
            FastReader in = new FastReader(inputStream);
            PrintWriter out = new PrintWriter(outputStream);
            CStep solver = new CStep();
            solver.solve(1, in, out);
            out.close();
        }
    }

    static class CStep {
        public void solve(int testNumber, FastReader s, PrintWriter w) {
            int n = s.nextInt();
            int[] a = new int[n];
            int cur = 0;
            long res = 0;
            int max = 0;
            for (int i = 0; i < n; i++) {
                a[i] = s.nextInt();
                res += Math.max(0, max - a[i]);
                max = Math.max(max, a[i]);
            }
            w.println(res);
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {

            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {

                curChar = 0;

                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }

            return buf[curChar++];
        }

        public int nextInt() {

            int c = read();

            while (isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-') {
                sgn = -1;
                c = read();
            }

            int res = 0;

            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();

                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));

            return res * sgn;
        }

        public boolean isSpaceChar(int c) {

            if (filter != null)
                return filter.isSpaceChar(c);

            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 34764