akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define sort(s) sort(s.begin(),s.end())
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<int>>
constexpr auto mod = 1000000007;


//2のn乗を求めるよ！！！
int ni(int n) {
	if (n == 0)return 1;
	int x = ni(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;
}

//フィボナッチ数列のx番目を求めるよ！
int f(int x, vector<int> s) {
	if (x == 0)return 0;
	if (x == 1)return 1;
	if (s[x] != 0)return s[x];
	s[x] = f(x - 1, s) + f(x - 2, s);
	return s[x];
}

//aとｂの最大公約数を求めるよ！
llint gcd(llint a, llint b) {
	if (a < b)swap(a, b);
	if (b == 0)return a;
	return gcd(b, a % b);
}



// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

// mod. m での a の逆元 a^{-1} を計算するよ！
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


//aCbをmod.mで割った余りを求める
ll int c(ll int a, ll int b, ll int m) {
	ll int ans = 1;
	for (ll int i = 0; i < b; i++) {
		ans *= a - i;
		ans %= m;
	}
	for (ll int i = 1; i <= b; i++) {
		ans *= modinv(i, m);
		ans %= m;
	}
	return ans;
}

//m進数のn桁を全列挙やで
void dfs(int m, int n) {

	stack<string> st;
	st.push("");
	while (!st.empty()) {
		string now = st.top();
		st.pop();
		if (now.size() == n) {
			cout << now << endl;
		}
		else {
			for (int i = m - 1; i >= 0; i--) {
				string next = now + to_string(i);
				st.push(next);
			}
		}
	}
}

int main() {
	int n;
	cin >> n;
	whei(int) s(3, vector<int>(n + 1, 0)),dp(2+1,vector<int>(n+1,0));
	rep(i, 1, 3) {
		rep(j, 1, n + 1) {
			cin >> s[i][j];
		}
	}
	rep(i, 1, 3) {
		rep(j, 1, n + 1) {
			dp[i][j] = s[i][j] + max(dp[i - 1][j], dp[i][j - 1]);
		}
	}
	cout << dp[2][n] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <algorithm>

const int maxn = 2e4 + 20;

int n;
int p[maxn];
int a[maxn];
int b[maxn];

int main()
{
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) scanf("%d", &p[i]);
	
	for(int i = 1; i <= n; i++) b[i] = n * (n - i + 1);
	for(int i = 1; i <= n; i++) a[i] = n * i;
	for(int i = 1; i <= n; i++) a[p[i]] += i - 1;
	
	for(int i = 1; i <= n; i++) printf("%d ", a[i]);
	printf("\n");
	for(int i = 1; i <= n; i++) printf("%d ", b[i]);
	printf("\n");
	
	return 0;
}

Measured memory_bytes: 768
#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)
#define var(Type, ...)  Type __VA_ARGS__; input(__VA_ARGS__)
#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); }
inline i64  sigma(i64 n)            { return (n * (n + 1) >> 1); }
inline i64  updiv(i64 a, i64 b)     { return (a + b - 1) / b; }
inline i64  sqr(i64 n)              { return n * n; }
inline string to_string(char c)     { return string(1, c); }
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...));
}

inline void input() {}
template <class Head, class... Tail>
inline void input(Head &head, Tail&... tail) { cin >> head; input(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;
}

template <typename Func>
struct FixPoint : Func {
    inline constexpr FixPoint(Func &&f) noexcept : Func(forward<Func>(f)) {}

    template <typename... Args>
    inline decltype(auto) operator()(Args &&... args) const {
        return Func::operator()(*this, forward<Args>(args)...);
    }
};

template< typename Func >
inline decltype(auto) makeFixPoint(Func &&f) {
    return FixPoint< Func >{forward< Func >(f)};
}
// }}} End Header

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

    var(int, N);
    var(string, s, t);
    string ans = "";

    rep(i, N) {
        ans += s[i];
        ans += t[i];
    }

    print(ans);

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
// #undef DEBUG
// #define DEBUG
// DEBUG {{{
// clang-format off
template<int n, class...T> typename enable_if<(n>=sizeof...(T))>::type _ot(ostream &, tuple<T...> const &){}
template<int n, class...T> typename enable_if<(n< sizeof...(T))>::type _ot(ostream & os, tuple<T...> const & t){ os << (n==0?"":", ") << get<n>(t); _ot<n+1>(os, t); }
template<class...T> ostream & operator<<(ostream &o, tuple<T...> const &t){ o << "("; _ot<0>(o, t); o << ")"; return o; }
template<class T, class U> ostream & operator<<(ostream &o, pair<T, U> const &p) { o << "(" << p.first << ", " << p.second << ")"; return o; }
#ifdef DEBUG
#if !defined(DEBUG_OUT)
// #define DEBUG_OUT cerr
#endif
#define dump(...) [&](){auto __debug_tap=make_tuple(__VA_ARGS__);DEBUG_OUT<<"["<<__LINE__<< "] "<<#__VA_ARGS__<<" = "<<__debug_tap<<"\n";}()
template < class T > inline void dump2D(T &d, size_t sizey, size_t sizex) { for(size_t i = 0; i < sizey; i++) { DEBUG_OUT << "\t"; for(size_t j = 0; j < sizex; j++) DEBUG_OUT << d[i][j] << (j + 1 == sizex ? "" : "\t"); DEBUG_OUT << endl; } }
template < class T, class = typename iterator_traits< typename T::iterator >::value_type, class = typename enable_if<!is_same<T, string>::value>::type > ostream &operator<<(ostream &o, const T &a) { o << "{"; for(auto ite = a.begin(); ite != a.end(); ++ite) o << (ite == a.begin() ? "" : ", ") << *ite; o << "}"; return o; }
#else
#define dump(...) (42)
#define dump2D(...) (42)
template < class T, class = typename iterator_traits< typename T::iterator >::value_type, class = typename enable_if<!is_same<T, string>::value>::type > ostream &operator<<(ostream &o, const T &a) { for(auto ite = a.begin(); ite != a.end(); ++ite) o << (ite == a.begin() ? "" : " ") << *ite; return o; }
#endif
// clang-format on
// }}}


int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  int n, x;
  cin >> n >> x;
  int a[212345];
  for(int i = 0; i < n; i++) cin >> a[i];
  auto f = [&](int k) {
    vector<int> last(k, -1);
    vector<int> cnt(k, 0);
    ll res = 0;
    for(int i = n-1; i >= 0; i--) {
      cnt[i%k]++;
      if(last[i%k] == -1) res += a[i];
      else res += ll(last[i%k] - a[i]) * (cnt[i%k])*(cnt[i%k]);
      last[i%k] = a[i];
    }
    for(int i = 0; i < k; i++){ 
      cnt[i]++;
      if(last[i] != -1) res += (ll) last[i] * cnt[i] * cnt[i];
    }
    return res + (ll) n * x + (ll) x * k;
  };
  int ok = n, ng = 0;
  while(ok-ng > 1) {
    int mid = (ok+ng)/2;
    if(f(mid + 1) - f(mid) >= 0) ok = mid;
    else ng = mid;
  }
  // dump(ok);
  // dump(f(1));
  cout << f(ok) << endl;
  return 0;
}


