akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll          long long int
#define ld          double
#define pb          push_back
#define mp          make_pair
#define ff          first
#define se          second
#define endl        '\n'
#define fd(n)       fixed<<setprecision(n)
#define MAX         1000000000000000000
#define MAXN        200005
#define LOG         20
#define mod         1000000007
using namespace std;
 
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m,i,flag,sum,x;
    string s;
    cin>>n>>m;
    vector<string> vi[n+1];
    for(i=0;i<m;i++){
        cin>>x>>s;
        vi[x].pb(s);
    }
    ll a[n+1],b[n+1];
    memset(a,0,sizeof(a));
    memset(b,0,sizeof(b));
    for(i=1;i<=n;i++){
        if(vi[i].size()>0){
            flag=0;
            for(auto x:vi[i]){
                if(x=="AC"){
                    flag=1;
                }
            }
            if(flag==1){
                a[i]++;
                for(auto x:vi[i]){
                    if(x=="WA"){
                        b[i]++;
                    }
                    else{
                        break;
                    }
                }
            }
        }
    }
    sum=0;
    for(i=1;i<=n;i++){
        sum+=a[i];
    }
    cout<<sum<<" ";
    sum=0;
    for(i=1;i<=n;i++){
        sum+=b[i];
    }
    cout<<sum;
}

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

int main() {
 string s; cin>>s;
  int sizes=s.size();
  int intmaxx=1000;
  int z1pos=0;
  int befpos=0;
  for(int z1=0;z1<=25;z1++){
    int intmax=1000;
    for(int i=0;i<s.size();i++){
      if(s[i]-'a'==z1){z1pos=i;
                   if(intmax==1000)intmax=z1pos;
                   else intmax=max(intmax,z1pos-befpos-1);
                   befpos=z1pos;
     
    
                  }
   
    }
    if(intmax==1000)continue;
    else{
     intmax=max(intmax,sizes-z1pos-1);
         if(z1==0)intmaxx=intmax;
      else intmaxx=min(intmax,intmaxx);
    }
  }
    
  cout<<intmaxx<<endl;
}


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

int main()
{
    int a,b,k;
    cin>>a>>b>>k;
    map<int,bool>m;
    for(int i=a;i<a+k&&i<=b;i++)
    {
        cout<<i<<'\n';
        m[i]=true;
    }
    for(int i=b-k+1;i<=b;i++)
    {
        if(!m[i]&&i>=a)
        cout<<i<<'\n';
    }
    return 0;
}




Measured memory_bytes: 3584
#include<iostream>
#include<cstdio>

using namespace std;

const int maxn=2e6+5;

int h,s[maxn];

void maxheapify(int i)
{
    int l,r,largest=i;
    l=2*i;
    r=2*i+1;
    if(l<=h&&s[l]>s[i]){
        largest=l;
    }
    if(r<=h&&s[r]>s[largest]){
        largest=r;
    }
    if(largest!=i){
        swap(s[i],s[largest]);
        maxheapify(largest);
    }
}

int main()
{
    scanf("%d",&h);
    for(int i=1;i<=h;i++){
        scanf("%d",&s[i]);
    }
    for(int i=h/2;i>=1;i--){
        maxheapify(i);
    }
    for(int i=1;i<=h;i++){
        cout<<" "<<s[i];
    }
    cout<<endl;
    return 0;
}
/*
10
4 1 3 2 16 9 10 14 8 7
*/



Measured memory_bytes: 5084
#include<stdio.h>

int main(void){
  int N,i,m;
  scanf("%d", &N);
  int taco[N+1];
  for(i=0; i<N; i++){
    scanf("%d", &taco[i]);
  }
  
  int count=0;
  for(i=0; i<N;i++){
    for(m=i+1; m<N; m++){
      count += taco[i]*taco[m];
    }
  }
  
  printf("%d\n", count);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>

using namespace std;

struct node {
    int id;
    node *left;
    node *right;
    node *parent;

    node() {
        left = right = parent = nullptr;
    }

    node *getRoot() {
        return parent == nullptr ? this : this->parent->getRoot();
    }
};

void walkPreOrder(node *cur) {
    if (cur == nullptr) return;
    printf(" %d", cur->id);
    walkPreOrder(cur->left);
    walkPreOrder(cur->right);
}

void walkInOrder(node *cur) {
    if (cur == nullptr) return;
    walkInOrder(cur->left);
    printf(" %d", cur->id);
    walkInOrder(cur->right);
}

void walkPostOrder(node *cur) {
    if (cur == nullptr) return;
    walkPostOrder(cur->left);
    walkPostOrder(cur->right);
    printf(" %d", cur->id);
}

int main() {
    int n, id, left, right;
    cin >> n;
    vector<node> tree(n);
    for (int i = 0; i < n; ++i) {
        cin >> id >> left >> right;
        tree[id].id = id;
        if (left != -1) {
            tree[id].left = &tree[left];
            tree[left].parent = &tree[id];
        }
        if (right != -1) {
            tree[id].right = &tree[right];
            tree[right].parent = &tree[id];
        }
    }
    node *root = tree[0].getRoot();
    cout << "Preorder" << endl;
    walkPreOrder(root);
    cout << endl;
    cout << "Inorder" << endl;
    walkInOrder(root);
    cout << endl;
    cout << "Postorder" << endl;
    walkPostOrder(root);
    cout << endl;
    return 0;
}



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

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

inline int in() { int x; std::scanf("%d", &x); return x; }
inline void pr(int x, char c=10){ std::printf("%d%c", x, c); }

using ll = long long;

using namespace std;

int C[20];
int X[20200];
ll dp[20200][256];
int N, M;

ll inf = 1e18;

signed main() {
    while (N = in(), M = in()) {
        rep(i, M) C[i] = in();
        rep(i, N) X[i] = in();
        rep(i, N + 1) rep(j, 256) dp[i][j] = inf;
        dp[0][128] = 0;
        rep(i, N) rep(j, 256) {
            if (dp[i][j] == inf) continue;
            rep(k, M) {
                const int nxt = max(min(255, j + C[k]), 0);
                ll& d = dp[i + 1][nxt];
                int c = (X[i] - nxt);
                if (dp[i][j] + c * c < d) {
                    d = dp[i][j] + c * c;
                }
            }
        }
        pr(*min_element(dp[N], dp[N] + 256));
    }

    return 0;
}

Measured memory_bytes: 43232
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);cout<<"\n";};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T> vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts> auto make_v(size_t a,Ts... ts){   return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){ for(auto &e:t) fill_v(e,v); }
template<typename T,typename U,typename... V> typename enable_if<is_same<T, U>::value!=0>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V> typename enable_if<is_same<T, U>::value==0>::type fill_v(U &u,const V... v){ for(auto &e:u) fill_v<T>(e,v...);}
//FUNCTION

