akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>

using namespace std;
typedef long long ll;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
#define REP(i, n) for(int i = 0;i < n;i++)
const long long INF = 1LL << 60;

int MOD = 1000000007;

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

    int n; cin>>n;
    std::vector<ll> a(3*n);
    REP(i, 3*n) cin >> a[i];

    priority_queue<ll, std::vector<ll>, greater<ll>>pql;
    priority_queue<ll, std::vector<ll>>pqr;

    vector<ll> left, right;
    ll left_sum = 0LL, right_sum = 0LL;

    REP(i,n){
        pql.push(a[i]);
        pqr.push(a[3*n-i-1]);
        left_sum += a[i];
        right_sum += a[3*n-i-1];
    }

    left.push_back(left_sum);

    for(int i=n; i<2*n; ++i){
        ll target = a[i];
        pql.push(target);
        left_sum+=target;
        left_sum-=pql.top();
        pql.pop();
        left.push_back(left_sum);
    }

    right.push_back(right_sum);

    for(int i=2*n-1; i>=n; --i){
        ll target = a[i];
        pqr.push(target);
        right_sum+=target;
        right_sum-=pqr.top();
        pqr.pop();
        right.push_back(right_sum);
    }

    reverse(right.begin(), right.end());
    ll ans = left[0] - right[0];
    REP(i,n) ans = max(ans, left[i+1]-right[i+1]);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 6508
