akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define forn(low,high,i) for(i = low;i < high;i++)
#define forrev(high,low,i) for(i = high; i >= low;i--)
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define line cout << __LINE__;
#define prv(a) for(auto x : a) cout << x << ' ';cout << '\n';
#define prvp(a) for(auto x : a) cout << "{" << x.ff << ',' << x.ss << "}";cout << '\n';
#define decimal_digits cout << fixed << setprecision(15);
string to_string(string s) { return '"' + s + '"';}
string to_string(char s) { return string(1, s);}
string to_string(const char* s) { return to_string((string) s);}
string to_string(bool b) { return (b ? "true" : "false");}
template <typename A> string to_string(A);
template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}
template <typename A> string to_string(A v) {bool f = 1; string r = "{"; for (const auto &x : v) {if (!f)r += ", "; f = 0; r += to_string(x);} return r + "}";}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {cerr << " " << to_string(H); debug_out(T...);}
#define pr(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

typedef unordered_map<int,int> umi;
typedef unordered_map<ll,ll> uml;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

const int inf = 1e9;
const ll INF = 1e18;
const int mod = 1e9 + 7;
const int bit32 = log2(inf) + 3;
const int bit64 = log2(INF) + 3;

inline int add(int a, int b){a += b; if(a >= mod) a -= mod; return a;}
inline int sub(int a, int b){a -= b; if(a < 0) a += mod; return a;}
inline int mul(int a, int b){return (int)((long long) a * b % mod);}
inline int modexpo(int a, int b){int res = 1; while(b > 0){ if(b & 1) res = mul(res, a); a = mul(a, a); b /= 2;} return res;}
inline int divide(int a, int b){ return mul(a, modexpo(b, mod - 2));}

clock_t time_p = clock();

void ktj(){
  time_p = clock() - time_p;
  cerr << "Time elapsed : " << (float)(time_p)/CLOCKS_PER_SEC << "\n";
}

void pre(){ // Reset each global variable (esp. for graphs)
  
}

void solve(){
  int n, m;
  cin >> n >> m;
  if(n == m){
    cout << "Yes\n"; 
  }else{
    cout << "No\n";
  }
}

int main(){
  fastio

  pre();

  int t = 1;
  // cin >> t;
  while(t--){
    solve();
  }

  ktj();
}


Measured memory_bytes: 256
local n, k = io.read("*n", "*n")
local w, d = {}, {}
for i = 1, n do
  w[i], d[i] = io.read("*n", "*n")
end
local min, max = 0, 2
for i = 1, 6 do
  max = max * 1000
end

local function solve(x)
  local c = 0
  for i = 1, n do
    if w[i] <= x then
      c = c + (x - w[i]) // d[i] + 1
    end
  end
  return k <= c
end
if solve(min) then
  print(min)
else
  while 1 < max - min do
    local mid = (min + max) // 2
    if solve(mid) then
      max = mid
    else
      min = mid
    end
  end
  print(max)
end


Measured memory_bytes: 4444
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

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

    int ans = 0;
    if (1 < N) {
        int tmp = (N * (N-1)) / 2;
        ans += tmp;
    }

    if (1 < M) {
        int tmp = (M * (M-1)) / 2;
        ans += tmp;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

constexpr int mod = 1000000007;
struct ModCalc {
    vector<int> fact;
    ModCalc(int N) : fact(N + 1) {
        fact[0] = 1;
        rep(i, N) fact[i + 1] = (long long)(i + 1) * fact[i] % mod;
    }
    int ModPow(int x, int y) {
        if (y == 0) return 1;
        long long a = ModPow(x, y / 2);
        if (y & 1) return a * a % mod * x % mod;
        else return a * a % mod;
    }
    int ModCom(int x, int y) {
        if (x < y) return 0;
        int res = fact[x];
        res = (long long)ModPow(fact[y], mod - 2) * res % mod;
        res = (long long)ModPow(fact[x - y], mod - 2) * res % mod;
        return res;
    }
};

int main() {
    int r1, r2, c1, c2;
    cin >> r1 >> c1 >> r2 >> c2;
    
    ModCalc MC(10000000);
    int sum1 = 0, sum2 = 0;
    for (int i = c1 + 1; i <= c2 + 1; ++i) {
        sum1 += MC.ModCom(r2 + i, i);
        sum1 %= mod;
        sum2 += MC.ModCom(r1 - 1 + i, i);
        sum2 %= mod;
    }
    int ans = sum1 - sum2;
    if (ans < 0) ans += mod;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 39296
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;

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

	int n = N;
	int S = 0;

	while (n) {
		S += n % 10;
		n /= 10;
	}

	if (N % S) cout << "No" << endl;
	else cout << "Yes" << endl;
}

Measured memory_bytes: 3600
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt(),m=sc.nextInt();
		int[][] A = new int[n][m];
		int[][] B= new int[m][1];

		for(int i=0;i<n;i++) {
			for(int j=0;j<m;j++) {
				A[i][j]=sc.nextInt();
			}
		}

		for(int i=0;i<m;i++) {
			B[i][0]=sc.nextInt();
		}

		for(int i=0;i<n;i++) {
			int ans =0;
			for(int j=0; j<m;j++) {
				ans += A[i][j]*B[j][0];
			}
			System.out.println(ans);
		}
	}
}


Measured memory_bytes: 40312
N=int(input())
*A,=map(int, input().split())

def check(si,xi):
    X = [-1] * N
    X[si] = xi
    for i in range(N-1):
        ci = (si+i+1)%N-1
        X[ci+1] = 2*A[ci] - X[ci]
    if X[si] == 2*A[si-1] - X[si-1]:
        return X
    return [2*A[si-1] - X[si-1]]

mm = 10**10
mi = -1
for i,a in enumerate(A):
    if a < mm:
        mm = a
        mi = i

xi = 0
while xi <= 2*mm:
    X = check(mi, xi)
    if len(X) == N:
        print(*X)
        exit()
    xi = (xi + X[0]) // 2

