akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
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 <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

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

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    int n = (int)s.length();
    vector<vector<ll> > dp(n + 1, vector<ll>(2));
    ll MOD = 1000000007;
    dp[0][0] = 1;
    rep (i, n) {
        if (s[i] == '1') {
            dp[i + 1][0] = (dp[i][0] * 2) % MOD;
            dp[i + 1][1] = (dp[i][1] * 3 + dp[i][0]) % MOD;
        } else {
            dp[i + 1][0] = dp[i][0];
            dp[i + 1][1] = (dp[i][1] * 3) % MOD;
        }
    }
    rep (i, 2) {
        rep (j, n + 1) eprintf("%lld ", dp[j][i]); eprintf("\n");
    }
    cout << (dp[n][0] + dp[n][1]) % MOD << "\n";
    return 0;
}

Measured memory_bytes: 5840
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tll;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S, T;
    cin >> S >> T;
    vector<int> sCharToIndex(26);//'a' = 0, 'z' = 25
    int sCharMaxIndex = 0;
    vector<int> tCharToIndex(26);//同上
    int tCharMaxIndex = 0;
    for(int i = 0; i < S.size(); i++)
    {
        int sChar = S.at(i) - 'a';
        int tChar = T.at(i) - 'a';
        if(sCharToIndex.at(sChar) == 0)
        {
            sCharMaxIndex++;
            sCharToIndex.at(sChar) = sCharMaxIndex;
        }
        if(tCharToIndex.at(tChar) == 0)
        {
            tCharMaxIndex++;
            tCharToIndex.at(tChar) = tCharMaxIndex;
        }
        int sIndex = sCharToIndex.at(sChar);
        int tIndex = tCharToIndex.at(tChar);
        if(sIndex != tIndex)
        {
            cout << "No" << endl;
            return 0;
        }
    }    
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 916
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef pair<int, int> P;
typedef pair<ll,ll> LP;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
const double PI = acos(-1.0);
const double EPS = 1e-10;

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; }
//template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

// 線分ab の偏角 [-π, π] を返す
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax = a.first, ay = a.second, bx = b.first, by = b.second;
    return atan2(by - ay, bx - ax);
}

// 偏角ソート
void argumentSort(vector<pair<long double, long double>> &v){
    pair<long double, long double> o(0, 0);
    sort(v.begin(), v.end(), [&](auto a, auto b){return argument(o, a) < argument(o, b);});
}

void solve(){
    int n;
    cin >> n;
    vector<pair<long double, long double>> xy;
    REP(i,n){
        long double a, b;
        cin >> a >> b;
        if(a == 0 && b == 0) continue;
        xy.emplace_back(a, b);
    }
    argumentSort(xy);
    long double ans = 0;
    int m = xy.size();
    REP(i,m){
        long double x = 0, y = 0;
        REP(j,m){
            x += xy[(i+j)%m].first;
            y += xy[(i+j)%m].second;
            chmax(ans, hypot(x, y));
        }
    }
    printf("%.12Lf\n", ans);
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    // int T; cin >> T; REP(t,T) solve();
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

typedef long long ll;
typedef pair<ll,ll> P;

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

	ll n, k;cin >> n >> k;
	vector<ll> a(n);
	vector<ll> b(n);
	vector<ll> c(n);

	REP(i, n)c[i] = k + 2 * n + i;
	ll ida = 0;
	ll idb = (n > 1);
	REP(i, n){
		a[ida] = k + i;
		b[idb] = k + n + i;
		ida += 2;if(ida >= n)ida = 1;
		idb += 2;if(idb >= n)idb = 0;
	}

	// SHOW1d(a, n);
	// SHOW1d(b, n);
	// SHOW1d(c, n);

	REP(i, n){
		if(a[i] + b[i] > c[i]){
			cout << -1 << endl;
			return 0;
		}
	}

	REP(i, n)cout << a[i] << " " << b[i] << " " << c[i] << endl;

	return 0;
}


Measured memory_bytes: 4608
s = input()

def is_kaibun(s_):
  s_len = len(s_)
  for i in range(int(s_len / 2)):
    if s_[i] != s_[s_len - i - 1]:
      return False
  else:
    return True
    
c_2 = s[:int((len(s) - 1) /2)]
c_3 = s[int((len(s) + 3) / 2)-1:]

result_1 = is_kaibun(s)
result_2 = is_kaibun(c_2)
result_3 = is_kaibun(c_3)

if result_1 and result_2 and result_3:
  print("Yes")
else:
  print("No")


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

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

    long long ans = 2000000000000;
    for (long long i = 1; i <= 1000000; i++){
        if (N % i == 0){
            long long j = N / i;
            long long dist = (i - 1) + (j - 1);
            ans = min(ans, dist);
        }
    }
    cout << ans << endl;
}


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

const int inf=1000000000;

int main() {
  int n,m,x; cin>>n>>m>>x;
  vector<int> c(n);
  vector<vector<int> > t(n, vector<int>(m));
  rep(i, n) {
    cin>>c[i];
    rep(j, m) cin>>t[i][j];
  }
  int res=inf;
  rep(bit, (1<<n)) {
    int tmp=0;
    vector<int> ok(m, 0);
    rep(i, n) {
      if (bit & (1<<i)) {
        tmp+=c[i];
        rep(j, m) {
          ok[j]+=t[i][j];
        }
      }
    }
    bool check=true;
    rep(i, m) {
      if (ok[i]<x) check=false;
    }
    if (check) res=min(res, tmp);
  }
  if (res!=inf) cout<<res<<endl;
  else cout<<-1<<endl;
}