#include <bits/stdc++.h>
using namespace std;
int b[101];
int a[101];
int main(){
    int n;
    scanf("%d", &n);
    for(int i=1;i<=n;i++) a[i] = 1e9;
    for(int i=1;i<=n-1;i++){
        scanf("%d", &b[i]);
    }   
    for(int i=1;i<=n;i++){
        if(i != n) a[i] = min(a[i], b[i]);
        if(i != 1) a[i] = min(a[i], b[i-1]);
    }
    int ans = 0;
    for(int i=1;i<=n;i++) ans += a[i];
    printf("%d\n", ans);
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

"""
参考：https://img.atcoder.jp/abc117/editorial.pdf
・各ビット0の多い所は1にするっていう方針は合ってた。
・ちょっと条件間違って書いてたのと、
　K以下に限定する時上の桁から見てくってのが足りなかった。
"""

import sys, re
from collections import deque, defaultdict, Counter
from math import sqrt, hypot, factorial, pi, sin, cos, radians
if sys.version_info.minor >= 5: from math import gcd
else: from fractions import gcd 
from heapq import heappop, heappush, heapify, heappushpop
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from functools import reduce, partial
from fractions import Fraction
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def ceil(a, b=1): return int(-(-a // b))
def round(x): return int((x*2+1) // 2)
def fermat(x, y, MOD): return x * pow(y, MOD-2, MOD) % MOD
def lcm(x, y): return (x * y) // gcd(x, y)
def lcm_list(nums): return reduce(lcm, nums, 1)
def gcd_list(nums): return reduce(gcd, nums, nums[0])
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, K = MAP()
aN = LIST()
Kb = format(K, 'b')
mxlen = len(Kb)

c = Counter()
for i in range(N):
    b = format(aN[i], '0' + str(mxlen) + 'b')
    b = b[::-1]
    # Kと同じ桁までの範囲で、各ビット0の所を集計する
    for j in range(len(b)):
        if b[j] == '0':
            c[j] += 1

num = ''
for i in range(mxlen):
    # ビット0が全体の過半数の所は、立てた方が得をする
    if c[i] > N / 2:
        num = '1' + num
    else:
        num = '0' + num

X = 0
for i in range(len(num)):
    if num[i] == '1':
        # 上の桁から順に、K以下の範囲内で足せるだけ足す
        if X + 2 ** (len(num)-i-1) <= K:
            X += 2 ** (len(num)-i-1)

ans = 0
for i in range(N):
    ans += X ^ aN[i]
print(ans)


Measured memory_bytes: 90504
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

vector<vector<ll>> memo;

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

class Combination {
public:
    Combination(ll max_num, ll mod) {
        fact_.resize(max_num + 1, 1);
        inv_fact_.resize(max_num + 1, 1);
        mod_ = mod;
        for (ll i = 2; i <= max_num; i++) {
            fact_[i] = i * fact_[i - 1] % mod_;
            inv_fact_[i] = MODpow(fact_[i], mod_ - 2);
            assert(fact_[i] * inv_fact_[i] % mod_ == 1);
        }
    }
    ll operator()(ll n, ll m) const {
        if (m < 0 || m > n) return 0;
        return fact_[n] * inv_fact_[n - m] % mod_ * inv_fact_[m] % mod_;
    }
private:
    ll MODpow(ll n, ll m) const {
        ll result = 1;
        while (m) {
            if (m % 2 == 1) {
                result *= n;
                result %= mod_;
            }

            m /= 2;
            n *= n;
            n %= mod_;
        }

        return result;
    }

    vector<ll> fact_, inv_fact_;
    ll mod_;
};

int main() {
    ll N, K;
    cin >> N >> K;
    Combination comb(N, MOD);
    memo.resize(N + 1, vector<ll>(N + 1, -1));
    for (ll i = 1; i <= K; i++) {
        ll b = comb(K - 1, i - 1);        
        ll r = comb(N - K + 1, i);
        
        cout << b * r % MOD << endl;
    }
}

Measured memory_bytes: 31616
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
  
int main() {
  int h,w;
  cin>>h>>w;
  char mi[55][55];
  rep(i,h+2){
    rep(j,w+2){
      mi[i][j]=0;
    }
  }
  rep(i,h){
    rep(j,w){
      i++;j++;
      cin>>mi[i][j];
      i--;j--;
    }
  } 
  rep(i,h){
    rep(j,w){
      i++;j++;
      if(mi[i][j]=='#'){
        i--;j--;
        continue;
      }else{
        int mine=0;
        if(mi[i-1][j-1]=='#')mine++;
        if(mi[i][j-1]=='#')mine++;
        if(mi[i+1][j-1]=='#')mine++;
        if(mi[i-1][j]=='#')mine++;
        if(mi[i+1][j]=='#')mine++;
        if(mi[i-1][j+1]=='#')mine++;
        if(mi[i][j+1]=='#')mine++;
        if(mi[i+1][j+1]=='#')mine++;
        mi[i][j]='0'+mine;
        i--;j--;
      }
    }
  }
  rep(i,h){
    rep(j,w){
      i++;j++;
      cout<<mi[i][j];
      i--;j--;
    }
    cout<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin >> n;
    vector<int> cnta(n + 1, 0), cntb(n + 1, 0);
    vector<int> a(n), b(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        cnta[a[i]]++;
    }
    for (int i = 0; i < n; i++) {
        cin >> b[i];
        cntb[b[i]]++;
    }
    for (int i = 1; i <= n; i++) {
        if (cnta[i] + cntb[i] > n) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    vector<int> revb = b;
    int t = 0;
    for (int i = 0; i < n; i++) {
        if (i > 0 && a[i] != a[i - 1]) {
            t = i;
        }
        if (a[i] == revb[i]) {
            while (revb[t] == a[i] || a[t] == revb[i]) {
                t++;
                if (t == n) t = 0;
            }
            swap(revb[t], revb[i]);
        }
    }
    cout << revb[0];
    for (int i = 1; i < n; i++) {
        cout << " " << revb[i];
    }
    cout << endl;
}

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

//int _; 

int a;
long long b,n;
 
int main()
{
	//for(scanf("%d",&_);_;_--)
	cin >> a >> b >> n;
	cout << a*min(n,b-1)/b << endl;
	return 0;
}


Measured memory_bytes: 3604
<?php

// START
list($n, $m) = Util::input(1);
$cityMap = [];
$inputList = [];
for ($i = 0; $i < $m; ++$i) {
    list($p, $y) = Util::input(1);
    $inputList[] = $p . '_' . $y;
    if (empty($cityMap[$p])) {
        $cityMap[$p] = [];
    }
    $cityMap[$p][$y]= 1;
}
foreach ($cityMap as $key => $m) {
    ksort($cityMap[$key]);
    $c = 1;
    foreach ($cityMap[$key] as $k => $v) {
        $cityMap[$key][$k] = $c;
        $c += 1;
    }
}

foreach ($inputList as $input) {
    list($p, $y) = explode('_', $input);
    echo sprintf("%06d%06d", $p, $cityMap[$p][$y]) . PHP_EOL;
}
class Util
{
    public static function input($isSplitSpace = false)
    {
        $input = trim(fgets(STDIN));
        if (!$isSplitSpace) {
            return $input;
        }

        return explode(' ', $input);
    }

    public static function arrToStr($arr)
    {
        return implode(",", $arr);
    }
}



Measured memory_bytes: 107956
#include<stdio.h>
int main(void){
int a, b, c;
scanf("%d %d %d\n", &a, &b, &c);
if (a > b){
if (a > c){
if (b > c){
printf("%d %d %d\n", c, b, a);
}
else{ printf("%d %d %d\n", b, c, a); }
}
else{printf("%d %d %d\n", b, a, c);}
}
else if (b > c){
if (a > c){printf("%d %d %d\n", a, c, b); }
else{printf("%d %d %d\n", c, a, b); }
}
else{printf("%d %d %d\n", a, b, c); }
return 0;		
}

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

typedef long long ll;
const ll mod=1e9+7;

ll n,k,zero;
ll a[200005];
vector<ll> pos,neg;

void find_pos(){
    sort(pos.begin(),pos.end(),[](const ll &a,const ll &b){
        return a>b;
    });
    sort(neg.begin(),neg.end(),[](const ll &a,const ll &b){
        return a<b;
    });
    ll res=k&1?pos.front():1;
    ll pi=k&1,ni=0;
    while(pi+1<pos.size()&&ni+1<neg.size()&&pi+ni+2<=k){
        if(pos[pi]*pos[pi+1]>neg[ni]*neg[ni+1]){
            res=res*pos[pi]%mod*pos[pi+1]%mod;
            pi+=2;
        }else{
            res=res*neg[ni]%mod*neg[ni+1]%mod;
            ni+=2;
        }
    }
    while(pi+1<pos.size()&&pi+ni+2<=k){
        res=res*pos[pi]%mod*pos[pi+1]%mod;
        pi+=2;
    }
    while(ni+1<neg.size()&&pi+ni+2<=k){
        res=res*neg[ni]%mod*neg[ni+1]%mod;
        ni+=2;
    }
    cout<<(res+mod)%mod<<endl;
}

void find_neg(){
    sort(a,a+n,[](const ll &a,const ll &b){
        return abs(a)<abs(b);
    });
    ll res=1;
    for(ll i=0;i<k;i++){
        res=res*a[i]%mod;
    }
    cout<<(res+mod)%mod<<endl;
}

int main(){

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

    cin>>n>>k;
    for(ll i=0;i<n;i++){
        cin>>a[i];
        if(a[i]>0)pos.emplace_back(a[i]);
        if(a[i]==0)zero++;
        if(a[i]<0)neg.emplace_back(a[i]);
    }
    if(neg.size()-(neg.size()&1)+pos.size()>=k&&(k&1)<=pos.size()){
        find_pos();
    }else if(zero){
        cout<<"0\n";
    }else find_neg();

    return 0;
}

Measured memory_bytes: 6712
#include <bits/stdc++.h>
#pragma runtime_checks("s", restore)

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REP1(i, n) for (int i = 1; i <= (n); ++i)
#define RREP(i, n) for (int i = (n)-1; i >= 0; --i)
#define ALL(a) begin(a), end(a)
#define CEIL(a, b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))
#define X first
#define Y second

using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;

constexpr int MOD = 1e9 + 7;
constexpr int INF = 1e9 + 1;
constexpr ll LLINF = 4 * 1e18 + 1;
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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

int calc(int n){
	if(n == 0) return 0;
	return n % 10 + calc(n / 10);
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	cin >> n;
	int ans = calc(n);
	while(n % 10 == 0 && n != 0) n /= 10;
	if(n == 1) ans = 10;
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 256
l = [x for x in input()]

r = len(l)

l1 = []
l2 = []

cnt1 = 0
cnt2 = 0

for i in range(r):
	if i % 2 == 0:
		l1.append('0')
		l2.append('1')
	else:
		l1.append('1')
		l2.append('0')

for i in range(r):
	if l[i] != l1[i]:
		cnt1 += 1
	if l[i] != l2[i]:
		cnt2 += 1

print(min(cnt1,cnt2))

Measured memory_bytes: 5528
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define MOD 1000000007
#define INF 1e9
#define All(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;

int main() {
  string a,b;
  cin>>a>>b;
  int as=a.size(),bs=b.size();
  if(as>bs){
    cout<<"GREATER\n";
    return 0;
  }
  if(bs>as){
    cout<<"LESS\n";
    return 0;
  }
  if(a==b){
    cout<<"EQUAL\n";
    return 0;
  }

  for(int i=0;i<as;i++){
    if(a[i]>b[i]){
      cout<<"GREATER\n";
      return 0;
    }
    if(a[i]<b[i]){
      cout<<"LESS\n";
      return 0;
    }
  }

  return 0;
}


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

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define sc second
#define int long long
using namespace std;

void solve()
{

}

int32_t main()
{
    int k;
    cin >> k;
    int pw = 10;
    if (k % 7 == 0)
        k /= 7;
    k *= 9;
    if (k == 9)
    {
        cout << 1;
        return 0;
    }
    int ans = 1;
    while (pw != 1)
    {
        if (ans >= 1e6)
        {
            cout << "-1\n";
            return 0;
        }
        pw *= 10;
        pw %= k;
        ans++;
    }
    cout << ans;
}


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

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

int main(void)
{
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    ll ans=0;
    if(a>=k) ans=k;
    else if(a+b>=k) ans=a;
    else ans=a-(k-a-b);
    cout<<ans<<endl;
    return 0;
} 

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

typedef vector<ll> vl;
ll dummy(vl x, vl v, ll n, ll c){
    vector<ll> acc(n+1, 0), left_max(n+1, 0), left_pos(n+1, 0);
    rep(i, 0, n) acc[i+1] = acc[i] + v[i];
//    rep(i, 0, n+1) cerr << acc[i] << endl;
    rep(i, 0, n){
        if(left_max[i] - left_pos[i] > acc[n] - acc[n-1-i] - (c - x[n-1-i])){
            left_max[i+1] = left_max[i];
            left_pos[i+1] = left_pos[i];
        }else{
            left_max[i+1] = acc[n] - acc[n-1-i];
            left_pos[i+1] = c - x[n-i-1];
        }
    }
//    rep(i, 0, n+1) cerr << left_max[i] << " " << left_pos[i] << endl;
    ll ans = 0;
    rep(i, 0, n+1){
        ll dist = (i == 0 ? 0 : x[i-1]);
        ll m1 = left_max[n-i] - 2 * left_pos[n-i] + acc[i] - dist;
        ll m2 = left_max[n-i] - left_pos[n-i] + acc[i] - 2 * dist;
//        cerr << i << ": " << m1 << " " << m2 << endl;
        ans = max({ans, m1, m2}); 
    }
    return ans;
}

int main(){
    ll n, c;
    cin >> n >> c;
    vector<ll> x(n), v(n);
    rep(i, 0, n) cin >> x[i] >> v[i];
    ll ans = dummy(x, v, n, c);
    rep(i, 0, n) x[i] = c - x[i];
    reverse(x.begin(), x.end());
    reverse(v.begin(), v.end());
    ans = max(ans, dummy(x, v, n, c));
    cout << ans << endl;
    return 0;
}

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

int main() {
  ll x;
  cin >> x;
  int ans;
  if(100*(x/100) <= x && x <= 105*(x/100)) ans = 1;
  else ans = 0;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
typedef pair<double,double> pdd;
#define MEM(a, b) memset(a, (b), sizeof(a))
#define SZ(i) ll(i.size())
#define FOR(i, j, k, in) for (ll i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (ll i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define REP1(i,j) FOR(i, 1, j+1, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define ALL(_a) _a.begin(),_a.end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define X first
#define Y second
#ifdef tmd
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
#endif

template<class T> inline bool cmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool cmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MOD=1000000007;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll MAXN=1e5+5;
const ll MAXLG=__lg(MAXN)+2;

vector<pair<pii,ll>> edge;
int l,n;
/********** Main()  function **********/
int main()
{
  IOS();
  cin>>l;
  n = __lg(l)+1;
  for(ll i=1;i<n;i++){
    edge.eb(mp(i,i+1),0);
    edge.eb(mp(i,i+1),1<<(n-i-1));
  }

  int base = 1<<(n-1);
  l -= 1<<(n-1);
  while(l > 0){
    int tmp = __lg(l);
    edge.eb(mp(1,n-tmp),base);
    base += 1<<tmp;
    l -= 1<<tmp;
  }
  cout<<n<<" "<<SZ(edge)<<endl;
  for(auto E:edge){
    cout<<E.X.X<<" "<<E.X.Y<<" "<<E.Y<<endl;
  }
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll INF = 1e18;
/* テンプレートここまで */

int main() {
  ll w,a,b; cin >> w >> a >> b;
  if(b>a+w){
    cout << b-(a+w) << endl;
  }else if(a>b+w){
    cout << a-(b+w) << endl;
  }else{
    cout << 0 << endl;
  }
}

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

int main()
{ 
  int h, w;
  vector<vector<char>> a(100, vector<char>(100));
  vector<bool> a_row(100, true), a_col(100, true);

  cin >> h >> w;
  for (int i = 0; i < h; i++)
  {
    for (int j = 0; j < w; j++)
    {
      cin >> a[i][j];
      if (a[i][j] == '#')
      {
        a_row[i] = false;
        a_col[j] = false;
      }
    }
  }
  for (int i = 0; i < h; i++)
  {
    if (a_row[i])
      continue;
    for (int j = 0; j < w; j++)
    {
      if (a_col[j])
        continue;
      cout << a[i][j];
    }
    cout << endl;
  }
}

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



int main(int argc, char const *argv[])
{
    int s;
    cin >> s;
    int h, m;
    h = s/3600;
    m = (s%3600)/60;
    s = (s%3600)%60;
    cout << h << ":" <<  m << ":" << s << endl;
    return 0;
}



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

using namespace std;

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

	int a, b, ans = 0, cnt = 1;
	cin >> a >> b;
	while(cnt < b) {
		cnt += a - 1;
		ans++;
	}
	cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep2(i, m, n) for (int i = m; i < n; ++i)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
// vvi data(n, vi(m));
using vll = vector<long long>;
using vvll = vector<vll>;


int main() {
  int n, m;
  cin >> n >> m;
  cout << (n - 1) * (m - 1) << endl;
}


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

int main()
{
	long long A, B, K;
	cin >> A >> B >> K;

	long long a = 0;
	long long b = B;
	if( A >= K ) {
		a = A - K;
	}
	else {
		b = max( 0LL, B - (K - A) );
	}

	cout << a << " " << b << endl;
}


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

#define NL '\n'
#define sz(x) x.size()
#define INF LONG_MAX
#define IINF LLONG_MAX
#define PI (2.0*acos(0.0))

#define sfi(x) scanf("%d",&x)
#define sfi2(x,y) scanf("%d %d",&x,&y)
#define sfi3(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define sfl(x) scanf("%lld",&x)
#define sfl2(x,y) scanf("%lld %lld",&x,&y)
#define sfl3(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define sfd(x) scanf("%lf",&x);
#define sfd2(x,y) scanf("%lf %lf",&x,&y);

#define max3(a,b,c) max(a,max(b,c))
#define max4(a,b,c,d) max(max3(a,b,c),d)
#define min3(a,b,c) min(a,min(b,c))
#define min4(a,b,c,d) min(a,min3(b,c,d))

#define fi first
#define se second
#define PB push_back
#define MP make_pair
#define For(i, j, k) for(int i = j; i <= k; i++)
#define Rof(i, j, k) for(int i = j; i >= k; i--)
#define all(x) x.begin(),x.end()
#define asort(x) sort(all(x));
#define dsort(x) sort(all(x), greater<int>())
#define unq(x) x.erase(unique(x.begin(),x.end()),x.end())

#define mem(ara,val) memset(ara,val,sizeof(ara))
#define READ freopen("input.txt","r",stdin)
#define WRITE freopen("output.txt","w",stdout)
#define IOS ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0)

typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair <int,int> PII;
typedef pair <LL,LL> PLL;

LL gcd(LL a,LL b) { return b==0 ? a : gcd(b,a%b); }
LL lcm(LL a,LL b) { return (a/gcd(a,b))*b; }

int main()
{
    int a,b;
    sfi2(a,b);
    vector <int> vec(b);
    For(i,0,b-1) sfi(vec[i]);
    asort(vec);
    if(binary_search(all(vec),a)==true)
    {
        int x = a, y = a;
        while(true)
        {
            x--;
            if(binary_search(all(vec),x)==false)
            {
                printf("%d",x);
                return 0;
            }
            y++;
            if(binary_search(all(vec),y)==false)
            {
                printf("%d",y);
                return 0;
            }
        }
    }
    else
    {
        printf("%d",a);
    }
}


Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
int main ()
{
  int k;
  string s;
  cin>>k>>s;
  bool t=false;
  int p=s.size();
  if(k>=p)
  {
      cout<<s;
      return 0;
  }
  else
    for(int i=0;i<k;i++)
    cout<<s[i];
  cout<<"...";
  return 0;
}



Measured memory_bytes: 3636
#include <stdio.h>
int main() {
  int a[3];
  int c,d;
  scanf("%d %d %d", &a[0], &a[1], &a[2]);
  for (c=0;c<2;c++) {
    for (d=0;d<2-c;d++) {
      if (a[d]>a[d+1]) {
        int temp=a[d+1];
        a[d+1]=a[d];
        a[d]=temp;
      }
    }
  }
  printf("%d %d %d\n", a[0], a[1], a[2]);
  return 0;
}

Measured memory_bytes: 596
import java.io.File;
import java.io.IOException;
import java.util.Scanner;

/*
 * メモ
 * Scanner:nextは空白か改行までの単語
 * String[][] c = new String[h][w];
 * TemplateMain,"template_input.txt"
 * 0.5 == 1.0/2
 */

public class Main {
	
	public static void printlnYN(boolean b){
		if(b) System.out.println("Yes");
		else System.out.println("No");
	}

	public static void main(String[] args) throws IOException {
		
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);
		
		Scanner sc = new Scanner(System.in);
		
    	int N = sc.nextInt();
    	int Y = sc.nextInt();
    	
    	int x = -1, y = -1, z = -1;
    	
    	int n = Y / 10000;
    	for(int i = 0; i <= n; i++){
    		int m = (Y - 10000*i) / 5000;
    		for(int j = 0; j <= m; j++){
    			int mm = Y - 10000 * i - 5000 * j;
    			if(mm % 1000 == 0 && mm / 1000 == N - i - j){
    				x = i;
    				y = j;
    				z = N - i - j;
    				break;
    			}
    		}
    		if(x >= 0) break;
    	}
    	
    	System.out.println(x + " " + y + " " + z);
	}

}

Measured memory_bytes: 21844
#include<iostream>
#include<stack>
#include<stdio.h>
#include<stdlib.h>
using namespace std;

int main()
{
  stack<int> S;
  char c[10];
  int x,y;
  while((scanf("%s",&c))!=EOF){
    if(c[0]=='+'){
      x=S.top();S.pop();
      y=S.top();S.pop();
      S.push(x+y);
    }
    else if(c[0]=='-'){ 
      x=S.top();S.pop();
      y=S.top();S.pop();
      S.push(y-x);
    }
    else if(c[0]=='*'){
      x=S.top();S.pop();
      y=S.top();S.pop();
      S.push(x*y);
    }
    else{
      S.push(atoi(c));
    }
  }
  cout<<S.top()<<endl;
  return 0;
}



Measured memory_bytes: 3236
def actual(a, b, k):
    if a >= k:
        # return f'{a - k} {b}'
        return '{} {}'.format((a - k), b)

    if b > (k - a):
        # return f'0 {b - (k - a)}'
        return '0 {}'.format(b - (k - a))

    return '0 0'

a, b, k = map(int, input().split())
print(actual(a, b, k))
  


Measured memory_bytes: 2940
/*input

*/


//assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
#include<bits/stdc++.h>
using namespace std;
#define ll          long long
#define pb          push_back
#define pii         pair<ll int,ll int>
#define vpii        vector< pii >
#define vi          vector<ll int>
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			(ll)1e18
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++) 
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define repr(i,a,b) for(ll int i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


int solve()
{
	ll a,b;cin>>a>>b;
	ll g = __gcd(a,b);
	map<ll,ll> pf;
	for(ll i=2;i*i<=g;i++) while(g%i==0) pf[i]++,g/=i;
	if(g>1) pf[g]++;
	cout<<sz(pf)+1<<"\n";
	return 0;
}

int main()
{
	auto start = chrono::high_resolution_clock::now();

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	ll test_cases=1;
	//cin>>test_cases;
	while(test_cases--)
		solve();

	auto stop = chrono::high_resolution_clock::now();
	auto duration = chrono::duration_cast<chrono::milliseconds>(stop-start);
	// cout<<"\nduration: "<<(double)duration.count()<<" milliseconds";
}

Measured memory_bytes: 256
#include<cstdio>
#include<set>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<cstdlib>
#include<time.h>
#include<string>
#include<stack>
#include<cmath>
#include<iostream>
#include<cstring>
#include<complex>
#include<tr1/unordered_set>
#include<tr1/unordered_map>
#define INF  (int)1e9
#define EPS   1e-9
#define MOD 1000000007
#define Pi 3.14159
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
// input macro
#define IN(x,n)   for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}
//output macro
#define print(x)    for(auto it:x) cout<<it<<' '; cout<<endl;
#define printPI(x)  for(auto it:x) cout<<it.F<<' '<<it.S<<'\t';  cout<<endl;
// shortcut for data type
#define ll long long
#define PI pair<int,int>
#define PL pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<VI>
#define vvl vector<VL>
#define vvvi vector<VVI>
#define vvvl vector<VVL>
#define vpi vector<PI>
#define vpl vector<PL>
#define pb push_back
#define ppb pop_back
#define eb emplace_back
#define mp make_pair
#define F first
#define S second
#define uset unordered_set
#define umap unordered_map
#define dbg(x, y) cout << x << " = " << y << endl
using namespace std;


const int Ntest = 1e5 + 5;
const int N = (int)4e5 + 10;

ll gcd(ll a, ll b) {ll temp; while (b > 0) {temp = a % b; a = b; b = temp;} return a;}
ll lcm(ll a, ll b) {return a * b / gcd(a, b);}
ll fpow(ll  b, ll exp, ll mod) {if (exp == 0) return 1; ll t = fpow(b, exp / 2, mod); if (exp & 1) return t * t % mod * b % mod; return t * t % mod;}
ll divmod(ll i, ll j, ll mod) {i %= mod, j %= mod; return i * fpow(j, mod - 2, mod) % mod;}

clock_t time_p = clock();
void TimeTaken()
{
	time_p = clock() - time_p;
	cerr << "Completion time : " << (float)(time_p) / CLOCKS_PER_SEC << "\n";
}


void sol() {
	int n;
	cin >> n;
	vector <int> arr(n);
	vector <int> freq(N, 0);
	ll sum = 0LL;
	for (int i = 0; i < n; ++i) {
		cin >> arr[i];
		sum += (ll)arr[i];
		freq[arr[i]]++;
	}
	int q;
	cin >> q;
	while (q--) {
		ll bi, ci;
		cin >> bi >> ci;
		sum -= (freq[bi] * bi);
		freq[ci] += freq[bi];
		sum += (freq[bi] * ci);
		freq[bi] = 0;
		cout << sum << endl;
	}
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int t = 1;
	//cin >> t;
	while (t--)
		sol();

	return 0;
}

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

using namespace std;

struct Frame {
	int h;
	int w;
};

int main(void) {
	int a, b;

	vector<struct Frame> v;
	while (cin >> a >> b) {
		if (a == 0 && b == 0) {
			break;
		}

		struct Frame frm;
		frm.h = a;
		frm.w = b;

		v.push_back(frm);
	}

	for (int i = 0; i < v.size(); i++) {
		for (int j = 0; j < v[i].h; j++) {
			for (int k = 0; k < v[i].w; k++) {
				if (k == 0 || k == v[i].w - 1 || j == 0 || j == v[i].h - 1) {
					cout << "#";
				}
				else {
					cout << ".";
				}
			}
			cout << endl;
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 3140
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    ll n; cin >> n;
    vi a(n);
    rep(i, n){ cin >> a[i]; a[i]--; }

    ll cnt = 1;
    vi chk(n, 0); chk[0] = 1;
    ll next = a[0];
    
    while(next != 1 && chk[next] != 1){
        chk[next] = 1;
        cnt++;
        next = a[next];
    }

    cout << ((next != 1) ? -1 : cnt) << endl;
}

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

// 0-based index
// tree size: 2 * NN - 1
// leaves indices: [NN - 1, 2 * NN - 1)
template<class T>
struct SegTree {
    int NN;
    T default_value;
    vector<T> data;

    T aggr(T a, T b) {
        return max(a, b);
    }

    SegTree(int N, T val) {
        default_value = val;
        NN = 1; while (NN < N) NN <<= 1;
        data = vector<T>(2 * NN - 1, val);
    }

    SegTree(const vector<T> v, T val) {
        default_value = val;
        int N = v.size();
        NN = 1; while (NN < N) NN <<= 1;
        data = vector<T>(2 * NN - 1, val);
        copy(v.begin(), v.end(), data.begin() + (NN - 1));
        build(0, 0, NN);
    }

    void build(int u, int l, int r) {
        if (r - l == 1) return;
        int m = (l + r) / 2;
        build(u * 2 + 1, l, m);
        build(u * 2 + 2, m, r);
        data[u] = aggr(data[2 * u + 1], data[2 * u + 2]);
    }

    T query(int a, int b, int u, int l, int r) {
        if (l >= b || r <= a)
            return default_value;
        if (l >= a && r <= b)
            return data[u];
        int m = (l + r) / 2;
        T res1 = query(a, b, u * 2 + 1, l, m);
        T res2 = query(a, b, u * 2 + 2, m, r);
        return aggr(res1, res2);
    }

    void update(int idx, T x, int u, int l, int r) {
        if (idx < l || idx >= r)
            return;
        if (idx == l && r - l == 1) {
            data[u] = x;
            return;
        }
        int m = (l + r) / 2;
        update(idx, x, u * 2 + 1, l, m);
        update(idx, x, u * 2 + 2, m, r);
        data[u] = aggr(data[2 * u + 1], data[2 * u + 2]);
    }

    void increment(int idx, T x, int u, int l, int r) {
        update(idx, data[NN - 1 + idx] + x, u, l, r);
    }
};

template <class T>
ostream & operator << (ostream &out, const SegTree<T> &seg) {
    out << "SegTree(NN=" << seg.NN << ", ";
    for (int u = seg.NN - 1, sz = seg.NN; sz >= 1; u /= 2, sz /= 2) {
        out << "[ ";
        for (int i = 0; i < sz; i++) {
            out << seg.data[u + i] << " ";
        }
        out << "]";
    }
    out << ")";
    return out;
}

int solve() {
    int H, W, M;
    cin >> H >> W >> M;

    auto cntR = vector<int>(H, 0);
    auto cntC = vector<int>(W, 0);
    auto t = vector<vector<int>>(H, vector<int>());
    for (int i = 0; i < M; i++) {
        int r, c; 
        cin >> r >> c;
        r--; c--;
        cntR[r]++;
        cntC[c]++;
        t[r].push_back(c);
    }

    auto seg = SegTree<int>(cntC, 0);
    // cout << seg << endl;
    int ans = -1;
    for (int r = 0; r < H; r++) {
        for (auto c : t[r]) {
            seg.increment(c, -1, 0, 0, seg.NN);
        }
        // cout << seg << endl;
        int val = cntR[r] + seg.query(0, W, 0, 0, seg.NN);
        ans = max(ans, val);
        for (auto c : t[r]) {
            seg.increment(c, +1, 0, 0, seg.NN);
        }
    }
    return ans;
}

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

    cout << solve() << endl;

    return 0;
}

Measured memory_bytes: 27220
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <utility>
#include <numeric>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <limits>

#define for0(i, n)    for (int i = 0  ; i <  (n); ++i)
#define for1n(i, n)   for (int i = 1  ; i <= (n); ++i)
#define for1(i, n)    for (int i = 1  ; i <  (n); ++i)
#define forn(i, n)    for (int i = 0  ; i <= (n); ++i)
#define forx(i, n, x) for (int i = (x); i <  (n); ++i)

using namespace std;

typedef long long ll;
typedef priority_queue<ll> pq;
typedef priority_queue<ll,vector<ll> ,greater<ll>> pql;
typedef stack<ll> stk;
typedef queue<ll> qu;


int main(void){
    int M, D;
    cin >> M >> D;
    int result = 0;

    for1n(i, M){
        for1n(j, D){
            int d1 = j%10;
            int d10 = j/10;
            if (d1>=2 && d10>=2 && i == d1 * d10) {
                ++result;
            }
        }
    }

    cout << result;

    return 0;
}


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

using namespace std;

int main()
{
    int N, x;
    cin >> N;
    string s;
    vector<string> S(N);
    vector<int> t(N);
    for(int i=0;i<N;++i){
        cin >> S[i];
        cin >> t[i];
    }
    cin >> s;
    for(int i=0;i<N;++i){
        if(s == S[i]){
            x = i;
        }
    }
    int ans = 0;
    for(int i=x+1;i<N;++i){
        ans += t[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
from __future__ import print_function

import sys

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction
from fractions import gcd

import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return


def lcm(n, m):
    return int(n * m / gcd(n, m))


def coprimize(p, q):
    common = fractions.gcd(p, q)
    return (p // common, q // common)


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


def main():
    n,a,b = map(int,input().split())
    m = n//(a+b)
    p = n %(a+b)
    print(a*m + min(p, a))


if __name__ == '__main__':
    main()


# 

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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, K; cin >> N >> K;
    bool have[N] = {};
    rep(i, K){
        int d; cin >> d;
        rep(j, d){
            int a; cin >> a;
            have[a-1] = true;
        }
    }
    int ans = 0;
    rep(i, N){
        if(!have[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
 
int main() {
	int N,D;
	cin>>N>>D;
	map<int,int> S;
	fx(D){
		int d;
		cin>>d;
		S[d]++;
	}
	
	bool loop=true;
	int n=N;
	while(loop){
		int k=n;
		while(k>0){
			if(S[k%10]>0){
				break;
			}else{
				k/=10;
			}
		}
		if(k==0){
			loop=false;
		}else{
			n++;
		}
		
	}
	
	ce(n)
	
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.TreeMap;

public class Main {

    public static void main(String[] args) throws Exception {

        InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(is);

        List<String> mylist = new ArrayList<>();

        // 標準入力からの値を変数strinputに代入
        String strinput = reader.readLine();

        while (strinput != null) {

            mylist.add(strinput);
            strinput = reader.readLine();

        }

        String arr01[] = mylist.get(0).split(" ");

        int n = Integer.valueOf(arr01[0]);

        //        Map<String, Integer> map = new HashMap<String, Integer>();
        TreeMap<String, Integer> map = new TreeMap<String, Integer>();
        for (int i = 1; i < 1 + n; i++) {

            String temp = mylist.get(i);

            if (map.containsKey(temp)) {
                int val = map.get(temp);
                map.put(temp, val + 1);
            } else {
                map.put(temp, 1);
            }
        }
        //        System.out.println(map);

        int maxdata = map.values().stream()
                .mapToInt(x -> x)
                .max()
                .orElse(0);
        //        System.out.println(maxdata);

        map.forEach((key, value) -> {
            if (value == maxdata) {
                System.out.println(key);
            }

        });

    }
}


Measured memory_bytes: 67956
#include<iostream>
#include<cmath>
#define MAXN 10*10*10*10*10

using namespace std;

long long a[100500];

signed main()
{
	long long n;
	cin >> n;
	
	for (long long i=0; i<n; i++)
	{
		cin >> a[i];
	}
	
	long long res = a[0];
	if (res == 0)
	{
		cout << 0 << endl;
		return 0;
	}
	
	for (long long i = 0; i<n; i++)
	{
		if (a[i] == 0){
			cout << 0 << endl;
			return 0;
		}
	}
	
	for (long long i = 1; i<n; i++)
	{
		if ((long long)pow(10,18)/res < a[i]) {
			cout << -1 << endl;
			return 0;
		}
		
		res = a[i]*res;
	}
	
	cout << res << endl;
	
	return 0;
} 


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

using namespace std;
using ll = long long;

int main() {
    int AC = 0,WA = 0,TLE = 0,RE = 0;
    int N = 0;
    cin >> N;
    vector<string> BOX(N,"");
    for (size_t i = 0; i < N; i++)
    {
        cin >> BOX.at(i);
    }
    for (size_t i = 0; i < N; i++)
    {
        if(BOX.at(i) == "AC")
        {
            AC+=1;
        }
        else if (BOX.at(i) == "WA")
        {
            WA++;
        }
        else if (BOX.at(i) == "TLE")
        {
            TLE++;
        }
        else if (BOX.at(i) == "RE")
        {
            RE++;
        }
    }
    cout << "AC x " << AC << endl;
    cout << "WA x " << WA << endl;
    cout << "TLE x " << TLE << endl;
    cout << "RE x " << RE << endl;

    return 0;
}

Measured memory_bytes: 6408
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
			long N = sc.nextLong();
		sc.close();

		long answer = 0;;
		int sq = (int)Math.sqrt(N);
		//System.out.println(sq);
		for(int i = 1 ; i <= sq ; i++){
			long p = N/i;

			//System.out.println(p);
			if(N%p == 0 && p != sq && N%(p-1) != 0){
				answer += p-1;
			}
		}

		System.out.println(answer);
	}
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<ll, II> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 100010;
const int MAXM = 110;
const int MAXK = 510;

int n, m, lab[MAXN];
vector<II> edge;

int getRoot(int u) {
    while (lab[u] > 0) u = lab[u];
    return u;
}

void unionPair(int u, int v) {
    int x = lab[u] + lab[v];
    if (lab[u] < lab[v]) {
        lab[v] = u;
        lab[u] = x;
    }
    else {
        lab[u] = v;
        lab[v] = x;
    }
}

vector<ll> kq;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n >> m;
    FOR(i,1,m) {
        int u, v;
        cin >> u >> v;
        edge.emplace_back(II(u, v));
    }
    FOR(i,1,n) lab[i] = -1;
    ll res = (ll) n * (n - 1) / 2;
    FORE(i,m-1,0) {
        kq.emplace_back(res);
        int u = getRoot(edge[i].FI);
        int v = getRoot(edge[i].SE);
        if (u != v) {
            int g = lab[u] * lab[v];
            res -= g;
            unionPair(u, v);
        }
    }

    FORE(i,m-1,0) cout << kq[i] << "\n";
    return 0;
}

Measured memory_bytes: 3444
#include <iostream>
#include <stack>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <deque>
using namespace std;

int main()
{
	int n,m,k[1001],cardA[100],cardB[100],b;
	cin>>n>>m;
	deque<int>deq;

	for(int i=1; i<=2*n; i++)
		deq.push_back(i);

	for(int i=0; i<m; i++)
		cin>>k[i];

	for(int i=0; i<m; i++)
	{
		if(k[i] == 0)
		{
			for(int j=0; j<n; j++)
				cardA[j] = deq[j];

			for(int j=n; j<2*n; j++)
				cardB[j-n] = deq[j];
	
			deq.clear();

			for(int j=0; j<n; j++)
			{
				deq.push_back(cardA[j]);
				deq.push_back(cardB[j]);
			}

		}
		else
		{
			for(int l=0; l<k[i]; l++)
			{
				b = deq[0];
				deq.pop_front();
				deq.push_back(b);
			}
		}
	}

	for(int i=0; i<2*n; i++)
		cout<<deq[i]<<endl;

	return 0;

}

Measured memory_bytes: 1220
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, n)       for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, s, t)   for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#ifndef DBG
#define trace(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> make_v(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto make_v(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initValue, args...))>(sz, make_v<T>(initValue, args...));
}

template <class T>
inline istream& operator>> (istream &in, vector<T> &vec) {
    for (auto &e : vec) in >> e;
    return in;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &out, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) out << e << delim[&e == &vec.back()];
    return out;
}
// }}} End Header

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);

    string s; read(s);
    vector<int> a(4);
    rep(i, 4) a[i] = s[i] - '0';

    rep(b, 1 << 3) {
        int sum = a[0];
        rep(i, 3) {
            if ((b >> i) & 1) {
                sum += a[i+1];
            } else {
                sum -= a[i+1];
            }
        }
        if (sum == 7) {
            cout << a[0];
            rep(i, 3) {
                if ((b >> i) & 1) {
                    cout << '+';
                } else {
                    cout << '-';
                }
                cout << a[i+1];
            }
            cout << "=7\n";
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 256
from operator import itemgetter
N = int(input())
A = list(map(int, input().split()))
# a= []
# for i in range(N):
#     a.append((i+1, A[i]))
#     a.sort(key=itemgetter(1))
# print(' '.join([str(i[0]) for i in a]))
a = [0] * N
for i in range(N):
    a[ A[i] -1 ] = str(i + 1)
print(' '.join(a))


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

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine().ToArray();
            var last = "";
            var count = 0;
            for(var i=0;i<S.Length;i++)
            {
                string l = S[i].ToString();
                if (last == l)
                {
                    if (i == S.Length - 1) break;
                    i++;
                    l += S[i];
                }
                last = l;
                count++;
            }
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 17368
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int r = sc.nextInt();
		int D = sc.nextInt();
		int x2000 = sc.nextInt();
		
		for(int i = 1; i <= 10; i++){
			x2000 = r * x2000 - D;
			System.out.println(x2000);
		}
	}
}

Measured memory_bytes: 21204