akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Main {

    private static FastReader in = new FastReader(System.in);
    private static PrintWriter out = new PrintWriter(System.out);

    private static final long MOD = (long) 1e9 + 7;

    public static void main(String[] args) {
        solve();
        out.flush();
    }

    private static void solve() {
        int n = in.nextInt();
        long[] a = in.nextLongArray(n);

        boolean hasZero = Arrays.stream(a).filter(l -> l == 0).count() > 0;
        if (hasZero) {
            out.println(0);
            return;
        }

        BigInteger ans = BigInteger.ONE;
        BigInteger lim = BigInteger.valueOf((long) 1e18);
        for (long l : a) {
            ans = ans.multiply(BigInteger.valueOf(l));
            if (ans.compareTo(lim) > 0) {
                out.println(-1);
                return;
            }
        }
        out.println(ans.toString());
    }

    // https://www.geeksforgeeks.org/fast-io-in-java-in-competitive-programming/
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        FastReader(InputStream inputStream) {
            br = new BufferedReader(new
                    InputStreamReader(inputStream));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        // https://qiita.com/masakinpo/items/5f77f2a879578a85a0bb
        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}


Measured memory_bytes: 51016
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <cassert>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define INF 1000000007
#define pi 3.141592653589793
using namespace std;
int saidaikouyakusuu(int a,int b){
    if(b==0) return a;
    return saidaikouyakusuu(b,a%b);
}
int saisyoukoubaisuu(int a,int b){
    return a*b/saidaikouyakusuu(a,b);
}
int n,m,cnt=0,aa[220000],y,d;
pair<int,int> pp[220000];
string s,ss[220000];
char c;
queue<int> que;
signed main(){
    cin>>s>>ss[0];
    rep(i,s.size()){
        if(s[i]!=ss[0][i]){
            cnt++;
        }
    }
    cout<<cnt;
}

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

using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i < (n); --i)
#define all(x) (x).begin(), (x).end()
#define gsort(x, n) sort((x), (x + n) greater<int>())
#define rv(s) reverse((s).begin(), (s).end())
#define setout(n, x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10);
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).flont_back(a)
#define eb(x, a) (x).emplaes_back(a)
using pii = pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1e9 + 7;

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

   int n;
   cin >> n;

   if (n % 2 == 0)
   {
      cout << n / 2 << '\n';
   }
   else
   {
      cout << n / 2 + 1 << '\n';
   }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;
typedef pair<int, int> P;
typedef tuple<ll, ll, ll> T;
int cnt[200001];
deque<T> dp[200001];
vector<int> G[200001];
ll mod_pow(ll a, ll b) {
	if (b == 0) return 1;
	if (b % 2 == 0) {
		ll x = mod_pow(a, b / 2);
		return (x*x) % MOD;
	}
	return (a*mod_pow(a, b - 1)) % MOD;
}
void dfs(int v, int d) {
	cnt[d]++;
	for (int to : G[v]) {
		dfs(to, d + 1);
	}
}
int solve(int v) {
	if (G[v].size() == 0) {
		dp[v].emplace_back(1, 1, 0);
		return v;
	}
	vector<P> child;
	for (int to : G[v]) {
		int t = solve(to);
		child.emplace_back(dp[t].size(), t);
	}
	sort(child.begin(), child.end());
	int q = child[child.size() - 1].second;
	int len = -1;
	if (child.size() > 1) len = dp[child[child.size() - 2].second].size();
	for (int i = 0; i + 1 < child.size(); i++) {
		int p = child[i].second;
		for (int j = 0; j < dp[p].size(); j++) {
			ll cnt[3] = {};
			ll a[3], b[3];
			tie(a[0], a[1], a[2]) = dp[p][j];
			tie(b[0], b[1], b[2]) = dp[q][j];
			for (int x = 0; x <= 2; x++) {
				for (int y = 0; y <= 2; y++) {
					(cnt[min(x + y, 2)] += (a[x] * b[y]) % MOD) %= MOD;
				}
			}
			dp[q][j] = make_tuple(cnt[0], cnt[1], cnt[2]);
		}
		dp[p].clear();
	}
	if (len != -1) {
		for (int i = 0; i < len; i++) {
			get<0>(dp[q][i]) += get<2>(dp[q][i]);
			get<2>(dp[q][i]) = 0;
		}
	}
	dp[q].emplace_front(1, 1, 0);
	return q;
}
int main() {
	int N;
	cin >> N;
	for (int i = 1; i <= N; i++) {
		int p;
		cin >> p;
		G[p].push_back(i);
	}
	dfs(0, 0);
	int k = solve(0);
	ll ans = 0;
	for (int i = 0; i < dp[k].size(); i++) {
		ll t = get<1>(dp[k][i]);
		(t *= mod_pow(2, N + 1 - cnt[i])) %= MOD;
		(ans += t) %= MOD;
	}
	cout << ans << endl;
}

Measured memory_bytes: 216832
import java.io.*;class Main{public static void main(String[]_)throws Exception{BufferedReader B=new BufferedReader(new InputStreamReader(System.in));Integer i=0,o,m,l=1+i.valueOf(B.readLine()),w[]=new Integer[l],n=i.valueOf(B.readLine());while(i<l)w[i]=i++;for(;n-->0;w[m]=i){_=B.readLine().split(",");i=w[o=i.valueOf(_[0])];w[o]=w[m=i.valueOf(_[1])];}for(i=0;++i<l;)System.out.println(w[i]);}}

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

// Function Macros:
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

// Type / Class / Struct Definitions:
using namespace std;

using ll = long long;
using ull = unsigned long long;

// Constants:
const int INF = (1ll << 30) - 1;  // approx 1.07e9
const ll INFLL = 1ll << 60;       // approx 1.15e18
const int MOD = 1e9 + 7;          // 998244353
const long double EPS = 1.0e-14;

