akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	for(auto &e:u) fill_v<T>(e,v...);
}

void step(string& s) {
  string t(s.size()-1, '0');
  REP(i, s.size()-1) {
    t[i] += abs(s[i]-s[i+1]);
  }
  swap(s, t);
}

// 1-stepすすめると0, 1, 2だけになる
//

int comb_parity(int64 a, int64 b) {
  int64 ret = 1;
  while (a) {
    if (a%2 == 0 && b%2) ret = 0;
    a /= 2;
    b /= 2;
  }
  return ret;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int64 N;
  cin >> N;
  string s;
  cin >> s;
  step(s);
  int th_1 = 0, res;
  REP(i, s.size()) {
    if (s[i] == '1') th_1 = 1;
  }
  if (th_1 == 0) {
    REP(i, s.size()) if (s[i] == '2') s[i] = '1';
  }
  res = 0;
  REP(i, s.size()) {
    res ^= (s[i]-'0')*comb_parity(s.size()-1, i)%2;
  }

  cout << res * (th_1 ? 1 : 2) << endl;
}


Measured memory_bytes: 2460
test = False


def solve_a(test=False, a=0, b=0, c=0):
    if not test:
        a, b, c = map(int, input().split())
    d = max(c - (a - b), 0)
    print(d)


def solve_b(test=False, n=0):
    if not test:
        n = int(input())
    res = 0
    for i in range(1, n + 1):
        if len(str(i)) % 2 == 1:
            res += 1
    print(res)


def solve_c(test=False, n=0, h_list=[]):
    if not test:
        n = int(input())
        h_list = list(map(int, input().split()))
    res = 'Yes'
    new_h_list = [0] * n
    new_h_list[0] = h_list[0] - 1

    for i in range(1, n):
        # cannot down
        if h_list[i] == new_h_list[i - 1]:
            new_h_list[i] = h_list[i]
        elif h_list[i] < new_h_list[i - 1]:
            new_h_list[i] = h_list[i]
            res = 'No'
        else:
            new_h_list[i] = h_list[i] - 1
    print(res)


if __name__ == "__main__":
    if test:
        solve_a(test=True, a=6, b=4, c=3)
        solve_a(test=True, a=8, b=3, c=9)
        solve_a(test=True, a=12, b=3, c=7)
        solve_b(test=True, n=11)
        solve_b(test=True, n=136)
        solve_b(test=True, n=100000)
        solve_c(test=True, n=5, h_list=[1, 2, 1, 1, 3])
        solve_c(test=True, n=4, h_list=[1, 3, 2, 1])
        solve_c(test=True, n=5, h_list=[1, 2, 3, 4, 5])
        solve_c(test=True, n=1, h_list=[1000000000])
    else:
        solve_a()
        # solve_b()
        # solve_c()


Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vv vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define INF 1000000000
#define eps 1e-7
#define mod 1000000007
#define int ll
using namespace std;

int B[25];
int A[25][25];