Measured memory_bytes: 3636
#include<iostream>
#include <string>
#include<stdio.h>
#include <math.h>


using namespace std;


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

	int A, B;

	A = X / 100;
	B = X % 100;

	if (A * 5 >= B) cout << 1 << endl;
	else cout << 0 << endl;

	return 0;
}

	






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

typedef long long ll;
priority_queue<int> pq;

int main() {
    int N, M, A;
    ll sum = 0;
    cin >> N >> M;
    for (int i=0;i<N;i++) {
        cin >> A;
        pq.push(A);
    }
    for (int i=0;i<M;i++) {

        pq.push(pq.top()/2);
        pq.pop();
    }
    for (int i=0;i<N;i++) {
        sum += pq.top();
        pq.pop();
    }
    cout << sum << '\n';
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
#define INF (1e9)

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

  ll ans = 0;
  sort(A.begin(), A.end());  // 昇順
  sort(B.begin(), B.end());  // 昇順
  if (N % 2 == 0) {
    ans = B[N / 2] + B[N / 2 - 1] - A[N / 2] - A[N / 2 - 1] + 1;
  } else {
    ans = B[N / 2] - A[N / 2] + 1;
  }

  cout << ans << endl;
}


Measured memory_bytes: 6364
#include<stdio.h>
#include<math.h>
int max(int a, int b)
{
    if (a > b)
        return a;
    else
        return b;
}
int main()
{
    int n;
    scanf("%d", &n);
    int i;
    int x[102], y[102], h[102];
    for (i = 0; i < n; i++)
        scanf("%d %d %d", &x[i], &y[i], &h[i]);
    int j;
    int hh;
    int s, t;
    int p;
    for (s = 0; s < 101; s++)
    {
        for (t = 0; t < 101; t++)
        {
            i = 0;
            while (h[i] == 0)
                i++;
            hh = h[i] + abs(s - x[i]) + abs(t - y[i]);
            p = 0;
            for (i = 0; i < n; i++)
                if (max(hh - abs(x[i] - s) - abs(y[i] - t), 0) != h[i])
                {
                    p++;
                    break;
                }
            if (p == 0)
                break;
        }
        if (p == 0)
            break;
    }
    printf("%d %d %d\n", s, t, hh);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <array>
#include <algorithm>

int main()
{
    std::array<int, 5> in;
    for (auto i = 0; i < 5; i++) {
        std::cin >> in.at(i);
    }

    std::sort(in.begin(), in.end());

    for (auto i = 4; i >= 0; i--) {
        if (i != 4) {
            std::cout << " ";
        }
        std::cout << in.at(i);
    }
    std::cout << std::endl;

    return 0;
}

Measured memory_bytes: 1176
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def main():
    
    x, y = map(int, readline().split())
    if (x+y)%3!=0:
        print(0)
        return
    n = (x+y)//3
    a, b = (2*y-x)//3, (2*x-y)//3
    if a<0 or b<0:
        print(0)
        return
    o = cmb(n, a)
    o = o % (10**9+7)
    print(o)

if __name__ == "__main__":
    main()


Measured memory_bytes: 44084
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#pragma GCC optimize(2)
#define int long long
#define MAXN 2000000
#define INF (1e13 + 7)
#define MANX MAXN

using namespace std;

inline int read()
{
	int x = 0, f = 1; char c = getchar();
	while (c > '9' || c < '0') { if (c == '-') f = -1; c = getchar(); }
	while (c >= '0' && c <= '9') { x = x * 10 + (c ^ 48); c = getchar(); }
	return f * x;
}

int a[MAXN], vis[MAXN];

signed main()
{
	int n = read();
	for (int i = 1; i <= n; i++) a[i] = read(), vis[a[i]]++;
	for (int i = 1000000; i; i--)
		if (vis[i])
			for (int j = i + i; j <= 1000000; j += i)
				vis[j] += vis[i];
	int ans = 0;
	for (int i = 1; i <= n; i++) ans += (vis[a[i]] == 1);
	cout << ans;
	return 0;
}

Measured memory_bytes: 12964
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    string s = read!string;
    auto n = s.count!(c => c == 'o') + (15 - s.length);
    writeln(n >= 8 ? "YES" : "NO");
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>

#define lli long long int

using namespace std;

lli min(lli a,lli b){
	return a>=b ? b :a;
}

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


lli f(int a,int b){
	char tmp[20];
	return max( sprintf(tmp,"%d",a) , sprintf(tmp,("%d"),b));
}


int main(){

	lli n;

	cin>>n;

	lli ans = f(n,1);

	if(n%2==0){
		ans = f(n/2,2);
	}

	for(lli i = 3; i * i <= n; i+=2){
		if(n%i==0){
			ans = f(n/i,i);
		}
	}

	cout<<ans<<endl;

	return 0;






}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int a, b, c;
  int i;
  int count = 0;
  
  scanf("%d %d %d", &a, &b, &c);

  for(i = a; i <= b; i++){
    if(c % i == 0) count++;
  }

  printf("%d\n", count);
  
  return 0;
}




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