// Global Variables:
set<ll> ans;

// Prototype Declarations:
void dfs(ll, int);
int gcd(int, int);
template <class T>
inline bool chmin(T&, T);
template <class T>
inline bool chmax(T&, T);

// ================ Main Loop ================
int main() {
    int k;
    cin >> k;
    k--;
    ll now = 0;
    for(int i = 1; i < 10; i++) {
        dfs(i, 10);
    }
    int i = 0;
    for(auto v : ans) {
        //cout << i << ": " << v << endl;
        if(i == k) {
            cout << v << endl;
            break;
        }
        ++i;
    }
    return 0;
}
// ===========================================

//Functions:
void dfs(ll x, int d) {
    int m = x % 10;
    if(d > 0) {
        if(m != 0) {
            dfs(x * 10 + (m - 1), d - 1);
        } else {
            //dfs(x * 10 + 9, d - 1);
        }
        dfs(x * 10 + m, d - 1);
        if(m != 9) {
            dfs(x * 10 + (m + 1), d - 1);
        } else {
            //dfs(x * 10, d - 1);
        }
    }
    ans.insert(x);
}

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

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


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

struct UnionFind {
    vector<int> par;
    vector<int> rank;
    UnionFind(int n) {
        par.resize(n);
        iota(par.begin(), par.end(), 0);
        rank.assign(n, 0);
    }
    int find(int x) {
        if (par[x] == x) {
            return x;
        }
        return par[x] = find(par[x]);
    }
    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return;
        if (rank[x] > rank[y]) {
            par[x] = y;
        } else {
            par[y] = x;
            if (rank[x] == rank[y]) {
                rank[x]++;
            }
        }
    }
};

int main()
{
    int n, q;
    cin >> n >> q;
    UnionFind uf(n);
    for (int i = 0; i < q; i++) {
        int com, x, y;
        cin >> com >> x >> y;
        if (com == 0) {
            uf.unite(x, y);
        } else if (com == 1) {
            if (uf.find(x) == uf.find(y)) {
                cout << 1 << endl;
            } else {
                cout << 0 << endl;
            }
        }
    }
}


Measured memory_bytes: 3176
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }


int main() {
    int N, X;
    while (cin >> N >> X, N) {
        int res = 0;
        for (int i = 1; i <= N; ++i) {
            for (int j = i+1; j <= N; ++j) {
                for (int k = j+1; k <= N; ++k) {
                    if (i + j + k == X) ++res;
                }
            }
        }
        cout << res << endl;
    }
}


















Measured memory_bytes: 3072
"""
奇数文字存在する文字がキモ
最低でも答えは奇数文字存在する文字の種類数以上
各ブロックに1つだけ奇数文字の文字を奇数個入れるのが良い

左に１つだけ奇数文字がある & 右に少なくとも一つの奇数文字が残っている
→切断すべき

数だけわかればいい
→分割が必要になる条件を考えればよい？

acababcb
a|ab|ab|b ←分割可能ポイント

2文字の間でどこなら分割を置いていいかは求められる
各範囲に最低1つ置いて

26C2かぁ…ちょっとでかくね→3s?

a|bbb|ccc|a

abc
000

a
100
b
110
b
100

abb  -  a   = bb
100 xor 100 = 000

0 xor 0 = 0
1 xor 0 = 1
1 xor 1 = 0

abcdefghijklmnopqrstuvwxyz
10010000000000000000000000
"""

s = input()

alp = "abcdefghijklmnopqrstuvwxyz"
alpdic = {}

for i in range(26):
    alpdic[alp[i]] = i

dic = {}
now = 0
dic[now] = 0

for i in range(len(s)):

    nalp = alpdic[s[i]]
    now ^= 2 ** nalp

    #print (format(now,"b").zfill(26))

    #dic[now]がokなのは all0かある桁&nalpの桁が1

    ans = float("inf")
    if now in dic:
        ans = dic[now]

    for i in range(26):

        nserch = (2 ** i) ^ now
        if nserch in dic:
            ans = min(ans , dic[nserch])

    if now in dic:
        dic[now] = min(dic[now] , ans + 1)

    else:
        dic[now] = ans + 1

print (max(1,dic[now]))