Measured memory_bytes: 14032
#include<stack>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
char list[255];
int main()
{
	list['A'] = 'T';
	list['T'] = 'A';
	list['C'] = 'G';
	list['G'] = 'C';
	char c;
	cin >> c;
	cout << list[c] << endl;
	
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
const int MOD = (int)1e9 + 7;


//---------------------------------------------------------------
template<int MOD> struct ModInt { int x;
    explicit operator bool() const { return !!x; }
    ModInt(int v = 0) : x(v % MOD) { if (x < 0) x += MOD; }
    ModInt(long long v) : x(v % MOD) { if (x < 0) x += MOD; }
    ModInt &operator+=(const ModInt &r) { if ((x += r.x) >= MOD) x -= MOD; return *this; }
    ModInt &operator-=(const ModInt &r) { if ((x += MOD - r.x) >= MOD) x -= MOD; return *this; }
    ModInt &operator*=(const ModInt &r) { x = 1LL * x * r.x % MOD; return *this; }
    ModInt &operator/=(const ModInt &r) { return *this *= r.inv(); }
    ModInt operator-() const { return x ? ModInt(MOD - x) : ModInt(x); }
    ModInt operator+(const ModInt &r) const { return ModInt(*this) += r; }
    ModInt operator-(const ModInt &r) const { return ModInt(*this) -= r; }
    ModInt operator*(const ModInt &r) const { return ModInt(*this) *= r; }
    ModInt operator/(const ModInt &r) const { return ModInt(*this) /= r; }
    ModInt inv() const { long long a = x, b = MOD, u = 1, v = 0;
        while (b) { long long t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); }
        return ModInt(u); } // x.pow(MOD-2)
    ModInt pow(long long k) const { ModInt r(1), a(x);
        while (k) { if (k & 1) r *= a; a *= a; k >>= 1; } return r; }
    bool operator==(const ModInt r) const { return x == r.x; }
    bool operator!=(const ModInt r) const { return x != r.x; }
    bool operator< (const ModInt r) const { return x <  r.x; }
    friend ostream& operator<<(ostream &os, const ModInt<MOD>& a) { return os << a.x; }
    friend istream& operator>>(istream &is, ModInt<MOD>& a) { return is >> a.x; }
};
template<typename T, int SZ> struct Comb { vector<T> _fac, _ifac, _inv;
    Comb() : _fac(SZ + 1), _ifac(SZ + 1), _inv(SZ + 1) {
        _fac[0] = _ifac[SZ] = _inv[0] = 1;
        for (int i = 1; i <= SZ; i++) _fac[i] = _fac[i - 1] * i;
        _ifac[SZ] /= _fac[SZ];
        for (int i = SZ - 1; i >= 0; i--) _ifac[i] = _ifac[i + 1] * (i + 1);
        for (int i = 1; i <= SZ; i++) _inv[i] = _ifac[i] * _fac[i - 1]; }
    T inv(int n) { return n < 0 ? T(0) : _inv[n]; }
    T fac(int n) { return n < 0 ? T(0) : _fac[n]; }
    T ifac(int n) { return n < 0 ? T(0) : _ifac[n]; }
    T P(int a, int b) { return (b < 0 || a < b) ? T(0) : _fac[a] * _ifac[a - b]; }
    T C(int a, int b) { return b < 0 ? T(0) : P(a, b) * _ifac[b]; }
    T H(int n, int k) { if (n < 0 || k < 0) return T(0);
        return k == 0 ? T(0) : C(n + k - 1, k); }
};
typedef ModInt<MOD> mint;
//---------------------------------------------------------------


int main() {
    int n, k; cin >> n >> k;
    cout << (n <= k) << endl;
    return 0;
}


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

string s;

int n;

int pr[111111], mn[111111];

int main() {
#ifdef LOCAL
    freopen("xxx.in", "r", stdin);
    freopen("xxx.out", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> s;
    n = s.size();
    for (int i = 1; i <= n; ++i) {
        pr[i] = pr[i - 1] + (s[i - 1] == 'p');
    }
    mn[n - 1] = (n - 2 * pr[n]) / 2;
    for (int i = n - 2; i >= 0; --i) {
        mn[i] = min(mn[i + 1], (i + 1 - 2 * pr[i + 1]) / 2);
    }
    int cnt = 0;
    for (int i = 0; i < n; ++i) {
        if (s[i] == 'g') {
            if (mn[i] - cnt > 0)
                cnt++;
        }
    }
    cout << cnt;
    return 0;
}

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

using namespace std;

#define ll long long
#define sz(x) (int) ((x).size())

int main() {
	bool ok = 1;
	int n;
	cin >> n;
	while (n--) {
		int x;
		cin >> x;
		if (x % 2 == 0 && x % 5 != 0 && x % 3 != 0)
			ok = 0;
	}
	puts(ok ? "APPROVED" : "DENIED");

	return 0;
}

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

using namespace std;

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

static const int INF = 1e+6;

static int dx[4] = { 0, 0, -1, +1 };
static int dy[4] = { -1, +1, 0, 0 };

void dfs(int x, int y, int c, vector<vector<int>>& costs, const vector<string>& s, const int H, const int W)
{
    if (s[x][y] == '#') {
        return;
    }

    if (c >= costs[x][y]) {
        return;
    }

    costs[x][y] = c;

    for (int i = 0; i < 4; ++i) {
        int h = x + dx[i];
        int w = y + dy[i];

        if (0 <= h && h < H && 0 <= w && w < W) {
            dfs(h, w, c + 1, costs, s, H, W);
        }
    }
}

int main()
{
    int H, W;
    cin >> H >> W;

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

    vector<vector<int>> costs(H, vector<int>(W, INF));
    dfs(0, 0, 1, costs, s, H, W);

    if (costs[H-1][W-1] == INF) {
        cout << -1 << endl;
        return 0;
    }

    int num_black = 0;
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            if (s[i][j] == '#') {
                ++num_black;
            }
        }
    }

    int ans = H*W - num_black - costs[H-1][W-1];
    cout << ans << endl;

    return 0;
}


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