using namespace std;
double a[105];

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

    double ans = 0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        ans += (double)1/a[i];
    }
    ans = (double)1/ans;
   // cout<<ans<<" "<<sum;
    printf("%.10f",ans);

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N;
string S[50];
int T[50];
string X;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N;
	rep(i, 0, N) cin >> S[i] >> T[i];
	cin >> X;

	int ans = -1;
	rep(i, 0, N) {
		if(0 <= ans) ans += T[i];
		if (X == S[i]) ans = 0;
	}
	cout << ans << endl;
}







Measured memory_bytes: 256
def bitcount(N):  # 立ってるbitの数
    bitcnt = [0]
    for _ in range(N):
        bitcnt += [i + 1 for i in bitcnt]
    return bitcnt


n, x = int(input()), input()

num, cnt = int(x, 2), x.count('1')
lbit = bitcount(18)
for i in range(n):
    ans = 1
    if x[i] == '0':
        ctmp = cnt + 1
        tmp = num % ctmp + pow(2, n - (i + 1), ctmp)
    elif x[i] == '1':
        ctmp = cnt - 1
        if ctmp == 0:
            print(0)
            continue
        tmp = num % ctmp - pow(2, n - (i + 1), ctmp)
    tmp %= ctmp
    ctmp = lbit[tmp]
    while tmp > 0:
        ans += 1
        tmp %= ctmp
        ctmp = lbit[tmp]
    print(ans)


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

//vector…可変長、データの大きさに合わせてサイズを変える
//list…双方向リスト、要素を挿入、削除の多いとき
//forward_list
//array…固定長配列
//set…集合
//multiset
//bitset…2進数、固定長ビット列
//map…連想配列、キーと値を関連付ける
//multimap
//deque…双方向リスト
//stack…FILO, 深さ優先探索
//queue…FIFO, 幅優先探索
//priority_queue…格納された最大値から順に取り出す
//pair…二つの値を一組
//tuple…複数の値を一組

const int mod = 1e9+7;

template<typename T>
void remove(std::vector<T>& vector, char index) {
    vector.erase(vector.begin() + index);
}

template<class T>
T ma(std::vector<T> &v) {
    T maxi = 0;
    for(auto &i:v) maxi = max(maxi, i);
    return maxi;
}
template<class T>
T mi(std::vector<T> &v) {
    T mini = 0;
    for(auto &i:v) mini = min(mini, i);
    return mini;
}
template <class T>
T pow(T x, T y, T n = numeric_limits<T>::max()) {
    if(y == 0) return 1;
    if(y % 2 == 0) return pow((x * x) % n, y / 2);
    return (x * pow(x, y - 1)) % n;
}

#define rep(i, n, m) for (int i = n; i <= m; i++)
#define Rep(i, n, m) for (int i = m; i >= 1; i--)

typedef long long ll;
typedef unsigned long long ull;

int gcd(int x, int y) {
    if (x < y) swap(x, y);
    return !y ? x : gcd(x % y, y);
}

using Graph = vector<vector<int>>;

template <class T, class S>
class Edge {
  T to;  //辺の行き先
  S weight;  //辺の重み

public:
  Edge(T t, S w) : to(t), weight(w) {}
};

int ansi = 0;
ll ansl = 0;
double ansd = 0.0;

int accumul(int mul) {
  if (mul == 0) {
    return 1;
  } else {
    return mul * accumul(mul-1);
  }
}

int main() {
  int d, n;
  cin >> n >> d;
  int x[n][d];
  rep(i, 0, n-1) {
    rep(j, 0, d-1) {
      cin >> x[i][j];
    }
  }

  int cont, ans = 0;
  rep(i, 0, n-1) {
    for (int k = i+1; k < n; k++) {
      cont = 0;
      rep(j, 0, d-1) {
        cont += pow(abs(x[i][j%d] - x[k][(j)%d]), 2);
      }
      if (sqrt(cont)-int(sqrt(cont)) == 0) {
        ans++;
      }
    }
  }

  cout << ans;
}

Measured memory_bytes: 256
import java.io.*;

class Main {
    static int swap = 0;
    
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        String str = br.readLine();
        String[] strarr = str.split(" ", n);
        
        int[] array = new int[n];
        for(int i=0; i<n; i++) {
            array[i] = Integer.parseInt(strarr[i]);
        }
        
        selectionSort(array, n);
        
    }
    
    static void selectionSort(int[] A, int N) {
        for(int i=0; i<N; i++) {
            int minj = i;
            int iv = A[i];
            for(int j=i+1; j<N; j++) {
                if(A[j] < A[minj]) {
                    minj = j;
                }
            }
            if(i != minj) {
                A[i] = A[minj];
                A[minj] = iv;
                swap++;
            }
        }
        
        for(int i=0; i<N-1; i++) {
            System.out.printf("%d ", A[i]);
        }
        System.out.println(A[N-1]);
        System.out.println(swap);
    }
    
}


Measured memory_bytes: 24724
#include <iostream>

int abs(int i) {
  if (i < 0) {
    return -i;
  }
  return i;
}

int main() {
  int n, l;
  std::cin >> n >> l;

  int sum = n * l + n * (n - 1) / 2;

  int diff = std::abs(sum);
  int result = 0;

  for (size_t i = 0; i < n; ++i) {
    int d = abs(l + i);
    if (diff > d) {
      result = sum - (l + i);
      diff = d;
    }
  }
  std::cout << result << std::endl;
}


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

