akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

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

/*
    freopen("input","r",stdin);
    freopen("output","w",stdout);
*/

int A[301][301];
int B[301][301];
int N;

int get_a(int a, int b) {
	if (a < 0 || b >= N) return 0;
	return A[a][b];
}

int get_b(int a, int b) {
	if (a < 0 || b >= N) return 0;
	return B[a][b];
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin >> s;
    N = s.size();
    int K;
    cin >> K;
    if (K * 2 + 1 >= N) {
    	cout << N << endl;
    	return 0;
    }
    memset(A, 0, sizeof(A));
    int res = 0;
    for (int i = 0;i < N;i++) {
    	for (int j = N - 1;j >= i;j--) {
    		if (i != j) {
    			if (s[i] == s[j]) {
    				A[i][j] = max(A[i][j], get_a(i - 1, j + 1) + 2);
    				A[i][j] = max(A[i][j], get_a(i - 1, j));
    				A[i][j] = max(A[i][j], get_a(i, j + 1));
    			}
    			else {
    				A[i][j] = max(A[i][j], get_a(i - 1, j + 1));
    				A[i][j] = max(A[i][j], get_a(i - 1, j));
    				A[i][j] = max(A[i][j], get_a(i, j + 1));
    			}
    		}
    		else {
    			A[i][j] = max(A[i][j], get_a(i - 1, j + 1) + 1);
    		}
    	}
    }
    for (int i = 0;i < N;i++) {
    	for (int j = i;j < N;j++) res = max(res, A[i][j]);
    }
    for (int k = 1;k <= K;k++) {
    	memset(B, 0, sizeof(B));
    	for (int i = 0;i < N;i++) {
    		for (int j = N - 1;j >= i;j--) {
    			if (i != j) {
    				if (s[i] == s[j]) {
    				B[i][j] = max(B[i][j], get_b(i - 1, j + 1) + 2);
    				B[i][j] = max(B[i][j], get_b(i - 1, j));
    				B[i][j] = max(B[i][j], get_b(i, j + 1));
    			}
    			else {
    				B[i][j] = max(B[i][j], get_a(i - 1, j + 1) + 2);
    				B[i][j] = max(B[i][j], get_b(i - 1, j + 1));
    				B[i][j] = max(B[i][j], get_b(i - 1, j));
    				B[i][j] = max(B[i][j], get_b(i, j + 1));
    			}
    			}
    			else {
    				B[i][j] = max(B[i][j], get_b(i - 1, j + 1) + 1);
    			}
    		}
    	}
    	swap(A, B);
    	for (int i = 0;i < N;i++) {
	    	for (int j = i;j < N;j++) res = max(res, A[i][j]);
	    }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1024
import math

X = int(input())


def explor_B(A):
    tmp = X - A**5

    def hantei(add_val):
        B = 0
        while True:
            if abs(B**5) == abs(tmp):
                return True, B
            elif abs(B**5) > abs(tmp):
                return False, 0
            else:
                B += add_val  

    if tmp < 0:
        return hantei(1)
         
    else:
        return hantei(-1)


A = 0

while True:
    flag, B = explor_B(A)
    if flag:
        break
    else:
        A += 1

print("{} {}".format(A, B))

Measured memory_bytes: 9120
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int i=(a);i<(n);++i)
#define eFOR(i,a,n) for(int i=(a);i<=(n);++i)
#define rFOR(i,a,n) for(int i=(n)-1;i>=(a);--i)
#define erFOR(i,a,n) for(int i=(n);i>=(a);--i)
#define each(i, a) for(auto &i : a)
#define SORT(a) sort(a.begin(),a.end())
#define rSORT(a) sort(a.rbegin(),a.rend())
#define fSORT(a,f) sort(a.begin(),a.end(),f)
#define all(a) a.begin(),a.end()
#define out(y,x) ((y)<0||h<=(y)||(x)<0||w<=(x))
#define tp(a,i) get<i>(a)
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T>inline istream& operator>>(istream& is, deque<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }
template<class T>inline void print(const T& a) { cout << a << "\n"; }
template<class T, class... Ts>inline void print(const T& a, const Ts&... ts) { cout << a << " "; print(ts...); }
template<class T>inline void print(const vector<T>& v) { for (int i = 0; i < v.size(); ++i)cout << v[i] << (i == v.size() - 1 ? "\n" : " "); }
template<class T>inline void print(const vector<vector<T>>& v) { for (auto& a : v)print(a); }
inline string reversed(const string& s) { string t = s; reverse(all(t)); return t; }

int main() {
    init();

    ll k; cin >> k;
    ll cur = 7 % k;
    FOR(i, 0, k * 2) {
        if (cur == 0) {
            print(i + 1);
            return 0;
        }
        cur = (cur * 10 + 7) % k;
    }
    print(-1);

    return 0;
}


Measured memory_bytes: 3652
using System;
using System.Collections.Generic;

class Program
{
    #region library
    static int n = 0;
    static int m = 0;
    static int r = 0;
    static int c = 0;
    static int x = 0;
    static int y = 0;
    static int[] arr;
    static string s = "";
    static string[] ss;
    static string alpha = "abcdefghijklmnopqrstuvwxyz";
    static long sum = 0;
    static long cnt = 0;
    static long max = -1;
    static long min = 2147483647;
    static bool flg = false;
    static bool flg2 = false;
    static char[,] map;
    static int[,] imap;
    static string rl()
    {
        return Console.ReadLine();
    }
    static string[] rls()
    {
        return Console.ReadLine().Split();
    }
    static void wl(object obj = null)
    {
        Console.WriteLine(obj);
    }
    static void w(object obj)
    {
        Console.Write(obj);
    }
    static int Int(string s)
    {
        return int.Parse(s);
    }
    static long Max(long a, long b)
    {
        return Math.Max(a, b);
    }
    static long Min(long a, long b)
    {
        return Math.Min(a, b);
    }
    static long Abs(long a)
    {
        return Math.Abs(a);
    }
    static void yes()
    {
        wl("YES");
    }
    static void no()
    {
        wl("NO");
    }
    static void Sum()
    {
        wl(sum);
    }
    static void Cnt()
    {
        wl(cnt);
    }
    static void setmap(char def = '@')
    {
        if (r == 0 && c == 0)
        {
            ss = rls();
            r = Int(ss[0]);
            c = Int(ss[1]);
        }
        map = new char[r, c];
        for (int i = 0; i < r; i++)
        {
            if (def == '@') s = rl();
            for (int j = 0; j < c; j++)
            {
                map[i, j] = (def == '@') ? s[j] : def;
            }
        }
    }
    static void setimap(int def = -1)
    {
        if (r == 0 && c == 0)
        {
            ss = rls();
            r = Int(ss[0]);
            c = Int(ss[1]);
        }
        imap = new int[r, c];
        for (int i = 0; i < r; i++)
        {
            if (def == -1) s = rl();
            for (int j = 0; j < c; j++)
            {
                imap[i, j] = (def == -1) ? Int(s[j].ToString()) : def;
            }
        }
    }
    #endregion

    static void Main(string[] args)
    {
        s = rl();
        int start = 0;
        int end = s.Length - 1;
        while(start < end)
        {
            if (s[start] != s[end]) cnt++;
            start++;
            end--;
        }
        Cnt();
    }
}



Measured memory_bytes: 13140
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>

#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#include <stdexcept>

using namespace std;

// type alias
using ll = long long;
using ull = unsigned long long;

//conversion
//------------------------------------------
inline int toint(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class t> inline string tostring(t x) { ostringstream sout; sout << x; return sout.str(); }

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (l" << __line__ << ")" << " " << __file__ << endl

inline ll floor(ll a, ull b)
{
	ll llb = b;
	if (a >= 0)
	{
		return a / llb;
	}
	else
	{
		return - ( (-a + llb - 1) / llb);
	}
}

inline ll ceil(ll a, ull b)
{
	ll llb = b;
	if (a >= 0)
	{
		return (a + llb - 1) / llb;
	}
	else
	{
		return - (-a / llb);
	}
}

inline ll getLowestOneBit(ll a)
{
	return a & (-a);
}

inline ll getHighestOneBit(ll a)
{
	while ((a & (a - 1)) != 0)
	{
		a = a & (a - 1);
	}
	return a;
}

inline bool isPower2(ull a)
{
	if (a == 0)
	{
		return false;
	}
	return !(a & (a - 1));
}

inline ll getSpecifiedBit(ll a, unsigned bit)
{
	return (a & (1LL << bit)) >> bit;
}

// computational complexity: o(log(max(a, b))) 
inline ull getGcd(ull a, ull b)
{
	if (b == 0)
	{
		return a;
	}
	return getGcd(b, a % b);
}

template<class Integer>
inline Integer getPower(Integer base, ull exponential)
{
	Integer result = 1;
	while (exponential >= 1)
	{
		if (exponential & 1)
		{
			result = result * base;
		}
		base = base * base;
		exponential >>= 1;
	}

	return result;
}

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

	ll N;
	cin >> N;

	vector<ll> indices(N);
	ll p;
	for (ll i = 0; i < N; ++i)
	{
		cin >> p;
		indices[p - 1] = i;
	}

	ll res = 0;

	ll count, w, x, y, z;
	multiset<ll> s;
	s.insert({ -1, -1, N, N });
	for (ll i = 0; i < N; ++i)
	{
		s.insert(indices[N - i - 1]);
		auto curr = s.find(indices[N - i - 1]);
		x = *(--curr);
		w = *(--curr);
		advance(curr, 2);
		y = *(++curr);
		z = *(++curr);
		count = (x - w) * (y - indices[N - i - 1]) + (indices[N - i - 1] - x) * (z - y);
		res += (N - i) * count;
	}

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 5760
require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

A, B, C, D = get_ints

takahashi = A
aoki = C
turn = true # takahashi
while takahashi > 0 && aoki > 0
  if turn
    aoki -= B
  else
    takahashi -= D
  end
  turn = !turn
end

puts aoki <= 0 ? 'Yes' : 'No'


Measured memory_bytes: 14452
MOD = 10**9+7

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

f = [1]
for i in range(10**5):
    f.append(f[-1] * (i+1) % MOD)

def nCr(n, r, mod=MOD):
    return f[n] * pow(f[r], mod-2, mod) * pow(f[n-r], mod-2, mod) % mod

ans = 0
for i in range(N-K+1):
    ans += (A[-1-i] - A[i]) * nCr(N-1-i, K-1)
    ans %= MOD

print(ans)


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

using namespace std;

constexpr int MOD = 1000000007;

using Long = long long;
template<typename T>
using V = vector<T>;
template<typename T>
using Vv = V<V<T>>;
using Vb = V<bool>;
using Vvb = V<Vb>;
using Vi = V<int>;
using Vvi = V<Vi>;
using Vl = V<Long>;
using Vvl = V<Vl>;
using Vd = V<double>;
using Vvd = V<Vd>;
using Vs = V<string>;

template <typename First, typename Second>
istream& operator>>(istream& is, pair<First, Second>& v);

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    for (auto& x : v) {
        is >> x;
    }
    return is;
}

template <typename First, typename Second>
istream& operator>>(istream& is, pair<First, Second>& v) {
    is >> v.first >> v.second;
    return is;
}

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    for (const auto& x : v) {
        os << x << ' ';
    }
    return os;
}

