akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(long long i=0;i<n;++i)
#define REPR(i,n) for(long long i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(v) {for(long long sitr=0;sitr<v.size();++sitr){cin>>v[sitr];}}

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  int n;
  cin >> n;

  int ans = INF;
  REP(i,n){
    int a, cnt = 0;
    cin >> a;
    while(a % 2 == 0){
      cnt++;
      a /= 2;
    }
    ans = min(ans, cnt);
  }

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1

def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, K, R, S, P, T):
    ans = 0
    s = []
    for i, t in enumerate(T):
        if t == 'r':
            if i - K >= 0 and s[i-K] == 'p':
                s.append('.')
            else:
                s.append('p')
                ans += P
        elif t == 's':
            if i - K >= 0 and s[i-K] == 'r':
                s.append('.')
            else:
                s.append('r')
                ans += R
        elif t == 'p':
            if i - K >= 0 and s[i-K] == 's':
                s.append('.')
            else:
                s.append('s')
                ans += S
    return ans


def main():
    N, K = read_int_n()
    R, S, P = read_int_n()
    T = read_str()
    print(slv(N, K, R, S, P, T))


if __name__ == '__main__':
    main()


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

using namespace std;

#define LOG(...) fprintf(stderr,__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define RFOR(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define RREP(i,n) for(int i=(int)(n-1);i>=0;--i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SZ(a) ((int)(a).size())
#define BIT(x, i) (((x) >> (i)) & 1)
#define SQ(x) ((x)*(x))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define INF 1000000000

int main() {
    int N;
    while (cin >> N, N) {
        vi in(N);
        REP(i, N) cin >> in[i];

        double ans = INF;
        tuple<int, int, int> res = make_tuple(INF, INF, INF);
        RREP(S, 16) RREP(A, 16) RREP(C, 16) {
            vi out(N);
            map<int, int> occurences;
            int R = S;
            REP(i, N) {
                R = (A * R + C) % 256;
                out[i] = (in[i] + R) % 256;
                occurences[out[i]]++;
            }
            double H = 0;
            for (auto kv : occurences) {
                double r = kv.second / double(N);
                H += r * (log(r) / log(2));
            }
            if (ans >= -H) {
                ans = -H;
                res = min(res, make_tuple(S, A, C));
            }
        }
        printf("%d %d %d\n", get<0>(res), get<1>(res), get<2>(res));
    }
}

Measured memory_bytes: 3440
#include<iostream>
#include<cmath>
#include<map>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1c(i, n) for (int i = 1; i <= (int)(n); i++)

using namespace std;

int N, dp[100][2][3];
map<int, int> m;

void solve() {
  rep1c(i, N) {
    int j = 2;
    int k = i;
    while (k > 1 || i >= j) {
      if (k % j == 0) {
        m[j] += 1;
        k /= j;
      } else {
        j++;
      }
    }
  }
  dp[0][0][0] = 1;
  int ki = 1;
  for ( auto it : m ) {
    rep(i, 2) rep(j, 3) dp[ki][i][j] = dp[ki-1][i][j];
    if(it.second >= 74) {
      dp[ki][1][2] += dp[ki-1][0][0];
    }
    if(it.second >= 24) {
      dp[ki][1][2] += dp[ki-1][1][0];
      dp[ki][0][2] += dp[ki-1][0][0];
    }
    if(it.second >= 14) {
      dp[ki][1][2] += dp[ki-1][0][1];
      dp[ki][1][1] += dp[ki-1][0][0];
    }
    if(it.second >= 4) {
      dp[ki][1][2] += dp[ki-1][1][1];
      dp[ki][1][1] += dp[ki-1][1][0];
      dp[ki][0][2] += dp[ki-1][0][1];
      dp[ki][0][1] += dp[ki-1][0][0];
    }
    if(it.second >= 2) {
      dp[ki][1][2] += dp[ki-1][0][2];
      dp[ki][1][1] += dp[ki-1][0][1];
      dp[ki][1][0] += dp[ki-1][0][0];
    }
    ki++;
  }
  cout << dp[m.size()][1][2] << endl;
}

int main() {
  cin >> N;
  solve();
  return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var c string
	fmt.Scan(&c)
	fmt.Println(next(c))
}