signed main(void) {
    int  N, M, C; cin >> N >> M >> C;
    rep(i, M) cin >>B[i];
    int ans=0;
    rep(i, N) {
        int sum=0;
        rep(j, M) {
            cin >> A[i][j];
            sum += B[j] * A[i][j];
        }
        sum+=C;
        if (sum > 0) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct Edge{
    ll to, weight;
    Edge(ll t, ll w) : to(t), weight(w){}
};
using graph = vector<vector<ll>>;
using Graph = vector<vector<Edge>>;


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

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

int main(){
    ll n, m;
    cin>>n>>m;
    vector<ll> s[m];
    for(ll i=0;i<m;++i){
        ll k;
        cin>>k;
        for(ll j=0;j<k;++j){
            ll c;
            cin>>c;
            c--;
            s[i].push_back(c);
        }
    }
    vector<ll> p(m);
    for(ll i=0;i<m;++i){
        cin>>p[i];
    }

    ll ans = 0;
    for(ll mask=0;mask<(1<<n);++mask){
        bool flag = true;
        for(ll i=0;i<m;++i){
            ll count = 0;
            for(auto val : s[i]){
                if((1<<val) & mask){
                    count++;
                }
            }
            if(count % 2 != p[i]){
                flag = false;
                break;
            }
        }
        if(flag){
            ans++;
        }
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
/*
文字列の配列の初期化、整数の型がlongになっているか
関数（splitとかcontainsとか）内では"+"とかは正規表現となされるので"\\+"とする
配列のコピーはarr1=arr.clone()
HashSet<>[]はおのおの初期化した？？？？？
 */
import java.util.*;
import java.awt.*;
import java.awt.geom.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] $) {
        Scanner sc = new Scanner(in);
        int n = sc.nextInt();
        int[] a = new int[n];
        int ans=1000000000;
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        for (int i = 1; i < n; i++) {
            ans=min(ans,gcd(a[i],a[i-1]));
        }
        out.println(ans);
    }
    static int gcd (int a, int b) {
        int temp;
        while((temp = a%b)!=0) {
            a = b;
            b = temp;
        }
        return b;
    }
}

Measured memory_bytes: 50108
import sys
#import string
#from collections import defaultdict, deque, Counter
#import bisect
#import heapq
import math
#from itertools import accumulate
#from itertools import permutations as perm
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as combr
#from fractions import gcd
#import numpy as np

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

def solve():
    n = int(stdin.readline().rstrip())
    #l = list(map(int, stdin.readline().rstrip().split()))
    #numbers = [[int(c) for c in l.strip().split()] for l in sys.stdin]
    #word = [stdin.readline().rstrip() for _ in range(n)]
    #number = [[int(c) for c in stdin.readline().rstrip()] for _ in range(n)]
    #zeros = [[0] * w for i in range(h)]
    a = (10 ** n )%MOD
    b = (9 ** n)%MOD
    c = (8 ** n)%MOD
    print((a-b*2+c)%MOD)



if __name__ == '__main__':
    solve()


Measured memory_bytes: 10816
#include <sstream>
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<ctime>
#include<cmath>
#include<map>
#include<unordered_map>
#include<stack>
#include<random>
#include<queue>
#include<list>
#include<math.h>
#include<bitset>
#include<fstream>
using namespace std;
#define ll long long int
#define ld long double
#define key pair<ld,ld>
#define ii pair<int,int>
#define si set<int>
#define vii vector<pair<int,int> >
#define vi vector<int>
#define vll vector<ll>
#define vb vector<bool>
#define vvi vector<vector<int> >
#define vs vector<string>
#define all(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define nu 100001
#define mul(x,y) ((ll)(x)*(y))%mod
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)
#define fastio  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define forn(i, n) for (int i = 0; i < int(n); i++)
#include<fstream>
const ll INF=9223372036854775807;
const ll mod=998244353
;
int  MOD(int  a, int  b)
{
    if(a>b)
        return a-b;
    else
        return b-a;
}
ll  max3(ll  a,ll  b, ll  c)
{
    return max(c,max(a,b));
}
ll min3(ll  a,ll  b,ll  c)
{
    return min(a,min(b,c));
}
ll  power(ll  x,ll  y,ll mod1)
{
    ll res = 1;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x)%mod1;
        y = y>>1;
        x = (x*x)%mod1;
    }
    return res;
}
ll logg(ll  a)
{
    ll  x=0;
    while(a>1)
    {
        x++;
        a/=2;
    }
    return x;
}
ll  gcd(ll  a,ll   b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
ll abso(ll x)
{
    if(x<0)
    {
        return -x;
    }
    return x;
}
ll ceiling (ll  a,ll  b)
{
    if(a%b==0)
    {
        return a/b;
    }
    else
    {
        return a/b+1;
    }
}
ll modinv(ll x,ll p)
{
    return power(x,p-2,p);
}
int main()
{
    fastio;
    int k,x;
    cin>>k>>x;
    for(int i=x-k+1;i<=x+k-1;i++)
    {
        cout<<i<<' ';
    }
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

template<typename T>
istream& operator >> (istream& is, vector<T>& vs){
  for(T& v: vs) is >> v;
  return is;
}

int main() {
  int X, Y, Z, K; cin >> X >> Y >> Z >> K;
  vector<LL> A(X), B(Y), C(Z); cin >> A >> B >> C;
  vector<LL> AB; AB.reserve(X * Y);
  for (int i = 0; i < X; ++i)
    for (int j = 0; j < Y; ++j)
      AB.push_back(A[i] + B[j]);
  sort(AB.rbegin(), AB.rend());

  int num1 = min(K, (int)AB.size());
  int num2 = min(K, Z);
  vector<LL> ABC; ABC.reserve(num1 * num2);
  for (int i = 0; i < num1; ++i) {
    for (int j = 0; j < num2; ++j) {
      ABC.push_back(AB[i] + C[j]);
    }
  }
  sort(ABC.rbegin(), ABC.rend());
  for (int i = 0; i < K; ++i) {
    cout << ABC[i] << endl;
  }
}


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

typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FOR1(i, n) for(int (i)=1; (i)<=(n); (i)++)
#define FORI(i, n) for(int (i)=n-1; (i)>=0; (i)--)
template<class T, class U> void umin(T& x, const U& y){ x = min(x, (T)y);}
template<class T, class U> void umax(T& x, const U& y){ x = max(x, (T)y);}
template<class T, class U> void init(vector<T> &v, U x, size_t n) { v=vector<T>(n, x); }
template<class T, class U> void init(vector<T> &v, U x, size_t n, size_t m...) { v=vector<T>(n); for(auto& a : v) init(a, x, m);}

int main(int argc, char** argv) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(15);
    if (argc == 2 && atoi(argv[1]) == 123456789) freopen("d:\\code\\cpp\\contests\\stdin", "r", stdin);

    int x;
    cin >> x;
    if ( x >= 30)
        cout << "Yes";
    else
        cout << "No";

    if (argc == 2 && atoi(argv[1]) == 123456789) cout << clock()*1.0/CLOCKS_PER_SEC << " sec\n";
    return 0;
}



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

int main()
{
	char a[3],b[3];
	cin>>a>>b;
	if(a[0]==b[2]&&a[1]==b[1]&&a[2]==b[0])
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
import math
def prime2(x):
    if x == 2: return True
    else:
        for s in stock:
            if x % s == 0: return False
        for j in xrange(3,int(math.sqrt(x))+1,2):
            if x % j == 0: return False
        else:
            stock.append(x)
            return True 
n = input()
count = 0
stock = [2]
for i in xrange(n):
    if prime2(input()): count += 1
print count

Measured memory_bytes: 4404
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {
	
	static boolean[] d = new boolean[10];
	
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		
		int n = sc.nextInt();
		int k = sc.nextInt();
		
		for (int i = 0; i < k; i++) {
			d[sc.nextInt()] = true;
		}
		
		for (int i = n;; i++) {
			if (check(i)) {
				out.println(i);
				break;
			}
		}
		
		out.flush();
	}
	
	static boolean check(int n) {
		while (n > 0) {
			if (d[(n % 10)]) return false;
			n /= 10;
		}
		return true;
	}
	
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	
	private byte readByte() {
		if (hasNextByte()) {
			return buffer[ptr++];
		} else {
			return -1;
		}
	}
	
	private boolean isPrintableChar(int c) {
		return '!' <= c && c <= '~';
	}
	
	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
	}
	
	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}
	
	public int nextInt() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		int n = 0;
		boolean minus = false;
		byte b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
}