// *** SOLUTION BEGIN ***

void solve() {
    int n;
    cin >> n;
    Vi a(n);
    cin >> a;
    Vi idx(n);
    for (int i = 0; i < n; ++i) {
        idx[i] = i;
    }
    sort(begin(idx), end(idx), [&a](int x, int y) {
        return a[x] < a[y];
    });
    Vi ans(n);
    int mid = n / 2;
    for (int i = 0; i < mid; ++i) {
        ans[idx[i]] = a[idx[mid]];
    }
    for (int i = mid; i < n; ++i) {
        ans[idx[i]] = a[idx[mid - 1]];
    }
    for (int i = 0; i < n; ++i) {
        cout << ans[i] << '\n';
    }
}

// *** SOLUTION END ***

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout.precision(10);
    cout << fixed;
    solve();
    return 0;
}


Measured memory_bytes: 4608
#include <iostream>
#include<cstdio>
typedef long long ll;
using namespace std;

int a[55];
int sum[55];
ll dp[55][2505];

int main()
{
    int n,A;
    scanf("%d%d",&n,&A);
    for(int i=1;i<=n;i++) 
	{
	scanf("%d",&a[i]); sum[i]=sum[i-1]+a[i];
	}
    dp[0][0]=1;
    for(int k=1;k<=n;k++){
        for(int i=k;i>=1;i--){
            for(int j=a[k];j<=sum[k];j++){
                dp[i][j]+=dp[i-1][j-a[k]];
            }
        }
    }
    ll ans=0;
    for(int i=1;i<=n;i++) ans+=dp[i][i*A];
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 1280
#define DEBUG 0

/**
 * File    : F.cpp
 * Author  : Kazune Takahashi
 * Created : 2019-5-26 22:16:32
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <functional>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(10101010));
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

int N;
ll ans = 0;
ll s[100010];

int main()
{
  cin >> N;
  for (auto i = 0; i < N; i++)
  {
    cin >> s[i];
  }
  for (auto d = 1; d < N; d++)
  {
    ll t = 0;
    set<int> S;
    int b = 0;
    int f = N - 1;
    while (b < N && f >= 0 && b != f && f > d && S.find(b) == S.end() && S.find(f) == S.end())
    {
      t += s[b];
      t += s[f];
      S.insert(b);
      S.insert(f);
      ans = max(ans, t);
      b += d;
      f -= d;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 7808
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> IP;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)


int main() {
	string S;
	cin >> S;
	int N = S.size();
	rep(i, N) {
		if (S[i] == 'R') {
			S[i] = '0';
		}
		else if (S[i] == 'L') {
			S[i] = '1';
		}
	}
	vector<int>A(N);
	int cnt0 = 0;
	rep(i, N) {
		if (S[i] == '0') {
			cnt0++;
		}
		else if (S[i] == '1') {
			if (cnt0 == 0) {
				//NULL
			}
			else if (cnt0 != 0) {
				A[i - 1] += cnt0 - cnt0 / 2;
				A[i] += cnt0 / 2;
				cnt0 = 0;
			}
		}
	}
	S[N - 1] += cnt0;
	reverse(S);
	reverse(A);
	int cnt1 = 0;
	rep(i, N) {
		if (S[i] == '1') {
			cnt1++;
		}
		else if (S[i] == '0') {
			if (cnt1 == 0) {
				//NULL
			}
			else if (cnt1 != 0) {
				A[i - 1] += cnt1 - cnt1 / 2;
				A[i] += cnt1 / 2;
				cnt1 = 0;
			}
		}
	}
	S[N - 1] += cnt1;
	reverse(A);
	rep(i, N) {
		cout << A[i];
		if (i != N - 1) {
			cout << ' ';
		}
		else {
			cout << endl;
		}
	}
}


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

int main(void){
	long i,n,min=2,ans=0,a;
	cin >> n;
	cin >> a;
	ans+=a-1;
	for(i=1;i<n;i++){
		cin >> a;
		if(a==min){
			min++;
			continue;
		}
		ans+=(a-1)/min;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
N=int(input())
S = []
for _ in range(N):
    tmp = []
    for s in input():
        tmp.append(s)
    tmp.sort()
    S.append("".join(tmp))
dic = {}
for s in S:
    if s not in dic:
        dic[s] = 0
    dic[s] += 1
ans = 0
import math
for v in dic.values():
    if v == 1:
        continue
    p = math.factorial(v)// (math.factorial(v - 2) * math.factorial(2))
    ans += p
print(ans)

Measured memory_bytes: 19412
// tested on node version 0.10.36
var fs = require("fs");

// Note: solution is based on information from the following page 
// https://www.chilimath.com/algebra/advanced/cramers/2x2.html

/*
    determinant of 2x2 matrix
    [ a  b ]
    [ c  d ]
*/
function det(a, b, c, d) {
    return a * d - b * c;
}
/*
    ax+by=c
    dx+ey=f

    [a b] = [c]
    [d e] = [f]

    x matrix:
    [c b]
    [f e]

    y matrix:
    [a c]
    [d f]
*/
function solve_xy(a, b, c, d, e, f) {
    var D = det(a, b, d, e)
    var x = det(c, b, f, e) / D;
    var y = det(a, c, d, f) / D;
    return { x: x, y: y }
}
var input = fs.readFileSync('/dev/stdin').toString();
var lines = input.split("\n");
for(var i = 0; i < lines.length; i++) {
    var parts = lines[i].split(" ");
    var a = parseInt(parts.shift());
    var b = parseInt(parts.shift());
    var c = parseInt(parts.shift());
    var d = parseInt(parts.shift());
    var e = parseInt(parts.shift());
    var f = parseInt(parts.shift());
    if(!isNaN(a)) {
        var solution = solve_xy(a, b, c, d, e, f);
        console.log(solution.x.toFixed(3), solution.y.toFixed(3));
    }
}

Measured memory_bytes: 15548
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
int cmp(const void *a, const void *b)
{
	return *(long long*)a - *(long long*)b;//昇順
	
}


int main()
{
	long long N,i,sa=0,x;
	long long (*d) = (long long(*))
		malloc(100010* sizeof(long long));
	scanf("%lld", &N);
	for(i=0;i<N;i++)scanf("%lld", &d[i]);
	qsort(d, N, sizeof(long long), cmp);
	printf("%lld\n", d[N/2] - d[N/2-1]);
	free(d);
	return 0;
}

Measured memory_bytes: 1788
//Code by 27.
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<queue>
#include<map>
#include<stack>
#include<fstream>
#include<stdlib.h>
#include<set>
#include<climits>
#include<cmath>  
#include<memory.h> 
#include<sstream>
#include<time.h>
#include<iomanip>
using namespace std;
const unsigned long long BIGEST=1000000000000000000+1000000000000000000;
const long long BIGER=1000000000000000000;
const int BIG=1000000000;
const int MOD=1000000007;
const long long LMOD=1000000007;
long long n;
long long f[2][3];
long long I[3];
long long mx;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d%d",&I[0],&I[1],&I[2]);
		f[i%2][0]=max(f[(i+1)%2][1],f[(i+1)%2][2])+I[0];
		f[i%2][1]=max(f[(i+1)%2][0],f[(i+1)%2][2])+I[1];
		f[i%2][2]=max(f[(i+1)%2][0],f[(i+1)%2][1])+I[2];
	}
	cout<<max(max(f[n%2][0],f[n%2][1]),f[n%2][2]);
	return 0;
}

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