Measured memory_bytes: 69796
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    lint d;
    cin >> d;
    if (d % 9 != 0) {
        cout << 0 << "\n";
        return 0;
    }
    d /= 9;
    lint ret = 0;
    for (int i = 1; i < 19; ++i) {
        lint t    = d;
        lint temp = 1;
        lint coef = 0;
        lint ten  = 1;
        for (int j = 0; j < i - 1; ++j) {
            coef += ten;
            ten *= 10;
        }
        for (int j = 0; j < i / 2; ++j) {
            lint tot = t % (10);
            if (j == 0)
                temp *= (9 - tot);
            else
                temp *= (10 - tot);
            t -= coef * tot;
            if (t < 0)
                t = -t;
            t /= 10;
            coef /= 100;
        }
        if (i % 2 == 1)
            temp *= 10; // 12?12, 0-9
        if (t == 0)
            ret += temp;
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<map>
#include<vector>
#include <bitset>
#include<math.h>
#include<queue>
using namespace std;
#define MAX 300000
#define INF 2000000000
typedef long long ll;
typedef pair<int,int> P;

int A[26],B[26];

int main(){
  int N,ans=0,sum=0;
  string S;
  cin>>N>>S;

  for(int i=0;i<N;i++,sum=0){
    for(int j=0;j<N;j++){
      if(j<=i) A[S[j]-'a']++;
      else B[S[j]-'a']++;
    }
    for(int j=0;j<26;j++){
      if(A[j]>0 && B[j]>0) sum++;
    }
    ans=max(ans,sum);
    for(int j=0;j<26;j++){
      A[j]=B[j]=0;
    }
  }
  cout<<ans<<endl;
}


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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
using Graph = vector<vector<int>>;

int main(){
    int a,b;cin>>a>>b;
    int res = 0;
    rep1(i,9){
        rep(j,10){
            rep(k,10){
                ll tmp = i*10001+j*1010+k*100;
                if(a<=tmp&&tmp<=b)res++;
            }
        }
    }
    cout<<res<<endl;
}

Measured memory_bytes: 3604
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vvint ad(n,vint(n,0));
    REP(i,n){
        string s;
        cin >> s;
        REP(j,n){
            ad[i][j]=s[j]-'0';
        }
    }
    int ans = -1;
    REP(i,n){
        stack<int> st1;
        st1.push(i);
        stack<int> st2;
        bool f = true;
        int tmp = 1;
        vint gp(n,-1);
        gp[i]=0;
        while(!st1.empty()){
            while(!st1.empty()){
                int now = st1.top();
                st1.pop();
                REP(j,n){
                    if(ad[now][j]==1){
                        if(gp[j]==-1){
                            gp[j]=gp[now]+1;
                            st2.push(j);
                            tmp = max(tmp,gp[j]+1);
                        }else if(gp[j]==gp[now]){
                            f = false;
                            break;
                        }
                    }
                }
            }
            if(!f) break;
            while(!st2.empty()){
                int next = st2.top();
                st2.pop();
                st1.push(next);
            }
        }
        if(f) ans = max(ans,tmp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) < (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007LL
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589


#define izryt bool
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}
pll Dir[8] = { //移動
	{ 0 ,1 },{ -1 ,0 },{ 1 ,0 },{ 0 ,-1 },
	{ 1 ,1 },{ 1 ,-1 },{ -1 ,1 },{ -1 ,-1 }
};

//[a, b)
#define Getsum(ar, a,b) (ar[b] - ar[a])
#define INF 10000000000000000LL

struct Edge {
	int from, to;
	ll w;
};
typedef vector<vector<Edge>> Graph;

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

signed main(void) {
	int a, b;

	cin >> a >> b;

	a--, b--;
	printf("100 100\n");
	REP(i, 50) {
		REP(j, 100) {
			if (i % 2 == 0 && j % 2 == 0) {
				if (b) {
					printf("#");
					b--;
				}
				else
					printf(".");
			}
			else
				printf(".");
		}
		printf("\n");
	}
	REP(i, 50) {
		REP(j, 100) {
			if (i % 2 && j % 2) {
				if (a) {
					printf(".");
					a--;
				}
				else
					printf("#");
			}
			else
				printf("#");
		}
		printf("\n");
	}

	return 0;
}



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

int main(){
  int k,x;
  int ans;
  cin >> k >> x;
  for(int i=-(k-1);i<k;i++){
    ans = x + i;
    if(ans<=1000000&&ans>=-1000000){
     cout << ans << " ";
    }else{
     continue; 
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int main() {
  int A, B;
  string S;
  cin >> A >> B >> S;
  int co = 0;
  rep(i, A + B + 1) {
    if(i == A) {
      if(S.at(i) == '-') {
        co++;
      }
    }
    else {
      if(S.at(i) != '-') {
        co++;
      }
    }
  }
  if(co == A + B + 1) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

const int mod = 1000000007;

template<int Modulus>
struct modint {
    ll x; // typedef long long ll;
    modint(ll x=0):x((x%mod+mod)%mod){}
    modint operator-() const { return modint(-x);}
    modint& operator+=(const modint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    modint& operator-=(const modint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    modint& operator*=(const modint a) { (x *= a.x) %= mod; return *this;}
    modint operator+(const modint a) const { return modint(*this) += a;}
    modint operator-(const modint a) const { return modint(*this) -= a;}
    modint operator*(const modint a) const { return modint(*this) *= a;}
    modint pow(ll t) const {
        if (!t) return 1;
        modint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    modint inv() const { return pow(mod-2);}
    modint& operator/=(const modint a) { return *this *= a.inv();}
    modint operator/(const modint a) const { return modint(*this) /= a;}
};
template<int Modulus>
istream& operator>>(istream& is, modint<Modulus>& a) { return is >> a.x;}
template<int Modulus>
ostream& operator<<(ostream& os, const modint<Modulus>& a) { return os << a.x;}

using mint = modint<mod>;

const int MX = 2e5;

ll power(ll x,ll y,ll p){
    ll res=1;
    x=x%p;
    while(y){
        if(y&1)res=(res*x)%p;
        y=y>>1;
        x=(x*x)%p;
    }
    return res;
}

ll modInverse(ll n, ll p){
    return power(n,p-2,p);
}

ll fac[MX+5];
void init(ll mod){
    fac[0] = 1;
    for (int i=1 ; i<=MX; i++)
        fac[i] = fac[i-1]*i%mod;
}

ll C(ll n,ll r,ll p){
    if (r==0)return 1;
    assert(r <= n);
    assert(0 < r);
    return (fac[n] * modInverse(fac[r], p) % p * modInverse(fac[n - r], p) %
            p) %
           p;
}

ll H(ll n,ll r,ll p){
    if(n<1||r<0)return 0;
    return C(n+r-1,r,p);
}

int main() {
    ll s;
    cin >> s;
    ll t = s / 3;
    // sum[k=1 ~ t] P(n-3k, k)
    // P(n, k) = P(n, k-1) + P(n-k, k)

    init(mod);
    mint res = 0;
    //for (int k = 1; k <= t; ++k) res += C((s - 3 * k) + k - 1, k - 1, mod);
    for (int k = 1; k <= t; ++k) res += C(s - 2 * k - 1, k - 1, mod);
    cout << res << endl;
}

Measured memory_bytes: 5168
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O0")
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define Rep(i,a,n) for (ll i = (a); i < (n); ++i)
const ll mod = 1e9+7;
const ll INF = 1e18;
#define All(a) (a).begin(),(a).end()
#define Pi acos(-1)
using Graph = vector<vector<ll>>;
using V = vector<ll>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  chrono::system_clock::time_point start,end;
  start = chrono::system_clock::now();

  ll n, m, x;
  cin >> n >> m >> x;
  Graph a(n, vector<ll>(m+1));
  rep(i,n) {
    rep(j,m+1) {
      cin >> a[i][j];
    }
  }
  ll ans = INF;
  for (ll bit = 0; bit < (1<<n); ++bit) {
    V q(m+1);
    for (ll i = 0; i < n; ++i) {
      if (bit & (1<<i)) { 
        rep(j,m+1) {
          q[j] += a[i][j];
        }

      }
    }
    Rep(j,1,m+1) {
      if (q[j] < x) {
        goto pp;
      }
    }
    ans = min(q[0],ans);
    pp:;
  }
  if (ans == INF) ans = -1;
  cout << ans << '\n';

  end = chrono::system_clock::now();
  auto elapsed = chrono::duration_cast< chrono::milliseconds >(end - start).count();
  cerr << elapsed << "ms" << '\n';
}

Measured memory_bytes: 3632
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>

#define PLANE (-1)
#define HOUSE (1)
#define CHURCH (100)

using namespace std;

int x, y;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
int home[10][10];
int n;
map<int, int> memo[24];

int goChurch(int ty, int tx)
{
    int i;
    int my, mx;
    for (i = 0; i < 4; i++){
        my = ty + dy[i];
        mx = tx + dx[i];
        while (0 <= my && my < y && 0 <= mx && mx < x){
            if (home[my][mx] == CHURCH){
                return (1);
            }
            my += dy[i];
            mx += dx[i];
        }
    }
    return (0);
}

int dfs(int v, int bit, int ty, int tx, char state[][11])
{
    int i;
    int ky, kx;
    int ans;
    
    if (memo[v].find(bit) != memo[v].end()){
        return (memo[v][bit]);
    }
    
    if (bit == (1 << n) - 1){
        if (__builtin_popcount(bit) < 19){
            return (memo[v][bit] = goChurch(ty, tx));
        }
        return (goChurch(ty, tx));
    }
    
    ans = 0;
    
    for (i = 0; i < 4; i++){
		kx = tx + dx[i];
        ky = ty + dy[i];
        //ツ逆ツ渉づ可プツδ個ゼツδ督トツづーツ置ツつ「ツづつ「ツつュ
		while (0 <= kx && kx < x && 0 <= ky && ky < y && (home[ky][kx] == PLANE || home[ky][kx] == CHURCH || state[ky][kx] == 1)){
			ky += dy[i];
            kx += dx[i];
		}
		if (0 <= kx && kx < x && 0 <= ky && ky < y){
			state[ky][kx] = 1;
			ans += dfs(home[ky][kx] , bit | (1 << home[ky][kx]) , ky, kx, state);
			state[ky][kx] = 0;
		}
	}
    
    if (__builtin_popcount(bit) < 19){
        memo[v][bit] = ans;
    }
	return (ans);
}


int main(void)
{
    int sy, sx;
    int i, j;
    char state[10][11];
    
    while (1){
        scanf("%d%d", &x, &y);
        
        if (x + y == 0){
            break;
        }
        n = 0;
        for (i = 0; i < y; i++){
            for (j = 0; j < x; j++){
                scanf("%d", &home[i][j]);
                if (home[i][j] == 2){
                    home[i][j] = CHURCH;
                    sy = i;
                    sx = j;
                }
                else if (home[i][j] == HOUSE){
                    home[i][j] = n++;
                }
                else if (home[i][j] == 0){
                    home[i][j] = PLANE;
                }
            }
        }
        memset(state, 0, sizeof(state));
        for (i = 0; i < 24; i++){
            memo[i].clear();
        }
        printf("%d\n", dfs(n, 0, sy, sx, state));
    }
    
    return (0);
}

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

int main()
{
	string s;
	cin >> s;
	string last = "";
	string cur = "";
	int cnt = 0;
	for (int i = 0; i < s.length(); ++i)
	{
		cur += s[i];
		if (cur != last)
		{
			last = cur;
			cur = "";
			cnt++;
		}
	}
	cout << cnt << endl;
}

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

int main() {
	int A, B;
	int i, j;
	int a_cnt = 1;
	int b_cnt = 1;
	cin >> A >> B;
	int K = 50;
	int S[100][100];
	for(i = 0; i < K; i++){
		for(j = 0; j < 2 * K ; j++){
			S[i][j] = 1;
			S[i + 50][j] = 0;
		}
	}
	for(i = 1; i < 2 * K - 1; i = i + 2){
		for(j = 1; j < 2 * K - 1; j = j + 2){
			if(a_cnt == A) break;
			S[i][j] = 0;
			a_cnt++;
		}
		for(j = 1; j < 2 * K - 1; j = j + 2){
			if(b_cnt == B) break;
			S[i + 50][j] = 1;
			b_cnt++;
		}
	}
	cout << 2 * K << " " << 2 * K << endl;
	for(i = 0; i < 2 * K; i++){
		for(j = 0; j < 2 * K; j++){
			if(S[i][j] == 0) cout << ".";
			else cout << "#";
		}
		cout << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
from collections import deque
import sys
readline = sys.stdin.readline
write = sys.stdout.write

def rotate(nd, d):
    c = nd[d]
    if d:
        nd[1] = c[0]
        c[0] = nd
    else:
        nd[0] = c[1]
        c[1] = nd
    return c


root = None
def insert(val, pri):
    global root
    st = []
    dr = []
    x = root
    while x:
        st.append(x)
        if x[2] == val:
            return
        d = (x[2] < val)
        dr.append(d)
        x = x[d]
    nd = [None, None, val, pri]
    while st:
        x = st.pop(); d = dr.pop()
        c = x[d] = nd
        if x[3] >= c[3]:
            break
        rotate(x, d)
    else:
        root = nd

def __delete(nd):
    st = []; dr = []
    while nd[0] or nd[1]:
        l = nd[0]; r = nd[1]
        d = (l[3] <= r[3]) if l and r else (l is None)
        st.append(rotate(nd, d))
        dr.append(d ^ 1)
    nd = x = None
    while st:
        nd = x; x = st.pop(); d = dr.pop()
        x[d] = nd
    return x

def delete(val):
    global root
    x = root

    y = None
    while x:
        if val == x[2]:
            break
        y = x; d = (x[2] < val)
        x = x[d]
    else:
        return

    if y:
        y[d] = __delete(x)
    else:
        root = __delete(x)

def find(val):
    x = root
    while x:
        if val == x[2]:
            return 1
        x = x[x[2] < val]
    return 0

def debug():
    s0 = [""]
    s1 = [""]

    def dfs(nd):
        v = str(nd[2])
        s0.append(v)
        if nd[0]:
            dfs(nd[0])
        s1.append(v)
        if nd[1]:
            dfs(nd[1])
    dfs(root)
    return " ".join(s1), " ".join(s0)


M = int(readline())
ans = []
for m in range(M):
    cmd, *V, = readline().split()
    if cmd == "print":
        ans.extend(debug())
    elif cmd == "find":
        ans.append("yes" if find(int(V[0])) else "no")
    elif cmd == "delete":
        delete(int(V[0]))
    else:
        val, pri = map(int, V)
        insert(val, pri)
write("\n".join(ans))
write("\n")



Measured memory_bytes: 65688
// ABC062B - 

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

typedef unsigned long long int ull;
typedef long long int ll;

int main() {
	int H, W;
	cin >> H >> W;
	string s[H];
	for (int i = 0; i < H; i++) {
		cin >> s[i];
	}

	for (int i = 0; i < W + 2; i++) {
		cout << "#";
	}
	cout << endl;

	for (int i = 0; i < H; i++) {
		cout << "#" << s[i] << "#" << endl;
	}

	for (int i = 0; i < W + 2; i++) {
		cout << "#";
	}
	cout << endl;


	return 0;
}


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

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;

const ll MOD = 1000000007;

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

  int N;
  cin >> N;

  vector<vector<int> > level(N, vector<int>(N, 0));
  int security = 1;
  bool updated = true;
  while(updated) {
    updated = false;
    vector<int> color(N, -1);
    for (int i = 0; i < N; i++) {
      for (int j = i+1; j < N; j++) {
        if (level[i][j] == 0 && ((color[i] == color[j] && color[i] == -1) || color[i] != color[j])) {
          updated = true;
          if (color[i] == 0) {
            color[j] = 1;
          }
          else {
            color[i] = 1;
            color[j] = 0;
          }
          level[i][j] = security;
          level[j][i] = security;
          stack<Pii> st;
          for (int k = 0; k < N; k++) {
            if (j != k) st.emplace(j, k);
          }
          while (!st.empty()) {
            auto now = st.top();
            st.pop();
            if (color[now.first] == color[now.second]) continue;
            if (level[now.first][now.second] != 0) continue;
            level[now.first][now.second] = security;
            level[now.second][now.first] = security;
            if (color[now.second] == -1) {
              if (color[now.first] == 0) color[now.second] = 1;
              else color[now.second] = 0;
              for (int k = 0; k < N; k++) {
                if (now.second != k) st.emplace(now.second, k);
              }
            }
          }
        }
      }
    }
    security++;
  }

  for (int i = 0; i < N-1; i++) {
    for (int j = i+1; j < N; j++) {
      cout << level[i][j];
      if (j < N-1) cout << " ";
      else cout << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 2304
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let h: usize = iterator.next().unwrap().parse().unwrap();
    let w: usize = iterator.next().unwrap().parse().unwrap();
    let mut map: Vec<Vec<char>> = vec![vec!['.'; w + 2]; h + 2];
    for i in 0..h {
        let line: Vec<char> = iterator.next().unwrap().chars().collect();
        for j in 0..w {
            map[i + 1][j + 1] = line[j];
        }
    }

    let mut possible: bool = true;
    let mut x = 1;
    let mut y = 1;
    let mut d = Direction::RIGHT;
    while !(x == w && y == h) {
        if d == Direction::RIGHT && map[y - 1][x] == '#' {
            possible = false;
            break;
        }
        if d == Direction::DOWN && map[y][x - 1] == '#' {
            possible = false;
            break;
        }

        if map[y][x + 1] == '#' && map[y + 1][x] == '#' {
            possible = false;
            break;
        }
        if map[y][x + 1] == '#' {
            d = Direction::RIGHT;
            x += 1;
            continue;
        }
        if map[y + 1][x] == '#' {
            d = Direction::DOWN;
            y += 1;
            continue;
        }
        possible = false;
        break;
    }

    if d == Direction::RIGHT && map[y - 1][x] == '#' {
        possible = false;
    }
    if d == Direction::DOWN && map[y][x - 1] == '#' {
        possible = false;
    }

    return if possible {
        String::from("Possible")
    } else {
        String::from("Impossible")
    };
}

#[derive(PartialEq)]
enum Direction {
    RIGHT, DOWN,
}


Measured memory_bytes: 4352
// ARC097A.cpp
#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 5000;

int n, k;
string str;

int main()
{
    cin >> str >> k;
    vector<string> vec;
    for (int i = 0; i < str.length(); i++)
        for (int j = 1; j <= min(k, int(str.length() - i)); j++)
            vec.push_back(str.substr(i, j));
    sort(vec.begin(), vec.end()), vec.erase(unique(vec.begin(), vec.end()), vec.end());
    cout << vec[k - 1] << endl;
    return 0;
}

Measured memory_bytes: 1660
use strict;
my $s = <STDIN>;
my ($N,$k) = split(/ /,$s);
chomp($k);
$s = <STDIN>;
my @dat = split(/ /,$s);
my %data;
my $sum = 0;
for(my $i=0;$i<=$#dat;$i++){
  if( ! defined($data{$dat[$i]})){
    $data{$dat[$i]} = 1;
  }else{
    $data{$dat[$i]}++;
  }
}
my $count =0;
foreach my $key (sort {$b <=> $a} keys%data){
  #print "$key $count $sum $k $data{$key}\n";
  if( $count < $k ){
    if( ($count + $data{$key}) < $k ){
      $count = $count +  $data{$key};
      next;
    }else{
      $sum = $sum + ($key * ($count + $data{$key} -$k ));
      $count = $count +  $data{$key};
  }
  }else{
    $sum = $sum + ($key * $data{$key});
  }
}
print "$sum\n";


Measured memory_bytes: 63084
import numpy as np

k, q = map(int, input().split())
d = np.array(input().split(), np.int64)
nxm = [map(int, input().split()) for _ in range(q)]

for n, x, m in nxm:
    dd = d % m

    ans = n - 1
    divq, divr = divmod(n - 1, k)

    dd_r = dd[:divr]

    ans -= (k - np.count_nonzero(dd)) * divq
    ans -= divr - np.count_nonzero(dd_r)

    last = x + np.sum(dd) * divq + np.sum(dd_r)
    ans -= last // m - x // m

    print(ans)


Measured memory_bytes: 20796
#include <stdio.h>

int main(int argc, const char * argv[])
{
    double a[3], b[3];
    double x = 0, y = 0;
    double fa[2], fb[2];
    
    while (scanf("%lf %lf %lf %lf %lf %lf", &a[0], &a[1], &a[2], &b[0], &b[1], &b[2]) != EOF) {
        fa[0] = a[1] * b[0];
        fa[1] = a[2] * b[0];
        fb[0] = b[1] * a[0];
        fb[1] = b[2] * a[0];
        y = (fa[1] - fb[1]) / (fa[0] - fb[0]);
        x = (a[2] - a[1] * y) / a[0];
        printf("%0.3f %0.3f\n", x, y);
        
    }
    return 0;
}

Measured memory_bytes: 652
def comp(X, Y):
    if X == Y:
        ret = 0
    elif X < Y:
        ret = 1
    else:
        ret = 2

    return ret


N = int(input())
A = list(map(int, input().split()))

div_Count = 1
current_mode = 0

for i in range(N-1):
    current_comp = comp(A[i], A[i+1])

    if current_mode == 0:
        current_mode = current_comp
    else:
        if current_mode == 0 or current_comp == 0:
            pass
        elif current_mode != current_comp:
            div_Count += 1
            current_mode = 0
        else:
            pass

print(div_Count)

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

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

using namespace std;


int main(int argc, const char * argv[]) {
    // source code
    int n ;
    cin >> n;
    vector<int> a(n);
    rep(i, n) {
        int t;
        cin >> t;
        a[t - 1] = i + 1;
    }
    rep (i, n) cout << a[i] << " ";
    
    return 0;
}


Measured memory_bytes: 1152
count = 0       #初期値を0とするcount変数を作る.
n,k = map(int,input().split())      #整数とn進数を入力する。

while n > 0:         #nをkで割った商が0になるまでcountに1を足し続ける。
    count += 1
    n //= k

print(count)

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

int main(){
    int N, K;
    string S;

    cin >> N >> K;
    cin >> S;

    if(S[K-1] == 'A'){
        S[K-1] = 'a';
    }
    if(S[K-1] == 'B'){
        S[K-1] = 'b';
    }
    if(S[K-1] == 'C'){
        S[K-1] = 'c';
    }
    cout << S << endl;
    return 0;
}

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

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

ll lcm(ll a,ll b){
    return a/gcd(a,b)*b;
}
int main(){
    ll n;
    cin >> n;
    vector<ll> t(n);
    for(ll i=0;i<n;i++){
        cin >> t[i];
    }
    ll ans=1;
    for(ll i=0;i<n;i++){
        ans = lcm(t[i],ans);
    }
    cout << ans << endl;

}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll> 
#define P pair<ll,ll>
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll ab,bc,ca;cin>>ab>>bc>>ca;
  const ll ans=ab*bc/2;
  print(ans);
  return 0;
}

Measured memory_bytes: 256
N=int(input())
if N==1:
  print(1)
elif 2<=N<4:
  print(2)
elif 4<=N<8:
  print(4)
elif 8<=N<16:
  print(8)
elif 16<=N<32:
  print(16)
elif 32<=N<64:
  print(32)
else:
  print(64)


Measured memory_bytes: 2940
class Dice:
    def __init__(self):
        self.face = {12:3, 13:5, 14:2, 15:4, 21:4, 23:1, 24:6, 26:3, 31:2, 32:6, 35:1, 36:5, 41:5, 42:1, 45:6, 46:2, 51:3, 53:6, 54:1, 56:4, 62:4, 63:2, 64:5, 65:3}
    
    def right_face(self, face):
        return self.face[face]

d = Dice()
dice = [dice for dice in input().split()]
q = int(input())
for i in range(q):
    face_up, face_front = input().split()
    face_up = dice.index(face_up)
    face_front = dice.index(face_front)
    face = str(face_up+1) + str(face_front+1)
    face = int(face)
    n = d.right_face(face)
    print(dice[n-1])
    

Measured memory_bytes: 7712
def news(moji, kaz):
    kazz=['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l']
    kotae=[]
    for i in range(kaz):
        kotae.append([moji+kazz[i], kaz])
    kotae.append([moji+kazz[kaz], kaz+1])
    return kotae

n=int(input())
now=[['a', 1]]
for i in range(n-1):
    new=[]
    for nw in now:
        new+=news(nw[0], nw[1])
    now=new
lenw=len(now)
for i in range(lenw):
    print(now[i][0])

Measured memory_bytes: 73052
main = do
    a <- getLine
    b <- getLine
    putStrLn $ solve a b

solve a b | la > lb = "GREATER"
          | la < lb = "LESS"
          | la == lb = solve' a b
      where la = length a
            lb = length b

solve' [] [] = "EQUAL"
solve' (a : as) (b : bs) | a == b = solve' as bs
                         | a > b = "GREATER"
                         | a < b = "LESS"

Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
long long ans, n, sol[10000001];
int main (){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n; ans++;
for (long long i=2; i<=n; i++){
	for (long long j=2*i; j<=n; j+=i)
		sol[j]+=1;
	ans+=i*(sol[i]+2LL);
} cout << ans;
return 0;
}


Measured memory_bytes: 81768
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
	string X;
	cin >> X;
	if (X == "RSS") { cout << 1; }
	if (X == "RSR") { cout << 1; }
	if (X == "RRS") { cout << 2; }
	if (X == "RRR") { cout << 3; }
	if (X == "SSS") { cout << 0; }
	if (X == "SSR") { cout << 1; }
	if (X == "SRS") { cout << 1; }
	if (X == "SRR") { cout << 2; }
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<int> h(n);
    for (int i = 0; i < n; ++i) {
        cin >> h[i];
    }
    vector<int> dp(n);
    for (int i = 1; i < n; ++i) {
        dp[i] = dp[i - 1] + abs(h[i - 1] - h[i]);
        if (i != 1) {
            dp[i] = min(dp[i], dp[i - 2] + abs(h[i - 2] - h[i]));
        }
    }
    cout << dp.back() << '\n';
    return 0;
}

Measured memory_bytes: 3972
/*氏名：保坂優介, 学籍番号：200441141
  概要：二つの数の大小を判別する*/

#include<stdio.h>

int main(void)
{
    int a, b;       //変数の宣言

    scanf("%d %d", &a, &b);     //入力

    if (a < b)      //a<bの場合
    {
        printf("a < b\n");      //出力
    }

    if (a > b)      //a>bの場合
    {
        printf("a > b\n");      //出力
    }

    if (a == b)     //a=bの場合
    {
        printf("a == b\n");      //出力
    }

    return 0;
}


Measured memory_bytes: 2096
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx")

#include <bits/stdc++.h>   
#include <stdio.h>    
 
using namespace std;
     
#define F first
#define S second
#define lb lower_bound               
#define ub upper_bound
#define pb push_back
#define pf push_front    
#define ppb pop_back
#define mp make_pair
#define bpp __builtin_popcountll                                                                                        
#define sqr(x) ((x) * (x)) 
#define al 0x3F3F3F3F
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define in insert
#define ppf pop_front
#define endl '\n'
#define int long long
 
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
 
const int mod = (int)1e9 + 7;
const int N = (int)2e5 + 123;
const ll inf = (ll)3e18 + 1;

const double pi = acos (-1.0);
const double eps = 1e-10;
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

int n;
ld x[N], y[N];
char d[N];

inline ld f (ld c) {
   ld mx_x = -inf, mx_y = -inf, mn_x = inf, mn_y = inf;
   for (int i = 1; i <= n; i ++) {
      if (d[i] == 'D') {
         ld val = y[i] - c;
         mx_y = max (mx_y, val);
         mn_y = min (mn_y, val);
         mx_x = max (mx_x, x[i]);
         mn_x = min (mn_x, x[i]);
      }  
      if (d[i] == 'U') {
         ld val = y[i] + c;
         mx_y = max (mx_y, val);
         mn_y = min (mn_y, val);
         mx_x = max (mx_x, x[i]);
         mn_x = min (mn_x, x[i]);
      }
      if (d[i] == 'R') {
         ld val = x[i] + c;
         mx_x = max (mx_x, val);
         mn_x = min (mn_x, val);
         mx_y = max (mx_y, y[i]);
         mn_y = min (mn_y, y[i]);
      }
      if (d[i] == 'L') {
         ld val = x[i] - c;
         mx_x = max (mx_x, val);
         mn_x = min (mn_x, val);
         mx_y = max (mx_y, y[i]);
         mn_y = min (mn_y, y[i]);
      }
   }
   return (mx_x - mn_x) * (mx_y - mn_y);}

inline void boost () {                    
   ios_base :: sync_with_stdio (NULL);
   cin.tie (NULL), cout.tie (NULL);          
}                                                     

inline void Solve () {
   cin >> n;
   for (int i = 1; i <= n; i ++) cin >> x[i] >> y[i] >> d[i];
   ld l = 0.0, r = 100000000.0;
   ld ans;
   for (int it = 0; it <= 400; it ++) {
      ld h = (r - l) / 3.0;
      ld m1 = l + h;
      ld m2 = r - h; 
      ld M1 = f (m1), M2 = f (m2);
      if (M1 < M2) r = m2, ans = M1;
      else l = m1, ans = M2;
   }
   cout << fixed << setprecision (9) << ans;
}                                     

main () {                                       
// freopen (".in", "r", stdin);    
// frexopen (".out", "w", stdout);              
   boost ();
   int tt = 1;
// cin >> tt;   
   while (tt --) {
      Solve ();
   }                                               
   return 0;      
}


Measured memory_bytes: 6016
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
ll n;
ll x[20];
ll y[20];
ll p[20];

vector<vector<ll>> ab(ll* xy){
    vector<vector<ll>> a(n,vector<ll>(1<<n,INF));
    for(ll bit=0;bit<(1<<n);bit++){
        vector<ll> xx;
        rep(i,n){
            if(bit>>i&1){
                xx.push_back(xy[i]);
            }
        }

        rep(i,n){
            rep(j,xx.size()){
                a[i][bit] = min(a[i][bit],abs(xy[i]-xx[j]));
            }
        }
    }
    return a;
}

int main(){
    cin >> n;
    rep(i,n) cin >> x[i] >> y[i] >> p[i];
    vector<vector<ll>> a = ab(x);
    vector<vector<ll>> b = ab(y);

    /*
    rep(i,n){
        rep(j,1<<n) cout << b[i][j] << " ";
        cout << endl;
    }
    */


    ll mask = 1;
    rep(i,n) mask *= 3;
    vector<ll> ans(n+1,LINF);

    for(ll bit=0;bit<mask;bit++){
        ll res = 0;
        ll xx = 0;
        ll yy = 0;
        vector<ll> own;

        ll tmp = bit;
        rep(i,n){
            if(tmp%3==0) own.push_back(i);
            else if(tmp%3==1) xx += (1<<i); 
            else if(tmp%3==2) yy += (1<<i); 
            tmp /= 3;
        }

        for(ll i:own){
            res += p[i] * min({abs(x[i]),abs(y[i]),a[i][xx],b[i][yy]});
        }
        /*
        if(n-own.size()==1&&res==300){
            cout << "bit" << bit << endl;
            cout << xx << endl;
            cout << yy << endl;
            rep(i,own.size()) cout << own[i] << " ";
            cout << "onw" << endl;
        }
        */

        ans[n-own.size()] = min(ans[n-own.size()],res);
    }
    rep(i,n+1) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 11256
#include <stdio.h>

int main()
{
    int r, c, a[101][101] = {0};
    scanf("%d %d", &r, &c);
    for (int i = 0; i < r; i++)
    {
        for (int j = 0; j < c; j++)
        {
            scanf("%d", &a[i][j]);
        }
    }

    for (int i = 0; i < r; i++)
    {
        for (int j = 0; j < c; j++)
        {
            a[i][c] = a[i][c] + a[i][j];
            a[r][j] = a[r][j] + a[i][j];
        }
    }
    for (int i = 0; i < r; i++)
    {
        a[r][c] = a[r][c] + a[i][c];
    }

    for (int i = 0; i < r + 1; i++)
    {
        for (int j = 0; j < c + 1; j++)
        {
            if (j == 0)
            {
                printf("%d", a[i][j]);
            }
            else
            {
                printf(" %d", a[i][j]);
            }
        }
        printf("\n");
    }

    return 0;
}


Measured memory_bytes: 2044
#include <iostream>
#include <queue>
#include <map>
#include <cmath>
#include <algorithm>
#include <queue>
#include <cstdarg>
#include <set>

using namespace std;
#define INF 2e9 + 9
#define MOD 1000000007
#define ALL(v) v.begin() , v.end()
#define Int int64_t
#define pll pair<Int,Int>
template<class T> using pql = priority_queue<T, vector<T>>;
template<class T> using pq = priority_queue<T, vector<T>, greater<T>>;
#define ll(n) Int n; cin >> n;
#define LL(...) Int __VA_ARGS___; cin >> __VA_ARGS___;
#define OUT(...) cout << __VA_ARGS___;
#define RP(n, i, s) for(Int i = s ;i < n ;i++)
#define REP(n, i) for (Int i = 0; i < n; i++)
#define REPe(n, i) for (Int i = 1; i <= n; i++)
#define RPe(n, i, s) for (Int i = s; i <= n; i++)
#define upd_max(maxer, updater) if (maxer < updater) maxer = updater;

struct node {
    Int to;
    Int length;
};


vector<Int> divisor(Int n) {
    vector<Int> ret;
    for (Int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    return (ret);
}

/*
vector<vector<int>> to;
vector<int> flag;
vector<int> c;


Int dfs(int from, int mae) {
    flag[from] = 1;
    Int mini = 0;
    for (auto next : to[from]) {
        if (next == mae) continue;
        if (flag[next] == 1) {
            return -1;
        } else {
            mini = min(mini, dfs(next, from));
        }
    }
    return mini;
}*/

int dx8[8] = {0, -1, -1, -1, 0, 1, 1, 1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};



int main(void) {
    int a[3][3];
    int c[3][3] = {};
    REP(3,i){
        REP(3,k){
            cin >> a[i][k];
        }
    }
    Int n;
    cin >> n;
    REP(n,i){
        Int b;
        cin >> b;
        REP(3,x){
            REP(3,y){
                if (a[x][y] == b) c[x][y] = 1;
            }
        }
    }
    bool flag = false;
    REP(3,i){
        Int ans = 0;
        REP(3,k){
            ans += c[i][k];
        }
        if (ans == 3) flag = true;
    }
    REP(3,i){
        Int ans = 0;
        REP(3,k){
            ans += c[k][i];
        }
        if (ans == 3) flag = true;
    }

    if (c[0][0] + c[1][1] + c[2][2] == 3) flag = true;
    if (c[2][0] + c[1][1] + c[0][2] == 3) flag = true;
    if (flag) cout << "Yes" << endl; else cout << "No" << endl;

}

Measured memory_bytes: 256