//BELOW
void solve(void)
{ 
  int N;
  cin>>N;
  vector<int> vec(N+1);
  int SUM = 0;
  for (int i = 0; i < N; i++)
  {
    cin>>vec[i+1];
    SUM += vec[i+1];
    vec[i+1] += vec[i];
  }
  int ANS = INF;
  for (int i = 1; i < N; i++)
  {
    chmin(ANS,abs(SUM - 2* vec[i]));
  }
  cout<<ANS<<endl;

  
  return;
}
  
int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define pb push_back
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

struct edge{
    int to,cap,cost,rev;
    edge(int to,int cap,int cost,int rev):to(to),cap(cap),cost(cost),rev(rev){}
};

const int INF=1001001001;
const int MAX_V=300;
int src=MAX_V-2,snk=MAX_V-1;

vector<edge>G[MAX_V];
int dist[MAX_V];
int prevv[MAX_V],preve[MAX_V];

void add_edge(int from,int to,int cap,int cost){
    G[from].pb(edge(to,cap,cost,G[to].size()));
    G[to].pb(edge(from,0,-cost,G[from].size()-1));
}

int min_cost_flow(int s,int t,int f){
    int res=0;
    while(f>0){
        fill(dist,dist+MAX_V,INF);
        dist[s]=0;
        bool update=true;
        while(update){
            update=false;
            for(int v=0;v<MAX_V;v++){
                if(dist[v]==INF)continue;
                for(int i=0;i<G[v].size();i++){
                    edge &e=G[v][i];
                    if(e.cap>0&&dist[e.to]>dist[v]+e.cost){
                        dist[e.to]=dist[v]+e.cost;
                        prevv[e.to]=v;
                        preve[e.to]=i;
                        update=true;
                    }
                }
            }
        }
        if(dist[t]==INF)return -1;

        int d=f;
        for(int v=t;v!=s;v=prevv[v]){
            d=min(d,G[prevv[v]][preve[v]].cap);
        }
        f-=d;
        res+=d*dist[t];
        for(int v=t;v!=s;v=prevv[v]){
            edge &e=G[prevv[v]][preve[v]];
            e.cap-=d;
            G[v][e.rev].cap+=d;
        }
    }
    return res;
}

const int C=100000;
int N,M,K;
int a[111],b[111][111];
int T[111];

signed main(){
    cin>>N>>M>>K;
    K=N-K;
    rep(i,N)cin>>a[i];
    rep(i,M)rep(j,N)cin>>b[i][j];
    rep(i,M)cin>>T[i];

    add_edge(src,snk,K,C);

    rep(i,M)add_edge(src,i,T[i],0);
    rep(i,M)rep(j,N){
        int tmp=b[i][j]-a[j];
        add_edge(i,j+M,1,C-tmp);
    }
    rep(j,N)add_edge(j+M,snk,1,0);

    int ans=min_cost_flow(src,snk,K);
    cout<<-ans+K*C+accumulate(a,a+N,0ll)<<endl;
    return 0;
}

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

int N;
int A[100000];

void all_minus(){
  int M = A[N - 1];
  for(int i = 0; i < N - 1; i++){
    M -= A[i];
  }
  cout << M << endl;
  int left = A[N - 1];
  for(int i = 0; i < N - 1; i++){
    cout << left << ' ' << A[i] << endl;
    left -= A[i];
  }
}

void all_plus(){
  int M = -A[0];
  for(int i = 1; i < N; i++){
    M += A[i];
  }
  cout << M << endl;
  int left = A[0];
  for(int i = 1; i < N - 1; i++){
    cout << left << ' ' << A[i] << endl;
    left -= A[i];
  }
  cout << A[N - 1] << ' ' << left << endl;
};

void mixed(){
  int M = 0;
  for(int i = 0; i < N; i++){
    M += abs(A[i]);
  }
  cout << M << endl;

  int left1 = A[N - 1];
  for(int i = 1; i < N - 1 && A[i] <= 0; i++){
    cout << left1 << ' ' << A[i] << endl;
    left1 -= A[i];
  }

  int left2 = A[0];
  for(int i = N - 2; i > 0 && A[i] > 0; i--){
    cout << left2 << ' ' << A[i] << endl;
    left2 -= A[i];
  }

  cout << left1 << ' ' << left2 << endl;
}

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

  sort(A, A + N);

  if(A[N - 1] <= 0){
    all_minus();
  }else if(A[0] >= 0){
    all_plus();
  }else{
    mixed();
  }
}



Measured memory_bytes: 2304
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>

#define MOD 1e9+7;
#define INF 1e17+9;
#define PI acos(-1);

using namespace std;

