akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int k,n;
	cin>>k>>n;
	int a[n+1];
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	sort(a+1,a+n+1);
	int maxn=10000000;
	for(int i=1;i<=n;i++)
	{
		int s=0;
		s+=a[n]-a[i];
		if(i!=1){
			s+=k-a[n];
			s+=a[i-1];
		}
		if(s<maxn)
		maxn=s;
		s=0;
		s+=a[i]-a[1];
		if(i!=n)
		{
			s+=a[1];
			s+=k-a[i+1];
		}
		if(s<maxn)
		maxn=s;
	}
	cout<<maxn;
	return 0;
 } 

Measured memory_bytes: 1024
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstdlib>
#include<bitset>
#include<utility>
#include<sstream>
#include<iomanip>
#include<ctime>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;

#define ll long long
#define MP make_pair

int n,p[10],q[10],d[10]={},num=0,a,b;
bool jud;

int main(void) {

    cin>>n;
    for (int i = 0; i < n; i++) {
        cin>>p[i];
        d[i]=i+1;
    }
    for (int i = 0; i < n; i++) {
        cin>>q[i];
    }

    do{
        num++;
        jud=true;
        for (int i = 0; i < n; i++) {
            if(d[i]!=p[i])jud=false;
        }
        if(jud)a=num;
        jud=true;
        for (int i = 0; i < n; i++) {
            if(d[i]!=q[i])jud=false;
        }
        if(jud)b=num;
    }while(next_permutation(d,d+n));

    cout<<abs(a-b)<<"\n";
    

    
    return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//typedef vector<vector<ll>> Graph;

const ll mod = 1e9 + 7;
//const ll mod = 998244353;

#define REP(i,n) for(ll i=0;i<(ll)n;i++)
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define spa << " " <<
#define fi first
#define se second

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 (a>b) { a=b; return 1; } return 0; }

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

template<typename T> void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cerr<<v[i][0];for(ll j=1;j<w;j++)cerr spa v[i][j];cerr<<endl;}};
template<typename T> void debug(vector<T>&v,ll n){if(n!=0)cerr<<v[0];
for(ll i=1;i<n;i++)cerr spa v[i];
cerr<<endl;};

string num2bit(ll num, ll len){
    string bit = "";
    REP(i, len){
    bit += char('0'+(num>>i & 1));
    }
    return bit;
}

ll calc_score(ll D, vector<ll> &c, vector<vector<ll>> &s, vector<ll> &t){
    ll res = 0;
    vector<ll> last(26, -1);
    REP(d, D){
        res += s[d][t[d]];
        last[t[d]] = d;
        REP(i, 26){
            res -= c[i] * (d  - last[i]);
        }
        cout << res << endl;
    }
    return res;
}

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

    ll D;
    cin >> D;
    vector<ll> c(26);
    vector<vector<ll>> s(D, vector<ll>(26, 0));
    vector<ll> t(D);

    REP(i, 26) cin >> c[i];
    REP(i, D){
        REP(j, 26){
            cin >> s[i][j];
        }
    }
    REP(i, D) cin >> t[i];
    REP(i, D) t[i]--;

    calc_score(D, c, s, t);

    return 0;
}

Measured memory_bytes: 3716
"""
    リーダーに向いてない人の最小
    (W in 0~i) + (E in i+2~n-1)
"""
from collections import Counter as count
n = int(input())
s = input()
turn = count(s[1:])['E']
least = turn

for i in range(n-1):
    if s[i] == 'W':
        turn += 1
    if s[i+1] == 'E':
        turn -= 1
    if turn < least:
        least = turn

print(least)


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

const int MOD = 1000000007;
const int INF = 1e9;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n, i##_len=(n); i>=0; i--)
#define FOR(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)

//最大公約数 
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }

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

int main(){
int N;
cin >> N;
vector<string>s(N);
REP(i, N) cin >> s.at(i);

REP(i, N) sort(all(s.at(i)));
sort(all(s));
ll ans = 0;
ll tmp = 1;
for(int i = 0; i < N - 1; i++){ 
   if(s.at(i) == s.at(i + 1)){
     ans += tmp;
     tmp++;
   } else tmp = 1;


}

print(ans);

}


Measured memory_bytes: 7296
###############################################################################

from sys import stdout
from bisect import bisect_left as binl
from copy import copy, deepcopy
from collections import defaultdict


mod = 1


def intin():
    input_tuple = input().split()
    if len(input_tuple) <= 1:
        return int(input_tuple[0])
    return tuple(map(int, input_tuple))


def intina():
    return [int(i) for i in input().split()]


def intinl(count):
    return [intin() for _ in range(count)]


def modadd(x, y):
    global mod
    return (x + y) % mod


def modmlt(x, y):
    global mod
    return (x * y) % mod


def lcm(x, y):
    while y != 0:
        z = x % y
        x = y
        y = z
    return x


def combination(x, y):
    assert(x >= y)

    if y > x // 2:
        y = x - y

    ret = 1

    for i in range(0, y):
        j = x - i
        i = i + 1

        ret = ret * j
        ret = ret // i

    return ret