using namespace std;

#define INF 2000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;


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

	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());

	ll al = 0;
	ll bo = 0;

	int j = 0;
	for (int i = a.size()-1; i >= 0; i--) {
		if (j%2==0) {
			al += a[i];
		} else {
			bo += a[i];
		}
		j++;
	}
	cout << al-bo << "\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>

#define INF 999999999
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=(n);i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define MOD(x) (x%(mod))
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

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

bool debug=false;

pair<pi,int> data[55];
int miss[55][15];
int M,T,P,R;

void init(){
  rep(i,55){
    data[i].first.first=0;
    data[i].first.second=0;
    data[i].second=i+1;
    rep(j,15){
      miss[i][j]=0;
    }
  }
}

void solve(){
  int m,t,p,j;
  rep(i,R){
    cin>>m>>t>>p>>j;
    if(j==0&&miss[t-1][p]!=-1){
      data[t-1].first.first++;
      data[t-1].first.second-=(m+miss[t-1][p]*20);
      miss[t-1][p]=-1;
    }else if(miss[t-1][p]!=-1){
      miss[t-1][p]++;
    }
  }

  sort(data,data+T);reverse(data,data+T);
  
  if(debug){cout<<"tema ";rep(i,T)cout<<data[i].second<<" ";cout<<endl;}
  if(debug){cout<<"solv ";rep(i,T)cout<<data[i].first.first<<" ";cout<<endl;}
  if(debug){cout<<"time ";rep(i,T)cout<<data[i].first.second<<" ";cout<<endl;}
  
  cout<<data[0].second;
  REP(i,1,T){
    if(data[i].first.first==data[i-1].first.first&&data[i].first.second==data[i-1].first.second){
      cout<<'='<<data[i].second;
    }else{
      cout<<','<<data[i].second;
    }
  }
  cout<<endl;
}

int main(){

  while(cin>>M>>T>>P>>R){
    if(M==0&&T==0&&P==0&&R==0)break;
    init();
    solve();
  }
  
  return 0;
}

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

public class Main{

    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);

        // input
        int day = scan.nextInt();

        // answer
        System.out.print("Christmas");
        for(int i = 0; i < 25 - day; i++){
            System.out.print(" Eve");
        }
        System.out.println("");

    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define ll long long