int main(){
	long long a,b,c,k;
	cin >> a >> b >> c >> k;
	long long cnt=0,ans;
	if(k%2==1)ans=-a+b;
	else ans=a-b;
	if(ans>=1e18){
		cout << "unfair" << endl;
		return 0;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class B
{
	public static void Main() => (new Solver()).Solve();
}


public class Solver
{
	public void Solve()
	{
		long mod = 998244353;
		int N = GetInt();
		int[] D = GetInts(N);

		if(D[0] != 0)
		{
			Console.WriteLine(0);
			return;
		}
		else if(D.Count(x => (x > 0)) != N - 1)
		{
			Console.WriteLine(0);
			return;
		}

		var dict = new Dictionary<int, long>();
		for(int i = 0; i < N; i++)
		{
			long c = 0;
			dict.TryGetValue(D[i], out c);
			dict[D[i]] = c + 1;
		}

		var mct = new ModCombTable((int)(1e5) + 1, mod);
		int max = D.Max();
		long ans = 1;
		for(int i = 1; i < max; i++)
		{
			long p = 0;
			dict.TryGetValue(i, out p);

			long c = 0;
			dict.TryGetValue(i + 1, out c);

			if(p * c == 0)
			{
				ans = 0;
				break;
			}

			ans = (ans * mct.ModPow(p, c)) % mod;
		}

		Console.WriteLine(ans);
	}
}

public class ModCombTable
{
	private long[] f = null;
	private long[] fInv = null;
	private long mod;

	public ModCombTable(int N, long m)
	{
		mod = m;

		// calc factorial
		f = new long[N+1];
		f[0] = 1;
		for(int i = 1; i <= N; i++)
			f[i] = (f[i-1] * i) % mod;

		// calc factorial inverse
		fInv = new long[N+1];
		fInv[N] = ModInv(f[N]);
		for(int i = N; i > 0; i--)
			fInv[i-1] = (fInv[i] * i) % mod;
	}

	public long ModComb(long n, long k)
	{
		if(n < 0 || n < k)
			return 0;
		
		return (((f[n] * fInv[k]) % mod) * fInv[n-k]) % mod;
	}

	public long ModInv(long x)
	{
		return ModPow(x, mod - 2);
	}

	public long ModPow(long x, long n)
	{
		long res = 1;
		while(n > 0)
		{
			if((n & 1) == 1)
				res = (res * x) % mod;
			x = (x * x) % mod;
			n >>= 1;
		}
		return res;
	}
}

public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(int N) => Enumerable.Range(0, N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(int N) => Enumerable.Range(0, N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(int N) => Enumerable.Range(0, N).Select(_ => GetDouble()).ToArray();
	public static string[] GetStrings(int N) => Enumerable.Range(0, N).Select(_ => GetString()).ToArray();
}


Measured memory_bytes: 30944
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll a,p;
    cin>>a>>p;
    a=3*a;
    a+=p;
    cout<<a/2<<endl;
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
#ABC136 C

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
h = LI()
ma = 0
for i in range(n):
    if ma < h[i]:
        ma = h[i]
    elif ma > h[i] + 1:
        print('No')
        quit()
print('Yes')


Measured memory_bytes: 59632
#include <iostream>
using namespace std;
int arr[1000005] = {0};
int main()
{
    int n;
    long long res = 0;
    cin >> n;
    for (int i = 1; i < n; ++i)
    {
        for (int j = i; j <= n; j += i)
        {
            ++arr[j];
        }
        res += arr[i];
    }
    cout << res;
}

Measured memory_bytes: 7472
N=int(input())
a=[]
b=0
for i in range(N):
	a.append(input())
d={}
sor={}
for i in range(N):
    if a[i] in d.keys():
        d[a[i]]+=1
    else:
        d.setdefault(a[i],1)
        b+=1
sod = sorted(d.keys())
#max=sod["a[0]"]
maxval=0
for i in range(N):
    if maxval<=d[a[i]]:
        maxval=d[a[i]]
for i in range(b):
    if maxval==d[sod[i]]:
        print(sod[i])

Measured memory_bytes: 35220
K, S = map(int, input().split())
ans = 0

for x in range(K+1):
    for y in range(K+1):
        z = S - (x+y)
        if(0<=z and z<=K):
            if(x == y and y == z):
                ans += 1
            elif(x != y and y != z and z != x):
                ans += 1
            else:
                ans += 1
                
                
                
print(ans)

Measured memory_bytes: 9112
#include <stdio.h>
#define MAX 100

int count = 0;

void print_array(int *A, int N) {
  int i;
  for(i = 0; i < N - 1; i++) {
    printf("%d ", A[i]);
  }
  printf("%d\n", A[i]);
}


void bubbleSort(int *A, int N) {
  int j, v, frag = 1;
  while(frag) {
    frag = 0;
    for(j = N - 1; j >= 1; j--) {
      if(A[j] < A[j-1]) {
	v = A[j];
	A[j] = A[j-1];
	A[j-1] = v;
	frag = 1;
	count++;
      }
    }
  }
}

int main() {
  int n, i, a[MAX];
  scanf("%d", &n);
  for(i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  bubbleSort(a, n);
  print_array(a, n);
  printf("%d\n", count);
}



Measured memory_bytes: 1968
package main

import (
	"fmt"
	"math"
)

func main() {
	var A, B, K int
	fmt.Scan(&A, &B, &K)

	for i := A; i <= min(B, A+K-1); i++ {
		fmt.Println(i)
	}
	for i := max(B-K+1, A); i <= B; i++ {
		if A+K-1 < i {
			fmt.Println(i)
		}
	}
}

/*  ----------------------------------------  */

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}

func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }

type SortBy []int

func (a SortBy) Len() int           { return len(a) }
func (a SortBy) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool { return abs(a[i]) > abs(a[j]) }


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

int main() {
  int N;
  cin >> N;
  
  int P[N];
  int Q[N];
  int a[N];
  for (int i = 0; i < N; i++) {
    cin >> P[i];
    a[i] = i + 1;
  }
  
  for (int i = 0; i < N; i++) {
    cin >> Q[i];
  }
  
  int p, q;
  int count = 0;
  do {
    count++;
    for (int i = 0; i < N; i++) {
      if (a[i]!=P[i]) {
        break;
      }
      if (i == N-1) {
        p = count;
      }
    }
    for (int i = 0; i < N; i++) {
      if (a[i]!=Q[i]) {
        break;
      }
      if (i == N-1) {
        q = count;
      }
    }
  } while(next_permutation(a, a+N));

  cout << abs(p-q) << endl;
}

Measured memory_bytes: 256
# include <bits/stdc++.h>
# define pf push_front
# define pb push_back
# define mp make_pair
# define pr printf
# define se second
# define si size()
# define sc scanf
# define fi first
# define er erase
# define be begin
# define ss size
# define Int __int64
# define INF 100000000000000008
# define MOD 1000000007
# define MN 500500
# define eps 0.0000000000000000018
# define mem(a) memset(a,0,sizeof(a))
# define cpy(b,a) memcpy(b,a,sizeof(a))
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	int n,i,mini(MOD),maxi(0);
	cin>>n;
	int a[n];
	for(i=0;i<n;i++){
	cin>>a[i];
	mini=min(mini,a[i]);
	maxi=max(maxi,a[i]);
	}
	cout<<maxi-mini;
	return 0;
}
/* and its only us now */


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

int main() {
  int a, b, k;
  cin >> a >> b >> k;
  int cnt = 0;
  vector<int> v;
  for (int i = 1; i <= min(a, b); i++) {
    if (a % i == 0 && b % i == 0) {
      cnt++;
      v.push_back(i);
    }
  }
  cout << v.at(v.size() - k) << endl;
  return 0;
}

Measured memory_bytes: 3604
k,n=map(int,input().split())
A=list(map(int,input().split()))
head=A[0]
for i in range(n-1):
    A[i]=A[i+1]-A[i]
A[n-1]=k-A[n-1]+head
ma=int(0)
ans=int(0)
for i in range(n):
    ans+=A[i]
    if ma<A[i]:
        ma=A[i]
print(ans-ma)

Measured memory_bytes: 25968
#include<stdio.h>

int main(){
  int i,j,n,n2,n3,n4[101][101],n5[101];

		      scanf("%d",&n);
		      for(i=1;i<=n;i++){
			for(j=1;j<=n;j++){
			  n4[i][j]=0; }}

		      for(i=1;i<=n;i++){
			scanf("%d",&n5[i]);
			scanf("%d",&n2);



			if(n2==0)continue;

			else{
			  for(j=0;j<n2;j++){
			    scanf("%d",&n3);
			    n4[i][n3]=1; }}
		      }

		      for(i=1;i<=n;i++){
			for(j=1;j<n;j++){
			  printf("%d ",n4[i][j]);}
			printf("%d\n",n4[i][n]);}

		      return 0;

		      }

Measured memory_bytes: 636
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>
#include <iomanip>
#include <unordered_map>
#include <map>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
typedef long double ld;
const char sp = ' ';

using namespace boost::multiprecision;
using namespace std;

int main(void){
    ll A, B, C, D;
    cin>>A>>B>>C>>D;
    if(A+B>C+D) cout<<"Left"<<endl;
    else if(A+B==C+D) cout<<"Balanced"<<endl;
    else cout<<"Right"<<endl;
    return 0;
}


Measured memory_bytes: 3600
L, R = map(int, input().split())

if R - L >= 2019:
    print(0)

else:
    l = L % 2019
    r = R % 2019
    if r<l:
        print(0)
    else:
        klist = []
        for i in range(r-l):
            for j in range(r-l-i):
                k = (i+l)*(l+i+j+1)%2019
                klist.append(k)
        klist.sort()
        print(klist[0])

Measured memory_bytes: 81416
sx,sy,tx,ty = map(int,input().split())
route = ""

#1回目行き
for i in range(tx-sx):
    route += "R"

for i in range(ty-sy):
    route += "U"

#1回目戻り
for i in range(abs(sx-tx)):
    route += "L"

for i in range(abs(sy-ty)):
    route += "D"

#2回め行き
route += "D"
for i in range((tx+1)-sx):
    route += "R"

for i in range(ty-(sy-1)):
    route += "U"

route += "L"

#2回め戻り
route += "U"
for i in range(abs((sx-1)-tx)):
    route += "L"

for i in range(abs(sy-(ty+1))):
    route += "D"

route += "R"

print(route)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string.h>
using namespace std;

int main(void) {
	int N, maxh, *mountains, answer = 1;
	scanf("%d", &N);
	mountains = (int *)malloc(sizeof(int));
	for (int i = 0; i < N; i++) {
		scanf("%d", mountains + i);
		if (!i) {
			maxh = mountains[0];
		}
		else {
			if (mountains[i] >= maxh) {
				answer++;
				maxh = mountains[i];
			}
		}
	}
	printf("%d", answer);
	return 0;
}

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

int main()
{
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  int sum = 0;
  for (int i = 0; i < n; i++)
  {
    cin >> a[i];
    sum += a[i];
  }
  int ans = 0;
  for (int i = 0; i < n; i++)
  {
    if (a[i] >= (double)sum / (4 * m))
    {
      ans++;
    }
  }
  if (ans >= m)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3628
import numpy as np
N = int(input())
A = list(map(int, input().split()))
A = np.array(A, dtype = 'int64')
k = np.where(A < 0)
l = len(k[0])
A = np.abs(A)
if l % 2 == 0:
    print(np.sum(A))
else:
    print(np.sum(A) - 2 * np.min(A))

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

using namespace std;

#define REP(i, n)   for(int i = 0; i < (n); i++)
#define REPS(i, n)  for(int i = 1; i <= (n); i++)
#define RREP(i, n)  for(int i = (n)-1; i >= 0; i--)
#define RREPS(i, n) for(int i = (n); i > 0; i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define mt make_tuple
#define pb push_back

using ll  = long long;
using pi  = pair<int, int>;
using pl  = pair<ll, ll>;
using vi  = vector<int>;
using vl  = vector<ll>;
using vs  = vector<string>;
using vb  = vector<bool>;
using vvi = vector<vi>;
using vvl = vector<vl>;

const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const ll  INFL = 1e18;
const double PI = 3.141592653589793;
const double EPS = 1e-9;

template<class T> bool chmax(T &a, const T &b) { if(a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if(a > b) { a = b; return true; } return false; }

ll modpow(ll a, ll x)
{
    ll res = 1;
    while(x > 0)
    {
        if(x & 1) res = res * a % MOD;
        a = a * a % MOD;
        x >>= 1;
    }
    return res;
}

ll modinv(ll a)
{
    return modpow(a, MOD-2);
}

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    ll H, W, A, B; cin >> H >> W >> A >> B;
    ll ans = 0;

    ll fact[200010];
    fact[0] = 1;
    for(ll i = 1; i < 200010; i++) fact[i] = (fact[i-1] * i) % MOD;
    
    REPS(i, H-A)
    {
        // (i+B)! / i!B! * (H-i+W-B)! / (H-i)!(W-B)!
        ans += fact[i-1+B-1] % MOD * modinv((fact[i-1] * fact[B-1]) % MOD) % MOD * fact[H-i+W-B-1] % MOD * modinv(fact[H-i] * fact[W-B-1] % MOD) % MOD;
        ans %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 5268
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
#include <cassert>

using namespace std;

/* template */

using ll = long long;

void debug_out() { std::cout << std::endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif

#define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define rrep(i, a, n) for (int i = ((int)(n-1)); i >= (int)(a); i--)
#define Rep(i, a, n) for (long long i = (long long)(a); i< (long long)(n); i++)
#define RRep(i, a, n) for (long long i = ((long long)(n-1ll)); i>=(long long)(a); i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

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

struct Edge{
    int to;
    ll weight;
    Edge(int t, ll w) : to(t), weight(w){ }
};

struct edge{
    int from;
    int to;
    ll weight;
    edge(int f,int t,ll w) : from(f), to(t), weight(w){ }
};


using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;

template <class T>
inline bool chmin(T &a, T b){
    if (a > b){
        a = b;
        return true;
    }
    return false;
}

template <class T>
inline bool chmax(T &a, T b){
    if (a < b){
        a = b;
        return true;
    }
    return false;
}

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

bool isPalindrome(string s){
    string t = s;
    reverse(all(t));
    return s==t;
}

constexpr ll LNF = __LONG_LONG_MAX__;

constexpr int INF = 1e9+7;

const double PI=3.14159265358979323846;


vector<int> dx = {-1,0,1,0,-1,1,-1,1};
vector<int> dy = {0,-1,0,1,1,-1,-1,1};

/* template */

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,a; cin >> n >> a;
    vector<int> x(n);
    int m = 0;
    rep(i,0,n){
        cin >> x[i];
        chmax(m,x[i]);
    }
    m *= n;
    vector<vector<ll>> dp(n+1,vector<ll>(m+1,0));
    dp[0][0] = 1ll;
    rep(i,0,n){
        rrep(j,0,i+1){
            rep(k,0,m+1){
                if(k+x[i]>m) continue;
                dp[j+1][k+x[i]] += dp[j][k];
            }
        }
    }
    ll ans = 0;
    rep(i,1,n+1){
        if(i*a>m) break;
        ans += dp[i][i*a];    
    }
    cout << ans << endl;
}

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


int main(void) {
	vector<int> col1(3);
	vector<int> col2(3);
	vector<int> col3(3);
	bool flag = true;

	for (int i = 0; i < 3; i++) {
		cin >> col1.at(i) >> col2.at(i) >> col3.at(i);
	}
	for (int i = 0; i < 2; i++) {
		if (col2.at(i) - col1.at(i) != col2.at(i + 1) - col1.at(i + 1)) { flag = false; break; }
		if (col3.at(i) - col1.at(i) != col3.at(i + 1) - col1.at(i + 1)) { flag = false; break; }
	}

	if (flag) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


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

int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  
  if (A + B > C + D) {
    cout << "Left" << endl;
  }
  else if (A + B < C + D) {
    cout << "Right" << endl;
  }
  else {
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define S second
#define F first

using namespace std;

const int N = 1e5 + 15, M = 2 * N;

#define arr(t, n, s, e) t _##n[e-s+1], *n= _##n+(-s);

int head[N], nxt[M], to[M], col[M], deg[N], ne;

void addEdge(int f, int t)
{
    nxt[ne] = head[f];
    to[ne] = t;
    deg[f]++;
    head[f] = ne++;
}

void addBiEdge(int f, int t)
{
    addEdge(f, t);
    addEdge(t, f);
}

void dfs(int u, int prvC = M)
{
    int c = 1;
    for(int e = head[u] ; ~e ; e = nxt[e])
    {
        if(col[e]) continue;
        if(c == prvC) c++;
        int v = to[e];
        col[e] = col[e ^ 1] = c;
        dfs(v, c++);
    }
}

int main()
{
    memset(head, -1, sizeof head);
    int n, t, u, v, mx = 0;
    scanf("%d", &n);
    for(int i = 1 ; i < n ; i++)
    {
        scanf("%d%d", &u, &v);
        addBiEdge(u, v);
        mx = max({mx, deg[u], deg[v]});
    }
    dfs(1);
    printf("%d\n", mx);
    for(int i = 0 ; i < ne ; i += 2)
    {
        printf("%d\n", col[i]);
    }
    return 0;
}

Measured memory_bytes: 10100
package main

import "fmt"

func min(a, b int) int {
	if a >= b {
		return b
	}
	return a
}

func main() {
	var S string
	var n0, n1 int
	fmt.Scan(&S)
	for i := 0; i < len(S); i++ {
		if S[i] == byte('0') {
			n0++
		} else {
			n1++
		}
	}
	fmt.Println(2*min(n0, n1))	
}


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

using namespace std;

#define PI 3.14159265358979323846264338327950L

int main(void){
    int X,Y,tmp;
    bool ans=false;

    cin>>X>>Y;

    for(int t=0;t<=X;t++){
        int k=X-t;

        tmp=2*t + 4*k;
        if(tmp == Y){
            ans=true;
            break;
        }

    }

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


    return 0;
}



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

int main(){
	int n;
	int x;
	cin >> n;
	for (int i = 1; i < n + 1; i++){
		x = i;
		if (x % 3 == 0){
			cout << " " << i;
			continue;
		}
		while (1){
			if (x % 10 == 3){
				cout << " " << i;
				break;
			}
			x /= 10;
			if (x == 0) break;
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 1160
def task(h1, m1, h2, m2, k):
    t1 = h1 * 60 + m1
    t2 = h2 * 60 + m2
    t = t2 - t1
    print(max(0, t - k))
    #print(h1, m1, h2, m2, k)


h1, m1, h2, m2, k = map(int, input().split())
task(h1, m1, h2, m2, k)


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

int main() {

    long long h;

    scanf("%lld", &h);

    long long r = 1;
    while (r*2LL <= h) r*=2LL;
    r = r*2LL - 1;

    printf("%lld\n", r);

    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;

ll gcd(ll x, ll y) {
  if (y == 0) return x;
  return gcd(y, x%y);
}

int main() {
  ll a, b;
  cin >> a >> b;

  ll c = gcd(a, b);

  cout << (a*b)/c << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <cstdio>
#include <cstdlib>
using namespace std;

signed main(){
    cin.tie(0); 
    ios::sync_with_stdio(false);
    int a,b;
    cin >> a >> b;
    cout << 6 - (a + b) << "\n";
    return 0;
}



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

int main()
{
	int n,a,b;
	cin>>n>>a>>b;
	
	int k=a/n;
    if(a%n!=0) k++;    
	if(k*n<=b)
	{
		cout<<"OK\n";
	}
	else
	{
		cout<<"NG\n";
	}
}

Measured memory_bytes: 3640
#include <stdio.h>
#include <string.h>
int main(void){
  char S[105];
  int i,cnt=0;
  if(scanf("%s",&S)<1) return 1;
  for(i=0;i<strlen(S)/2;i++){
    if(S[i]!=S[strlen(S)-i-1]){
      cnt++;
    }
  } 
  printf("%d",cnt);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define INF 999999999
#define rep(i,n) for(int i=0;i<n;i++)
const int MOD = 1000000007;
int h,w;
char table[110][110];
int cnt = 0;

void bfsdot(int y , int x);
void bfssharp(int y,int x);

int main(){
   ll n , k ; cin >> n >> k;

   bool flag=1;
   
   cout << min(n%k,abs( (n%k)-k ) )<< endl;
}



Measured memory_bytes: 256
a,b = gets.chomp.split.map(&:to_i)

dig_2 = Array(a/1000..b/1000)
ans = 0

dig_2.each do |i|
    for j in 0..9
        x = i*1000 + j*100 + i/10+(i%10)*10
        if a <= x and x <= b
            ans +=1
        end
    end
end

p ans

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

using namespace std;
typedef pair<int, int> P;
// input


int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
    int taste, N, L;
    cin >> N >> L;

    if(L < 0 && N + L > 0) taste = 0;
    else if(L < 0) taste = -(L + N - 1);
    else taste = -1*L;
    
    for(int i = L; i < N + L; i++) taste += i;
    cout << taste << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;
const ll MAX = 510010;
const ll MOD = 1000000007;
vector<ll> fac(MAX), finv(MAX), inv(MAX);

//=============modinv============================
void COMinit() {
    fac.at(0) = 1;
    fac.at(1) = 1;
    finv.at(0) = 1;
    finv.at(1) = 1;
    inv.at(1) = 1;
    for (ll i = 2; i < MAX; i++){
        fac.at(i) = fac.at(i - 1) * i % MOD;
        inv.at(i) = MOD - inv.at(MOD % i) * (MOD / i) % MOD;
        finv.at(i) = finv.at(i - 1) * inv.at(i) % MOD;
    }
}

ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac.at(n) * (finv.at(k) * finv.at(n - k) % MOD) % MOD;
}
//=================================================

ll N, K;

int main()
{
  cin >> N >> K;
  COMinit();
  ll M = COM(N + N - 1, N - 1);
  if (K >= N - 1) {
    cout << M << endl;
    return 0;
  }
  ll ans = 1;
  for (ll i = 1; i <= K; ++i) {
    ans = (ans + COM(N, i) * COM(N - 1, i) % MOD) % MOD;
  }
  cout << ans << "\n";
}


Measured memory_bytes: 12160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

#define N 212345
int a[N];
vi v[N];
int b[N];
deque<int> que;
set<int> st;

int main(){
	int n; ll k; scanf("%d%lld", &n, &k);
	REP(i, n){
		scanf("%d", a+i);
		v[a[i]].EB(i);
	}
	for(vi &u: v){
		if(u.empty()) continue;
		u.EB(u[0] + n);
		REP(i, (int)u.size() - 1){
			b[u[i]] = u[i+1] - u[i];
		}
	}
	ll p = 0;
	while(p < n*(k-1)) {
		p += b[p%n] + 1;
		if(p%n == 0) break;
	}
	if(p < n*(k-1)) {
		p = n*(k-1) /p*p;
		while(p < n*(k-1)) {
			p += b[p%n] + 1;
		}
	}
	
	for(ll j = p; j < n*k; j++){
		int i = j % n;
		if(st.find(a[i]) != st.end()){
			while(que.back() != a[i]){
				st.erase(st.find(que.back()));
				que.pop_back();
			}
			st.erase(st.find(que.back()));
			que.pop_back();
		} else {
			st.emplace(a[i]);
			que.emplace_back(a[i]);
		}
	}
	for(int i : que) printf("%d ", i);
}


Measured memory_bytes: 24448
#include <stdio.h>

int main(void) {
	int x1, y1, x2, y2;
	int dx, dy;
	if (scanf("%d%d%d%d", &x1, &y1, &x2, &y2) != 4) return 1;
	dx = x2 - x1;
	dy = y2 - y1;
	printf("%d %d %d %d\n", x2 - dy, y2 + dx, x1 - dy, y1 + dx);
	return 0;
}


Measured memory_bytes: 256
import sys, math
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

N, K = rl()
R, S, P = rl()
T = rs()

scores = {'r':R,'s':S,'p':P}
wins = {'r':'p','s':'r','p':'s'}

score = 0
ans = 0
state = [None]*len(T)
for i in range(N):
	if i < K:
		score += scores[wins[T[i]]]
		state[i] = wins[T[i]]
	else:
		if state[i-K] != wins[T[i]]:
			score += scores[wins[T[i]]]
			state[i] = wins[T[i]]
		else:
			if scores[state[i-K]] < scores[wins[T[i]]]:
				score -= scores[state[i-K]]
				score += scores[wins[T[i]]]
				state[i-K] = '*'
				state[i] = wins[T[i]]
			else:
				state[i] = '*'
print(score)

Measured memory_bytes: 40944
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]
def I(): return int(sys.stdin.buffer.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    a = LI()
    d = defaultdict(lambda : 0)
    for i in a:
        d[i-1] += 1
    for i in range(n):
        print(d[i])
    return

#Solve
if __name__ == "__main__":
    solve()


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

int main(){
    long N,sum = 0;
    cin >> N;

    for(int i = 1;i <= N;i++){
        if(i % 3 != 0 && i % 5 != 0)
            sum += i;
    }
    cout << sum << endl;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define ll long long int
#define pi pair<int,int>
#define eps 0.000000001
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define sz(x) ((int)x.size())
#define ln(x) ((int)x.length())
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define dbg(x) cout<<#x<<" "<<x<<endl
#define clr(x,v) memset(x, v, sizeof(x))
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
const int mod = 1e9 + 7;
const double PI = acos(-1.0);
const int MAXN = 1e6 + 5;

void cp()
{
    int n;
    cin >> n;
    vector<ll> arr(n);
    for(ll &x : arr)
        cin >> x;
    sort(all(arr));
    if(arr[0] == 0)
    {
        cout << 0;
        return;
    }
    long double ans = 1.0;
    for(ll x : arr)
    {
        ans = ans * x;
        if(ans > 1e18)
        {
            cout << -1;
            return;
        }
    }
    cout << (ll)ans;
}

int main()
{
    FASTIO;
    int t;
    t = 1;
    // cin >> t;
    while(t--)
    {
        cp();
    }
    return 0;
}

Measured memory_bytes: 4004
import java.util.*;

public class Main {

	static int mod = 1_000_000_007;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int[] A = new int[N];
		ArrayList<Integer> plus = new ArrayList<Integer>();
		ArrayList<Integer> minus = new ArrayList<Integer>();
		int zero_cnt = 0;
		for (int i=0;i<N;i++) {
			A[i] = sc.nextInt();
			if (A[i]>0) plus.add(A[i]);
			if (A[i]<0) minus.add(-A[i]);
			if (A[i]==0) zero_cnt++;
		}

		if (N==K) {
			long ans = 1L;
			for (int i=0;i<N;i++) {
				long val = A[i];
				if (val<0) {
					val += mod;
				}
				ans = ans*val%mod;
			}
			System.out.println(ans);
			return;
		}

		if (plus.size()==0 && K%2==1) {
			if (zero_cnt>0) {
				System.out.println(0);
				return;
			} else {
				Collections.sort(minus);
				long aaa = 1L;
				for (int i=0;i<K;i++) {
					aaa = aaa*(mod-minus.get(i))%mod;
				}
				System.out.println(aaa);
				return;
			}
		}

		Collections.sort(plus, (o1, o2)->Integer.compare(o2, o1));
		Collections.sort(minus, (o1, o2)->Integer.compare(o2, o1));
		long ans = 1L;
		if (K%2==1) {
			ans = plus.get(0);
			plus.remove(0);
		}
		TreeMap<Long, Integer> map = new TreeMap<Long, Integer>();
		for (int i=0;i<plus.size()/2;i++) {
			long tmp = (long)plus.get(2*i)*plus.get(2*i+1);
			if (map.containsKey(tmp)) {
				map.put(tmp, map.get(tmp)+1);
			} else {
				map.put(tmp, 1);
			}
		}
		for (int i=0;i<minus.size()/2;i++) {
			long tmp = (long)minus.get(2*i)*minus.get(2*i+1);
			if (map.containsKey(tmp)) {
				map.put(tmp, map.get(tmp)+1);
			} else {
				map.put(tmp, 1);
			}
		}
		for (int i=0;i<K/2;i++) {
			if (map.size() == 0) {
				if (zero_cnt>0) System.out.println(0);
				return;
			}
			long last_key = map.lastKey();
			ans = ans*(last_key%mod)%mod;
			if (map.get(last_key)>1) {
				map.put(last_key, map.get(last_key)-1);
			} else {
				map.remove(last_key);
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 67564
H, W = map(int, input().split())
t = []
for _ in range(H):
    x = input()
    if x != '.' * W:
        t += [x]
num = len(t)
k = []
for s in zip(*t):
    s = ''.join(s)
    if s != '.' * num:
        k += [s]
for x in zip(*k):
    print(''.join(x))

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
using namespace std;

#define debug(x) cout<<#x<<": "<<x<<endl
#define rep(i,a,b) for(int i=a;i<b;i++)
#define PB push_back
#define putn(x,n) cout<< fixed<< setprecision(n)<< x << endl;
typedef long long ll;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	rep(i, 0, s.length()){
		if (s[i] == 'C'){
			rep(j, i, s.length()){
				if (s[j] == 'F'){
					cout << "Yes" << endl;
					exit(0);
				}
			}
		}
	}
		cout << "No" << endl;



	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <array>
#include <vector>
#include <utility>
#include <bitset>
#include <queue>

using namespace std;

typedef long long ll;

constexpr ll MAX_N = 300;

ll N, M;
ll A[MAX_N][MAX_N];
ll sports[MAX_N];
ll pointer[MAX_N];

int main(void) {
    cin >> N >> M;

    for (ll n = 0; n < N; n++) {
        for (ll m = 0; m < M; m++) {
            cin >> A[n][m];
            A[n][m]--;
        }
    }

    ll ans = MAX_N;

    while (true) {
        bool end = true;
        for (ll m = 0; m < M; m++) {
            sports[m] = min(sports[m], 0ll);
            if (sports[m] == 0) {
                end = false;
            }
        }

        if (end) {
            cout << ans << endl;
            return 0;
        }

        for (ll n = 0; n < N; n++) {
            while (sports[A[n][pointer[n]]] == -1) {
                pointer[n]++;
            }
            if (pointer[n] < M) {
                sports[A[n][pointer[n]]]++;
            }
        }

        ll ma = -1, idx = -1;
        for (ll m = 0; m < M; m++) {
            if (ma < sports[m]) {
                idx = m;
                ma = sports[m];
            }
        }

        ans = min(ans, ma);
        sports[idx] = -1;
    }
}



Measured memory_bytes: 896
/***********************
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++) 
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

int main()
{
	int a[4];
	rep(i,2) cin>>a[i];
	a[2]=a[0]-1;
	a[3]=a[1]-1;
	sort(a,a+4);
	cout<<a[3]+a[2]<<endl;
	rt0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int,int> Pair;
const int Nmax = 1e5 + 5, Mod = 1e9 + 7;

string S; int i;
int main()
{
   // freopen("input", "r", stdin);
    //freopen("output", "w", stdout);
    cin.sync_with_stdio(false);

    cin >> S;
    for(i=0; i<S.size() - 1; ++i)
    if(S[i] == 'A' && S[i+1] == 'C')
    {
        cout << "Yes\n";
        return 0;
    }

    cout << "No\n";

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include<iostream>
#include<stdio.h>
#include <algorithm>
#include<iostream>
#include<stdio.h>
#include<vector>
#include<set>
#include<string>
#define rep(i,n) for(int i=0; i<(int)n; i++)//n回繰り返す
using namespace std;
using ll = long long;
using P = pair<int, int>; 
int main(){
	int	L; cin >> L;
  double a = (double)L / 3, b = a * a * a;
  printf("%12f\n",b);
	
}

Measured memory_bytes: 256
H,W=map(int,input().split())
t=''
s=[]
for i in range(W+2):
  t+='#'
s.append(t)
for i in range(H):
  a='#'+input()+'#'
  s.append(a)
s.append(t)
for i in range(H+2):
  print(s[i])

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

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

    int A[10100];
    rep (i, 10010) A[i] = 0;
    for (int x=1; x<=100; x++) {
        for (int y=1; y<=100; y++) {
            for (int z=1; z<=100; z++) {
                int s = x*x + y*y + z*z + x*y + y*z + z*x;
                if (s <= 10000) A[s]++;
            }
        }
    }

    for (int i=1; i<=N; i++) {
        cout << A[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 3652
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <set>
#include <iostream>
#include <stack>
#include <vector>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <random>
#include <chrono>
#include <deque>
using namespace std;

int k;

const int maxn = 1e5 + 5;

typedef long long LL;

LL dis[maxn];

void bfs(){
    memset(dis, 0x3f3f3f3f, sizeof(dis));
    dis[1] = 1;
    deque<int> q;
    q.push_back(1);
    while(!q.empty()){
        int p = q.front();q.pop_front();
        int to = (p + 1) % k;
        if(dis[to] > dis[p] + 1){
            dis[to] = dis[p] + 1;
            q.push_back(to);
        }
        to = p * 10 % k;
        if(dis[to] > dis[p]){
            dis[to] = dis[p];
            q.push_front(to);
        }
    }
}

int main(){
    cin >> k;
    bfs(); 
    cout << dis[0] << endl;
    return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cassert>
using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> d(N);
    for(int i=0; i<N; i++) cin >> d[i];
    sort(d.begin(), d.end());
    int x = d[N/2-1];
    int y = d[N/2];
    cout << y - x << endl;
    return 0;
}

Measured memory_bytes: 640