def get_divisors(x):
    retlist = []
    for i in range(1, int(x**0.5) + 3):
        if x % i == 0:
            retlist.append(i)
            retlist.append(x // i)
    return retlist


def get_factors(x):
    retlist = []
    for i in range(2, int(x**0.5) + 3):
        while x % i == 0:
            retlist.append(i)
            x = x // i
    retlist.append(x)
    return retlist


def make_linklist(xylist):
    linklist = {}
    for a, b in xylist:
        linklist.setdefault(a, [])
        linklist.setdefault(b, [])
        linklist[a].append(b)
        linklist[b].append(a)
    return linklist


def calc_longest_distance(linklist, v=1):
    distance_list = {}
    distance_count = 0
    distance = 0
    vlist_previous = []
    vlist = [v]
    nodecount = len(linklist)

    while distance_count < nodecount:
        vlist_next = []
        for v in vlist:
            distance_list[v] = distance
            distance_count += 1
            vlist_next.extend(linklist[v])
        distance += 1
        vlist_to_del = vlist_previous
        vlist_previous = vlist
        vlist = list(set(vlist_next) - set(vlist_to_del))

    max_distance = -1
    max_v = None
    for v, distance in distance_list.items():
        if distance > max_distance:
            max_distance = distance
            max_v = v

    return (max_distance, max_v)


def calc_tree_diameter(linklist, v=1):
    _, u = calc_longest_distance(linklist, v)
    distance, _ = calc_longest_distance(linklist, u)
    return distance


###############################################################################


def main():
    a, b = intin()

    c = a + b
    d = a - b
    e = a * b

    print(max([c, d, e]))

if __name__ == '__main__':
    main()


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

#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)

using namespace std;

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

int main() {
  int x;
  cin >> x;
  cout << (x >= 30 ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
ll gcd(ll a,ll b){if(a>b)swap(a,b);for(;a>0;b%=a,swap(a,b));return b;}
int modpow(ll a,ll n,int m){if(a==0)return a;ll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(int)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
int c[200005], n, k, a;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> k;
  FOR(i, 0, n){
    cin >> a;
    c[a]++;
  }
  sort(c, c+n+1);
  reverse(c, c+n+1);
  int ans = 0;
  FOR(i, k, n) ans += c[i];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace cShaprTest
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var x = new double[N];
            var u = new string[N];

            for(var i = 0; i < N; i++)
            {
                var input = Console.ReadLine().Split(' ');
                x[i] = double.Parse(input[0]);
                u[i] = input[1];
            }

            double sum = 0;

            for (var i = 0; i < N;i++)
            {
                if (u[i] == "JPY")
                {
                    sum += x[i];
                } else
                {
                    sum += 380000.0 * x[i];
                }
            }

            Console.WriteLine(sum);
        }
    }
}


Measured memory_bytes: 11220
#include<bits/stdc++.h>
using namespace std;
 
#define rep(i, a, n) for(int i=a; i<n; i++)
#define ll long long
#define all(x) begin(x), end(x)
#define toInt(x) (x - '0')
#define pll pair<ll, ll>
#define MAXN 200 + 5
const long long INF = 1LL << 60;
const int inf = 1 << 30;


int main(){
  long long n, k;
  cin >> n >> k;
  long long a = n / k;
  n -= a * k;
  cout << min(n, abs(n - k)) << endl;
}
     


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int getcard,losecard;
string get_c[100],lose_c[100];
int solve(string n)
{
	int ret=0;
	for(int i=0;i<getcard;i++)
	{
		if(get_c[i]==n)ret++;
	}
	for(int i=0;i<losecard;i++)
	{
		if(lose_c[i]==n)ret--;
	}
	return ret;
}
int main()
{
	cin>>getcard;
	for(int i=0;i<getcard;i++)
	{
		cin>>get_c[i];
	}
	cin>>losecard;
	for(int i=0;i<losecard;i++)
	{
		cin>>lose_c[i];
	}
	sort(get_c,get_c+getcard);
	sort(lose_c,lose_c+losecard);
	
	int ans=0;
	for(int i=0;i<getcard;i++)
	{
		if(i>0 && get_c[i]==get_c[i-1])continue;
		ans=max(solve(get_c[i]),ans);
	}
	cout<<ans<<endl;
	return 0;
}

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

#define llint long long int

using namespace std;

int main()
{
    string N;

    cin >> N;

    int count = 0;

    for (int i = 0; i < N.length(); i++)
    {
        count += (N[i] - '0');
    }
    if (count % 9 == 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3756
#coding: utf-8
import numpy as np
from functools import reduce

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

n,x = list(map(int,input().split()))

y = np.asarray(list(map(int,input().split())))
y -= x
y = map(abs,y)

print(reduce(gcd, y))


Measured memory_bytes: 23112
import java.util.*;
class Main{
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		int A = Integer.parseInt(in.next());
		int B = Integer.parseInt(in.next());
		int C = Integer.parseInt(in.next());
		int cnt = 0;
		int e = 0;
		if(A%2 == 0) e++;
		if(B%2 == 0) e++;
		if(C%2 == 0) e++;
		if(e == 1 || e == 2){
			if((A%2 == B%2)&&B%2 != C%2){
				A++;
				B++;
				cnt++;
			}
			if((B%2 == C%2)&&C%2 != A%2){
				B++;
				C++;
				cnt++;
			}
			if((C%2 == A%2)&&A%2 != B%2){
				C++;
				A++;
				cnt++;
			}
		}
		Integer[] arr = {A, B, C};
		Arrays.sort(arr, Collections.reverseOrder());
		while(arr[0] != arr[1]){
				arr[1] += 2;
				cnt++;
			}
		while(arr[1] != arr[2]){
			arr[2] += 2;
			cnt++;
		}
		
		System.out.println(cnt);
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;

int main() {
string S;
cin >> S;
int mini = INF;
for (int i = 0;i < S.size()-2;i++) {
    int a = (S.at(i) - '0') * 100 + (S.at(i+1) - '0') * 10 + (S.at(i+2) - '0');
    if (abs(a-753) < mini) mini = abs(a-753); 
}
cout << mini << endl;

return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <tuple>
#include <cstring>
#include <map>
#include <iomanip>
#include <ctime>
#include <complex>
#include <cassert>
#include <climits>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define _ << " " <<
#define all(X) (X).begin(), (X).end()
#define len(X) (X).size()
#define Pii pair<int, int>
#define Pll pair<ll, ll>
#define Tiii tuple<int, int, int>
#define Tlll tuple<ll, ll, ll>

ll n, a, b;
ll h[100010];
 
bool f(ll k) {
    ll s = 0;
    for (int i = 0; i < n; i++) {
        if (h[i] - b * k > 0) {
            s += ceil(double(h[i] - b * k) / (a - b));
        }
    }
    //cerr << k << " " << s << endl;
    return s <= k;
}
 
int main() {
    cin >> n >> a >> b;
    for (int i = 0; i < n; i++) cin >> h[i];
 
    ll ng = 0, ok = 2e9;
    while (ok - ng > 1) {
        ll mid = (ng + ok) / 2;
        if (f(mid)) ok = mid;
        else ng = mid;
    }
    cout << ok << endl;
}


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

using namespace std;

#define REP(a, b, c) for (register int a = b, _n = c; a <= _n; ++a)
#define DREP(a, b, c) for (register int a = b, _n = c; a >= _n; --a)
#define FOR(a, b, c) for (register int a = b, _n = c; a < _n; ++a)
#define DFOR(a, b, c) for (register int a = b, _n = c; a > _n; --a)
#define EREP(a, b) for (register int a = head[b]; a; a= edge[a].nxt)

inline int rd () {
	int x = 0; char IO = getchar();
	bool f = 0;
	while ((IO < '0' || IO > '9') && IO != '-') IO = getchar();
	if (IO == '-') f = 1, IO = getchar();
	while (IO >= '0' && IO <= '9') x = (x << 3) + (x << 1) + (IO ^ 48), IO = getchar();
	return f ? -x : x;
}

const int SIZE = 200005;

int n, m;
long long sum[SIZE];

int head[SIZE], ecnt;
struct Edge {
	int v, nxt;
} edge[SIZE << 1];
void Add_Edge (int u, int v) {
	++ecnt;
	edge[ecnt].v = v;
	edge[ecnt].nxt = head[u];
	head[u] = ecnt;
}

void dfs (int u, int fa) {
	EREP (i, u) {
		Edge& e = edge[i];
		if (e.v == fa) continue;
		sum[e.v] += sum[u];
		dfs(e.v, u);
	}
}

void _main () {
	scanf ("%d%d", &n, &m);

	FOR (i, 1, n) {
		int u = rd(), v = rd();
		Add_Edge(u, v);
		Add_Edge(v, u);
	}

	REP (i, 1, m) {
		int u = rd();
		sum[u] += rd();
	}

	dfs(1, 0);

	REP (i, 1, n)
		printf ("%lld ", sum[i]);
}

int main () {
#ifdef LOCAL
	freopen("in.txt", "r", stdin);
#endif
	_main();
	return 0;
}


Measured memory_bytes: 17280
#include <stdio.h>
int main(void)
{
  int num = 0;
  long n,d,x,y;
  
  scanf("%ld %ld",&n,&d);
  for(int i=0; i<n; i++){
    scanf("%ld %ld",&x,&y);
    if(x*x + y*y <= d*d)
      num++;
  }
  
  printf("%d\n",num);
  
  return 0;
}

Measured memory_bytes: 1732
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <queue>
#include <stack>
#include <string>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <array>
#include <set>
#include <climits>
#include <cassert>
#include <bitset>
using namespace std;
int dp[100000];
int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int h , n; cin>>h>>n;
    memset(dp , 1000000 , sizeof(dp));
    dp[0] = 0;
    int a, b;
    for(int i=0;i<n;++i){
        cin>>a>>b;
        for(int j=0;j<h;++j){
            dp[min(j+a,h)] = min(dp[min(j+a,h)],dp[j]+b);
        }
    }
    cout<<dp[h]<<endl;
    return 0;
}


Measured memory_bytes: 640
# Rem of sum is Num
# Reviewing problem


from collections import defaultdict


def cnt_func(X):
    res = 0
    right = 0
    L = len(X)
    for i in range(L):
        while right+1 < L and X[right+1] < K+X[i]:
            right += 1
        res += right-i
    return res


N, K = map(int, input().split())

A = list(map(int, input().split()))
A.insert(0, 0)
for i in range(1, N+1):
    A[i] += A[i-1]
B = [0 for i in range(N+1)]
for i in range(N+1):
    B[i] = (A[i]-i) % K
ans = 0
Mod = defaultdict(list)
for i in range(N+1):
    Mod[B[i]].append(i)
for X in Mod.values():
    ans += cnt_func(X)
print(ans)

Measured memory_bytes: 138492
#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; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int X, Y, Z;
    cin >> X >> Y >> Z;
    cout << ((X - Z) / (Y + Z)) << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(int)n; i++)
#define rep2(i,a,n) for(int i=(a); i<(int)(n); i++)
#define all(vec) vec.begin(),vec.end()
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using psi = pair<string, int>;
const int dx[4] = {1, 0,-1, 0};
const int dy[4] = {0, 1, 0,-1};
const ll mod = 1e9+7;
int gcd(int a, int b){if(a<b) swap(a,b); if (a%b == 0){return(b);}else{return(gcd(b, a%b));}}
int lcm(int a, int b){return a * b / gcd(a, b);}

long long N, M, K, H, W, L, R;

int main(){
  cin >> H >> W >> N;
  vi A(N); rep(i,N) cin >> A[i];
  vvi maze(H,vi(W));
  ll cnt = 0;
  ll crr = 1;
  rep(i,H){
    if(i%2 == 0){
      rep(j,W){
        maze[i][j]= crr;
        cnt++;
        if(cnt == A[crr-1]){crr++; cnt = 0;}
      }
    }else{
      for(int j=W-1; j>=0; j--){
        maze[i][j]= crr;
        cnt++;
        if(cnt == A[crr-1]) {crr++; cnt = 0;}
      }
    }
  }
  
  rep(i,H){
    rep(j,W){
      cout << maze[i][j];
      if(j != W-1) cout << " ";
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


int main()
{
    string s;
    cin >> s;
    int mR = 0;
    int mL = 0; 

    vector<int> num(s.size());
    int score = 0;
    int mL_p = 0;
    int mR_p = 0;
    s += 'R';
    for (int i = 1; i < s.size(); i++)
    {
        score++;
        if (s[i-1] == 'R' && s[i] == 'L'){
            mR = i-1;
            mL = i;
            if (score%2==0) mL_p = 1;
            else mR_p = 1;  
        }
        
        if ((s[i-1] == 'L' && s[i] == 'R')|| (i == s.size() -1)){
            //cout << i << " " << score << endl;
            if (score%2 == 0) { mL_p = 0; mR_p = 0; }
            num[mR] = score/2 + mR_p;
            num[mL] = score/2 + mL_p;
            score = 0;
            mL_p = 0; mR_p = 0;
        }
    }
    rep(i, s.size()-1){
        cout << num[i] << " ";
    }
    

}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
ll mod =1000000007;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX*/                      int gcd(ll a,ll b){return b?gcd(b,a%b):a;}
/*"lcm"   MIN*/                      int lcm(ll a,ll b){return a*b/gcd(a,b);}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
int main(){
ll a,b,m;
cin >> a >> b >> m;
vector<ll>aa(a),bb(b);
ll am = 10e17;
for(int i=0;i<a;i++){
    cin >>aa.at(i);
    am = min(am,aa.at(i));
}
ll bm=10e17;
for(int i=0;i<b;i++){
    cin >>bb.at(i);
    bm=min(bm,bb.at(i));
}
ll ans = bm+am;
for(int i=0;i<m;i++){
    ll x,y,c;
    cin >> x >> y >> c;
    if(aa.size()<x||bb.size()<y)continue;
    x--;
    y--;
    ll che = aa.at(x)+bb.at(y)-c;
    ans = min(ans,che);
}
cout << ans << endl;
}





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

int main() {
  int N;
  cin >> N;
  vector<int> mochi(N);

  for (int i = 0; i < N; i++) {
    cin >> mochi.at(i);
  }

  sort(mochi.begin(), mochi.end(), greater<int>());

  int ans = 0, prev = 101;
  for (int i = 0; i < N; i++) {
    if (prev <= mochi.at(i)) {
      continue;
    }
    
    ans++;
    prev = mochi.at(i);
  }

  cout << ans << endl;
}


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

int main() {
  	long long int A;
  	string S;
  	cin >> A >> S;
  	long long int B_ = (S[0] - '0') * 100 + (S[2] - '0') * 10 + (S[3] - '0') * 1;
  	cout << (A * B_) / 100 << endl;
}

Measured memory_bytes: 3620
#include<iostream>

int main(){
	int n, ans = 100000;
	std::cin >> n;
	for (int i = 0; i < n; ++i){
		ans *= 1.05;
		--ans;
		ans += 1000 - (ans % 1000);
	}
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<long long, int> ll_i;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << (x) << "\n"
#define debug2(x, y) cout << " --- " << (x) << " " << (y) << "\n"
#define debug3(x, y, z) cout << " --- " << (x) << " " << (y) << " " << (z) << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)

int t[200][3];
signed main(void){
  int i, j;
  for(int testcase = 0;testcase >= 0;testcase++){
    int(n);
    rep(i, n)rep(j, 3)scanf("%d", &t[i][j]);

    rep(i, n){
      int res = 0;
      rep(j, 3){
        int k;
        rep(k, n)if(k != i)if(t[i][j] == t[k][j])break;
        if(k == n)res += t[i][j];
      }
      pri(res);
    }


/*/

//*/ break;
  }
  return 0;
}

Measured memory_bytes: 3156
//
// Created by watemus on 03.05.2020.
//

#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>

using namespace std;

#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define ff first
#define ss second

using ll = long long;
using ld = long double;
#define int ll

constexpr ll INFL = 1'000'000'000'000'000'228;
constexpr int INFI = 1'000'000'228;

#ifdef LOCAL
#else
#endif


void run() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    map<int, int> cnt;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        ans += cnt[i - a[i]];
        cnt[i + a[i]]++;
    }
    cout << ans << '\n';
}

signed main() {
#ifdef LOCAL
    std::freopen("input.txt", "r", stdin);
#else
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
#endif
    int t = 1;
//    cin >> t;
    while (t--) {
        run();
    }
    return 0;
}

Measured memory_bytes: 27476
#include <algorithm>
#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int l;
    cin >> l;
    vector<int64_t> dp(5, 0);

    for (int i = 0; i < l; ++i)
    {
        int64_t A;
        cin >> A;
        int64_t diff2 = A == 0 ? 2 : A % 2;
        int64_t diff1 = (A + 1) % 2;
        dp[0] += A;
        dp[1] += diff2;
        dp[2] += diff1;
        dp[3] += diff2;
        dp[4] += A;

        for (int j = 1; j < 5; j++)
        {
            dp[j] = min(dp[j], dp[j - 1]);
        }
    }
    cout << dp[4] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

#define rep(i, e) for(int i = 0; i < e; i++)
#define repp(i, s, e) for(int i = s; i < e; i++)
#define MAX_N 100
#define Card_Max 36
#define p(a) printf("%d\n", a);
#define ll long long
#define ull unsigned long long
#define MAX 1e9
#define NIL -1

void print(vector<ll> &v) {
    rep(i, v.size()) {
        if(i)
            cout << " ";
        cout << v[i];
    }
    cout << endl;
}

int main() {
    int A, B, K;
    cin >> A >> B >> K;
    rep(i, K) {
        if(i % 2 == 0)
            if(A % 2 == 1) {
                A--;
                A /= 2;
                B += A;
            } else {
                A /= 2;
                B += A;
            }
        else {
            if(B % 2 == 1) {
                B--;
                B /= 2;
                A += B;
            } else {
                B /= 2;
                A += B;
            }
        }

        // cout << A << " " << B << endl;
    }
    cout << A << " " << B << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int X, Y;
  cin >> X >>Y;
  //cout << X <<endl;
  //cout << Y <<endl;
  int a=0; //turu
  int b=0; //kame
  b = (Y-2*X)/2;
  a = X-b;
  //cout << a <<endl;
  //cout << b<<endl;
  if (a<0 || b<0){
    cout << "No";
  }  
  else{
    if(a+b == X && 2*a+4*b == Y){
    cout << "Yes";
    }
    else{
      cout << "No";
    }
  }
}

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

int main(){
    int N;
    cin>>N;
    set<int> s;
    for(int i=0;i<N;i++){
        int d;
        cin>>d;
        s.insert(d);
    }
    cout<<s.size()<<endl;
}

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


int main(){
  ll n;
  cin >> n;
  cout << n*(n-1)/2 << endl;
  return 0;
}


Measured memory_bytes: 256
import glob
import numpy as np

# 問題ごとのディレクトリのトップからの相対パス
REL_PATH = 'ABC\\166\\B'

# テスト用ファイル置き場のトップ
TOP_PATH = 'C:\\AtCoder'

class Common:

    problem = []
    index = 0

    def __init__(self, rel_path):
        self.rel_path = rel_path

    def initialize(self, path):
        file = open(path)
        self.problem = file.readlines()
        self.index = 0
        return

    def input_data(self):
        try:
            IS_TEST
            self.index += 1
            return self.problem[self.index-1]
        except NameError:
            return input()

    def resolve(self):
        pass

    def exec_resolve(self):
        try:
            IS_TEST
            for path in glob.glob(TOP_PATH + '\\' + self.rel_path + '/*.txt'):
                print("Test: " + path)
                self.initialize(path)
                self.resolve()
                print("\n\n")
        except NameError:
            self.resolve()


class B(Common):

    def resolve(self):

        N, K = map(int, self.input_data().split())

        snack = np.zeros((N+1, K+1), dtype = int)

        for i in range(K):
            d = int(self.input_data())
            tmp = list(map(int, self.input_data().split()))
            for t in tmp:
                snack[t][i+1] = 1

        count = 0
        for i in range(1, N+1):
            if np.sum(snack[i,1:]) == 0:
                count += 1

        print(str(count))


solver = B(REL_PATH)
solver.exec_resolve()

Measured memory_bytes: 27404
#include <algorithm>
#include <iostream>

using namespace std;

const int N = 100000, M = 200000, INF = 0x3f3f3f3f;

int oo[1 + M * 2], oj[1 + M * 2];

int link(int o, int j) {
	static int _ = 1;
	oo[_] = o, oj[_] = j;
	return _++;
}

int ae[N], dd[N], pp[N];
int qu[N];

int main() {
	int n, m; cin >> n >> m;
	while (m--) {
		int i, j; cin >> i >> j, i--, j--;
		ae[i] = link(ae[i], j);
		ae[j] = link(ae[j], i);
	}
	fill(pp, pp + n, -1);
	fill(dd, dd + n, INF);
	int head = 0, cnt = 0;
	dd[0] = 0, qu[head + cnt++] = 0;
	while (cnt) {
		int i = qu[cnt--, head++];
		int d = dd[i] + 1;
		for (int o = ae[i]; o; o = oo[o]) {
			int j = oj[o];
			if (dd[j] == INF) {
				if (pp[j] != -1) {
					cout << "No\n";
					return 0;
				}
				pp[j] = i, dd[j] = d, qu[head + cnt++] = j;
			}
		}
	}
	cout << "Yes\n";
	for (int i = 1; i < n; i++)
		cout << pp[i] + 1 << '\n';
	return 0;
}


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

int main(){
  char c[51][51];
  int numG[51][51] = {0};
  int ans = -1;

  int H,W,numW = 0;

  queue<pair<int,int> > Q;

  cin >>H>>W;

  for(int i = 0; i<H;i++){
      string s;
      cin >>s;
      for(int j = 0;j<W;j++){
          if(s[j] =='.')numW++;
          c[i][j] = s[j];
      }
  }

  numG[0][0] = 1;

  Q.push(make_pair(0,0));

  while(!Q.empty()){
      int d_x[] = {1,0,0,-1};
      int d_y[]= {0,-1,1,0};

      pair<int,int> cur = Q.front();
      Q.pop();

      for(int i = 0;i<4;i++){
          int newX = cur.first + d_x[i];
          int newY = cur.second + d_y[i];
          if(c[newX][newY] == '.' && numG[newX][newY] == 0 && newX >= 0 && newY >= 0 && newX < H && newY < W){
              numG[newX][newY] = numG[cur.first][cur.second] + 1;
              Q.push(make_pair(newX,newY));
        }   
      }
  }

  if(numG[H-1][W-1] == 0){
      cout <<-1<<endl;
  }else{
    cout <<-(numG[H-1][W-1]-numW)<<endl;
  }

  return 0;
  }

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

int main(){
    double r;
    double pi = 3.141592;
    cin >> r;
    cout << 2*r*pi << endl;

    return 0;
}



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

using namespace std;

#define int long long

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

typedef vector<int> VI;
typedef pair<int, int> PII;

//-------------------

int A, B;

signed main(){

    cin >> A >> B;

    int ans = 0;

    if(A > B){
        ans += A;
        A--;
    }
    else{
        ans += B;
        B--;
    }

    if(A > B){
        ans += A;
        A--;
    }
    else{
        ans += B;
        B--;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std ;
int a[52] = {0 , 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51} ;
int main()
{
  int k ;
  cin >> k ;
  cout << a[k] << endl ;
  return 0 ;
}


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

using namespace std;

#define LL           long long
#define ULL          long long unsigned
#define LD           long double
#define FOR(i,n)     for(int i=0;i<n;i++)
#define FLR(i,n)     for(LL i=0;i<n;i++)
#define RFOR(i,n)    for(int i=n-1;i>=0;i--)
#define RFLR(i,n)    for(LL i=n-1;i>=0;i--)
#define rep(i,a,b)   for(int i=a;i<=b;i++)
#define repl(i,a,b)  for(LL i=a;i<=b;i++)
#define fast         ios_base::sync_with_stdio(0);cin.tie(0);
#define all(a)       a.begin(),a.end()
#define ABS(x)       ((x)<0?-(x):(x))
#define endl         "\n"
#define PB           push_back
int main()
{
    fast;
    LL i,j,N,kount=0,x;
    cin>>N;
    vector<int>A,B;
    FOR(i,N+1){
        cin>>x;
        A.PB(x);
    }
    FOR(i,N){
        cin>>x;
        B.PB(x);
    }
    FOR(i,N){
        if(B[i]>=A[i]){
            B[i]=B[i]-A[i];
            kount+=A[i];
        }
        else if(B[i]<A[i]){
            kount+=B[i];
            B[i]=0;
        }
        if(B[i]>=1){
            kount+=min(A[i+1],B[i]);
            A[i+1]-=B[i];
            if(A[i+1]<0)A[i+1]=0;
        }
    }
    cout<<kount;

}



Measured memory_bytes: 1400
import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
from collections import deque, Counter
def getN():
    return int(input())
def getList():
    return list(map(int, input().split()))
import math
INF = 10 ** 9

def main():
    n = getN()
    nums = getList()
    tmp = 1
    br = n
    for num in (nums):
        # print(num, tmp)
        if num == tmp:
            br -= 1
            tmp += 1
            # print(br, num)



    if br == n:
        ans = -1
    else:
        ans = br
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 70988
/*
    Written by Nitrogens
    Desire for getting accepted!!
*/
#include <cstdio>
#include <ctime>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <queue>
#include <map>
#include <bitset>
#include <stack>
#include <set>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

const int maxn = 1e5+5;
const int Mod = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double e = exp(1);
const db PI = acos(-1);
const db ERR = 1e-10;

#define Se second
#define Fi first
#define pb push_back
#define dbg(x) cout<<#x<<" = "<< (x)<< endl
#define dbg2(x1,x2) cout<<#x1<<" = "<<x1<<" "<<#x2<<" = "<<x2<<endl
#define dbg3(x1,x2,x3) cout<<#x1<<" = "<<x1<<" "<<#x2<<" = "<<x2<<" "<<#x3<<" = "<<x3<<endl

int n;
vector<pii> ve[maxn];
ll dp[305][305][305];

bool check(int a, int b, int c) {
    int k = max(a, max(b, c));
    if (k > n) return false;
    for (auto element: ve[k]) {
        int cnt = 0;
        if (a >= element.Fi) cnt++;
        if (b >= element.Fi) cnt++;
        if (c >= element.Fi) cnt++;
        if (cnt != element.Se) return false;
    }
    return true;
}

int main()
{
    //ios::sync_with_stdio(false);
    //freopen("a.txt","r",stdin);
    //freopen("b.txt","w",stdout);

    int m;
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= m; i++) {
        int l, r, x;
        scanf("%d%d%d", &l, &r, &x);
        ve[r].pb(pii(l, x));
    }
    ll ans = 0;
    dp[0][0][0] = 1;
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= n; j++) {
            for (int k = 0; k <= n; k++) {
                if (!check(i, j, k)) {
                    dp[i][j][k] = 0;
                    continue;
                }
                int target = max(i, max(j, k));
                if (target == n) ans = (ans + dp[i][j][k]) % Mod;
                dp[target + 1][j][k] = (dp[target + 1][j][k] + dp[i][j][k]) % Mod;
                dp[i][target + 1][k] = (dp[i][target + 1][k] + dp[i][j][k]) % Mod;
                dp[i][j][target + 1] = (dp[i][j][target + 1] + dp[i][j][k]) % Mod;
            }
        }
    }
    printf("%lld\n", ans);

    //cout << "time: " << (long long)clock() * 1000 / CLOCKS_PER_SEC << " ms" << endl;
    return 0;
}


Measured memory_bytes: 224384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e6+6;
const int OO = 0x3f3f3f3f;

int main()
{
    int n;
    cin >> n;
    int co = 0;
    for(int i = 1; i<= n; i++)
    {
        if(to_string(i).size()%2 != 0)
            co++;
    }
    cout << co << endl;
    return 0;
}




Measured memory_bytes: 256
import itertools
N = int(input())
A = [int(_) for _ in input().split()]
if A[0] != 0:
    if N == 0 and A[0] == 1:
        print(1)
    else:
        print(-1)
    exit()
ans = 1
n = 1
if A[0] > 1:
    print(-1)
    exit()
cumr = list(itertools.accumulate(A[::-1]))[::-1]
for i in range(1, N + 1):
    minn = n - A[i - 1]
    n = min(2 * minn, cumr[i])
    if n>=minn and n>=A[i]:
        ans += n
    else:
        print(-1)
        exit()
print(ans)


Measured memory_bytes: 20356
#pragma region
#include <algorithm>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <vector>
typedef long long ll;
#define tr t[root]
#define lson t[root << 1]
#define rson t[root << 1 | 1]
#define rep(i, a, n) for (long long i = a; i <= n; ++i)
#define per(i, a, n) for (long long i = n; i >= a; --i)
#define IO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
template <typename T>
void read(T &x) {
    x = 0;
    char ch = getchar();
    ll f = 1;
    while (!isdigit(ch)) {
        if (ch == '-') f *= -1;
        ch = getchar();
    }
    while (isdigit(ch)) {
        x = x * 10 + ch - 48;
        ch = getchar();
    }
    x *= f;
}
using namespace std;
/*
 *                                                     __----~~~~~~~~~~~------___
 *                                    .  .   ~~//====......          __--~ ~~
 *                    -.            \_|//     |||\\  ~~~~~~::::... /~
 *                 ___-==_       _-~o~  \/    |||  \\            _/~~-
 *         __---~~~.==~||\=_    -_--~/_-~|-   |\\   \\        _/~
 *     _-~~     .=~    |  \\-_    '-~7  /-   /  ||    \      /
 *   .~       .~       |   \\ -_    /  /-   /   ||      \   /
 *  /  ____  /         |     \\ ~-_/  /|- _/   .||       \ /
 *  |~~    ~~|--~~~~--_ \     ~==-/   | \~--===~~        .\
 *           '         ~-|      /|    |-~\~~       __--~~
 *                       |-~~-_/ |    |   ~\_   _-~            /\
 *                            /  \     \__   \/~                \__
 *                        _--~ _/ | .-~~____--~-/                  ~~==.
 *                       ((->/~   '.|||' -_|    ~~-/ ,              . _||
 *                                  -_     ~\      ~~---l__i__i__i--~~_/
 *                                  _-~-__   ~)  \--______________--~~
 *                                //.-~~~-~_--~- |-------~~~~~~~~
 *                                       //.-~~~--\
 *                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 */

#pragma endregion
const int maxn = 3e3 + 5;
int n;
double p[maxn], dp[maxn][maxn];
int main() {
    IO;
    cin >> n;
    rep(i, 1, n) cin >> p[i];
    dp[0][0] = 1;
    rep(i, 1, n) rep(j, 0, i)
        if (!j) dp[i][j] = dp[i - 1][j] * (1 - p[i]);
        else dp[i][j] = dp[i - 1][j - 1] * p[i] + dp[i - 1][j] * (1 - p[i]);
    double ans = 0;
    for (int i = n / 2 + 1; i <= n; ++i) ans += dp[n][i];
    cout << fixed << setprecision(10) << ans << endl;
}

Measured memory_bytes: 49944
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    if(N%10==0){
      System.out.println(10);
    }else{
      String nStr = Integer.toString(N);
      int ans = 0;
      for(int i=0;i<nStr.length();i++){
        int n = Integer.parseInt(nStr.substring(i,i+1));
        ans+=n;
      }
      System.out.println(ans);
    }
  }
}

Measured memory_bytes: 35668
#include <bits/stdc++.h>
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
#define MOD 1000000007
using ll = long long;
using namespace std;
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 (a>b) { a=b; return 1; } return 0; }
struct pos{
    int h;
    int x;
    int y;
};

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int n;
cin>>n;
vector<pair<int,pair<int,int>>> p(n);
rep(i,n){
    int x,y,h;
    cin>>x>>y>>h;
    p[i]={h,{x,y}};
}
sort(p.begin(),p.end(),greater<pair<int,pair<int,int>>>());

int CX,CY,H;
rep(cy,101){
    rep(cx,101){
        int base_h=p[0].first;
        int base_dh=-(abs(cx-p[0].second.first)+abs(cy-p[0].second.second));
        bool isFit=true;

        reps(i,n,1){
            int dh=-(abs(cx-p[i].second.first)+abs(cy-p[i].second.second));
            int _h= base_h + dh - base_dh;
            _h = _h>0 ?_h:0;
            if(p[i].first!=_h){
                isFit=false;
                break;
            }
        }
        if(isFit){
            CX=cx;
            CY=cy;
            H=base_h-base_dh;
            break;
        }
    }
}
cout<<CX<<" "<<CY<<" "<<H<<" "<<endl;
//system("pause");
return 0;
}

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

