akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define llong long long
#define INF (__INT32_MAX__ / 2)
#define EPS 10e-8
#define MAX_N 100000

using namespace std;
typedef pair<llong, llong> ipair;
llong modulo(llong left, llong right) { return (left % right + right) % right; }

llong N, C;
ipair sushi[MAX_N + 2];
llong cw_oneway[MAX_N + 2], cw_round[MAX_N + 2];
llong ccw_oneway[MAX_N + 2], ccw_round[MAX_N + 2];

llong solve() {
    llong v_sum = 0;
    cw_oneway[0] = cw_round[0] = 0;
    for(int i = 1; i <= N; ++i) {
        v_sum += sushi[i].second;
        cw_oneway[i] = max(cw_oneway[i - 1], v_sum - sushi[i].first);
        cw_round[i] = max(cw_round[i - 1], v_sum - sushi[i].first * 2);
    }

    v_sum = 0;
    ccw_oneway[N + 1] = ccw_round[N + 1] = 0;
    for(int i = N; i >= 1; --i) {
        v_sum += sushi[i].second;
        ccw_oneway[i] = max(ccw_oneway[i + 1], v_sum - (C - sushi[i].first));
        ccw_round[i] = max(ccw_round[i + 1], v_sum - (C - sushi[i].first) * 2);
    }

    llong res = 0;
    for(int i = 0; i <= N; ++i)
        res = max(res, cw_round[i] + ccw_oneway[i + 1]);
    for(int i = 0; i <= N; ++i)
        res = max(res, cw_oneway[i] + ccw_round[i + 1]);

    return res;
}

int main(int argc, char **argv) {
    cin >> N >> C;
    for(int i = 1; i <= N; ++i)
        cin >> sushi[i].first >> sushi[i].second;
    
    sort(sushi + 1, sushi + N + 1);
    
    cout << solve() << endl;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 100005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 +c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
int N,M;
struct node {
    int to,v,next;
}E[MAXN * 2];
int head[MAXN],sumE,col[MAXN];
bool vis[MAXN];
int cnt[5];
int64 ans,s,num;
bool flag = 0;
void add(int u,int v,int c) {
    E[++sumE].to = v;
    E[sumE].next = head[u];
    E[sumE].v = c;
    head[u] = sumE;
}
void dfs(int u) {
    vis[u] = 1;++num;
    ++cnt[col[u]];
    for(int i = head[u] ; i ; i=  E[i].next) {
	int v = E[i].to;++s;
	if(vis[v]) {
	    if(col[v] != (col[u] + E[i].v + 3) % 3) flag = 1;
	}
	else {
	    col[v] = (col[u] + E[i].v + 3) % 3;
	    dfs(v);
	}
    }
}
void Solve() {
    read(N);read(M);
    int a,b;
    for(int i = 1 ; i <= M ; ++i) {
	read(a);read(b);
	add(a,b,1);
	add(b,a,-1);
    }
    for(int i = 1 ; i <= N ; ++i) {
	if(!vis[i]) {
	    memset(cnt,0,sizeof(cnt));
	    col[i] = 0;
	    s = 0;num = 0;
	    flag = 0;dfs(i);
	    if(!flag) {
		if(!cnt[0] || !cnt[1] || !cnt[2]) {
		    ans += s / 2;
		}
		else {
		    ans += 1LL * cnt[1] * cnt[0];
		    ans += 1LL * cnt[2] * cnt[1];
		    ans += 1LL * cnt[2] * cnt[0];
		}
	    }
	    else {
		ans += 1LL * num * num;
	    }
	}
    }
    out(ans);enter;
}

int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}


Measured memory_bytes: 6528
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define MAX_V 100005

ll gcd(ll a, ll b){
	ll c;
	while(true){
		c=a%b;
		if(c==0){
			return b;
		}
		a=b;
		b=c;
	}
}