Measured memory_bytes: 1888
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e18;
const ll MAX_N = 201010;

//組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };
char notes[110][10];
ll tre[3030][3030];
ll dp[3030][3030][4];

//long longしか使わない
//素数は1より大きい
//lower_boundは指定したkey以上の要素の一番左のイテレータをかえす
//upper_boundは指定したkeyより大きい要素の一番左のイテレータをかえす
int main() {
	ll n;
	cin >> n;
	vector<ll>a(n);
	ll res = 0;
	ll ans = 0;
	rep(i, n) {
		cin >> a[i];
		if (res <= a[i])chmax(res, a[i]);
		else {
			ans += res - a[i];
		}
	}
	cout << ans << endl;
	return 0;
}


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

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

  if (n == 0) {
    cout << x << endl;
    return 0;
  }

  set<int> p;
  for (int i = 0; i < n; i++) {
    int q;
    cin >> q;
    p.insert(q);
  }

  int ans = (int)1e9;
  int diff_min = (int)1e9;
  for (int i = 0; i < 500; i++) {
    if (p.count(i)) continue;

    // 正方向
    int diff = abs(x - i);
    if (diff <= diff_min) {
      if (diff < diff_min) {
        ans = (int)1e9;
      }
      diff_min = diff;
      ans = min(i, ans);
    }

    // 負方向
    diff = abs(x + i);
    if (diff <= diff_min) {
      if (diff < diff_min) {
        ans = (int)1e9;
      }
      diff_min = diff;
      ans = min(i, ans);
    }
  }

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


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

int a[105];
long long int dp[105][21];

int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i)cin >> a[i];
	fill((long long int*)dp, (long long int*)(dp + n), 0);
		
	dp[0][a[0]] = 1;
	for (int i = 0; i < n - 2; ++i){
		for (int j = 0; j <= 20; ++j){
			if (0 <= j - a[i+1]) dp[i+1][j] += dp[i][j-a[i+1]];
			if (j + a[i+1] <= 20) dp[i+1][j] += dp[i][j+a[i+1]];
		}
	}
	
	cout << dp[n-2][a[n-1]] << endl;
	
}
	

Measured memory_bytes: 1172
<?php

fscanf(STDIN, "%s", $s);
$s = trim($s);
$a = str_split($s);

foreach($a as $v) {
    if(isset($b[$v])) {
        $b[$v]++;
    }else{
        $b[$v] = 1;
    }
}

$check = function($b) {
    if(2 !== count($b)){
        return false;
    }
    foreach($b as $cnt){
        if(2 !== $cnt){
            return false;
        }
    }
    return true;
};

echo $check($b) ? 'Yes' : 'No';


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int q(int pos){
    cout<<pos<<endl;
    string s;cin>>s;
    if(s=="Vacant")return -1;
    if(s=="Male")return 1;
    return 0;
}

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

    int x=q(0);
    if(x==-1)return 0;
    int l=1,r=N;
    int vl=x,vr=x;
    while(true){
        int m=(l+r)/2;
        int x=q(m);
        if(x==-1)return 0;

        if((m-l)%2==(vl^x)){
            r=m;
            vr=x;
        }
        else{
            l=m+1;
            vl=x;
        }
    }


    return 0;
}


Measured memory_bytes: 852
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long ll;

//struct _IO { _IO() { ios::sync_with_stdio(0); cin.tie(0); } }_io;
using namespace std;
string s;
int len;
bool dfs(int d) {
	if (d == len) return 1;
	if (d > len) return 0;
	if (s[d] == 'e') {
		if (d + 5 < len && s.substr(d, 6) == "eraser") return dfs(d + 6);
		if (d + 4 < len && s.substr(d, 5) == "erase") return dfs(d + 5);
		return 0;
	}
	else if (s[d] == 'd') {
		if (d + 6 < len && s.substr(d, 7) == "dreamer") if(dfs(d+7))return 1;
		if (d + 4 < len && s.substr(d, 5) == "dream") return dfs(d + 5);
		return 0;
	}
	return 0;
}
int main() {
	cin >> s;
	len = s.size();
	if (dfs(0)) cout << "YES" << '\n';
	else cout << "NO" << '\n';
}


