akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

int main(){
	int N,K;
	scanf("%d %d",&N,&K);
	
	int a[N];
	int i;
	for(i = 0;i < N;i++)
		scanf("%d",&a[i]);
		
	//排序
	int j;
	for(i = 0;i < N-1;i++){
		for(j = 0;j < N - i - 1;j++){
			if(a[j] > a[j+1]){
				int temp = a[j];
				a[j] = a[j+1];
				a[j+1] = temp;
			}
		}
	} 
	//然后挨个加 
	int sum = 0;
	i = 0;
	while(K--){
		sum += a[i++];
	}
	
	printf("%d",sum);
	
	return 0;
}

Measured memory_bytes: 1700
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;

int main(void) {
    int N, K;
    cin >> N >> K;
    vector<int> v(N);
    while(K--) {
        int d;
        cin >> d;
        while(d--) {
            int A;
            cin >> A;
            v[--A]++;
        }
    }

    int ans = 0;
    for(auto e: v) {
        if(e == 0) ++ans;
    }

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


Measured memory_bytes: 3628
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
constexpr long long LINF = 1000100010001000100LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
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; }

vector<pair<long long, long long>> prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        while (N % a == 0) {
            ++ex;
            N /= a;
        }
        res.push_back({a, ex});
    }
    if (N != 1) res.push_back({N, 1});
    return res;
}

int main(){ 
    int n; cin >> n;
    map<int, int> sisuu;
    rept(i, 1, n+1){
        vector<pll> tmp = prime_factorize(i);
        for(auto p: tmp){
            sisuu[p.first] += p.second;
        }
    }
    map<int, int>cnt;
    for(auto s: sisuu){
        int num = s.second;
        if(num>=74) cnt[75]++;
        if(num>=24) cnt[25]++;
        if(num>=14) cnt[15]++;
        if(num>=4) cnt[5]++;
        if(num>=2) cnt[3]++;
    }

    ll res = 0;
    res += cnt[75];
    res += cnt[25] * (cnt[3]-1);
    res += cnt[15] * (cnt[5]-1);
    res += cnt[5]*(cnt[5]-1)/2 * (cnt[3]-2);

    cout << res << ln;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
#define endl "\n"
typedef long long ll;
using namespace std;

const int N = 222222;
string s;
ll occ[N];
ll n;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> s;
    n = s.size();
    for(int i = 0; i < n; i++) {
        occ[s[i] - 'a']++;
    }
    ll ans = n * (n + 1) / 2;
    for(int i = 0; i < 26; i++) {
        ans -= occ[i] * (occ[i] + 1) / 2;
    }
    cout << ans + 1 << endl;
    return 0;
}

Measured memory_bytes: 720
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <functional>

using namespace std;
using ll = long long;

#define FOR(i, m, n) for(int i = (m);i < (n);i++)
#define REP(i,n) for(int i = 0; i < int(n); i++)
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VL vector<ll>
#define VVL vector<vector<ll>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define PAIR pair<int,int>
#define MP make_pair
#define VP vector<pair<int,int>>
#define VS vector<string>
#define QUE queue<int>
#define DEQ deque<int>
#define PQUE priority_queue<int> //5,5,4,3,3,2,...
#define REPQUE priority_queue<int, vector<int>, greater<int>> //1,1,2,3,4,4,5,...
#define SUM(obj) accumulate((obj).begin(), (obj).end(), 0)
#define SORT(obj) sort((obj).begin(), (obj).end()) // 1,2,3,4,5...
#define RESORT(obj) sort((obj).begin(), (obj).end(), greater<int>()) // 5,4,3,2,1...
#define UB(obj,n) upper_bound((obj).begin(), (obj).end(), n) //itr > n
#define LB(obj,n) lower_bound((obj).begin(), (obj).end(), n) //itr>= n

const ll MOD = (ll)1e9 + 7;

int main() {
	string s1, s2, s3;
	cin >> s1 >> s2 >> s3;
	cout << (char)toupper(s1[0]) << (char)toupper(s2[0]) << (char)toupper(s3[0]) << endl;
	return 0;
}


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

// typedef
// -----------------------------------------------------------------------------
typedef long long ll;
typedef long double ld;

// container util
// -----------------------------------------------------------------------------
#define ALL(c)  (c).begin(),(c).end()
#define SZ(c) ((ll)(c).size())
#define MAX(c) *max_element(ALL(c))
#define MIN(c) *min_element(ALL(c))
#define SORT(c) sort((c).begin(),(c).end())

// repetition
// -----------------------------------------------------------------------------
#define FOR(i, a, b) for(int i= (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

// constant
// -----------------------------------------------------------------------------
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);

// debug
// -----------------------------------------------------------------------------
#define DUMP(x)  cerr << #x << " = " << (x) << endl


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    int N, C, K; cin >> N >> C >> K;
    vector<int> T(N); REP(i, N) cin >> T[i];
    SORT(T);
    int f = 0;
    int p = 0;
    int ans = 0;
    REP(i, N) {
        if (!f) {
            f = T[i];
            p = 1;
            ans++;
        } else if (f + K < T[i] || p == C) {
            f = T[i];
            p = 1;
            ans++;
        } else {
            p++;
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3700
import java.util.Scanner;


public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x=sc.nextInt();
		int y=sc.nextInt();
		System.out.println(gcd(x,y));

	}

	public static int gcd(int x,int y){
		int r=0;
		if(x<y){
			swap(x,y);
		}
		while(y>0){
			r=x%y;
			x=y;
			y=r;
		}
		return x;
	}
	public static void swap(int x,int y){
		int dummy=y;
		y=x;
		x=dummy;
	}

	}


Measured memory_bytes: 26352
a = input()
ls = {}
for i in range(ord('a'), ord('z') + 1):
    ls[chr(i)] = 0

for i in a:
    ls[i]+=1;

f = 1;
for i in a:
    if ls[i] > 1:
        f = 0
        break
if f:
    print("yes")
