akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define repeat(i,a,b) for(int i=(a),i##__end=(b);i<i##__end;i++)
#define repeat_back(i,a,b) for(int i=(b)-1,i##__end=(a);i>=i##__end;i--)
#define mst(a,x) memset((a),(x),sizeof(a))
#define pii pair<int,int>
#define N 100010
#define mod 1000000007
//#define int ll
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int a,b,ans=0;
	cin>>a>>b;
	if(a*b==1)ans=4;
	if(a<4)ans+=(4-a);
	if(b<4)ans+=(4-b);
	cout<<ans*100000<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;


int main() {
    ll a,v,b,w,t;
    cin >> a >> v >> b >> w >> t;
    if (abs(a-b) <= (v-w)*t) cout << "YES" << endl;
    else cout << "NO" << endl; 

}

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

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
// #define MOD 998244353 
#define MEM_SIZE 100010
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


void solve(void)
{
  int X;cin>>X;
  int P = X/200;
  cout<<10 - P <<endl;
  return;
}
int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

ll dp[200][5][2];

void init(){
    rep(i, 0, 200) rep(j, 0, 5) rep(k, 0, 2) dp[i][j][k] = 0;
}

int main(){
    string s;
    ll k;
    cin >> s >> k;
    ll n = s.size();
    init();
    dp[0][0][0] = 1;

    rep(i, 0, n) {

        // smaller -> smaller
        rep(j, 0, 3) dp[i+1][j+1][1] += 9*dp[i][j][1];
        rep(j, 0, 4) dp[i+1][j][1] += dp[i][j][1];

        // exact -> smaller
        rep(j, 0, 3) dp[i+1][j+1][1] += max(s[i] - '0' - 1, 0) * dp[i][j][0]; 
        if(s[i] != '0') rep(j, 0, 4) dp[i+1][j][1] += dp[i][j][0]; 

        // exact -> exact
        if(s[i] != '0') rep(j, 0, 4) dp[i+1][j+1][0] += dp[i][j][0];
        else rep(j, 0, 4) dp[i+1][j][0] += dp[i][j][0];

    }

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

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int inf=1e9+7;
ll type1(ll h,ll w)
{
	if(h<3) return w;
	else{
		ll s[3],res=inf;
		for(ll i=1;i<=h-2;i++)
		{
			s[0]=i*w;
			s[1]=((h-i)/2)*w;
			s[2]=((h-i)-(h-i)/2)*w;
			sort(s,s+3);
			res=min(s[2]-s[0],res);
		}
		return res;
	}
}
ll type2(ll h,ll w)
{
    ll s[3],res=inf;
    for(ll i=1;i<=h-1;i++)
	{
 	    s[0]=i*w;
 		s[1]=(h-i)*(w/2);
 		s[2]=(h-i)*(w-w/2);
	    sort(s,s+3);
	    res=min(s[2]-s[0],res);
	}
	return res;
}
int main()
{
 	ll h,w,ans;
 	cin>>h>>w;
 	ans=min(type1(h,w),type1(w,h));
 	ans=min(type2(h,w),ans);
 	ans=min(type2(w,h),ans);
 	cout<<ans;
}


Measured memory_bytes: 256
import std.stdio : readln, writeln;
import std.string : split;
import std.conv : to;
import std.algorithm : sort;
import std.container : Array, BinaryHeap, RedBlackTree;
import std.typecons : Tuple;

void main()
{
    long X, Y, Z, K;
    {
        auto tmp = readln().split().to!(long[])();
        X = tmp[0];
        Y = tmp[1];
        Z = tmp[2];
        K = tmp[3];
    }
    auto A = readln().split().to!(long[])();
    auto B = readln().split().to!(long[])();
    auto C = readln().split().to!(long[])();
    A.sort!"b<a"();
    B.sort!"b<a"();
    C.sort!"b<a"();

    alias vec3 = Tuple!(long, long, long);
    alias cake = Tuple!(long, vec3);

    auto PQ = BinaryHeap!(Array!cake)();
    PQ.insert(cake(A[0] + B[0] + C[0], vec3(0, 0, 0)));

    auto set = new RedBlackTree!vec3();
    set.insert(vec3(0, 0, 0));

    foreach (_; 0 .. K)
    {
        auto c = PQ.front;
        PQ.removeFront();

        writeln(c[0]);
        auto v = c[1];

        if (v[0] + 1 < X && vec3(v[0] + 1, v[1], v[2]) !in set)
            PQ.insert(cake(A[v[0] + 1] + B[v[1]] + C[v[2]], vec3(v[0] + 1, v[1], v[2])));

        if (v[1] + 1 < Y && vec3(v[0], v[1] + 1, v[2]) !in set)
            PQ.insert(cake(A[v[0]] + B[v[1] + 1] + C[v[2]], vec3(v[0], v[1] + 1, v[2])));

        if (v[2] + 1 < Z && vec3(v[0], v[1], v[2] + 1) !in set)
            PQ.insert(cake(A[v[0]] + B[v[1]] + C[v[2] + 1], vec3(v[0], v[1], v[2] + 1)));

        set.insert(vec3(v[0] + 1, v[1], v[2]));
        set.insert(vec3(v[0], v[1] + 1, v[2]));
        set.insert(vec3(v[0], v[1], v[2] + 1));
    }
}


Measured memory_bytes: 3068
//Himanshu Shukla
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
//#define file_input
//#define multitest
//#define measure_time
#define ll long long
#define v32 vector<int>
#define v64 vector<ll>
#define s32 set<int>
#define s64 set<ll>
#define graph vector<v32>
#define p32 pair<int, int>
#define p64 pair<ll, ll>
#define sz(v) (ll)(v).size()
#define fi first
#define se second
#define ln '\n'
#define debug(x) cerr << (#x) << ": " << (x) << ln
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); }
inline ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); }
const double EPS = 1e-6;
const ll MOD = 1e9 + 7;
template <typename T, typename U>
ostream &operator<<(ostream &out, const pair<T, U> &p)
{
    out << '[' << p.fi << ", " << p.se << ']';
    return out;
}
template <template <typename, typename...> class ContainerType, typename ValueType, typename... Args>
void print_container(const ContainerType<ValueType, Args...> &c)
{
    cout << "{ ";
    for (const auto &v : c)
        cout << v << ' ';
    cout << '}' << ln;
}