using namespace std;

string str;

int main() {
    string ans;
    
    cin >> str;
    for(auto s : str) {
        switch(s) {
            case '0':
            case '1':
                ans += s;
                break;
            case 'B':
                if(ans.size())
                    ans.pop_back();
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <limits>
#include <vector>
using namespace std;

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

    int n, k; cin >> n >> k;

    vector<int> h(n);
    for(int& x : h) cin >> x;


    vector<int> dp(n, numeric_limits<int>::max());
    dp[n - 1] = 0;

    for(int i = n - 2; i >= 0; --i) {
        for(int j = 1; j <= k && i + j < n; ++j) {
            dp[i] = min(dp[i], dp[i + j] + abs(h[i] - h[i + j]));
        }
    }

    cout << dp[0] << '\n';
}


Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

const int INF = 1 << 29;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
int N;
vector<int> A;
map<int, int> cnt;
int main() {
  cin >> N;
  A.resize(N);
  for (auto &val : A){
    cin >> val;
  }
  for (int i = 0; i < N; i++){
    cnt[A[i]]++;
    cnt[A[i] - 1]++;
    cnt[A[i] + 1]++;
  }
  int res = 0;
  for (const auto &val : cnt){
    res = max(res, val.second);
  }
  cout << res << endl;
  return 0;
}


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

//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 Definitions:
typedef long long ll;
typedef unsigned long long ull;

//Constants:
const int INF = 2e9;
const int MOD = 1e9 + 7;

//Global Variables:
int cnt = 0;

//Prototype Declarations:
int gcd(int, int);
void insertionSort(int*, int, int);
void shellSort(int*, int);

//================ Main Loop ================
int main() {
    int n;
    cin >> n;
    int a[n];
    rep(i, n) cin >> a[i];

    shellSort(a, n);
    cout << cnt << endl;
    rep(i, n) cout << a[i] << endl;
    return 0;
}
//===========================================

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

void insertionSort(int* a, int n, int g) {
    for(int i = g; i < n; i++) {
        int v = a[i];
        int j = i - g;
        while(j >= 0 && a[j] > v) {
            a[j + g] = a[j];
            j = j - g;
            cnt++;
        }
        a[j + g] = v;
    }
}

void shellSort(int* a, int n) {
    int G[105];
    int bf = n - 1;
    int h = 0;

    while(bf > 1) {
        G[h] = bf;
        bf = bf / 3;
        h++;
    }
    G[h] = 1;
    int m = h + 1;
    cout << m << endl;
    rep(i, m - 1) cout << G[i] << " ";
    cout << G[m - 1] << endl;

    for(int i = 0; i < m; i++) {
        insertionSort(a, n, G[i]);
    }
}


Measured memory_bytes: 7028
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define rv(s) reverse(s.begin(),s.end());
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;
 
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; }

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

int n,A,B,C;
vi l;

int rec(int i, int a, int b, int c){
  // 終端処理
  if(i==n){
    if(!a||!b||!c)return 10000;
    return abs(A-a)+abs(B-b)+abs(C-c);
  }
  
  // 材料にしない場合
  int ans=rec(i+1, a, b, c);
  
  // aまたはbまたはcの材料にする
  chmin(ans,rec(i+1, a+l[i], b, c)+(a?10:0));
  chmin(ans,rec(i+1, a, b+l[i], c)+(b?10:0));
  chmin(ans,rec(i+1, a, b, c+l[i])+(c?10:0));
  
  return ans;
}

int main()
{
  cin.tie( 0 );
  ios::sync_with_stdio( false );
  
  cin>>n>>A>>B>>C;
  l.resize(n);
  rep(i,n)cin>>l[i];
  int ans=rec(0,0,0,0);
  cout(ans);
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

const int N=1e6+5;
ll a[N],c[N],n;

int main()
{ios_base::sync_with_stdio(false);
cin>>n;
rep(i,0,n-1)cin>>a[i],c[a[i]]++;

ren(i,N-1,1)
{
	for(int j=2*i;j<=N-1;j+=i)
	c[j]+=c[i];
}
ll ans=0;
rep(i,0,n-1)
{
	//o2(a[i],c[a[i]]);on;
	if(c[a[i]]==1)
	ans++;
}
ol(ans);
return 0;
}



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

public class Main {
	static int N,M;
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		while(true){

			N=sc.nextInt();
			M=sc.nextInt();
			if(N+M==0)break;
			int[]a = new int[N+1];
			for(int i=1;i<=N;i++){
				a[i]=sc.nextInt();
			}
			int[] b = new int[(N+1)*(N+1)];
			int cnt=0;
			for(int i=0;i<a.length;i++){
				for(int j=0;j<a.length;j++){
					b[cnt]=a[i]+a[j];
					cnt++;
				}
			}
			Arrays.sort(b);
			int ans=0;
			for(int i=0;i<b.length;i++){
				if(b[i]>M)continue;
				int left=-1,right=b.length,mid=-1;
				int sum = b[i];
				while(left<right-1){
					mid=(left+right)/2;
					if(b[mid]+sum == M){
						System.out.println(M);
						return; 
					}
					else if(b[mid]+sum < M){
						left=mid;
					}
					else{
						right=mid;
					}
				}
				ans=Math.max(ans, b[left]+sum);	

			}
			System.out.println(ans);
		}

	}
}

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

#define ll long long int

using namespace std;

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n;
	cin>>n;

	int a[2*n];

	for(int i=0;i<2*n;i++)
		cin>>a[i];

	ll ans = 0;
	sort(a,a+2*n);

	for(int i=0;i<2*n;i++){
		if(i%2 == 0)
			ans+=a[i];
	}

	cout<<ans<<endl;

	return 0;

}