else:
    print("no")


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
const int N=100005,mod=1000000007;
int n;
long long a,b,s[N];
struct seg
{
	int tr[N<<2],tag[N<<2];
	void pushdown(int k)
	{
		if(tag[k])
		{
			tr[k<<1]=0;
			tag[k<<1]=1;
			tr[k<<1|1]=0;
			tag[k<<1|1]=1;
			tag[k]=0;
		}
	}
	void update(int k,int l,int r,int a,int b)
	{
		if(l==a&&r==b)
		{
			tr[k]=0;
			tag[k]=1;
			return;
		}
		pushdown(k);
		int mid=l+r>>1;
		if(b<=mid) update(k<<1,l,mid,a,b);
		else if(a>mid) update(k<<1|1,mid+1,r,a,b);
		else update(k<<1,l,mid,a,mid),update(k<<1,mid+1,r,mid+1,b);
		tr[k]=(tr[k<<1]+tr[k<<1|1])%mod;
	}
	void add(int k,int l,int r,int x,int v)
	{
		if(l==r)
		{
			tr[k]=(tr[k]+v)%mod;
			return;
		}
		pushdown(k);
		int mid=l+r>>1;
		if(x<=mid) add(k<<1,l,mid,x,v);
		else add(k<<1|1,mid+1,r,x,v);
		tr[k]=(tr[k<<1]+tr[k<<1|1])%mod;
	}
	int query(int k,int l,int r,int a,int b)
	{
		if(l==a&&r==b)
			return tr[k];
		pushdown(k);
		int mid=l+r>>1;
		if(b<=mid) return query(k<<1,l,mid,a,b);
		else if(a>mid) return query(k<<1|1,mid+1,r,a,b);
		else return (query(k<<1,l,mid,a,mid)+query(k<<1|1,mid+1,r,mid+1,b))%mod;
	}
}dp0,dp1;
int main()
{
	ios::sync_with_stdio(false);
	cin>>n>>a>>b;
	for(int i=1;i<=n;i++)
		cin>>s[i];
	dp0.add(1,1,n+1,1,1);
	dp1.add(1,1,n+1,1,1);
	for(int i=1;i<n;i++)
	{
		int p,ad0,ad1;
		p=upper_bound(s+1,s+n+1,s[i+1]-b)-s-1;
		ad1=dp0.query(1,1,n+1,1,p+1);
		p=upper_bound(s+1,s+n+1,s[i+1]-a)-s-1;
		ad0=dp1.query(1,1,n+1,1,p+1);
		if(s[i+1]-s[i]<a)
			dp0.update(1,1,n+1,1,n+1);
		if(s[i+1]-s[i]<b)
			dp1.update(1,1,n+1,1,n+1);
		dp0.add(1,1,n+1,i+1,ad0);
		dp1.add(1,1,n+1,i+1,ad1);
	}
	int ans=(dp0.query(1,1,n+1,1,n+1)+dp1.query(1,1,n+1,1,n+1))%mod;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 8648
#include<bits/stdc++.h>
using namespace std;
int main()
{

    long int n,d;
    cin>>n>>d;
    long int count=0;
    double ans=0;
    long long int x,y;
    for(int i=0;i<n;i++)
    {
        cin>>x>>y;
        ans=sqrt(x*x+y*y);
        if(ans<=d)
            count++;

    }
    cout<<count;
}


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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define ALPHABET    (26)
#define INF         INT_MAX
#define MOD         (1000000007LL)
#define EPS         (1e-10)
#define EQ(a, b)    (abs((a)-(b)) < EPS)

using P   = pair<int, int>;
using LL  = long long;
// }}}


// graph {{{
template<class T>
struct G {
    // 辺
    struct E {
        int from;
        int to;
        T w;
    };
    int n;  // 頂点数
    vector<vector<E>> e;// 隣接リスト
    // コンストラクタ
    G(){}
    G(int n) {
        this->n = n;
        e.resize(n);
    }
    // 辺の追加
    void add(int i, int j, T w) {
        e[i].push_back({i, j, w});
    }
    // 全辺の取得
    vector<E> getES() {
        vector<E> ret;
        for(int i=0;i<n;i++){
            for(auto ee : e[i]){
                ret.push_back(ee);
            }
        }
        return ret;
    }
    // 全点対最短路ワーシャル・フロイド法 {{{
    // INFのとり方に注意．大きすぎるとオーバーフローする
    // O(V^3)
    // verified AOJ GRL_1_C
    vector<vector<T>> solveWF() {
        vector<vector<T>> d(n, vector<T>(n, INF));
        auto es = getES();
        for(auto e : es) d[e.from][e.to] = e.w;
        for(int i=0;i<n;i++){
            d[i][i] = 0;
        }
        for(int k=0;k<n;k++){
            for(int i=0;i<n;i++){
                for(int j=0;j<n;j++){
                    if(d[i][k] == INF || d[k][j] == INF) continue;
                    d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
                }
            }
        }
        return d;
    }// }}}
};
//}}}

int main() {
    std::ios::sync_with_stdio(false);
    int n, m, R;cin >> n >> m >> R;
    G<int> g(n);
    vector<int> r(R);
    for(int i=0;i<R;i++){
        cin >> r[i];
        r[i]--;
    }
    for(int i=0;i<m;i++){
        int a, b, c;cin >> a >> b >> c;a--;b--;
        g.add(a, b, c);
        g.add(b, a, c);
    }

    auto dist = g.solveWF();

    sort(r.begin(), r.end());
    int ans = INT_MAX;
    do{
        int d = 0;
        for(int i=1;i<R;i++){
            d += dist[r[i-1]][r[i]];
        }
        ans = min(ans, d);
    }while(next_permutation(r.begin(), r.end()));
    cout << ans << endl;
    return 0;
}


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


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

        ll x = min(b-1, n);
        ll ans = a * x / b - a * (x / b);

        cout << ans << endl;

        return 0;
}

