akhauriyash/Code-Regression huggingface dataset:
N = int(input())
B = list(map(int,input().split()))
C = list(map(int,input().split()))

tmp=0
cnt=0
for i in range(N):
    tmp = B[i]-C[i]
    if(tmp>0):
        cnt+=C[i]
        B[i]-=C[i]
        C[i]=0
    else:
        cnt+=B[i]
        C[i]-=B[i]
        B[i]=0

    tmp = B[i+1]-C[i]
    if(tmp>0):
        cnt+=C[i]
        B[i+1]-=C[i]
        C[i]=0
        
    else:
        cnt+=B[i+1]
        C[i]-=B[i+1]
        B[i+1]=0

print(cnt)

Measured memory_bytes: 19004
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(18);
}
signed main(){
  init_io();
  ll n;
  cin >> n;
  vector<ll> ans(n*n,-1),x(n),need(n);
  vector<P> px;
  queue<ll> que;
  for(int i=0;i<n;i++){
    cin >> x[i];
    x[i]--;
    px.push_back(P(x[i],i));
    ans[x[i]] = i;
    need[i] = i;
  }
  sort(px.begin(),px.end());
  for(int i=0;i<n;i++){
    for(int j=0;j<px[i].second;j++){
      que.push(px[i].second);
    }
  }
  for(int i=0;i<n*n;i++){
    if(ans[i]==-1){
      if(que.empty()){
        cout << "No\n";
        return 0;
      }
      ans[i] = que.front();
      need[que.front()]--;
      que.pop();
    }else{
      if(need[ans[i]]!=0){
        cout << "No\n";
        return 0;
      }else{
        for(int j=0;j<n-1-ans[i];j++){
          que.push(ans[i]);
        }
      }
    }
  }
  cout <<"Yes\n";
  for(int i=0;i<n*n;i++){
    cout << ans[i]+1;
    if(i==n*n-1) cout << endl;
    else cout << " ";
  }
}


Measured memory_bytes: 4736
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<stack>
#include<map>
#include<deque>
#include<cstdio>
#include<cstdio>
#include<time.h>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define pd(a,n) for(int i=0;i<n;i++)cout<<a[i]<<((i==n-1)?"\n":" ")
#define pdd(a,n,m)for(int i=0;i<m;i++)pd(a,m)
#define mp make_pair
#define pb push_back
#define ll __int64
#define __int64 long long
#define P pair<int,int>
#define PP pair<P,int>

ll n,k;
ll a[222222];
///3 3 -4 -2
///-4 -2 3 3
bool func(ll x){
  ll cnt=0;
  ll c=0,d=0;
  rep(i,n){
    if(a[i]>0){
      ll ok=i-1,ng=n,mid;
      while(abs(ok-ng)>1){
        mid=(ok+ng)/2;
        ( (a[i]*a[mid]<x)?ok:ng)=mid;
      }
      if(ok>i)cnt+=ok-i;
      if(ok>i)c+=ok-i;
    }
    else if(a[i]<0){
      ll ng=i-1,ok=n,mid;
      while(abs(ok-ng)>1){
        mid=(ok+ng)/2;
        //cout<<ng<<"&"<<ok<<endl;
        ( (a[i]*a[mid]>=x)?ng:ok)=mid;
      }
      //cout<<a[i]<<" "<<ng<<endl;
      if(ng!=i-1){
        cnt+=n-1-ng;
        d+=n-1-ng;
      }
      else{
        cnt+=n-1-ok;
        d+=n-1-ok;
      }
    }
    else{
      if(x>0)cnt+=n-1-i;
    }
  }
  //cout<<x<<" "<<cnt<<" "<<c<<" "<<d<<" "<<endl<<endl;
  return cnt<k;
}

int main(){
  cin>>n>>k;
  rep(i,n)cin>>a[i];
  sort(a,a+n);
  ll INF=1e18;
  ll ok=-INF,ng=INF,mid;
  while(abs(ok-ng)>1){
    mid=(ok+ng)/2;
    ((func(mid))?ok:ng)=mid;
  }
  cout<<ok<<endl;
  return 0;
}


Measured memory_bytes: 1792
#■標準入力ショートカット


def get_next_int():
    return int(float(input()))


def get_next_ints(delim=" "):
    return tuple([int(float(x)) for x in input().split(delim)])


def get_next_str():
    return input()


def get_next_strs(delim=" "):
    return tuple(input().split(delim))


def get_next_by_types(*value_types, delim=" "):
    return tuple([t(x) for t, x in zip(value_types, input().split(delim))])


class Grid():

    def __init__(self):
        self.H, self.W = get_next_ints()
        self.canvas = []
        for i in range(self.H):
            self.canvas.append(get_next_str())

    def check(self, x, y):
        checker = False
        if x-1 >= 0:
            checker = checker or self.canvas[y][x-1] == '#'
        if x+1 < self.W:
            checker = checker or self.canvas[y][x+1] == '#'
        if y-1 >= 0:
            checker = checker or self.canvas[y-1][x] == '#'
        if y+1 < self.H:
            checker = checker or self.canvas[y+1][x] == '#'
        return checker

    def solve(self):
        available = True
        for y in range(self.H):
            if not available:
                break
            for x in range(self.W):
                if self.canvas[y][x] == '#':
                    available = available and self.check(x, y)
        if available:
            print('Yes')
        else:
            print('No')


def solve():
    g = Grid()
    g.solve()
    
solve()