Measured memory_bytes: 256
/*
...........__________                                                                           ___  __
.............|       |                                                                           |   /
.............|       |                                                                           |  /
.............|       |                               |                         __                | /      _______
.............|_______|  _______            _______   |______   ________   /|  /  |               |/       |      |
.............| \               | |      | |          |      |          | / | /   |               |\       |
.............|  \       _______| |      | |_______   |      |   _______|   |/    |               | \      |
.............|   \      |      | |      |         |  |      |  |       |   |     |               |  \     |
...........__|    \__|  |______| |______| ________|  |      |_ |_______|   |     |__|           _|   \__ _|        .

*/
#include<bits/stdc++.h>
using namespace std ;
#define int                 long long
#define ull                 unsigned long long int
#define ld                  long double
#define vi                  vector<int>
#define vii                 vector<pair<int,int>>
#define vvi                 vector<vector<int>>
#define pii                 pair<int,int>
#define prec(x)             fixed<<setprecision(15)<<x
#define all(x)              x.begin(),x.end()
#define rall(x)             x.rbegin(),x.rend()
#define rev(x)              reverse(x.begin(),x.end())
#define mset(a,b)           memset(a,b,sizeof(a))
#define mcpy(a,b)           memcpy(a,b,sizeof(a))
#define fo0(i,n)            for(int i=0,i##end=n;i<i##end;i++)
#define fo1(i,n)            for(int i=1,i##end=n;i<=i##end;i++)
#define fo(i,a,b)           for(int i=a,i##end=b;i<=i##end;i++)
#define foe(i,x)            for(__typeof((x).end())i=(x).begin();i!=(x).end();++i)
#define fre(i,x)            for(__typeof((x).rend())i=(x).rbegin();i!=(x).rend();++i)
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0)
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
#define inf 1e18
const int mod=1e9+7;
const int N=2e5+9;
int a[N],b[N];

