akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999aa
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    int n,k; cin>>n>>k;
    vector<int>v(n); rep(i,n)cin>>v[i];
    int ans=0;
    rep(i,n){
        ans+=min(abs(v[i]-0),abs(k-v[i]));
    }
    cout<<2*ans<<endl;
}

Measured memory_bytes: 256
import itertools
import numpy as np
n = int(input())
xy = []
ans_sum = 0
count = 0
for i in range(n):
    xy.append(list(map(int,input().split())))
for i in itertools.permutations(xy):
    ans = 0
    for j in range(n-1):
        ans += np.sqrt((i[j][0]-i[j+1][0])**2 + (i[j][1]-i[j+1][1])**2)
    count += 1
    ans_sum += ans
print("{:9f}".format(ans_sum/count))


Measured memory_bytes: 21408
#include<iostream>
using namespace std;
int main(){
	int k,n,a[2000005]={0},max,f;
	cin>>k>>n;max=0;
	if(n==0){
		cout<<0;
		return 0;
	}
	for(int i=1;i<=n;i++){
		cin>>a[i];
		if(i==1){
			f=a[i];
			continue;
		}
		if(a[i]-a[i-1]>max) max=a[i]-a[i-1];
	}
	if(a[1]+k-a[n]>max) max=a[1]+k-a[n];
	cout<<k-max;
	return 0;
}

Measured memory_bytes: 8064
#include <stdio.h>

int N, K;

int main(void)
{
	int i;
	int tmp;

	scanf("%d %d", &N, &K);


	tmp = K;
	for (i = 0; i < N-1; i++)
	{
		tmp *= (K-1);
	}
	printf("%d\n", tmp);
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#define ll long long int
int main()
{
    ll n,a,b;
    scanf("%lld %lld %lld",&n,&a,&b);
    if(n==(a+b))
    {
        printf("%lld",a);
    }
    else if(n<(a+b))
    {
        if(n<a){
            printf("%lld",n);
        }
        else
        {
            printf("%lld",a);
        }
    }
    else
    {
        ll x=n%(a+b);
        ll y=n/(a+b);
        if(x<a)
        {
            printf("%lld",(a*y)+x);
        }
        else
        {
            printf("%lld",(a*y)+a);
        }
    }
  return 0;
}

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    ll a; cin >> a;
    cout << a + a*a + a*a*a << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 7736
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    int b[n];
    b[n-1]=0;
    int max1=0;
    for(int i=n-2;i>=0;i--)
    {
        if(a[i+1]<=a[i])
        {
            b[i]=b[i+1]+1;
        }
        else
        {
            b[i]=0;
        }
        max1=max(max1,b[i]);
    }
    cout<<max1;
    return 0;
}


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

int main() {
 int S;
  cin >> S;
  int a,b,c,d;
  a=S%10;
  b=(S%100-a)/10;
  c=(S%1000-S%100)/100;
  d=(S-S%1000)/1000;
  if(a==b || b==c || c==d){
   cout << "Bad" << endl; 
  }
  else{
   cout << "Good" << endl; 
  }
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!}
    int a;
    int b;
    cin >> a >> b;
    
 
   int x = a % 2;
   int y = b % 2;
    
        
    if(x == 1 && y == 1){
        
        cout << "Odd" <<endl;
        
    }
    
    else{
        cout << "Even" <<endl;
    }
     
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()

using namespace std;

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

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

bool check(string &s, char ch) {
	rep(i, s.size()) {
		if (s[i] != ch) return false;
	}
	return true;
}

signed main() {
	string s;
	cin >> s;

	int ret = INT_MAX;
	rep(i, s.size()) {
		char ch = s[i];

		string t = s;
		int cnt = 0;
		while (!check(t, ch)) {
			string tt = "";
			rep(i, t.size() - 1) {
				if (t[i] == ch || t[i + 1] == ch) {
					tt += ch;
				} else {
					tt += t[i];
				}
			}
			t = tt;
			cnt++;
		}
		ret = min(ret, cnt);
	}

	cout << ret << endl;

    return 0;
}


Measured memory_bytes: 256
import sys, bisect, math, itertools, string, queue, copy
import numpy as np
import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

n,m = inpm()
s = [[0] * n for i in range(m)]
for i in range(m):
    tmp = inpl()
    for j in range(len(tmp) - 1):
        s[i][tmp[j+1]-1] = 1
p = inpl()

ans = 0
for i in range(2**n):
    for j in range(m):
        cnt = 0
        for k in range(n):
            if s[j][k] == 1 and (i >> k) & 1 == 1:
                cnt += 1
        if p[j] != (cnt % 2):
            break
    else:
        ans += 1
        continue