Measured memory_bytes: 3064
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>

using namespace std;

const int MAX = 105;
const int NMAX = 100005;
int nx = 0; // = ii
int a[MAX];
int d[NMAX];

int dp(int n){
        if(n<6) return n;
        if(d[n] != -1) return d[n];
        int ans = n;
        for(int i=nx-1; i>=0; i--){
                if(n<a[i]) continue;
                // printf("%d, ", dp(n-a[i]));
                ans = min(ans, dp(n-a[i]) + 1);
        }
        d[n] = ans;
        return ans;
}

int main(){
        int N, n = 0;
        int i, ii = 0, t = 0;
        scanf("%d", &N);
        a[ii++] = 1;
        for(i=1; ; i++){
                t = pow(6, i);
                if(t>NMAX) break;
                a[ii++] = t;
        }
        for(i=1; ; i++){
                t = pow(9, i);
                if(t>NMAX) break;
                a[ii++] = t;
        }
        nx = ii;
        sort(a, a+ii);
        /* for(i=0; i<ii; i++){
                printf("%d, ", a[i]);
        }
        for(i=ii-1; i>=0; i--){
                n+= N/a[i];
                N = N%a[i];
                if(N==0) break;
        } */
        memset(d, -1, sizeof(d));
        printf("%d", dp(N));
        return 0;
}