void raushan_kumar(){

    //variables
    int d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m,n,o=0,p=0,q=0,r=0,u=0,v=0,w=0,x=0,y=0,z=0,s=0,t=0;
    double f1=0.0,f2=0.0,f3=0.0,f4=0.0,f5=0.0,f6=0.0;
    int flag=0,ans=0,res=0,cnt=0;

    cin>>n;
    fo1(i,n){
        if(i%3==0){

        }
        else if(i%5==0){

        }
        else if(i%3==0 and i%5==0){

        }
        else{
            res+=i;
        }
    }
    cout<<res;
    
}

int32_t main()
{
    fast;int t=1;
    //cin>>t;
    while(t--){
        raushan_kumar();
    }

}


Measured memory_bytes: 3692
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define MIN(a,b) ((a) <= (b) ? (a) : (b))
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort( ALL(v) )

using namespace std;
using ll = long long;
using P = pair<int,int>;

int main()
{

   ll n ; cin >> n;
   ll blue , red; cin >> blue>>red;

   if((blue+red)==n)
   {
       cout<<blue<<endl;
       return 0;
   }
   else if(blue == 0 )
   {
       cout<< 0 << endl;
       return 0;
   }

   ll num = 0 ;
   ll mult = n/(blue+red);
   ll rest = n%(blue+red);

   num = blue*mult;
   if(rest<blue)num+=rest;
   else num+=blue;

   cout << num << endl;


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(int argc, const char * argv[]) {
    int n,v,j;cin>>n;
    int A[n+1];
    for(int i=0;i<n;i++)cin>>A[i];
    for(int i=0;i<n-1;i++)cout<<A[i]<<' ';cout<<A[n-1]<<endl;
    for(int i=1;i<n;i++){
        v = A[i];
        j = i -1;
        while(j>=0 && A[j]>v){
            A[j+1] = A[j];
            j--;
        A[j+1] = v;
        }
        for(int i=0;i<n-1;i++)cout<<A[i]<<' ';cout<<A[n-1]<<endl;
    }
}



Measured memory_bytes: 3120
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int a = scan.nextInt();
		int ma = 0;
		int[] x = new int[n+1];
		for (int i = 0; i < n; i++) {
			x[i] = scan.nextInt();
			ma = Math.max(a, x[i]);
			x[i] = x[i] - a;
		}
		long[][] dp = new long[n+1][2*n*ma+1];
		dp[0][n*ma] = 1;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j <= 2*n*ma; j++) {
				dp[i+1][j] += dp[i][j];
				if (0 <= (j-x[i]) && (j-x[i]) <= 2*n*ma) dp[i+1][j] = dp[i][j] + dp[i][j-x[i]];
			}
		}
		System.out.println(dp[n][n*ma]-1);
	}
}


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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;