print(ans)

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<pair<ll, int>> v;
    rep(i, n) {
        ll a;
        int b;
        cin >> a >> b;
        v.emplace_back(pair(a, b));
    }
    sort(all(v));
    ll prc = 0, sum = 0;
    rep(i, n) {
        sum += v[i].second;
        if (sum >= m) {
            ll diff = sum - m;
            prc += v[i].first * (v[i].second - diff);
            break;
        } else {
            prc += v[i].first * v[i].second;
        }
    }
    cout << prc << "\n";
}

Measured memory_bytes: 5292
nums = list(map(int, input().rstrip().split()))


#-----
N = nums[0]
Y = nums[1]


count=[-1,-1,-1]
break_flag=False
for a in range(0,N+1):
    for b in range(0,N+1-a):
        c = N - (a+b)
        
        total = a*10000 + b*5000 + c*1000

        
        if total == Y:
            count = [a,b,c]

            break_flag=True
            break
            
    if break_flag:
        break

print(" ".join(str(i) for i in count))


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

int main() {
  vector<int> a(3);
  for(int i = 0; i < 3; i++) cin >> a.at(i);
  sort(a.begin(), a.end());
  
  int t = a.at(2) * 2 - a.at(0) - a.at(1);
  
  if(t % 2) t += 2;
  
  cout << (t+1) / 2 << endl;
}

Measured memory_bytes: 256
from itertools import permutations

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

toList = [set() for _ in range(N)]
for _ in range(M):
    fr, to = map(lambda a: int(a) - 1, input().split())
    toList[fr].add(to)
    toList[to].add(fr)

def countPath():
    ret = 0
    for P in permutations(range(N), r=N):
        if P[0] != 0:
            continue
        for fr, to in zip(P, P[1:]):
            if not to in toList[fr]:
                break
        else:
            ret += 1
    return ret

print(countPath())


Measured memory_bytes: 9136
s = input()
n = len(s)
lis = [0 for _ in range(n)]
p = 1
while p<n:
  cnt = 1
  while p<n and s[p-1]==s[p]=="R":
    p += 1
    cnt += 1
  if s[p-1]=="R":
    lis[p-1] = cnt

  cnt = 1
  anc = p  
  while p<n-1 and s[p]==s[p+1]=="L":
    p += 1
    cnt += 1
  if s[anc]=="L":
    lis[anc] = cnt
  p += 1
  
p2 = 0
while p2<n-1:
  if p2<n-1 and lis[p2]!=0 and lis[p2+1]!=0:
    m = lis[p2]+lis[p2+1]
    if m%2==1:
      if lis[p2]<lis[p2+1]:
        if lis[p2+1]%2==0:
          lis[p2], lis[p2+1] = (m+1)/2, (m-1)/2
        else:
          lis[p2], lis[p2+1] = (m-1)/2, (m+1)/2
      elif lis[p2]>lis[p2+1]:
        if lis[p2]%2==1:
          lis[p2], lis[p2+1] = (m+1)/2, (m-1)/2
        else:
          lis[p2], lis[p2+1] = (m-1)/2, (m+1)/2
    else:
      lis[p2], lis[p2+1] = m/2, m/2
    p2 += 2
  else:
    p2 += 1

ans = ""
for i in lis:
  ans = ans+str(int(i))+" "
print(ans[:-1])


Measured memory_bytes: 7236
void main() {
	auto ip = readAs!(int[]), N = ip[0], M = ip[1], X = ip[2], Y = ip[3];
	auto x = readAs!(int[]);
	auto y = readAs!(int[]);
	bool ok;
	foreach(Z; -100..101) {
		bool flag = false;
		if(!(X < Z && Z <= Y)) flag = true;
		foreach(i; x) {
			if(!(i < Z)) flag = true;
		}
		foreach(i; y) {
			if(!(i >= Z)) flag = true;
		}
		if(!flag) ok = true;
	}
	writeln(!ok ? "War" : "No War");
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 256
MOD = 10 ** 9 + 7
ONE = '1'.freeze

def nCk(n, k)
  res = 1
  i = k
  j = 1
  while i > 0
    res = res * (n - i + 1)
    res %= MOD
    j *= i
    j %= MOD
    i -= 1
  end
  res *= inv(j)
  res %= MOD
  res
end

def repeated_nCk(n, k)
  # 仕切りのイメージで
  nCk(n + k - 1, n - 1) % MOD
end

def inv(x)
  res = 1
  beki = x
  (MOD - 2).to_s(2).reverse.chars do |digest|
    res = (beki * res) % MOD if digest == ONE
    beki = (beki * beki) % MOD
  end
  res
end

s = gets.chomp.split("")
mods = [0]
current = 0
digit = 1
s.reverse.each_with_index do |n, i|
  current = (current + n.to_i * digit) % 2019
  mods << current % 2019
  digit = digit * 10 % 2019
end
puts mods.tally.values.select { |v| v > 1 }.inject(0) { |res, num| res + nCk(num, 2) }


Measured memory_bytes: 29368
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)
#define N_MAX 100000+10
using namespace std;