int main() {
  int N, H, H_tmp, max, n;
  max = n = 0;
  
  cin >> N;
  cin >> H_tmp;
  for(int i=1; i<N; i++) {
    cin >> H;
    if(H_tmp >= H) {
      n++;
    } else {
      if(n>=max) {
        max = n;
      }
      n = 0;
    }
    H_tmp = H;
  }
  
  if(n>=max) {
    max = n;
  }
  
  cout << max << endl;
  return 0;
}

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

int main() {
    int n, p; cin >> n >> p;
    vector<int> a(n);
    int m = 0;
    rep(i, n) {
        int tmp;
        cin >> tmp;
        if (tmp % 2 == 0) {
            m++;
        }
    }
    if (n == m) {
        if (p == 0) {
            cout << ((Int)1<<(n)) << endl;
        }
        else {
            cout << 0 << endl;
        }
        return 0;
    }
    cout << ((Int)1<<(n-1)) << endl;
}


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

using ll = long long;

int main(){
  ll n, c, k; cin >> n >> c >> k;
  ll t[n];
  for (int i = 0; i < n; i++) {
    cin >> t[i];
  }

  sort(t, t+n);

  int ans = 1;
  int before = t[0], cnt = 1;
  for (int i = 1; i < n; i++) {
    if(t[i] - before > k || cnt >= c ){
      before = t[i];
      cnt = 1 ;
      ans++;
    }
    else{
      cnt++;
    }

  }

  cout << ans  << endl;

  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

ll binomialCoeff(ll n, ll k) 
{ 
    ll C[k+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1;  // nC0 is 1 
  
    for (ll i = 1; i <= n; i++) 
    { 
        // Compute next row of pascal triangle using 
        // the previous row 
        for (ll j = min(i, k); j > 0; j--) 
            C[j] = C[j] + C[j-1]; 
    } 
    return C[k]; 
} 

int n,m,r;
vector <int> towns;
vector <vector <int> > dist;
vector <vector <int> > g;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    n=nxt();m=nxt();r=nxt();
    towns.resize(r);
    generate(all(towns),nxt);
    vector <int> r1;
    r1.resize(n+1,1e9);
    dist.resize(n+1,r1);
    for(int i=1;i<=n;i++)
        dist[i][i]=0;
    for(int i=0;i<m;i++)
    {
        int u=nxt(),v=nxt(),c=nxt();
        dist[u][v]=dist[v][u]=c;
    }
    for (int k = 1; k <=n; k++)  
    {  
        // Pick all vertices as source one by one  
        for (int i = 1; i <=n; i++)  
        {  
            // Pick all vertices as destination for the  
            // above picked source  
            for (int j = 1; j <=n; j++)  
            {  
                // If vertex k is on the shortest path from  
                // i to j, then update the value of dist[i][j]  
                if (dist[i][k] + dist[k][j] < dist[i][j])  
                    dist[i][j] = dist[i][k] + dist[k][j];  
            }  
        }  
    }  
    int tot=1;
    for(int i=2;i<=r;i++)
        tot*=i;
    int test=INT_MAX;
    for(int i=0;i<tot;i++)
    {
        int temp=0;
        for(int i=0;i<r-1;i++)
            temp+=dist[towns[i]][towns[i+1]];
        if(temp<test)
            test=temp;
        next_permutation(all(towns));
    }
    cout<<test<<endl;
    
    
    
    return 0;   
}




 
 


Measured memory_bytes: 384
#include <iostream>
#include <queue>
#define int long long
using namespace std;
queue<int>q[1010];
int n, p, t, x;
signed main() {
	cin >> n >> p;
	for (int i = 0; i < p; i++) {
		cin >> n >> t;
		if (!n) { cin >> x; q[t].push(x); }
		else if (q[t].size()) {
			if (n == 1)cout << q[t].front() << endl;
			else q[t].pop();
		}
	}
}


Measured memory_bytes: 5120