akhauriyash/Code-Regression huggingface dataset:
main :: IO ()
main = do
  n <- readLn
  print $ g n

f :: Int -> [(Int,Int)]
f n = [(x, n-x) | x <- [1..((n+1) `div` 2)]]

sod
  :: Int -> Int
sod n
  | n `elem` [10^p | p <- [1..5]] = 10 -- 100 = 50+50 case 
  | otherwise = sum $ sod' n

sod' 
  :: Int -> [Int]
sod' n
  | q == 0 = [r] 
  | otherwise = r : sod' q
  where
    (q,r) = quotRem n 10

sod2 :: Int -> Int -> Int
sod2 x y = sod x + sod y

g :: Int -> Int
g = minimum . map (uncurry sod2) . f

Measured memory_bytes: 892
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;

void f(vector<string>& t, vector<vector<int>>& bi, int i, int j, int bnum, int h,int w){
  int di[]={1,0,-1,0};
  int dj[]={0,1,0,-1};
  bi[i][j]=bnum;
  REP(k,4){
    int ni=i+di[k];
    int nj=j+dj[k];
    if(ni<0||nj<0||ni>=h||nj>=w)continue;
    if(t[i][j]!=t[ni][nj])continue;
    if(bi[ni][nj]!=-1)continue;
    f(t,bi,ni,nj,bnum,h,w);
  }
}