Measured memory_bytes: 8020
#include<cstdio>
#include<cstring>
#include<cmath>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define FOR(i,a,b) for(int i = a;i < b;i++)
#define MEM(a,b) memset(a,b,sizeof(a))
#define ALL(x) (x).begin(),(x).end()
#define LMAX 9223372036854775807
#define LMIN -9223372036854775808

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ull, ull> UP;
typedef tuple<int, int, int> T;

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1){}
	void unionSet(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x])swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

int gcd(int a, int b) {
	if (a < b)swap(a, b);
	int k = a % b;
	if (k == 1)return 1;
	if (k == 0)return b;
	int ans = gcd(b, k);
	return ans;
}
int digisum(ll a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}


int main() {
	int n;
	cin >> n;
	bool ans = false;
	while (n >= 0) {
		if (n % 4 == 0)ans = true;
		n -= 7;
	}
	cout << (ans ? "Yes" : "No") << endl;
}



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

int main() {

    int N;
    cin >> N;

    vector<P> D(N);
    rep(i, N) cin >> D[i].first >> D[i].second;

    int cnt = 0;

    rep(i, N) {
        if (D[i].first == D[i].second) {
            cnt++;
        }
        else {
            cnt = 0;
        }

        if (cnt == 3) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3632
//#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <queue>
#include <list>
#include <limits>
#include <string>
#include <vector>
using namespace std;
typedef pair<int, int> P;

typedef long long ll;
const int MOD = 1000000007;

    class Pairs{
        public : ll a;
        ll b;
        void setpairs(ll _a, ll _b){
            a = _a;
            b = _b;
        }
    };

    bool cmp(const P &A, const P &B){
        return (A.first < B.first);
    }


int main(){  
    int N,L,sum = 0;
    cin >> N >> L;
    for(int i=0;i<N;i++) sum += L + i;
    if(L < 0 && N > L*(-1)){
    }else if(L < 0){
        sum -= L + N - 1;
    }else{
        sum -= L;
    }
    cout << sum;
}


Measured memory_bytes: 256
d,g=map(int,input().split())
ls=[list(map(int,input().split())) for i in range(d)]
P=list(map(lambda x:x[0],ls))
C=list(map(lambda x:x[1],ls))

tmp=10**9
for i in range(1<<d):
  total=0
  num=0
  for j in range(d):
    if (i>>j)&1:
      total+=C[j]+P[j]*100*(j+1)
      num+=P[j]
  if total>=g:
    tmp=min(num,tmp)
  else:
    for j in range(d-1,-1,-1):
      if (i>>j)&1:
        continue
      for k in range(P[j]):
        if total>=g:
          break
        total+=100*(j+1)
        num+=1
    tmp=min(tmp,num)
print(tmp)

Measured memory_bytes: 3064
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int until = 0;
    if (n == 2) {
      int a = sc.nextInt();
      int b = sc.nextInt();
      until = gcd(a, b);
    } else {
      int a = sc.nextInt();
      int b = sc.nextInt();
      int c = sc.nextInt();
      until = gcd(gcd(a, b), c);
    }
    for (int i = 1; i <= until; i++) {
      if (until % i == 0) {
        System.out.println(i);
      }
    }
  }

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


Measured memory_bytes: 26080
#include<iostream>

using namespace std;

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

string str;
int bit;

bool f(string str){
  if (str.size() == 1) {
    if (str[0] == 'T') return true;
    if (str[0] == 'F') return false;
    else return bit & (1 << (str[0] - 'a'));
  }
  int count = 0;
  rep (i, str.size()) {
    if (str[i] == '(') ++count;
    if (str[i] == ')') --count;
    if (count == 0 && (str[i] == '*' || str[i] == '+' || str.substr(i, 2) == "->")) {
      if (i < int(str.size()) - 1) {
	if(str[i] == '*') return f(str.substr(0, i)) && f(str.substr(i + 1));
	if (str[i] == '+') return f(str.substr(0, i)) || f(str.substr(i + 1));
	return !f(str.substr(0, i)) || f(str.substr(i + 2));
      }
    }
  }
  if (str[0] == '-') return !f(str.substr(1));
  return f(str.substr(1, str.size() - 2));
}

int main() {
  for (;;) {
    cin >> str;
    if (str == "#") break;
    string s1, s2;
    int app[12] = {};
    rep (i, str.size()) if (isalpha(str[i])) ++app[str[i] - 'a'];
    rep (i, str.size()) if (str[i] == '=') {
      s1 = str.substr(0, i);
      s2 = str.substr(i + 1);
    }
    bool ok = true;
    int need = 0;
    rep (i, 11) if (app[i]) need |= 1 << i;
    rep (i, 1 << 11) {
      if (i & ~need) continue;
      bit = i;
      if (f(s1) != f(s2)) {
	ok = false;
	break;
      }
    }
    cout << (ok ? "YES" : "NO") << endl;
  }
}

Measured memory_bytes: 1492
N = int(input())

nlist = map(int,input().split())

llist = list(nlist)

resu = float('INF')

def stamina_req(coordinate):
    res = 0
    for nl in llist:
        res += abs(nl - coordinate)**2
    return res



for j in range(1, 101):
    resu = min(resu, stamina_req(j))

print(resu)


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

int main(){
    string s;
    int n[4], ans=7;
    cin >> s;

    for(int i=0; i<4; ++i) n[i] = s[i] - '0';

    ans -= n[0];

    for(int op1 = 0; op1 <2; ++op1){
        for(int op2 = 0; op2 < 2; ++op2){
            for(int op3 = 0; op3 < 2; ++op3){
                int b, c, d;
                b = (op1 == 0 ? n[1] : -n[1]);
                c = (op2 == 0 ? n[2] : -n[2]);
                d = (op3 == 0 ? n[3] : -n[3]);
                if(b + c + d == ans){
                    char op[2] = {'+', '-'};
                    cout << s[0] << op[op1] << s[1] << op[op2] << s[2] << op[op3] << s[3] << "=7" << endl;
                    return 0;
                }
            }
        }
    }
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define fs first
#define fst first
#define sc second
#define snd second
#define sz(X) (int)(X).size()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define fornr(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define forab(i, a, b) for(int i = int(a); i < int(b); i++)
#define all(X) X.begin(), X.end()

typedef long long ll;
typedef pair<int, int> pii;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef double dbl;
typedef long double ld;
typedef vector<int> vi;

const int N = 2e3 + 1;
const int LOG = 61;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const int D = 700;
const ll LLMOD = 1e9 + 7;
const ll LLINF = 1e18;

int cnt[N];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, k;
    cin >> n >> k;
    vi a(n);
    forn(i, n) cin >> a[i];
    int cntinv = 0;
    forn(i, n) {
        forab(j, i + 1, n) {
            cntinv += (a[i] > a[j]);
        }
    }
    ll ans = (cntinv * 1ll * k) % LLMOD;
    ll x = ((k * 1ll * (k - 1)) / 2) % LLMOD;
    forn(i, n) {
        if (!cnt[a[i]]) {
            forn(j, n) {
                cnt[a[i]] += (a[i] > a[j]);
            }
        }
        ll add = cnt[a[i]] * 1ll * x;
        add %= MOD;
        ans += add;
        ans %= MOD;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] srgs) {
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());
    Deque<Integer> queue = new ArrayDeque<>();
    for(int i = 0; i < n; i++) {
      if(i % 2 == 0) queue.addFirst(Integer.parseInt(sc.next()));
      else queue.addLast(Integer.parseInt(sc.next()));
    }
    StringBuilder sb = new StringBuilder();
    if(n % 2 == 1) {
      for(int i = 0; i < n; i++) {
        sb.append(queue.pollFirst());
        sb.append(" ");
      }
    } else {
      for(int i = 0; i < n; i++) {
        sb.append(queue.pollLast());
        sb.append(" ");
      }
    }
    System.out.println(sb.toString());
  }
}