void solve()
{
    int n, q;
    cin >> n;
    string s;
    cin >> s;
    s32 cnt[26];
    for (int i = 0; i < s.length(); i++)
        cnt[s[i] - 'a'].insert(i);
    cin >> q;
    while (q--)
    {
        int t;
        cin >> t;
        if (t == 1)
        {
            int i;
            char c;
            cin >> i >> c;
            i--;
            cnt[s[i] - 'a'].erase(i);
            s[i] = c;
            cnt[c - 'a'].insert(i);
        }
        else
        {
            int l, r;
            cin >> l >> r;
            l--;
            r--;
            int ans = 0;
            for (int i = 0; i < 26; i++)
            {
                auto idx1 = cnt[i].lower_bound(l);
                auto idx2 = cnt[i].lower_bound(r);
                if (idx1 != cnt[i].end() && *idx1 <= r)
                    ans++;
            }
            cout << ans << ln;
        }
    }
    return;
}

int main()
{
    FASTIO;
#ifdef file_input
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    clock_t start, stop;
    int t = 1;
#ifdef multitest
    cin >> t;
#endif
#ifdef measure_time
    start = clock();
#endif
    for (int tc = 1; tc < t + 1; tc++)
        solve();
#ifdef measure_time
    stop = clock();
    cerr << "Time :" << fixed << setprecision(5) << double(stop - start) / double(CLOCKS_PER_SEC) << "s" << ln;
#endif
    return 0;
}


Measured memory_bytes: 24220
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, a, b) for (ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())
#define PRINT(V) for (auto v:(V)) {cerr << v << " ";} cerr << endl
#define dump(x) cerr << #x << " : " << (x) << endl
#define dump2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl
inline ll GCD(ll a, ll b){return b ? GCD(b, a % b) : a;}
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
/* END OF TEMPLATE */

//    t     s
ll dp[2020][2020];
int f[2020];

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    ll n, m;
    cin >> n >> m;
    vll s(n);
    rep(i, n){
        cin >> s[i];
    }
    vll t(m);
    rep(i, m){
        cin >> t[i];
    }
    rep(i, 2020){
        dp[i][0] = 1;
        dp[0][i] = 1;
    }
    rep(i, m){
        rep(j, n){
            /*
            if(s[j] == t[i]){
                dp[i+1][j+1] = (dp[i][j+1] + dp[i+1][j]) % MOD;
                f[j+1] = 1;
            }else if(f[j+1]){
                dp[i+1][j+1] = (dp[i][j+1] + dp[i+1][j] - dp[i][j] + MOD) % MOD;
            }else{
                dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j]);
            }
            */
            if(s[j] == t[i]){
                dp[i+1][j+1] = (dp[i][j+1] + dp[i+1][j]) % MOD;
                f[j+1] = 1;
            }else{
                dp[i+1][j+1] = (dp[i][j+1] + dp[i+1][j] - dp[i][j] + MOD) % MOD;
            }
            //cerr << dp[i+1][j+1] << " ";
        }
        //cerr << endl;
    }
    cout << dp[m][n] << endl;
    return 0;
}

Measured memory_bytes: 32000
#include<stdio.h>
int main(){
	int a[6],b,x,y=0,i,j;
	for(i=0;i<6;i++)scanf("%d",&a[i]);
	for(i=0;i<4;i++){
		for(j=i;j<4;j++){
			if(a[i]<a[j]){
				x=a[i];
				a[i]=a[j];
				a[j]=x;
			}
		}
	}
	if(a[4]<a[5])a[4]=a[5];
	for(i=0;i<3;i++)y=y+a[i];
	printf("%d\n",a[4]+y);
	return 0;
}


Measured memory_bytes: 2128
#! /usr/bin/env python
# coding: utf-8


def test(n, k, a):
    count = 0
    dict = {}
    for i in range(n):
        a[i] = int(a[i])
        if a[i] in dict:
            dict[a[i]] += 1
        else:
            dict[a[i]] = 1



    if len(dict) > k:
        num = 0
        for ke, v in sorted(dict.items(), key=lambda x:x[1]):
            if num < (len(dict) - k):
                count += v
                num += 1
            else:
                return count
    else:
        return 0

if __name__ == "__main__":
    nk = input().split(" ")
    a = input().split(" ")
    print(test(int(nk[0]), int(nk[1]), a))