int main(void){
	ll N,X,inp;
	vector<ll> town;
	cin>>N>>X;
	rep(i,N){
		cin>>inp;
		town.push_back(abs(inp - X));
	}
	ll ans = town[0];
	rep(i,N-1){
		ans = gcd(ans, town[i+1]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
int dp[100006];
int arr[100006];
int fun(int n ){
	
  if(n==1) return 0;
  if(dp[n]!=-1)return dp[n];
  if(n>=3)dp[n]=min(abs(arr[n]-arr[n-2])+fun(n-2),abs(arr[n]-arr[n-1])+fun(n-1));
  else dp[n]=abs(arr[n]-arr[n-1])+fun(n-1);
  return dp[n];
}


int main(){
int n ;
cin>>n;
for(int i=1;i<=n;i++)cin>>arr[i],dp[i]=-1;

cout<<fun(n)<<endl;
return 0;
}

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

#define ll long long

void chmin(ll&a, ll b) {
  if (a > b) a = b;
}

int main() {
  ll N;
  cin >> N;
  
  ll minimum = 1000000000000000;
  for (int i = 0; i < 5; i++) {
    ll x;
    cin >> x;
    chmin(minimum, x);
  }

  
  cout << (N+minimum-1) / minimum + 4 << endl;
  
}

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

int n;
bool can[123];

int main(){
    ios_base::sync_with_stdio(0);
    //ifstream in ("input.txt");

    cin>>n;

    for(int i=1;i<=9;i++){
        for(int j=1;j<=9;j++){
            can[i*j]=true;
        }
    }

    cout << (can[n]?"Yes":"No") << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*) array, (T*) (array + N), val);
}
pii Dir [] = {
	{ 1,0 },{ 0,1 }
};
void visit(const vector<vector<int>> &g, int v, vector< vector<int> >& scc,
	stack<int> &S, vector<bool> &inS,
	vector<int> &low, vector<int> &num, int& time) {
	low[v] = num[v] = ++time;
	S.push(v); inS[v] = true;
	for (auto e : g[v]) {
		int w = e;
		if (num[w] == 0) {
			visit(g, w, scc, S, inS, low, num, time);
			low[v] = min(low[v], low[w]);
		}
		else if (inS[w])
			low[v] = min(low[v], num[w]);
	}
	if (low[v] == num[v]) {
		scc.push_back(vector<int>());
		while (1) {
			int w = S.top(); S.pop(); inS[w] = false;
			scc.back().push_back(w);
			if (v == w) break;
		}
	}
}
void stronglyConnectedComponents(const vector<vector<int>>& g,
	vector< vector<int> >& scc) {
	const int n = g.size();
	vector<int> num(n), low(n);
	stack<int> S;
	vector<bool> inS(n);
	int time = 0;
	REP(u, n) if (num[u] == 0)
		visit(g, u, scc, S, inS, low, num, time);
}
signed main() {
	int n;
	scnaf("%d", &n);
	vector<int> a(n);
	REP(i, n) {
		scnaf("%d", &a[i]);
	}
	int Min = INT_MAX;
	rep(i, -100, 101) {
		int sum = 0;
		REP(j, n) {
			sum += PW(a[j] - i);
		}
		Min = min(Min, sum);
	}
	printf("%d\n" , Min);
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>

/*
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };
*/

using namespace std;

int main()
{
    int n;
    cin >> n;
    bool ans = false;
    for (int i = 0; i * 4 <= n;i++){
        if((n-i*4)%7==0)
            ans = true;
    }
    if(ans)
        cout << "Yes";
    else
        cout << "No";
}

Measured memory_bytes: 256
/*input
5
2 5 2
2 3 10
1 3 8
3 4 2
*/
#include <bits/stdc++.h>
using namespace std;
#define TEMPLATE

#ifdef TEMPLATE
	typedef long long ll;
	typedef long double ld;
	typedef complex<ld> cd;

	typedef pair<int, int> pi;
	typedef pair<ll,ll> pl;
	typedef pair<ld,ld> pd;

	typedef vector<int> vi;
	typedef vector<vi> vii;
	typedef vector<ld> vd;
	typedef vector<ll> vl;
	typedef vector<vl> vll;
	typedef vector<pi> vpi;
	typedef vector<vpi> vpii;
	typedef vector<pl> vpl;
	typedef vector<cd> vcd;
	typedef vector<pd> vpd;
	typedef vector<bool> vb;
	typedef vector<vb> vbb;
	typedef std::string str;
	typedef std::vector<str> vs;

	#define x first
	#define y second
	#define debug(...) cout<<"["<<#__VA_ARGS__<<": "<<__VA_ARGS__<<"]\n"

	const int MOD = 1000000007;
	const ll INF = std::numeric_limits<ll>::max();
	const int MX = 100101;
	const ld PI = 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111745028410270L;

	template<typename T>
	pair<T, T> operator+(const pair<T, T> &a, const pair<T, T> &b) { return pair<T, T>(a.x + b.x, a.y + b.y); }
	template<typename T>
	pair<T, T> operator-(const pair<T, T> &a, const pair<T, T> &b) { return pair<T, T>(a.x - b.x, a.y - b.y); }
	template<typename T>
	T operator*(const pair<T, T> &a, const pair<T, T> &b) { return (a.x * b.x + a.y * b.y); }
	template<typename T>
	T operator^(const pair<T, T> &a, const pair<T, T> &b) { return (a.x * b.y - a.y * b.x); }
#endif

vpi edges[MX];
vi color;

void dfs(int c, int p){
	for(auto u: edges[c]){
		if(u.x == p) continue;

		color[u.x] = (u.y & 1 ? !color[c]: color[c]);
		dfs(u.x, c);
	}
}
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int N;
	cin >> N;
	color = vi(N);
	int a, b, w;

	for (int i = 0; i < N-1; ++i)
	{
		cin >> a >> b >> w;a--;b--;
		edges[a].push_back({b, w});
		edges[b].push_back({a, w});
	}

	color[0] = 0;
	dfs(0, -1);

	for(auto u: color)
		printf("%d\n", u);
}

/* Look for:
* special cases (n=1?)
* overflow (ll vs int?)
* the exact constraints (multiple sets are too slow for n=10^6 :( ) 
* array bounds
*/
	

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

int main() {
  string C;
  cin >> C;
  if(C == "a") {
    cout << "b" << endl;
  }
  if(C == "b") {
    cout << "c" << endl;
  }
  if(C == "c") {
    cout << "d" << endl;
  }
  if(C == "d") {
    cout << "e" << endl;
  }
  if(C == "e") {
    cout << "f" << endl;
  }
  if(C == "f") {
    cout << "g" << endl;
  }
  if(C == "g") {
    cout << "h" << endl;
  }
  if(C == "h") {
    cout << "i" << endl;
  }
  if(C == "i") {
    cout << "j" << endl;
  }
  if(C == "j") {
    cout << "k" << endl;
  }
  if(C == "k") {
    cout << "l" << endl;
  }
  if(C == "l") {
    cout << "m" << endl;
  }
  if(C == "m") {
    cout << "n" << endl;
  }
  if(C == "n") {
    cout << "o" << endl;
  }
  if(C == "o") {
    cout << "p" << endl;
  }
  if(C == "p") {
    cout << "q" << endl;
  }
  if(C == "q") {
    cout << "r" << endl;
  }
  if(C == "r") {
    cout << "s" << endl;
  }
  if(C == "s") {
    cout << "t" << endl;
  }
  if(C == "t") {
    cout << "u" << endl;
  }
  if(C == "u") {
    cout << "v" << endl;
  }
  if(C == "v") {
    cout << "w" << endl;
  }
  if(C == "w") {
    cout << "x" << endl;
  }
  if(C == "x") {
    cout << "y" << endl;
  }
  if(C == "y") {
    cout << "z" << endl;
  }
}

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

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

    int x, a;
    cin >> x >> a;
    if (x < a) cout << 0 << endl;
    else cout << 10 << endl;
}

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

