akhauriyash/Code-Regression huggingface dataset:
using System;

namespace AtCoder.Problems
{
    public class ProblemC
    {
        public static void Main(string[] args)
        {
            var s = new SolveC();
            s.Solve();
        }

        public class Scanner
        {
            private string[] _s;
            private int _i;
            private readonly char[] _separators = new char[] { ' ' };

            public Scanner()
            {
                _s = new string[0];
                _i = 0;
            }

            public string Next()
            {
                if (_i < _s.Length) return _s[_i++];
                string st = Console.ReadLine();
                while (st == "") st = Console.ReadLine();
                _s = st.Split(_separators, StringSplitOptions.RemoveEmptyEntries);
                if (_s.Length == 0) return Next();
                _i = 0;
                return _s[_i++];
            }

            public int NextInt() => int.Parse(Next());
            public long NextLong() => long.Parse(Next());
            public ulong NextULong() => ulong.Parse(Next());
            public double NextDouble() => double.Parse(Next());

            public int[] GetIntArray(int n, int add = 0)
            {
                int[] array = new int[n];
                for (int i = 0; i < n; i++)
                {
                    array[i] = NextInt() + add;
                }
                return array;
            }

            public long[] GetLongArray(int n, long add = 0)
            {
                long[] array = new long[n];
                for (int i = 0; i < n; i++)
                {
                    array[i] = NextLong() + add;
                }
                return array;
            }

            public double[] GetDoubleArray(int n, double add = 0)
            {
                double[] array = new double[n];
                for (int i = 0; i < n; i++)
                {
                    array[i] = NextDouble() + add;
                }
                return array;
            }

            public string[] GetStringArray(int n)
            {
                string[] array = new string[n];
                for (int i = 0; i < n; i++)
                {
                    array[i] = Next();
                }
                return array;
            }
        }
    }

    public class SolveC
    {
        public void Solve()
        {
            var cin = new ProblemC.Scanner();
            var a = cin.NextLong();
            var b = cin.NextLong();
            var h = cin.NextLong();
            var m = cin.NextLong();

            var result = GetAnswer(a, b, h, m);
            Console.WriteLine(result);
        }

        public double GetAnswer(long a, long b, long h, long m)
        {
            var radA = (h * 30d + m * 0.5d) * Math.PI / 180;
            var radB = (m * 6d) * Math.PI / 180;

            var ax = a * Math.Sin(radA);
            var ay = a * Math.Cos(radA);

            var bx = b * Math.Sin(radB);
            var by = b * Math.Cos(radB);


            var dis = Math.Sqrt(Math.Pow(Math.Abs(ax - bx), 2) + Math.Pow(Math.Abs(ay - by), 2));
            return dis;
        }
    }
}


Measured memory_bytes: 27936
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <string>
#include <iostream>
#include <stdio.h>
#include <queue>

using namespace std;

long long N;
int main() {
	string S;
	cin >> S;
	for (int i = 0; i < S.length()-1; i++) {
		if (S[i] == 'A' && S[i + 1] == 'C') {
			cout << "Yes";
			return  0;
		}

	}
	cout << "No";
	return 0;



	return 0;
}

Measured memory_bytes: 256
from functools import lru_cache


class MatrixRKSearch:
    shift = 40
    size = 33554393

    def __init__(self, m1, m2):
        self.haystack = self._encode(m1)
        self.needle = self._encode(m2)

    def find(self):
        i1, j1 = len(self.haystack), len(self.haystack[0])
        i2, j2 = len(self.needle), len(self.needle[0])
        if i1 < i2 or j1 < j2:
            return

        hs1 = [self._hash(s, j2) for s in self.haystack]
        hs2 = [self._hash(s, j2) for s in self.needle]
        dm = self.shift**(j2-1) % self.size

        for j in range(j1-j2+1):
            for i in range(i1-i2+1):
                if hs1[i:i+i2] == hs2:
                    yield (i, j)
            if j+j2 < j1:
                for i in range(i1):
                    hs1[i] = self._shift(hs1[i], self.haystack[i][j+j2],
                                         self.haystack[i][j], dm)

    @lru_cache(maxsize=1000)
    def _shift(self, h, add, remove, dm):
        return ((h - remove*dm) * self.shift + add) % self.size

    def _hash(self, s, length):
        h = 0
        for i in range(length):
            h = (h * self.shift + s[i]) % self.size

        return h

    def _encode(cls, m):
        basea = ord('a')
        based = ord('0')
        es = []
        for s in m:
            bs = []
            for c in s:
                if c.isdigit():
                    bs.append(ord(c) - based + 27)
                else:
                    bs.append(ord(c) - basea)
            es.append(bs)

        return es

def run():
    h, w = [int(x) for x in input().split()]
    m = []

    for _ in range(h):
        m.append(input())

    r, c = [int(x) for x in input().split()]
    pt = []

    for _ in range(r):
        pt.append(input())

    sch = MatrixRKSearch(m, pt)
    result = []
    for i, j in sch.find():
        result.append((i, j))

    result.sort()
    for i, j in result:
        print(i, j)


if __name__ == '__main__':
    run()



Measured memory_bytes: 66060
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define pie 3.141592653589793238462643383279
#define int long long
#define mod 1000000007
#define INF 1145141919364364
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}

int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1)*x%mod;
}