Measured memory_bytes: 39068
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int M = 2e5 + 10;
int a[M];
ll dp[M][3];
int main(){
    int n;
    scanf("%d", &n);
    for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
    for(int i = 0; i <= n; i++) {
        for(int j = 0; j < 3; j++) {
            dp[i][j] = -1e18;
        }
    }
    dp[1][0] = a[1], dp[2][1] = a[2], dp[3][0] = a[1] + a[3], dp[3][2] = a[3];
    for(int i = 4; i <= n; i++) {
        dp[i][0] = dp[i - 2][0] + a[i];
        dp[i][1] = max(dp[i - 2][1], dp[i - 3][0]) + a[i];
        dp[i][2] = max(dp[i - 2][2], max(dp[i - 3][1], dp[i - 4][0])) + a[i];
    }
    ll ans;
    if(n & 1) ans = max(dp[n][2], max(dp[n - 1][1], dp[n - 2][0]));
    else ans = max(dp[n][1], dp[n - 1][0]);
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 9236
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <random>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;

typedef
tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> orderedSet;

#define pb push_back
#define F first
#define S second
#define all(a) (a).begin(), (a).end()

#define for1(i0, l0, r0) for (int i0 = l0; i0 < r0; ++i0)
#define for2(i0, l0, r0) for (int i0 = l0; i0 <= r0; ++i0)
#define forn(i0, n0) for (int i0 = 0; i0 < n0; ++i0)
#define forn1(i0, n0) for (int i0 = 1; i0 < n0; ++i0)
#define forr(i0, n0) for (int i0 = n0; i0 >= 0; --i0)
#define forr1(i0, r0, l0) for (int i0 = r0; i0 > l0; --i0)
#define forr2(i0, r0, l0) for (int i0 = r0; i0 >= l0; --i0)

#define Sort(a) sort(all(a))
#define Reverse(a) reverse(all(a))

typedef long double ld;
#define ui unsigned int
#define ull unsigned long long

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef pair<string, string> pss;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<ld> vld;
typedef vector<bool> vb;
typedef vector<string> vs;

typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<pdd> vpdd;

typedef vector<vi> vvi;
typedef vector<vd> vvd;
typedef vector<vll> vvll;
typedef vector<vb> vvb;

#define vpss vector<pss>
#define vvs vector<vs>
#define vvpii vector<vpii>
#define vvpll vector<vpll>
#define vpt vector<pt>
#define vvvi vector<vvi>
#define vsi vector<set<int>>
#define ss second
#define ff first

#define printvi(arr) for (int x0 : arr) cout << x0 << ' '; cout << '\n';
#define printvll(arr) for (ll x0 : arr) cout << x0 << ' '; cout << '\n';
#define printpair(pair0) cout << pair0.F << ' ' << pair0.S << '\n';
#define printvp(arr) for (auto pair0 : arr) printpair(pair0);
#define initArray(arr, N0, X0) memset(arr, X0, N0 * sizeof(int))
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void init() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //cout.precision(16);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
}

void solve() {
    int n;
    cin >> n;
    vi l(n), r(n);
    vi a(n), b(n);
    forn(i, n) cin >> a[i];
    forn(i, n) cin >> b[i];
    l[0] = r[0] = a[0];
    forn1(i, n){
        if (a[i] > a[i - 1]){
            l[i] = r[i] = a[i];
        } else {
            l[i] = 1;
            r[i] = a[i];
        }
    }
    l[n - 1] = max(l[n - 1], b[n - 1]);
    r[n - 1] = min(r[n - 1], b[n - 1]);
    forr(i, n - 2){
        if (b[i] > b[i + 1]){
            l[i] = max(l[i], b[i]);
            r[i] = min(r[i], b[i]);
        } else {
            r[i] = min(r[i], b[i]);
        }
    }
    ll ans = 1;
    ll mod = 1e9 + 7;
    forn(i, n){
        ll x = max(0, r[i] - l[i] + 1);
        ans = (ans * x) % mod;
    }
    cout << ans << '\n';
}

bool multitest = false;

int main() {
    init();
    int t = 1;
    if (multitest) cin >> t;
    forn(i, t) solve();
}

Measured memory_bytes: 4776
import itertools


def main():
    H, W, K = list(map(int, input().split(' ')))
    S = [input() for _ in range(H)]
    ans = (H - 1) * (W - 1)
    for h_divs in itertools.product([0, 1], repeat=H-1):
        # 例：h_patterns = [0, 0, 1, 2, 2] -> チョコを1～2、2～3番目の行で分割
        h_patterns = [0] * H
        for h in range(1, H):
            h_patterns[h] = h_patterns[h - 1] + h_divs[h - 1]
        # 横方向には h_patterns[-1] 回割る
        div_cnt = h_patterns[-1]
        # 縦方向にはgreedyに割っていく
        white_cnt = [0] * (div_cnt + 1)
        valid_div = True  # 各列において、単体でホワイトチョコがK個より多いブロックがあったらFalse
        for w in range(W):
            new_white_cnt = [0] * (div_cnt + 1)
            for h in range(H):
                if S[h][w] == '1':
                    new_white_cnt[h_patterns[h]] += 1
            if max(new_white_cnt) > K:
                valid_div = False
                break
            should_div = False
            for r in range(len(white_cnt)):
                if white_cnt[r] + new_white_cnt[r] > K:
                    should_div = True
                    break
            if should_div:
                div_cnt += 1
                for r in range(len(white_cnt)):
                    white_cnt[r] = new_white_cnt[r]
            else:
                for r in range(len(white_cnt)):
                    white_cnt[r] += new_white_cnt[r]
        if valid_div:
            ans = min(ans, div_cnt)
    print(ans)