typedef long long int Int;

Int N,M;
map<Int,Int> fraction;
Int fact[2*N_MAX];
Int invfact[2*N_MAX];
Int inv[2*N_MAX];

void init(void) {
    fact[0] = fact[1] = 1;
    invfact[0] = invfact[1] = 1;
    inv[1] = 1;
    for(Int i = 2;i <= N+sqrt(M);i++) {
        fact[i] = (i * fact[i-1]) % MOD;
        inv[i] = MOD - (MOD / i) * inv[MOD % i] % MOD;
        invfact[i] = inv[i] * invfact[i-1] % MOD;
    }

    return;
}

Int comb(Int n, Int k) {
    if(n < k) {
        return 0;
    }
    if(n < 0 || k < 0)
        return 0;

    return fact[n] * (invfact[n-k] * invfact[k] % MOD) % MOD;
}
Int solve(void) {
    while(M % 2 == 0) {
        fraction[2]++;
        M /= 2;
    }
    for(Int i = 3;i <= M;i+=2) {
        while(M % i == 0) {
            fraction[i]++;
            M /= i;
        }
    }

    Int sum = 1;
    for(auto bj:fraction) {
        sum = (sum * comb(N+bj.second-1,bj.second)) % MOD;
    }

    return sum;
}

int main(void) {
    cin>>N>>M;

    init();

    cout<<solve()<<endl;

    return 0;
}




Measured memory_bytes: 3840
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

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

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

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

	string az = "abcdefghijklmnopqrstuvwxyz";
	map<char, int> m;
	for (char c : az) {
		m[c] = 0;
	}
	string s;
	while (getline(cin, s)) {
		for (char c : s) {
			if (isalpha(c)) {
				m[tolower(c)]++;
			}
		}
	}
	for (auto p : m) {
		cout << p.first << " : " << p.second << endl;
	}
}


Measured memory_bytes: 3184
from scipy.sparse import *
N,M,*A=map(int,open(0).read().split());g=csr_matrix(([1]*M,(A[::2],A[1::2])),shape=(N+1,N+1)).tolil()
c = 0

for a,b in zip(*g.nonzero()):
  g[a,b]=0
  n,_=csgraph.connected_components(g)
  c+=n!=2
  g[a,b]=1

print(c)

Measured memory_bytes: 17568
// #pragma comment(linker, "/stack:200000000")
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")
#include<bits/stdc++.h>

using namespace std;

using ll = long long;
using ld = long double;
using ull = unsigned long long;

#define F first
#define S second
#define int long long
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()


void accell() {
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
}

const int N = 1e6 + 2;


int dp[N][10][2];