Measured memory_bytes: 5356
#include <bits/stdc++.h>
using namespace std;
using lint  = long long;

signed main(){
  string s; cin >> s;
  lint ans = 0;
  lint l = 0, r = s.size() - 1;
  while(l < r){
    if(s[l] == s[r]) l++, r--;
    else if(s[l] == 'x' && s[r] != 'x'){
      l++; ans++;
    }
    else if(s[l] != 'x' && s[r] == 'x'){
      r--; ans++;
    }
    else{
      cout << -1 << endl;
      return 0;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
#include <stdio.h>

int main(){
    int i,A,B,T;
    int ans=0;
    scanf("%d %d %d",&A,&B,&T);
    for(i=1;i*A<(T+0.5);i++){
        ans +=B ;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 128
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}

int main() {
    ll a, b, c; cin >> a >> b >> c;
    ll res;
    if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) {
        res = 0;
    } else {
        res = a * b;
        res = min(res, a * c);
        res = min(res, b * c);
    }
    cout << res << endl;
    return 0;
}

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

using namespace std;

int main()
{
    int n;
    cin >> n;
    int cnt = 0;
    for( int i = 0; i < n; i++ ){
        int num;
        cin >> num;
        if( (i + 1) % 2 && num % 2 )
            cnt++;
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 3592
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;
using ll = long long;

#define REP(i, a) for (int i = 0; i < (a); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a)-1; i >= (b); --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond, yes, no) \
    { cout << ((cond) ? (yes) : (no)) << endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(), (list).rend())
#define ASSERT(cond, mes) assert(cond&& mes)

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template <typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())
    is >> v[i];
    return is;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a) n = a;
    if (n > b) n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

std::vector<ll> enum_div(ll n) {
    std::vector<ll> ret;
    for (ll i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i != 1 && i * i != n) { ret.push_back(n / i); }
        }
    }
    return ret;
}

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

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

struct ToUpper {
    char operator()(char c) {
        return toupper(c);
    }
};

struct ToLower {
    char operator()(char c) {
        return tolower(c);
    }
};

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

    int N;
    cin >> N;
    vector<int> A(N);
    cin >> A;

    int x = 0, y = 0, z = 0;
    ll ans = 1;
    REP(i, N) {
        int t = 0;
        if (x == A[i]) { t++; }
        if (y == A[i]) { t++; }
        if (z == A[i]) { t++; }
        ans *= t;
        ans %= MOD;
        if (x == A[i]) {
            x++;
        } else if (y == A[i]) {
            y++;
        } else {
            z++;
        }
    }

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

Measured memory_bytes: 640
#include<stdio.h>

void trace(int A[], int N) {
  int i;
  for ( i = 0; i < N; i++ ) {
    if ( i > 0 ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

void insertionSort(int A[], int N) {
  int i, v, j;
  for ( i = 1; i < N; i++ ) {
    v = A[i];
    j = i - 1;
    while ( j >= 0 && A[j] > v ) {
      A[j + 1] = A[j];
      j--;
    }
    A[j + 1] = v;
    trace(A, N);
  }
}

int main() {
  int N, i, j;
  int A[100];

  scanf("%d", &N);
  for ( i = 0; i < N; i++ ) scanf("%d", &A[i]);

  trace(A, N);
  insertionSort(A, N);

  return 0;
}


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

using namespace std;
typedef long long ll;
#define int ll

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

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
const int MAX_N = 100010;

template <typename T> T gcd(T a, T b) { while (a) { b %= a; swap(a, b); } return b; }
template <typename T> T lcm(T a, T b) { return a / gcd(a,b) * b; }

map<ll, ll> PrimeFactor(ll n) {
    map<ll, ll> res;
    for(ll i = 2; i * i <= n; ++i) {
        while(n % i == 0) {
            ++res[i];
            n /= i;
        }
        if(LLINF / i <= i) { break; }  // オーバーフロー警察
    }
    if(n != 1) { res[n] = 1; }
    return res;
}

int N, M;
vector<int> A, B;

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

    cin >> N >> M;
    A.resize(N);
    REP(i, N) {
        cin >> A[i];
        A[i] /= 2;
    }

    // 何回 2 で割れるか
    auto Check = [](int num) {
        int ret = 0;
        while(num % 2 == 0) {
            num /= 2;
            ret++;
        }
        return ret;
    };
    // 2 の個数チェック
    int check = Check(A[0]);
    REP(i, N) {
        if(check != Check(A[i])) {
            printf("0\n");
            return 0;
        }
        A[i] >>= check;
    }

    M >>= check;

    int lcm_a = 1; 
    REP(i, N) {
        lcm_a = lcm(lcm_a, A[i]);
    }

    int ans = M / lcm_a;
    if(ans % 2 != 0) {
        ans = ans / 2 + 1;
    }
    else {
        ans /= 2;
    }

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

    return 0;
}


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

int Exp(long long int exp_n,long long int exp_e, long long exp_mod);

int main(){
  long long int K;
  string S;
  long long int O = 0;
  long long int tmp;
  cin >> K >> S;
  long long int N = S.length();
  long long int R[K];
  for(long long int i=0;i<K;i++){
    R[i]=Exp(i+1,1000000005,1000000007);
  }
  long long int COMB=1;
  
  
  for(long long int i=0;i<=K;i++){
    tmp = 1;

    tmp = tmp*Exp(25,i,1000000007);
    
    if(tmp> 1000000007){
      tmp = tmp % 1000000007;
    }
    
    tmp = tmp*Exp(26,K-i,1000000007);
    
    if(tmp> 1000000007){
      tmp = tmp % 1000000007;
    }
    
    tmp = tmp*COMB;
    
    if(tmp> 1000000007){
      tmp = tmp % 1000000007;
    }
    
    if(N+i-1==0){
      COMB = COMB * 1 * 1;
    }else{
      COMB = COMB * (N+i);
      if(COMB > 1000000007){
        COMB = COMB % 1000000007;
      }
      COMB = COMB * R[i];
      if(COMB > 1000000007){
        COMB = COMB % 1000000007;
      }
    }

    
    O = O + tmp;
    if(O > 1000000007){
      O = O % 1000000007;
    }
    
  }
  cout << O <<endl;
  
  return 0;
}


int Exp(long long int exp_n,long long int exp_e, long long int exp_mod){
  long long int exp_o = 1;
  long long int exp_x=exp_n;
  long long int exp_tmp;
  
  while(0<exp_e){
    exp_tmp = exp_e/2;
    if(exp_e - exp_tmp*2 == 1){
      exp_o = exp_o*exp_x;
      if(exp_o>exp_mod){
        exp_o=exp_o%exp_mod;
      }
    }
    
    exp_x = exp_x*exp_x;
    if(exp_x>exp_mod){
      exp_x=exp_x%exp_mod;
    }
    exp_e = exp_tmp;
  }
  return exp_o;
}


Measured memory_bytes: 12020
N = int(input())
A = list(map(int, input().split()))

flag = True
for i in range(N):
    if A[i]%2 == 0:
        if A[i]%3 != 0 and A[i]%5 != 0:
            flag = False

if flag:
    print('APPROVED')
else:
    print('DENIED')

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>
#include <iomanip>
#include <queue>
#include <cctype>
#include <stack>
#include<set>


#define rep(i,p,q) for(ll i = p;i < q;++i)
#define ll long long

using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll npk(ll n, ll k) {
	ll ret = 1;
	if (n < k || n < 0)return 0;
	rep(i, 0, k) {
		ret *= (n - i);
		ret %= MOD;
	}
	if (ret < 0) ret = 0;
	return ret;
}


//135 A
int main(void) {
	ll a, b;
	cin >> a >> b;
	if (a == b)cout << 0 << endl;
	else {
		if ((a + b) % 2 != 0) cout << "IMPOSSIBLE" << endl;
		else cout << (a + b) / 2 << endl;
	}
}

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

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

int main() {
  int n;
  cin >> n;
  ll h[n];
  rep(i, n) { cin >> h[i]; }

  ll dp[n];
  // dp テーブルの初期化
  rep(i, n) { dp[i] = INF; }
  dp[0] = 0;
  dp[1] = abs(h[1] - h[0]);

  for (int i = 1; i < n; i++) {
    chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
    chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
  }

  cout << dp[n - 1] << endl;

  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long

using namespace std;

ll n, ans, k, mod = 1000000007;
string s1, s2;

int main() {
    cin >> n;
    cin >> s1 >> s2;
    ans = 3;
    int i = 1;
    if (s1[0] != s2[0]) ans = 6, i++, k = 1;
        for (; i < n; i++)
            if (s1[i] == s2[i] && !k)
                ans *= 2, ans %= mod;
            else if (s1[i] != s2[i] && !k) {
                ans *= 2;
                i++;
                k = 1;
                ans %= mod;
            }
            else if (s1[i] != s2[i] && k){
            ans *=3;
            ans %= mod;
                i++;
            }
            else k = 0;

    cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
N = int(input())
W = list(map(int, input().split()))
diff = []
s_1 = 0
s_2 = sum(W)

for i in range(N):
    s_1 += W[i]
    s_2 -= W[i]
    diff.append(abs(s_1 - s_2))

print(min(diff))

Measured memory_bytes: 3060
S = gets.chomp
N = S.size
R = Array.new(N, 0)

(0 ... N).inject(-1) do |r, i|
  if S[i] == 'L'
    R[(r - i).odd? ? r + 1: r] += 1
    r
  else
    i
  end
end
(0 ... N).reverse_each.inject(N) do |l, i|
  if S[i] == 'R'
    R[(l - i).odd? ? l - 1 : l] += 1
    l
  else
    i
  end
end
puts R.join(' ')


Measured memory_bytes: 6012
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <iostream>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n,n_;

struct data{
	ll val,lazy;
	data(){}
	data(ll vv,ll la){
		val=vv;
		lazy=la;
	}
};

data dat[1<<23];

void lazy_evaluate(int k){
	dat[k].val+=dat[k].lazy;
	dat[k].val%=MOD;
	if(k+1<n_){
		dat[k*2+1].lazy+=dat[k].lazy;
		dat[k*2+2].lazy+=dat[k].lazy;
		dat[k*2+1].lazy%=MOD;
		dat[k*2+2].lazy%=MOD;
	}
	dat[k].lazy=0;
}

void lazy_update(int k){
	dat[k].val=(dat[k*2+1].val+dat[k*2+2].val)%MOD;
}

void update(int a,int b,ll v,int k=0,int l=0,int r=n_){
	lazy_evaluate(k);
	if(b<=l || r<=a)return;
	if(a<=l && r<=b){
		dat[k].lazy+=v;
		dat[k].lazy%=MOD;
		lazy_evaluate(k);
		return;
	}
	update(a,b,v,k*2+1,l,(l+r)/2);
	update(a,b,v,k*2+2,(l+r)/2,r);
	lazy_update(k);
}

ll query(int a,int b,int k=0,int l=0,int r=n_){
	lazy_evaluate(k);
	if(b<=l || r<=a)return 0;
	if(a<=l && r<=b){
		return dat[k].val;
	}
	ll vl=query(a,b,k*2+1,l,(l+r)/2);
	ll vr=query(a,b,k*2+2,(l+r)/2,r);
	lazy_update(k);
	return (vl+vr)%MOD;
}

ll dp2[1000001];

int main(void){
	scanf("%d",&n);
	n_=1;
	while(n_<n+1)n_*=2;
	ll sum=0;
	ll res=0;
	dp2[0]=1;
	dp2[1]=1;
	dp2[2]=1;
	for(int i=0;i<n;i++){
		ll v;
		if(dp2[i]!=0)v=dp2[i];
		else{
			v=(sum+MOD-dp2[i-2])%MOD;
		}
		dp2[i]=v;
		sum+=v;
		sum%=MOD;
		if(i==n-1){
			res+=(ll)v*n%MOD;
		}else{
			res+=(ll)((v*(n-1LL)%MOD)*(n-1LL))%MOD;
			res%=MOD;
			ll rest=n-i-1;
			if(rest==1){
				res+=(ll)v*(n-1)%MOD;
			}else{
				res+=(ll)v*(n-rest+1)%MOD;
			}
			res%=MOD;
		}
		//printf("%lld %lld\n",res,v);
	}
	res%=MOD;
	printf("%lld\n",res);
	return 0;
}


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

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

  ll N; cin >> N;
  ll M = N - 1;

  ll ans = 0;
  ll MAX = sqrt(M);
  for (ll i = 2; i <= MAX; i++) {
    if (M % i == 0) ans += 2;
  }
  if (MAX * MAX == M) ans--;
  ans++; // N - 1

  MAX = sqrt(N);
  for (ll i = 2; i <= MAX; i++) {
    if (N % i == 0) {
      ll K, T;
      K = i, T = N;
      while(T % K == 0) {
        T /= K;
      }
      if (T % K == 1) ans++;

      K = N / i, T = N;
      while(T % K == 0) {
        T /= K;
      }
      if (T % K == 1) ans++;
    }
  }
  if (MAX * MAX == N) ans--;
  ans++; // N

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

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		double N = Integer.parseInt(scanner.nextLine());
		scanner.close();

		double v =  (N - (int) (N / 2)) / N;
		
		System.out.println(v);
	}
}

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

#define what_is(x) cout << #x << " is " << x << endl;
#define PI acos(-1)
#define hell 1000000007
#define HELL 998244353
#define io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define fix(n) cout << fixed << setprecision(n)
#define mset(a,n) memset(a,n,sizeof a)
#define rep(i,a,b) for (__typeof((b)) i=(a);i<(b);i++)
#define repp(i,a,b,p) for(__typeof((b)) i=(a);i<(b);i+=p)
#define ren(i,a,b) for(__typeof((a)) i=(a);i>=(b);i--)
#define renn(i,a,b,p) for(__typeof((a) i=(a);i>=(b);i-=p)
#define ADD(a,b,c) ((a)%c+(b)%c)%c
#define SUB(a,b,c) ((a)%c-(b)%c+c)%c
#define MUL(a,b,c) (((a)%c)*((b)%c))%c
#define lbd lower_bound
#define ubd upper_bound
#define ll long long
#define ld long double
#define pb push_back
#define fi first
#define se second
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define all(v) (v).begin(), (v).end()
#define sz(x) (ll)x.size()
// #define out(n) cout<<n<<" "
#define outl(n) cout<<n<<endl
#define bug(n) {outl(n);return;}
#define pii pair<int,int>
#define lim 1000000000000000000
#define ninf -9223372036854775802
#define M 1000000007
#define eps 1e-9
#define MAX 5
#define N 200001
#define db(a) for(auto it:a) {cout<<it<<" ";}cout<<endl;
ll prime[MAX];
ll fact[MAX];

const long long INF64 = 1e18;
ll vpow(ll a, ll b, ll p) {
    if (b == 0)
        return 1;
    if (b == 1)
        return a;
    ll temp = vpow(a, b / 2, p);
    temp *= temp;
    temp %= p;
    if (b % 2 == 0)
        return temp;
    temp = temp * a;
    temp %= p;
    return temp;
}

ll gcd(ll a, ll b) {
    if (a == 0)
        return b;
    return gcd(b % a, a);
}


ll inverseMod(ll a, ll b, ll p) {
    if (b == 0)
        return 1;
    ll temp = vpow(b, p - 2, p);
    ll ans = temp * a;
    ans %= p;
    return ans;
}
void sieve()
{
    prime[0] = prime[1] = 1;
    for (ll i = 2; i < MAX; i++) {
        if (prime[i] == 0) {
            for (int j = i * 2; j < MAX; j += i) {
                if (prime[j] == 0) {
                    prime[j] = i;
                }
            }
            prime[i] = i;
        }
    }
}

void factorial() {
    fact[0] = 1;
    fact[1] = 1;
    rep(i, 2, MAX) {
        fact[i] = (fact[i - 1] * i);
        // fact[i]%=M;
    }
}
void solve(ll ttt) {
	string s;
    cin>>s;
    ll n=sz(s);
    if(s[n-1]!='s'){
        s+='s';
    }
    else
        s+="es";
    cout<<s<<endl;
}

int main() {
    io;
    // sieve();
    // factorial();
#ifndef ONLINE_JUDGE
    freopen("input1.txt", "r", stdin);
    // freopen("output1.txt","w",stdout);
#endif

    ll t = 1;
    // cin >> t;
    fix(12);
    rep(q, 1, t + 1) {
        // cout<<"Test case : "<<q<<endl;
        solve(q);
        //solve2();
    }
    return 0;

}


Measured memory_bytes: 3636
///==================================================///
///                HELLO WORLD !!                    ///
///                  IT'S ME                         ///
///               BISHAL GAUTAM                      ///
/// [ bsal.gautam16@gmail.com, bishal@devskill.com ] ///
///==================================================///
#include<bits/stdc++.h>
#define X first
#define Y second
#define mpp make_pair
#define nl printf("\n")
#define SZ(x) (int)(x.size())
#define pb(x) push_back(x)
#define pii pair<int,int>
#define pll pair<ll,ll>
///---------------------
#define S(a) scanf("%d",&a)
#define P(a) printf("%d",a)
#define SL(a) scanf("%lld",&a)
#define S2(a,b) scanf("%d%d",&a,&b)
#define SL2(a,b) scanf("%lld%lld",&a,&b)
///------------------------------------
#define all(v) v.begin(),v.end()
#define CLR(a) memset(a,0,sizeof(a))
#define SET(a) memset(a,-1,sizeof(a))
#define fr(i,a,n) for(int i=a;i<=n;i++)
using namespace std;
typedef long long ll;
///==========CONSTANTS=============///
///  Digit     0123456789012345678 ///
#define MX     500012
#define inf    10000000000000000LL
#define MD     1000000007
#define eps    1e-9
///===============================///

ll n,a,b,c,d;

ll go(ll x){
   if(x==0) return 0LL;
   ll xa=a*4LL*x;
   ll xb=b*2LL*x;
   ll xc=c*x;
   ll xd=inf;
   if(x!=1)xd=d*(x/2LL)+go(x%2);
   return min(min(xa,xb),min(xc,xd));
}
int main() {
    cin>>a>>b>>c>>d>>n;
    cout<<go(n)<<endl;
    return 0;
}


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

using namespace std;
using ll = long long;

int main() {
	int r, D, x;
	cin >> r >> D >> x;

	for (int i = 0; i < 10; ++i) {
		int nx = r * x - D;
		cout << nx << endl;
		x = nx;
	}

	return 0;
}


Measured memory_bytes: 256
primes = [0, 0] + [1]*50020
for i in range(2, 226):
    if primes[i]:
        for j in range(i*i, 50021, i):
            primes[j] = 0

while True:
    try:
        n = int(input())
    except:
        break
    print(n-primes[n-1::-1].index(1)-1, n+primes[n+1:].index(1)+1)

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

typedef complex<double> P;
typedef pair<P,P> L;

const double INF = 1e+9;
const double EPS = 1e-8;

bool equal(double a, double b){
  return fabs(a-b) < EPS;
}

double dot(P a, P b){ return real(conj(a)*b); }

double cross(P a, P b){ return imag(conj(a)*b); }

int ccw(P a, P b, P c){
  b -= a;
  c -= a;
  if(cross(b,c) > EPS) return 1;
  if(cross(b,c) < -EPS) return -1;
  if(dot(b,c) < -EPS) return 2;
  if(norm(b) < norm(c)) return -2;
  return 0;
}

bool isIntersectSP(L s, P p){ 
  return abs(s.first-p) + abs(s.second-p) - abs(s.second-s.first) < EPS; 
}

bool isIntersect(L s1, L s2){  
  if(max(real(s1.first), real(s1.second)) + EPS < min(real(s2.first), real(s2.second)) ||
     max(imag(s1.first), imag(s1.second)) + EPS < min(imag(s2.first), imag(s2.second)) ||
     max(real(s2.first), real(s2.second)) + EPS < min(real(s1.first), real(s1.second)) ||
     max(imag(s2.first), imag(s2.second)) + EPS < min(imag(s1.first), imag(s1.second))) return false;

  return ( ccw(s1.first,s1.second,s2.first) * ccw(s1.first,s1.second,s2.second) <= 0 &&
           ccw(s2.first,s2.second,s1.first) * ccw(s2.first,s2.second,s1.second) <= 0 );
}


P crossPoint(L l, L m){
  double A = cross(l.second - l.first, m.second - m.first);
  double B = cross(l.second - l.first, l.second - m.first);
  if(fabs(A) < EPS && fabs(B) < EPS) return m.first;
  else if(fabs(A) >= EPS) return m.first + B / A * (m.second - m.first);
}


int m, n;
vector<P> xyv, xzv;

bool find(vector<double> v, double x){
  for(int i=0;i<v.size();i++){
    if(equal(v[i], x)) return true;
  }
  return false;
}

double calc_width(vector<P> v, double x){
  L l = L(P(x, -INF), P(x, INF));
  double maxy = -INF, miny = INF;
  int n = v.size();

  for(int i=0;i<n;i++){
    if(isIntersect(l, L(v[i], v[(i+1)%n])) /*&& !equal(real(v[i]), real(v[(i+1)%n]))*/){
      maxy = max(maxy, imag(crossPoint(L(P(x, -INF), P(x, INF)), L(v[i], v[(i+1)%n]))));
      miny = min(miny, imag(crossPoint(L(P(x, -INF), P(x, INF)), L(v[i], v[(i+1)%n]))));
    }
  }

  if(equal(maxy, -INF) || equal(miny, INF)) return 0;
  else return maxy - miny;
}

double solve(){
  double res = 0;
  vector<double> xv;
  
  for(int i=0;i<xyv.size();i++){
    if(!find(xv, real(xyv[i]))) xv.push_back(real(xyv[i]));
  }
  for(int i=0;i<xzv.size();i++){
    if(!find(xv, real(xzv[i]))) xv.push_back(real(xzv[i]));
  }
  
  sort(xv.begin(), xv.end());

  for(int i=0;i<(int)xv.size()-1;i++){
    double fa = calc_width(xyv, xv[i]+EPS) * calc_width(xzv, xv[i]+EPS);
    double fab = calc_width(xyv, (xv[i] + xv[i+1]) / 2.0) * calc_width(xzv, (xv[i] + xv[i+1]) / 2.0);
    double fb = calc_width(xyv, xv[i+1]-EPS) * calc_width(xzv, xv[i+1]-EPS);
    //cout << fa << ' ' << fab << ' ' << fb << endl;
    res += (fa + 4.0 * fab + fb) * (xv[i+1] - xv[i]) / 6.0; // simpson
  }

  return res;
}

int main(){
  double a, b;
  while(cin >> m >> n && (m|n)){
    xyv.clear();
    xzv.clear();
    for(int i=0;i<m;i++){
      cin >> a >> b;
      xyv.push_back(P(a,b));
    }
    for(int i=0;i<n;i++){
      cin >> a >> b;
      xzv.push_back(P(a,b));
    }
    printf("%.10f\n", solve());
  }
}

Measured memory_bytes: 1284
#include <iostream>
#include <vector>
#include <stack>

using namespace std;

class UnionFind {
    vector<int> par;
    vector<int> tree_count;

public:
    UnionFind(int N) : par(N), tree_count(N) {
        for(int i = 0; i < N; i++) {
            par[i] = i;
            tree_count[i] = 1;
        }
    }

    int size(int x) {
        return tree_count[root(x)];
    }

    int root(int x) {
        if(par[x] == x) return x;
        //親を探すときに経路上のノードを親にくっつける
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if(rx == ry) return;
        //ryに所属するグループの頂点数を格納(親でなくなった頂点は-1)
        tree_count[ry] += tree_count[rx];
        tree_count[rx] = -1;
        //xの親をyの親の下にくっつける
        par[rx] = ry;
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};


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

    vector<long long> A(M, 0);
    vector<long long> B(M, 0);
    for(int i = 0; i < M; i++) {
        cin >> A[i] >> B[i];
    }

    vector<long long> ret(M, 0);
    UnionFind uf(N);
    long long change = 0;
    ret[M-1] = (long long)((N*(N-1))/2);
    for(int i = M - 2; i >= 0; i--) {
        if (!uf.same(A[i+1] - 1, B[i+1] - 1)) 
            change =  (uf.size(A[i+1]-1) * uf.size(B[i+1]-1));
        else 
            change = 0;

        //cout << "change:" << change   << endl;
        
        uf.unite(A[i+1]-1, B[i+1]-1);
        ret[i] = ret[i+1] - change;
        //cout << (uf.size(A[i]-1)) << "," << (uf.size(B[i]-1)) <<endl;

    }
    
    for(int i = 0; i < M; i++) {
        cout << ret[i] << endl;
    }
}

Measured memory_bytes: 4480
import java.util.*;
import java.util.ArrayList;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        
        int A,B;

        A = sc.nextInt();
        B = sc.nextInt();

       
        if(A >= 10 || B >= 10) {
            System.out.print("-1");
        } else {
            System.out.print(A * B);
        }

        sc.close();


    }
}

Measured memory_bytes: 23380
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<chrono>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
using namespace std;
 
template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " <<to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

void solve(){
    ll n;
    cin>>n;
    if(n%2)cout<<0<<"\n";
    else{
      ll ans=0;
      ll div=10;
      while(div<=1e18){
        ans+=n/div;
        div*=5LL;
      }
      cout<<ans<<"\n";
    }
}
 
int main(){
	ios::sync_with_stdio(false);
    cin.tie(0);
	cout<<fixed<<setprecision(15);
	solve();
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<utility>
using namespace std;
double x,y;
bool cross(double a,double b,double c,double d)
{
	return (c-a)*(y-b)-(x-a)*(d-b)>0;
}
int main()
{
	double a,b,c,d,e,f;
	for(;cin>>a>>b>>c>>d>>e>>f>>x>>y;)
	{
		int cnt=0;
		cnt+=cross(a,b,c,d);
		cnt+=cross(c,d,e,f);
		cnt+=cross(e,f,a,b);
		cout<<(cnt==0||cnt==3?"YES":"NO")<<endl;
	}
}



Measured memory_bytes: 3208
#include <stdio.h>

int main(){
	int a[3];
	long int h[100100],i,ans=0;
	
	for(i=0;i<3;i++)scanf("%d",a+i);
	
	if(a[0]==a[1] && a[1]!=a[2]
	 ||a[1]==a[2] && a[1]!=a[0]
	 ||a[2]==a[0] && a[0]!=a[1])printf("Yes\n");
	 
	 else printf("No\n");
	
	return 0;	
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
class book{
public:
	ll t,a,b,flag;
};
bool compare(pair<ll,ll> p1,pair<ll,ll> p2){
  if(p1.second==p2.second) return p1.first>p2.first;
	return p1.second>p2.second;
}
bool comp(char a, char b)
{
    return (a < b);
}
int mex(int *A,int n){
	int C[n];
	for(int i=0;i<n;i++) C[i]=A[i];
	sort(C,C+n);
	for(int i=0;i<=n;i++){
		if(!binary_search(C,C+n,i)) return i;
	}
}
bool check(int *A,int n){
	for(int i=0;i<n-1;i++){
		if(A[i]>A[i+1]) return false;
	}
	return true;
}
bool subsetSum(vector<ll> arr, int n, int s){
	int dp[2][s+1];

	for(int i=0;i<=s;i++){
		dp[0][i] = false;
	}
    dp[0][0] = true;

    int flag = 1;

	for(int i=1;i<=n;i++){
		for(int j =1;j<=s;j++){
			dp[flag][j] = dp[flag^1][j];
			if(j-arr[i-1]>=0){
				dp[flag][j] = dp[flag][j] || dp[flag^1][j-arr[i-1]];
			}
		}
        flag^=1;
	}

 	return dp[flag^1][s];
}
int main() {
	// your code goes here


	int T=1;
	//cin>>T;

	while(T--){
	     ll n;
			 cin>>n;
			 ll ctr=1;
       ll a=7;
       map<ll,ll> m;
       while(1){
         a=a%n;
         if(a==0) break;
         else{
           if(m[a]) {
             ctr=-1;
             break;
           }
           else{
             m[a]++;
             ctr++;
             a=a*10+7;
           }
         }
       }
       cout<<ctr<<endl;
}
	return 0;
}


Measured memory_bytes: 65968
//ABC069C
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
#include <numeric>
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	int t = 0, f = 0;
	for(int i=0;i<n;i++){
		cin >> a.at(i);
		if(a.at(i)%2 == 0){
			t++;
			if(a.at(i)%4 == 0){
				f++;
				t--;
			}
		}
	}
	int i = 1;
	if(t != 0){
		if((n-t)/2+(n-t)%2 <= f){
			cout << "Yes" << endl;
		}else{
			cout << "No" << endl;
		}
	}else{
		if(n/2 <= f){
			cout << "Yes" << endl;
		}else{
			cout << "No" << endl;
		}
	}
	return 0;
}

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

int main(){
    int n,k;
    long long int x[100000];
    long long int distance;
    long long int min;

    cin>>n>>k;

    for(int i=0;i<n;i++){
        cin>>x[i];
    }

min=300000001;

    for(int i=0;i<=n-k;i++){
        if(x[i+k-1]<0){
          distance=abs(x[i]);
        }
        else if(x[i+k-1]>=0&&x[i]<=0){
            if(abs(x[i])<abs(x[i+k-1])){
            distance=(x[i+k-1]-x[i])+abs(x[i]);
            }
            else{
                 distance=(x[i+k-1]-x[i])+abs(x[i+k-1]);
            }
        }
        else{
            distance=abs(x[i+k-1]);
        }

        if(distance<min){
         min=distance;
        }

        
    }
    cout<<min<<endl;
    return 0;
}

Measured memory_bytes: 1024
s = input()
def f(s,c):
    result = 0
    while len(set(s)) != 1:
        t = ""
        for i in range(len(s)-1):
            #print(s)
            if s[i] == c or s[i+1] == c:
                #print(s[i],s[i+1],c)
                t += c
            else:
                t += s[i]
        #print(t)
        s = t
        result += 1
    return result
result = float('inf')
for c in set(s):
    result = min(result, f(s,c))
print(result)


Measured memory_bytes: 3060
#include <cstdio>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <cstring>
#include <sstream>

using namespace std;

typedef long long ll;
int R,C;
string ss[201];
int dp[2][1<<16];
const int INF=1<<30;
int bitPos[1<<16][18];
int bitCnt[1<<16][18];
int main(){
  for(int mask=0;mask<(1<<16);mask++){
    int a=0;
    for(int i=0;i<16;i++){
      if(((mask>>i)&1))bitPos[mask][i]=a++;
      else bitPos[mask][i]=-1;
      bitCnt[mask][i+1]=bitCnt[mask][i]+((mask>>i)&1);
    }
  }
  cin>>R>>C;
  for(int i=0;i<R;i++)cin>>ss[i];
  for(int i=R*C;i>=0;i--){
    int cur=i%2;
    int nxt=cur^1;
    const int cy=i/C;
    const int cx=i%C;
    for(int mask=0;mask<(1<<C);mask++){
      int res=-INF;
      if(i==R*C)res=0;
      else{
	int cnt=0;
	if(cy-1>=0)
	  cnt=(int)ss[cy-1].size()-(bitCnt[mask][16]-bitCnt[mask][cx]);
	const int ct=bitCnt[mask][cx];
	if(ct<(int)ss[cy].size()){
	  int nmask=mask|(1<<cx);
	  int add=0;
	  if(cx-1>=0&&bitPos[mask][cx-1]!=-1
	     &&bitPos[mask][cx-1]<(int)ss[cy].size()
	     &&bitPos[mask][cx-1]+1<(int)ss[cy].size()
	     &&ss[cy][bitPos[mask][cx-1]]==ss[cy][bitPos[mask][cx-1]+1]){
	    add+=2;
	  }
	  if(cy-1>=0&&bitPos[mask][cx]!=-1
	     &&cnt<(int)ss[cy-1].size()
	     &&bitCnt[mask][cx]<(int)ss[cy].size()
	     &&ss[cy-1][cnt]==ss[cy][bitCnt[mask][cx]]){
	    add+=2;
	  }
	  if(cx!=C-1||ct+1==(int)ss[cy].size()){
	    res=max(res,dp[nxt][nmask]+add);
	  }
	}
	{
	  int nmask=mask&~(1<<cx);
	  if(cx!=C-1||ct==(int)ss[cy].size()){
	    res=max(res,dp[nxt][nmask]);
	  }
	}
      }
      dp[cur][mask]=res;
    }
  }
  cout<<dp[0][0]<<endl;
  return 0;
}

Measured memory_bytes: 10940
#include<bits/stdc++.h>
using namespace std;
string s;int a[1<<17],b,n,i;
main(){
	cin>>s;
	n=s.size();
	for(i=n-1;i>=0;i--)if(s[i]=='L')b=i;else a[b-((b-i)&1)]++;
	for(i=0;i<n;i++)if(s[i]=='R')b=i;else a[b+((i-b)&1)]++;
	for(i=0;i<n;i++)cout<<a[i]<<" ";
}


Measured memory_bytes: 1024