using namespace std;
template<typename tn> void read(tn &a){
	tn x=0,f=1; char c=' ';
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	a=x*f;
}
const int mod = 1e9+7,N = 201000;
ll fp(ll a,ll k){
	ll ans=1;
	for(;k;k>>=1,a=a*a%mod)
		if(k&1) ans=a*ans%mod;
	return ans;
}
int n,a[N],h[N],lim[N];
ll C[N],T[N],S,ans1,ans2,ans;
struct BIT{
	int c[N];
	BIT(){memset(c,0,sizeof(c));}
	void modify(int x,int k){
		for(int i=x;i<=n;i+=i&-i) c[i]=(c[i]+k)%mod;
	}
	int query(int x){
		int ans=0;
		for(int i=x;i;i-=i&-i) ans=(ans+c[i])%mod;
		return ans;
	}
};
void solve(ll&ans,int tag){
	BIT b;
	for(int i=1;i<=n;i++){
		ll s=b.query(a[i]-tag)-b.query(lim[a[i]]-1);
		ans=(ans+s*T[a[i]]%mod*S)%mod;
		b.modify(a[i],fp(T[a[i]],mod-2));
	}
}
int main(){
	read(n);
	for(int i=1;i<=n;i++) read(a[i]),h[a[i]]++;
	for(int i=n;i;i--)
		C[i]=C[i+1]+h[i];
	for(int i=1;i<=n;i++)
		C[i]-=n-i;
	S=1;
	for(int i=1;i<=n;i++) S=1ll*S*C[i]%mod;
	if(S==0){
		cout<<0<<'\n';
		return 0;
	}
	int lst=1;
	T[0]=1;
	for(int i=1;i<=n;i++){
		if(C[i]==1) T[i]=T[i-1],lst=i;
		else T[i]=T[i-1]*(C[i]-1)%mod*fp(C[i],mod-2)%mod;
		lim[i]=lst;
	}
	ll s=0;
	BIT b;
	for(int i=1;i<=n;i++)
		s+=b.query(n)-b.query(a[i]),b.modify(a[i],1);
	s%=mod;
	solve(ans1,0);
	reverse(a+1,a+n+1);
	solve(ans2,1);
	ans=(ans1*fp(2,mod-2)%mod+s*S%mod-ans2*fp(2,mod-2)%mod+mod)%mod;
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 7296
/*
　　　　　　 ＿＿
　　　　　／＞　　 フ
　　　　　|   _　 _l  
　 　　　／` ミ＿x ノ   Zzz..
　　 　 /　 　 　 |   コード見ちゃだめ！！
　　　 /　 ヽ　　  ﾉ
　 　 │　　|　|  |   
　／￣|　　 |　|  |
　| (￣ヽ＿_ヽ_)_ _)
　＼二つ
*/

#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(),(a).end())
#define RSORT(a) reverse((a).begin(),(a).end())
typedef long long ll;
typedef vector<vector<int> > Matrix;
const int MOD = 1e9+7;
#define REP(i, n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef vector<vector<int> > Matrix;


int main() {
int n; cin>>n;
int res=0; 

vector<vector<pair<int,int> > > p(n);

 REP(i,n){
  int a; cin>>a;
  REP(j,a){
      int x,y; cin>>x>>y;
      p[i].push_back({x-1,y});
  }
 }
 

for(int s = 0; s<(1<<n); s++){
    bool TF=true;
    REP(i,n){
    if(s&(1<<i)){
        REP(j,p[i].size()){
            if(p[i][j].second==0&&(s&(1<<p[i][j].first))){
            TF=false;
        }
        if(p[i][j].second==1 && !(s&(1<<p[i][j].first))) TF=0;
      }
    }
    
  }
   if(TF){
     int sum=0;
     REP(i,n)if(s&(1<<i))sum++;
     if(sum>res)res=sum;
   }
}
cout<<res<<endl;
}


Measured memory_bytes: 256
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
//-----------------------------------------
#define dcml(n) fixed<<setprecision(n)
using namespace std;
int main(void){
    ll N,K;cin>>N>>K;
    ld ans=0;
    REPS(i,N){//さいころの面
        ll point=i;
        ld p=1.0/N;
        while(point<K){
            p/=2;
            point*=2;
        }
        ans+=p;
    }
    cout<<dcml(15)<<ans<<"\n";
}

Measured memory_bytes: 256
#include<iostream>
#include<numeric>
#include<algorithm>
using namespace std;
int main(){
int n,k,w[100000];
cin>>n>>k;
for(int i=0;i<n;i++)cin>>w[i];

int max=*max_element(w,w+n);
int ave=accumulate(w,w+n,0)/k;

int p_least=(max>ave?max:ave);
int p=p_least;
for(;;p++){
int usage=0;
int sum=0;
for(int j=0;j<n;j++){
sum+=w[j];
if(sum>p){
++usage;
sum=w[j];
}
}
++usage;
if(usage<=k)break;

}
cout<<p<<endl;
}



Measured memory_bytes: 3480
#include<bits/stdc++.h>
using namespace std;
 
ostream& operator<<(ostream &out, string str) {
	for(char c : str) out << c;
	return out;
}
 
template<class L, class R> ostream& operator<<(ostream &out, pair<L, R> p) {
	return out << "(" << p.first << ", " << p.second << ")";
}
 
template<class T> auto operator<<(ostream &out, T a) -> decltype(a.begin(), out) {
	out << "{";
	for(auto it = a.begin(); it != a.end(); it = next(it))
		out << (it != a.begin() ? ", " : "") << *it;
	return out << "}";
}
 
void dump() { cerr << "\n"; }
template<class T, class... Ts> void dump(T a, Ts... x) {
	cerr << a << ", ";
	dump(x...);
}

#ifdef DEBUG
#  define debug(...) cerr << "[" #__VA_ARGS__ "]: ", dump(__VA_ARGS__)
#else
#  define debug(...) false
#endif
 
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define ST first
#define ND second
 
template<class T> int size(T && a) { return a.size(); }
 
using LL = long long;
using PII = pair<int, int>;

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

	int n;
	cin >> n;
	vector<string> name(n);
	vector<int> dur(n);
	REP(i, n) cin >> name[i] >> dur[i];
	string t;
	cin >> t;
	int ans = 0;
	bool add = false;
	REP(i, n) {
		if(add) ans += dur[i];
		if(name[i] == t)
			add = true;
	}
	cout << ans << "\n";
}


Measured memory_bytes: 256
/*"Everything in the universe is balanced. Every disappointment
   you face in life will be balanced by something good for you!
                Keep going, never give up."            */

#include "bits/stdc++.h"
using namespace std;

#define ll long long
const ll N=1e6+9;
const ll mod=1e9+7;

ll a[N];

void solve()
{    
    ll n, m ,k;
    cin >> n ;
    vector<int> a(n), b(n), c(n) ;
    for(int i=0 ; i<n; i++) {
    	cin >> a[i] >> b[i] >> c[i] ;
    }
    vector<vector<int>> dp(n, vector<int>(3)) ;

    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];

    for(int i=1; i<n; i++) {
    	dp[i][0] = a[i] + max(dp[i-1][1], dp[i-1][2]) ;
    	dp[i][2] = c[i] + max(dp[i-1][1], dp[i-1][0]) ;
    	dp[i][1] = b[i] + max(dp[i-1][0], dp[i-1][2]) ;
    }
    cout << max({dp[n-1][0], dp[n-1][1], dp[n-1][2]}) ;

}

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll t=1;
    //pre();
    //cin>>t;
    while(t--)
    {
      solve();
    }  
}


// Xorawar

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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; }

void Main(){
    int x; cin >> x;
    int ans;
    if(x<600) ans = 8;
    else if(x<800) ans = 7;
    else if(x<1000) ans = 6;
    else if(x<1200) ans = 5;
    else if(x<1400) ans = 4;
    else if(x<1600) ans = 3;
    else if(x<1800) ans = 2;
    else if(x<2000) ans = 1;
    cout << ans << en;
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}

Measured memory_bytes: 3648
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <regex>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
using ll = long long;
using VL=vector<ll>;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
const long long INF =  999999999;

ll N,a[200020];
//
ll dp[200020];