Measured memory_bytes: 71044
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>

#define ll long long

using namespace std;

void solve() {
    string s, t;
    cin >> s;
    cin >> t;
    int res = 0;
    for(int i = 0; i < s.size(); i++) {
        if(s[i] != t[i]) {
            res++;
        }
    }
    cout << res <<endl;
}

int main() {
    
    // int T;
    // cin >> T;
    // while(T--) {
        // solve();
    // }
    solve();
    
    return 0;
};


Measured memory_bytes: 3920
// https://atcoder.jp/contests/abc086/tasks/abc086_b

#include <bits/stdc++.h>
using namespace std;

int main()
{
    string a, b;
    cin >> a >> b;
    long n = stol(a + b);
    for (int i = 0; i < 1000; i++)
    {
        if (i * i == n)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3596
#include<stdio.h>
#include<stdlib.h>

#define MAX(x,y) (((x)>(y))?(x):(y))

struct node{
  int l,index;
};

void make_pr_queue(struct node *array, int n);
struct node pop_pr_queue(struct node *array,int n);

int main(void){
  struct node *ice,now;
  int *time;
  int i,k=0,n,L;

  scanf("%d%d",&n,&L);

  ice=(struct node *)calloc(n,sizeof(struct node));
  time=(int *)calloc(n,sizeof(int));

  for(i=0;i<n;i++){
    scanf("%d",&ice[i].l);
    ice[i].index=i;
  }

  make_pr_queue(ice,n);
  for(i=0;i<n;i++){
    now=pop_pr_queue(ice,n-i);
    time[now.index]=L-now.l;
    if(now.index==0) time[now.index]+=time[now.index+1];
    else if(now.index==n-1) time[now.index]+=time[now.index-1];
    else time[now.index]+=MAX(time[now.index-1],time[now.index+1]);
    
    if(time[now.index]>k) k=time[now.index];
  }
  printf("%d\n",k);
  free(ice);
    free(time);
  return 0;
}

void make_pr_queue(struct node *array, int n){
  int i,tmp;
  struct node swaps;

  for(i=n-1;i>=0;i--){
    if(2*i+1>=n) continue;
    if(2*i+2<n && array[2*i+2].l>array[2*i+1].l) tmp=2*i+2;
    else tmp=2*i+1;
    if(array[tmp].l>array[i].l){
      swaps=array[i];
      array[i]=array[tmp];
      array[tmp]=swaps;
      i=tmp+1;
    }
  }
}

struct node pop_pr_queue(struct node *array,int n){
  struct node ret,swaps;
  int i,next,tmp;
  ret=array[0];
  array[0]=array[n-1];

  for(i=0;2*i<n-2;i=next){
    if(2*i+2<n-1 && array[2*i+2].l>array[2*i+1].l) next=2*i+2;
    else next=2*i+1;
    if(array[next].l>array[i].l){
      swaps=array[i];
      array[i]=array[next];
      array[next]=swaps;
    }else break;
  }

  return ret;
}

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

int main()
{
  int n;
  cin >> n;
  int ans=0;
  for (int i = 1; i < n+1; i++)
  {
    int count=0;
    if(i%2==0){
      continue;
    }
    for(int j=1;j<i+1;j++){
      if(i%j==0){
        count++;
      }
    }
    if(count==8){
      ans++;
    }
  }
  cout<<ans;
  return 0;
}

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

#define REPI(i, n) for(int i = 0; i < n; i++)
#define REPJ(j, n) for(int j = 0; j < n; j++)

using namespace std;

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

    string s; cin >> s;
    s.pop_back(); s.pop_back();

    REPI(i, s.length()/2){
        if(s[i] != s[i + s.length()/2]){
            s.pop_back(); s.pop_back();
            i = 0;
        }
    }cout << s.length();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    string s; cin>>s;
    int ans=0;
    for(int i=0; i<n-2; i++){
        if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C') ans++;
        }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n, x;
  cin >> n >> x;
  vector<int> a(n);
  rep(i, n) cin >> a.at(i);
  sort(ALL(a));
  int ans = 0;
  rep(i, n){
    if(i != n - 1){
      if(x > 0 && x - a.at(i) >= 0){
        ans++;
        x -= a.at(i);
      }else break;
    }else{
      if(x == a.at(i)) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1000000007;
const int INF = 1001001001;
const ll LINF = 1001001001001001001;

int main(){
    ll n; cin >> n;
    bool flag = 0;
    rep(i,n){
        ll a; cin >> a;
        if(a%2) flag = 1;
    }
    if(flag){
        cout << "first" << endl;
    }else{
        cout << "second" << endl;
    }
}

Measured memory_bytes: 256
// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


void solve(long long n, std::vector<long long> a){

    vector<vector<i64>> dp(n + 1, vector<i64>(n + 1, -INF));
    dp[0][0] = 0;
    vector<pair<i64,int>> v;
    for(int i = 0; i < n; ++i)
        v.emplace_back(a[i], i);
    sort(v.begin(), v.end(), greater<>());
    for(int i = 0; i < n; ++i){
        int idx = v[i].second;
        i64 val = v[i].first;
        for(int j = 0; j <= n; ++j){
            if(j != n)
                chmax(dp[i + 1][j + 1], dp[i][j] + val * abs(j - idx));

            int r = i - j;
            chmax(dp[i + 1][j], dp[i][j] + val * abs((n - 1 - r) - idx));
        }
    }
    cout << *max_element(dp.back().begin(), dp.back().end()) << endl;
}


signed main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


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

int main(int argc, char const *argv[])
{
	double r;
	double area, cir;

	scanf("%lf", &r);
	area = r*r*M_PI;
	cir = 2*M_PI*r;
	printf("%.6f %.6f\n", area, cir);


	return 0;
}


Measured memory_bytes: 2136
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int d = sc.nextInt();
    if(a*b>=c*d){
      System.out.println(a*b);
    }else{
      System.out.println(c*d);
    }
  }
}

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

//素因数分解
vector<pair<ll,int>> factorize(ll n){
    vector<pair<ll,int>>res;
    for(ll i=2;i*i<=n;i++){
        if(n%i)continue;
        res.emplace_back(i,0);
        while (n%i == 0)
        {
        n /= i;
        res.back().second++;
        }
        
    }
    if(n != 1) res.emplace_back(n,1);
    return res;
}

int main(){
    int A,B,C,D,ans;
    cin >> A >> B >> C >> D;
    ans = min(A,B) + min(C,D);
    cout << ans <<endl;
}

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

namespace Atcoder
{
    class AtCodeeeeeeeeeeeeeeeeeeeer
    {
        static void Main(string[] args)
        {
            int[] s = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int H = s[0];
            int W = s[1];
            int[] a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int h = a[0];
            int w = a[1];
            Console.WriteLine((H - h) * (W - w));

        }

    }
}


Measured memory_bytes: 13268
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

long long gcd(long long a, long long b)
{
    a = abs(a), b = abs(b);
    if (a < b) swap(a, b);
    if (b == 0)
        return a;
    else {
        return gcd(b, a % b);
    }
}

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

// 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; }
};

int main()
{
    // const int mod = 1000000007;
    int n;
    cin >> n;
    using pll = pair<long long, long long>;
    using pii = pair<int, int>;
    map<pll, pii> mp;
    int zero = 0;
    for (int i = 0; i < n; i++) {
        long long a, b;
        cin >> a >> b;
        if (a == 0 & b == 0) {
            zero++;
            continue;
        }
        auto g = gcd(a, b);
        a /= g;
        b /= g;

        if (b < 0) a = -a, b = -b;
        if (b == 0 && a < 0) a = -a, b = -b;
        bool rot90 = (a <= 0);
        if (rot90) {
            auto tmp = a;
            a = b, b = -tmp;
        }
        if (rot90)
            mp[{a, b}].first++;
        else
            mp[{a, b}].second++;
    }
    /*
        modint<int> ans{1};
        for (const auto& p : mp) {
            auto rotated = p.second.first;
            auto unrotated = p.second.second;
            modint<int> now{1};
            now += modint<int>{2}.pow(rotated) - 1;
            now += modint<int>{2}.pow(unrotated) - 1;
            ans *= now;
        }
        */
    mint ans{1};
    for (const auto& p : mp) {
        auto rotated = p.second.first;
        auto unrotated = p.second.second;
        mint now{1};
        now += mint{2}.pow(rotated) - 1;
        now += mint{2}.pow(unrotated) - 1;
        ans *= now;
    }
    ans -= 1;
    ans += zero;
    cout << ans.x << endl;
    return 0;
}


Measured memory_bytes: 15668
import java.io.*;

public class Main {

	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder output = new StringBuilder();

		int m ;
		int f ;
		int r ;

		String[] str ;//m,f,r???????????????????????????????????????str????????????????????????

		while(true) {
	 //??\???????????????????????????		
			 str = br.readLine().split(" ");
			 m = Integer.parseInt(str[0]);
			 f = Integer.parseInt(str[1]);
			 r = Integer.parseInt(str[2]);

	        if(m == -1 & f == -1 & r ==  -1)  break;
	        

	 //?????????????´¢?????????????????????       

	        if(m <= 50 | f <= 50 |r <= 100) {

		    	 if(m == -1 | f == -1) output.append("F\n");  //1????¨????????????????????????´???

		    	 else if((m+f) >= 80) {         
		    		 output.append("A\n");
		    	 }
		    	 else if((m+f) >= 65) {
		    		 output.append("B\n");
		    	 }
		    	 else if((m+f) >= 50) {
		    		 output.append("C\n");
		    	 }

		    	 else if((m+f) >= 30 | r >= 50) {
		    		 if(r >= 50 ) {
		    			 output.append("C\n");
		    		 }else {
		    		     output.append("D\n");
		    		 }
		    	 }
		    	 else {
		    		 output.append("F\n");
		    	 }

		      }

	     }
        System.out.print(output);

	br.close();
	
	}

}