int main(){

    string s;
    cin >> s;

    int ans = 700;
    for(int i = 0; i < 3; i++){
        if(s[i] == 'o') ans += 100;
    }
    cout << ans << endl;
    
    return 0;
}

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

namespace ABC
{
    class ABC096B
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int A = int.Parse(str[0]);//
            int B = int.Parse(str[1]);//
            int C = int.Parse(str[2]);//
            int K = int.Parse(Console.ReadLine());//回数K

            int ans = AssumeSum(A, B, C, K);

            Console.WriteLine("{0}", ans);
        }

        static int AssumeSum(int A, int B, int C, int K)
        {
            //全数探索だと3^K回
            //最大値は、3つのうちのどれかを常に最大にし続ければいい
            var ary = new List<int> { A, B, C };
            for (int i = 0; i < K; ++i)
            {
                int maxIdx = getMaxIdx(ary);
                ary[maxIdx] *= 2;
            }
            return ary[0] + ary[1]+ary[2];
        }
        static int getMaxIdx(List<int> ary) {
            int m = Math.Max(Math.Max(ary[0], ary[1]), ary[2]);
            return ary.FindIndex(x => x == m);
        }
    }
}


Measured memory_bytes: 13268
#pragma GCC optimize ("-O3")
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
using namespace std;