signed main() {
    accell();
    string s;
    cin >> s;
    reverse(all(s));
    int n = s.size();
    for (int i = 0; i <= n; ++i) {
        for (int j = 0; j < 10; ++j) {
            for (int k = 0; k < 2; ++k) {
                dp[i][j][k] = 2e9;
            }
        }
    }
    for (int i = 0; i <= 9; ++i) {
        int pv = s[0] - '0';
        dp[0][(i + pv) % 10][(pv + i) / 10] = i + (i + pv) % 10;
    }
    for (int i = 1; i <= n; ++i) {
        int prv = 0;
        if (i != n) {
            prv = s[i] - '0';
        }
        for (int j = 0; j < 10; ++j) {
            for (int k = 0; k < 10; ++k) {
                for (int t = 0; t < 2; ++t) {
                    int a1 = j + prv + t;
                    int p1 = a1 % 10;
                    int p2 = a1 / 10;
                    dp[i][p1][p2] = min(dp[i][p1][p2], dp[i - 1][k][t] + p1 + j);
                }
            }
        }
    }
    int ans = 2e9;
    for (int i = n; i <= n; ++i) {
        for (int j = 0; j < 10; ++j) {
            ans = min(ans, dp[i][j][0]);
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 157596
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll dp[20005];
ll a[1005];
ll b[1005];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll h,n;
    cin>>h>>n;
    ll ans=999999999;
    for(int i=1;i<=n;i++)
        cin>>a[i]>>b[i];
    for(int i=1;i<=20004;i++)
      dp[i]=999999999;
    for(int i=1;i<=n;i++)
    {

        for(int j=a[i];j<=h+10000;j++)
        {

            dp[j]=min(dp[j],dp[j-a[i]]+b[i]);
        }
    }
    for(int i=h;i<=h+10000;i++)
    {

        ans=min(ans,dp[i]);
    }


    cout<<ans<<'\n';


}




















Measured memory_bytes: 384
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let x: usize = input();

    let mut sum = 0;
    let mut ans = 0;
    for i in 1..x + 1 {
        sum += i;
        if sum >= x {
            ans = i;
            break;
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
x1, y1, x2, y2 = gets.split.map(&:to_i)

x3 = x2 - (y2 - y1)
y3 = y2 + (x2 - x1)
x4 = x3 - (y3 - y2)
y4 = y3 + (x3 - x2)

puts "#{x3} #{y3} #{x4} #{y4}"

Measured memory_bytes: 3836
#include <iostream>
using namespace std;
int a[3005];
int main(int argc, const char * argv[])
{
    int n,ans=0;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        ans+=a[i]-1;
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  cout << s[0] << s.size() - 2 << s.back() << endl;
  return 0;
}


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

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key);
void init();
void printList();
void deleteNode(NodePointer t);
void deleteFirst();
void deleteLast();
void delete(int key);
void insert(int key);

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {
      insert(key);
      np++;
      size++;
    }
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	if ( com[6] == 'F' ) deleteFirst();
	else if ( com[6] == 'L' ) deleteLast();
      }
      else {
	delete(key);
	nd++; 
      }
      size--;
    }
  }
  
  printList();
  return 0;
}

NodePointer listSearch(int key){
  /* your code */
  NodePointer n=nil->next;
  while(n->key!=key&&n!=nil)n=n->next;
  return n;
}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  /* your code */
  t->prev->next=t->next;
  t->next->prev=t->prev;
  free(t);
}

void deleteFirst(){
  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}

void deleteLast(){
  /* your code */
  NodePointer t = nil->prev;
  if(t==nil) return; 
  deleteNode(t);
}

void delete(int key){
  /* your code */
  NodePointer x;
  x=listSearch(key);
  if(x==nil)return;
  deleteNode(x);
}


void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;
  /* your code */
  x->next=nil->next;
  nil->next->prev=x;
  nil->next=x;
  x->prev=nil;
}




Measured memory_bytes: 32968
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
using i64 = long long;

int main()
{
  i64 n;
  cin >> n;
  vector<pair<pair<string, i64>, i64>> d(n);
  for (i64 i = 0; i < n; i++)
  {
    cin >> d[i].first.first >> d[i].first.second;
    d[i].second = i + 1;
    d[i].first.second *= -1;
  }
  sort(d.begin(), d.end());
  for (i64 i = 0; i < n; i++)
    cout << d[i].second << endl;
  return 0;
}


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

const long long INF = (1ll << 30);

struct Dinic {
  typedef long long flow_type;
  struct edge {
    int src, dst;
    flow_type capacity, flow;
    size_t rev;
  };
  int n;
  vector<vector<edge>> adj;
  Dinic(int n) : n(n), adj(n) { }
  void add_edge(int src, int dst, flow_type capacity) {
    adj[src].push_back({src, dst, capacity, 0, adj[dst].size()});
    adj[dst].push_back({dst, src, 0, 0, adj[src].size()-1});
  }
  flow_type max_flow(int s, int t) {
    vector<int> level(n), iter(n);
    function<int(void)> levelize = [&]() { // foward levelize
      level.assign(n, -1); level[s] = 0;
      queue<int> Q; Q.push(s);
      while (!Q.empty()) {
        int u = Q.front(); Q.pop();
        if (u == t) break;
        for (auto &e: adj[u]) {
          if (e.capacity > e.flow && level[e.dst] < 0) {
            Q.push(e.dst);
            level[e.dst] = level[u] + 1;
          }
        }
      }
      return level[t];
    };
    function<flow_type(int, flow_type)> augment = [&](int u, flow_type cur) {
      if (u == t) return cur;
      for (int &i = iter[u]; i < adj[u].size(); ++i) {
        edge &e = adj[u][i], &r = adj[e.dst][e.rev];
        if (e.capacity > e.flow && level[u] < level[e.dst]) {
          flow_type f = augment(e.dst, min(cur, e.capacity - e.flow));
          if (f > 0) {
            e.flow += f;
            r.flow -= f;
            return f;
          }
        }
      }
      return flow_type(0);
    };
    for (int u = 0; u < n; ++u) // initialize
      for (auto &e: adj[u]) e.flow = 0;

    flow_type flow = 0;
    while (levelize() >= 0) {
      fill(iter.begin(), iter.end(), 0);
      for (flow_type f; (f = augment(s, INF)) > 0; )
        flow += f;
    }
    return flow;
  }
};