if __name__ == '__main__':
    main()

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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  
  int T;
  cin >> T;

  for (int i = 0; i < T; i++) {
    int m, n;
    cin >> m >> n;
    
    int cnt = 0;
    for (int j = -150; j <= 150; j++) {
      for (int k = -150; k <= 150; k++) {
        int D = j * j + k * k;
        if (D == 0) continue;
        cnt += ((j * m + k * n) % D == 0 && (j * n - k * m) % D == 0);
      }
    }
    cout << (cnt == 8 ? 'P' : 'C') << endl;
  }

  return 0;
}


Measured memory_bytes: 3136
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int a[][] = new int[n][m];
		int b[] = new int[m];
		int c[] = new int[n];
		for(int i=0; i<n; i++){
			c[i]=0;
			for(int j=0; j<m; j++){
				a[i][j]=sc.nextInt();
			}
		}
		for(int j=0; j<m; j++){
			b[j]=sc.nextInt();
		}
		for(int i=0; i<n; i++){
			for(int j=0; j<m; j++){
				c[i]=c[i]+(a[i][j]*b[j]);
			}
			System.out.println(c[i]);
		}
	}
}

Measured memory_bytes: 40532
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;
 
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
 
const int mod=1e9+7;
 
struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  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 c[4005][4005];
void init() {
  c[0][0] = 1;
  for (int i = 0; i <= 4000; i++) {
    for (int j = 0; j <= i; j++) {
      c[i+1][j] += c[i][j];
      c[i+1][j+1] += c[i][j];
    }
  }
}
mint comb(int n, int k) {
  return c[n][k];
}
 
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
 
    return true;
}
 
map<ll, ll> primeFact(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1) res[n]++;
  return res;
}
 