#define all(c) (c).begin(),(c).end()
#define endl "\n"
#define ff first
#define ss second
#define allr(c) (c).rbegin(),(c).rend()
#define ifr(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define pof pop_front
#define pob pop_back
#define pb emplace_back
#define pf emplace_front
#define fstm(m,n,r) m.reserve(n);m.max_load_factor(r)
#define mp make_pair
#define mt make_tuple
#define inf LLONG_MAX
#define os tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
//order_of_key (k) : Number of items strictly smaller than k .
//find_by_order(k) : K-th element in a set (counting from zero).
const double PI = acos(-1);
typedef complex<double> cd;
typedef long long ll;
ll gcd(){return 0ll;} template<typename T,typename... Args> T gcd(T a,Args... args) { return __gcd(a,(__typeof(a))gcd(args...)); }
typedef map<ll,ll> mll;
typedef map<string,ll> msll;
typedef unordered_map<ll,ll> umap;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef long double ld;
#define mod 1000000007 
#define N 100001

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n;
    cin>>n;
    ll a[n];
    ifr(i,0,n) cin>>a[i];
    ll dp[n][n][2];
    ifr(i,0,n) ifr(j,0,n) ifr(t,0,2) dp[i][j][t]=0;
    ifr(i,0,n) {
        dp[i][i][0]=a[i];
        dp[i][i][1]=-a[i];
    }
    for(int i=n-2;i>=0;i--) {
        for(int j=i+1;j<n;j++) {
            dp[i][j][0] = max(dp[i+1][j][1]+a[i],dp[i][j-1][1]+a[j]);
            dp[i][j][1] = min(dp[i+1][j][0]-a[i],dp[i][j-1][0]-a[j]);
        }
    }
    cout<<dp[0][n-1][0]<<endl;
    return 0;
}

Measured memory_bytes: 140928
N, S = gets.split.map(&:to_i)
A = gets.split.map(&:to_i)
MOD = 998244353

dp = Array.new(N + 1) { Array.new(S + 1, 0) }
dp[0][0] = 1

A.each_with_index do |a, i|
  S.downto(0) do |s|
    next if dp[i][s] <= 0

    dp[i + 1][s] += (2 * dp[i][s]) % MOD

    if s + a <= S
      dp[i + 1][s + a] += dp[i][s]
      dp[i + 1][s + a] %= MOD
    end
  end
end

puts dp[N][S]


Measured memory_bytes: 84712
#include <bits/stdc++.h>
#define mem(ar,num) memset(ar,num,sizeof(ar))
#define me(ar) memset(ar,0,sizeof(ar))
#define lowbit(x) (x&(-x))
#define Pb push_back
#define  FI first
#define  SE second
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define IOS ios::sync_with_stdio(false)
#define DEBUG cout<<endl<<"DEBUG"<<endl;
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const int    prime = 999983;
const int    INF = 0x7FFFFFFF;
const LL     INFF = 0x7FFFFFFFFFFFFFFF;
const double pi = acos(-1.0);
const double inf = 1e18;
const double eps = 1e-6;
const LL     mod = 1e9 + 7;
LL qpow(LL a, LL b) {LL s = 1; while (b > 0) {if (b & 1)s = s * a % mod; a = a * a % mod; b >>= 1;} return s;}
LL gcd(LL a, LL b) {return b ? gcd(b, a % b) : a;}
int dr[2][4] = {1, -1, 0, 0, 0, 0, -1, 1};
typedef pair<int, int> P;
int main(void)
{
	int N, A, B;
	cin >> N >> A >> B;
	cout << min(N * A, B) << endl;


	return 0;
}

Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {

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

  static void solve(InputStream is, PrintStream os) {
    Scanner sc = new Scanner(is);

    /* read */
    int n = sc.nextInt();
    Map<String, Integer> map = new HashMap<>();

    for (int i = 0; i < n; i++) {
      String s = sc.next();
      List<String> list = new ArrayList<>(s.length());
      for (int j = 0; j < s.length(); j++) {
        list.add("" + s.charAt(j));
      }
      Collections.sort(list);
      String sorted = String.join("", list);
      map.put(sorted, map.getOrDefault(sorted, 0) + 1);
    }

    long ans = 0;
    for (String s : map.keySet()) {
      int occur = map.get(s);
      if (occur > 1) {
        ans += combination(occur, 2);
      }
    }
    os.println(ans);
  }

  private static long combination(long n , long k) {
    long ans = 1;
    for (long i = 1; i <= k; i++) {
      ans *= (n - i + 1);
      ans /= i;
    }
    return ans;
  }
}