func next(alphabet string) string {
	alphabets := "abcdefghijklmnopqrstuvwxyz"

	for i, a := range alphabets {
		if string(a) == alphabet {
			return string(alphabets[i+1])
		}
	}
	return ""
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
#define INT_MAX 1<<30
const ll mod = 1e9+7;



int main(){
	ll n,m,v,p; cin >> n >> m >> v >> p;
	vl a(n); rep(i,n) cin >> a[i];
	sort(rall(a));
	ll ok = p, ng = n+1;
	while(ng-ok>1){
		ll mid = (ok+ng)/2;
		ll now = a[mid-1] + m;
		if(now < a[p-1]){
			ng = mid;
			continue;
		}
		ll cnt = n*m - (mid-p)*m;
		REP(i,p-1,mid-1){
			cnt += min(now-a[i],m);
		}
		//cout << mid << " " << cnt << endl;
		if(cnt >= v*m) ok = mid;
		else ng = mid;
	}
	ll safe = a[ok-1];
	ll ans = 0;
	rep(i,n){
		if(a[i]>=safe) ans++;
	}
	cout << ans << endl;
}


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

constexpr long long int M = 1000000007, m = 79133769, n = 536396504, mask = 1073741823;
 
inline long long int MR(long long int A){
    long long int ret((A + M * (m * A & mask)) >> 30);
    return ret - (ret >= M) * M;
}

template<int N>
struct Fact{
  long long int val[N];
  constexpr Fact() : val() {
    val[0] = 73741817;
    for(int i = 1; i < N; ++i)val[i] = val[i - 1] * i % M;
  }
};

template<int N, long long F>
struct IFact{
  long long int val[N];
  constexpr IFact() : val() {
    val[N - 1] = F * 73741817 % M;
    for(int i = N - 1; i > 0; --i)val[i - 1] = val[i] * i % M;
  }
};

long long int N, ans;
constexpr auto fact = Fact<1000001>();
constexpr auto ifact = IFact<1000001, 397802501>();

int main(){
    scanf("%lld", &N);
    for(int i = N / 2; i < N - 1; ++i){
        ans += MR(MR(fact.val[i] * fact.val[i - 1]) * ifact.val[i * 2 - N]);
    }
    ans = fact.val[N] - fact.val[N - 1] - ans;
    ans %= M;
    cout << MR(ans > 0 ? ans : M + ans) << endl;
    return 0;
}


Measured memory_bytes: 256
import sys

# import re
# import math
# import collections
# import decimal
# import bisect
# import itertools
# import fractions
# import functools
import copy
# import heapq
# import decimal
# import statistics
import queue

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    h, w, k = ns()
    mat = [list(input()) for _ in range(h)]

    ans_mat = [[0 for i in range(w)] for j in range(h)]

    cnt = 1
    for i in range(h):
        for j in range(w):
            if mat[i][j] == "#":
                ans_mat[i][j] = copy.deepcopy(cnt)
                cnt += 1

    for i in range(h):
        for j in range(1, w):
            if ans_mat[i][j] == 0:
                ans_mat[i][j] = copy.deepcopy(ans_mat[i][j - 1])
        for j in range(w - 2, -1, -1):
            if ans_mat[i][j] == 0:
                ans_mat[i][j] = copy.deepcopy(ans_mat[i][j + 1])

    for i in range(1, h):
        if max(ans_mat[i]) == 0:
            ans_mat[i] = copy.deepcopy(ans_mat[i - 1])
    for i in range(h - 2, -1, -1):
        if max(ans_mat[i]) == 0:
            ans_mat[i] = copy.deepcopy(ans_mat[i + 1])

    for ai in ans_mat:
        print(*ai, sep=" ")


if __name__ == '__main__':
    main()


Measured memory_bytes: 64212
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000, boost::int128_type>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

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; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }
template<class T> inline bool isSosuu(const T& n) { if (n == T(1)) { return false; } for (T i = 2; i*i <= n; ++i) { if (n % i == 0) { return false; } } return true; }
template<class T> vector<vector<T>> split (const vector<T>& S, T delim) { vector<vector<T>> ret{}; vector<T> buff{}; for (auto c : S) { if (c == delim) { if (!buff.empty()) ret.push_back(buff); buff.clear(); } else { buff.push_back(c); } } if (!buff.empty()) ret.push_back(buff); return ret; }
template<class T> inline void printYesNo(const T& t) { cout << (t ? "Yes" : "No") << CRLF; }
template<class T = int64_t> T modpow(T N, T P, T M) { T ret{1}; N %= M; while (P) { if (P & 0x01) { ret *= N; ret %= M; } P >>= 1; N *= N; N %= M; } return ret; }

/** code for assert debug begin */
int gErr = 0;
#define ASSERT(p) if(!(p)){ gErr = 1; }else{ ; }
/** code for assert debug end */