Measured memory_bytes: 24228
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.Closeable;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

public class Main implements Runnable {
    static ContestScanner in;
    static Writer out;
    public static void main(String[] args) {
        new Thread(null, new Main(), "", 16 * 1024 * 1024).start();
    }

    public void run() {
        Main main = new Main();
        try {
            in = new ContestScanner();
            out = new Writer();
            main.solve();
            out.close();
            in.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    void solve() throws IOException {
        char[] s = in.nextToken().toCharArray();
        for (int i = 0; i < s.length - 1; i++) {
            if(s[i] == 'A' && s[i + 1] == 'C') {
                System.out.println("Yes");
                return;
            }
        }
        System.out.println("No");
    }
}

@SuppressWarnings("serial")
class MultiSet<T> extends HashMap<T, Integer>{
    @Override public Integer get(Object key){return containsKey(key)?super.get(key):0;}
    public void add(T key,int v){put(key,get(key)+v);}
    public void add(T key){put(key,get(key)+1);}
    public void sub(T key){final int v=get(key);if(v==1)remove(key);else put(key,v-1);}
    public MultiSet<T> merge(MultiSet<T> set)
    {MultiSet<T>s,l;if(this.size()<set.size()){s=this;l=set;}else{s=set;l=this;}
        for(Entry<T,Integer>e:s.entrySet())l.add(e.getKey(),e.getValue());return l;}
}

class Writer extends PrintWriter{
    public Writer(String filename)throws IOException
    {super(new BufferedWriter(new FileWriter(filename)));}
    public Writer()throws IOException{super(System.out);}
}
class ContestScanner implements Closeable{
    private BufferedReader in;private int c=-2;
    public ContestScanner()throws IOException
    {in=new BufferedReader(new InputStreamReader(System.in));}
    public ContestScanner(String filename)throws IOException
    {in=new BufferedReader(new InputStreamReader(new FileInputStream(filename)));}
    public String nextToken()throws IOException {
        StringBuilder sb=new StringBuilder();
        while((c=in.read())!=-1&&Character.isWhitespace(c));
        while(c!=-1&&!Character.isWhitespace(c)){sb.append((char)c);c=in.read();}
        return sb.toString();
    }
    public String readLine()throws IOException{
        StringBuilder sb=new StringBuilder();if(c==-2)c=in.read();
        while(c!=-1&&c!='\n'&&c!='\r'){sb.append((char)c);c=in.read();}
        return sb.toString();
    }
    public long nextLong()throws IOException,NumberFormatException
    {return Long.parseLong(nextToken());}
    public int nextInt()throws NumberFormatException,IOException
    {return(int)nextLong();}
    public double nextDouble()throws NumberFormatException,IOException
    {return Double.parseDouble(nextToken());}
    public void close() throws IOException {in.close();}
}

Measured memory_bytes: 21588
s = input()

l,r = 0,0
ma = 0
for l in range(len(s)):
    if(s[l] not in ['A','C','G','T']):continue
    t = ""
    for r in range(l,len(s)):
        if(s[r] not in ['A','C','G','T']):break
        t += s[r]
    ma = max(ma,len(t))
print(ma)


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

int dp[101][10001];
int main() {
  int N, W;
  cin >> N >> W;
  vector<int> v(N);
  vector<int> w(N);
  rep(i, N) cin >> v[i] >> w[i];

  rep(i, N) rep(j, W + 1) {
    if (j < w[i])
      dp[i + 1][j] = dp[i][j];
    else
      dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
  }

  cout << dp[N][W] << endl;
  return 0;
}


Measured memory_bytes: 7000
n=int(input())
xyh=[tuple(map(int,input().split())) for i in range(n)]
xyh.sort(key=lambda tup:-tup[2])
for x in range(101):
	for y in range(101):
		esth=abs(x-xyh[0][0])+abs(y-xyh[0][1])+xyh[0][2]
		for i in range(1,n):
			if xyh[i][2]==0:
				if esth>abs(x-xyh[i][0])+abs(y-xyh[i][1]):
					break
			elif esth!=abs(x-xyh[i][0])+abs(y-xyh[i][1])+xyh[i][2]:
				break
		else:
			print(x,y,esth)
			exit()
		continue



Measured memory_bytes: 41200
#include<bits/stdc++.h>
#ifndef ONLINE_JUDGE
#include"custom_header.h"
#else
#define openfile 
#endif
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
#define ll long long
#define ld long double
#define fo(i,v,e) for(v=i;v<e;v++)
#define rfo(i,v,e) for(v=i;v>e;v--)
#define pll pair<ll,ll>
#define all(x) x.begin(),x.end()
#define vl vector<ll>
#define sz(x) (ll)x.size()
#define vvl vector<vl>
#define vpl vector<pll>
const ll mod = 1000000007;
void solve()
{
    string s;cin>>s;
    ll n = sz(s),i,j,sum = 0;
    fo(0,i,n)
    {
        sum+=(s[i]-'0');
    }
    cout<<(sum%9?"No":"Yes")<<endl;
}
int main()
{
   // openfile;fastio;
    ll T = 1; 
    // cin>>T;
    while(T--)
    {solve();}
}

Measured memory_bytes: 3756
/*input
3
0.30 0.60 0.80
*/

//sometimes it's the people who no one imagines anything of 
//who do the things that no one can imagine.

//code author: iamxlr8

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define N 300005
#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int main() 
{
    off;
    ll n;
    cin>>n;
    vector<double>p(n+1);
    for(ll i=1;i<=n;i++)
        cin>>p[i];
    double dp[n+1][n+1];
    memset(dp,0.0,sizeof(dp));
    dp[1][1]=p[1];
    for(ll i=2;i<=n;i++)
        dp[i][i]=dp[i-1][i-1]*p[i];
    dp[1][0]=1-p[1];
    for(ll i=2;i<=n;i++)
        dp[i][0]=dp[i-1][0]*(1-p[i]);
    for(ll i=2;i<=n;i++)
    {
        for(ll k=1;k<i;k++)
            dp[i][k]=dp[i-1][k-1]*p[i]+dp[i-1][k]*(1-p[i]);
    }
    double ans=0.0;
    for(ll i=n/2+1;i<=n;i++)
        ans+=dp[n][i];
    cout<<setprecision(12)<<ans;
    return 0;
}

Measured memory_bytes: 70656
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll; 
typedef long double ld;
typedef pair<ll, ll> pll;

const ll N = 5e5 + 30, Mod = 1e9 + 7;
const ll SQ = 330;

ll n, k;
ll d[N];
ll a[N], q[N];
set<pll> s;
vector<ll> G[N];
void Add(ll v, ll u) {
	if (!~v || u > n) 
		return;
	G[v].pb(u);
	d[u] ++;
}
int main () {
    ios::sync_with_stdio(0), cin.tie(0);
   	cin >> n >> k;
   	s.insert({-1, -1});
   	s.insert({n + n, n + n});
   	for (int i = 1; i <= n; i ++) {
   		cin >> a[i];
		if (i > k)
			s.erase({a[i - k], i - k}); 
		auto it = *s.lower_bound({a[i], -1});
		ll x = it.S;
		Add(i, x);
		auto itt = s.lower_bound({a[i], -1});
		itt--;
		x = itt->S;
		Add(x, i);
		s.insert({a[i], i});
	}
	set<ll> Q;
	for (int i = 1; i <= n; i ++)
		if (!d[i])
			Q.insert(i);
	for (int i = 1; i <= n; i ++) {
		ll x = *Q.begin();
		Q.erase(x);
		q[x] = i;
		for (auto u : G[x]) {
			d[u] --;
			if (!d[u])
				Q.insert(u);
		}
	}
	for (int i = 1; i <= n; i ++)
		cout << q[i] << '\n';
    return (0);
}

Measured memory_bytes: 76928
#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#if __cplusplus >= 201103L
#include <chrono>
using namespace std::chrono;
#endif
using namespace std;
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pb push_back
#define fi first
#define se second
#ifdef LOCAL
#define prln(x) (cout << #x << ' ' << x << endl)
#define pr(x) (cout << #x << ' ' << x << ' ' )
#define prv(x) (cout << x << ' ')
#else
#define prln(x) 
#define pr(x)
#define prv(x)
#endif
#define clr(x) memset((x), 0, sizeof((x)))
#define clr1(x) memset((x), -1, sizeof((x)))
#define endl "\n"
#define pi acos(-1)
#define rep(i, st, ed) for (int i = (st); i <= (ed); ++i)
#define rep0(i, st, ed) for (int i = (st); i < (ed); ++i)
#define per(i, st, ed) for (int i = (st); i >= ed; --i)
template<class T> void _sf(T &x) {cin >> x;}
void _sf(int &x) {scanf("%d", &x);}
void _sf(ll &x) {scanf("%lld", &x);}
void _sf(double &x) {scanf("%lf", &x);}
void _sf(char &x) {scanf(" %c", &x);}
void _sf(char *x) {scanf("%s", x);}
void sf() {}
template <class T, class...U> void sf(T & head, U&... tail) { _sf(head); sf(tail...);}
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;

int read() {
    int x = 0, f = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9') {
        if (ch == '-') f = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9') {
        x = x * 10 + ch - '0';
        ch = getchar();
    }
    return x * f;
}
vector<ll> v;
vector<ll> ans;
int main(){
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
        #if __cplusplus >= 201103L
        auto start = steady_clock::now();
        #endif
    #endif
    int n = read();
    ll x;
    ll s = 0;
    rep(i, 1, n) {
        sf(x);
        v.push_back(x);
        if (i & 1) {
            s += x;
        }else {
            s -= x;
        }
    }
    ll st = s;
    prln(st);
    ans.push_back(st);
    for (int i = 1; i <= n; ++i) {
        ll temp = ans.back();
        prln(temp);
        prln(v[i - 1]);
        ans.push_back(2 * v[i - 1] - temp);
    }
    for (int i = 0; i < n; ++i) {
        printf("%lld%c", ans[i], i == n - 1 ? '\n' : ' ');
    }

    #ifdef LOCAL
        #if __cplusplus >= 201103L
        auto end = steady_clock::now();
        duration<double> time_span = duration_cast<duration<double>>(end - start);;
        printf("Total time: %.6fs\n", time_span.count());
        #endif
    #endif
    return 0;
}

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main () {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> v(n);
  for(int i = 0; i < n; ++i) cin >> v[i];
  
  if (n <= 2) {
    cout << 1 << endl;
    return 0;
  }
  int ct = 0;
  int dir = 0;
  for(int i = 1; i < n; ++i) {
    if (v[i] > v[i - 1]) {
      if (dir < 0) {
        ct++;
        dir = 0;
      } else dir = 1;
    } else if (v[i] < v[i - 1]){
      if (dir > 0) {
        ct++;
        dir = 0;
      } else dir = -1;
    }
  }

  ct++;
  cout << ct << endl;
}

Measured memory_bytes: 640
import sys
from collections import deque

sys.setrecursionlimit(5 * 10**5)
input=sys.stdin.readline

N, Q = list(map(int, input().split()))

M = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = list(map(int, input().split()))
    M[a-1].append(b-1)
    M[b-1].append(a-1)

ans = [0] * N
for _ in range(Q):
    p, x = list(map(int, input().split()))
    ans[p-1] += x

Q = deque([0])

while Q:
    current = Q.pop()