Measured memory_bytes: 3564
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
#define ln '\n'
const long long MOD = 1000000007LL;
//const long long MOD = 998244353LL;
typedef long long ll;
typedef unsigned long long ull; 
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
///////////////////////////////////////////////////////////////////////////////////////////////////

int N,K;
vector<vector<int>> G;
vector<int> dist;
int ans = 0;
template<typename T>
vector<T> BFS(vector<vector<int>> &G, int s) {
    vector<T> ret(G.size(),-1);
    ret[s] = 0;
    queue<int> que;
    que.emplace(s);
    while (!que.empty()) {
        int v = que.front(); que.pop();
        for (auto nv : G[v]) {
            if (ret[nv] != -1) continue;
            ret[nv] = ret[v] + 1;
            que.emplace(nv);
        }
    }

    return ret;
}

int dfs(int v,int pv) {
	int MAX = dist[v];
	for (auto nv : G[v]) {
		chmax(MAX,dfs(nv,v));
	}
	if (MAX > K && MAX - K + 1 == dist[v]) {
		ans++;
		return 0;
	}
	return MAX;
}

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
	cin >> N >> K;
	vector<int> A(N);
	rep(i,N) {
		cin >> A[i];
		A[i]--;
	}

	G.resize(N);
	for (int i = 1; i < N; i++) {
		G[A[i]].emplace_back(i);
	}

	dist = BFS<int>(G,0);
	dfs(0,-1);
	cout << (A[0] ? ans+1 : ans) << ln;
}


Measured memory_bytes: 9600
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static int Calc(int data1, int data2) {

            int ans = data1 % data2;
            if (ans == 0) { return data2; }

            return Calc(data2, ans);    
        }

        static void Main(string[] args)
        {
            //int inputData = int.Parse(Console.ReadLine());
            List<string> inputData = Console.ReadLine().Split(' ').ToList();
            Int32 dayCnt = Int32.Parse(inputData[0]);
            List<string> dataList = Console.ReadLine().Split(' ').ToList();
            Int32 workDay = 0;
            foreach (string current in dataList) {
                workDay += Int32.Parse(current);
            }

            if (workDay <= dayCnt)
            {
                Console.WriteLine(dayCnt - workDay);
            } else { 
                Console.WriteLine(-1);
            }
            Console.ReadLine();
        }
    }
}


Measured memory_bytes: 29316
import java.util.Scanner;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   String N = sc.next();
   boolean flg = true;
   for(int i=0;i<N.length();i++)
   {
     if(i % 2 == 0)
     {
       if(N.charAt(i) == 'L') 
       {
         flg = false;
         break;
       }
     }
     else
     {
       if(N.charAt(i) == 'R') 
       {
         flg = false;
         break;
       }
     }
   }
   String SS= "Yes";
   if (!flg) SS ="No";
   System.out.println(SS);
 }
}

Measured memory_bytes: 23124
// 0202_AtBosssExpense.cpp
//
#include <bits/stdc++.h>
using namespace std;
const int MAX_X = 1000001;
const int MAX_N =30;
bool prime[MAX_X], dp[MAX_X];
int v[MAX_N];
int n, x;
void table() {
  fill(prime,prime+MAX_X,1);

  for(int i=2;i*i<MAX_X;++i)
    if(prime[i])
      for(int j=i*i;j<MAX_X;j+=i)
        prime[j]=0;
}
void solve() {
  fill(dp,dp+MAX_X,0);
  dp[0]=1;
  for(int i=0;i<=x;++i)
    for(int j=0;j<n;++j)
      if(v[j]<=i&&dp[i-v[j]]) dp[i]=1;

  for(int i=x;i>0;--i) {
    if(prime[i]&&dp[i]) {
      cout << i << endl;
      return;
    }
  }
  cout << "NA" << endl;
}
int main() {
  table();
  while(cin >> n >> x && n && x) {
    for(int i=0;i<n;++i) cin >> v[i];
    solve();
  }
  return 0;
}



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

const int mnx = 1e6 + 9;
const int mod = 1e9 + 7;

string s;

int main(){
    cin >> s;

    ll cn = 0;

    for(int i = 0; i < s.size() / 2; i++){
        if(s[s.size() - i - 1] != s[i]) cn++;
    }

    cout << cn << '\n';
    return 0;
}























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


int n,T;


int main()
{
	scanf("%d%d",&n,&T);
	int now=0;
	int res=0;
	int last=-T;
	for(int i=1;i<=n;i++)
	{
		int x;
		scanf("%d",&x);
		if(last+T<x)
		{
			now+=x-last-T;
		}
		if(i==n) res=x;
		last=x;
	}
	res+=T;
	cout<<res-now<<endl;
}
		
		
		
		

Measured memory_bytes: 256
#NOT_FOUND = 0
import copy

def linearSearch(n, S, t):
    i = 0
    key = t
    S.append(t)
    while S[i] != t:
        i = i+1
    if i == n:
        return False
    
    return True

if __name__ == '__main__':
    n = int(input())
    S = list(map(int,input().split()))
    q = int(input())
    T = list(map(int,input().split()))
    
    C = 0
    for i in range(q):
        isExist = linearSearch(n, copy.deepcopy(S), T[i])
        if isExist :
            C = C + 1
    print(C)


Measured memory_bytes: 7076
import java.io.PrintWriter
import java.lang.Math.min

val pw = PrintWriter(System.out)
fun main(args: Array<String>) {
    var (l,r)=listOfLong()
    var re=2018
    for(i in (l..min(r,l+4545))){
        for(j in ((i+1)..min(r,i+4545))) {
            re = min(re, (i*j%2019).toInt())
        }
    }
    pw.println(re)
    pw.flush()
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { it.toInt() }
fun listOfLong() = listOfString().map { it.toLong() }
fun listOfDouble() = listOfString().map { it.toDouble() }


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

int main() {
  string s;
  cin >> s;
  for (char c = 'a'; c <= 'z'; c++)
    if (s.find(c) == (size_t)-1) {
      cout << c << '\n';
      return 0;
    }
  cout << "None\n";
  return 0;
}

Measured memory_bytes: 512
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 文字列の入力
		String s = sc.next();
      	int sum = 0;
      	if("1".equals(s.substring(0,1))) sum +=1;        
        if("1".equals(s.substring(1,2))) sum +=1;
        if("1".equals(s.substring(2,3))) sum +=1;
      	
		// 出力
		System.out.println(sum);
	}
}