int main(){
  cin>>N;
  ll count=1;
  REP(i,N){
    cin>>a[i];
    if(a[i]==count){
      count++;
    }
  }
  ll ans=N-count+1;
  if(ans==N)cout<<-1<<endl;
  else cout<<ans<<endl;
}


Measured memory_bytes: 1792
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy,copy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N=I()
    candidate = set(["3","5","7"])
    for i in range(9):
        for c in copy(candidate):
            candidate.add(c+"3")
            candidate.add(c+"5")
            candidate.add(c+"7")
    
    ans = 0
    for c in candidate:
        if int(c)<=N and 0 not in (c.count("3"),c.count("5"),c.count("7")):
            ans += 1
    print(ans)



if __name__ == '__main__':
    main()




Measured memory_bytes: 19816
a, b, x = map(int, input().split())

import math

if a**2 * b < 2 * x:
    tangent = (2 * (a**2 * b - x)) / a ** 3
    theta = math.degrees(math.atan(tangent))
    print(theta)
else:
    tangent = (a * b**2) / (2 * x)
    theta = math.degrees(math.atan(tangent))
    print(theta)

Measured memory_bytes: 62404
#include <bits/stdc++.h>
typedef long long int LL;
using namespace std;

const int N   = 3e5+7;
const int MOD = 1e9+7;
const int INF = (~(1<<31));

/*****************************************************************/

int n;
int a[N];
int vis[N];

LL qmod(LL a,LL b){
    LL res = 1ll;
    for(;b;b>>=1,a=a*a%MOD)
        if(b&1) res=res*a%MOD;
    return res;
}

LL fac[N],inv[N];
void init(){
    fac[0]=1;
    for(LL i=1;i<N;i++)fac[i]=fac[i-1]*i%MOD;
    inv[N-1]=qmod(fac[N-1],MOD-2);
    for(LL i=N-2;i>=0;i--)inv[i]=inv[i+1]*(i+1)%MOD;
}

LL C(int n,int m){
    if(n<m) return 0;
    return fac[n]*inv[m]%MOD*inv[n-m]%MOD;
}