int mod_pow(int x, int y, int mood) {
	int res = 1;
	while (y > 0) {
		if (y & 1)res = res * x%mood;
		x = x * x%mood;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}

int n, m, a;
int ta[9] = { 2,5,5,4,5,6,3,7,6 };
vector<P> vec;
int dp[10010];
vector<int> cnt;

signed main() {
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		cin >> a;
		vec.push_back({ a,ta[a - 1] });
	}
	dp[0] = 0;
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j < (int)vec.size(); j++) {
			if (vec[j].second <= i && dp[i - vec[j].second] != INF)dp[i] = max(dp[i], dp[i - vec[j].second] + 1);
		}
		if (dp[i] == 0)dp[i] = INF;
	}
	sort(all(vec));
	reverse(all(vec));
	int b = n;
	while (dp[b] != 0) {
		bool bl = false;
		for (int j = 0; j < (int)vec.size(); j++) {
			if (!bl&&b - vec[j].second >= 0 && dp[b] == dp[b - vec[j].second] + 1) {
				b -= vec[j].second;
				cnt.push_back(vec[j].first);
				bl = true;
			}
		}
	}
	for (int i = 0; i < (int)cnt.size(); i++) {
		cout << cnt[i];
	}
	cout << endl;
}

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

int main(){
  string divide[4] = {"dream", "dreamer", "erase", "eraser"};

  string S;
  cin >> S;

  reverse(S.begin(), S.end());
  for(int i = 0; i < 4; ++i) reverse(divide[i].begin(), divide[i].end());

  bool can = true;
  for(int i = 0; i < S.size();){
    bool can2 = false;
    for(int j = 0; j < 4; ++j){
      string d = divide[j];
      if(S.substr(i, d.size()) == d){
        can2 = true;
        i += d.size();
      }
    }
    if(!can2){
      can = false;
      break;
    }
  }
  if(can) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


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

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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


fn main() {
    input! {
        N: usize,
        A: [u64; N]
    };


    let mut max = 0;
    let mut L: Vec<u64> = vec![0; N+1];
    let mut R: Vec<u64> = vec![0; N+1];

    for i in 0..N {
        L[i+1] = gcd(A[i], L[i]);
    }
    for i in 0..N {
        R[N-i-1] = gcd(A[N-i-1], R[N-i]);
    }
    for i in 0..N {
        let tmp_max = gcd(L[i], R[i+1]);
        if max < tmp_max {
            max = tmp_max;
        }
    }
    println!("{}", max);
}

fn gcd(a: u64, b: u64) -> u64 {
    if b == 0 {
        a
    } else {
        gcd(b, a%b)
    }
}


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

int main() {
    int n;
    cin >> n;
    long long a[100], ans=1, g, x, y;
    for(int i=0; i<n; i++) {
        cin >> a[i];
        g=__gcd(a[i], ans);
        x=a[i]/g;
        y=ans/g;
        ans=g*x*y;
    }
    cout << ans;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<string>
#include<math.h>
#include<stdlib.h>
#include<time.h>
#include<map>
#include<queue>
#include<set>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
int a,b,c,d,e,f,ans1,ans2,t1,t2,h[3200];
bool g[3200];
long double ans,t;
int main(){
	scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);
	g[0]=1;
	fo(i,c,f) g[i]=g[i-c];
	fo(i,d,f) g[i]|=g[i-d];
	fo(i,1,f){
		h[i]=h[i-1];
		if (g[i]) h[i]=i;
	}
	ans1=a*100;//
	for(int i=0;a*i*100<=f;i++)
		for(int j=0;a*i*100+b*j*100<=f;j++){
			t1=a*i*100+b*j*100;
			if (!t1) continue;
			t2=t1/100*e;
			if (f-t1<t2) t2=f-t1;
			t2=h[t2];
			t=t1+t2;
			t=t2/t;
			if (t>ans){
				ans=t;
				ans1=t1+t2;
				ans2=t2;
			}
		}
	printf("%d %d\n",ans1,ans2);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Ford(i,a,b) for(int i=(a);i>=(b);--i)
#define fio(s) freopen(s".inp","r",stdin)
#define foo(s) freopen(s".out","w",stdout)
#define task "test"
using namespace std;
typedef long long LL;
const LL N=1009,OO=1e9+7;
LL n,m,dp[N][N];
char a[N][N];
int main(){
    //fio(task); foo(task);
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin>>n>>m;
    For(i,1,n)
    For(j,1,m) cin>>a[i][j];
    dp[1][1]=1;
    For(i,1,n)
    For(j,1,m)
    if(a[i][j]!='#'){
        dp[i][j]=(dp[i][j]%OO+dp[i-1][j]%OO+dp[i][j-1]%OO)%OO;
    }else dp[i][j]=0;
    cout<<dp[n][m]%OO;
    return 0;
}


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


using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(ll i=st; i<ed; i++)
#define repn(i, st, ed) for(ll i=st; i<=ed; i++)
#define repb(i, ed, st) for(ll i=ed; i>=st; i--)
#define all(v) v.begin(),v.end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 2e5 + 10;
const ll INF = 1LL << 60;

template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}



// Main Code
bool p[N];
vector<ll> v;
void sieve()
{
	for(ll i = 2; i*i <= N; i++)
	{
		if(p[i] == 0)
		{
			for(ll j =i*i; j<= N; j+= i)
				p[j] = 1;
		}
	}
	for(ll i=2; i<= N; i++)
	{
		if(p[i] == 0) v.pb(i);
	}
}
int main()
{
	ll k;
	cin>>k;
	sieve();
	auto itr = lower_bound(all(v), k);
	cout<<*itr<<endl;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	ll a, b;
	cin >> a >> b;
	string ans = "";
	if( a*b <= 0 ){
		ans += "Zero";
	} else if ( a+b > 0 || ( a+b < 0 && abs(b-a) % 2 == 1 )){
		ans += "Positive";
	} else {
		ans += "Negative";
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int A,B;
  char S[10],T[10],U[10];
  scanf("%s %s\n%d %d\n%s",S,T,&A,&B,U);

  if(*S==*U)
  {
    printf("%d %d\n", A-1, B);
  }
  else if(*T==*U)
  {
    printf("%d %d\n", A,B-1);
  }
  return 0;
}


Measured memory_bytes: 1708
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (size_t i = 0; i < size_t(n); i++)
#define forn1(i,n) for (size_t i = 1; i <= size_t(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

int head(int x) {
    while (x >= 10) {
        x /= 10;
    }
    return x;
}

int cnt[10][10];

int main() {
    fastio();

    int n;
    cin >> n;
    forn1(i, n) {
        cnt[head(i)][i % 10]++;
    }

    ll ans = 0;
    forn1(i, 9) {
        forn1(j, 9) {
            ans += cnt[i][j] * cnt[j][i];
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
// #define int ll
using namespace std;
const int INF (1 << 30);
const ll LLINF (1LL << 55LL);
const int MOD = 1000000007;
const int MAX = 510000;
const double pi=3.14159265358979;

ll fac[MAX], finv[MAX], inv[MAX];
ll POW[MAX];

void POWinit(){
    POW[0]=0;
    POW[1]=1;
    for(ll i=2;i<MAX;i++){
        POW[i]=POW[i-1]*i;
        POW[i]%=MOD;
    }
}


// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k;
    cin>>n>>k;
    COMinit();
    POWinit();
    if(n>k){
        cout<<0<<endl;
        return 0;
    }
    cout<<COM(k,k-n)<<endl;
    return 0;
}


Measured memory_bytes: 19136
import sys
import math
import itertools
import numpy
import collections

rl = sys.stdin.readline

n = int(rl())

li = []
for _ in range(n):
    li.append(rl().rstrip())
c = collections.Counter(li)
max_cnt = 0
li = []
for k, v in c.items():
    if v < max_cnt:
        continue
    elif v == max_cnt:
        li.append(k)
    else:
        max_cnt = v
        li = [k]
li.sort()
print('\n'.join(li))





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

int main() {
	vector<int>ans(4,0);
	for (int i = 0; i < 3; i++) {
		int x, y;
		cin >> x >> y;
		ans.at(x - 1)++;
		ans.at(y - 1)++;
	}
	sort(ans.begin(), ans.end());
	if (ans.at(3) == 2)cout << "YES" << endl;
	else cout << "NO" << endl;
	// 1,1,2,2, 1,1,1,3 
		
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  ll T[N], A[N];
  for(int i=0;i<N;++i) cin>>T[i];
  for(int i=0;i<N;++i) cin>>A[i];
  if(T[N-1]!=A[0]) {
    cout<<0<<endl;
    return 0;
  }
  ll mh = T[N-1];
  int l=-1, r=-1;
  for(int i=0;i<N;++i) {
    if(T[i]==mh && A[i]==mh) {
      l = i;
      break;
    }
  }
  for(int i=N-1;i>=0;--i) {
    if(T[i]==mh && A[i]==mh) {
      r = i;
      break;
    }
  }
  if(l==-1) {
    cout<<0<<endl;
    return 0;
  }
  ll ans = 1;
  for(int i=1;i<l;++i) {
    if(T[i]==T[i-1]) {
      ans *= T[i];
      ans %= mod;
    }
  }
  for(int i=N-2;i>=r;--i) {
    if(A[i]==A[i+1]) {
      ans *= A[i];
      ans %= mod;
    }
  }
  for(int i=0;i<r-l-1;++i) {
    ans *= mh;
    ans %= mod;
  }
  cout<<ans<<endl;
}



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

int main() {
  int h, w;
  cin >> h >> w;
  vector<vector<int>> c(10, vector<int>(10));
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      cin >> c[i][j];
    }
  }
  vector<vector<int>> a(h, vector<int>(w));
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cin >> a[i][j];
    }
  }
  for (int k = 0; k < 10; k++) {
    for (int i = 0; i < 10; i++) {
      for (int j = 0; j < 10; j++) {
        c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (a[i][j] == -1) continue;
      ans += c[a[i][j]][1];
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
import collections

n,q=map(int,input().split())
cnt=[0]*(n+1)
g=[[] for _ in range(n+1)]
for _ in range(n-1): #木グラフの隣接リストを作成
 a,b=map(int,input().split())
 g[a].append(b)
 g[b].append(a)
for _ in range(q): #各頂点についてcount[v]を計算
 v,val=map(int,input().split())
 cnt[v]+=val
q=collections.deque()
q.append(1) #DFSのスタックによる実装、まずスタックに始点1を積む
checked=[0]*(n+1) #各頂点を見たかどうかのフラグを持っておく
while q:
 v=q.pop()
 checked[v]=1 #頂点を見たかどうかのフラグを更新する
 for u in g[v]:
   if checked[u]==1: #vの子ノードuについて、まだ見ていない頂点であればcount[u]をcount[u]+=count[v]として更新する
     continue
   cnt[u]+=cnt[v]
   q.append(u) #スタックに子ノードuを積む
print(*cnt[1:]) #各頂点のcountが答えとなる

Measured memory_bytes: 128920
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;

int N;

vector<int> t[15];
string u[15];
int sx[15],sy[15];
int dp[ (1<<15) ];
map< P , int > mp;

void ry(vector<int> &v){
  int tmp=v[2];
  v[2]=v[4];
  v[4]=v[3];
  v[3]=v[5];
  v[5]=tmp;
}

void rx(vector<int> &v){
  int tmp=v[0];
  v[0]=v[4];
  v[4]=v[1];
  v[1]=v[5];
  v[5]=tmp;
}

int main(){
  while(1){
    cin>>N;
    if(N==0)break;
    mp.clear();
    for(int i=0;i<N;i++){
      t[i].clear();
      t[i].resize(6);
      cin>>sx[i]>>sy[i];
      for(int j=0;j<6;j++)cin>>t[i][j];
      cin>>u[i];
    }

    for(int i=0;i<N;i++){
      P p=P(sx[i],sy[i]);
      mp[p]|=(1<<i);
      for(int j=0;j<(int)u[i].size();j++){
        if(u[i][j]=='L')p.first--;
        if(u[i][j]=='R')p.first++;
        if(u[i][j]=='F')p.second--;
        if(u[i][j]=='B')p.second++;
        mp[p]|=(1<<i);
      }
    }
      
    memset(dp,0,sizeof(dp));

    for(int S=0;S<(1<<N);S++){
      for(int i=0;i<N;i++){
        if(S>>i&1)continue;
        map< P , int > w;
        vector<int> v=t[i];
        P p=P(sx[i],sy[i]);
        int cost=0;

        if((mp[p]&S)==0){
          cost-=w[p];
          w[p]=v[4];
          cost+=v[4];
        }
        
        for(int j=0;j<(int)u[i].size();j++){
          if(u[i][j]=='L'){
            p.first--;
            rx(v);rx(v);rx(v);
          }
          if(u[i][j]=='R'){
            p.first++;
            rx(v);
          }
          if(u[i][j]=='F'){
            p.second--;
            ry(v);ry(v);ry(v);
          }
          if(u[i][j]=='B'){
            p.second++;
            ry(v);
          }
          if((mp[p]&S)==0){
            cost-=w[p];
            w[p]=v[4];
            cost+=v[4];
          }
        }
        dp[S|(1<<i)]=max(dp[S|(1<<i)],dp[S]+cost);
      }
    }
    cout<<dp[(1<<N)-1]<<endl;
  }
  return 0;
}

Measured memory_bytes: 1380
n = int(input())
aaa = list(map(int, input().split(' ')))
bbb = list(map(int, input().split(' ')))
ccc = list(map(int, input().split(' ')))
ans = 0
old = -999
for i in aaa:
    ans += bbb[i-1]
    if i == old + 1 and old-1 < len(ccc):
        ans += ccc[old-1]
    old = i
print(ans)

Measured memory_bytes: 40528
#include<stdio.h>
void ashi(int p0[2],int p1[2],int p2[2],double *x,double *y){
  int x1=p1[0]-p0[0],x2=p2[0]-p0[0],y1=p1[1]-p0[1],y2=p2[1]-p0[1];
  *x=1.0*(x1*x2+y1*y2)/(x1*x1+y1*y1)*x1+p0[0];
  *y=1.0*(x1*x2+y1*y2)/(x1*x1+y1*y1)*y1+p0[1];
}
int main(){
  int p[3][2],n;
  double x,y;
  for(n=0;n<4;n++)scanf("%d",&p[n/2][n%2]);
  scanf("%d",&n);
  while(n--){
    scanf("%d %d",&p[2][0],&p[2][1]);
    ashi(p[0],p[1],p[2],&x,&y);
    printf("%.9f %.9f\n",x,y);
  }
  return 0;
}

Measured memory_bytes: 640
//-------------
//include
//-------------
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <vector>
#include <string>
#include <cctype>
#include <random>
#include <cstdlib>
#include <iostream>
#include <numeric>
#include <algorithm>
using namespace std;
//-------------
//typedef
//-------------
typedef long long LL;
typedef  vector<int> VI;
typedef  set<int> SI;
typedef  string STR;
typedef  pair<int, int> PII;
typedef  vector<int, int> VII;
typedef  map<string, int> MSI;
//-------------
//utillty
//-------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MK make_pair
#define PB push_back
#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 COUT(a) cout<<a<<endl
//-------------
//repetition
//-------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//-------------
//debug
//-------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumpl(c) REP(i,SZ(c))cerr<<#c<<i<<"="<<(c[i])<<endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const int MOD = 1000000007;
int main()
{
	int N,K;
	cin >>N>>K;
	VI A;
	REP(i,N)
	{
		int temp;
		cin >> temp;
		A.push_back(temp);
	}
	SORT(A);
	auto itr = A.begin()+ (N - K);
	COUT(accumulate(itr, A.end(),0));
#ifdef _DEBUG
	while (1);
#endif // _DEBUG

	return 0;
}

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

int main(){
	char s[1001];
	char *tok;
	char *tok_list[100];
	int tok_mode[100]={0};
	char max_length_str[33]="";
	char max_times_str[33]="";
	int max_times=0;
	int i, j, n;

	scanf("%[^\n]", s);
	
	tok = strtok( s, " " );
	for( n=0; tok!=NULL; n++ ){
		tok_list[n] = tok;
		if( strlen(tok)>strlen(max_length_str) )
		 	strcpy( max_length_str, tok );
		tok = strtok( NULL, " " );
	}

	for( i=0; i<n; i++ ){
		for( j=0; j<n; j++ ){
			if( strcmp( tok_list[i], tok_list[j] )== 0 ) 
				tok_mode[i]++;
		}
	}
	
	for( i=0; i<n; i++ ){
		if( tok_mode[i] > max_times ){
			max_times = tok_mode[i];
			strcpy( max_times_str, tok_list[i] );
		}
	}
	
	printf("%s %s\n", max_times_str, max_length_str);
	
	return 0;
}
			

Measured memory_bytes: 560
#include<bits/stdc++.h>
using namespace std;
#define M 1000000
#define NIL -1;
#define L 14
char H[M][L];

int h1(int key)
{
    return key%M;
}
int h2(int key)
{
    return (1+(key%(M-1)));
}
int h3(int key,int i)
{
    return(h1(key)+i*h2(key))%M;
}

int getChar(char ch)
{
    if(ch=='A') return 1;
    else if(ch=='C') return 2;
    else if(ch=='G') return 3;
    else if(ch=='T') return 4;
    else return 0;
}

long long getKey(char str[])
{
    long long sum=0,p=1,i;
    for(i=0;i<strlen(str);i++)
    {
        sum+=p*(getChar(str[i]));
        p*=5;
    }
    return sum;
}

int Insert(char str[])
{
    long long key,i,h;
    key=getKey(str);
    for(i=0;;i++)
    {
        h=(h1(key)+i*h2(key))%M;
        if(strcmp(H[h],str)==0) return 1;
        else if(strlen(H[h])==0)
        {
            strcpy(H[h],str);
            return 0;
        }
    }
    return 0;
}
int Find(char str[])
{
    long long key,i,h;
    key=getKey(str);
    for(int i=0;;i++)
    {
        h=(h1(key)+i*h2(key))%M;
        if(strcmp(H[h],str)==0) return 1;
        else if(strlen(H[h])==0) return 0;
    }
    return 0;
}

int main()
{
    int n,i;
    char cmd[9],str[L];
    cin>>n;
    for(i=0;i<n;++i)
    {
        cin>>cmd>>str;
        if(cmd[0]=='i')
        {
            Insert(str);
        }
        else if(cmd[0]=='f')
        {
            if(Find(str))
            {
                cout<<"yes"<<endl;
            }
            else
            {
                cout<<"no"<<endl;
            }
        }
    }

	return 0;
}


Measured memory_bytes: 16712
#include <stdio.h>
long long p = 1000000007;
long long n, a, t;
long long k[60];
long long ans;
long long rui[60];
int main() {
	scanf("%lld", &n);
	rui[0] = 1;
	for (int i = 1; i < 60; i++) {
		rui[i] = rui[i - 1] * 2;
		rui[i] %= p;
	}
	for (long long i = 0; i < n; i++) {
		scanf("%lld", &a);
		for (int j = 0; j < 60; j++) {
			t = a % 2;
			a /= 2;
			if (t) {
				ans += rui[j] * (i - k[j]);
			}
			else {
				ans += rui[j] * k[j];
			}
			ans %= p;
			k[j] += t;
		}
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
//using System.Linq;
//using System.Numerics;

class Program {
    static void Main (string[] args) {
        var input = INP();
        CWL(input[0].Substring(0,1).ToUpper() +
            input[1].Substring(0,1).ToUpper() +
            input[2].Substring(0,1).ToUpper());
    }

    public static List<int> PrimeFactors (int n) {
        var tmpList = new List<int>();
        int i = 2;
        int tmp = n;

        while(i * i <= n) {
            if(tmp % i == 0) {
                tmp /= i;
                tmpList.Add(i);
            } else {
                i++;
            }
        }

        if(tmp != 1) tmpList.Add(tmp);

        return tmpList;
    }

    static string[] INP () {
        return Console.ReadLine().Split(' ');
    }

    static void CWL (string value) {
        Console.WriteLine(value);
    }

    static void CWL (int value) {
        Console.WriteLine(value);
    }

    static void CWL (long value) {
        Console.WriteLine(value);
    }

    static void CWL (float value) {
        Console.WriteLine(value);
    }

    static void CWL (double value) {
        Console.WriteLine(value);
    }

    static int TOI (string str) {
        return int.Parse(str);
    }

    static long TOL (string str) {
        return long.Parse(str);
    }

    static float TOF (string str) {
        return float.Parse(str);
    }

    static double TOD (string str) {
        return double.Parse(str);
    }

    /*static void Main (string[] args) {
        var input = INP();
        var input2 = INP();
        var input3 = INP();

        CWL("dummy");
    }*/
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T> using ve = vector<T>;
template<typename T> using pq1 = priority_queue<T>;
template<typename T> using pq2 = priority_queue<T,vector<T>,greater<T>>;



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



int main()
{
    int H,N;
    cin >> H >> N;
    vi A(N),B(N);
    rep(i,N) cin >> A[i] >> B[i];
    vi dp(H+1,infi);
    dp[0] = 0;
    rep(i,N) rep(j,H){
        int n = j+A[i];
        chmin(n,H);
        chmin(dp[n],dp[j]+B[i]);
    }
    out(dp[H]);

    return 0;
}


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

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int cards[4][13];
    int i,j;
    int a,n;
    char m,d;

    for(i=0; i<4; i++){
        for(j=0; j<13;j++){
            cards[i][j]=0;
        }
    }    
    scanf("%d", &a);
    for(i=0; i<a; i++){
        scanf("%c", &d);
        scanf("%c %d", &m, &n);
        if(m=='S'){
            cards[0][n]=1;
        }
        else if(m=='H'){
            cards[1][n]=1;
        }
        else if(m=='C'){
            cards[2][n]=1;
        }
        else if(m=='D'){
            cards[3][n]=1;
        }
    }
    
    for(j=1; j<=13; j++){
        if(cards[0][j]!=1) printf("S %d\n", j);
    }
    for(j=1; j<=13; j++){
        if(cards[1][j]!=1) printf("H %d\n", j);
    }
    for(j=1; j<=13; j++){
        if(cards[2][j]!=1) printf("C %d\n", j);
    }
    for(j=1; j<=13; j++){
        if(cards[3][j]!=1) printf("D %d\n", j);
    }
    
    return 0;
}


Measured memory_bytes: 2088
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
#define endl '\n'
const ll inf = LLONG_MAX;
long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
  ll n, k;
  cin >> n >> k;
  n %= k;
  cout << min(n, k - n) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC target ("avx2")
#pragma GCC optimization ("03")
#pragma GCC optimization ("unroll-loops")
using namespace std;

const int maxn = 200002;
const int maxe = 20;
int a[maxn],b[maxn],c,pa[maxn],x,y,q,sol,d,mod=1000000007;
long long k,m,n;
string s;
int rmq[maxn][maxe];
int st[4*maxn],la[4*maxn],ft[maxn];
char h;
set<int>se;
void build(int n){
    for(int j=1;(1<<j)<=n;j++){
        for(int i=1;i+(1<<j)-1<=n;i++){
            rmq[i][j] = min(rmq[i][j-1], rmq[i+(1<<(j-1))][j-1]);
        }
    }
}

int query(int a, int b){
    int k = 31- __builtin_clz(b-a+1);
    return min(rmq[a][k], rmq[b-(1<<k)+1][k]);
}

int fin(int i)
{
    if(pa[i]==i)return i;
    return pa[i]=fin(pa[i]);
}

int bs(int l,int r)
{

    while(l!=r)
    {
        int mi=(l+r)/2;
        if(a[mi]==x)return mi;
        if(a[mi]>x)r=mi;
        else l=mi+1;
    }
    return l;
}
void crear(int l,int r,int nod){
if(l==r)st[nod]=a[l];
else{
int mi=(l+r)/2;
crear(l,mi,2*nod);
crear(mi+1,r,2*nod+1);
st[nod]=min(st[2*nod],st[2*nod+1]);
}
}

void upd(int l,int r,int nod){
if(l>x || r<x)return;
if(la[nod]!=0){
st[nod]+=la[nod];
la[2*nod]+=la[nod];
la[2*nod+1]+=la[nod];
la[nod]=0;
}
if(l==r)st[nod]+=y;
else{
int mi=(l+r)/2;
upd(l,mi,2*nod);
upd(mi+1,r,2*nod+1);
st[nod]=min(st[2*nod],st[2*nod+1]);
}
}

int qu(int l,int r,int nod){
if(l>y || r<x)return 100001;
if(la[nod]!=0){
st[nod]+=la[nod];
la[2*nod]+=la[nod];
la[2*nod+1]+=la[nod];
la[nod]=0;
}
if(l>=x && r<=y)return st[nod];
else {
int mi=(l+r)/2;
return min(qu(l,mi,2*nod),qu(mi+1,r,2*nod+1));
}
}

void lazy(int l,int r,int nod){
if(l>y || r<x)return;
if(la[nod]!=0){
st[nod]+=la[nod];
la[2*nod]+=la[nod];
la[2*nod+1]+=la[nod];
la[nod]=0;
}
if(l>=x && r<=y){
st[nod]+=q;
if(l!=r){
la[nod*2]+=q;
la[2*nod+1]+=q;
}
}
else {
int mi=(l+r)/2;
lazy(l,mi,2*nod);
lazy(mi+1,r,2*nod+1);
st[nod]=min(st[2*nod],st[2*nod+1]);
}
}

int ftq(int n){
int c=0;
while(n){
c+=ft[n];
n-=(n&-n);
}
return c;
}

void ftupd(int x){
for(int i=x;i<maxn;i+=(i&-i))
ft[i]+=y;
}

int main()
{
    ios_base::sync_with_stdio(0);
    //cin.tie(0);
    //cout.tie(0);

    cin>>n;
    k=sqrt(n);
    for(int i=k;k>0;i--){
    if(n%i==0){cout<<i+n/i-2;return 0;}
    }
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int N;
  cin >> N;
  vl A(N);
  rep(i,N) {
    cin >> A[i];
  }
  vl sum(N);
  ll a = 0;
  if(A[0]>0) {
    sum[0] = A[0];
  } else {
    sum[0] = 1;
    a += 1-A[0];
  }
  srep(i,1,N) {
    if(i%2==0) {
      if(sum[i-1]+A[i]>0) {
        sum[i] = sum[i-1]+A[i];
      } else {
        sum[i] = 1;
        a += 1 - (sum[i-1]+A[i]);
      }
    } else {
      if(sum[i-1]+A[i]<0) {
        sum[i] = sum[i-1]+A[i];
      } else {
        sum[i] = -1;
        a += 1 + (sum[i-1]+A[i]);
      }
    }
  }
  ll b = 0;
  if(A[0]<0) {
    sum[0] = A[0];
  } else {
    sum[0] = -1;
    b += 1 + A[0];
  }
  srep(i,1,N) {
    if(i%2==1) {
      if(sum[i-1]+A[i]>0) {
        sum[i] = sum[i-1]+A[i];
      } else {
        sum[i] = 1;
        b += 1 - (sum[i-1]+A[i]);
      }
    } else {
      if(sum[i-1]+A[i]<0) {
        sum[i] = sum[i-1]+A[i];
      } else {
        sum[i] = -1;
        b += 1 + (sum[i-1]+A[i]);
      }
    }
  }
  cout << min(a,b) << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
struct ios_accelerate { ios_accelerate() { ios::sync_with_stdio(false); cin.tie(nullptr); } } CALL;

#define REP(i, n) for(auto (i) = (n)*0; (i) < (n); (i)++)
#define RNG(i, a, b) for(auto (i) = (a); (i) < (b); (i)++)
#define RBF(i, v) for(auto& (i) : (v))
#define ALL(x) (x).begin(), (x).end()

using LL = long long;
using UL = unsigned long;
using ULL = unsigned long long;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
template<typename T> using P = pair<T, T>;

const double PI = 3.141592653589793;
const int MOD = 1000000007;
const LL INF64 = static_cast<LL>(1e18) + 2;
const int INF = static_cast<int>(1e9) + 2;

template<typename T> inline void upsort(vector<T>& x) { sort(x.begin(), x.end()); }
template<typename T> inline void downsort(vector<T>& x) { sort(x.begin(), x.end(), greater<T>()); }
template<typename T> inline void col(T x) { cout << x << '\n'; }
template<> inline void col(double x) { cout << fixed << setprecision(12) << x << '\n'; }

signed main() {
	int n;
	string s;
	cin >> n >> s;
	
	if (n % 2) {
		col("No");
		return 0;
	}

	REP(i, n / 2) {
		if (s[i] != s[i + n / 2]) {
			col("No");
			return 0;
		}
	}
	col("Yes");
	return 0;
}

Measured memory_bytes: 3592
#include<iostream>
using namespace std;
int main(){
  int n,a[1000];
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  
  for(int i=n-1;i>0;i--){
    cout<<a[i]<<" ";
  }
  cout<<a[0]<<endl;
  
}



Measured memory_bytes: 3072
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;

const ll MOD  = 1e9 + 7;
const ll LINF = 1LL << 62;
const int INF = 1e9 + 7;

const int MAX_DEGIT = 50;
int main(){
    ll n, k;
    cin >> n >> k;

    ll cnt[MAX_DEGIT] = {};
    rep(i, n){
        ll a;
        cin >> a;
        rep(j, MAX_DEGIT)if((1LL<<j) & a)cnt[j]++;
    }

    //dp[i][1] = 上位i桁目までを決めて，かつkより小さい
    ll dp[MAX_DEGIT+1][2] = {};
    rep(i, MAX_DEGIT+1)dp[i][1] = -1;
    
    rep(i, MAX_DEGIT){
        ll base = (1LL<<(MAX_DEGIT-i-1));

        ll cost_up = base * (n - cnt[MAX_DEGIT-i-1]);
        ll cost_down = base * cnt[MAX_DEGIT-i-1];

        //既にkより小さく行けているのなら自由にビットを立てる
        if(dp[i][1] >= 0){
            dp[i+1][1] = dp[i][1] + max(cost_up, cost_down);
        }

        if(base & k){
            //ギリギリの物からビットを下げてkより小さくする
            dp[i+1][1] = max(dp[i+1][1], dp[i][0] + cost_down);
            dp[i+1][0] = dp[i][0] + cost_up;
        }
        else {
            dp[i+1][0] = dp[i][0] + cost_down;
        }
    }

    cout << max(dp[MAX_DEGIT][0], dp[MAX_DEGIT][1]) << endl;
}

Measured memory_bytes: 3604
#include <stdio.h>
#include <string.h>
int main(){
 int A,B,C,K;
 scanf("%d %d %d %d",&A,&B,&C,&K);
 if(K<=A)printf("%d",K);
  else if(K<=A+B)printf("%d",A); 
   else printf("%d",2*A-K+B);
 return 0;
}

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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n;
  while (cin >> n) {
    vector<double> p(n);
    cin >> p;
    const int N = 3000 + 5;
    static double dp[N][N];
    fill(&dp[0][0], &dp[N - 1][N - 1] + 1, 0);
    dp[0][0] = 1;
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < n; ++j) {
        dp[i + 1][j + 1] += dp[i][j] * p[i];
        dp[i + 1][j] += dp[i][j] * (1.0 - p[i]);
      }
    }

    double sum = 0;
    for (int j = n / 2 + 1; j <= n; ++j) {
      sum += dp[n][j];
    }
    //cout << sum << endl;
    printf("%.10lf\n", sum);
  }
  
  return 0;
}


Measured memory_bytes: 70784
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N,N1;
  cin >> N;
  N1=N;
  int x=0;
  for (int i=7;i>0;i--){
    int t=pow(10,i);
    x+=N/t;
    N=N-(N/t)*t;
  }
  x+=N;
  if (N1%x==0)cout<<"Yes"<<endl;
  else cout <<"No"<<endl;
}


Measured memory_bytes: 384
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func main() {
	var N int
	fmt.Scan(&N)
	a := make([]int, 3*N)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	for i := 0; i < 3*N; i++ {
		sc.Scan()
		a[i], _ = strconv.Atoi(sc.Text())
	}
	sort.Ints(a)
	var sum int64
	sum = 0
	for i := N; i < N*3; i += 2 {
		sum += int64(a[i])
	}
	fmt.Println(sum)
}


Measured memory_bytes: 5888
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
constexpr int MOD=1000000007;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;

int main(void){
    lint N,M;
    cin >> N >> M;
    if(N==1 && M==1) cout << N << endl;
    else if(N==1 || M==1) cout << max(N,M)-2 << endl;
    else cout << N*M-(N+M)*2+4 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<long long> p(n+1);
  for(int i=1;i<n+1;i++){
    int a;
    cin >> a;
    p[a] = i;
  }
  set<long long> st;
  st.insert(0);
  st.insert(n+1);
  long long ans = 0;
  for(int i=1;i<n+1;i++){
    auto r = st.lower_bound(p[i]);
    auto l = r;
    l--;
    ans += (*r - p[i]) * (p[i] - *l) * i;
    st.insert(p[i]);
  }
  cout << ans << endl;
}

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

int main() {
int x,y;
while(cin>>x>>y){
	if(x==0 && y==0)return 0;
	cout<<min(x,y)<<" "<<max(x,y)<<endl;
	
}
	// your code goes here
	return 0;
}

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

namespace ABC128
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            int N = int.Parse(s);

            string[] s1;

            Dictionary<int, string> dic = new Dictionary<int, string>();
            Dictionary<int, int> dic2 = new Dictionary<int, int>();

            for (int i = 0; i < N; i++)
            {
                s1 = Console.ReadLine().Split(' ');
                dic.Add(int.Parse(s1[1]), s1[0]);

                dic2.Add(int.Parse(s1[1]), i);
            }

            var SortedDic = dic.OrderBy(x => x.Value).ThenByDescending(x => x.Key);

            foreach (var v in SortedDic)
            {
                Console.WriteLine(dic2[v.Key] + 1);
            }

        }
    }
}