int main(){

    int h, w; cin >> h >> w;
    
    //0 := start, h + w + 1 := goal
    Dinic G(h + w + 2);
    
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            char c; cin >> c;
            if(c == '.') continue;
            
            if(c == 'S'){
                G.add_edge(0, i + 1, INF);
                G.add_edge(0, h + j + 1, INF);
            }else if(c == 'T'){
                G.add_edge(i + 1, h + w + 1, INF);
                G.add_edge(h + j + 1, h + w + 1, INF);
            }else{
                G.add_edge(i + 1, h + j + 1, 1LL);
                G.add_edge(h + j + 1, i + 1, 1LL);
            }
        }
    }

    

    if(G.max_flow(0, h + w + 1) >= INF) cout << -1 << endl;
    else cout << G.max_flow(0, h + w + 1) << endl;

    return 0;
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

int main(){
    int N;
    cin>>N;
    int a,b;
    vector<int> P(N);
    REP(i, N) cin >> P[i];
    vector<int> Q(N);
    REP(i, N) cin >> Q[i];
    vector<int> O(N);
    iota(All(O),1);
    int i=1;
    do{
        if(O==P) a=i;
        if(O==Q) b=i;
        i++;
    }while(next_permutation(All(O)));
    cout<<abs(a-b)<<endl;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;


public class Main {
//	入力値
	static Scanner scInputData = new Scanner(System.in);
//	配列
	static ArrayList<Integer> arrA = new ArrayList<Integer>();
	
	public static void main(String[] args) {
		
//		必要なパラメータを用意する処理
//		配列Aを取得する処理
		getArr(arrA);
//		reverse処理
		reverseArr();
//		結果を出力する処理
		putResult();
	}
	
	private static void putResult() {
		for(int arrNum=0; arrNum < arrA.size() - 1; arrNum++) {
			System.out.print(arrA.get(arrNum) + " ");
		}
		System.out.println(arrA.get(arrA.size() - 1));
	}

	private static void reverseArr() {
//		reverse処理の試行回数
		int revNum = scInputData.nextInt();
//		対象の範囲 (start/end)
		int start = 0, end = 0;
		for(int indexToRev = 0; indexToRev < revNum; indexToRev++) {
			start = scInputData.nextInt();
			end = scInputData.nextInt();
			reverseNum(start, end);
		}
	}

	private static void reverseNum(int start, int end) {
//		対象範囲の入替え回数
		int changeNum= (int) (end - start) / 2;

//		入替える対象の値(small側のみ)
		int val_small = 0;
		for(int indexToChange=0; indexToChange < changeNum; indexToChange++) {
			val_small = arrA.get(start + indexToChange);
			arrA.set(start + indexToChange, arrA.get(end - indexToChange - 1));
			arrA.set(end - indexToChange - 1 , val_small);
		}
	}

	private static void getArr(ArrayList<Integer> arr) {
//		 配列の要素数
		int iArrNum = 0;
		iArrNum = scInputData.nextInt();
		while(arr.size() < iArrNum) {
			arr.add(scInputData.nextInt());
		}
	}

}



Measured memory_bytes: 34400
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define RREP(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define RFOR(i, s, n) for (int i = (int)n - 1; i >= s; --i)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
template<class T>istream&operator >>(istream&is,vector<T>&vec){for(T&x:vec)is>>x;return is;}
template<class T>inline void out(T t){cout << t << "\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout << t << " ";out(ts...);}
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;}
constexpr int INF = 1e18;


signed main() {
    int N, K;
    cin >> N >> K;
    vector<int>a(N);
    cin >> a;
    auto f =[&](int x){
        int cnt = 0;
        REP(i, N) {
            cnt += (a[i] - 1) / x;
        }
        return cnt <= K;
    };
    int l = 0, r = 1e18 + 1;
    while(r - l > 1){
        int c = (l + r) / 2;
        if(f(c)) r = c;
        else l = c;
    }
    cout << r << endl;
}

Measured memory_bytes: 4800
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const ll INF = 2e15;
template<class T> void print(const T& t){ cout << t << endl; }
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 gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
  ll n;
  cin >> n;
  ll sum = 0;
  ll sum1 = 0;
  while (n >= 10){
    sum1 += n % 10;
    n /= 10;
    sum += 9;
  }
  sum += n-1;
  sum1 += n;
  sum = max(sum, sum1);
  print(sum);
}

Measured memory_bytes: 3640
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int A, B, C;
    cin >> A >> B >> C;
    
    if (C > A && C < B) cout << "Yes" << endl;
    else if (C < A && C > B) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

class Main{

	//static long[] a;
	static	int N ;
	static	int M ;
	static long[][] dp;
	static int ans = 100000000;
	static	boolean[] flag ;

	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);			//文字の入力
		String S = sc.next();
		String T = sc.next();
		char[] ansc = S.toCharArray();
		
		for(int i = S.length()-1;i >= T.length()-1;i--){
			ansc = S.toCharArray();
//			System.out.println("i " + i);

			if(S.charAt(i) == '?' || S.charAt(i) == T.charAt(T.length()-1)){				//Sのi文字目が?かTの後ろの文字と一緒ならそこから判定
				int c = T.length()-1;
				for(int j = i;c >= 0;j--){
//					System.out.println("j " + j);
//					System.out.println("c " + c);

					if(S.charAt(j) != '?' && S.charAt(j) != T.charAt(c)){			//もしSのj文字めが?でもTのc文字目でもないのなら無理
//						System.out.println("break ");

						break;
					}else{
						ansc[j] = T.charAt(c);
					}

					if(c == 0){
						for(int k = 0;k < S.length();k++){				//?にaを入れていく
							if(ansc[k] == '?'){
								ansc[k] = 'a';
							}
						}
						String aString = new String(ansc);
						System.out.println(aString);
						return;
					}
					c--;
				}
				
			}

		}


		System.out.println("UNRESTORABLE");




	}

}
class Bridge{
	int p;			//自分の場所
	ArrayList<Integer> town = new ArrayList<Integer>();				//辺でつながっている町
	public Bridge(int n) {
		p = n;
	}
	void addtown(int t){
		town.add(t);
	}