int main(){
    init();
    while(~scanf("%d",&n)){
        memset(vis,0,sizeof(vis));
        int t ;
        for(int i=1,x;i<=n+1;i++){
            scanf("%d",&x);
            if(vis[x])    t=i-vis[x];
            vis[x]=i;
        }

        for(int i=1;i<=n+1;i++)
            printf("%lld\n",(C(n+1,i)-C(n+1-t-1,i-1)+MOD)%MOD );
    }
    return 0;
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>/
// #include <ext/pb_ds/tree_policy.hpp>

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define mod 1000000007
#define maxn 100005
#define IN freopen("nocross.in","r",stdin)
#define OUT freopen("nocross.out","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define INF 2000000000
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off 2

// using namespace __gnu_pbds;
using namespace std ;

// typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

char s[105][105] ;
int A , B ;

int main()
{
    int i , j , k , l , m , n ;

    scanf("%d %d",&A,&B) ;

    for(i=0 ; i<100 ; i++)
    {
        s[0][i] = 'B' ; s[49][i] = 'B' ;
        s[50][i] = 'W' ; s[99][i] = 'W' ;
    }

    for(i=0 ; i<50 ; i++)
    {
        s[i][0] = 'B' ; s[i][99] = 'B' ;
        s[50+i][0]='W' ; s[50+i][99] = 'W' ;
    }

    A-- ; B-- ;

    for(i=1 ; i<49 ; i++)
    {
        if(i%2==0)
        {
            for(j=1 ; j<99 ; j++) s[i][j] = 'B' ;
            continue ;
        }
        for(j=1 ; j<99 ; j++)
        {
            if( A==0 ) s[i][j] = 'B' ;
            else
            {
                if( s[i-1][j]=='B' && s[i][j-1]=='B' )
                {
                    s[i][j] = 'W' ;
                    A-- ;
                }
                else s[i][j] = 'B' ;
            }
        }
    }

    for(i=51 ; i<99 ; i++)
    {
        if(i%2==0){
            for(j=1 ; j<99 ; j++) s[i][j] = 'W' ;
            continue ;
        }
        for(j=1 ; j<99 ; j++)
        {
            if( B==0 ) s[i][j] = 'W' ;
            else
            {
                if( s[i-1][j]=='W' && s[i][j-1]=='W' )
                {
                    s[i][j] = 'B' ;
                    B-- ;
                }
                else s[i][j] = 'W' ;
            }
        }
    }

    printf("100 100\n") ;

    for(i=0 ; i<100 ; i++)
    {
        for(j=0 ; j<100 ; j++)
        {
            if( s[i][j]=='B' ) s[i][j] = '#' ;
            else s[i][j] = '.' ;
        }
    }

    for(i=0 ; i<100 ; i++)
    {
        s[i][100] = '\0' ;
        printf("%s\n",s[i]) ;
    }

    return 0 ;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int n,i,j,num;
	int cards[4][13]={};
	char mark,kindmark[] = {'S', 'H', 'C', 'D'};

	scanf("%d",&n);
	for(i=0;i<n+1;i++){
		scanf("%c %d%*c",&mark,&num);

		switch(mark){
			case 'S':
				cards[0][num-1]=1;
				break;
			case 'H':
				cards[1][num-1]=1;
				break;
			case 'C':
				cards[2][num-1]=1;
				break;
			case 'D':
				cards[3][num-1]=1;
				break;
		}
	}
	for(i=0;i<=3;i++){
		for(j=0;j<13;j++){
			if(cards[i][j]==0){
				printf("%c %d\n",kindmark[i],j+1);
			}
		}
	}
	return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
//BEGIN CUT HERE
template<typename T>
struct AbsoluteSum{
  multiset<T> lp,rp;
  T sum;
  AbsoluteSum():sum(0){}
  T add(T x){
    if(lp.empty()){
      lp.emplace(x);
      rp.emplace(x);
      return T(0);
    }
    auto p=interval();
    lp.emplace(x);
    rp.emplace(x);
    if(p.first<=x&&x<=p.second) return T(0);
    while(*lp.rbegin()>*rp.begin()){
      T a=*lp.rbegin();
      T b=*rp.begin();
      lp.erase(lp.find(a));
      rp.erase(rp.find(b));
      rp.emplace(a);
      lp.emplace(b);
    }
    T res=min(abs(p.first-x),abs(p.second-x));
    sum+=res;
    return res;
  }
  pair<T, T> interval(){
    assert(!lp.empty());
    return make_pair(*lp.rbegin(),*rp.begin());
  }
  T value(){return sum;}
};
//END CUT HERE
//INSERT ABOVE HERE
signed ABC127_F(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  int q;
  cin>>q;
  using ll = long long;
  AbsoluteSum<ll> as;
  ll sum=0;
  for(int i=0;i<q;i++){
    int t;
    cin>>t;
    if(t==1){
      ll a,b;
      cin>>a>>b;
      as.add(a);
      sum+=b;
    }
    if(t==2){
      cout<<as.interval().first<<" "<<sum+as.value()<<"\n";
    }
  }
  cout<<flush;
  return 0;
}

signed main(){
  ABC127_F();
  return 0;
}


Measured memory_bytes: 19072
def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

A,B=two_int()
if A>9 or B>9:
    print(-1)
else:
    print(A*B)

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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

int main() {

    ll N;
    cin >> N;
    ll ans = 1;
    vector<ll> A(N);
    REP(i, N) {
        cin >> A[i];
        if (A[i] == 0){
            cout << 0 << endl;
            return 0;
        }
    }
    REP(i, N){
        ll pre = ans;
        
        if (A[i] > (ll)1e18 / ans){
            cout << -1 << endl;
            return 0;
        }
        ans *= A[i];
    }
    //cout << (ll)1e18 << endl;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3580
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <deque>
#include <numeric>
#include <cmath>
#include <map>
#include <set>
#define ull unsigned long long
#define ll long long
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int k;
    cin >> k;
    int cnt=0;
    for(int i=0;i<k;i++){
        for(int j=0;j<k;j++){
            if(i%2==0 && j%2==1){
                cnt++;
            }
        }
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;
 
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
 
template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
 
template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) { 
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }
 
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) {is >> x;} return is;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'['; for(T i: a) {out<<i<<',';} out<<']'; return out;
}
 
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const int MOD = 1000000007;

signed main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);

  ll n, q;
  cin >> n >> q;
  vector<ll> a(n);
  vector<PII> x(q);
  REP(i, n) cin >> a[i];
  REP(i, q) cin >> x[i].first, x[i].second = i;

  sort(ALL(a));
  sort(ALL(x));

  vector<ll> b(n, 1);
  FOR(i, n/2, n) {
    // cout << "i=" << i << endl;
    // i番目をn-i回目より前に取る最小のx
    ll lb = 0, ub = a[i];
    while(ub - lb > 1) {
      ll mid = (lb+ub)/2;
      // cout << lb << " " << mid << " " << ub << endl;
      if(a[i] - mid < mid - a[i-n+i+1]) ub = mid;
      else lb = mid;
    }
    b[i] = ub;
  }
  vector<ll> c(n);
  FOR(i, n/2-1, n-1) c[i] = b[i+1]-1;

  // cout << b << endl;
  // cout << c << endl;

  vector<ll> d(a);
  FOR(i, 1, n) d[i] += d[i-1];
  vector<ll> e(a);
  for(int i=2; i<n; i+=2) e[i] += e[i-2];
  for(int i=3; i<n; i+=2) e[i] += e[i-2];

  // cout << d << endl << e << endl;

  vector<ll> ans(q);
  ll idx = n/2-1;
  REP(i, q) {
    while(!IN(b[idx], c[idx]+1, x[i].first) && idx+1 < n-1) idx++;
    // cout << "x=" << x[i] << " idx=" << idx << endl;
    // [idx+1, n-1]
    ans[x[i].second] += d[n-1] - d[idx];
    // idx - (n-1 - idx)
    if(idx != n/2-1) ans[x[i].second] += e[idx-(n-1-idx)];
  }

  REP(i, q) cout << ans[i] << endl;

  return 0;
}


Measured memory_bytes: 7936
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long a,b,c,d,m,n;
  cin>>a>>b>>c>>d;
  m=a*b;
  n=c*d;
  m=max(m,n);
  cout<<m<<endl;
return 0;
}


Measured memory_bytes: 3620
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

#define int long long int
constexpr int INF = std::numeric_limits<int>::max();
constexpr int NINF = std::numeric_limits<int>::min();
using namespace std;