Measured memory_bytes: 768
#include<iostream>
using namespace std;
int main() {
    int r,g,b,ans;
    while(cin>>r>>g>>b) {
        ans=r*100+g*10+b;
        if(ans%4!=0)
            cout<<"NO"<<endl;
        else
            cout<<"YES"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <tuple>
#include <stack>

using namespace std;

int main(void) {
    int R, C, N;
    cin >> R >> C >> N;

    auto boundary = [R, C](int x, int y) {
        return (x == 0 || x == R || y == 0 || y == C);
    };

    vector< tuple<int,int,int> > v;
    for(int i=0; i<N; i++) {
        int x, y, z, w;
        cin >> x >> y >> z >> w;
        if(boundary(x, y) && boundary(z, w)) {
            v.emplace_back(x, y, i);
            v.emplace_back(z, w, i);
        }
    }

    stack<int> stk;
    sort(v.begin(), v.end());
    for(auto e: v) {
        if(get<0>(e) == 0 || get<1>(e) == C) {
            if(stk.empty()) {
                stk.push(get<2>(e));
            } else if(stk.top() == get<2>(e)) {
                stk.pop();
            } else {
                stk.push(get<2>(e));
            }
        }
    }

    sort(v.rbegin(), v.rend());
    for(auto e: v) {
        if(get<0>(e) == 0 || get<1>(e) == C) continue;
        if(get<0>(e) == R || get<1>(e) == 0) {
            if(stk.empty()) {
                stk.push(get<2>(e));
            } else if(stk.top() == get<2>(e)) {
                stk.pop();
            } else {
                stk.push(get<2>(e));
            }
        }
    }

    if(stk.empty()) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 4596
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <ccomplex>
#include <unordered_map>
#include <cstring>
#include <iostream>
#include <numeric>
#include <sstream>
#include <set>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <map>

using namespace std;
#define MAX 1LL << 60

typedef long long ll;
typedef unsigned long long ull;

#define rep(i, s, e) for(ll i = s; i < e; i++)
#define repR(i, s, e) for(ll i = s; i > e; i--)
#define reft0(i, j) setfill('0') << setw(i) << j

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 main(){
    int N;
    double sum = 0;

    cin >> N;
    rep(i, 0, N){
        double tmp;
        string tmpS;
        cin >> tmp >> tmpS;
        if (tmpS == "JPY"){
            sum += tmp;
        }else{
            sum += tmp * 380000.0;
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Sort(a) sort(a.begin(), a.end())
#define Rev(a) reverse(a.begin(), a.end())
typedef long long ll;
const ll MOD = 1e9+7;

/*ll gcd(ll a, ll b){
  if(b==0) return a;
  return gcd(b, a%b);
}*/
/*ll myPow(ll x, ll n, ll m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}*/

/*ll lcm(ll a, ll b){
  ll g = gcd(a, b);
  b /= g;
  a *= b;
  return a;
}*/

/*int dfs(vector<int> &T, vector<int> &C, int i, int sum, int g, int count){
   
}*/

int main(){
  int n, m;
  cin >> n >> m;
  ll ans= (n-m)*100+1900*m;
  int g=1;
  rep(i, m) g *= 2;
  cout << ans*g << endl;

}



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

int main(){
	string S;
	cin >> S;
	int l = S.size();
	int a[l] = {0};
	for(int i = 0; i < l; i++){
		char c = S.at(i);
		if(c == 'A' || c == 'C' || c == 'G' || c == 'T')
			a[i] =  1;
	}
	int ans = a[0];
	for(int i = 1; i < l; i++){
		if(a[i] != 0)
			a[i] += a[i-1];
		ans = max(ans,a[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef string str;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=998244353;
const ll inf=1e18;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define pb(x) pop_back(x)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define sum(x) accumulate(all(x),0)
#define lb(x,a) lower_bound(all(x),a)
#define ub(x,a) upper_bound(all(x),a)
#define pc(x) __builtin_popcount(x)
#define gll greater<ll>()

void solve(){
 ll n,x,m;
  cin >> n >> x >>m;
 ll s=0; 
 map<ll,ll> mp;
  vll v;
  ll z=n;
  while(z--){
    if(mp[x]>=2) break;
    mp[x]++;
    s+=x;
    x*=x;
    x%=m;
    if(x==0||z==0) {
      cout << s << endl;
      return; 
    }
  }
 
  ll num=0;
  ll ans=0;
  s=0;
  for(auto p:mp){
   if(p.se==2){
    s+=p.fi;
    num++; 
   }else{
    ans+=p.fi;
    n--; 
   }
  }
  
  ans+=(n/num)*s;
  n-=(n/num)*num;
  
  while(n--){
   ans+=x;
   x*=x;
   x%=m; 
  }
  cout << ans << endl;
  
}
int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
  solve();
}

Measured memory_bytes: 6768
#include <iostream>

using namespace std;

int main(void) {
	int p, g = 0, k = 0, a, i;
	long long num;
	cin >> num >> p;
	for (i = 0; i < num; i++) {
		scanf("%d", &a);
		if (a & 1)
			k++;
		else
			g++;
	}
	if (k == 0) {
		if (p)
			printf("0\n");
		else
			cout << (1ll << num) << "\n";
		return 0;
	}
	cout << (1ll << (num - 1)) << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
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; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main(){
    int A,B;cin >> A >> B;
    if(A > 2*B){
        cout << A - 2*B <<  endl;
    }
    else{
        cout << 0 << endl;
    }
}



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

typedef long long ll;
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    ll ans = 0;
    int cur = 0;
    int index = 0;
    while (index < s.size()) {
        char ss = s[index];
        if (ss == 'A') {
            cur++;
            index++;
        } else if (ss == 'B' && s[index+1] == 'C') {
            ans += cur;
            index += 2;
        } else {
            cur = 0;
            index++;
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
    int a, b, c, d, e, k;
    cin >> a >> b >> c >> d >> e >> k;

    int x[] = {a, b, c, d, e};

    sort(x, x+5); 

    if(x[4] - x[0] <= k) {
        cout << "Yay!";
    }
    else {
        cout << ":(";
    }

    cout << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();

        int M = sc.nextInt()*60+sc.nextInt();

        double hx = A*Math.sin(Math.toRadians(0.5 * M)), hy = A*Math.cos(Math.toRadians(0.5 * M));
        double mx = B*Math.sin(Math.toRadians(6 * M)), my = B*Math.cos(Math.toRadians(6 * M));

        System.out.println(Math.sqrt((hx-mx)*(hx-mx) + (hy-my)*(hy-my)));
    
    }
}


Measured memory_bytes: 35924
#include <bits/stdc++.h> 
using namespace std; 
#define flash ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ll long long
#define INF 1000000000
#define pb push_back
#define ve vector<ll>
#define dos pair<ll,ll>
#define vedos vector<dos>
struct greateri
{
    template<class T>
    bool operator()(T const &a, T const &b) const { return a > b; }
};
int main()
{
  //flash;
  ll x;
  cin>>x;
  ll glob=0;
  ll last=0;
  ll cur=0;
  for (ll i = 0; i < x; ++i)
  {
  	ll yo;cin>>yo;
  	if(yo>last)
  	{
  		last=yo;
  		glob=max(cur,glob);
  		cur=1;
  	}
  	else
  	{
  		cur++;
  		last=yo;
  	}
  }
  glob=max(cur,glob);
  cout<<glob-1;
  return 0;
}
//code the AC sol !
// BS/queue/map

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(n) begin(n), end(n)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
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);
}
struct UnionFind
{
    vector<int> data;

    UnionFind(int sz)
    {
        data.assign(sz, -1);
    }

    bool unite(int x, int y)
    {
        x = find(x), y = find(y);
        if (x == y)
            return (false);
        if (data[x] > data[y])
            swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return (true);
    }

    int find(int k)
    {
        if (data[k] < 0)
            return (k);
        return (data[k] = find(data[k]));
    }

    int size(int k)
    {
        return (-data[find(k)]);
    }
    bool same(int x, int y)
    {
        return find(x) == find(y);
    }
};

int main()
{
    int N,M;
    cin>>N>>M;
    vint p(N);
    UnionFind uf(N);
    int cnt=0;
    for (size_t i = 0; i < N; i++)
    {
        cin>>p[i];
        p[i]--;
    }
    int x,y;
    for (size_t i = 0; i < M; i++)
    {
        cin>>x>>y;
        x--;y--;
        uf.unite(x,y);
    }
    int ans = 0;
    for (size_t i = 0; i < N; i++)
    {
        if(uf.same(i,p[i]))ans++;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
#define rep(i,n) for (ll i = 0; i < (n); i++)
#define repd(i,a,b) for (ll i = (a); i < (b); i++)
#define INF LLONG_MAX
#define mod 1000000007
typedef long long ll;

int main(void)
{
	long long a, b, c;
	cin >> a >> b >> c;
	ll d = c-a-b;
	if(4*a*b < d*d && d > 0) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


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

namespace contest_Csharp
{

    class Program
    {
        public static (long m, long s)[,] dp;
        public static long mod;

        static long power(long a, long b, long modulo)
        {
            long result = 1;
            long buff = a;
            for (int i = 1; i <= b; i *= 2)
            {
                result = result * ((b / i % (2) == 1) ? buff : 1) % modulo;
                buff = (buff * buff) % modulo;
            }
            return result % modulo;
        }
        static long binomal(long n, long r, long modulo)
        {
            long result = 1;
            for (long i = 0; i < r; i++)
            {
                result = (result * (n - i)) % modulo;
                result = (result * power(i + 1, modulo - 1, modulo)) % modulo;
            }
            return result;
        }
        static void Main(string[] args)
        {
            checked
            {
                var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
                Console.SetOut(sw);

                var vals = Console.ReadLine().Split(' ').
                    Select(x => long.Parse(x)).ToList();

                mod = (long)1e9 + 7;
                var N = vals[0];


                var ans = (power(10, N, mod)-2*power(9,N,mod))%mod;

                ans = (ans + power(8, N, mod) % mod);
                ans = (mod + ans) % mod;

                Console.WriteLine(ans);

                Console.Out.Flush();
            }//cheked




        }
        static long gcd(long a, long b)
        {
            long large = Math.Max(a, b);
            long small = Math.Min(a, b);
            while (large % small != 0)
            {
                var S = small;
                small = large % small;
                large = S;
            }
            return small;
        }
    }

}




Measured memory_bytes: 28248
import numpy as np
from numba import njit

@njit
def main(N):
    spf = np.zeros(N+1,np.int32)
    prime = np.zeros(N+1,np.int32)
    index = 0
    for i in range(2,N+1):
        if not spf[i]:
            spf[i] = i
            prime[index] = i
            index += 1
        for j in range(index):
            if prime[j] > i or i*prime[j] > N:
                break
            spf[i*prime[j]] = prime[j]
    ans = 0
    for k in range(1,N+1):
        n = k
        before = spf[n]
        count = 0
        fk = 1
        while n > 1:
            if spf[n] == before:
                count += 1
                n //= spf[n]
            else:
                fk *= (count+1)
                before = spf[n]
                count = 1
                n //= spf[n]
        fk *= (count+1)
        ans += k*fk
    print(ans)
    
N = int(input())
main(N)

Measured memory_bytes: 189440
#include <cstdio>
#include <string>
#include <cmath>
#include <string>
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
#include <iomanip>
#include <tuple>
#include <queue>
using namespace std;
typedef long long ll;
#define rep(i, a, n) for (int i=a;i<n;++i)
#define repeq(i, a, n) for(int i=a;i<=n;++i)
#define per(i, a, n) for (int i=n-1; i>=a;--i)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()

// C - March
int N;
int march[5];
char pattern[5] = {'M', 'A', 'R', 'C', 'H'};
ll ans = 0;
map<char, ll> m;
string march_s = "MARCH";

int main(){
    cin >> N;
    rep(i, 0, N){
        string S;
        cin >> S;
        m[S[0]]++;
    }

    rep(a, 0, 5){
        rep(b, a+1, 5){
            rep(c, b+1, 5){
                ans += m[march_s[a]] * m[march_s[b]] * m[march_s[c]];
            }
        }
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
using namespace std;
int main(void)
{
     int i,j,k,n,m,x;
     scanf("%d%d%d",&n,&m,&x);
     int l=0;
     for(i=0;i<=n;i++)
     {
          k=i*m;
          for(j=0;j<=m;j++)
          {
               int kk=k+j*n-j*i*2;
               if(kk==x)
               {
                    l=1;
                    break;
               }
          }
          if(l==1)
               break;
     }
     if(l==1)
          printf("Yes\n");
     else
          printf("No\n");
     return 0;
}


Measured memory_bytes: 256
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")


# 処理内容
def main():
    H1, M1, H2, M2, K = map(int, input().split())
    a = M1 + H1 * 60
    b = M2 + H2 * 60
    if b-a < K:
        print(0)
    else:
        print(b-a-K)
    


if __name__ == '__main__':
    main()

Measured memory_bytes: 72752
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	int n; cin >> n;
	vi a(n); rep(i, n) cin >> a[i];
	sort(all(a));
	
	vector<ll> s(n + 1);
	rep(i, n) s[i + 1] = s[i] + a[i];
	for(int i = n - 1; i >= 0; i--){
		if(a[i] > 2 * s[i]){
			cout << n - i << endl;
			return 0;
		}
	}
	
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define EPS (1e-10)
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
 
int t[100],v[100];
map<int,int>dp[60000];
 
int main(){
	int n;scanf("%d",&n);
	rep(i,n)cin>>t[i],t[i]*=2;
	rep(i,n)cin>>v[i],v[i]*=2;
	int k=0;
	int sum=t[0];
	dp[0][0]=0;
	rep(i,50000){
		bool flag=false;
		if(i+1>=sum){
			if(k<n-1){
				flag=true;
				k++;sum+=t[k];
			}
		}
		for(auto p:dp[i]){
			int j=p.first;
			if(j&&j-1<=v[k])dp[i+1][j-1]=max(dp[i+1][j-1],dp[i][j]+j-1);
			if(j+1<=v[k]){
				if(flag){
					if(j+1<=v[k-1])dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j]+j+1);
				}
				else dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j]+j+1);
			}
			if(j<=v[k])dp[i+1][j]=max(dp[i+1][j],dp[i][j]+j);
		}
		if(i+1>=sum&&k==n-1)break;
	}
	printf("%.12lf\n",dp[sum][0]/4.);
}

Measured memory_bytes: 199936
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;
int main() {
	int N; cin>>N;
	vector<int>a(N);
	for(auto & e:a) cin>>e;

	int sum=0;
	for(auto e:a) sum+=e-1;

	cout<<sum<<endl;

	return 0;
}


Measured memory_bytes: 256
n = int(input())
l = list(map(int,input().split()))

ret = 0
for i in range(n):
    for j in range(i+1,n):
        for k in range(j+1,n):
            x,y,z = l[i],l[j],l[k]
            lis = [x,y,z]
            lis = sorted(lis)
            if len(set(lis)) == 3 and lis[-1] < lis[0] + lis[1]:
                #print(lis)
                ret+=1

print(ret)

Measured memory_bytes: 74032
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vb = vector<bool>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define LINF 1E18*5
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

template<class S, class T>ostream& operator<<(ostream&os, pair<S, T>p) { os << "[" << p.first << ", " << p.second << "]"; return os; };
template<class S>auto&operator<<(ostream&os, vector<S>t) { bool a = 1; for (auto s : t) { os << (a ? "" : " ") << s; a = 0; } return os; }

//int dx[]={1,1,1,0,-1,-1,-1,0},dy[8]={1,0,-1,-1,-1,0,1,1,1};
//
constexpr ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

class compare {
public:
	bool operator()(tuple<int, int> a, tuple<int, int> b) {
		return (get<1>(a) < get<1>(b));
	}

};

void solve(ll n) {
	ll ans = 1;
	ll fsans = n;
	for (ll i = 2; i*i <= n*2; i++){
		ll l = n - ((i - 1)*i / 2);
		if (l >= 0 && l%i == 0) {
			fsans = l / i;
			ans = i;
		}
	}
	cout << fsans << " " << ans << endl;
}


int main() {
	ll n;
	while (cin >> n, n) {
		solve(n);
	}
}



Measured memory_bytes: 3092
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(void)
{
  long long int a,b,c,d; cin>>a>>b>>c>>d;
  vector<long long int> m(4);
  m[0]=a*c;
  m[1]=a*d;
  m[2]=b*c;
  m[3]=b*d;
  
  sort(m.begin(),m.end());
  
  cout<<m[3]<<endl;
  
  return 0;
}

Measured memory_bytes: 3580
fun main(args: Array<String>) {
  val (a, b) = readInts()
  var aStr = ""
  var bStr = ""
  for (i in 0 until b) {
    aStr += a
  }
  for (i in 0 until a) {
    bStr += b
  }
  println(if (aStr < bStr) aStr else bStr)
}

fun readString() = readLine()!!
fun readStrings() = readString().split(" ")
fun readInt() = readString().toInt()
fun readInts() = readStrings().map { it.toInt() }
fun readLongs() = readStrings().map { it.toLong() }


Measured memory_bytes: 36060
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
//cout<<setprecision(20)
//cin.tie(0);
//ios::sync_with_stdio(false);
const llint mod=1000000007;
const llint big=4.19e18+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
int LBI(vector<int>&ar,int in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
int UBI(vector<int>&ar,int in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	int n,m,i,x,y;cin>>n>>m;
	vector<int>p(n);
	for(i=0;i<n;i++){cin>>p[i];p[i]--;}
	vector<int>go(n);
	vector<int>ran(n);
	for(i=0;i<n;i++){go[i]=i;}
	for(i=0;i<m;i++){
		cin>>x>>y;x--;y--;
		while(x!=go[x]){x=go[x];}
		while(y!=go[y]){y=go[y];}
		if(x==y){continue;}
		if(ran[x]<ran[y]){swap(x,y);}
		go[y]=x;
		if(ran[x]==ran[y]){ran[x]++;}
	}
	for(i=0;i<n;i++){
		int x=i;
		while(x!=go[x]){x=go[x];}
		go[i]=x;
	}
	vector<vector<int>>ren(n);
	for(i=0;i<n;i++){ren[go[i]].pub(i);}
	for(i=0;i<n;i++){SO(ren[i]);}
	int ans=0;
	for(i=0;i<n;i++){
		int ba=LBI(ren[go[i]],p[i]);
		if(ba<ren[go[i]].size()&&ren[go[i]][ba]==p[i]){ans++;}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 6912
# coding: utf-8
# Your code here!
import numpy as np

N = int(input())

A = list(map(int,input().split()))
B = A
ct = 0

for i in range(N):
    j = N-i-1
    if(j+1>N/2):
        B[j] = A[j]
        
        if(B[j]==1):
            ct = ct + 1
    else:
        sum = 0
        for k in range(j+1,N+1,j+1):
            if(k%(j+1)==0 and k!=j+1):
                
                sum = sum + B[k-1]
        if(sum%2==0):
            B[j] = A[j]
            if(B[j]==1):
                ct = ct + 1
        else:
            B[j] = 1 - A[j]
            
            if(B[j]==1):
                ct = ct + 1
        

print(ct)
C = []

for i in range(N):
    if(B[i]==1):
        C.append(i+1)
print(*C)



Measured memory_bytes: 21676
N, M = map(int, input().split())

imos = [0] * (N + 1)

for i in range(M):
    l, r = map(int, input().split())
    imos[l - 1] += 1
    imos[r] -= 1

for i in range(N):
    imos[i + 1] = imos[i] + imos[i + 1]

# print(imos)
print(imos[:-1].count(M))



Measured memory_bytes: 7748
n=int(input())

#t={}
s=[]
#t=set(list(input()))
si=input()
lsi=list(si)
lsi.sort()
s.append([lsi[0],100])
for i in range(1,len(lsi)):
    if lsi[i]!=lsi[i-1]:
        s.append([lsi[i],100])
#print(s)
for j in range(len(s)):
    s[j][1]=min(s[j][1],si.count(s[j][0]))
for i in range(n-1):
    si=input()
    for j in range(len(s)):
        s[j][1]=min(s[j][1],si.count(s[j][0]))

#s=list(t)
strs=""
for i in range(len(s)):
    for ii in range(s[i][1]):
        strs=strs+s[i][0]
print(strs)


Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
typedef struct
{
    char name[10];
    int quantum;
}Task;
typedef struct
{
    int tail;
    int head;
    int acSize;
    int maxSize;
}Queue;
void enqueue(Task a,Queue *queue, Task *task);
Task dequeue(Task a,Queue *queue, Task *task);
void getnew (int interval,Queue *queue, Task p[]);
int ifIsFull(Queue *queue);
int main() {
    int interval, size;
    scanf("%d %d",&size, &interval);
    Task task[size];
    Queue queue;
    queue.acSize=0;
    queue.maxSize=size;
    queue.head=0;
    queue.tail=0;
    Task tempTask;
    for(int i = 0; i < size; ++i)
    {
        scanf("%s %d", tempTask.name, &tempTask.quantum);
        enqueue(tempTask, &queue, task);
    }
    getnew(interval,&queue,task); 
    return 0;
}
void enqueue(Task a,Queue *queue, Task *task)
{
    int tail;
    tail = queue->tail;
    if(ifIsFull(queue)==0)
    {
        task[tail] = a;
        queue->tail = (queue->tail+1) % queue->maxSize;
        queue->acSize++;
    }
    if(queue->acSize == queue->maxSize)
    {
        queue->tail = -1;
    }
}
void getnew (int interval,Queue *queue, Task p[])
{
    Task temp;
    int toltime = 0;
    while(queue->head != queue->tail){  
        if(queue->tail < 0 || queue->tail > queue->maxSize - 1)
        {
            queue->tail = queue->head;
        }
        temp = p[queue->head];
        queue->head = (queue->head + 1) % queue->maxSize;
        queue->acSize--;   
        if(temp.quantum <= interval)
        {
            toltime += temp.quantum;
            printf("%s %d\n",temp.name, toltime);
        }
        else 
        {
            toltime += interval;
            temp.quantum -= interval;
           if(ifIsFull(queue)==0)
        {
            p[queue->tail] = temp;
            queue->tail = (queue->tail+1) % queue->maxSize;
            queue->acSize++;
        }
        if(queue->acSize == queue->maxSize)
        {
            queue->tail = -1;
        }
        }
    }
}
int ifIsFull(Queue *queue)
{
    if(queue->acSize < queue->maxSize)
        return 0;
    else 
        return 1; 
}



Measured memory_bytes: 2616
#include <bits/stdc++.h>
using namespace std;
using Int = int_fast64_t;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	Int h, w; cin >> h >> w;
	Int a = (w+1)/2, b = (h+1)/2;
	if(h == 1 || w == 1) cout << 1 << "\n";
	else cout << a*b + (w-a)*(h-b) << "\n";
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)









int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    ll sum = 0, cnt = 0;
    REP(i, n){
        cin >> a[i];
        sum += abs(a[i]);
        if(a[i] < 0) cnt++;
    }
    if(cnt % 2 == 1){
        ll mn = INF;
        REP(i, n){
            mn = min(mn, abs(a[i]));
        }
        sum -= 2 * mn;
    }
    cout << sum << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for(int i = 1, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define PRINT(A) std::cout << (#A) << ":" << (A) << std::endl;

typedef long long int ll;
const int MOD = 1e9 + 7;
const int INF = 1e9;

using namespace std;

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  int ans = min(A * N, B);
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;

int main() {
    int N;
    string S;
    cin >> N >> S;
    int ans = 0;
    for(int i = 0; i < 1000; i++) {
        string pin = to_string(i);
        while(pin.size() < 3) pin = '0' + pin;
        int checking = 0;
        for(int j = 0; j < N && checking < 3; j++) {
            if(S[j] == pin[checking]) checking++;
        }
        if(checking >= 3) {
            ans++;
        }
    }
    cout << ans;
    return 0;
}


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

ab=0
ba=0
if sum(a)>sum(b):
    ans="No"
else:
    for i in range(N):
        abtmp=max(a[i]-b[i],0)
        ab+=abtmp
        batmp=max(b[i]-a[i],0)
        ba+=batmp//2
    if ab>ba:
        ans="No"
    else:
        ans="Yes"

print(ans)

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

using namespace std;

int main(){
  int N, K;
  cin >> N >> K;
  
  vector<int> max_sushi(N, 0);
  priority_queue<pair<int, int>> pq;
  for(int i = 0; i < N; i++){
    int t, d;
    cin >> t >> d;
    t--;
    max_sushi[t] = max(d, max_sushi[t]);
    pq.push(make_pair(d, t));
  }
  
  vector<int> a(N, 0);
  long long delicious = 0;
  vector<pair<int, int>> used;
  for(int i = 0; i < K; i++){
    delicious += pq.top().first;
    used.push_back(pq.top());
    a[pq.top().second]++;
    pq.pop();
  }
  sort(used.begin(), used.end());
  
  long long kind = 0;
  priority_queue<int> pq2;
  for(int t = 0; t < N; t++){
    if(a[t] == 0 && max_sushi[t]) pq2.push(max_sushi[t]);
    else if(a[t]) kind++;
  }
  
  long long point = delicious + kind * kind;
  
  for(int i = 0; i < used.size() && !pq2.empty();){
    while(i < used.size() && a[used[i].second] <= 1) i++;
    if(i < used.size()){
      delicious -= used[i].first;
      a[used[i].second]--;
      i++;
      delicious += pq2.top();
      pq2.pop();
      kind++;
      point = max(delicious + kind * kind, point);
    }
  }
  
  cout << point << endl;
  
  return 0;
}

Measured memory_bytes: 3316
import Foundation

#if swift(>=4.0)
extension String {
    func split(by separator: String) -> [String] {
        return self.components(separatedBy: separator)
    }
    func toArray() -> [String] {
        return self.map{String($0)}
    }
}
func exponentiate(_ lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#else
extension String {
    func split(by separator: String) -> [String] {
        return self.componentsSeparatedByString(separator)
    }
    var count: Int {
        return self.characters.count
    }
    func toArray() -> [String] {
        return self.characters.map{String($0)}
    }
    func uppercased() -> String {
        return self.uppercaseString
    }
    func lowercased() -> String {
        return self.lowercaseString
    }
}
//extension Array where Element == String {
//    func joined(separator separator: String) -> String {
//        return self.joinWithSeparator(separator)
//    }
//}
extension Array where Element: Comparable {
    func max() -> Element? {
        return self.maxElement()
    }
    func min() -> Element? {
        return self.minElement()
    }
    func sorted() -> Array {
        return self.sort()
    }
    func reversed() -> Array {
        return self.reverse()
    }
//    func enumerated() -> [(Int, Element)] {
//        return self.enumerate()
//    }
    mutating func sort() {
        self.sortInPlace()
    }
}
extension Array {
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
}
func stride<T: Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T> {
    return start.stride(to: end, by: stride)
}
func exponentiate(lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#endif
func readInt() -> Int? {
    return Int(readLine()!)
}
func readStringSplit(by separator: String) -> [String] {
    return readLine()!.split(by: separator)
}
func readIntSplit(by separator: String) -> [Int] {
    return readLine()!.split(by: separator).map{Int($0)!}
}

/*************** テストスペース ***************/

func gcd(_ x: Int, _ y: Int) -> Int {
    if y == 0 {
        return x
    } else {
        return gcd(y, x%y)
    }
}

/*************** メインプログラム ***************/

let input = readIntSplit(by: " ")
let N = input[0]
let x = (readIntSplit(by: " ") + [input[1]]).sorted()
let d = (1...N).map{x[$0] - x[$0-1]}
var ans = 0
for i in d {
    ans = gcd(i, ans)
}
print(ans)


Measured memory_bytes: 8252
#include <bits/stdc++.h>
#define rep(i , n) for (int i = 0; i < (int)(n); i++)
const int INF = 1<<29;
using namespace std;
using ll = long long;
vector <int> F(30);
int main(){
    int H , W;
    cin >> H >> W;
    vector <string> C(H);
    for(int i = 0; i < H; i++){
        cin >> C[i];
        cout << C[i] << endl;
        cout << C[i] << endl;
    }
}

Measured memory_bytes: 3624
N,Y = map(int,input().split())

for i in range(N+1):
    for j in range(N+1):
        num = Y - i * 10000 - j * 5000
        
        if num % 1000 == 0 and N == i + j + num//1000 and num >= 0:
            print(i,j,num//1000)
            quit()
            
print(-1,-1,-1)

Measured memory_bytes: 42436
//Radhe Radhe
#include<bits/stdc++.h>
#define godspeed  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define rep1(i,a,b)    for(ll i=a; i<=b; i++)
#define repVect(i,n)    for(ll i=0; i<sum.size(); i++)
#define fixed cout.setf(ios::fixed);
#define Precise cout.precision(7);
#define yes cout<<"Yes"<<'\n';
#define no cout<<"No"<<'\n';
using namespace std;

int main()
{
    godspeed
    ll  t,i,j,k,n;
    cin>>n;
    ll a[n];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    ll dist=0;
    for(i=0;i<n;i++)
     {
        if(a[0]==a[i])continue;
        else dist+=abs(a[i]-a[i-1]);
     }
        cout<<dist<<endl;

    return 0;
}





Measured memory_bytes: 3620
#include <stdio.h>
int main (){
    long long int N; //test case
    long long int total=1;
    
    scanf("%lld",&N);
    long long int A[N]; //input nilainya
    
    for(int i=0;i<N;i++){
        scanf("%lld", &A[i]);
    }
    for(int j=0;j<N;j++){
        if(A[j] == 0){  //mirip seperti ?: (ternary operator)
            printf("0"); //angka berapapun kalo dikali 0, hasilnya tetap 0
            return 0;
        }
    }
    for(int k=0;k<N;k++){
        if(A[k]<=1000000000000000000/total){
            total = total*A[k];
            // apakah angka yang dikalikan itu < 10^18
       // apakah input <= 10^18/total
        } else {
            printf("-1");
            return 0;
        }
    }
    printf("%lld\n", total);
    
    
return 0;
}

Measured memory_bytes: 2460
"use strict";

function main(input) {
    input = input.split(" ").map(s => +s);
    const ia = input[0],
          ib = input[1];

    let result = -1;
    for (let i = ib * 10; i < ib * 100; i++) {
        let A = ~~(i * 0.08);
        let B = ~~(i * 0.1);
        if (A === ia && B === ib) {
            result = i;
            break;
        }
    }
    console.log(result);
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

ll binary_search(
    ll lo, ll hi, function<bool(ll)> is_ok,
    bool maximize
){
    while(lo < hi){
        if(maximize){
            const ll mid = (lo + hi + 1) / 2;
            if(is_ok(mid)){
                lo = mid;
            }else{
                hi = mid - 1;
            }
        }else{
            const ll mid = (lo + hi) / 2;
            if(is_ok(mid)){
                hi = mid;
            }else{
                lo = mid + 1;
            }
        }
    }
    return lo;
}


ll ask(vector<ll>& a){
    cout << "? ";
    REP(i, a.size()){
        cout << a.at(i) + 1;
        if(i + 1 < a.size()){
            cout << ' ';
        }
    }
    cout << endl << flush;
    string s;
    cin >> s;
    if(s == "Red"){
        return 0;
    }else if(s == "Blue"){
        return 1;
    }else{
        exit(0);
    }
}

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

    vector<ll> tmp(n);
    REP(i, n){ tmp.at(i) = i; }
    ll col0 = ask(tmp);

    ll pos = binary_search(
        1, n,
        [&](ll mid) -> bool {
            vector<ll> tmp(n);
            REP(i, n){ tmp.at(i) = mid + i; }
            ll col = ask(tmp);
            return col != col0;
        },
        false
    );

    vector<ll> ans(2 * n, -1);
    ans.at(pos - 1) = col0;
    ans.at(pos + n - 1) = 1 - col0;

    vector<ll> tmp1, tmp2;
    REP(i, 2 * n){
        if(i == pos - 1 || i == pos + n - 1){
            continue;
        }else if(pos - 1 < i && i < pos + n - 1){
            tmp1.push_back(i);
        }else{
            tmp2.push_back(i);
        }
    }
    tmp1.push_back(-1);
    tmp2.push_back(-1);

    REP(i, 2 * n){
        if(ans.at(i) != -1){
            continue;
        }
        if(i < pos - 1 || pos + n - 1 < i){
            tmp1.back() = i;
            ans.at(i) = ask(tmp1);
        }else{
            tmp2.back() = i;
            ans.at(i) = ask(tmp2);
        }
    }

    cout << "! ";
    REP(i, 2 * n){
        if(ans.at(i) == 0){
            cout << 'R';
        }else{
            cout << 'B';
        }
    }
    cout << endl << flush;

    return 0;
}


Measured memory_bytes: 724
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
#include<numeric>
#include<complex>
#include<ctype.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0;i<n;++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl

const ll mod = 1e9 + 7;
const ll inf = 1e18;

void pV(vector<ll> A){
    cout << "[vector]" << endl;
    for(int i=0; i<A.size(); i++){
        cout << A[i] << " ";
    }
    cout << endl;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    // input
    int A, B, C;
    cin >> A >> B >> C;

    vector<int> v;
    v.push_back(A);
    v.push_back(B);
    v.push_back(C);

    sort(ALL(v));

    int score = v[2] * 10 + v[0] + v[1];
    p(score);
    
    return 0;
}

Measured memory_bytes: 256
A,B,C = map(int,input().split())
K = int(input())
L = max(A,B,C)
if L == A:
  print((A*(2**K))+B+C)
elif L == B:
  print(A+(B*(2**K))+C)
else:
  print(A+B+(C*(2**K)))

Measured memory_bytes: 3060
n,d=map(int,input().split())
x=[]
out=0
for i in range(n):
    x.append(list(map(int,input().split())))

for i in range(n):
    for j in range(i+1,n):
        tol=0
        for k in range(d):
            tol+=(x[i][k]-x[j][k])**2
        if tol**(1/2)-int(tol**(1/2))==0:
            out+=1
print(out)


Measured memory_bytes: 3316
N=int(input())
a=list(map(int,input().split()))
M=0
b=[]
c=[]
for i in range(N):
    b.append(0)

for i in range(N-1,-1,-1):
    s=0
    for j in range(N//(i+1)):
        s+=b[(j+1)*(i+1)-1]
    if s%2!=a[i]:
        b[i]=1

for i in range(N):
    if b[i]==1:
        M+=1
        c.append(str(i+1))

print(M)
print(' '.join(c))


Measured memory_bytes: 17212
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

const ll M = 1000000007;

int main(){
	static ll n;
	static ll t[100010];
	static ll a[100010];
	static ll h[100010];
	static ll H[100010];
	scanf("%lld",&n);
	rep(i,n)scanf("%lld",&t[i]);
	rep(i,n)scanf("%lld",&a[i]);
	
	rep(i,100010){
		h[i] = -1;
		H[i] = 1000000000;
	}
	int x = -1;
	rep(i,n){
		if(x < t[i]){
			h[i] = t[i];
			x = t[i];
		}
		else H[i] = t[i];
	}
	x = -1;
	rrep(i,n){
		if(x < a[i]){
			if(h[i] != -1 && h[i] != a[i]){
				puts("0");
				return 0;
			}
			h[i] = a[i];
			x = a[i];
		}
		else H[i] = min ( H[i] , a[i] );
	}
	
	ll ret = 1;
	rep(i,n){
		if(h[i] == -1){
			ret *= H[i];
			ret %= M;
		}
		else if(h[i] > H[i])ret = 0;
	}
	cout << ret << endl;
}


Measured memory_bytes: 3328