int main()
{
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    int x = abs(x1 - x2),
        y = abs(y1 - y2);

    // A B     A
    //  □    D ◇ B
    // D C     C

    // A -> D
    if( x1 == x2 && y2 < y1 ) // 正方形
        cout << x2 + y << " " << y2 << " "
             << x1 + y << " " << y1 << endl;
    else if( x2 < x1 && y2 < y1 ) // ひし形
        cout << x2 + y << " " << y2 - x << " "
             << x1 + y << " " << y1 - x << endl;

    // D -> C
    else if( x1 < x2 && y1 == y2 ) // 正方形
        cout << x2 << " " << y2 + x << " "
             << x1 << " " << y1 + x << endl;
    else if( x1 < x2 && y2 < y1 ) // ひし形
        cout << x2 + y << " " << y2 + x << " "
             << x1 + y << " " << y1 + x << endl;

    // C -> B
    else if( x1 == x2 && y1 < y2 ) // 正方形
        cout << x2 - y << " " << y2 << " "
             << x1 - y << " " << y1 << endl;
    else if( x1 < x2 && y1 < y2 ) // ひし形
        cout << x2 - y << " " << y2 + x << " "
             << x1 - y << " " << y1 + x << endl;

    // B -> A
    else if( x2 < x1 && y1 == y2 ) // 正方形
        cout << x2 << " " << y2 - x << " "
             << x1 << " " << y1 - x << endl;
    else if( x2 < x1 && y1 < y2 ) // ひし形
        cout << x2 - y << " " << y2 - x << " "
             << x1 - y << " " << y1 - x << endl;

    return 0;
}


Measured memory_bytes: 256
//Cutting Down Water Bills
import java.io.IOException;
import java.util.Scanner;

class Main {

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

		Scanner scan =new Scanner(System.in);
		
		int n;
	      while ((n = scan.nextInt())!=-1) { 


			int p;
			if(n<=10){
				p=1150;
			}else if(n<=20){
				p=1150+(n-10)*125;
			}else if(n<=30){
				p=2400+(n-20)*140;
			}else{
				p=3800+(n-30)*160;
			}

			 System.out.println(4280-p);
			
		}

	}
}

Measured memory_bytes: 18548
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    int N,ans=0;
    cin>>N;
    vint A(N),B(N),SA(N+1),SB(N+1);
    rep(i,N)
    {
        cin>>A[i];
        SA[i+1]=SA[i]+A[i];
    }
    rep(i,N)
    {
        cin>>B[i];
        SB[i+1]=SB[i]+B[i];
    }
    rep(i,N)
    {
        chmax(ans,SA[i+1]+SB.back()-SB[i]);
    }
    cout<<ans;
    return 0;
}

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

typedef long long ll;

static const ll MAX = 220;
static const ll INFTY = (1LL << 60);

ll n;
ll d[MAX][MAX];

// ワーシャルフロイド（全点対間最短経路(動的計画法)）
void floyd() {
	for (ll k = 0; k < n; k++) {
		for (ll i = 0; i < n; i++) {
			if (d[i][k] == INFTY) continue;
			for (ll j = 0; j < n; j++) {
				if (d[k][j] == INFTY) continue;
				// 頂点 k を経由する場合としない場合の最小コストを求める
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}
}

int main() {
	ll e, u, v, c;
	ll R;
	cin >> n >> e >> R;
	vector<ll> r(R);
	for (ll i = 0; i < R; i++) {
		cin >> r[i];
		r[i]--;
	}
	sort(r.begin(),r.end());

	for (ll i = 0; i < n; i++) {
		for (ll j = 0; j < n; j++) {
			d[i][j] = ((i == j) ? 0 : INFTY);
		}
	}

	for (ll i = 0; i < e; i++) {
		cin >> u >> v >> c;
		u--; v--;
		d[u][v] = min(d[u][v],c);
		d[v][u] = min(d[v][u],c);
	}

	floyd();

	ll ans=INFTY;
	do {
		ll sum=0;
		for (ll i = 1; i < r.size(); i++) {
			sum += d[r[i-1]][r[i]];
		}
		ans = min(ans,sum);
	} while (next_permutation(r.begin(), r.end()));
	
	cout << ans << endl;
}


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

using namespace std;

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

    long long ret = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            int x = lower_bound(l.begin(), l.end(), l[i] + l[j]) - l.begin();
            ret += x - j - 1;
        }
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"bufio"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)
var NULL = -1

type node struct {
	parent, left, right, depth int
}

func nextInt() int {
	sc.Scan()
	v, _ := strconv.Atoi(sc.Text())
	return v
}

// 再帰的に深さを求める
func recursion(nodes []node, n, p int) {
	nodes[n].depth = p
	if (nodes[n].right != NULL) {
		recursion(nodes, nodes[n].right, p)
	}
	
	if (nodes[n].left != NULL) {
		recursion(nodes, nodes[n].left, p + 1)
	}
}

func getNodeType(n node) string {
	if n.parent == NULL {
		return "root"
	}

	if n.left == NULL {
		return "leaf"
	}

	return "internal node"
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()

	nodes := make([]node, n)
	for i := 0; i < n; i++ {
		nodes[i] = node{NULL, NULL, NULL, NULL}
	}

	// structing tree
	var l int
	for i := 0; i < n; i++ {
		id := nextInt()
		k := nextInt()
		for j := 0; j < k; j++ {
			c := nextInt()
			if j == 0 {
				nodes[id].left = c
			} else {
				nodes[l].right = c
			}
			l = c
			nodes[c].parent = id
		}
	}
	
	// find root node
	var root int
	for i := 0; i < n; i++ {
		if nodes[i].parent == NULL {
			root = i
			break
		}
	}

	recursion(nodes, root, 0)
	for i, v := range nodes {
		var childlen []string
		for i := nodes[i].left; i != NULL; i = nodes[i].right {
			childlen = append(childlen, strconv.Itoa(i))
		}
		childlenStr := strings.Join(childlen, ", ")
		nodeType := getNodeType(v)
		fmt.Printf("node %d: parent = %d, depth = %d, %s, %s\n", i, v.parent, v.depth, nodeType, "[" + childlenStr + "]")
	}
}