	int townnum(){
		return town.size();
	}





}




Measured memory_bytes: 22868
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e5 + 10;
pair<int, int> a[N];
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n, g;
	cin >> n >> g;
	int ans = INF;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i].first >> a[i].second;
	}
	for (int o = 0; o < (1 << n); o++)
	{
		vector<pair<int, int>> vp;
		int sum = 0;
		int tot = 0;
		for (int i = 0; i < n; i++)
		{
			if (o >> i & 1) sum += a[i].first * 100 * (i + 1) + a[i].second, tot += a[i].first;
			else vp.emplace_back(i + 1, a[i].first);
		}
		reverse(vp.begin(), vp.end());
		for (auto& p : vp)
		{
			while (sum < g && p.second--)
			{
				sum += p.first * 100;
				tot++;
			}
		}
		ans = min(ans, tot);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)

using namespace std;
static const int MAX=50;
int n,m;
int a[MAX],b[MAX];
bool graph[MAX][MAX];
bool visited[MAX];

/*void dfs(int v){
  visited[v]=true;//vからスタート
  for(int v2=0;v2<n;v2++){
    if(!graph[v][v2])continue;
    if(visited[v2])continue;
    dfs(v2);
  }
} */

void dfs(int v){
    stack<int> S;
    S.push(v);
    visited[v]=true;
    while(!S.empty()){
        int v2=S.top();S.pop();
        for(int i=0;i<n;i++){
            if(!graph[v2][i])continue;
            if(visited[i])continue;
            visited[i]=true;
            S.push(i);//スタックに追加
        }
    }
}
int main(){
    cin>>n>>m;
    for(int i=0;i<m;i++){//隣接リスト表現→隣接行列
        cin>>a[i]>>b[i];

        a[i]--;b[i]--;
        graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;
    }
    int ans=0;
    for(int i=0;i<m;i++){
        graph[a[i]][b[i]]=graph[b[i]][a[i]]=false;
        for(int j=0;j<n;j++)visited[j]=false;

        dfs(0);//iを抜いてみて探索

        bool bridge=false;
        for(int j=0;j<n;j++){
            if(!visited[j])bridge=true;
        }
        if(bridge)ans+=1;

        graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;//元に戻す
    }
    cout<<ans<<"\n";
    return 0;
}


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

int main(void)
{
	double x, y;
	int walk, roll;
	int now_roll;
	
	x = y = 0.0;
	now_roll = 90.0;
	scanf("%d,%d", &walk, &roll);
	while (walk != 0 || roll != 0){
		x += walk * cos(now_roll * M_PI / 180);
		y += walk * sin(now_roll * M_PI / 180);
		now_roll = (now_roll - roll + 360) % 360;
		
		scanf("%d,%d", &walk, &roll);
	}
	
	printf("%d\n", (int)x);
	printf("%d\n", (int)y);
	
	return 0;
}

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