void printv(vi& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
void printv(vll& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
int vtotal(vi& v){
  int total=0;
  rep(i,v.size()) total+=v[i];
  return total;
}
 
int main()
{
  //init(); // mint初期化
  cin.tie( 0 );
  ios::sync_with_stdio( false );
  
  int n;cin>>n;
  int ans=n*(n+1)/2;
  cout(ans);
  return 0;
}

Measured memory_bytes: 125568
//By Vlgd
#include<bits/stdc++.h>
using namespace std;
const int N=100000;
vector<int>G[N];
set<int>ans;
int m,n;
int vis[N]={0},par[N],low[N],pre[N],tot=1;
void dfs(int u,int prev){
	pre[u]=low[u]=tot++;
	vis[u]=1;
	int nxt;
	for(int i=0;i<G[u].size();i++){
		nxt=G[u][i];
		if(!vis[nxt]){
			par[nxt]=u;
			dfs(nxt,u);
			low[u]=min(low[u],low[nxt]);
		}else if (nxt!=prev){
			low[u]=min(low[u],pre[nxt]);
		} 
	} 
}
void solve(){
	dfs(0,-1);
	int cnt=0;
	for(int i=1;i<n;i++){//²»ÓÃ¼ì²é¸ù£¡ 
		int p=par[i];
		if(p==0) cnt++;
		else if(low[i]>=pre[p]) ans.insert(p);  
	} 
	if(cnt>1)ans.insert(0);
	set<int>::iterator it;
	for(it=ans.begin();it!=ans.end();it++) printf("%d\n",*it);
}
main(){
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++){
		int u,v;
		scanf("%d%d",&u,&v);
		G[u].push_back(v);
		G[v].push_back(u);
	}
	solve();
}




Measured memory_bytes: 6912
from collections import Counter
from bisect import bisect_right

def prime_decompose(x):
    decomposed = []
    for i in range(2,int(pow(x,0.5))+1):
        while x % i == 0:
            x //= i
            decomposed.append(i)
    if x > 1:
        decomposed.append(x)
    return decomposed

N = int(input())
d = prime_decompose(N)
cnt = Counter(d)
ref = [0] * 50
for i in range(len(ref)):
    ref[i] = sum(range(1,i+2))

ans = 0
for i in cnt:
    ans += bisect_right(ref, cnt[i])

print(ans)



Measured memory_bytes: 9656
#include <iostream>
#include<sstream>
#include<string>
#include<vector>
#include <cmath>
#include <limits>
#include <queue>
#include<algorithm>
#include<cstring>
#include <cstdlib>
#include <cstdio>
#include <set>
#include <iomanip>
#include <map>
#include <stack>
#include <memory>
#include <numeric>
#include <type_traits>
 
using namespace std;
 
#define rep(i,n) for (int (i)=0;(i)<(n);i++)


int main(){
    string s;
    cin >> s;
    int zero = 0, one = 0, res = 0;
    rep(i,s.length()){
        if (s[i] == '0'){
            if (one > 0){
                --zero; --one; res += 2;
            }
            ++zero;
        }
        else{
            if (zero > 0){
                --zero; --one; res += 2;
            }
            ++one;
        }
    }
    cout << res << endl;

    
    
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define co(n) cout<<n<<endl
using namespace std;

int main(){ 
  int n,x=0,y=0,ans=100000,c=0;
  cin>>n>>x;
  int xx[n][x];
  rep(i,0,n) rep(j,0,x) cin>>xx[i][j];
  
  rep(i,0,n-1){
    rep(j,i+1,n){
      rep(k,0,x){
        c+=(xx[i][k]-xx[j][k])*(xx[i][k]-xx[j][k]);
      }
      ans=pow(c,0.5);
      if(c==ans*ans) y++;
      c=0;
    }
  }
  co(y);
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
const bool debug=false;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main(void) {
    int n,l;
    cin >> n >> l;
    int s=0;
    int res=INT_MAX,diff;
    rep(i,n){
        s+=l+i;
    }
    diff=INT_MAX;
    rep(i,n){
       if(abs(l+i)<diff){
           diff=abs(l+i);
           res=s-(l+i);
       }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import math
from operator import mul
from functools import reduce
import numpy as np
import sys
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect
from scipy.special import comb
import copy
sys.setrecursionlimit(10**6)

# lis_of_lis = [[] for _ in range(N)]


def zz():
    return list(map(int, sys.stdin.readline().split()))


def z():
    return int(sys.stdin.readline())


def S():
    return sys.stdin.readline()[:-1]


def C(line):
    return [sys.stdin.readline() for _ in range(line)]


N = z()
L = zz()
L = sorted(L)
ans = 0
for i, j, k in itertools.combinations_with_replacement(range(N), 3):
    if((L[i] + L[j] > L[k]) and (not ((L[i] == L[k]) or (L[i] == L[j]) or (L[j] == L[k])))):
        # print(L[i], L[j], L[k])
        ans += 1
print(ans)


Measured memory_bytes: 42448
n = int(input())
a = list(map(int, input().split()))
from collections import Counter
c = Counter(a)
vals = [True]*(max(a)+1)
ans = 0
m = max(a)+1
for i in range(1, m):
    if i not in c:
        continue
    if c[i]>=2:
        vals[i] = False
    for j in range(2*i, m, i):
        vals[j] = False
ans = 0
for i in range(1, max(a)+1):
  if vals[i] and i in c:
    ans += 1

print(ans)

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

using namespace std;
using ll = long long;

int main(void) {
  int n, m;
  cin >> n >> m;
  vector<pair<int , int>> vec(m);
  for (int i =0; i < m; i++) {
    cin >> vec[i].first >> vec[i].second;
  }
  int ud= vec[0].first;
  int tp = vec[0].second;
  for (int i = 1; i < m; i++) {
    if (ud < vec[i].first) ud = vec[i].first; 
    if (tp > vec[i].second) tp = vec[i].second;
  }
  if (tp < ud) {
    cout << 0 << endl;
    return 0;
  }
  cout << tp - ud + 1 << endl;
	return 0;
}



Measured memory_bytes: 1024
a, b, c, d = map(int, input().split())
mod = 998244353
DP = [[0] * (d+1) for _ in range(c+1)]

DP[a][b] = 1
for y in range(a+1, c+1):
    DP[y][b] = DP[y-1][b] * b % mod

for x in range(b+1, d+1):
    DP[a][x] = DP[a][x-1] * a % mod

for y in range(a+1, c+1):
    for x in range(b+1, d+1):
        DP[y][x] = (DP[y-1][x] * x + (DP[y][x-1] - DP[y-1][x-1] * (x-1)) * y + DP[y-1][x-1] * (x-1)) % mod

print(DP[c][d])


Measured memory_bytes: 133796
#include <stdio.h>
#include <math.h>
 
int main(){
    double v,t,y;
    int N;
    while(0<=scanf("%lf",&v)){
        t=v/9.8;
        y=4.9*t*t;
        for(N=0;5*N-5<y;N++){
        }
        printf("%d\n",N);
    }
    return 0;
}

Measured memory_bytes: 628
import java.util.*

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val n = scanner.nextInt()
    val title = mutableListOf<String>()
    val sec = IntArray(n)
    for (i in 0..n-1) {
        title.add(i, scanner.next())
        sec[i] = scanner.nextInt()
    }
    val startTitle = scanner.next()

    val sleepIndex = title.indexOf(startTitle) + 1

    var sum = 0
    for (i in sleepIndex..n-1) {
        sum += sec[i]
    }
    println(sum)
}

Measured memory_bytes: 29464
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
  return list(map(int,input().split()))
def m(): #複数文字
  return map(int,input().split())
def onem(): #Nとかの取得
  return int(input())
def s(x): #圧縮
  a = []
  if len(x) == 0:
    return []
  aa = x[0]
  su = 1
  for i in range(len(x)-1):
    if aa != x[i+1]:
      a.append([aa,su])
      aa = x[i+1]
      su = 1
    else:
      su += 1
  a.append([aa,su])
  return a
def jo(x): #listをスペースごとに分ける
  return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
  return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
  ll = 0
  rr = r
  while True:
    mid = (ll+rr)//2

  if rr == mid:
    return ll
  if (ここに評価入れる):
    rr = mid
  else:
    ll = mid+1
"""
n = input()[:-1]

for i in range(3):
  po = int(n[i])
  if po == 7:
    print("Yes")
    break
else:
  print("No")







Measured memory_bytes: 65144
N = int(input())
D = [list(map(int, input().split())) for _ in range(N)]
ans = 'No'

for i in range(0, N - 2):
    if D[i][0] == D[i][1] and D[i + 1][0] == D[i + 1][1] and D[i + 2][0] == D[i + 2][1]:
        ans = 'Yes'
        break

print(ans)

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

int main() {
	int n, m, sum;
	int a[100][100], b[100], ab[100];

	for(int i=0; i<100; i++) {
		for(int j=0; j<100; j++) {
			a[i][j] = 0;
		}
		b[i] = 0;
		ab[i] = 0;
	}

	cin >> n >> m;

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

	for(int i=0; i<m; i++) {
		cin >> b[i];
	}

	for(int i=0; i<n; i++) {
		sum = 0;
		for(int j=0; j<m; j++) {
			sum += a[i][j] * b[j];
		}
		ab[i] = sum;
	}

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

	return 0;
}


Measured memory_bytes: 3140
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char* argv[])
{
	int W,H;
	cin>>H>>W;
	string s;
	int i;
	for (i=0;i<H;i++){
		cin>>s;
		for (int j=1;j<=2;j++){
			cout<<s<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
sx, sy, tx, ty = map(int, input().split())

for i in range(ty - sy):
    print("U", end = "")

for i in range(tx - sx):
    print("R", end = "")

for i in range(ty - sy):
    print("D", end = "")

for i in range(tx - sx + 1):
    print("L", end = "")

for i in range(ty - sy + 1):
    print("U", end = "")

for i in range(tx - sx + 1):
    print("R", end = "")

print("DR", end = "")

for i in range(ty - sy + 1):
    print("D", end = "")

for i in range(tx - sx + 1):
    print("L", end = "")

print("U", end = "")

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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define ALL(v) (v).begin(), (v).end()
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO  cout << "NO"  << endl
#define No  cout << "No"  << endl

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    int N, X; cin >> N >> X;
    vi L(N); REP(i, N) cin >> L[i];
    int pos = 0;
    int ans = 0;
    REP(i, N)
    {
        if(pos <= X) ans++;
        pos = pos + L[i];
    }
    if(pos <= X) ans++;
    cout << ans << endl;
} 
    
int main() 
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

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

using namespace std;
typedef long long ll;

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

  vector<long long> a(n);

  long long ans = 0;

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

  for(int i=1; i<n; i++){
    ans += max(ll(0), a[i - 1] - a[i]);
    a[i] += max(ll(0), a[i - 1] - a[i]);
  }

  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 4400
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cctype>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <numeric>
#include <functional>
#include <cstdlib>
#include <regex>
#include <list>
#include <cstring>
#include <math.h>

int main() {
	std::string s;
	std::cin >> s;
	int a = s.size();
	for (int i = 0;i < a;++i) {
		if (i % 2 == 0) {
			if (s[i] == 'L') {
				std::cout << "No" << std::endl;
				return 0;
			}
		}
		else {
			if (s[i] == 'R') {
				std::cout << "No" << std::endl;
				return 0;
			}
		}
	}
	std::cout << "Yes" << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;

#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
//void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
///////////////////////////////////////



int main(){fastio
    ll r,d,x;cin>>r>>d>>x;
    rep(i,1,10){
        x=r*x-d;
        cout<<x<<" ";
    }
    
    return 0;
}




Measured memory_bytes: 256
class MathAlgo(object):

    @classmethod
    def gcd(cls, a, b):
        if b == 0:
            return a
        else:
            return cls.gcd(b, a%b)


N,M = map(int,input().split())
S=input(); T=input()

base = MathAlgo.gcd(N,M)

for i in range(base):
    if S[len(S) //base *i] != T[len(T) //base *i]:
        print(-1)
        break
else:
    print(N //base *M)


Measured memory_bytes: 3316
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long k = sc.nextLong();
		long ans = -1;
		long[] tmp = new long[2];
		long i = -1;
		ans = Math.abs(n-k);
		long j = ans;
		if(n > k){
			long z = n/k;
			long w = z+1;
			z = Math.abs(n-z*k);
			w = Math.abs(n-w*k);
			System.out.println(Math.min(z, w));
		} else {
			while(ans != 0 || i != ans){
				ans = Math.abs(ans-k);
				if(ans == 0 || i == ans) {
					System.out.println(Math.min(ans, j));
					break;
				}
				i = j;
				j = ans;
			}
		}
	}
}


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

int main() {
	int N;
	cin >> N;
	string s;
	cin >> s;
	int B = 0, R = 0;
	for (int i = 0; i < N; ++i) {
		if (s[i] == 'B') ++B;
		else ++R;
	}
	if (B < R) cout << "Yes";
	else cout << "No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long A,B,N;
  cin >> A >> B >> N;

  long long AB = A*(B-1)/B;
  long long AN = A*N/B;
  
  if(B-1 <= N){
    cout << AB << endl;
  }else{
    cout << AN << endl;
  }
}

Measured memory_bytes: 3648
import java.util.*;

public class Main{
	static Scanner sc = new Scanner(System.in);
	
	public static void main(String[] args){
		int n = sc.nextInt();
		int nOdd = (n % 2 == 0) ? n / 2 : (n + 1) / 2;
		double ans = 1.0 * nOdd / n;
		System.out.println(ans);
	}
}

Measured memory_bytes: 22228
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>

using namespace std;
using ll = long long;

int main() {

	cin.tie(nullptr); ios::sync_with_stdio(false);

	int A, B, C, D; cin >> A >> B >> C >> D;

	int ans = (B > D ? D : B) - (A > C ? A : C);

	if (ans <= 0)ans = 0;

	cout << ans;

	return 0;

}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main(){
    cin.tie(0);cout.tie(0);
    ios::sync_with_stdio(false);
	int n;
	cin>>n;

	int i;
	for(i=1;;i++){
		if((1<<i)<=n&&(1<<(i+1))>n){
			break;
		}
	}
	cout<<(1<<i)<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
#define pb push_back
#define rsz resize
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
using pi = pair<int,int>;
#define f first
#define s second
#define mp make_pair
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
void setIO(string name = "a") {
    ios_base::sync_with_stdio(0); cin.tie(0);
    freopen((name+".in").c_str(), "r", stdin);
    freopen((name+".out").c_str(), "w", stdout);
}

int main() {
    //setIO();
    vi v (3);
    for (int i = 0; i < 3; i++) {
        cin >> v[i];
    } sort(all(v));
    if (v[2] == v[1] + v[0]) {
        cout << "Yes" << "\n";
    } else {
        cout << "No" << "\n";
    }
}

Measured memory_bytes: 3620
#include<iostream>
#include<map>
#include<string.h>
#include<queue>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<cstdlib>
#include<math.h>
#include<set>
#include<array>
using namespace std;

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



#define rep(n) for(int i=0;i<n;i++)
typedef pair<int, int> pii;

typedef long long ll;
typedef pair<ll, ll>pll;
const int MOD = 1000000007;
const int INF = 1 << 29;


int main() {
	
	ll k, a, b;
	cin >> k >> a >> b;
	ll h = k-a + 1;
	ll j = h % 2;
	if (a >= b-1 || h/2==0)cout << 1 + k << endl;
	else cout <<a+ (b-a) * ll(h / 2) + j << endl;
	return 0;
	
}


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

using namespace std;

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

constexpr int MAXN = 300000;

char S[MAXN + 2];

int main() {
	int N;
	cin >> N >> S;
	int sume = 0, sumw = 0;
	for(int i = 0; i < N; i++)
		sumw += S[i] == 'E';
	int ans = INT_MAX;
	for(int i = 0; i < N; i++) {
		sumw -= S[i] == 'E';
		ans = min(ans, sume + sumw);
		sume += S[i] == 'W';
	}
	cout << ans << endl;
}


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

int main(void){
    int N , bcount;
    string s;
    bool flag = false;

    cin >> N;
    cin >> s;
    bcount = 0;
    for (int i = 0;i < s.length(); i++){
        if(s[i] == 'B'){
            bcount++;
        }
    }

    flag = s.length() - bcount > bcount ? true : false;

    if(flag){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
template<class Monoid>
class SegmentTree
{
public:
    using Func = function<Monoid(Monoid, Monoid)>;
    SegmentTree(int n, const Func f, const Monoid& unity)
    :F(f)
    ,UNITY(unity)
    {
        Init(n);
    }

    void Init(int n)
    {
        SIZE_R = 1;
        while (SIZE_R < n) SIZE_R *= 2;
        dat.assign(SIZE_R * 2 - 1, UNITY);
    }

    void Set(int i, const Monoid& v)
    {
        dat[i + SIZE_R - 1] = v;
    }

    void Update(int i, const Monoid& v)
    {
        i += SIZE_R - 1;
        dat[i] = v;
        while (i > 0)
        {
            i = (i - 1) / 2;
            dat[i] = F(dat[i * 2 + 1], dat[i * 2 + 2]);
        }
    }

    Monoid Get(int i, int j)
    {
        return Get(i, j, 0, 0, SIZE_R);
    }

    inline Monoid operator[](int i) { return dat[i + SIZE_R]; }

    void Print()
    {
        for (int i = 0; i < SIZE_R; ++i)
        {
            cout << (*this)[i];
            if (i != SIZE_R - 1) cout << ", ";
        }
        cout << endl;
    }

private:
    Monoid Get(int i, int j, int k, int l, int r)
    {
        if (r <= i || j <= l) return UNITY;
        if (i <= l && r <= j) return dat[k];
        else
        {
            Monoid vl = Get(i, j, k * 2 + 1, l, (l + r) / 2);
            Monoid vr = Get(i, j, k * 2 + 2, (l + r) / 2, r);
            return F(vl, vr);
        }
    }

    const Func F;
    const Monoid UNITY;
    int SIZE_R;
    vector<Monoid> dat;
};
//------------------------------------------------------------------------------
template<typename T>
T GCD(T a, T b) { return b ? GCD(b, a % b) : a; }

void _main()
{
    int N;
    cin >> N;

    SegmentTree<ll> st(N, [](ll a, ll b) { return GCD(a, b); }, 0 );
    vector<ll> A(N);
    rep(i, 0, N)
    {
        cin >> A[i];
        st.Update(i, A[i]);
    }

    ll ans = 0;
    rep(i, 0, N)
    {
        ll left = st.Get(0, i);
        ll right = st.Get(i + 1, N);
        chmax(ans, GCD(left, right));
    }
    cout << ans << endl;
}


Measured memory_bytes: 3072
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"

using namespace std;
using namespace __gnu_pbds;


#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()

typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)
ll fre[200001];
int main(void)
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, tot = 0;
    cin>>n;
    ll a[n], i;
    for(i=0; i<n; i++) {
    	cin>>a[i];
    	fre[a[i]]++;
    }
    for(i=0; i<200001; i++) {
    	tot += (fre[i]*(fre[i] - 1))/2;
    }
    // cout<<tot<<"\n";
    for(i=0; i<n; i++) {
    	ll cur = tot;
    	cur = cur - (fre[a[i]] * (fre[a[i]] - 1))/2;
    	ll temp = fre[a[i]] - 1;
    	cur += (temp*(temp - 1))/2;
    	cout<<cur<<"\n";
    }
}

Measured memory_bytes: 4736
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.nextLine());
		int AC = 0;
		int WA = 0;
		int TLE = 0;
		int RE = 0;

		for(int i = 0; i < N ; i++) {
			String result = sc.nextLine();
			switch(result) {
			case "AC":
				AC ++;
				break;
			case "WA":
				WA ++;
				break;
			case "TLE":
				TLE ++;
				break;
			case "RE":
				RE ++;
				break;
			default:
				break;
			}
		}
		System.out.println("AC x " + AC);
		System.out.println("WA x " + WA);
		System.out.println("TLE x " + TLE);
		System.out.println("RE x " + RE);


	}
}

Measured memory_bytes: 60220
import java.util.*;
 
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        double v[] = new double[n];
        for (int i = 0; i < n; i++) {
            v[i] = sc.nextDouble();
        }

        quick_sort(v, 0, n-1);

        double sum = (v[0] + v[1]) / 2;

        for (int i = 2; i < n; i++) {
            sum = (sum + v[i]) / 2;
        }

        System.out.println(sum);
    }
    
    static void quick_sort(double[] d, int left, int right) {
        if (left>=right) {
            return;
        }
        int p = (int)d[(left+right)/2];
        int l = left, r = right, tmp;
        while(l<=r) {
            while(d[l] < p) { l++; }
            while(d[r] > p) { r--; }
            if (l<=r) {
                tmp = (int)d[l]; d[l] = d[r]; d[r] = tmp;
                l++; r--;
            }
        }
        quick_sort(d, left, r);  // ピボットより左側をクイックソート
        quick_sort(d, l, right); // ピボットより右側をクイックソート
    }
}


Measured memory_bytes: 23124
#include<stdio.h>
int data[100];

int fib(int n)
{
  if(n == 0 || n == 1)return data[n]= 1;
  if(data[n] != -1)return data[n];
  return data[n] = fib( n - 2 ) + fib( n - 1 );
}



int main()
{
  int n;
  int i;
  
  scanf("%d",&n);
  for( i = 0; i < 100; i++)
    data[i] = -1;
  printf("%d\n",fib(n));
}



Measured memory_bytes: 2112
N = int(input())
numbers = list(map(int, input().split()))
odd_num_cnt = 0
even_num_cnt = 0
four_mal_cnt = 0
for i in numbers:
    if i % 4 == 0:
        four_mal_cnt += 1
    elif i % 2 == 0:
        even_num_cnt += 1
    else:
        odd_num_cnt += 1
if four_mal_cnt >= odd_num_cnt or (four_mal_cnt == odd_num_cnt - 1 and even_num_cnt == 0):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 20148
import sys
def main():
    s = input().rstrip()
    nums = [ord(c)-ord("a") for c in s]
    if len(s) < 26:
        c = ""
        for x in range(26):
            f = True
            for y in nums:
                if x == y:
                    f = False
                    break
            if f:
                c = chr(x + ord("a"))
                break
        print(s+c)
    else:
        if s == "zyxwvutsrqponmlkjihgfedcba":
            print("-1")
        else:
            x = -1
            for i in reversed(range(25)):
                if nums[i] < nums[i+1]:
                    x = i
                    break
            p = 26
            for i in range(x+1, 26):
                if nums[x] < nums[i] and nums[i] < p:
                    p = nums[i]
            print(s[:x]+chr(p+ord("a")))

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include<iostream>
#include<queue>
#include<vector>
int gcd(int a, int b);
using namespace std;
long long int dp[3002][3002];
long long int mod = 998244353;
long long int DP(long long int X, long long int Y);
int main() {


	//B
	long long int A, B, C, D;
	cin >> A >> B >> C >> D;
	dp[A][B] = 1;
	int i;
	for (i = A + 1; i <= C; i++) {
		dp[i][B] = (dp[i - 1][B] * B) % mod;
	}
	for (i = B + 1; i <= D; i++) {
		dp[A][i] = (dp[A][i-1] * A) % mod;
	}
	cout << DP(C, D) << endl;
	return 0;

	//A
	/*int x;
	cin >> x;
	cout << 360 / gcd(360, x) << endl;

	return 0;
}
int gcd(int a, int b) {
	if (a == 0) {
		return b;
	}
	else if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}*/
}
long long int DP(long long int X, long long int Y) {
	//cout << X << ':' << Y << endl;
	if (dp[X][Y] > 0) {
		return dp[X][Y];
	}
	else {
		//dp[X][Y] = (((DP(X - 1, Y)*Y)%mod) + ((DP(X, Y - 1)*X)%mod)- ((DP(X-1,Y-1)*(X-1)*(Y-1))%mod)) % mod;
		dp[X][Y] = (((DP(X - 1, Y)*Y)%mod) + ((DP(X, Y - 1)*X)%mod) + mod -  ((DP(X-1,Y-1)*(X-1)*(Y-1))%mod)) % mod;

		return dp[X][Y];
	}
}


Measured memory_bytes: 74264
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define MOD 1000000007
#define enld endl
typedef long long ll;
using namespace std;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int n,m; cin >> n >> m;
    int H[100100];
    int highest[100100]; // high[i] := 展望台iを含めて一本の道を使って辿り着ける展望台のうち最大の高さの展望台
    int height[100100];
    for(int i=0;i<n;i++) cin >> H[i];
    for(int i=0;i<n;i++){
        highest[i] = i;
        height[i] = H[i];
    }
    for(int i=0;i<m;i++){
        int a,b; cin >> a >> b;
        a--; b--;
        if(H[a] >= height[b]){
            highest[b] = a;
            height[b] = H[a];
        }
        if(H[b] >= height[a]){
            highest[a] = b;
            height[a] = H[b];
        }
    }

    int ans = 0;
    for(int i=0;i<n;i++){
        if(highest[i] == i) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4780