Measured memory_bytes: 97644
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pdi = pair<double,int>;
const double PI = acos(-1);

double solve() {
    ll N, ix;
    cin >> N;
    double th;
    ll x,y;
    vector<pdi> mv;
    vector<ll> X(N), Y(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> x >> y;
        X[i] = x;
        Y[i] = y;
        th = atan2(y,x);
        mv.push_back(pdi(th,i));
    }
    sort(mv.begin(), mv.end());
    for ( int i = 0; i < N; i++ ) {
        auto v = pdi(mv[i]);
        mv.push_back(v);
    }
    double ans = (double)0;
    int M = 2*N+1;
    vector<ll> cx(M);
    vector<ll> cy(M);
    for ( int k = 0; k < 2*N; k++ ) {
        int j = mv[k].second;
        cx[k+1] = cx[k] + X[j];
        cy[k+1] = cy[k] + Y[j];
    }
    for ( int l = 0; l < N; l++ ) {
        for ( int r = l + 1; r <= l + N; r++ ) {
            double xx = cx[r] - cx[l];
            double yy = cy[r] - cy[l];
            double d = sqrt(xx*xx+yy*yy);
            if ( ans < d ) ans = d;
        }
    }
    return ans;
}

int main() {
    auto ans = solve();
    cout.precision(15);
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

int gcd(int n, int m) {
    if(n < m) {
        return gcd(m, n);
    }
    int r;
    while((r = n % m)) {
        n = m;
        m = r;
    }
    return m;
}

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

    int sum = 0;
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= n; j++) {
            for(int k = 1; k <= n; k++) {
                sum += gcd(i, gcd(j, k));
            }
        }
    }

    std::cout << sum << std::endl;
}


Measured memory_bytes: 3640
#ifdef LOCAL111
#else
	#define NDEBUG
#endif
#include <bits/stdc++.h>
const int INF = 1e8;
using namespace std;

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define RBP(i,a) for(auto& i : a)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
#define rangej(a,b,c) ((a) <= (c) and (c) < (b))
#define rrangej(b,c) rangej(0,b,c)
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;
typedef pair<LL,LL> LP;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);	
}

int main()
{
	ios_init();
	LL a[3];
	cin >> a[0] >> a[1] >> a[2];
	if(a[0]%2 == 0 or a[1]%2 == 0 or a[2]%2 == 0){
		cout << 0 << endl;
	}else{
		sort(a,a+3);
		cout << a[0]*a[1] << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <string>

using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)

char s[300001];
ll E[300001] = {};
ll W[300001] = {};

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

	repe(i, 1, N) {
		W[i] += W[i - 1] + ((s[i - 1] == 'W') ? 1 : 0);
	}
	for (int i = N; i > 0; i--) {
		E[i] += E[i + 1] + ((s[i - 1] == 'E') ? 1 : 0);
	}

	ll minV = 1 << 29;
	repe(i, 1, N) {
		minV = min(W[i] + E[i] - 1, minV);
	}

	cout << minV << endl;
	return 0;
}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
typedef vector<pii> vp;
typedef vector<tiii> vt;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//cout << fixed << setprecision(10);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main () {
  int n, k;
  cin >> n >> k;
  vi h(n);
  rep(i,n) cin >> h[i];
  
  vi dp(n+1,INF);
  dp[0] = 0;
  rep(i,n) {
    rrep(j,k) {
      //if (i+j > n) continue;
      chmin(dp[i+j], dp[i]+abs(h[i]-h[i+j]));
    }
  }

  cout << dp[n-1] << endl;
  return 0;
}

Measured memory_bytes: 1024
S = input()
voc=['dream','dreamer','erase','eraser']
S = S[::-1]
newvoc=[]
for v in voc:
    newvoc.append(v[::-1])
can1= True
i=0
while i<len(S):
    can2 = False
    for v in newvoc:
        if S[i:i+len(v)] == v:
            can2 = True
            i+= len(v)
            break
    if not can2:
        can1= False
        break
if can1:
    print("YES")
else:
    print("NO")  

Measured memory_bytes: 3188