Measured memory_bytes: 21844
import numpy as np
n, y = map(int, input().split())
y //= 1000
c = -1
for i in range(min(n,y)+1):
    if (y - i) % 5 != 0: continue
    if n - i <= (y - i)/5 and (y - i)/5 <= 2*(n - i):
        c = i
        break
if c == -1:
    print(-1,-1,-1)
else:
    a = (y-c)//5 - n + c
    b = n - a - c
    print(a,b,c)


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

#define int long long 

using namespace std;

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, ww;
  cin >> n >> ww;
  vector<int> w(n), v(n);
  for (int i = 0; i < n; i++) {
    cin >> w[i] >> v[i];
  } 
  vector<int> dp(ww + 1, -1);
  dp[0] = 0;
  for (int i = 0; i < n; i++) {
    for (int j = ww; j >= 0; j--) {
      if (j + w[i] <= ww && dp[j] >= 0) {
        dp[j + w[i]] = max(dp[j + w[i]], v[i] + dp[j]);
      }
    }
  }

  cout << *max_element(dp.begin(), dp.end()) << "\n";
  return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>

int main(void) {
    int num,i,ans=1;
    char *color;
    scanf("%d",&num);
    color=malloc(sizeof(char)*num);
    scanf("%s",color);
    for (i=0;i<num-1;i++) {
        if (color[i]!=color[i+1]) ans++;
    }
    free(color);
    printf("%d\n",ans);
    return 0;
}

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

const static int MOD = 1e9 + 7;

int main(void){
    int n;
    std::cin >> n;
    std::vector<long long> a(n);
    for(int i = 0; i < n; i++){
	std::cin >> a[i];
    }
    long long x;
    long long ans = 0;
    long long tmp;
    for(long long i = 0; i < 60; i++){
	x = 0;
	for(int j = 0; j < n; j++){
	    long long cur = a[j];
	    if((a[j] >> i) & 1) x++;
	}
	tmp = x * (n - x) % MOD;
	for(int j = 0; j < i; j++){
	    tmp = (tmp * 2) % MOD;
	}
	// std::cout << tmp << std::endl;
	ans = (ans + tmp) % MOD;
    }
    std::cout << ans << std::endl;
    return 0;
}



Measured memory_bytes: 5560
#include<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<math.h>
#include<iomanip>
#include<map>
#include<stack>
#include<queue>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int main(){
    int n;
    while(cin >> n, n){
        int data[105];
        rep(i,n){
            cin >> data[i];
        }
        int ans = 0, search;
        cin >> search;
        int start = 0, end = n - 1;
        int p;
        while(end >= start){
            p = (end + start) / 2;
            ans++;
            if(search > data[p])
                start = p + 1;
            else if(search < data[p])
                end = p - 1;
            else
                break;
        }
        cout << ans << endl;
    }
}

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

int main(){
  int n, k;
  cin >> n >> k;
  int ans = 0;
  rep(i,n){
    int h;
    cin >> h;
    if(h >= k) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> p = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,57,59,61,67,71,73,79,83,89,97};
    vector<int> pw(p.size(),0);
    for(int i=2;i<=N;i++){
        int tmp=i;
        for(int j=0;j<p.size();j++){
            while(tmp%p[j]==0){
               pw[j]++;
               tmp/=p[j];
            }
        }
    }
    int ans=0;
    for(int i=0;i<pw.size();i++){
        if(pw[i]>=74) ans++;
        if(pw[i]>=24){
            for(int j=0;j<pw.size();j++){
                if(i!=j&&pw[j]>=2) ans++;
            }
        }
        if(pw[i]>=14){
            for(int j=0;j<pw.size();j++){
                if(i!=j&&pw[j]>=4) ans++;
            }
        }
        if(pw[i]>=4){
            for(int j=i;j<pw.size();j++){
                if(i!=j&&pw[j]>=4) {
                    for(int k=0;k<pw.size();k++){
                         if(i!=k&&j!=k&&pw[k]>=2) ans++;
                    }
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int n,m,l;
	cin >> n >> m >> l;
	int a[n][m],b[m][l];
	long c[n][l];
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++) cin >> a[i][j];
	}
	for(int i=0;i<m;i++){
		for(int j=0;j<l;j++) cin >> b[i][j];
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<l;j++){
                        c[i][j] = 0;
			for(int k=0;k<m;k++) c[i][j] += a[i][k]*b[k][j];
		}
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<l-1;j++) cout << c[i][j] << " ";
		cout << c[i][l-1] << endl;
	}
}

Measured memory_bytes: 1312
#include<iostream>
#include<vector>
using namespace std;
const int mod = 1e9+7;

int main(){
    string s;
    cin >> s;
    int n = s.length();
    vector<vector<int>> v(n+1, vector<int>(13, 0));
    v[0][0] = 1;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < 13; j++){
            if(s[i] == '?'){
                for(int k = 0; k < 10; k++){
                    int next = (j*10+k)%13;
                    v[i+1][next] += v[i][j];
                    v[i+1][next] %= mod;
                }
            }else{
                int next = (j*10+(s[i]-'0'))%13;
                v[i+1][next] += v[i][j];
                v[i+1][next] %= mod;
            }
        }
    }
    cout << v[n][5] << endl;
    return 0;
}