Measured memory_bytes: 22172
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define ll long long 
int ctoi(char c) {return c-'0';}/*char to int*/
int gcd(ll a,ll b){return b?gcd(b,a%b):a;}/*MAX*/
int lcm(ll a,ll b){return a*b/gcd(a,b);}/*MIN*/
bool primecheck(ll n){/*sosuu*/if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
int  main(){
int n;
cin >> n;
map<int,int>a;
vector<ll>che(n);
for(int i=0;i<n;i++){
    int z;
    cin >> z;
    che.at(i)=z;
    if(a.count(z))a.at(z)++;
    else{
        a[z]=1;
}
}
sort(che.begin(),che.end());
reverse(che.begin(),che.end());
ll q = 0,qq=0;
for(int i=0;i<n;i++){
    ll d = che.at(i);
    if(a.at(d)>=4){ll ans = max({d*d,d*q,d*qq});cout << ans << endl; return 0;}
    if(a.at(d)>=2&&d!=q&&d!=qq){
        vector<int>dd(3);
        dd.at(0)=q;
        dd.at(1)=qq;
        dd.at(2)=d;
        sort(dd.begin(),dd.end());
        q = dd.at(1);
        qq = dd.at(2);
    }
    if(qq!=0&&q!=0){
        ll ans = q*qq;
        cout << ans << endl;
        return 0;
    }
}
ll ans = q*qq;
cout << ans << endl;
}




Measured memory_bytes: 5760
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

N, *A = map(int, read().split())

ans = True
for a in A:
    if a % 2 == 0:
        if (a % 3 == 0) or (a % 5 == 0):
            pass
        else:
            ans = False

if ans:
    print("APPROVED")
else:
    print("DENIED")


Measured memory_bytes: 2940
N,K=map(int,input().split())
Points=[[int(i) for i in input().split()] for i in range(N)]
List_x=[Points[i][0] for i in range(N)]
List_x.sort(key=lambda x:x)
List_y=[Points[i][1] for i in range(N)]
List_y.sort(key=lambda x:x)
n=0
Y=0
S=(List_x[-1]-List_x[0])*(List_y[-1]-List_y[0])
for x1 in range(N-1):
  for x2 in range(x1+K-1,N):
    for y1 in range(N-1):
      for y2 in range(max([y1+K-1,Y]),N):
        for p in Points:
          if List_x[x1]<=p[0]<=List_x[x2] and List_y[y1]<=p[1]<=List_y[y2]:
            n+=1
          if n==K:
            x_delta=List_x[x2]-List_x[x1]
            y_delta=List_y[y2]-List_y[y1]
            if x_delta*y_delta<S:
               S=x_delta*y_delta
            break
        if n>=K:
          n=0
          Y=y2
          break  
        n=0
    Y=0    
print(S)          
          

Measured memory_bytes: 3064
n,m = map(int, input().split())

for x in range(n, -1, -1):
  if m - 10000*x < 0: continue
  for y in range(n-x, -1, -1):
    z = n-x-y
    if 10000*x + 5000*y + 1000*z == m:
      print(x,y,z)
      exit()
print(-1,-1,-1)

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


#define debug(x) cout << #x << " = " << x << endl;
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define FOR(it, b, e) for (typeof(b) it = (b); it != (e); ++it)
#define MSET(c, v) memset(c, v, sizeof(c))

const int INF = 0x3F3F3F3F; 
const int NEGINF = 0xC0C0C0C0;
const int NULO = -1;
const double EPS = 1e-10;
const ll mod = 1e9 + 7;

inline int cmp(double x, double y = 0) 
{  
  if(fabs(x - y) < EPS)
    return 0;
  return x > y ? 1 : -1;
}

ll exp(ll a, ll b)
{
  ll ans = 1;
  while(b)
  {
    if(b & 1)
      ans = (ans * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return ans;
}

const int maxn = 1e6 + 10;
ll fat[maxn], inv[maxn];

ll C(int n, int k)
{
  if(n < k) 
    return 0;
  if(n < 0 || k < 0) 
    return 0;
  return (((fat[n] * inv[k]) % mod) * inv[n - k]) % mod;
}

void initInverse()
{
  inv[0] = 1;
  for(int i = 1; i < maxn; i++)
  {
    inv[i] = exp(i, mod - 2);
  }
}

ll a[maxn];
int prime[maxn];

unordered_map<int, int> max_map; 

void sieve() 
{ 
    prime[0] = prime[1] = 1; 
    for (int i = 2; i < maxn; i++) { 
        if (prime[i] == 0) { 
            for (int j = i * 2; j < maxn; j += i) { 
                if (prime[j] == 0) { 
                    prime[j] = i; 
                } 
            } 
            prime[i] = i; 
        } 
    } 
} 
  
ll lcmModuloM(int n) 
{ 
  sieve();
  for (int i = 0; i < n; i++) { 
      int num = a[i]; 
      unordered_map<int, int> temp; 
      while (num > 1) { 

          int factor = prime[num]; 
          temp[factor]++; 

          num /= factor; 
      } 

      for (auto it : temp) { 

          max_map[it.first] = max(max_map[it.first], it.second); 
      } 
  } 

  ll ans = 1; 

  for (auto it : max_map) { 

      ans = (ans * exp(it.first, it.second)) % mod; 
  } 

  return ans; 
} 

int main()
{
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  initInverse();
  ll l = 1;
  for(int i = 0 ; i < n; i++)
  {
    cin >> a[i];
  }
  l = lcmModuloM(n);

  
  ll ans = 0;

  for(int i = 0 ; i < n; i++)
  {
    ll b = (l * inv[a[i]]) % mod;
    ans = (ans + b) % mod;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 15776
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    move(vector<vector<T>>(h,move(vector<T>(w))))
#define VVI(T,h,w,i) move(vector<vector<T>>(h,move(vector<T>(w,i))))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
	auto digit_sum = [](ll n) {ll ans = 0; while (n > 0) { ans += n % 10; n /= 10; }; return ans; };
	ll n = in();
	ll a = n - 1, b = 1;
	ll ans = INFLL;
	while (a >= b) {
		ans = min(ans, digit_sum(a) + digit_sum(b));
		--a;
		++b;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
s = input()

if not(s.count('N') > 0 and s.count('S') > 0 or
       s.count('N') == 0 and s.count('S') == 0):
    print('No')
elif not(s.count('W') > 0 and s.count('E') > 0 or
       s.count('W') == 0 and s.count('E') == 0):
    print('No')
else:
    print('Yes')



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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

// {{{
template<typename T>
void printmatrix(vector<vector<T> > ar){
    for (int i = 0; i < (int)ar.size(); i++) {
        for (int j = 0; j < (int)ar[0].size(); j++) {
            cout << ar[i][j];
        }
        cout << endl;
    }
}

template<typename T>
void printvector(vector<T> vec){
    for (int i = 0; i < (int)vec.size(); i++) {
        cout << vec[i] << endl;
    }
}

template<typename T>
void unique(vector<T>& vec){
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
}

template<typename T>
vector<T> cumsum(vector<T> vec){
    vector<T> newvec((T)vec.size());
    int tmp = 0;
    for (int i = 0; i < (int)vec.size(); i++) {
        tmp += vec[i];
        newvec[i] = tmp;
    }

    return newvec;
}

template<typename T>
T digitsum(T x){
    T y=0;
    while(x){
        y += x % 10;
        x /= 10;
    }

    return y;
}

template<typename T>
T gcd(T a, T b){
    if (a == 0 || b == 0) {
        return 0;
    }

    while (a != b) {
        if (a > b) {
            a -= b;
        }else{
            b -= a;
        }
    }

    return a;
}
// }}}
/* vim:set foldmethod=marker: */

int main(int argc, char const* argv[])
{
    int a,b,c;
    cin >> a >> b >> c;
    if (c % gcd(a,b) == 0) {
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}

// sortの仕方
// int a[N];
// array<int,N> ar;
// vector<int> v;
//
// sort(a, a+N); // 配列
// sort(ar.begin(), ar.end()); // array
// sort(v.begin(), v.end()); // vector 昇順
// sort(v.begin(), v.end(), greater<int>()); // 降順

// Template
// template <class T>
// T foomax(T x, T y){
//   if (x > y){
//     return x;
//   }else{
//     return y;
//   }
// }

// string を int に変換 stoi("1010")
// int を string に変換 to_string(1010)


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstdint>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <utility>
#include <limits>
#include <list>
#include <type_traits>

/* template start */

using i64=std::int_fast64_t;
using u64=std::uint_fast64_t;
 
#define rep(i, a, b) for (i64 i = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()

#ifdef LOCAL
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  if(sizeof...(t)>0)std::cout<<" :";
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}

template<typename Num>
constexpr Num mypow(Num a, u64 b,Num id=1) {
  if(b==0)return id;
  Num x = id;
  while (b > 0) {
    if(b & 1)x*=a;
    a*=a;
    b >>= 1;
  }
  return x;
}

/* template end */

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

  std::string s;
  std::cin>>s;

  i64 ans=0;

  char prev='t';
  i64 cnt=0;

  for(const auto& e:s){
    if(e==prev){
      cnt++;
    }else{
      if(prev=='R')chmax(ans,cnt);
      cnt=1;
      prev=e;
    }
  }

  if(prev=='R')chmax(ans,cnt);
  
  std::cout<<ans<<"\n";

  return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <bitset>
#include <tuple>
#include <stack>
#include <utility>

using namespace std;

int main(){
    int A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;
    int w=100*A, s=0;
    for(int i=0; i<=30; i++){
        for(int j=0; j<=30; j++){
            if(100*(A*i+B*j) > F || i+j==0) continue;
            int Z = E*(A*i + B*j), W = 100*(A*i + B*j);
            for(int y=0; y<=Z/D; y++){
                for(int x=0; x<= Z/C; x++){
                    if(C*x+D*y > Z) continue;
                    if(1.0*s/(w+s) < 1.0*(C*x+D*y)/(W+C*x+D*y) && W+C*x+D*y <= F){
                        w = W;
                        s = C*x + D*y;
                    }
                }
            }
        }
    }
    cout << w+s << " " << s << endl;
    return 0;
}

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

int main(){
	int num, a[200][3], i, j, score[200], h, k;
	scanf("%d", &num);
	for(i = 0; i < num; i++){
		for(j = 0; j < 3; j++) scanf("%d", &a[i][j]);
		score[i] = 0;
	}
	for(i = 0; i < 3; i++){
		for(j = 0; j < num; j++){
			h = 0;
			for(k = 0; k < num; k++){
				if(j == k) continue;
				if(a[j][i] == a[k][i]){
					h = 1;
					break;
				}
			}
			if(h == 0) score[j] += a[j][i];
		}
	}
	for(i = 0; i < num; i++) printf("%d\n", score[i]);
	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }





const ll mxm = 1e18;
struct SegmentTree {
private:
    int n;
    vector<ll> node;
public:
    SegmentTree(vector<ll> v) {
        auto sz = v.size();
        n = 1; while (n < sz) n *= 2;
        node.resize(2 * n - 1, mxm);
        for (int i = 0; i < sz; ++i) node[i + n - 1] = v[i]; // 最下段に値を入れる
        for (int i = n - 2; i >= 0; --i) node[i] = min(node[2 * i + 1], node[2 * i + 2]);
    }
    void update(int x, ll val) {
        x += n - 1;
        node[x] = val;
        while (x > 0) {
            x = (x - 1) / 2;
            node[x] = min(node[2 * x + 1], node[2 * x + 2]);
        }
    }
    ll getmin(int a, int b, int k = 0, int l = 0, int r = -1) {
        if (r < 0) r = n; // init
        if (r <= a || b <= l) return mxm;
        if (a <= l && r <= b) return node[k];
        ll vl = getmin(a, b, 2 * k + 1, l, (l + r) / 2);
        ll vr = getmin(a, b, 2 * k + 2, (l + r) / 2, r);
        return min(vl, vr);
    }
    // http://tsutaj.hatenablog.com/entry/2017/03/29/204841
    void out() {
        rep(i, sz(node)) cout << (node[i] == mxm ? -1 : node[i]) << " "; cout << endl;
    }
};


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    
    int n, m;
    cin >> n >> m;
    
    vector<ll> a(n, mxm);
    a[0] = 0;
    SegmentTree sgt(a);
    // sgt.out();
    vector<pair<pii, ll> > v;
    rep(i, m) {
        int l, r, c;
        cin >> l >> r >> c;
        v.eb(make_pair(pii(l, r), c));
    }
    sort(all(v));
    rep(i, m) {
        int l, r; ll c;
        l = v[i].F.F, r = v[i].F.S, c = v[i].S;
        l--; r--;
        ll tmp = sgt.getmin(l, r + 1);
        // cout << endl << tmp << " " << c << endl;
        if (tmp >= mxm) continue;
        tmp += c;
        if (sgt.getmin(l, l + 1) > tmp) sgt.update(l, tmp);
        if (sgt.getmin(r, r + 1) > tmp) sgt.update(r, tmp);
        // sgt.out();
    }
    ll ans = sgt.getmin(n - 1, n);
    if (ans == mxm) cout << -1 << endl;
    else cout << ans << endl;
}


Measured memory_bytes: 6184
#include <iostream>
#include <vector>
#define llint long long
#define mod 1000000007

using namespace std;

llint n;
vector<llint> G[5005];
llint dp[5005][5005][2];
llint dp2[5005][5005][2];
llint size[5005];
llint fact2[5005];

void dfs(int v, int p)
{
	for(int i = 0; i < G[v].size(); i++){
		if(G[v][i] == p) continue;
		dfs(G[v][i], v);
	}
	
	llint sum = 1;
	for(int j = 0; j <= sum; j++){
		for(int k = 0; k < 2; k++) dp2[0][j][k] = 0;
	}
	dp2[0][1][0] = 1;
	
	for(int i = 0; i < G[v].size(); i++){
		int u = G[v][i];
		if(u == p){
			for(int j = 0; j <= sum; j++){
				for(int k = 0; k < 2; k++) dp2[i+1][j][k] = dp2[i][j][k];
			}
			continue;
		}
		for(int j = 0; j <= sum + size[u]; j++) dp2[i+1][j][0] = dp2[i+1][j][1] = 0;
		for(int j = 0; j <= sum; j++){
			for(int k = 0; k < 2; k++){
				for(int l = 0; l <= size[u]; l++){
					for(int m = 0; m < 2; m++){
						(dp2[i+1][j+l][(k+m)%2] += dp2[i][j][k] * dp[u][l][m] % mod) %= mod;
						(dp2[i+1][j][(k+m+1)%2] += dp2[i][j][k] * dp[u][l][m] % mod * fact2[l] % mod) %= mod;
					}
				}
			}
		}
		sum += size[u];
	}
	size[v] = sum;
	
	for(int i = 0; i <= sum; i++){
		for(int j = 0; j < 2; j++){
			dp[v][i][j] = dp2[G[v].size()][i][j];
		}
	}
}

int main(void)
{
	cin >> n;
	llint u, v;
	for(int i = 1; i <= n-1; i++){
		cin >> u >> v;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	
	fact2[0] = 1;
	for(int i = 2; i <= n; i+=2){
		fact2[i] = fact2[i-2] * (i-1) % mod;
		fact2[i] %= mod;
	}
	
	dfs(1, -1);
	
	llint ans = 0;
	for(int i = 0; i <= n; i++){
		ans += dp[1][i][0] * fact2[i] % mod, ans %= mod;
		ans += mod - dp[1][i][1] * fact2[i] % mod, ans %= mod;
	}
	cout << ans << endl;
	
	return 0;
}

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

using namespace std;

typedef long long LL;
const LL MAXN=128;
const LL MAXW=100000+100;
long long dp[MAXW];
long long c[MAXN],v[MAXN];
long long n,w;

int main(){
	cin>>n>>w;
	for(LL i=1;i<=n;i++){
		cin>>c[i]>>v[i];
	}
	for(LL i=1;i<=n;i++){
		for(LL j=w;j>=c[i];j--){
			dp[j]=max(dp[j],dp[j-c[i]]+v[i]);
		}
	}
	cout<<dp[w]<<endl;
	return 0;
}


Measured memory_bytes: 1024
/*
	@author: cheerioskun
*/

#include "bits/stdc++.h"
#define f first
#define sc second
#define pb push_back
#define MOD 1000000007L
#define inf 0x3f3f3f3f
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long int ll;
typedef std::vector<int> vi;
typedef std::pair<int, int> pii;
using namespace std;


int main(){
	fast_io
	int A, B, C;
	cin>>A>>B>>C;
	if(A==B || B == C || A == C){
		if(A == B && B == C){
			cout<<"No"<<endl;
		}else{
			cout<<"Yes"<<endl;
		}
	}else{
		cout<<"No"<<endl;
	}
	

}



Measured memory_bytes: 256
#define C(a,b,c,d)((c-a)*(n-b)-(m-a)*(d-b))
main(){float d,e,f,g,h,i,m,n,p;for(;~scanf("%f%f%f%f%f%f%f%f",&d,&e,&f,&g,&h,&i,&m,&n);puts(C(d,e,f,g)*p>0&&p*C(h,i,d,e)>0?"YES":"NO"))p=C(f,g,h,i);}

Measured memory_bytes: 0
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10 ** 6)
# MOD = 10 ** 9 + 7
INF = float("inf")


def main():
    n, t = map(int, input().split())
    T = list(map(int, input().split()))
    ans = 0
    for i in range(n - 1):
        ans += min(t, T[i+1] - T[i])
    ans += t
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 25744
def insertionSort(a, n):
    for i in range(1, n):
        show(a, n)
        v = a[i]
        j = i - 1
        while j >= 0 and a[j] > v:
            a[j+1] = a[j]
            j -= 1
        a[j+1] = v
    else:
        show(a, n)

def show(a, n):
    for i in range(n):
        if i == n-1:
            print "%d" % a[i]
        else:
            print "%d" % a[i],

n = input()
a = map(int, raw_input().split())
insertionSort(a, n)

Measured memory_bytes: 6468
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n;
	cin>>n;
	ll a[n];
	map<ll,ll> pam;
	for(ll i=0;i<n;i++)
	{
		cin>>a[i];
		pam[a[i]]++;
	}
	ll ans = 0;
	for(auto p = pam.begin();p!=pam.end();++p)
	{
		ll val = (*p).second;
		ans+=(val*(val-1))/2;
	}
	for(ll i=0;i<n;i++)
	{
		ll val = pam[a[i]];
		ll Ans = ans - (val*(val-1))/2;
		val--;
		Ans+=(val*(val-1))/2;
		cout<<Ans<<"\n";
	}
}

Measured memory_bytes: 11136
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
using namespace std;
#define ll long long
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define clr(x,y) memset(x,y,sizeof(x))
#define in(a) a=read()
#define out(a) printf("%d\n",a)
inline ll read(){
    char c=getchar();ll f=1,x=0;
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9')x=x*10+(c-'0'),c=getchar();
    return x*f;
}
#define mod 1000000007
void MOD(int &x){if(x>=mod)x-=mod;}
#define maxn 100010
#define inf (1<<30)
int a[maxn];
int main(){
	int n;
	in(n);
	FOR(i,1,n)in(a[i]);
	FOR(i,2,n){
		if(a[i]>a[i-1])a[i]--;
		if(a[i]<a[i-1]){puts("No");return 0;}
	}
	puts("Yes");
}

Measured memory_bytes: 640
#define M(x,y)(x>y?x:y)
#define m(x,y)(x<y?x:y)
I;int parse(char *p){switch(*p){
	case'0':return 0;
	case'1':return 1;
	case'2':return 2;
	case'P':return I%3;
	case'Q':return I/3%3;
	case'R':return I/9%3;
	case'-':return 2-parse(p+1);
	case'(':{
		int x=0,y;
		char*q=++p;
		for(;;p++){
			if(*p=='(')x++;
			if(*p==')')x--;
			if(x==0&&*p!='-')break;
		}
		return(*(++p)=='*')?m(parse(q),parse(p+1)):M(parse(q),parse(p+1));
	}
}}
char p[81];main(s){for(;scanf("%s",p),*p-'.';printf("%d\n",s))for(s=I=0;I<27;I++)s+=parse(p)==2;exit(0);}

Measured memory_bytes: 536
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#ifndef bhartiya
    #pragma GCC optimize("Ofast")
    #pragma GCC optimize("unroll-loops")
    // #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#endif


typedef long long ll;
typedef pair<ll, ll> pll;
typedef gp_hash_table<long long, long long> umap;
typedef tree<int, null_type, less<int>, rb_tree_tag,
		tree_order_statistics_node_update> oset;
// not that imp
typedef pair<pll, ll> plll;
typedef vector<ll> vl;
typedef vector<pll> vll;

#define inf 200000000000000ll
#define mod 1000000007ll
#define eps 1e-7
#define PI 3.1415926535897932385
// #define PI acos(-1)

#define pb push_back
#define bitc  __builtin_popcountll
#define mp make_pair
#define ff first
#define ss second
#define all(ar) ar.begin(), ar.end()

#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)
#define foreach(it,ar) for (auto it = ar.begin(); it != ar.end(); it++)
#define fill(ar,val) memset(ar, val, sizeof(ar))

#ifdef bhartiya
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n"; return 0;
#else
#define endl '\n'
#define trace(...)
#define end_routine() return 0;
#endif

mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
inline bool equals(double a, double b) {return fabs(a - b) < 1e-9;}
ll gcd(ll a, ll b){ return b==0 ? a : gcd(b, a%b); }

const ll maxn = 500005;

void solve(){
    string s; cin>>s;
    rep(i,s.length()-1){
        if(s[i] == s[i+1]){
            cout<<"Bad";
            return;
        }
    }
    cout<<"Good";
}

int main() 
{ 
	ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0), cout.precision(10); //cout<<fixed;
    cin.exceptions(cin.failbit);
    #ifdef bhartiya
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    solve();
    end_routine();
}

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

class Program
{
    static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());
        int A = int.Parse(Console.ReadLine());
        Console.WriteLine(N % 500 <= A ? "Yes" : "No");
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define ull uint64_t
#define ll long long int
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mx5 100005
#define mx52 200005
#define mx6 1000005
#define mod 1000000007
#define nfs ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

ll dp[3005] = {}, fact[mx52] = {}, ifact[mx52] = {};

ll binExp(ll b, ll e) {
    ll ans = 1;
    b %= mod;
    e %= (mod-1);
    while (e) {
        if (e & 1) {
            ans = (ans * b) % mod;
        }
        b = (b * b) % mod;
        e /= 2;
    }
    return ans;
}

ll inv(ll n) {
    return binExp(n, mod-2);
}

void pre() {
    fact[0] = 1;
    int lim = mx52;
    for (int i = 1; i < lim; i++) {
        fact[i] = (fact[i-1] * i) % mod;
    }
    
    ifact[lim-1] = inv(fact[lim-1]);
    for (int i = lim-2; i >= 0; i--) {
        ifact[i] = (ifact[i+1] * (i+1)) % mod;
    }
}

ll nCr(int n, int r) {
    if (r > n || r < 0 || n < 0) return 0;
    return (((fact[n] * ifact[r]) % mod) * ifact[n-r]) % mod;
}

ll npaths(int fromx, int fromy, int tox, int toy) {
    if (tox < fromx || toy < fromy) {
        return 0;
    }
    return nCr(tox-fromx + toy-fromy, tox-fromx);
}

int main() {
    nfs
    pre();
    int i, j, h, w, n, r, c;
    cin >> h >> w >> n;
    vector <pii> forbidden(1, pii(1,1));
    for (i = 0; i < n; i++) {
        cin >> r >> c;
        forbidden.pb({r, c});
    }
    
    auto comp = [] (pii const& s1, pii const& s2) -> bool
    {
        return s1.ff + s1.ss < s2.ff + s2.ss;
    };
    
    sort(forbidden.begin(), forbidden.end(), comp);
    
    for (i = n; i >= 0; i--) {
        dp[i] = npaths(forbidden[i].ff , forbidden[i].ss, h, w);
        for (j = i + 1; j <= n; j++)
            dp[i] = (dp[i] + (mod - (npaths(forbidden[i].ff , forbidden[i].ss, forbidden[j].ff, forbidden[j].ss) * dp[j]) % mod) %mod) %mod;
    }
    cout << dp[0];
}

Measured memory_bytes: 6788
//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/math/common_factor.hpp>
#include <boost/algorithm/string.hpp>

#define REP(i, N) for(int i=0; i<(N); i++)
#define REC(f, ...) (void)0; const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::math;

using ll = long long;
namespace bst = boost;
template<typename T> class in {
    T value;
public:
    in() { cin >> value; }
    operator const T&() const { return value; }
    operator T&() { return value; }
    in& operator=(T source) { value = source; return *this; }
};
template<> class in<string> : public string {
public:
    in() { cin >> *this; }
};
template<class T> class inseq : public T {
public:
    template<typename... Arg> inseq(Arg... arg) : T(forward<Arg>(arg)...) { for (auto&& i : *this) cin >> i; }
};
template<class T> using invec = inseq<vector<T>>;

auto solve() {
  in<int> A, B;
  invec<int> AA(B);

  
  int r = A - bst::accumulate(AA, 0);
  return max(-1, r);
}

template<typename T> void plot(const T& func) { cout << func() << endl; }
template<> void plot<void()>(void(&func)()) { func(); }
template<> void plot<double()>(double(&func)()) { cout << setprecision(9) << func() << endl; }

int main() {
  plot(solve);

  return 0;
}



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

string strmax(string a, string b){
  if(a.size() > b.size()) return a;
  if(a.size() < b.size()) return b;
  if(a > b) return a;
  else return b;
  }

int main(){
  int N,M; cin>>N>>M;
  vector<int> A(M);
  for(int i=0;i<M;i++) cin>>A[i];
  int cost[9] = {2,5,5,4,5,6,3,7,6};
  vector<string> dp(10100,"0");
  dp[0] = "";
  for(int i=0;i<N;i++){
    if(dp[i] == "0") continue;
    for(int j=0;j<M;j++){
      dp[i+cost[A[j]-1]] = strmax(dp[i+cost[A[j]-1]], dp[i] + (char)('0' + A[j]));
    }
  }
  cout<<dp[N]<<endl;
  return 0;
}


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

int main(){
	int a,b,c,d,hatsune,miku;
	cin>>a>>b>>c>>d;
	hatsune=a*b;
	miku=c*d;
	if(hatsune>miku){
		cout<<hatsune<<endl;
	}else cout<<miku<<endl;
}

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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

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

const ll LINF=1LL<<60;
const int INF=1<<29;
const int MOD=1e9+7;

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

int main(){
    ll n; cin >> n;
    ll ans=0;
    ans=n*(n-1)/2;
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 3640
object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)

    val N = sc.nextInt(); sc.nextLine()
    val S = sc.nextLine().toList
    // 3桁の暗証番号, N桁のラッキーナンバーS, SからN - 3桁を消して, 残りの3桁を 左から読んだものを暗証番号として設定
    // 設定されうる暗証番号は何種類?
    // 残す桁を一つづつ選ぶ場合だと, N^3 なので, 間に合わない.
    // 最大で, 9 ^ 3種類しかない, というのはわかっている
    // 逆に, 9 ^ 3種類の中からSで満たすものがあるか？を調べた方が良さそう
    // 9 ^ 3通りの組み合わせで, Nについて走査すればいい
    def check(a: Int, b: Int, c: Int): Boolean = {
      def recursive(s: List[Char], rest: List[Char]): Boolean =
        rest match {
          case Nil => true
          case h :: t =>
            s match {
              case Nil => false
              case hh :: tt =>
                if (h == hh) recursive(tt, t)
                else recursive(tt, rest)
            }
        }
      recursive(S, List(a, b, c).map(i => (i + '0').toChar))
    }

    val r = (for {
      a <- 0 to 9
      b <- 0 to 9
      c <- 0 to 9
      if check(a, b, c)
    } yield (a, b, c)).size



    println(r)
  }

}


Measured memory_bytes: 56120
A,B,C = (map(int,input().split()))

cnt=0
a = A
b = B
c = C

if  A==B and A==C and A%2==0:
    cnt = -1
else :
    while True:
        if A%2!=0 or B%2!=0 or C%2!=0:
            break
        else:
            a = A
            b = B
            c = C
            
            A = b/2+c/2
            B = a/2+c/2
            C = a/2+b/2
            
            cnt+=1
        
print(cnt)

Measured memory_bytes: 3064