    for i in M[current]:
        ans[i] += ans[current]
        M[i].remove(current)
        Q.append(i)

print(' '.join(map(str, ans)))


Measured memory_bytes: 72136
n, m = map(int, input().split())
adj = [[] for _ in range(n)]
h = list(map(int, input().split()))
for i in range(m):
	a, b = map(int, input().split())
	adj[a-1].append(b-1)
	adj[b-1].append(a-1)

ans = 0
for i in range(n):
	ok = True
	for v in adj[i]:
		if h[v] >= h[i]:
			ok = False
	ans += ok
print(ans)

Measured memory_bytes: 30136
local n = io.read("*n", "*l")
local str = io.read()
local mod = 1000000007
local _unused = io.read()
local t = {str:byte(1, n)}
local ret = 1
local prevstate = 0
local i = 1
while(i <= n) do
  if(i ~= n and t[i] == t[i + 1]) then
    if(prevstate == 0) then
      ret = (ret * 6) % mod
    elseif(prevstate == 1) then
      ret = (ret * 3) % mod
    else
      ret = (ret * 2) % mod
    end
    i = i + 2
    prevstate = 1
  else
    if(prevstate == 0) then
      ret = (ret * 3) % mod
    elseif(prevstate == 1) then
      --  * 1
    else
      ret = (ret * 2) % mod
    end
    i = i + 1
    prevstate = 2
  end
end
print(ret)


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll read(){
	ll a=0,b=getchar(),c=1;
	while(!isdigit(b))c=b=='-'?-1:1,b=getchar();
	while(isdigit(b))a=a*10+b-'0',b=getchar();
	return a*c;
}
string s,t;
int ans;
int main(){
	cin >> s >> t;
	for(int i=0;i<3;i++)
		if(s[i]==t[i])ans++;
	cout << ans;
	return 0;
}

Measured memory_bytes: 256