int main(){
    ll a,b,c,k;
    cin >> a >> b >> c >> k;
    ll sum = 0;

    if(a>=k){
        sum = k;
        cout << sum << endl;
    }
    else{
        sum += a;
        k -= a;
        if(b>=k){
            cout << sum << endl;
        }
        else{
            k -= b;
            sum -= k;
            cout << sum << endl;
        }
    }
    return 0;
}

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

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

const long long MOD = 1000000007;
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main(){
  int n;
  cin>>n;
  vector<vector<ll>> v(2,vector<ll>(n,0));
  rep(i,2)
    rep(j,n) cin>>v[i][j];
  int ans = -1;
  rep(i,n) {
    int tmp = 0;
    for(int j=0; j<n; j++) {
      if(j<=i) tmp+=v[0][j];
      if(i<=j) tmp+=v[1][j];
    }
    ans = max(tmp, ans);
  }
  std::cout << ans << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int t,n,i;
	for(i=0;i<4;i++){
		scanf("%d%d",&t,&n);
		switch(t){
		case 1:
			printf("%d\n",6000*n);
			break;
		case 2:
			printf("%d\n",4000*n);
			break;
		case 3:
			printf("%d\n",3000*n);
			break;
		default:
			printf("%d\n",2000*n);
		}
	}
	return 0;
}

Measured memory_bytes: 2696
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, m,a;
    cin >> n >> m;
    for (int i = 0; i < m;i++){
        cin >> a;
        n -= a;
        if (n < 0){
            cout << -1 << endl;
            return 0;
        }
    }
    cout << n << endl;
    return 0;
}

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

int main() {
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  int xa = min(a, k);
  k -= xa;
  int xb = min(b, k);
  k -= xb;
  int xc = k;
  int ans = xa - xc;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std ;
#define ll long long
inline int D(){
    int t ;
    scanf( "%d" , &t ) ;
    return t ;
}
inline ll LLD(){
    ll t ;
    scanf( "%lld" , &t ) ;
    return t ;
}


//#########################################



int main() {
 int a=D(),b=D();
 string s;
 cin>>s;
 bool flag1=0,flag2=1;
 for(int i=0;i<(a+b+1);i++){
     if(s[a]=='-'){
         flag1=1;

     }
     if(i!=a&&s[i]=='-'){
         flag2=0;
         break;

     }



 }

 if(flag1&&flag2){
   cout<<"Yes";


 }
 else
     cout<<"No";




}


Measured memory_bytes: 256
import Control.Monad
import qualified Data.ByteString.Char8 as BS
import Data.Maybe

readString = map BS.unpack . BS.words

getString = readString <$> BS.getLine

calc :: String -> Int -> Int
calc [] cur = 0
calc (s : ss) cur
  | s == 'W' = cur + calc ss cur
  | otherwise = calc ss (cur + 1)

main = do
  [s] <- getString
  print $ calc s 0


Measured memory_bytes: 4476
import re

S = input()

if S == 'keyence' or re.fullmatch(r'[a-z]+keyence', S) or re.fullmatch(r'k[a-z]+eyence', S) or re.fullmatch(r'ke[a-z]+yence', S) or re.fullmatch(r'key[a-z]+ence', S) or re.fullmatch(r'keye[a-z]+nce', S) or re.fullmatch(r'keyen[a-z]+ce', S) or re.fullmatch(r'keyenc[a-z]+e', S) or re.fullmatch(r'keyence[a-z]+', S):
  print('YES')
else:
  print('NO')

Measured memory_bytes: 3188
#include"iostream"
#include"vector"
#include"string"
#include"map"
#include"set"
using namespace std;
int min(int a, int  b){
	if (a > b)
		return b;
	return a;
}
int main(){
	int a,b;
	cin >> a >> b;
	a--;
	b--;
	vector<bool>v(3,false);
	v[a] = true;
	v[b] = true;
	for (int i = 0; i < 3; i++){
		if (v[i] == false){
			cout << i + 1 << endl;
			break;
		}
	}
	return 0;
}

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

//const int M = 1e9+7;

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int n;
    cin >> n;
    double p[n+1];
    for(int i = 1; i <= n; i++) cin >> p[i];
    vector<vector<double>> dp(n+1 , vector<double>(n+1 , 0.0));
    for(int i = 1; i <= n; i++) dp[i][0] = 1-p[i];
    for(int i = 2; i <= n; i++) dp[i][0] *= dp[i-1][0];
    dp[0][0] = 1;
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= i; j++) dp[i][j] = p[i]*dp[i-1][j-1] + (1-p[i])*dp[i-1][j];
    }
    double ans = 0;
    for(int i = (n+1)/2; i <= n; i++) ans += dp[n][i];
    cout << fixed << setprecision(10) << ans << "\n";

    return 0;
}