int h, w, i, j, y, x, k, ans;
char mat[10][10];

int count()
{
    int cnt = 0;
    for (y = 0; y < h; ++y) {
        if ((1 << y) & i)
            continue;

        for (x = 0; x < w; ++x) {
            if ((1 << x) & j)
                continue;

            if (mat[y][x] == '#')
                cnt++;
        }
    }
    return cnt;
}

int main()
{
    cin >> h >> w >> k;
    for (i = 0; i < h; ++i)
        cin >> mat[i];

    for (i = 0; i < (1 << h); ++i) {
        for (j = 0; j < (1 << w); ++j) {
            if (count() == k)
                ans++;
        }
    }
    cout << ans << '\n';
}


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

class Mondai
{
    static void Main()
    {
        var line = Console.ReadLine().Split(' ').Select(x => Int32.Parse(x)).ToArray();
        var N = line[0];
        var A = line[1];
        var B = line[2];
        var C = line[3];
        var D = line[4];
        var S = Console.ReadLine().ToCharArray();
        var isGyaku = false;
        var startGyaku = 0;
        var endGyaku = N - 1;
        if (A< B && D < C)
        {
            isGyaku = true;
            startGyaku = Math.Max(A,B);
            endGyaku = Math.Min(C,D);
        }
        var isNotKasanari = false;
        var notKasanariStart = 0;
        var notKasanariEnd = 0;
        if (C < B)
        {
            isNotKasanari = true;
            notKasanariStart = C-1;
            notKasanariEnd = B-1;
        }
        var start = Math.Min(A,B);
        var end = Math.Max(C,D);
        var ans = "Yes";
        var canGyaku = false;
        for (int i=1;i<N;++i)
        {
            if (isNotKasanari)
            {
                if (notKasanariStart < i && i < notKasanariEnd) continue;
            }
            if (start-1<i && i < end)
            {
                if (S[i-1]=='#' && S[i] == '#')
                {
                    ans = "No";
                    break;
                }
            }
            if (isGyaku && !canGyaku)
            {
                if (startGyaku-2 < i && i < endGyaku)
                {
                    if (i<N-1 && S[i-1] == '.' && S[i] == '.' && S[i + 1] == '.')
                    {
                        canGyaku = true;
                    }
                }
            }
        }
        if (isGyaku)
        {
            if (canGyaku == false) ans = "No";
        }
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 13376
-- haskell
import Data.List
import Debug.Trace

main = getContents >>= (putStrLn . show . ans)

ans :: String -> Int
ans str = maximum $  0 : [y - 1 | (x,y) <- zip hist [0,1..] , x + 1 >= y]
  where
    hist = take (n + 10) $ scanl (+) 0 diff_table
    diff_table = zipWith (-) as_table bs_table
    as_table = tail $ countList as_counted 0
    bs_table = countList bs_counted 0
    as_counted = map (\x -> (head x, length x)) . group $ as_sorted
    bs_counted = map (\x -> (head x, length x)) . group $ bs_sorted
    as_sorted = sort as
    bs_sorted = sort bs
    as = map head l
    bs = map (head . tail) l
    n = length l
    l = map (map read . words) . tail . lines $ str


countList :: [(Int, Int)] -> Int -> [Int]
countList [] _ = repeat 0
countList ((x,y):xs) i =
  if x == i then y : (countList xs (i + 1)) else 0 : (countList ((x,y) : xs) (i + 1))

Measured memory_bytes: 121864
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <utility>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <istream>
#include <ostream>

#include <cstdlib>
#include <cmath>
#include <cstdio>

using namespace std;

#define fi first
#define se second
#define mkp make_pair
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define rep(i,n) for(ll i=0; i < (n); ++i)
#define rrep(i,n) for(ll i=((n)-1); i >= 0; --i)

#define OPLT(T) bool operator<(const T & lop_, const T & rop_)
#define OPEQ(T) bool operator==(const T & lop_, const T & rop_)

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

istream& operator>>(istream& istr, __float128& obj) { double d; istr >> d; obj = d; return istr; };
ostream& operator<<(ostream& ostr, __float128& obj) { ostr << static_cast<double>(obj); return ostr; };

int main() {
	string s;
	cin >> s;
	cout << string(s.begin(), s.end() - (8)) << endl;
	return 0;
}


Measured memory_bytes: 256
N = input()
L = len(N)
N = int(N)
C = 0
dig = 1
try:
    while dig < L:
        if dig % 2 == 1:
            C = C + 10 ** dig * 0.9
        else:
            C = C
        dig += 1

    if dig == L:
        if dig % 2 == 1:
            C = C + N - (10 ** (dig - 1) - 1)
        else:
            C = C

    print(int(C))
except:
    print("ERROR NO 2")
    import traceback
    traceback.print_exc()

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

int n, m;
vector<ll> a,c;
bool f = false;
bool vis[1050][(1<<12)+5];
ll dp[1050][(1<<12)+5];

ll solve(int i, int open) {
    if (i==m) {
        int temp = (1<<n)-1;
        if (open==temp) {
            f = true;
            return 0;
        }
        return (ll)1e15;
    }
    if (vis[i][open]) return dp[i][open];
    vis[i][open] = true;
    // printf("%d %d\n", i, open);
    return dp[i][open] = min(a[i]+solve(i+1, open | c[i]), solve(i+1, open));
}

int main() {
    scanf("%d %d", &n, &m);
    a.resize(m, 0ll);
    c.resize(m, 0ll);
    memset(vis, 0, sizeof vis);
    for (int i=0; i<m; i++) {
        scanf("%lld", &a[i]);
        int l;
        scanf("%d", &l);
        while (l--) {
            int k;
            scanf("%d", &k);
            c[i] |= (1<<(k-1));
        }
        // printf("c[%d] = %lld\n", i, c[i]);
    }
    ll z = solve(0, 0);
    if (!f) {
        printf("-1\n");
        return 0;
    }
    printf("%lld\n", z);
}

Measured memory_bytes: 37632
class SegmentTree():
    """一点更新、区間取得クエリをそれぞれO(logN)で答えるデータ構造を構築する
    update: i番目をvalに変更する
    get_min: 区間[begin, end)の最小値を求める
    """
    def __init__(self, n):
        self.n = n
        self.INF = 0
        self.size = 1
        while self.size < n:
            self.size *= 2
        self.node = [self.INF] * (2*self.size - 1)

    def update(self, i, val):
        i += (self.size - 1)
        self.node[i] = val
        while i > 0:
            i = (i - 1) // 2
            self.node[i] = self.node[2*i + 1] | self.node[2*i + 2]

    def get_min(self, begin, end):
        begin += (self.size - 1)
        end += (self.size - 1)
        s = 0
        while begin < end:
            if (end - 1) & 1:
                end -= 1
                s = s | self.node[end]
            if (begin - 1) & 1:
                s = s | self.node[begin]
                begin += 1
            begin = (begin - 1) // 2
            end = (end - 1) // 2
        return s

import sys
input = sys.stdin.readline


n = int(input())
s = input()
q = int(input())
query = [list(input().split()) for i in range(q)] 

alph = "abcdefghijklmnopqrstuvwxyz"
to_int = {char: i for i, char in enumerate(alph)}
st = SegmentTree(n)

for i, char in enumerate(s[0:n]):
    st.update(i, 1 << to_int[char]) 

for num, l, r in query:
    if num == "1":
        st.update(int(l) - 1, 1 << to_int[r]) 
    else:
        tmp = st.get_min(int(l) - 1, int(r))
        print(bin(tmp).count("1"))

Measured memory_bytes: 73436
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	int f=0;
	for(int i=0;i<s.size();++i){
		if(s.substr(i,1)=="C")f=1;
		if(f==1 && s.substr(i,1)=="F"){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
} 

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#define ll long long int
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};
int mx2[] = {1,0};
int my2[] = {0,1};

class BPopularVote {
public:
	void solve(istream& in, ostream& out) {
        int n,m,h = 0;
        in >> n >> m;
        vector<int> a(n);
        rep(i,n) in >> a[i];
        rep(i,n) h += a[i];
	    sort(a.rbegin(),a.rend());
	    bool ok = true;
	    rep(i,m){
	        if(a[i] * 4 * m < h){
	            ok = false;
	        }
	    }
	    if(ok) out << "Yes" << endl;
	    else out << "No" << endl;

	}
};

int main() {
	BPopularVote solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f3f3f3f3fLL
#define SIZE 200010

using namespace std;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
long long int MOD = 1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int N;
vi xs,ys;
double pi=2.0*acos(0.0);
vector<pair<pair<double,double>,int> > data;
vi ans;
int main(){
	cin>>N;
	int lef=0;
	for(int i=0;i<N;i++){
		double x,y;
		cin>>x>>y;
		data.pb(mp(mp(x,y),i));
	}
	sort(data.begin(),data.end());
	reverse(data.begin(),data.end());
	int num=0,nxnum;
	double kakub=acos(0.0);
	while(1){
		double fromx=data[num].first.first,fromy=data[num].first.second;
		nxnum=0;
		double mi=2.0*pi,kakumemo;
		for(int i=0;i<N;i++){
			if(i!=num){
				double nowx=data[i].first.first,nowy=data[i].first.second;
				nowx-=fromx;
				nowy-=fromy;
				double kaku=acos(nowx/sqrt(nowx*nowx+nowy*nowy));
				if(nowy<0.0){
					kaku=2.0*pi-kaku;
				}
				double kakuc=kaku-kakub;
				if(kakuc<0)kakuc+=2.0*pi;
				//cout<<kakuc<<endl;
				if(kakuc<mi){
					mi=kakuc,nxnum=i,kakumemo=kaku;
				}
			}
		}
		//cout<<endl;
		ans.pb(num);
		//cout<<num<<endl;
		kakub=kakumemo;
		if(nxnum==0)break;
		num=nxnum;
	}
	double ans2[105]={0.0};
	int n=ans.size();
	/*rep(i,n){
			 cout<<data[ans[i]].second<<endl;
	 }*/
	for(int i=0;i<ans.size();i++){
		int n1=ans[i],n2=ans[((i+1)%n)],n0=ans[((i+n-1)%n)];
		double x1=data[n2].first.first-data[n1].first.first;
		double y1=data[n2].first.second-data[n1].first.second;
		double ka1=acos(x1/sqrt(x1*x1+y1*y1));
		if(y1<0.0)ka1=2.0*pi-ka1;
		double x2=data[n1].first.first-data[n0].first.first;
		double y2=data[n1].first.second-data[n0].first.second;
		double ka2=acos(x2/sqrt(x2*x2+y2*y2));
		if(y2<0.0)ka2=2.0*pi-ka2;
		double ka=ka1-ka2;
		if(ka<0.0)ka+=2.0*pi;
		ans2[data[ans[i]].second]=ka/(2.0*pi);
		//cout<<ka/(2.0*pi)<<endl;
	}
	for(int i=0;i<N;i++)printf("%.7lf\n",ans2[i]);
}

Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>

int main(int argc, char *argv[]){
        int r;
        double pi = 3.1415926535897932;
        double ans;
        scanf("%d",&r);
        ans = 2 * r * pi;
        printf("%lf",ans);
        return 0;
}

Measured memory_bytes: 1748
k, a, b = gets.chomp.split.map(&:to_i)
if k >= 2 && a + 2 < b
  if k < a + 1
    puts k + 1
  else
    if (k - (a - 1)) % 2 == 0
      puts a + (b - a) * ((k - (a - 1)) / 2)
    else
      puts a + (b - a) * ((k - (a - 1)) / 2) + 1
    end
  end
else
  puts k + 1
end

Measured memory_bytes: 1788
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>
#include <cassert>
#include <random>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll conbinationMemo[100][100];

void cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
//-----------------------ここから-----------
random_device rnd;
mt19937 mt(rnd());
uniform_int_distribution<> rand26(1, 26);
int main(void){
    ll d;
    cin >> d;
    rep(i, d){
        cout << rand26(mt) << endl;
    }
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <limits>
#include <numeric>

using namespace std;
using ll = long long;

int calc(const vector<int>& v)
{
    int time = 0;

    for (int i = 0; i < v.size()-1; ++i) {
        time += v[i];
        if (time % 10 != 0) {
            time += 10 - (time % 10);
        }
    }

    time += v[v.size()-1];

    return time;
}

int main()
{
    vector<int> v(5);
    for (auto&& vi : v) {
        cin >> vi;
    }

    int ans = 1000;

    do {
        ans = min(ans, calc(v));
    } while (next_permutation(begin(v), end(v)));

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

int main()
{
    fast;
    int n,i;
    cin>>n;
    int sub[n+1]={0},a;
    for (i=0;i<n-1;i++)
    {
        cin>>a;
        sub[a]++;
    }
    for (i=1;i<=n;i++)
        cout<<sub[i]<<endl;
    return 0;
}

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

int main(){
    int N, K;
    cin >> N >> K;
    vector<int> d(K);
    vector<int> S(N, 1);
    vector<vector<int>> A(K, vector<int>(N));
    for (int i = 0; i < K; ++i){
        int d[i];
        cin >> d[i];
        for (int j = 0; j < d[i]; ++j){
            cin >> A[i][j];
            S[A[i][j]-1] = 0;
        }
    }
    int ans = 0;
    for (int i = 0; i < N; ++i){
        ans += S[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3576
import java.util.*;
public class Main {
    Scanner sc = new Scanner(System.in);
    boolean solve(int N, int Y) {
	for(int	i = 0; i <= N; i++) {
            int	v1 = i * 10000;
            if(v1 > Y) break;
            for(int j =	0; j <=	N; j++) {
		int v2 = v1 + j	* 5000;
		if(v2 >	Y || i + j > N) break;
		int k =	N - i -	j;
		int v3 = v2 + k	* 1000;
		
		if(v3 == Y) {
                    System.out.println(i + " " + j + " " + k);
                    return true;
                }
            }
        }
        return false;
    }
    void doIt() {
        boolean ret = solve(sc.nextInt(), sc.nextInt());
        if(!ret ) System.out.println("-1 -1 -1");
    }
    public static void main(String args[]) {
        new Main().doIt();
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, a, b) for(int i = (a); i <= (b); i++)
#define PER(i, a, b) for(int i = (a); i >= (b); i--)
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define all(S) (S).begin(), (S).end()
#define pb push_back
#define mk make_pair
#define S second
#define F first
typedef long long ll;
typedef long double lf;
typedef pair<int, int> ii;
const int MAX = 2e5+5;
char s[MAX];
int ans;

int main(int argc, char ** argv) {
	scanf(" %s", s);
	int sz = strlen(s);
	rep(i, 0, sz) ans += (s[i]-'0');
	printf("%s\n", (ans%9) ? "No" : "Yes");
	return 0;
}



Measured memory_bytes: 3952
import java.util.Scanner;

public class Main {
  public static void main(String... args) {

    Scanner scan = new Scanner(System.in) ;

    int n = scan.nextInt() ;

    long[] arr = new long[n];

    for (int i=0; i<n; i++) arr[i] = scan.nextInt() ;

    long max = Long.MIN_VALUE ;
    long min = Long.MAX_VALUE ;
    long sum = 0 ;

    for (long i: arr) {

      if(i > max) max = i ;
      if(i < min) min = i ;
      sum += i ;
    }

    System.out.println(min + " " + max + " " + sum ) ;

  }
}



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

using namespace std;

const int MAXN = 100010;

int n, d;

int v[MAXN];

vector< int > ans;

int main()
{
	scanf("%d %d",&n,&d);

	for(int i = 1 ; i <= n ; i++)
		scanf("%d",&v[i]);

	int mx = 1;

	for(int i = 2 ; i < n ; i++)
		if( v[mx] + v[mx + 1] < v[i] + v[i + 1] ) mx = i;

	if( v[mx] + v[mx + 1] < d )
	{
		printf("Impossible\n");
		return 0;
	}

	for(int i = 1 ; i < mx ; i++)
		ans.push_back( i );

	for(int i = n - 1 ; i > mx ; i--)
		ans.push_back( i );

	ans.push_back( mx );

	printf("Possible\n");

	for(int i = 0 ; i < ans.size() ; i++)
		printf("%d\n",ans[i]);
}

Measured memory_bytes: 1784
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {
    private static int MOD = 1000000007;


    public static void main(String[] args) throws IOException {
        InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
        String str = br.readLine();
        if (str.contains("7")) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


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

void solve(std::istream &ist, std::ostream &ost)
{
    /* ------- 宣言と入力 ------- */

    int N;
    ist >> N;

    vector<string> S;

    unordered_set<string> keihin;

    for (int i = 0; i < N; i++)
    {
        string input;
        ist >> input;
        S.emplace_back(input);
        keihin.emplace(input);
    }

    /* ------- 計算 ------- */
    cout << keihin.size() << endl;
}

#ifndef WOMAIN
int main()
{
    solve(std::cin, std::cout);
    return 0;
}
#endif


Measured memory_bytes: 23936
# Disjoint Set: Union Find Tree
class UnionFind:
    def __init__(self, N):
        self.N = N  # ノード数
        # 最初は全てが根であるとして初期化        
        self.parent = [-1] * N  # idxが各ノードのid, 値がそのノードの親ノードのid
        self.rank = [0] * N # idxが各ノードのid, 値がそのノードの集合における高さ

    def root(self, x):  # ノードのidを受け取って一番上の親ノードのidを帰す
        if (self.parent[x] < 0):
            return x
        self.parent[x] = self.root(self.parent[x])  # 経由したノードすべての親を上書き（経路圧縮）
        return self.parent[x]

    def unite(self, x, y): # ノード番号を2つ受け取って、そのノード同士をつなげる処理を行う。
        # 引数のノードを直接つなぐ代わりに、親同士を連結する処理にする。
        rx = self.root(x) # xの根をrx
        ry = self.root(y) # yの根をry
        if (rx == ry): # xとyの根が同じ(=同じ木にある)時はそのまま
            return False

        if (self.rank[rx] > self.rank[ry]): # 高い方に低い方をつなぐ
            self.parent[ry] = rx
        else:
            self.parent[rx] = ry
            if (self.rank[rx] == self.rank[ry]):
                self.rank[ry] += 1

        return True

    def same(self, x, y):
        return self.root(x) == self.root(y)

N, Q = map(int, input().split())
ds = UnionFind(N)
for _ in range(Q):
    com, x, y = map(int, input().split())
    if com == 0:
        # unite
        ds.unite(x, y)
    elif com == 1:
        # same?
        print(1 if ds.same(x, y) else 0)


Measured memory_bytes: 5812
#include <stdio.h>

int conv_chr2int(char ch) {
    if(ch=='1') {
        return 1;
    } else {
        return 0;
    }
}

int main() {
    char s1, s2, s3;
    scanf("%c%c%c", &s1, &s2, &s3);

    int a, b, c;
    a = conv_chr2int(s1);
    b = conv_chr2int(s2);
    c = conv_chr2int(s3);

    printf("%d\n", a+b+c);

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#define T true
#define F false

using namespace std;

int main(void) {
	int i, l, r, num, k, lim, sum, ans = 0;
	cin >> num >> k;
	vector<int> d(num);
	lim = min(num, k);
	for (i = 0; i < num; i++)
		scanf("%d", &d[i]);
	for (l = 0; l <= lim; l++) {
		for (r = 0; l + r <= lim; r++) {
			sum = 0;
			priority_queue<int, vector<int>, greater<int>> s;
			for (i = 0; i < l; i++) {
				s.push(d[i]);
				sum += d[i];
			}
			for (i = num - 1; i >= num - r; i--) {
				s.push(d[i]);
				sum += d[i];
			}
			for (i = 0; i < k - r - l; i++) {
				if (!s.empty() && s.top() < 0) {
					sum -= s.top();
					s.pop();
				}
				else
					break;
			}
			ans = max(ans, sum);
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
A1 = [0] * 3
A2 = [0] * 3
A3 = [0] * 3
for i in range(3):
    A1[i], A2[i], A3[i] = map(int, input().split())
A = A1 + A2 + A3

N = int(input())
l_index = []
for i in range(N):
    b = int(input())
    if b in A:
        l_index.append(A.index(b))
    
s0 = set(l_index)

if {0,1,2}.issubset(s0):
    print('Yes')
elif {3,4,5}.issubset(s0):
    print('Yes')
elif {6,7,8}.issubset(s0):
    print('Yes')
elif {0,3,6}.issubset(s0):
    print('Yes')
elif {1,4,7}.issubset(s0):
    print('Yes')
elif {2,5,8}.issubset(s0):
    print('Yes')
elif {0,4,8}.issubset(s0):
    print('Yes')
elif {2,4,6}.issubset(s0):
    print('Yes')
else:
    print('No')

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

int main()
{
    // input
    int n, k;
    cin >> n >> k;

    // solve
    double ans=0;
    for(int i=1; i<=n; i++){
        ll a=i;
        ll cnt=0;
        while(a<k) {a*=2; cnt++;}
        ans += (double) 1 / (pow(2,cnt)*n);
    }

    // output
    cout << fixed << setprecision(15) << ans << endl;


    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <map>
using namespace std;

int main(void){
    int N; cin >> N;
    int a[N];
    for(int i=0; i < N; i++) {
        cin >> a[i];
    }
    map<int, int> mp;
    for(int i=0; i < N; i++) {
        mp[a[i]] += 1;
    }
    int ans = 0;
    for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
        int key = itr->first, val = itr->second;
        if(val - key >= 0) ans += val - key;
        else ans += val;
    }
    cout << ans << endl;
}

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

// #include "../../template-proj/myMente.h"

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;

#define MOD 1000000007
#define rp(i,n) for(int i=0;i<(n);i++)
#define up(i,s,e,d) for(int i=(s);i<(e);i+=(d))
#define ot(x) cout<<(x)
#define ote(x) cout<<(x)<<endl

int main(){
	int N; cin>>N;
	// int a,b,c; cin>>a>>b>>c;
	// string s; cin>>s;

	ll ans = 0;
	rp(i,N-1){
		ans += i+1;
	}

	ote(ans);
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	defer w.Flush()

	var N int
	fmt.Scan(&N)

	if N == 3 {
		fmt.Println("2 5 63")
		return
	}
	if N == 4 {
		fmt.Println("2 5 20 63")
		return
	}
	if N == 5 {
		fmt.Println("2 5 20 30 63")
		return
	}

	found := make([]int, 0, N+4)
	for k := 0; len(found) < N; k++ {
		found = append(found, 6*k+2)
		found = append(found, 6*k+3)
		found = append(found, 6*k+4)
		found = append(found, 6*k+6)
	}

	ans := found[:N]
	sum := Sum(ans...)
	switch sum % 6 {
	case 2:
		// ans[0] == 2
		next6 := ans[N-1] + 6 - (ans[N-1] % 6)
		ans[0] = next6
	case 3:
		// ans[1] == 3
		next6 := ans[N-1] + 6 - (ans[N-1] % 6)
		ans[1] = next6
	case 5:
		// 9
		// ans[1] == 3
		var next4 int
		switch ans[N-1] % 6 {
		case 0:
			next4 = ans[N-1] + 4
		case 2:
			next4 = ans[N-1] + 2
		case 3:
			next4 = ans[N-1] + 1
		case 4:
			next4 = ans[N-1] + 6
		}
		ans[1] = next4
	}

	for _, a := range ans {
		Printf("%d ", a)
	}
}

func Sum(slice ...int) int {
	sum := 0
	for _, v := range slice {
		sum += v
	}
	return sum
}

var w = bufio.NewWriter(os.Stdout)

func Printf(format string, a ...interface{}) { fmt.Fprintf(w, format, a...) }


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

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

  vector<vector<int> > v(n, vector<int>(2, 0));
  rep(i, n){
    int a;
    cin >> a;
    rep(j, a){
      int x, y;
      cin >> x >> y;
      if (y == 0) v[i][0] |= (1 << (x-1));
      if (y == 1) v[i][1] |= (1 << (x-1));
    }
  }

  int ans = 0;
  rep(i, 1 << n){
    int h = 0;
    int u = 0;
    int count = 0;
    rep(j, n){
      if ((i>>j) & 1) {
        h |= v[j][1];
        u |= v[j][0];
        count++;
      }
    }
    if ((i == (i | h)) && (i == (i & ~u))){
      ans = max(ans, count);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3624
s = list(input())
op = ['+', '-']
for op1 in op:
    for op2 in op:
        for op3 in op:
            ans = s[0]+op1+s[1]+op2+s[2]+op3+s[3]
            if eval(ans) ==7:
                print(ans + '=7')
                exit()

Measured memory_bytes: 2940
from bisect import bisect_right, bisect_left
from itertools import groupby, permutations, combinations
from fractions import gcd
import numpy as np
from sys import stdin, stderr


def lcm(x, y):
    return (x * y) // gcd(x, y)


def main():
    H, A = [int(x) for x in input().split()]
    return H // A if H % A == 0 else H // A + 1


if __name__ == "__main__":
    print(main())

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

int main(){
    int N;
    cin >> N;
    int candies[2][N];
    int score_sum = 0;
    for(int i = 0; i < 2; i++){
        for(int j = 0; j < N; j++){
            cin >> candies[i][j];
            if(i){
                score_sum += candies[i][j];
            }
        }
    }
    score_sum += candies[0][0];
    int ans = score_sum;
    for(int i = 1; i < N; i++){
        score_sum -= candies[1][i - 1];
        score_sum += candies[0][i];
        ans = max(ans, score_sum);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
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 All(v) (v).begin(), (v).end()
typedef long long ll;

int gcd(int a, int b) {
    if(b == 0)
        return a;
    else
        return gcd(b, a % b);
}

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    vector<int> lgcd(N + 1), rgcd(N + 1);
    for(int i = 0; i < N; i++) {
        lgcd[i + 1] = gcd(lgcd[i], A[i]);
    }
    for(int i = N - 2; i >= 0; i--) {
        rgcd[i] = gcd(rgcd[i + 1], A[i + 1]);
    }
    int res = 0;
    rep(i, N) {
        // cout << i << ":" << lgcd[i] << " " << rgcd[i] << endl;
        res = max(res, gcd(lgcd[i], rgcd[i]));
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1408
#include<stdio.h>
int main(void){

	int data[10];
	int i,j,t;

	for(i=0;i<10;i++){
		scanf("%d",&data[i]);
	}
	for(i=0;i<9;i++){
		for(j=0;j<9-i;j++){
			if(data[j]<data[j+1]){
				t=data[j];
				data[j]=data[j+1];
				data[j+1]=t;
			}
		}
	}
	for(i=0;i<3;i++){
		printf("%d\n",data[i]);
	}
	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  map<int,bool> mp;
  for(int i=0; i<N; i++){
    int x;
    cin >> x;
    if(!mp.count(x)){
      mp[x] = true;
    }
  }
  if(mp.size() == N){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 9600
#include <cstdio>
#include <iostream>
#include <deque>
using namespace std;

int main(){

  int n;
  cin >> n;
  deque<int> dq;
  int t = n % 2;
  for (int i = 0; i < n; i++) {
    int k;
    scanf("%d", &k);
    if (t == 0) dq.push_back(k);
    if (t == 1) dq.push_front(k);
    t = (t+1) % 2;
  }

  for (int i = 0; i < n; i++) {
    if (i == 0) printf("%d", dq[i]);
    else printf(" %d", dq[i]);
  }
  printf("\n");

  return 0;
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
 
int main(){
    string s;
    cin >> s;
    ll n = s.size();
    ll ans = 0;
    bool flag = false;
    bool next_dig = false;
    rep(i, n) {
        int tmp = s[n-i-1] - '0';
        if (flag == true) tmp++;
        if (tmp == 5) {
            ans += 5;
            if (i==n-1) flag = false;
            else if (s[n-i-2] - '0' >= 5) flag = true;
            else flag = false;
        } else if (10-tmp > tmp) ans += tmp, flag = false;
        else ans += 10 - tmp, flag = true;
    }
    if (flag == true) ans ++;
    cout << ans << endl;
}

Measured memory_bytes: 1412
s = gets.chomp
larger_than_left = [0]
consecutive = 0
s.each_char.with_index do |c|
  consecutive = c == "<" ? consecutive + 1 : 0
  larger_than_left.push(consecutive)
end
larger_than_right = [0]
consecutive = 0
s.reverse.each_char do |c|
  consecutive = c == ">" ? consecutive + 1 : 0
  larger_than_right.unshift(consecutive)
end
ans = 0
(s.size + 1).times { |i| ans += [larger_than_left[i], larger_than_right[i]].max }
puts ans


Measured memory_bytes: 24660
def gcd(n, m)
    if n % m == 0
        m
    else
        gcd(m, n % m)
    end
end

while line = gets
    m, n = line.split.map(&:to_i)
    gcd = gcd(m, n)
    lcm = m * n / gcd
    puts "#{gcd} #{lcm}"
end

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

#define times(n, i) uptil(0, n, i)
#define upto(f, t, i) for(auto _##i = (t), i = decltype(_##i)(f) poi  i <= _##i poi  i++)
#define uptil(f, t, i) for(auto _##i = (t), i = decltype(_##i)(f) poi  i < _##i poi  i++)
#define downto(f, t, i) for(auto i = (f), _##i = decltype(i)(t) poi  i >= _##i poi  i--)
#define downtil(f, t, i) for(auto i = (f), _##i = decltype(i)(t) poi  i > _##i poi  i--)

#define unless(c) if(!(c))
#define until(c) while(!(c))
#define loop while(true)

#define poi ;
#define poipoi << "\n"

using namespace std;

#define fuwafuwa(n, c) dokidoki((n) + (c) - 1, c)
#define dokidoki(n, c) ((n) / (c) * (c))

template<class T> bool read(T& t){
    return cin >> t poi
}
template<class T, class...U> bool read(T& t, U&... u){
    unless(cin >> t) return false poi
    return read(u...) poi
}

template<class T> T lov_yet(T t){
    if(t) return t poi
    else return 0 poi
}

template<class T> T gcd(T a, T b){
    if(b) return gcd(b, a % b) poi
    else return a poi
}

int main(){
    vector<int> count(1000000, 1) poi
    count[0] = count[1] = 0 poi

    times(1000000, i)
        if(count[i])
            upto(2, 1000000 / i, j)
                count[i * j] = 0 poi

    upto(1, 1000000, i)
        count[i] += count[i - 1] poi

    int n poi
    while(read(n)){
        cout << count[n] poipoi poi
    }

    return 0 poi
}

Measured memory_bytes: 4892
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

N,K = map(int,input().split())
A = list(map(int,input().split()))
D = sum(A)
D = make_divisors(D)[::-1]

for d in D:
    a = []
    for i in range(N):
        a.append(A[i]%d)
    k = 0
    M = max(a)
    while k <= K and M != 0:
        i = 0
        j = 0
        m = d
        M = 0
        for l in range(N):
            if 0 < a[l] < m:
                m = a[l]
                i = l
        for l in range(N-1,-1,-1):
            if a[l] > M:
                M = a[l]
                j = l
        if m == d:
            break
        if m <= d-M:
            a[i] = 0
            a[j] += m
            a[j] %= d
            k += m
        else:
            a[i] -= d-M
            a[i] %= d
            a[j] = 0
            k += d-M
    if k <= K:
        break

print(d)

Measured memory_bytes: 44140
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int c;
    cin>>c;
    if(c==0&&c<0){
        cout<<"0"<<endl;
        return 0;
    }
    else
    {
        cout<<pow(c,3)<<endl;
    }
    return 0;
}


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

template <typename T> T gcd(T x, T y) {
  if (y == 0)
    return x;
  return gcd(y, x % y);
}

template <typename T> T lcm(T x, T y) {
  if (x == 0 || y == 0)
    return 0;
  return x / gcd(x, y) * y;
}

int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}

vector<int> p;
vector<int> r;

void init(int n) {
  p.reserve(n);
  r.reserve(n);
  for (int i = 0; i < n; i++) {
    p[i] = i;
    r[i] = 0;
  }
}

int root(int x) { return p[x] == x ? x : p[x] = root(p[x]); }

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

void unite(int x, int y) {
  x = root(x);
  y = root(y);
  if (x == y)
    return;

  if (r[x] < r[y])
    p[x] = y;
  else {
    p[y] = x;
    if (r[x] == r[y])
      r[x]++;
  }
}

int main() {
  int N;
  cin >> N;
  if (N < 1000)
    cout << "ABC" << endl;
  else
    cout << "ABD" << endl;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
typedef long long ll;
const int mod= 1e+9+7;

int main() {
    string s; cin>>s;
    ll cntW=0;
    ll ans=0;
    rep(i,s.size()){
        if(s[i]=='W'){
            ans+=i;
            ans-=cntW;
            cntW++;
        }
    }
    /*ll a=0;
    for(int i=1;i<cntW;i++){
        a+=i;
    }
    //cout<<ans<<" "<<cntW<<" "<<a<<endl;
    cout<<ans-a<<endl;*/
    cout<<ans<<endl;

}

Measured memory_bytes: 640
N = int(input())
P = list(map(float, input().split()))


def solve():
    dp = [[0]*(i+2) for i in range(N+1)]
    dp[0][0] = 1
    for i in range(1,N+1):
        dp[i][0] = dp[i-1][0]*(1-P[i-1])
    for i in range(1,N+1):
        for j in range(1,i+1):
            dp[i][j] = dp[i-1][j-1]*P[i-1]+dp[i-1][j]*(1-P[i-1])
    ans = sum(dp[-1][(N+2)//2:])
    return ans
print(solve())

Measured memory_bytes: 215944