Measured memory_bytes: 11604
#include <bits/stdc++.h>
#define io_optimized ios::sync_with_stdio(false);cin.tie(0);
using namespace std;

int main () {
#define int int_fast32_t
	io_optimized
	int n,m;
	double x;
	while(cin>>n>>m)
	{
		double a[n];
		set<double> se;
		double sum=0;
		for(int i=0;i<n;i++)
		{
			double y=0;
			cin>>x;
			if(int(x)%2==0)
			{
				y+=((x+1)*(x/2))/x;
			}
			else
			{
				y+=((x+1)*int(x/2)+ceil(x/2))/x;
			}
			a[i]=y;
			if(i==m-1)
			{
				for(int j=i;j>=i+1-m;j--)
				{
					sum+=a[j];
				}
				se.insert(sum);
			}
			else if(i>m-1)
			{
				sum-=a[i-m];
				sum+=a[i];
				se.insert(sum);
			}
		}
		cout<<fixed<<setprecision(12)<<*se.rbegin()<<"\n";
	}

	return 0;
}


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

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

    if (N * M > 0)
    {
        cout << N * (N - 1) /2 + M * (M - 1) /2;
    }
    else if (N > 0)
    {
        cout << N * (N - 1)/2;
    }
    else if (M > 0)
    {
        cout << M * (M - 1)/2;
    }
    else
    {
        cout << "0";
    }
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <atcoder/all>
using namespace atcoder;
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
// gp_hash_table<int, int> mapka;

using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

using mint = modint998244353;
ostream& operator<<(ostream& out, mint m){
  out << m.val();
  return out;
}

struct val{
  mint res;
  mint p10;
};

val op(val a,val b){
  return {a.res * b.p10 + b.res, a.p10 * b.p10};
}
val e(){
  return {0, 1};
}

val mapping(int x,val y){
  if(x != -1)return {(y.p10-1) / 9 * x, y.p10};
  return y;
}
int composition(int a,int b){
  if(a!=-1)return a;
  return b;
}

int id(){
  return -1;
}

int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);
  int n,q;
  cin >> n >> q;
  lazy_segtree<val, op, e, int, mapping, composition, id> dp(vector<val>(n,{1,10}));
  R(i,q){
    int l,r,d;
    cin >> l >> r >> d;l--;
    dp.apply(l,r,d);
    cout << dp.all_prod().res << "\n";
  }
}


Measured memory_bytes: 10900