struct Tmp
{
public:
  int N;
  Tmp(int N)
  : N(N)
  {}
};

void solve(void)
{
  int N; cin >> N;
  multiset<int> s{};
  for (int i = 0; i < N; ++i) {
    int d; cin >> d;
    s.emplace(d);
  }
  int M; cin >> M;
  for (int i = 0; i < M; ++i) {
    int t; cin >> t;
    auto itr = s.find(t);
    if (itr == s.end()) {
      cout << "NO" << CRLF;
      return;
    } else {
      s.erase(itr);
    }
  }
  cout << "YES" << CRLF;
  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


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

typedef long long ll;
int N;
const char C[4] = {'A', 'C', 'G', 'T'};
const int MOD = 1e9 + 7;
using namespace std;

vector<unordered_map<string, int>> memo(101);

bool ok(string last4) {
    // cout << last4 << endl;
    for (int i = 0; i < 4; i++) {
        string ss = last4;
        if (i >= 1) {
            char c = ss[i];
            ss[i] = ss[i - 1];
            ss[i - 1] = c;
        }
        if (ss.substr(0, 3) == "AGC" || ss.substr(1, 4) == "AGC")
            return false;
        // cout << "  " << ss << " " << std::count(ss.begin(), ss.end(), "AGC") << endl; 
    }
    return true;
}

int dfs(int cur, string last3) {
    if (memo[cur].find(last3) != memo[cur].end()) {
        return memo[cur][last3];
    }
    if (cur == N) {
        return 1;
    }

    int ans = 0;
    for (char c : C) {
        string n = last3 + c;
        string nn = n.substr(1, n.size());
        if (ok(n)) {
            ans = (ans + dfs(cur + 1, nn)) % MOD;
        }
    }
    memo[cur][last3] = ans;
    return ans;
}


int main() {
    cin >> N;

    // for (int i = 0; i <= N; i++) { memo[i].clear(); }

    int ans = dfs(0, "TTT");
    cout << ans << endl;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define REPD(i,a,b) for (int i=(a);i<(b);i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef set<int> si;
typedef vector<si> vsi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> pi;
typedef queue<int> qi;
typedef queue<pi> qpi;
typedef pair<ll, ll> pll;
typedef queue<pll> qpll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const int mod = 1000000007;
const int INF = 1001001001;
// 小数点　<< fixed << setprecision(0) <<
// sort降順　sort(ALL(),greater<int>());
// 円周率　M_PI
// 文字判定　isupper islower
// 文字変換　
// 順列　do {} while(next_permutation(ALL(X)));
// 最大値　LLONG_MAX
// a内でx以上　auto iter = lower_bound(ALL(a), x);
// a内でxより大きい　auto iter = upper_bound(ALL(a), x);
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};
typedef struct edge se;
typedef vector<edge> ve;
unsigned euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main() {
  ll a;
  long double b;
  cin >> a >> b;
  b*=1000;
  ll ans = a*b/1000;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3676
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const double eps = 1E-18;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint operator^(const ll& t)const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

///////////////////////////

ll N, M;
vector<vector<ll>> g;
vector<ll> con;

void dfs(ll v, ll i) {
	con[v] = i;
	
	for (ll w : g[v]) {
		if (con[w] != -1) { continue; }
		dfs(w, i);
	}
	return;
}


int main() {
	ll N;
	cin >> N;
	vector<ll> x(N + 1);
	repn(i, N) cin >> x[i];

	vector<ll> gl(N + 1);
	gl[1] = 0;
	for (ll i = 2; i <= N; i++) {
		gl[i] = max(gl[i - 1], i - 1 - (x[i - 1] + 1) / 2);
	}

	mint ans = 1;
	repn(i, N) {
		ans *= i - gl[i];
	}
	cout << ans << endl;

	system("PAUSE");
}


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

/* 4 方向への隣接頂点への移動を表すベクトル */
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

int main() {
	
	int height, width;
	cin >> height >> width;
	vector<string> field(height);
	rep(i, height) cin >> field[i];
	
	int mx = 0;
	rep(sx, height){
		rep(sy, width){
			if(field[sx][sy] == '#') continue;
			
			// 各セルの最短距離 (訪れていないところは -1 としておく)
			vector<vector<int> > dist(height, vector<int>(width, -1)); 
			dist[sx][sy] = 0; // スタートを 0 に

			// 「一度見た頂点」のうち「まだ訪れていない頂点」を表すキュー
			queue<pair<int, int> > que; 
			que.push(make_pair(sx, sy)); // スタートを push

			/* キューが空になるまで */
			while (!que.empty()) {
				pair<int, int> current_pos = que.front(); // キューの先頭を見る (C++ ではこれをしても pop しない)
				int x = current_pos.first;
				int y = current_pos.second;
				que.pop(); // キューから pop を忘れずに

				// 隣接頂点を探索
				for (int direction = 0; direction < 4; ++direction) {
					int next_x = x + dx[direction];
					int next_y = y + dy[direction];
					if (next_x < 0 || next_x >= height || next_y < 0 || next_y >= width) continue; // 場外アウトならダメ
					if (field[next_x][next_y] == '#') continue; // 壁はダメ

					// まだ見ていない頂点なら push
					if (dist[next_x][next_y] == -1) {
						que.push(make_pair(next_x, next_y));
						dist[next_x][next_y] = dist[x][y] + 1; // (next_x, next_y) の距離も更新
					}
				}
			}
			// 最大値
			rep(x, height){
				rep(y, width){
					if(dist[x][y] > mx) mx = dist[x][y];
				}
			}
		}
	}
	cout << mx << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e7+1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector < pair<ll, ll > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
typedef list <ll> lst;

ll n,m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

/*--------------------template--------------------*/

int main()
{
	cin >> n;
	vi v(n);
	REP(i, n) cin >> v[i];
	REP(i, n)
	{
		cnt = 0;
		while (v[i] > 9) {
			ans = 0;
			ll digit = log10(v[i]);
			REP(j, digit)
			{
				ll b = pow(10, j + 1);
				ll a = (v[i] / b)*(v[i] % b);
				ans = max(ans, a);
			}
			cnt++;
			v[i] = ans;
		}
		cout << cnt << endl;
	}
}

Measured memory_bytes: 3492
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

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

using namespace std;


int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

long long inputValueLongLong(){
    long long a;
    cin >> a;
    return a;
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

int main(int argc, const char * argv[]) {
    const double PI=3.14159265358979323846;
    // source code
    long long N = inputValueLongLong();
    cout << 2*N*PI << endl;
    
    return 0;
}

Measured memory_bytes: 3768
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():

    N, K = in_nn()
    h = sorted(list(in_na()))

    ans = 10**9 + 7

    for i in range(N - K + 1):
        ans = min(ans, h[i + K - 1] - h[i])

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 18376
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

long long max(long long x, long long y){return (x > y ? x : y);}
long long min(long long x, long long y){return (x < y ? x : y);}

#define ll long long
#define pb push_back
#define ld long double
#define mp make_pair
#define F first
#define S second
#define pii pair<ll,ll> 

using namespace :: std;

const ll maxn=5030;
const ll maxm=205;
const ll inf=1e9+800;
const ll mod=1e9+7;

ll a[maxn];
ll b[maxn][maxm];

ll seg[maxn*4];
ll lazy[maxn*4];


void shift(ll a){
    lazy[2*a]+=lazy[a];
    lazy[2*a+1]+=lazy[a];
    seg[2*a]+=lazy[a];
    seg[2*a+1]+=lazy[a];
    lazy[a]=0;
}


void update(ll L,ll R,ll node,ll l,ll r,ll v){
    if(l<=L && R<=r){
        lazy[node]+=v;
        seg[node]+=v;
        return;
    }
    if(R<=l || r<=L){
        return ;
    }
    ll mid=(L+R)/2;
    shift(node);
    update(L,mid,2*node  ,l,r,v);
    update(mid,R,2*node+1,l,r,v);
    seg[node]=max(seg[2*node],seg[2*node+1]);
}
ll find_max(){
    return seg[1];
}

stack<ll> stk[maxm];
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);    

    ll n,m;
    cin>>n>>m;
    for(ll i=0;i+1<n;i++){
        cin>>a[i];
    }
    for(ll i=0;i<n;i++){
        for(ll j=0;j<m;j++){
            cin>>b[i][j];
        }
    }
    for(ll i=0;i<m;i++){
        stk[i].push(n);
        stk[i].push(n-1);
        b[n][i]=inf;
        update(0,n,1,n-1,n,b[n-1][i]);
    }
    ll ans=find_max();
    for(ll i=n-2;i>=0;i--){
        for(ll j=0;j<m;j++){
            update(0,n,1,i,i+1,b[i][j]);
            while(b[stk[j].top()][j]<=b[i][j]){
                ll l=stk[j].top();
                stk[j].pop();
                ll r=stk[j].top();
                update(0,n,1,l,r,b[i][j]-b[l][j]);
            }
            stk[j].push(i);
        }
        update(0,n,1,i+1,n,-a[i]);
        ans=max(ans,find_max());
    }
    cout<<ans;
}

































Measured memory_bytes: 8832
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main() {
    int N,a,b;
    cin >> N >> a >> b;
    int p = 0;
    int k,j;
    for (int i = 1; i <= N; i++){
        j = 0;
        k = i;
        while(k >= 1){
            j = j + (k % 10);
            k = k / 10;
        }
        if (a <= j && j <= b){
            p = p + i;
        }
    }
    cout << p << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define INIT    \
    cin.tie(0); \
    ios::sync_with_stdio(false);

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

ll const INF = 1LL << 60;
ll const MOD = 1000000007;

int main() {
    INIT;

    double n, m, d;
    cin >> n >> m >> d;

    double ans;
    if (d == 0.0) {
        cout << fixed << setprecision(10) << (m - 1) * 1.0 / n << endl;
    } else {
        cout << fixed << setprecision(10) << (m - 1) * 2.0 * (n - d) / (n * n)
             << endl;
    }

    return 0;
}

Measured memory_bytes: 3796
#include <stdio.h>
#include <stdlib.h>
#define NIL NULL

struct node{
    struct node *right;
    struct node *left;
    struct node *parent;
    int key;
};

typedef struct node * Node;

Node root;

void insert(int key){

    Node z;
    Node y = NIL;
    Node x = root;

    z = malloc(sizeof(struct node));

    z->key = key;
    z->left = NIL;
    z->right = NIL;

    while( x != NIL ){
        y = x;

        if( z->key < x->key ){
            x = x->left;
        }else{
            x = x->right;
        }

        z->parent = y;

    }

    if( y == NIL ){
        root = z;
    }else if( z->key < y->key ){
        y->left = z;
    }else{
        y->right = z;
    }

}


void pre(Node z){

    if( z == NIL ){
        return;
    }

    printf(" %d",z->key);
    pre(z->left);
    pre(z->right);

}

void ino(Node z){

    if( z == NIL ){
        return;
    }

    ino(z->left);
    printf(" %d",z->key);    
    ino(z->right);

}


int main(){

    int n;
    int i;
    int key;
    char order[8];

    scanf("%d",&n);

    for( i = 0 ; i < n ; i++ ){
        scanf("%s",order);

        if( order[0] == 'i' ){
            scanf("%d",&key);
            insert(key);
        }else if( order[0] == 'p' ){

            ino(root);
            printf("\n");
            pre(root);
            printf("\n");

        }

    }

    return 0;

}

Measured memory_bytes: 24040
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap};

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;

fn main() {
    input! {
        n: usize,
        a: [usize; 5],
    }

    let x = a.iter().min().unwrap();

    println!("{}", 4 + (n + x - 1) / x);
}


Measured memory_bytes: 4352
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn main(){
    let s : Vec<i64> = read_vec();
    let res :i64;
    if s[0] >= 10 {
        res = s[1];
    }
    else{
        res = s[1] + 100 * (10 - s[0]);
    }
    println!("{}", res);
}


Measured memory_bytes: 4352
mod = 10 ** 9 + 7


N = int(input().rstrip())
As = list(map(int, input().rstrip().split()))
ans = 0
add = 0

for i in range(N):
	add += As[i]
	add %= mod
ans = add * add % mod

for i in range(N):
	ans -= As[i] * As[i] % mod
	if (ans < 0):
		ans += mod

ans *= int((mod + 1) / 2)
ans %= mod

print(ans)

Measured memory_bytes: 93892
n,m = map(int,input().split())
A = [[] for i in range(n)]
b = [0 for i in range(m)]
c = [0 for i in range(n)]
for i in range(n):
    A[i].extend(map(int,input().split()))
for i in range(m):
    b[i] = int(input())
for i in range(n):
    for j in range(m):
        c[i] += A[i][j] * b[j]
    print(c[i])


Measured memory_bytes: 6020
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int T = sc.nextInt();
        int[] c = new int[n];
        int[] t = new int[n];
        int min = Integer.MAX_VALUE;
        int ans = Integer.MAX_VALUE;
        for (int i = 0; i < n; i++) {
            c[i] = sc.nextInt();
            t[i] = sc.nextInt();
            if(T >= t[i]) {
                ans = Math.min(ans, c[i]);
            }
        }
        if(ans == Integer.MAX_VALUE) System.out.println("TLE");
        else System.out.println(ans);
    }
}

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

result = 0

for idx in range(len(A)):

    if idx == 0:
        continue
    elif A[idx-1] > A[idx]:
        result += A[idx-1] - A[idx]
        A[idx] = A[idx-1]

print(result)

Measured memory_bytes: 32288
n,a=map(int,input().split())
x=list(map(int,input().split()))
# dp[j][k][s]=(x1,...,xjからk枚選んでx[i]の合計をsにするような選び方の総数)
dp=[[[0]*2501 for i in range(51)] for j in range(51)]
dp[0][0][0]=1
for i in range(n):
    for j in range(n+1):
        for k in range(2501):
            if k<x[i]:
                dp[i+1][j][k]=dp[i][j][k]
            else:
                dp[i+1][j][k]=dp[i][j][k]+dp[i][j-1][k-x[i]]
ans=0
for i in range(1,n+1):
    ans+=dp[n][i][i*a]
print(ans)

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

using namespace std;

main(){
	vector<int> arr;
	int size, max; 
	scanf("%d %d",&size,&max);
	arr.assign(size,0);
	int num;
	for(int i=0;i<size;++i){
		scanf("%d",&num);
		arr[i] = num;
	}
	sort(arr.begin(),arr.end());
	int pos = size-1;
	int sum;
	while(max--){
		sum += arr[pos];
		pos--;
	}
	printf("%d",sum);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//#define int long long


int main() {
  int a,b;
  cin >> a >> b;
 
  cout << (a+b+1)/2 << endl;
       
}



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

using namespace std;

int main(){
        int n,m,ansl=0,ansr=100010;
        bool fl=false;

        cin>>n>>m;

        for(int i=0; i<m; i++){
                int l,r;
                cin>>l>>r;
                if(ansr<l) fl=true;
                ansl=max(ansl,l);
                ansr=min(ansr,r);
        }

        if(fl) cout<<0<<endl;
        else cout<<ansr-ansl+1<<endl;
        return 0;
}

Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
# def LIST(): return list(map(str, input().split()))
# def LIST(): return list(input())

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
L = [LIST() for i in range(N)]

dp = [[0] * 3 for i in range(N)]
# dp_b = [0] * N
# dp_c = [0] * N
dp[0][0] = L[0][0]
dp[0][1] = L[0][1]
dp[0][2] = L[0][2]
for i in range(1, N):
    # dp_a[i+1] = max(dp_a[i]+, )
    # for abc in range(3):
    dp[i][0] = max(dp[i-1][1]+L[i][0], dp[i-1][2]+L[i][0])
    dp[i][1] = max(dp[i-1][2]+L[i][1], dp[i-1][0]+L[i][1])
    dp[i][2] = max(dp[i-1][0]+L[i][2], dp[i-1][1]+L[i][2])

ans = 0
for i in range(3):
    if ans < dp[N-1][i]:
        ans = dp[N-1][i]
print(ans)



Measured memory_bytes: 49544
#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)
using TSII = tuple<string, int, int>;

bool comp_res(const TSII &a, const TSII &b) {
  if(get<0>(a) != get<0>(b))
    return get<0>(a) < get<0>(b);
  else
    return get<1>(a) > get<1>(b);
}

int main()
{
  int n;
  cin >> n;
  vector<TSII> restaurants(n);
  REP(i, n) {
    string s; int p;
    cin >> s >> p;
    restaurants.at(i) = make_tuple(s, p, i+1);
  }
  sort(restaurants.begin(), restaurants.end(), comp_res);
  for(auto rest : restaurants) {
    cout << get<2>(rest) << endl;
  } 
}

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

signed main(){ 
    //int g;
    //cin >> g;    
    //for(int a0 = 0; a0 < g; a0++)
    {
        int n;
        int m;
        int x;
        cin >> n >> m >> x;
        
        vector<int> a(n);
        for(int a_i = 0; a_i <n; a_i++){
           cin >> a[a_i];
        }
        
        vector<int> b(m);
        for(int b_i =0; b_i <m; b_i++){
           cin >> b[b_i];
        }
        
        int sum=0,count=0,temp=0,i=0,j=0;        
        
        while(i<n && sum+a[i]<=x)
        {    //considering only first stack and calculating count
            sum+=a[i];
            i++;
        }
        count=i; 
       // cout<<"Count "<<count<<endl;       
       
        while(j<m && i>=0){          //now adding one element of second stack at a time and subtracting the top element of first stack and calculating the count   
            sum+=b[j];             
            j++;
            while(sum>x && i>0){
                i--;
                sum-=a[i];
            }
            if(sum<=x && i+j>count)
                count=i+j;
        }
        cout<<count<<endl;
    } 
    return 0;
}

Measured memory_bytes: 6384
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
int main(){
  string  s;
  cin >> s;
  string ans = "AC";
  if(s.at(0)!='A'){
    ans = "WA" ;
  }
  int cnt = 0;
  for(int i = 1; i<s.size(); i++){
    if(isupper(s.at(i))){//与えられた文字がアルファベットの大文字かを判定。
      if(i == 1 || i == s.size()-1 || s.at(i) != 'C'){
        ans = "WA";
      }
      cnt++;
    }
  }
  if(cnt != 1){
    ans = "WA" ;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
def larger(x, y):
	if x > y: return x
	return y

N, K = map(int, input().split())
S = input()
cnt = 1
standlist = []
for i in range(1, N):
	if S[i-1] != S[i]:
		standlist.append(cnt)
		cnt = 1
	else:
		cnt += 1
standlist.append(cnt)
if S[0] == '0':
	standlist = [0] + standlist
if S[-1] == '0':
	standlist.append(0)
sumlist = [standlist[0]]
for i in range(1, len(standlist)):
	sumlist.append(sumlist[-1]+standlist[i])
srchlen = 2 * K + 1
max = 0
if srchlen > len(sumlist):
	max = sumlist[-1]
else:
	index = 0
	while index + srchlen - 1 < len(sumlist):
		sum = sumlist[index+srchlen-1]
		if index != 0:
			sum -= sumlist[index-1]
		max = larger(sum, max)
		index += 2
print(max)

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

int main() {
    int k,x;cin>>k>>x;
    for(int i=k-1;i>0;i--){
        cout<<x-i<<endl;
    }
    cout<<x<<endl;
    for(int i=1;i<k;i++){
        cout<<x+i<<endl;
    }
}

Measured memory_bytes: 256
int main(void){
    int A, B, C, D;
    scanf("%d %d %d %d",&A, &B, &C, &D);
    while(A > 0 && C > 0){
        C -= B;
        if(C <= 0){
            break;
        }
        A -= D;
    }
    if(A > 0){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
}

Measured memory_bytes: 1660
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cerr << #x << " = " << (x) << endl;
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = 1e9;
const double pi = acos(-1.0);

typedef complex<double> CD;
double gosa = 0.0000001;

//平行判定
bool Check_para(CD p1, CD p2, CD q1, CD q2) {
	double a1 = arg(p1 - p2), a2 = arg(q1 - q2);
	return abs(a1 - a2) < gosa || abs(abs(a1 - a2) - pi) < gosa;
}

int main() {
	int n; cin >> n;
	rep(loop, n) {
		vector<double> xy(8); rep(i, 8)cin >> xy[i];
		CD a(xy[0], xy[1]), b(xy[2], xy[3]), c(xy[4], xy[5]), d(xy[6], xy[7]);
		puts(Check_para(a, b, c, d) ? "YES" : "NO");
	}
}


Measured memory_bytes: 3328
import java.util.*;

class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();
		LinkedList<Integer> list = new LinkedList<>();
		for(int i = 0; i < n; i++) {
			list.add(scan.nextInt());
		}

		Collections.sort(list);

		long size = list.poll();
		int color = 1;
		for(int i = 1; i < n; i++) {
			long dummy = list.poll();
			if(dummy > size*2) {
				color = 1;
			}else {
				color++;
			}
			size+=dummy;
		}

		System.out.println(color);
	}
}


Measured memory_bytes: 62788
#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
    int n;
    int sum=0,t;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&t);
        sum+=t-1;
    }
    printf("%d\n",sum);
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007

using namespace std;

struct UnionFind{
  vector<int> par,num;

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

  int root(int x){
    if(par[x] == x) return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y){
    int rx = root(x);
    int ry = root(y);
    if(rx == ry) return;
    par[rx] = ry;
    num[ry] = num[ry]+num[rx]; 
  }

  int get_num(int x){
    int rx = root(x);
    return num[rx];
  }

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


int main(void){
  int n;
  cin >> n;
  set<string> set;

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

  cout << set.size() << endl;
  
}


Measured memory_bytes: 19224
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<vector>
#define inf 2147483647
#define rep(i,a,b) for(int i=a;i<b;i++)
#define  rr read()
#define ll long long
#define repb(i,a,b) for(int i=a;i<=b;i++)
#define CloseIo   ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
using namespace std;
int read()
{
    char ch = getchar();
	int x = 0, f = 1;
    while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
    while('0' <= ch && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
    return x * f;
}
const int N=2e5+5;

ll a[N],b[N];
int main()
{
	 ll n;
	 CloseIo;
	 cin>>n;
	 ll maxx=0;
	 rep(i,0,n)
	 {cin>>a[i];
	 maxx=max(maxx,a[i]);
	 b[i]=a[i];
	 }
	 sort(a,a+n);
	rep(i,0,n)
	{
		 if(b[i]==a[n-1])
		 {
		 	printf("%lld\n",a[n-2]);
		 }
		 else
		 printf("%lld\n",a[n-1]);
	}
 } 


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

using namespace std;

using i64 = int64_t;

const i64 MOD = 1e9+7;

const i64 INF = 1e18+7;


signed main(){
    int n;
    cin >> n;
    vector<string> s(n);
    unordered_map<string, int> e;
    for(auto& x : s){
        cin >> x;
        ++e[x];
    }
    bool fl = true;
    for(auto& x : e)
        fl &= (x.second == 1);
    for(int i = 0; i < n - 1; ++i)
        fl &= (s[i].back() == s[i + 1].front());
    cout << (fl ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,a[10000];
    long long sum = 0;
    int min,max;
    scanf("%d",&n);
    for(int i = 0;i<n;i++){
    scanf("%d",&a[i]);
        sum+=a[i];
        if(i==0 || a[i] < min) min = a[i];
        if(i==0 || a[i] > max) max = a[i];
    }
    printf("%d %d %lld\n",min,max,sum);
}


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

int main() {
  int N, M, X;
  cin >> N >> M >> X;
  vector<int> C(N);
  vector<vector<int>> A(N, vector<int>(M));
  for (int i = 0; i < N; i++) {
    cin >> C.at(i);
    for (int j = 0; j < M; j++) cin >> A.at(i).at(j);
  }
  
  int ans = -1;
  
  for (int bit = 0; bit < (1 << N); bit++) {
    vector<int> R(M);
    int cost = 0;
    for (int i = 0; i < N; i++) {
      if (bit & (1 << i)) {
        cost += C.at(i);
        for (int j = 0; j < M; j++) {
          R.at(j) += A.at(i).at(j);
        }
      }
    }
    bool L = true;
    for (int i = 0; i < M; i++) {
      if (R.at(i) < X) L = false;
    }
    if (L) {
      if (ans == -1) ans = cost;
      else ans = min(ans, cost);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3636
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;

public class Main {

    private static final String CUP_A = "A";

    private static final String CUP_B = "B";

    private static final String CUP_C = "C";

    private static final String SPLIT_COMMA = ",";

    public static void main(String[] args) {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String input = null;
        Map<String, Object> cup = new HashMap<String, Object>();
        cup.put(CUP_A, new Object());
        cup.put(CUP_B, null);
        cup.put(CUP_C, null);

        try {
            while ((input = in.readLine()) != null) {

                String[] change = input.split(SPLIT_COMMA);

                Object tmp = cup.get(change[0]);
                cup.put(change[0], cup.get(change[1]));
                cup.put(change[1], tmp);
            }

            for (Map.Entry<String, Object> entry : cup.entrySet()) {
                if(entry.getValue() != null) {
                    System.out.println(entry.getKey());
                    break;
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                in.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}

Measured memory_bytes: 16924
package main
         
        import ("fmt")
         
        func main(){
        	var a, b int
         
        	fmt.Scan(&a, &b)
         
        	if a < b{
        		for i := 0 ; i < b ; i++{
        			fmt.Print(a)
        		}
        	}else {
        		for i := 0 ; i < a ; i++{
        			fmt.Print(b)
        		}
        	}
         
        }

Measured memory_bytes: 512
def main():
    n=int(input())
    S=tuple(input().strip())
    r,g,b=0,0,0
    for s in S:
        if s=='R':
            r+=1
        elif s=='G':
            g+=1
        else:
            b+=1
    ans=r*g*b
    #print(ans)
    for i in range(n-2):
        for j in range(i+1,n-1):
            k=i+(j-i)*2
            if k>=n:
                break
            #print(i,j,k)
            #print(S[i],S[j],S[k])
            if S[i]!=S[j] and S[j]!=S[k] and S[k]!=S[i]:
                #print(i,j,k)
                ans-=1
    print(ans)
    
if __name__=='__main__':
    main()

Measured memory_bytes: 73888