int main() {
  while(1){
    int w,h;
    cin>>w>>h;
    if(!w)break;
    vector<string> t(h);
    REP(i,h) cin>>t[i];
    int n = 0;
    vector<vector<int>> bi(h,vector<int>(w,-1));
    vector<int> bmass;
    vector<double> bxsum;
    REP(i,h)REP(j,w){
      if(t[i][j] != '.'){
        if(bi[i][j]==-1){
          f(t,bi,i,j,n++,h,w);
          bmass.push_back(0);
          bxsum.push_back(0);
        }
        ++bmass[bi[i][j]];
        bxsum[bi[i][j]]+=j+0.5;
      }
    }
    vector<int> xmn(n,11),xmx(n,0),rt(n);
    REP(i,h){
      REP(j,w){
        if(t[i][j] != '.'){
          if(i!=h-1 && t[i+1][j] != '.' && t[i][j] != t[i+1][j]){
            int bid=bi[i][j];
            xmn[bid]=min(xmn[bid], j);
            xmx[bid]=max(xmx[bid], j+1);
            rt[bid]=bi[i+1][j];
          }else if(i==h-1){
            int bid=bi[i][j];
            xmn[bid]=min(xmn[bid], j);
            xmx[bid]=max(xmx[bid], j+1);
            rt[bid]=-1;
          }
        }
      }
    }
    bool stable = true;
    REP(i,n){
      double grx = bxsum[i]/bmass[i];
      if(grx <= xmn[i] || xmx[i] <= grx) {
        stable = false;
        break;
      }
      if(rt[i]>0){
        bmass[rt[i]] += bmass[i];
        bxsum[rt[i]] += bxsum[i];
      }
    }
    if(stable)
      cout<<"STABLE"<<endl;
    else
      cout<<"UNSTABLE"<<endl;
  }
  return 0;
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
#define int long long int
#define ld long double
#define pb push_back
#define pf push_front
#define ft first
#define sc second
#define all(v) v.begin(), v.end()
using namespace std;
const int maxn = 201001;
signed main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int h, w;
    cin >> h >> w;
    if (h == 1 || w == 1) {
        cout << 1;
        return 0;
    }
    cout << (h * w + 1) / 2;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <math.h>    //pow(x,y)=x^y 99999とかの場合+1するif文
#include <algorithm> //sort(a.begin(), a.end());reverse(a.begin(), a.end());
#include <ctime>     //実行時間を測る
#define ll long long
#define vecvec(h,w,name) vector<vector<ll>> name(h, vector<ll>(w));
#define rep(init, i, n) for (ll i = init; i < (n); i++)
#define rev(s) reverse(s.begin(), s.end())
#define sor(v) sort(v.begin(), v.end())
#define PI 3.14159265358979323846264338327950L
//コード自動整形 Shift + Option + F @vscode
//変数名一括置換　command+fn+f2 @vscode
using namespace std;
using vec = vector<ll>;
//function
ll facctorialMethod(ll k);     //階乗を出力する
ll modpow(ll a, ll n, ll mod); // a^n mod を計算する
//

//struct
// UnionFind
// coding: https://youtu.be/TdR816rqc3s?t=726
// comment: https://youtu.be/TdR816rqc3s?t=6822
struct UnionFind
{
  vector<ll> d;
  UnionFind(ll n = 0) : d(n, -1) {}
  ll find(ll x)
  { //根っこを返す
    if (d[x] < 0)
      return x;
    return d[x] = find(d[x]); //根っこの場所を貼り付ける
  }
  bool unite(ll x, ll y)
  { //くっつける操作、連結成分の情報整理 ABC177,157D参照
    x = find(x);
    y = find(y);
    if (x == y)
      return false;
    if (d[x] > d[y])
      swap(x, y); //dはマイナスをかけたサイズだからxの方がサイズ小さいようにする
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(ll x, ll y) { return find(x) == find(y); } //同じ集合に属しているかを判定
  ll size(ll x) { return -d[find(x)]; }                //あるID、xが所属するグループに所属するIDの数を得る ABC177,157D参照
};
//

/////main/////
int main()
{
  int clock_on = 0; //提出時は0!!!!!!!!!!!!!!!!!
  int time_clock = clock();
  //
	ll a,b;
  cin>>a>>b;
  cout<<a*b<<endl;
  //
  if (clock_on == 1)
    printf("Execution Time: %.4lf sec\n", 1.0 * (clock() - time_clock) / CLOCKS_PER_SEC);
  return 0;
}
/////main/////

/////function/////
//階乗を出力する
ll facctorialMethod(ll k)
{
  ll sum = 1;
  for (ll i = 1; i <= k; ++i)
  {
    sum *= i;
  }
  return sum;
}

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

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

using namespace std;

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

template<typename T> ostream& operator << (ostream& os, vector<T> v) {
  for (auto& i : v) os << i << " "; return os; 
}
template<typename T> istream& operator >> (istream& is, vector<T>& v) {
  for (auto& i : v) is >> i; return is;
}
template<typename K, typename V> ostream& operator << (ostream& os, unordered_map<K, V> m) {
  for (auto& i : m) os << i.first << ":" << i.second << endl; return os;
}
template<typename T> inline bool chmin(T& x, T y) {
  if (x > y) {
    x = y;
    return true;
  }
  return false;
}
template<typename T> inline bool chmax(T& x, T y) {
  if (x < y) {
    x = y;
    return true;
  }
  return false;
}

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  cin >> a;
  int res = 0;
  for (int i=1; i<n-1; i++) {
    int mi = min(a[i-1], a[i+1]);
    int ma = max(a[i-1], a[i+1]);
    if (mi < a[i] && a[i] < ma) res++;
  }
  cout << res << endl;
  return 0;
}


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

int main(){
    string str;
    bool flag=false;
    cin >> str;
    sort(str.begin(),str.end());
    if(str.at(0)==str.at(1)){
        if(str.at(2)==str.at(3)){
            if(str.at(1)!=str.at(2)){
                flag=true;
            }
        }
    }
    if(flag) cout << "Yes" <<endl;
    else cout <<"No" << endl;
    return 0;
}


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

int main() {
    int N;
    cin >>N;
    double a;
    vector<double>data(N);
    for(int i=0;i<N;i++)cin >>data[i];
    sort(data.begin(),data.end());
    for(int i=2;i<N;i++){
        a=(data[0]+data[1])/2;
        data[0]=a;
        data[1]=data[i];
    } 
    cout <<(data[0]+data[1])/2<<endl;

}

Measured memory_bytes: 256
#include <stdio.h>
#define MOD 1000000007
#define SAISHO  1
#define TATE    2
#define YOKO    3
static char s1[53], s2[53];
static int n, prev = SAISHO;
static long sum = 1;
void f(int x) {
    sum = sum * x % MOD;
}
int main(void) {
    int i;
    scanf("%d%s%s", &n, s1, s2);
    for (i = 0; i < n; ++i) {
        if (s1[i] == s2[i]) {
            if (prev == SAISHO)
                f(3);
            else if (prev == TATE)
                f(2);
            else if (prev == YOKO)
                f(1);
            prev = TATE;
        } else {
            if (prev == SAISHO)
                f(6);
            else if (prev == TATE)
                f(2);
            else if (prev == YOKO)
                f(3);
            prev = YOKO;
            ++i;
        }
    }
    printf("%ld\n", sum);
    return 0;
}


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

int main()
{
  int n, m, e, j;
  while(1)
  {
    cin >> n;
    if(!n)
      break;

    for(int i = 0; i < n ; i++)
    {
      cin >> m >> e >> j;
      if((m + e) / 2 >= 90 || m == 100 || e == 100 || j == 100 || (m + e + j) / 3 >= 80)
        cout << 'A' << endl;
      else if((m + e + j) / 3 >= 70 || (m + e + j) / 3 >= 50 && (m >= 80 || e >= 80))
        cout << 'B' << endl;
      else
        cout << 'C' << endl;
    }
  }
}

Measured memory_bytes: 1152
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <cassert>
#include <string>
#include <memory.h>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <set>
#include <map>
#include <cctype>
#include <iomanip>
#include <sstream>
#include <cctype>
#include <fstream>
#include <cmath>
using namespace std;

#define REP2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define REP(i, n) REP2(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
#define ITER(c) __typeof((c).begin())
#define PB(e) push_back(e)
#define FOREACH(i, c) for(ITER(c) i = (c).begin(); i != (c).end(); ++i)
#define MP(a, b) make_pair(a, b)
#define PARITY(n) ((n) & 1)

typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1000 * 1000 * 1000 + 7;
const double EPS = 1e-10;

int main(){
  int N, M;
  cin >> N >> M;
  vector<string> field(N);
  REP(i, N) cin >> field[i];
  
  vector<int> rows;
  vector<int> cols;
  
  REP(i, N)REP(j, M)if(isalpha(field[i][j])){
    REP(k, 3){
      rows.push_back(i+k-1);
      cols.push_back(j+k-1);
    }
  }

  sort(ALL(rows));
  sort(ALL(cols));
  rows.erase(unique(ALL(rows)), rows.end());
  cols.erase(unique(ALL(cols)), cols.end());
  
  vector<string> board(rows.size(), string(cols.size(), '.'));
  
  REP(i, N)REP(j, M)if(isalpha(field[i][j])){
    int r = lower_bound(ALL(rows), i) - rows.begin();
    int c = lower_bound(ALL(cols), j) - cols.begin();
    board[r][c] = field[i][j];
  }
  
  N = rows.size();
  M = cols.size();
  
  int res = 0;
  int dr[4] = {0, -1, 0, 1};
  int dc[4] = {1, 0, -1, 0};
  bool update = true;
  
  while(update){
    update = false;
    
    REP(r, N)REP(c, M)if(board[r][c] == '.'){
      vector<int> t_row;
      vector<int> t_col;
      REP(i, 4){
        int r2 = r + dr[i];
        int c2 = c + dc[i];
        while(0 <= r2 && r2 < N && 0 <= c2 && c2 < M && board[r2][c2] == '.'){
          r2 += dr[i];
          c2 += dc[i];
        }
        
        if(0 <= r2 && r2 < N && 0 <= c2 && c2 < M){
          t_row.push_back(r2);
          t_col.push_back(c2);
        }
        
        REP(i, 26){
          int c = 0;
          REP(j, t_row.size()) if(board[t_row[j]][t_col[j]] == 'A' + i) c++;
          if(c >= 2){
            update = true;
            res += c;
            REP(j, t_row.size()){
              char &tile = board[t_row[j]][t_col[j]];
              if(tile == 'A' + i) tile = '.';
            }
          }
        }
      }
    }
  }
  
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 1532
// clang-format off
	#include <bits/stdc++.h>
	using namespace std; using ll = long long; using uint = unsigned int;
	#define SFINAE(x, ...)	template <class, class = void> struct x : false_type {}; template <class T> struct x<T, void_t<__VA_ARGS__>> : true_type {};
	SFINAE(DefaultIO, decltype(cout << declval<T &>()))
	SFINAE(IsTuple, typename tuple_size<T>::type)
	SFINAE(Iterable, decltype(begin(declval<T>())))
	template <class T> constexpr char Space(const T &) { return (Iterable<T>::value or IsTuple<T>::value) ? '\n' : ' '; }
	template <auto &os> struct Writer {
		template <class T> void Impl(T const &t) const {
			if constexpr (DefaultIO<T>::value) os << t;
			else if constexpr (Iterable<T>::value) { int i = 0; for (auto &&x : t) ((i++) ? (os << Space(x), Impl(x)) : Impl(x)); }
			else if constexpr (IsTuple<T>::value) apply([this](auto const &... args) { int i = 0; (((i++) ? (os << ' ', Impl(args)) : Impl(args)), ...);}, t);
			else static_assert(IsTuple<T>::value, "No matching type for print");
		}
		template <class F, class... Ts> auto &operator()(F const &f, Ts const &... ts) const { return Impl(f), ((os << ' ', Impl(ts)), ...), os << '\n', *this; }
	};
	template <auto &is> struct Reader {
		template <class T> auto& operator()(T &t) const {
			if constexpr (DefaultIO<T>::value) is >> t;
			else if constexpr (Iterable<T>::value) for (auto &x : t) (*this)(x);
			else if constexpr (IsTuple<T>::value) apply([this](auto &... args) { ((*this)(args), ...); }, t);
			else static_assert(IsTuple<T>::value, "No matching type for read");
			return *this;
		}
		template <class T> auto operator[](T t) const { (*this)(t); return t; }
	};
	#ifdef NARUT_LOCAL
	#define Debug(...) cerr << "\033[0;31m", Writer<cerr>{}(__VA_ARGS__), cerr << "\033[0m\n"
	#else
	#define Debug(...) 0
	#endif
	[[maybe_unused]] constexpr Reader<cin> Cin; [[maybe_unused]] constexpr Writer<cout> Cout;
	#define FOR(i, j, n) for (int i = int(j); i < int(n); ++i)
	#define ROF(i, j, n) for (int i = int(n) - 1; i >= int(j); --i)
// clang-format on





auto Main() {
	int x;
	cin>>x;
	auto c = (x-400)/200;
	cout << 8-c;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << fixed << setprecision(10);
#ifdef NARUT_LOCAL
	assert(freopen("io/test.in", "r", stdin));
	cin.exceptions(cin.badbit | cin.failbit);
	cerr << fixed << setprecision(10);
#endif

	Main();
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;

#define ll long long
const long long llINF = 1LL << 60;
const int iINF = 0x20000000;
template<class T> inline bool chmin(T& a, T b) { if (b < a) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

void execute();
int main() 
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);// cin と scanfの併用禁止
    cout << fixed << setprecision(15);
    execute();
    return 0;
}


void execute()
{
    string s;
    cin >> s;

    int l = s.size();

    cout << s << (s[l-1]== 's' ? "es" : "s") << endl; 
}


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

//int sieve[9999999];

int main()
{
    ///BISMILLAHIR RAHMANIR RAHIM
   string s;
   cin>>s;
   for(int i=0;i<3;i++)
    cout<<s[i];
   cout<<endl;
    /// A L H A M D U L I L L A H
}


Measured memory_bytes: 3624
def ans3_2():
    hasAnswer = False
    N, Y = map(int, input().split(" "))
    for x in range(Y // 10000 + 1):
        if hasAnswer == True: break
        for y in range((Y - x * 10000) // 5000 + 1):
            z = (Y - 10000 * x - 5000 * y) // 1000
            if z >= 0 and x + y + z == N:
                print(x, y, z, sep=" ")
                hasAnswer = True
                break
    if hasAnswer == False:
        print(-1, -1, -1, sep=" ")

ans3_2()

Measured memory_bytes: 3060
#include<string>
#include<iostream>
#include<cctype>
using namespace std;
typedef long long ll;
typedef string::const_iterator State;

ll d[3];

ll number(State &begin) {
  ll ans = 0;
  while (isdigit(*begin)) ans = ans * 10 + (*begin - '0'), begin++;
  return ans;
}

ll first(State &begin);

ll check(State &begin) {
  if (isdigit(*begin)) return number(begin);
  begin++;
  ll ans = first(begin);
  begin++;
  return ans;
}

ll third(State &begin) {
  ll ans = check(begin);
  while (1) {
    if (*begin == '*' && d[0] == 2) begin++, ans *= check(begin);
    else if (*begin == '+' && d[1] == 2) begin++, ans += check(begin);
    else if (*begin == '-' && d[2] == 2) begin++, ans -= check(begin);
    else return ans;
  }
}

ll second(State &begin) {
  ll ans = third(begin);
  while (1) {
    if (*begin == '*' && d[0] == 1) begin++, ans *= third(begin);
    else if (*begin == '+' && d[1] == 1) begin++, ans += third(begin);
    else if (*begin == '-' && d[2] == 1) begin++, ans -= third(begin);
    else return ans;
  }
}

ll first(State &begin) {
  ll ans = second(begin);
  while (1) {
    if (*begin == '*' && d[0] == 0) begin++, ans *= second(begin);
    else if (*begin == '+' && d[1] == 0) begin++, ans += second(begin);
    else if (*begin == '-' && d[2] == 0) begin++, ans -= second(begin);
    else return ans;
  }
}

int main() {
  string s;
  cin >> s;
  State begin = s.begin();
  ll ans = first(begin);
  for (ll i = 0; i < 3; i++) for (ll j = 0; j < 3; j++) for (ll k = 0; k < 3; k++) {
    d[0] = i, d[1] = j, d[2] = k;
    State begin = s.begin();
    //cout << first(begin) << endl;
    //begin = s.begin();
    ans = max(ans, first(begin));
  }
  cout << ans << endl;
}



Measured memory_bytes: 3216
f=lambda:map(int,input().split())
n,k=f()
l=list(f())
v=0
m=min(n,k)
from bisect import *
for i in range(m+1):
  for j in range(m+1-i):
    s=sorted(l[:i]+l[n-j:])
    v=max(v,sum(s[min(bisect_left(s,0),k-i-j):]))
print(v)

Measured memory_bytes: 3060
N = int(input())
X = list(map(int, input().split()))
X0 = X[::]
X.sort()
num = int(N / 2 - 1)  # index は num
ans0, ans1 = X[num], X[num + 1]
for i in range(N):
    if X0[i] > ans0:
        print(ans0)
    else:
        print(ans1)


Measured memory_bytes: 25220
#include <cstdio>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
using namespace std;

typedef vector<int> vi;

static inline void p(int x) { printf("%d\n", x); }

int main()
{

	int n, cnt = 0;
	scanf("%d", &n);

	vi A(n), G;
	for (int &x: A)
		scanf("%d", &x);

	for (int i = 1, x = 1; x <= n; x = (pow(3, ++i) - 1) / 2)
		G.push_back(x);
	reverse(G.begin(), G.end());

	for (int g: G)
		for (int i = g; i < n; i++) {
			int v = A[i], j = i - g;
			for(; j >= 0 && A[j] > v; j -= g)
				A[j+g] = A[j], cnt++;
			A[j+g] = v;
		}

	p(G.size());
	for (int &x: G)
		printf("%s%d", (&x == &G[0] ? "" : " "), x);
	puts("");
	p(cnt);
	for (int x: A)
		p(x);
}


Measured memory_bytes: 6300
while(1):
    h = int(input())
    if not h:
        break
    a = [[] for j in range(h)]
    for i in range(h):
        a[i] = [int(i) for i in input().split()]
    ans = 0
    disap = True
    fall = True
    while(disap):
        while(disap):
            disap = False
            for i in range(h):
                if a[i][0] and all([a[i][k] == a[i][k+1] for k in range(4)]):
                    ans += a[i][0]*5
                    for k in range(5):
                        a[i][k] = 0
                    disap = True
                    fall = True
                elif a[i][0] and all([a[i][k] == a[i][k+1] for k in range(3)]):
                    ans += a[i][0]*4
                    for k in range(4):
                        a[i][k] = 0
                    disap = True
                    fall = True
                elif a[i][1] and all([a[i][k+1] == a[i][k+2] for k in range(3)]):
                    ans += a[i][1]*4
                    for k in range(4):
                        a[i][k+1] = 0
                    disap = True
                    fall = True
                elif a[i][0] and all([a[i][k] == a[i][k+1] for k in range(2)]):
                    ans += a[i][0]*3
                    for k in range(3):
                        a[i][k] = 0
                    disap = True
                    fall = True
                elif a[i][1] and all([a[i][k+1] == a[i][k+2] for k in range(2)]):
                    ans += a[i][1]*3
                    for k in range(3):
                        a[i][k+1] = 0
                    disap = True
                    fall = True
                elif a[i][2] and all([a[i][k+2] == a[i][k+3] for k in range(2)]):
                    ans += a[i][2]*3
                    for k in range(3):
                        a[i][k+2] = 0
                    disap = True
                    fall = True
        while(fall):
            fall = False
            for i in range(1, h):
                for j in range(5):
                    if a[i][j] == 0 and a[i-1][j]:
                        a[i][j], a[i-1][j] = a[i-1][j], a[i][j]
                        fall = True
                        disap = True
    print(ans)


Measured memory_bytes: 5640
#include <bits/stdc++.h>
using namespace std;
int main() {
	string s; cin >> s;
  	int a = stoi(s.substr(0,4));
  	int b = stoi(s.substr(5,2));
  	int c = stoi(s.substr(8,2));
  	if (a < 2019) cout << "Heisei" << endl;
 	else {
     	if (a > 2019) {
         	cout << "TBD" << endl; 
        }
      	else {
         	if (b < 4) cout << "Heisei" << endl;
          	else {
             	if (b > 4) cout << "TBD" << endl;
              	else {
					if (c <= 30) cout << "Heisei" << endl;
                  	else cout << "TBD" << endl;
                }
            }
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int ans,n,m,a[100010],b[100010],dp[100010];
vector < int > adj[100010];
bool visit[100010];
int dfs(int x)
{
	if(dp[x]!=-1) return dp[x];
	dp[x] = 1;
	for(int i=0;i<adj[x].size();i++)
	{
		dp[x] = max(dp[x],1+dfs(adj[x][i]));
	}
	return dp[x];
}
int main()
{
	scanf("%d %d",&n,&m);
	for(int i=0;i<m;i++)
	{
		scanf("%d %d",&a[i],&b[i]);
		adj[a[i]].push_back(b[i]);
	}
	for(int i=1;i<=n;i++) dp[i] = -1;
	ans = 1;
	for(int i=1;i<=n;i++)
	{
		ans = max(ans,dfs(i));
	}
	printf("%d\n",ans-1);
	return 0;
}

Measured memory_bytes: 8960
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <string>
#include <iomanip>
#include <stdio.h>
#include <cstring>
#include <random>
#include <chrono>
#include <bitset>
#include <fstream>
#include <sstream>

using namespace std;

typedef long long ll;
typedef long double ld;

ll big = 1000000007ll;
float likeabutterfly;
string likeabee;
ll n,m,q,h,k,w;
ll T;

vector<ll> A;

int main()
{
    ll c1,c2,c3,c4,c5,c6;
    ll a,b,c,e,g;
    ll x,y,z;
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);


    cin >> n;

    ll sn = 0;
    for(c1 = 0; c1 < n; c1++){
        cin >> a;
        A.push_back(a);
        sn += a;
    }
    A.push_back(0);
    ll odd = 0;
    ll odds = 0;
    for(c1 = 0; c1 <= n; c1++){

        if(A[c1] == 0){
            odds += odd%2;
            odd = 0;
        }
        odd += A[c1];
    }
    cout << (sn-odds)/2 << "\n";

	return 0;
}




Measured memory_bytes: 1400
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int N = sc.nextInt();
	
		int a = 0 ;
		for ( int i = 0 ; i < N ; i++) a += sc.nextInt();
		if(a >= H) System.out.println("Yes");
		else System.out.println("No");
	}
}


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

vector< vector<int> > g(301, vector<int>(301,-1) );

void setval( int x0, int y0, int x1, int y1, int val ) {
  for ( int y=y0; y<=y1; ++y ) {
    for ( int x=x0; x<=x1; ++x ) {
      g[y][x] = val;
    }
  }
}

int main() {
  int H,K,W;
  cin >> H >> W >> K;
  vector< string > s(H);
  REP(i,H) {
    cin >> s[i];
  }

  int x0 = 0;
  int y0 = 0;
  int n = 1;
  REP(y,H) {
    x0 = 0;
    REP(x,W) {
      if ( s[y][x] == '#' ) {
        setval(x0,y0, x,y,n++);
        x0 = x+1;
      }
    }
    if ( x0 != 0 && x0 != W ) {
      setval(x0,y0,W-1,y,n-1);
    }
    if ( x0 != 0 ) y0=y+1;
  }
  REP(y,H) {
    if ( g[y][0] == -1 )
      REP(x,W) g[y][x] = g[y-1][x];
  }
  REP(y,H) {
    REP(x,W) {
      cout << g[y][x];
      if ( x != W-1 ) cout << " ";
    }
    cout << endl;
  }
}


Measured memory_bytes: 1280
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;
int main(){
	int x,a,n,sum=0,mx=-1e9;
	cin>>a>>n;
	for(int i=1;i<=n;i++){
		cin>>x;
		sum+=x;
		mx=max(mx,x);
	}
	cout<<max(mx*2-sum-1,0)<<endl;
	return 0;
}


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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  int jun = 0;
  while (A > 0 && C > 0) {
    if (jun % 2 == 0) {
      C -= B;
    }
    else {
      A -= D;
    }
    jun++;
  }
  if (A > 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
template<typename T = int> vector<T> create(size_t n){ return vector<T>(n); }
template<typename T, typename... Args> auto create(size_t n, Args... args){ return vector<decltype(create<T>(args...))>(n, create<T>(args...)); }
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a;
	cin >> a;
	cout << a + a * a + a * a * a << '\n';
	return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef vector<ii> vii;
typedef vector<vi> vvi;
#define deb(x) cout << #x": " << (x) << endl;

const int N = 1e3;
const lli INF = 1e18;
const lli MOD = 1e9+7;

bool m[N];
vi primes(1,2);
ld nk[N][N];
void sieve(){
	for(int i = 4; i<N; i+=2)m[i]=1;
	for(int i = 3; i*i<=N; i+=2)if(!m[i])for(int j = i*i; j<N; j+=i)m[j]=1;
	for(int i = 3; i<N; i+=2)if(!m[i])primes.pb(i);
}

void pascal(){
	fore(i,0,N)nk[i][0]=nk[i][i]=1.0;
	fore(i,1,N)fore(j,1,i)nk[i][j]=nk[i-1][j-1]+nk[i-1][j];
}

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

lli lcm(lli a, lli b){
	if(a<b)swap(a,b);
	lli c = gcd(a,b);
	a/=c;
	return a*b;
}

int popcount(lli x) { return __builtin_popcountll(x); }

lli poww(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = res * a;
		a = a*a;
		b/=2;
	}
	return res;
}

lli powm(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = (res * a)%MOD;
		a = (a*a)%MOD;
		b/=2;
	}
	return res;
}

bool isPrime(lli x){
	if(x==1)return 0;
	for(auto i:primes){
		if(i*i>x)return 1;
		if(x%i==0)return 0;
	}
	return 1;
}

// ---- コーディングはここから！ ('-')7


int main(){_
	int n; cin>>n; int k = 0;
	fore(i,0,n){
		int a; cin>>a;
		if(i%2==0 and a&1)k++;
	}
	cout<<k<<ENDL;

}


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

#define pb push_back
#define f1 first
#define s2 second

#define fastio ios :: sync_with_stdio(); cin.tie(0); cout.tie(0);
#define debug(x...) cerr << "[" << #x << "]: " << x << "\n";

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> pl;

int const N = 1e4 + 7;
ll ar[N];
int main()
{
	fastio;

	int n;
	cin >> n;

	for (int x = 1; x*x <= n; ++x)
	{
		for (int y = 1; x*x + y*y + x*y <= n; ++y)
		{
			for (int z = 1; x*x + y*y + z*z + x*y + y*z + z*x <= n; ++z)
			{
				ar[x*x + y*y + z*z + x*y + y*z + z*x]++;
			}
		}
	}

	for (int i = 1; i <= n; ++i)
		cout << ar[i] << '\n';

	return 0;
}


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

#define NREP() for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define IPT(x) ll t; cin >> t; x.push_back(t);
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<string> vvs;

const static ll MOD = 1e9 + 7;

bool is_prime(ll n) {
    if (n == 2) return true;
    if (n % 2 == 0) return false;
    for (ll i = 3; i * i <= n; i += 2) {
        if (n % i == 0) return false;
    }
    return true;
}

int main(int argc, char *argv[]) {
    ll x;
    cin >> x;

    while (true) {
        if (is_prime(x)) break;
        x++;
    }
    MSG(x)
}


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

using namespace std;

int main(void)
{
    string o,e;
    cin >> o >> e;

    for (int i = 0;i < o.size() && i < e.size();i++)
    {
        cout << o[i] << e[i];
    }
    if (o.size() != e.size())
    {
        cout << o[o.size() - 1];
    }
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 256
/*
 ╔═══╦═══╦═══╗
 ║╔═╗║╔══╩╗╔╗║
 ║║░║║╚══╗║║║║
 ║║░║║╔══╝║║║║
 ║╚═╝║╚══╦╝╚╝║
 ╚══╗╠═══╩═══╝
 ░░░╚╝░░░░░░░░
 */

#include <bits/stdc++.h>
#define ll					long long
#define debug(x)			{ cerr << #x << " = " << x << endl; }
#define MOD					1000000007
#define MAX					1e9
#define MIN                 -1e9
#define vi					vector<int>
#define vii					vector<vi>
#define max(x,y)			(x>y)?x:y
#define min(x,y)			(x<y)?x:y
#define mid(s,e)			(s+(e-s)/2)

using namespace std;

int main() {
	ios::sync_with_stdio(false);
 	cin.tie(0);
	int n;
	string s,t;

	cin>>n>>s>>t;
	vector<char> newString(2*n);
	for(int i=0, j=0; i<n; i++, j++) {
		newString[j++] = s[i];
		newString[j] = t[i];
	}
	for(char&c : newString)
		cout<<c;
	cout<<endl;

	return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define all(a)          (a).begin(), (a).end()
#define sort(a)         sort(all(a))
#define uniq(a)         sort(a);(a).erase(unique(all(a), (a).end())
#define reverse(a)      reverse(all(a))
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }
#define pb              push_back
#define fst             first
#define int             long long

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

const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve() {
  ll n; cin >> n;
  vector<P> v(n);
  rep(i, n) {
    ll x, l; cin >> x >> l;
    v[i] = make_pair(x + l, x - l);
  }
  sort(v);
  ll right = -10000000000, ans = 0;
  rep(i, n) {
    if (right <= v[i].second) {
      right = v[i].first;
      ans++;
    }
  }
  outl(ans);
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define pb push_back
#define test cout<<"#"

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll n;
	cin>>n;
	vector<ll> v(n);
	for(ll x = 0; x < n; x++)
		cin>>v[x];
	ll ans[n];
	for(ll x = 0; x < n; x++)
		ans[x] = LONG_LONG_MAX;
	ans[0] = 0;
	for(ll x = 1; x < n; x++)
	{
		if(x-1>=0)
			ans[x] = min(ans[x], ans[x-1]+abs(v[x]-v[x-1]));
		if(x-2>=0)
			ans[x] = min(ans[x], ans[x-2]+abs(v[x]-v[x-2]));
	}
	cout<<ans[n-1];
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int n,a[N],b[N];

int main(){
	scanf("%d",&n);
	for(int i = 1;i<=n;i++) scanf("%d%d",&a[i],&b[i]);
	if(n%2){
		sort(a+1,a+n+1);
		sort(b+1,b+n+1);
		printf("%d",b[n/2+1]-a[n/2+1]+1);
	}else{
		sort(a+1,a+n+1);
		sort(b+1,b+n+1);
		printf("%d",(b[n/2]+b[n/2+1])-(a[n/2]+a[n/2+1])+1);
	}
	return 0;
}

Measured memory_bytes: 5388
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

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

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String[] s = new String[n];

		long total = 0l;

		Map<String, Integer> map = new HashMap<>();

		for (int i = 0; i < n; i++) {
			s[i] = sc.next();
			char[] chars = s[i].toCharArray();
			Arrays.sort(chars);
			s[i] = new String(chars);
			map.put(s[i], -1);
		}

		for (int i = 0; i < n; i++) {
			map.put(s[i], map.get(s[i]) + 1);
			total += map.get(s[i]);
		}

		System.out.println(total);
		sc.close();

	}

}

Measured memory_bytes: 55332
/*
 * src.cpp
 *
 *  Created on: 2016/10/01
 *      Author: joi
 */

#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

string S;

int main(){
	cin>>S;
	int res=S.length();
	int scnt=0;
	REP(i,(int)S.length()){
		if (S[i]=='S'){
			scnt++;
		}else{
			if (scnt>0){
				scnt--;
				res-=2;
			}
		}
	}
	printf("%d\n",res);
	return 0;
}




Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long 
#define M 1000000007
#define P pair<int,int>

int n;
int a[1000000];
int t;
int ans,ma,mi=inf;

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


  for(int i=0;i<n;i++){
    if(a[i]-mi>ma) ma=a[i]-mi,ans=1;
    else if(a[i]-mi==ma) ans++;
    if(a[i]<mi) mi=a[i];
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int g[31234][10];

int main() {
	int N;
	string S;
	cin >> N >> S;
	
	memset(g, -1, sizeof(g));
	for (int i = N; i > 0; i--) {
		int cur = S[i - 1] - '0';
		g[i - 1][cur] = i;
		REP(j, 10) if (cur != j) g[i - 1][j] = g[i][j];
	}
	
	int ans = 0;
	REP(i, 1000) {
		string s = to_string(i);
		while (s.size() < 3) s.insert(s.begin(), '0');
		int p = 0, cnt = 0;
		while (p != -1 && p < N && cnt < 3) {
			p = g[p][s[cnt]-'0'];
			cnt++;
		}
		
		if (cnt == 3 && p != -1) ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1536
let change n m d =
  let t = Array.make (n + 1) max_int in
  let rec doit = function
    | (i, _) when i = m -> t.(n)
    | (i, x) when x + d.(i) > n -> doit (i + 1, 0)
    | (i, x) ->
      t.(x + d.(i)) <- min t.(x + d.(i)) (t.(x) + 1);
      doit (i, x + 1) in
  t.(0) <- 0;
  doit (0, 0)

let () =
  let (n, m) = Scanf.scanf "%d %d " (fun n m -> (n, m)) in
  let d = Array.init m (fun _ -> Scanf.scanf "%d " (fun i -> i)) in
  Printf.printf "%d\n" (change n m d)

Measured memory_bytes: 2728
class BIT:
    def __init__(self, N):
        self.size = N
        self.tree = [0] * (N + 1)
        self.MSB = 1 << (N.bit_length() - 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

    def bisect(self, w):
        bit, N = self.tree, self.size
        i = 0
        k = self.MSB
        while k > 0:
            if i + k <= N and bit[i + k] < w:
                w -= bit[i + k]
                i += k
            k //= 2
        return i + 1

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

memo = {a: i for i, a in enumerate(sorted(set(A)), 1)}
M = len(memo)

bit = BIT(M)
for b in (memo[a] for a in A):
    s = bit.sum(b - 1)
    if s > 0:
        i = bit.bisect(s)
        bit.add(i, -1)
    bit.add(b, 1)

print(bit.sum(M))


Measured memory_bytes: 71228
#include <algorithm> // std::sort(begin,end), std::min, std::max
#include <iostream>
#include <queue>
#include <string>
#include <unordered_map>
#include <utility> // std::swap
#include <vector>

using namespace std;
using ll = long long;

bool judge(ll score, ll k, vector<ll> &a, vector<ll> &f) {
  int n = a.size();
  for (int i = 0; i < n && k >= 0; i++) {
    if (a[i] * f[i] > score) {
      ll tmp = score / f[i];
      k -= a[i] - tmp;
      if (k < 0)
        return false;
    }
  }
  return true;
}

int main(int argc, char const *argv[]) {
  ll n, k = 0;
  cin >> n >> k;
  vector<ll> a(n), f(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> f[i];
  }

  sort(a.begin(), a.end());
  sort(f.begin(), f.end(), greater<ll>());

  ll inf = -1, sup = 1e12, mid;

  for (; sup - inf > 1;) {
    mid = (inf + sup) / 2;
    if (judge(mid, k, a, f)) {
      sup = mid;
    } else {
      inf = mid;
    }
  }
  cout << sup << endl;

  return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
#define inf 1e9


int main(){
	ll n;
	vector<ll> c(3);
	cin>>c[0]>>c[1]>>c[2]>>n;
	vector<ll> dp(n+1,0);
	dp[0] = 1;
	for(int i=0;i<3;i++){
		for(int j=0;j<=n;j++){
			if(j-c[i]>=0){
				dp[j]+=dp[j-c[i]];
			}
		}
	}
	cout<<dp[n]<<endl;
	//for(int i=0;i<=n;i++){
	//	cout<<i<<' '<<dp[i]<<endl;
	//}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main()
{
    string S; cin >> S;
    for (int i = 0; i < S.size()-1; i++) {
        if (S[i] == 'A' && S[i+1] == 'C') {
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";
    return 0;
}

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

using namespace std;

class Edge{
public:
    int from, to, cost;
};

vector < vector < Edge > > edge;
vector <bool> visited;
vector <int> color;

void dfs(int now, int cost){
	int l=edge[now].size();
    for(int i=0; i<l; i++){
        if(!visited[edge[now][i].to]){
            visited[edge[now][i].to]=true;
            if((cost + edge[now][i].cost) % 2 == 0){
                color[edge[now][i].to] = 1;
            }
            dfs(edge[now][i].to, (cost + edge[now][i].cost) % 2);
        }
    }
}

int main(){
    int N;
    int from, to, cost;

    cin>>N;
    edge.resize(N);
    for(int i=0; i<N-1; ++i){
        cin>>from>>to>>cost;
        edge[from-1].push_back((Edge){from-1, to-1, cost%2});
        edge[to-1].push_back((Edge){to-1, from-1, cost%2});
    }

    visited.resize(N);
    color.resize(N);
    for(int i=0; i<N; ++i){
        visited[i]=false;
        color[i] = 0;
    }

    int start=0;
    visited[start]=true;
    color[start] = 1;
    dfs(start, 0);

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

    return 0;
}


Measured memory_bytes: 8192
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        long result = 0L;
        for(int a=1; a<=K; a++) {
            for(int b=1; b<=K; b++) {
                int gcd_ab = gcd(a, b);
                for(int c=1; c<=K; c++) {
                    int gcd_abc = gcd(gcd_ab, c);
                    result+=gcd_abc;
                }
            }
        }
        System.out.println(String.format("%d", result));
    }
    static int gcd (int a, int b) {
        int temp;
        while((temp = a%b)!=0) {
            a = b;
            b = temp;
        }
        return b;
    }
}


Measured memory_bytes: 35780
#include <stdio.h>

int main(void)
{
    int i,n,t,  waku[5][5],roop, kazu[100];

    for(i = 1; i <= 3; i++){
        for(n = 1; n <= 3; n++){
            scanf("%d", &waku[i][n]);
        }
    }

    scanf("%d", &roop);
    for(i = 1; i <= roop; i++){
        scanf("%d", &kazu[i]);
    }

    for(i = 1; i <= 3; i++){
        for(n = 1; n <= 3; n++){
            for(t = 1; t<=roop; t++){
                if (waku[i][n] == kazu[t])
                    waku[i][n] = 1000;
            }
        }
    } 

    if((waku[1][1] == waku[1][2] && waku[1][1] == waku[1][3])||(waku[2][1] == waku[2][2] && waku[2][1] == waku[2][3])||(waku[3][1] == waku[3][2] && waku[3][1] == waku[3][3])||(waku[1][1] == waku[2][2] && waku[1][1] == waku[3][3])||(waku[3][1] == waku[2][2] && waku[3][1] == waku[1][3])||(waku[1][1] == waku[2][1] && waku[1][1] == waku[3][1])||(waku[1][2] == waku[2][2] && waku[1][2] == waku[3][2])||(waku[1][3] == waku[2][3] && waku[1][3] == waku[3][3]))
        printf("Yes");
    else
        printf("No");
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
#define PI 3.14159265359

int main() {
  int s,w;
  cin>>s>>w;
  if(s<=w){
    cout<<"unsafe"<<endl;
  }else{
    cout<<"safe"<<endl;
  }
}


Measured memory_bytes: 3636
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
#include <unordered_set>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int main() {
  string s;
  cin >> s;
  int x, y;
  cin >> x >> y;
  int N = s.size();

  vector<int> d;
  int cnt = 0;
  for (int i = 0; i < N; i++) {
    if (s[i] == 'T') {
      d.push_back(cnt);
      cnt = 0;
    } else {
      cnt++;
    }
  }
  d.push_back(cnt);

  int D = d.size();
  vector<unordered_set<int>> dp(D);
  dp[0].insert(d[0]);

  // D: 1, 2, 3, 4, 5
  // x: 0, 0, 2, 2, 4
  // y:-1 ,1, 1, 3, 3
  int xmax = ((D - 1) / 2) * 2;
  int ymax = (D / 2) * 2 - 1;

  // X
  for (int i = 2; i < D; i+=2) {
    for(auto &s : dp[i - 2]) {
      dp[i].insert(s + d[i]);
      dp[i].insert(s - d[i]);
    }
  }

  // Y
  for (int i = 1; i < D; i+=2) {
    if (i == 1) {
      dp[i].insert(d[i]);
      dp[i].insert(-d[i]);
    } else {
      for(auto &s : dp[i - 2]) {
        dp[i].insert(s + d[i]);
        dp[i].insert(s - d[i]);
      }
    }
  }
  bool xok = false, yok = false;
  if (ymax == -1) {
    yok = y == 0;
  } else {
    yok = dp[ymax].find(y) != dp[ymax].end();
  }
  xok = dp[xmax].find(x) != dp[xmax].end();

  if (yok && xok) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 204544
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a, b;
  cin >> a >> b;
  int minimum = min(a, b);
  int maximum = max(a, b);
  int result = 0;
  for(int i = 0; i < minimum; i++){
    result += maximum;
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 3648
import Control.Applicative

data Dice = Dice [Int] deriving (Show, Ord, Eq)

roll :: Dice -> Char -> Dice
roll (Dice [top, front, right, left, back, bottom]) 'S' = Dice [back, top, right, left, bottom, front]
roll (Dice [top, front, right, left, back, bottom]) 'E' = Dice [left, front, top, bottom, back, right]

turn1 :: Dice -> Dice
turn1 (Dice [top, front, right, left, back, bottom]) = Dice [top, right, back, front, left, bottom]
turn2 = turn1 . turn1
turn3 = turn2 . turn1

turnAll :: [Dice] -> [Dice]
turnAll dices =  [id, turn1, turn2, turn3] <*> dices

dices :: Dice -> [Dice]
dices dice = [dice
             , rev dice
             , toS dice
             , toE dice
             , rev (toS dice)
             , rev (toE dice)
             ]

toS = flip roll 'S'
toE = flip roll 'E'
rev = toS . toS

solve :: Dice -> [Dice] -> String
solve dice dices | dice `elem` dices = "Yes"
                 | otherwise         = "No"

main :: IO ()
main = do
    dice1 <- Dice . map read . words <$> getLine
    dice2 <- Dice . map read . words <$> getLine
    putStrLn $ solve dice2 (turnAll (dices dice1))


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

typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector <ll> vi;
typedef vector <pi> vpi;
#define f first
#define s second
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0)
#define int ll
int H,W;
int32_t main(){
	fast;
	
	cin>>H>>W;
	
	if (H == 1 || W == 1) cout<<1;
	else cout<<(H*W + 1)/2;
	
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define range(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, a) range(i, 0, a)
using namespace std;
const int INF = sizeof(int) == sizeof(long long) ? 1e18 : 1e9;
const int MOD = 1000000007;
const long double EPS = 1e-8;

int x, y;

int main() {
	cin >> x >> y;
	if (x % y == 0) {
		cout << -1 << endl;
	} else {
		cout << x << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#define ll long long
using namespace std;

int main()
{
    int n;
    int a[100];
    scanf("%d",&n);
    int i;
    for(i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
    }

    int sum=0;
    for(int j=1;j<=n-1;j++)
    {
        for(int k=j+1;k<=n;k++)
        {
            sum=sum+a[j]*a[k];
        }
    }
    printf("%d\n",sum);
    return 0;
}


Measured memory_bytes: 256
import sys
input=sys.stdin.readline
sys.setrecursionlimit(100000000)

def main():
    n=int(input())
    tree=[[] for i in range(n)]
    for _ in range(n-1):
       a,b=map(int,input().split())
       a-=1
       b-=1
       tree[a].append(b)
       tree[b].append(a)
    
    depth=[-1]*n
    depth[0]=0

    def dfs(i):
        for e in tree[i]:
            if depth[e]==-1:
                depth[e]=(depth[i]+1)%2
                dfs(e)
    dfs(0)
    o=sum(depth)
    e=n-o

    if n%3==0:
        i = n//3
        j = i
        k = i
    elif n%3==1:
        i = n//3
        j = i+1
        k = i
    else:
        i = n//3
        j = i+1
        k = j

    ans=[0]*n
    if 3*e > n and 3*o > n:
        for l in range(n):
            if depth[l]==0:
                if j==0:
                    ans[l]=3*i
                    i-=1
                else:
                    ans[l]=3*j-2
                    j-=1
            else:
                if k==0:
                    ans[l]=3*i
                    i-=1
                else:
                    ans[l]=3*k-1
                    k-=1
    
    elif 3*e <= n:
        for l in range(n):
            if depth[l]==0:
                ans[l]=3*i
                i-=1
            else:
                if j==0 and k==0:
                    ans[l]=3*i
                    i-=1
                elif j==0:
                    ans[l]=3*k-1
                    k-=1
                else:
                    ans[l]=3*j-2
                    j-=1
    
    else:
        for l in range(n):
            if depth[l]==1:
                ans[l]=3*i
                i-=1
            else:
                if j==0 and k==0:
                    ans[l]=3*i
                    i-=1
                elif j==0:
                    ans[l]=3*k-1
                    k-=1
                else:
                    ans[l]=3*j-2
                    j-=1
    print(*ans)
    
if __name__=='__main__':
    main()

Measured memory_bytes: 195780
#include <stdio.h>
#include <algorithm>
#include <string.h>


using namespace std;

long long int f(long long int x) {
    long long int ret;
    if (x%4==0) {
        return ret=x;
    }
    else if (x%4==1) {
        return ret=1;
    }
    else if (x%4==2) {
        return ret=x+1;
    }
    else {
        return ret=0;
    }
}

int main() {
    /*int i, j;
    int res = 0;
    for (i=1; i<=50; i++) {
        res ^= i;
        printf("** %d: %d\n", i, res);
    }
    for (i=1; i<=1000; i*=10) {
        res = 0;
        for (j=1; j<=i; j++) {
            res ^= j;
        }
        printf("%d: %d\n", i, res);
    }*/
    //printf("%d\n",res);
    long long int a, b;
    scanf("%lld %lld", &a, &b);
    if (a==0) {
        printf("%lld\n", b);
    }
    else {
        long long int x, y;
        x = f(b);
        y = f(a-1);

       //printf("%lld %lld\n", x, y);
        printf("%lld\n", f(b)^f(a-1));
    }
    return 0;
}


Measured memory_bytes: 128