int gcd(int a, int b) {
  if (a < b) {
    int tmp = a;
    a = b;
    b = tmp;
  }

  while (b != 0) {
    int r = a % b;
    a = b;
    b = r;
  }
  return a;
}

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


void solve() {
  int N, M;
  cin >> N >> M;

  vector<int> A(N);
  int l = 1;
  for (int &a: A) {
    cin >> a;
    a /= 2;
    l = lcm(l, a);
  }

  for (int a:A) {
    if ((l / a) % 2 == 0) {
      cout << 0 << endl;
      return;
    }
  }

  int ans = 0;
  for (int x = l; x <= M; x += l + l) {
    ans++;
  }
  cout << ans << endl;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}


Measured memory_bytes: 3672
#include <iostream>
using namespace std;
int main(int argc, const char * argv[]) {
    int a,b;
    while (1) {
        cin >> a >> b;
        if (a==0&&b==0) {
            break;
        }
        if (a>b) {
            cout << b << " "<< a <<endl;
        }else
        {
            cout << a << " " << b <<endl;
        }
        
    }
    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
static const int MAX=100000;
ll N,cunt_a,cunt_c;
ll A[MAX],B[MAX],C[MAX];
int main(){
    cin>>N;

    for(ll i=0ll;i<N;i++) cin>>A[i];
    for(ll i=0ll;i<N;i++) cin>>B[i];
    for(ll i=0ll;i<N;i++) cin>>C[i];

    sort(A,A+N);
    sort(C,C+N);

    ll ans=0ll;
    for(ll i=0ll;i<N;i++){
        cunt_a=lower_bound(A,A+N,B[i])-A;
        cunt_c=C+N-upper_bound(C,C+N,B[i]);

        ans+=cunt_a*cunt_c;
    }

    cout<<ans<<"\n";

    return 0;
}


Measured memory_bytes: 2560
#include<stdio.h>
#include<math.h>

int main(){
    int N, M;
    int k[10], s[10][10], p[10];
    int onoff[10] = {};
    int ans = 0, onnum, oncheck;
    int i, j, l;
    scanf("%d %d", &N, &M);
    for(i = 0; i < M; i++){
        scanf("%d", &k[i]);
        for(j = 0; j < k[i]; j++){
            scanf("%d", &s[i][j]);
        }
    }
    for(i = 0; i < M; i++){
        scanf("%d", &p[i]);
    }
    for(i = 0; i < (int)pow(2, N); i++){
        oncheck = 1;
        for(j = 0; j < M; j++){
            onnum = 0;
            for(l = 0; l < k[j]; l++){
                onnum += onoff[s[j][l] - 1];
            }
            if(onnum % 2 != p[j]){
                oncheck = 0;
                break;
            }
        }
        if(oncheck == 1){
            ans++;
        }
        onoff[0]++;
        j = 0;
        while(onoff[j] == 2){
            onoff[j] = 0;
            onoff[++j]++;
        }
    }
    printf("%d\n", ans);
    return 0;
}

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

struct point {
   double x;
   double y;
   double z;
};

int main(){
   int n;
   while(cin>>n, n){
      point s[n];
      for(int i=0; i<n; i++) cin>>s[i].x>>s[i].y>>s[i].z;

      int m; cin>>m;
      vector<bool> see(n, false);
      for(int i=0; i<m; i++){
         point t;
         double rad;
         cin>>t.x>>t.y>>t.z>>rad;
         int ans = 0;
         for(int j=0; j<n; j++){
            if(see[j])continue;
            double angle = acos((s[j].x*t.x+s[j].y*t.y+s[j].z*t.z)
                              /sqrt(s[j].x*s[j].x+s[j].y*s[j].y+s[j].z*s[j].z)
                              /sqrt(t.x*t.x+t.y*t.y+t.z*t.z));
            if(angle < rad+1e-8) see[j]=true;
         }
      }
      int ans = 0;
      for(bool s : see) if(s)ans++;
      cout << ans << endl;
   }
}



Measured memory_bytes: 3384
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<map>
#include<cmath>
using namespace std;
typedef long long ll;
ll n,k;
vector<ll> av,fv,rv;
int main(){
  cin>>n>>k;
  for(ll i=0;i<n;i++){
    ll a;
    cin>>a;
    av.push_back(a);
  }
  for(ll i=0;i<n;i++){
    ll f;
    cin>>f;
    fv.push_back(f);
  }
  sort(av.begin(),av.end());
  sort(fv.begin(),fv.end(),greater<ll>());
  rv.push_back(av[0]);
  for(ll i=1;i<n;i++){
    rv.push_back(rv[i-1]+av[i]);
  }

  ll lb=-1,rb=17441744174417;
  while(rb-lb>1){
    ll mid=(lb+rb)/2;
    ll z=k;
    for(int i=0;i<n;i++){
      ll ma=mid/fv[i];
      z-=max(av[i]-ma,(ll)0);
    }
    if(z<0) lb=mid;
    else rb=mid;
  }
  //judge(12);
  cout<<rb<<endl;
}


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

using namespace std;

int main(){
  int n;
  scanf("%d",&n);
  bool flag=false;
  for(int i=1;i<10;i++){
    if(n%i){
      continue;
    }
    if(n/i<10){
      flag=true;
    }
  }
  if(!flag){
    printf("No\n");
  }
  else{
    printf("Yes\n");
  }
  return 0;
}
  

Measured memory_bytes: 256