Measured memory_bytes: 8960
s = input()
n = len(s)
ans = [0]*n
for ri in range(2):
    cnt = 0
    for i in range(n):
        if s[i] == 'R':
            cnt += 1
        else:
            ans[i] += cnt//2
            ans[i-1] += -(-cnt//2)
            cnt = 0

    ans.reverse()
    s = s[::-1]
    s_list = list(s)
    for i in range(n):
        if s_list[i] == 'L':
            s_list[i] = 'R'
        else:
            s_list[i] = 'L'
    s = "".join(s_list)

print(' '.join(map(str, ans)))


Measured memory_bytes: 11112
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int) n; i++)
using ll = long long;
template <class T>
using vt = vector<T>;
using vvi = vector<vector<int>>;

int main(){
  int N;
  cin >> N;
  vt<int> s(N);
  rep(i,N)
    cin >> s[i];
  sort(s.begin(),s.end());
  int total = accumulate(s.begin(),s.end(),0);

  rep(i,N){
    if(total % 10 != 0)
      break;
    if(s[i] % 2 != 0)
      total -= s[i];
  }

  if(total%10==0)
    cout << 0 << endl;

  else
    cout << total << endl;
    
  return 0;
}


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

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

  int a[n];
  int b[n];
  int c[n-1];

  rep (i, n) cin >> a[i];
  rep (i, n) cin >> b[i];
  rep (i, n-1) cin >> c[i];
  rep (i, n) a[i]--;

  int ans = 0;
  for (int i = 0; i < n; i++) {
    ans += b[a[i]];
    if (i > 0 && a[i-1] + 1 == a[i])
      ans += c[a[i-1]];
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define nl '\n'
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define flood(x) memset(x, 0x3f, sizeof x)
#define drain(x) memset(x, 0, sizeof x)
#define dcit cin.sync_with_stdio(0);cin.tie(0);
#define frp(x, y) freopen(x, "r", stdin);freopen(y, "w", stdout);
typedef pair<int, int> pii;
typedef long long ll;

#ifdef LOCAL_PROJECT

#define gc getchar()
#define pc(x) putchar(x)

#endif
#ifndef LOCAL_PROJECT

#define gc getchar_unlocked()
#define pc(x) putchar_unlocked(x)

#endif

template<typename T> void scani(T &x) {x = 0;register bool _=0;register T c=gc;_=c==45;c=_?gc:c;while(c<48||c>57)c=gc;for(;c<48||c>57;c=gc);for(;c>47&&c<58;c=gc)x=(x<<3)+(x<<1)+(c&15);x=_?-x:x;}
template<typename T> void printi(T n) {register bool _=0;_=n<0;n=_?-n:n;char snum[65];int i=0;do{snum[i++]=n%10+48;n/= 10;}while(n);--i;if (_)pc(45);while(i>=0)pc(snum[i--]);pc(10);}
string nextstring() { string r; register char c=gc;while(c==32||c==10) c = gc;while(!(c==32||c==10)) { r += c;c = gc; }return r; }
char nextgetchar(){ register char c = gc; while(c==32 || c==10) c = gc; return c;}

void prints(string k){ for (int i = 0; i < k.length(); i++)pc(k[i]); }
void scani() {}

template<typename First, typename ... Ints>
void scani(First &arg, Ints&... rest) { scani(arg);scani(rest...); }

int N; ll a[100005], dp[100005];
int main(){
    flood(dp);
    scani(N);
    for (int i = 1; i <= N; i++)scani(a[i]);
    dp[1]=0;
    for (int i = 2; i <= N; i++)dp[i] = min( abs(a[i]-a[i-1]) +dp[i-1], abs(a[i]-a[i-2]) +dp[i-2]);
    printi(dp[N]);
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
#define all(V) V.begin(),V.end()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
const ll INF=1e18;
const int MOD=1e9+7;
const double pi=acos(-1);


int main(){
  double l;
  cin >> l;
  printf("%.12lf\n",l*l*l/27);
  return 0;
}


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

int main() {
  string c;
  cin >> c;
  if (c.at(0)=='a' || c.at(0)=='i' || c.at(0)=='u' || c.at(0)=='e' || c.at(0)=='o'){
    cout<<"vowel"<<endl;
  }
  else{
    cout<<"consonant"<<endl;
  }
}


Measured memory_bytes: 3596
//M-candies
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define fr(a,b) for(ll i=a;i<=b;i++)
#define mod 1000000007
#define all(x) (x).begin(),(x).end()
#define prDouble(x) cout<<fixed <<setprecision(10)<<x
#define triplet pair<ll,pair<ll,ll>>
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;




int NoOfWays(vector<int>&arr,int n,int k)
{
ll dp[n+2][k+2];
//base case
for(int j=0;j<=k;j++)
dp[1][j]=(j>arr[1])? 0: 1;


for(int i=2;i<=n;i++)
{
    for(int j=0;j<=k;j++)
    {
        if(j==0)
        dp[i][j]=dp[i-1][j];//i,e 1
        else
        {
            dp[i][j]=(mod + dp[i][j-1]+dp[i-1][j]- ((j-arr[i]-1 >=0)? dp[i-1][j-arr[i]-1] :0))% mod; //from the recurrence
        }
    }
}



return dp[n][k];
}
int main()
{
    int n,k;
    cin>>n>>k;
    vector<int>arr(n+1);
    //int sum=0;
    fr(1,n){
    cin>>arr[i];
    //sum+=arr[i];
    }
    // if(k>sum)
    // return 0;
    cout<<NoOfWays(arr,n,k);
    return 0;


}

Measured memory_bytes: 78976
import io.StdIn._
 
object Main extends App {
  val arr       = readLine.split(" ")
  val tHitPoint = arr(0).toInt
  val tAttack   = arr(1).toInt
  val aHitPoint = arr(2).toInt
  val aAttack   = arr(3).toInt
 
  def process(tHitPointRest: Int, aHitPointRest: Int, isTsTurn: Boolean): Unit = {
    if (isTsTurn) {
      if ((aHitPointRest - tAttack) > 0) process(tHitPointRest, aHitPointRest - tAttack, !isTsTurn)
      else print("Yes")
    } else {
      if ((tHitPointRest - aAttack) > 0) process(tHitPointRest - aAttack, aHitPointRest, !isTsTurn)
      else print("No")
    }
  }
 
  process(tHitPoint, aHitPoint, true)
}

Measured memory_bytes: 54696
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
   string s,t;
   cin>>s>>t;
   vector<vector<int>>dp (s.length()+1,vector<int>(t.length()+1,0));
   for(ll i=1;i<=s.length();i++)
    {
    for(int j=1;j<=t.length();j++)
    {
      if(s[i-1]==t[j-1] && dp[i][j]<1+dp[i-1][j-1])
      dp[i][j]=1+dp[i-1][j-1];
      else
      dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
     }
 }
    
//cout<<dp[s.length()][t.length()]<<"\n";
int i=s.length(),j=t.length();
string p;
while(i>0 and j>0)
{
    if(s[i-1]==t[j-1])
    {
        p+=s[i-1];
        i--,j--;
    }
    else
    {
        if(dp[i-1][j]>=dp[i][j-1])
        {
            i--;
        }
        else
        j--;
    }
}
reverse(p.begin(),p.end());
cout<<p<<"\n";
return 0;
}

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

using namespace std;

#ifdef LOCAL
  #include "debug.hpp"
#endif

double dp[3001][3005] = {};

int main(){
    int n;
    cin >> n;
    vector <double> p(n);
    for (int i = 0; i < n; i++) {
      cin >> p[i];
      dp[0][i] = (1-p[i]);
      if (i > 0) dp[0][i] *= (dp[0][i-1]);
    }
    dp[1][0] = p[0];
    for(int j = 1; j < n; j++) {
      for(int i = 1; i < n+1; i++) {
        dp[i][j] = p[j]*dp[i-1][j-1];
        dp[i][j] += (1-p[j])*dp[i][j-1];
      }
    }
    double sim = 0;
    for (int i = 0; i < n+1; i++) {
      if(i > (n)/2) sim += dp[i][n-1];
    }
    printf("%.11lf",sim);
#ifdef LOCAL
  cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 70656
from bisect import bisect_right
from time import time

N, M, K = [int(x) for x in input().split()]

a_book = [0]
for index, i in enumerate(input().split(), 1):
    if a_book[index-1] + int(i) <= K:
        a_book.append(a_book[index-1] + int(i))
    else:
        N = index - 1
        break

b_book = [0]
for index, i in enumerate(input().split(), 1):
    if b_book[index-1] + int(i) <= K:
        b_book.append(b_book[index-1] + int(i))
    else:
        M = index - 1
        break

check = {}

max_books = 0

for i, a in enumerate(a_book):
    b_pos = bisect_right(b_book, K - a)

    if max_books < b_pos - 1 + i:
        max_books = b_pos - 1 + i

print(max_books)


Measured memory_bytes: 41148
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main(int argc, char *argv[]) {
	string S;
	cin >> S;
	reverse(begin(S), end(S));

	string words[] = { "maerd", "remaerd", "esare", "resare" };
	int idx = 0;
	while (idx < S.size()) {
		bool matched = false;
		for (int i = 0; i < 4; i++) {
			string &w = words[i];
			if (S.substr(idx, w.size()) == w) {
				matched = true;
				idx += w.size();
				break;
			}
		}

		if (!matched) {
			printf("NO\n");
			return 0;
		}
	}

	printf("YES\n");

	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
using namespace std;
int n, p[25], cnt;

int main() {
	int i;
	cin>>n;
	for(i=0; i<n; i++) cin>>p[i];
	for(i=1; i<n-1; i++) {
		if(p[i] < p[i-1] && p[i] > p[i+1] || p[i] > p[i-1] && p[i] < p[i+1]) cnt++;
	}
	cout<<cnt;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdint>

using namespace std;

int main()
{
	int_least64_t x;
	cin >> x;

	int_least64_t result {2 * (x / 11 + 1)}, r{x % 11};
	if(r == 0) {
		result -= 2;
	}
	else if(r <= 6) {
		result -= 1;
	}

	cout << result << endl;
}


Measured memory_bytes: 256
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
#dt = {k:v for k,v in sorted(x.items(), key=lambda i: i[1])}
ipnl = lambda n: [int(input()) for _ in range(n)]
inp = lambda :int(input())
ip = lambda :[int(w) for w in input().split()]
mp = lambda :map(int,input().split())

n = inp()
x = ip()
ctr = 0
a = [i+x[i] for i in range(n)]
b = [i-x[i] for i in range(n)]

dt1 = {} 
for i in a: dt1[i] = dt1.get(i,0)+1
dt2 = {} 
for i in b: dt2[i] = dt2.get(i,0)+1

for i in dt1:
    if i in dt2:
        ctr += dt1[i]*dt2[i]
print(ctr)

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

int main()
{
    long long n;
    cin >> n ;
    long long  a[n];

    for(auto &aa : a)
        cin >> aa;

    long long curr = 1 , count = 0;

    for(int i = 0 ;  i < n ; i++)
    {
        if(a[i]!= curr)
        {
            count++;
        }
        else{
            curr++;
        }
    }

    cout << ((count == n) ? -1 : count )<< endl;
    return 0;
}

Measured memory_bytes: 1792
//
//  water_bottle.cpp
//  learningCplusplus
//
//  Created by Tran Duc Chinh on 2020/04/04.
//  Copyright © 2020 Tran Duc Chinh. All rights reserved.
//

#include <iostream>
#include <queue>
#include <math.h>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
#define PI 3.14159265

int main(int argc, const char* argv[]) {

  double a, b, x;
  std::cin >> a >> b >> x;
  double tan = (double)a*b*b/(2*x);
  if (x > a*a*b/2) {
    tan = (double)((2*a*a*b-2*x)/(a*a*a));
  }
  double result = atan(tan) * 180 / PI;
  printf("%.9f\n", result);
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int N,A=0;
  char S[200002];
  scanf("%d\n%s",&N,S);
  int LW=0,RR=N-1;
  while(S[LW]!='W'&&LW<N) LW++;
  while(S[RR]!='R'&&RR>0) RR--;
  while(LW<RR){
    A++;
    LW++;
    RR--;
    while(S[LW]!='W'&&LW<N) LW++;
    while(S[RR]!='R'&&RR>0) RR--;
  }
  printf("%d\n",A);
  return 0;
}

Measured memory_bytes: 1928
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H& b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H & b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H & b) const { return x == b.x && y == b.y; }
	bool operator!=(const H & b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P& b) const { return cost < b.cost; }
	bool operator>(const P& b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E& b) const { return cost < b.cost; }
	bool operator>(const E& b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T & a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T & a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int n;
int a[200000];
int b[200000];
signed main() {
	cin >> n;
	int sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		sum += a[i];
	}
	for (int i = 1; i < n; i+=2) {
		b[i + 1] = b[i-1]+(a[i] - a[i - 1]) * 2;
	}
	//山1から
	for (int i = n - 1; i > 0; i -= 2) {
		b[i - 1] = b[(i + 1) % n] + (a[i - 1] - a[i]) * 2;
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		ans += b[i];
	}
	b[0] = (sum - ans) / n;
	cout << b[0];
	for (int i = 1; i < n; i++) {
		cout << " " << b[i] + b[0];
	}
	cout << endl;
}

Measured memory_bytes: 2944
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {

		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		int Y = sc.nextInt();
		int R = Y / 1000;

		for (int x = 0; x <= R / 10; x++) {
			for (int y = 0; y <= R / 5; y++) {
				int z = N - x - y;
				if (0 <= z && z <= R) {
					if (x * 10 + y * 5 + z == R) {
						System.out.println(x + " " + y + " " + z);
						return;
					}
				}
			}
		}
		System.out.println("-1" + " " + "-1" + " " + "-1");

	}
}

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

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

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

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

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

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

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

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

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


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

using namespace std;

typedef long long ll;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n;
	cin >> n;

	ll lastT = 1, lastA = 1;
	for (int i = 0; i < n; i++) {
		ll t, a;
		cin >> t >> a;

		ll factor=max(lastA/a,lastT/t);
        while(true){
            if(factor * t >= lastT && factor * a >= lastA)
                break;
            factor++;
        }

		lastT = t * factor;
		lastA = a * factor;
	}

	//cout << "ans: " << lastT << " " << lastA << '\n';
	cout << (lastT + lastA) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define T() int t; cin>>t; while(t--)                      
#define pb push_back
#define endl "\n"

int main()
{	
	FIO;
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);

	ll n;
	cin>>n;

	ll ans = 1, minus = 0;
	vector<ll> arr(n);

	for(ll i=0;i<arr.size();i++) cin>>arr[i];
	sort(arr.begin(),arr.end());
	
	if(arr[0] == 0){
		cout<<0<<endl;
		return 0;
	}

	for(ll i=0;i<n;i++){
		// ll val;
		// cin>>val;
		// ll check =ans*arr[i]; 
		if( arr[i]<= 1000000000000000000/ans){
			ans *= arr[i];
			
		}
		else{
			cout<<-1<<endl;
			return 0;
		}
		
	}

	cout<<ans<<endl;

	
	return 0;
	
}

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

int main() {
    int n;
    cin >> n;
    set<string> s;

    rep(i, n) {
        string a;
        cin >> a;
        s.insert(a);
    }

    cout << s.size() << endl;
    return 0;
}


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

void call(int n) {
    for (int i = 1; i <= n; i++) {
        int x = i;
        // CHECK_NUM
        if (x % 3 == 0) {
            cout << " " << i;
            continue;
        }
        // INCLUDE3
        while (x) {
            if (x % 10 == 3) {
                cout << " " << i;
                break;
            }
            x /= 10;
        }
    }
    cout << endl;
}

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

    return 0;
}