Measured memory_bytes: 70784
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <complex>
using namespace std;

int main() {
    for( ; ; ){
        string str;
        cin >> str;
        if(str == "-"){
            break;
        }
        int n;
        cin >> n;
        for(int i = 0; i < n; i++){
            int x;
            cin >> x;
            str += str.substr(0, x);
            str.erase(str.begin(), str.begin() + x );
        }

        cout << str << endl;

    }

}


Measured memory_bytes: 3228
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

typedef pair<int, int> P;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

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

__attribute__((constructor)) void initial() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int main() {
    ll L, R;
    cin >> L >> R;

    if ((R - L) >= 2019) {
        cout << 0 << endl;
        return 0;
    }
    
    L = L % 2019;
    R = R % 2019;
    if (L >= R) {
        R =+ 2019;
    }
    ll minValue = (R * (R - 1)) % 2019;
    for (int i = L; i <= R ; i++) {
        for (int j = L; j <= R; j++) {
            if (i != j) {
                ll newValue = (i * j) % 2019; 
                minValue = min(minValue, newValue);
            }
        }
    }
    cout << minValue << endl;
}

Measured memory_bytes: 256
import itertools
n = int(input())
l = (list(map(int,input().split())))


ans = 0
if len(l) < 3:
    print(0)
else:
    prelst = list(itertools.combinations(l,3))

    for lst in prelst:
        lst = sorted(lst)
        if lst[0] + lst[1] > lst[2] and lst[0] != lst[1] != lst[2]:
            ans += 1
    print(ans)

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

int main(){
    vector<char> c(3);
    vector<char> C(3);
    int i,k=0;
    for(i=0;i<3;i++){
        cin >> c.at(i);
    }
    for(i=0;i<3;i++){
        cin >> C.at(i);
    }
    for(i=0;i<3;i++){
        if(c.at(i) != C.at(2-i)){
            k++;
        }
    }

    if(k==0){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }

    return 0;
}

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

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

int n;
// string s;
VVi v;

void fall(int depth, int start, int end) {
    RREP(i, depth, 0) {
        if (i != 0) {
            REP2(j, start, end+1) {
                v[i][j] = v[i-1][j];
            }
        } else {
            REP2(j, start, end+1) {
                v[i][j] = -1;
            }
        }
    }
}

int getScore(int depth, int start, int end) {
    int x = v[depth][start];
    if (x == -1) return 0;
    if (end - start + 1 < 3) return 0;
    fall(depth, start, end);
    return x * (end - start + 1);
}

int main() {
    while (true) {
        cin >> n;
        if (n == 0) break;

        v = VVi(n, Vi(5));
        REP(i, n) REP(j, 5) cin >> v[i][j];
        int result = 0;

        while (true) {
            bool f = false;
            REP(i, n) {
                Vi u = v[i];
                int x = u[0], start = 0;
                REP2(j, 1, 5) {
                    if (u[j] != x) {
                        int score = getScore(i, start, j-1);
                        if (score > 0) f = true;
                        result += score;
                        x = u[j]; start = j;
                    }
                }
                int score = getScore(i, start, 4);
                if (score > 0) f = true;
                result += score;
            }
            if (!f) break;
        }
        std::cout << result << '\n';
    }

    return 0;
}



Measured memory_bytes: 3172
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<double> VEC;
typedef vector<VEC> MAT;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef pair<int, TIII> QIIII;
typedef long long LL;
typedef vector<LL> VLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define MT(a,b,c) MP(a, MP(b,c))
#define MQ(a,b,c,d) MP(a, MT(b,c,d))
#define Q1 first
#define Q2 second.first
#define Q3 second.second.first
#define Q4 second.second.second

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define EPS 1e-8
#define MOD 1000000007

int main(){
	string str;
	cin >> str;
	int n=str.length();
	while(n){
		string::size_type k=str.find("mew");
		if(k==string::npos){
			cout << "Rabbit" << endl;
			return 0;
		}
		else if(k==0){
			if(n==3)cout << "Cat" << endl;
			else cout << "Rabbit" << endl;
			return 0;
		}else{
			n-=3;
			str.erase(k, 3);
		}
	}
	return 0;
}

Measured memory_bytes: 1208