Measured memory_bytes: 3096
MOD=10**9+7
cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def desc(ar) ar.sort!{|x,y|y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end

def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end

def puts_yesno(can) puts(can ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def debug(k,v) puts "#{k}:#{v}" end
########### ( ˘ω˘ )ｽﾔｧ… ###########
m=gi
dc=m.times.map{gsmi}

cnt=0
q=[]
dc.each do |d,c|
  num=d
  while c>1 do
    if c.odd?
      q<<num
    end
    c/=2
    num*=2
    cnt+=c
    if num>=10
      s=num/10+num%10
      cnt+=c
      num=s
    end
  end
  q<<num
end

q1=q.shift
while q.size>0 do
  q2=q.shift
  num=q1+q2
  cnt+=1
  if num>=10
    s=num/10+num%10
    cnt+=1
    q1=s
  else
    q1=num
  end
end

puts cnt

Measured memory_bytes: 41908
import itertools
import math
N = int(input())
sm = 0
xy= [list(map(int, input().split())) for _ in range(N)]
L = itertools.permutations(list(range(N)),N)
for l in L:
    for i in range(len(l)-1):
        sm += ((xy[l[i]][0]-xy[l[i+1]][0])**2+(xy[l[i]][1]-xy[l[i+1]][1])**2)**0.5

print(sm / math.factorial(N))


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int a,b;
int main()
{
	cin>>a>>b;
	int n1,n2,n3;
	n1=a+b;
	n2=a-b;
	n3=a*b;
	int n4=max(n1,n2);
	printf("%d",max(n3,n4));
	return 0;
}

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

int main()
{
    ll n,x,t;
    cin>>n>>x>>t;
    ll m=n/x;
    if(n%x!=0) m++;
    cout<<m*t;
    return 0;
}


Measured memory_bytes: 3588
#include<stdio.h>
#include<string.h>

int main(){
    char s[15];
    char t[15];

    scanf("%s",s);
    scanf("%s",t);

    if(strlen(s) == (strlen(t) - 1) && strncmp(s,t,strlen(s)) == 0)printf("Yes\n");
    else printf("No\n");


    return 0;
}

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

long long gcd(long long a, long long b){
  return b ? gcd(b, a % b) : a;
}

long long lcm(long long a, long long b){
  return a / gcd(a, b) * b;
}

long long f(long long x, int c, int d) {
  long long res = x;
  res -= x / c;
  res -= x / d;
  res += x / lcm(c, d);
  return res;
}

int main() {
  long long A, B;
  int C, D;
  cin >> A >> B >> C >> D;
  long long ans = f(B, C, D) - f(A - 1, C, D);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define N 10001
typedef struct {
  int sum;
  int flag;
} CC;
CC C[N];
int A[1000],B[1000];
int main()
{
  int i,n,min=0,m,k,now,sum=0,minx,sum1,sum2;
  scanf("%d",&n);
  for(i=1;i<n+1;i++){
    scanf("%d",&A[i]);
  }
  minx=A[1];
  for(i=1;i<n+1;i++){
    if(minx>A[i])minx=A[i];
  }
  for(i=0;i<N;i++){
    C[i].sum=0;
    C[i].flag=0;
  }
  for(i=1;i<n+1;i++){
    C[A[i]].sum+=1;
    C[A[i]].flag+=1;
  }
  for(i=0;i<N;i++){
    C[i].sum+=C[i-1].sum;
  }

  for(i=n+1;i>0;i--){
    if(C[A[i]].flag==1){
      k=i;
      now=k;
      m=0;
      B[C[A[k]].sum]=A[k];
      C[A[i]].flag=0;
      min=A[k];
      k=C[A[k]].sum;
      while(A[now]!=A[k]){
        if(m==0){
          sum+=A[now];
	  //printf("%d ",A[now]);
        }
        //printf("%d ",A[k]);
        B[C[A[k]].sum]=A[k];
        C[A[k]].flag=0;
        sum+=A[k];
        if(min>A[k])min=A[k];
        k=C[A[k]].sum;
        m+=1;
      }
      sum2=min*(m-1);
      sum1=min+(m+2)*minx;
      if(m>1){      
	if(sum1<sum2){
	  sum+=sum1;
	}
	else sum+=sum2;     
	m=0;
	min=0;
      }
    }
    
  }
  /* printf("\n");
  for(i=1;i<n;i++){
    printf("%d ",B[i]);
  }
  printf("%d",B[i]);*/
  printf("%d\n",sum);
  return 0;
}

Measured memory_bytes: 680
#include <bits/stdc++.h>
#define int long long
using namespace std;

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<PII> VP;


//REPEAT
//------------------------------------------
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define RFOR(i, m, n) for(int i = m;i > n;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,m)  RFOR(i,m,0)

//container util
//------------------------------------------
#define pb(a) push_back(a)
#define fst first
#define snd second
#define SORT(V) sort((V).begin(),(V).end())
#define REV(V) reverse((V).begin(),(V).end())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//grobal variable
//------------------------------------------

//def function, class
//------------------------------------------

//main
//------------------------------------------
signed main(){
  int N, L;
  cin >> N >> L;

  int mini = INF, ans = 0;
  REP(i, N){
    ans += L+i;
    if(abs(mini)>abs(L+i)) mini = L+i;
  }

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


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

struct union_find {
	int N, M;
	std::vector<int> parent, sz;

	union_find(int n) : N(n), M(n) {
		parent.resize(N); sz.resize(N, 1);
		for (int i = 0; i < N; i++) parent[i] = i;
	}

	int root(int i) {
		if (parent[i] == i) return i;
		return parent[i] = root(parent[i]);
	}

	bool is_united(int i, int j) {return (root(i) == root(j));}

	int size(int i) {return sz[root(i)];}

	bool unite(int i, int j) {
		if (is_united(i, j)) return false;
		if (size(i) < size(j)) std::swap(i, j);
		i = root(i); j = root(j);
		parent[j] = i;
		sz[i] += sz[j];
		M--;
		return true;
	}
};

int main() {
	int n, m;
	std::cin >> n >> m;
	union_find uf(n);
	while (m--) {
		int a, b;
		std::cin >> a >> b;
		uf.unite(a - 1, b - 1);
	}
 
	int ans = 0;
	for (int i = 0; i < n; i++) ans = std::max(ans, uf.size(i));
	std::cout << ans << '\n';

	return 0;
}

Measured memory_bytes: 4844
n, y = map(int, input().split())
for a in range(0, n+1):
    for b in range(0, n+1-a):
        c = n - a - b
        if 10000 * a + 5000 * b + 1000 * c == y:
            print(a, b, c)
            exit()
print(-1, -1, -1)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<vector<pair<int, int>>> Edges(N);
	vector<int> colors(N - 1, 0);
	for (int i = 0; i < N - 1; i++) {
		int a, b;
		cin >> a >> b;
		Edges[a - 1].push_back({ i, b - 1 });
		Edges[b - 1].push_back({ i, a - 1 });
	}
	queue<pair<int,int>> NodeQueue;
	NodeQueue.push({ 0,0 });

	int maxcolor = 0;
	while (!NodeQueue.empty()) {
		pair<int, int> nodepair = NodeQueue.front();
		int node = nodepair.first;
		int color = nodepair.second;
		NodeQueue.pop();
		int nextcolor = 1;
		while (nextcolor == color) nextcolor++;
		for (const auto& neighbors : Edges[node]) {
			if (colors[neighbors.first] <= 0) {
				NodeQueue.push({ neighbors.second, nextcolor });
				colors[neighbors.first] = nextcolor;
				maxcolor = max(nextcolor, maxcolor);
				nextcolor++;
				while (nextcolor == color) nextcolor++;
			}
		}
	}
	cout << maxcolor << endl;
	for (int c : colors) cout << c << endl;

}


Measured memory_bytes: 7040