akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define tr(it, a) for (auto it = a.begin(); it != a.end(); it++)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define fo(i, n) for (int i = 0; i < n; i++)
#define Fo(i, k, n) for (int i = k; k < n ? i < n : i > n; k < n ? i += 1 : i -= 1)
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<int, pair<int, int>> pipii;
typedef priority_queue<pii, vector<pii>, greater<pii>> minpq;
typedef priority_queue<pii> maxpq;
//const double PI = acos(-1);
const int mod = 1000000007;

// ----------------------DEBUG TEMPLATE--------------------------
void __print(int x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template <typename T, typename V>
void __print(const pair<T, V> &x)
{
	cerr << '{';
	__print(x.first);
	cerr << ',';
	__print(x.second);
	cerr << '}';
}
template <typename T>
void __print(const T &x)
{
	int f = 0;
	cerr << '{';
	for (auto &i : x)
		cerr << (f++ ? "," : ""), __print(i);
	cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v)
{
	__print(t);
	if (sizeof...(v))
		cerr << ", ";
	_print(v...);
}
#ifndef ONLINE_JUDGE
#define debug(x...)               \
	cerr << "[" << #x << "] = ["; \
	_print(x)
#else
#define debug(x...)
#endif
// ----------------------DEBUG TEMPLATE--------------------------

vector<int> *adj;
int V, E;

void addEdge(int x, int y)
{
	adj[x].push_back(y);
}
int dp[100005];
int giveLongestPath(int n){
	if(adj[n].size()==0){
		return 0;
	}
	if(dp[n]>-1){
		return dp[n];
	}
	dp[n]=0;
	for(int nbr : adj[n]){
		dp[n] =  max(1 + giveLongestPath(nbr),dp[n]);
	}
	return dp[n];
}

void cover(){
	int ans=0;
	Fo(i,1,V+1){
		ans = max(ans,giveLongestPath(i));
	}
	cout<<ans<<endl;
}


int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin >> V >> E;
	adj = new vector<int>[V+1];
	for(int i =0;i <E;i++){
		int u,v;
		cin>>u>>v;
		addEdge(u,v);
	}
	memset(dp,-1,sizeof(dp));
	cover();




}


Measured memory_bytes: 11808
/*input
1101010010101101110111100011011111011000111101110101010010101010101 20
*/

// Nihesh Anderson - knandy

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; // find_by_order, order_of_key
ll MOD=998244353;

#define endl '\n'
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
ll INF = 2000000000000000001;
long double EPS = 1e-9;
ll power(ll a, ll n, ll md){if(n==0){return 1;}else{ll res=power(a,n/2,md);res=(res*res)%md;if(n%2!=0){res=(res*a)%md;}return res;}}
random_device rndm;
mt19937 grndm(rndm());
void mix(ll* a, ll* b){shuffle(a,b,grndm);}

const ll MX = 305;

ll dp[MX][MX][MX], k, n, ones;

string s;
vector<ll> zeros;

ll solve(ll idx, ll carry, ll left) {
	if(carry < 0 || left < 0) {
		return 0;
	}
	if(idx == -1) {
		return carry == 0;
	}
	if(dp[idx][carry][left] != -1) {
		return dp[idx][carry][left];
	}
	ll ans = 0;
	for(ll i = 0; i <= zeros[idx] + carry; i++) {
		ll now = zeros[idx] + carry - i;
		ll used = max((ll)0, zeros[idx] - i);
		ans = (ans + solve(idx - 1, now, left - used)) % MOD;
	}
	return dp[idx][carry][left] = ans;
}

int main(){
	fast_cin();
	// freopen("input.in","r",stdin);
	// freopen("output.out","w",stdout);
	cin >> s >> k;	
	memset(dp, -1, sizeof(dp));
	n = s.size();
	k = min(k, n);
	for(auto c: s) {
		ones += (c == '1');
	}
	ll i = 0, z = 0;
	while(i < n) {
		while(i < n && s[i] == '1') {
			i++; z++;
		}
		zeros.push_back(z);
		z = 0;
		i++;
	}
	cout << solve(zeros.size() - 1, 0, k) << endl;
	return 0;
}

Measured memory_bytes: 225348
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
using namespace std;
using ll = long long;
using P = pair<int,int>;


int main(){
   int n;
   cin>>n;
   vector<int> x[15], y[15];
   rep(i, n){
      int a;
      cin>>a;
      rep(j, a){
         int ix, iy;
         cin>>ix>>iy; ix--;
         x[i].push_back(ix);
         y[i].push_back(iy);
      }
   }

#define isPure(k) ((co>>(k))&1)
   int mx=0;
   for(int co=0; co<(1<<n); co++){
      bool ok=true;
      int cnt=0;
      rep(i, n) if(isPure(i)){
         rep(j, x[i].size()) if(y[i][j] != isPure(x[i][j])){
            ok=false;
         }
         cnt++;
      }
      if(ok) mx=max(mx, cnt);
   }

   cout<<mx<<endl;
   return 0;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
const long long mod = 1e9+7;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
const int ddx[4] = {1,1,-1, -1};
const int ddy[4] = {1,-1,-1,1};
//////////////////////////////////

int main(){
  int n; cin >> n;
  string s, t; cin >> s >> t;
  for(int i=0; i<n; i++) {
    cout << s[i] << t[i];
  }
  cout << endl;

  return 0;
}

// EOF


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0;i < (int)n;i++)
#define repb(i, n) for(int i = (int)n;i >= 0;i--)
#define reps(i, m, n) for(int i = (int)m;i < (int)n;i++)
#define repsb(i, m, n) for(int i = (int)m;i >= (int)n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long ll;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
using namespace std;
int main(int argc, char const *argv[]) {
  int a,b;
  cin>>a>>b;
  if(a>8||b>8) {
    cout << ":(" << '\n';
    return 0;
  }
  else{
    cout << "Yay!" << '\n';
  }

  return 0;
}


Measured memory_bytes: 256
fn main() {
    let n = read::<usize>();
    let ps = read_vec::<u32>();
    let mut qs = vec![false; ps.len()];

    for (i, &p) in ps.iter().enumerate() {
        if i + 1 == p as usize {
            qs[i] = true;
        }
    }

    let mut count = 0;
    let mut i = 0;
    let len = qs.len();
    while i < len {
        if i < len - 1 {
            if qs[i] && qs[i + 1] {
                count += 1;
                i += 2;
            } else if qs[i] && !qs[i + 1] {
                count += 1;
                i += 2;
            } else {
                i += 1;
            }
        } else {
            if qs[i] {
                count += 1;
            }
            i += 1;
        }
    }

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

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#include<stdio.h>
#define MAXS 100000
int main(){
  int n,q,i,s[MAXS],t,c=0;
  int left,right,mid;
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&s[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&t);
    left=0;
    right=n;
    while (left<right){
      mid=(left+right)/2;
      if(s[mid]==t){
	c++;
	break;
      }else if(t<s[mid])
	right=mid;
      else left=mid+1;
    }
  }
  printf("%d\n",c);
  return 0;
}



Measured memory_bytes: 2124
#include <iostream>
#include <stdio.h>

#include <vector>
#include <cctype>
#include <cstring>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
    int studentNumber;
    int score;


    while (1) {

        vector<int> scoreS;

        cin >> studentNumber;

        if (studentNumber == 0) {
            break;
        }
        for (int i = 0; i < studentNumber;i++) {
        cin >> score;
        scoreS.push_back(score);
        }
        
        double sum = 0;

        for (int i = 0; i < scoreS.size(); i++) {
            sum = sum + scoreS[i];
        }

        double ave = sum / studentNumber;

        double div = 0;

        for (int i = 0; i < scoreS.size(); i++) {
            div = div + (scoreS[i]-ave)*(scoreS[i] - ave);
        }

        printf("%lf\n", sqrt(div/studentNumber));

    }

    return 0;
}



Measured memory_bytes: 3244
/*
 *  Author :: Kattu37
 */

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

#define ll long long
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define sortallr(x) sort(allr(x))
#define PI 3.1415926535897932384626
#define mod 1000000007

typedef pair<int, int>  pii;
typedef pair<ll, ll>  pll;
typedef vector<int>   vi;
typedef vector<ll>    vl;
typedef vector<pii>   vpii;
typedef vector<pll>   vpl;
typedef vector<vi>    vvi;
typedef vector<vl>    vvl;

void solve()
{
	ll n, m, k;
	cin >> n >> m >> k;
	vector<ll> a(n), b(m);

	for (auto &it : a)
		cin >> it;
	for (auto &it : b)
		cin >> it;

	vector<ll> asum(n), bsum(m);
	asum[0] = a[0];
	bsum[0] = b[0];

	for (int i = 1; i < n; i++)
	{
		asum[i] = asum[i - 1] + a[i];
	}

	for (int i = 1; i < m; i++)
	{
		bsum[i] = bsum[i - 1] + b[i];
	}

	ll index = upper_bound(asum.begin(), asum.end(), k) - asum.begin();
	index--;

	ll mi = 0;

	if (index < 0)
	{
		ll index2 = upper_bound(bsum.begin(), bsum.end(), k) - bsum.begin();
		index2--;
		mi = max(mi, index2 + 1);
		cout << mi << "\n";
		return;
	}

	while (index >= 0)
	{
		ll tot = k - asum[index];
		ll index2 = upper_bound(bsum.begin(), bsum.end(), tot) - bsum.begin();
		index2--;

		mi = max(mi, index + index2 + 2);
		//cout << mi << " " << index << " " << index2 << "\n";
		index--;
	}

	ll index3 = upper_bound(bsum.begin(), bsum.end(), k) - bsum.begin();
	index3--;
	mi = max(mi, index3 + 1);
	cout << mi << "\n";
}

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

	int t = 1;
	//cin >> t;
	while (t--)
	{
		solve();
	}

	return 0;
}


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

int main(){
  int n,m; cin>>n>>m;
  vector<int> num(n+1,0);
  for(int i=0;i<m;i++){
    int x,y; cin>>x>>y;
    num[x]++; num[y]++;
  }
  for(int i=0;i<=n;i++){
    if(num[i]%2==1){
      cout<<"NO"<<endl;
      return 0;
    }
  }
  cout<<"YES"<<endl;
}

Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main() {
    int a,b;

    cin >> a >> b;

    if (a > b) {
        cout << "a > b";
    } else if (a < b) {
        cout << "a < b";
    } else {
        cout << "a == b";
    }

    cout << endl;

    return 0;
}

Measured memory_bytes: 1156
import fractions
from functools import reduce
N = int(input())
T = [int(input()) for i in range(N)]

def lcm_base(x,y):
	return (x*y)//(fractions.gcd(x,y))

def lcm_list(numbers):
	return reduce(lcm_base, numbers,1)

print(lcm_list(T))

Measured memory_bytes: 5048
using System;
using System.IO;
using System.Linq;

namespace ABC127A
{
    class Program
    {
        static void Main(string[] args)
        {
            if (args.Length > 0)
            {
                Console.SetIn(new StreamReader(args[0]));
            }

            new Program().Solve();
        }

        void Solve()
        {
            var temp = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var A = temp[0];
            var B = temp[1];
            var price = 0;

            if (A >= 13)
            {
                price = B;
            }
            else if (A >= 6)
            {
                price = B / 2;
            }
            else
            {
                price = 0;
            }

            Console.WriteLine(price);
        }
    }
}


Measured memory_bytes: 11348
#include <stdio.h>

int main() {
	int r,c;
	int i,j;

	while (1) {
		scanf("%d%d",&r,&c);
		if (r == 0 && c == 0) {
			break;
		}
		for (i = 0;i != r;++i) {
			for (j = 0;j != c;++j) {
				printf(i == 0 || i == r-1 || j == 0 || j == c-1 ? "#" : ".");
			}
			printf("\n");
		}
		printf("\n");
	}	
	return 0;
}

Measured memory_bytes: 588
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n, ans = 1;
    cin >> n;
    vector<int> d(n); 
    for (int i = 0; i < n; i++)
        cin >> d.at(i);
    sort(d.begin(), d.end());
    for (int i = 0; i < n-1; i++) {
        if (d.at(i) < d.at(i+1))
            ans += 1;
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#define MN 200000
using namespace std;
inline 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;
}
char st[MN+5];
int f[MN+5],F[MN+5],g[MN+5],from[MN+5],dep[MN+5],n,head[MN+5],tot=0,mnok[MN+5];
int cnt=0,mx[MN+5],H[MN+5],h[MN+5],mn[MN+5];
struct edge{int to,next;}e[MN*2+5];
inline void ins(int f,int t)
{
	e[++cnt]=(edge){t,head[f]};head[f]=cnt;
	e[++cnt]=(edge){f,head[t]};head[t]=cnt;
}
void Pre(int x,int fa)
{
	f[x]=F[x]=dep[x];H[x]=st[x]=='1';mnok[x]=int(1e9);
	for(int i=head[x];i;i=e[i].next)
		if(e[i].to!=fa)
		{
			dep[e[i].to]=dep[x]+1;
			Pre(e[i].to,x);
			if(f[e[i].to]>f[x]) F[x]=f[x],f[x]=f[e[i].to],from[x]=e[i].to;
			else F[x]=max(F[x],f[e[i].to]);
			H[x]+=H[e[i].to];
			if(H[e[i].to]) mnok[x]=min(mnok[x],f[e[i].to]);
		}
}
void Dfs(int x,int fa)
{
	if(st[x]=='0') mn[x]=min(mnok[x]-dep[x],h[x]);
	mx[x]=min(max(f[x]-dep[x],g[x])-1,f[x]-dep[x]+1);
	for(int i=head[x];i;i=e[i].next)
		if(e[i].to!=fa)
		{
			int dis2=max((e[i].to==from[x]?F[x]:f[x])-dep[x],g[x]);
			mx[x]=min(mx[x],dis2+1);
			g[e[i].to]=dis2+1;
			h[e[i].to]=tot>H[e[i].to]?dis2+1:int(1e9);
			Dfs(e[i].to,x);
		}
}
long long ans=1;
int main()
{
	n=read();
	for(int i=1;i<n;++i) ins(read(),read());
	scanf("%s",st+1);
	for(int i=1;i<=n;++i) tot+=st[i]=='1';
	Pre(1,0);h[1]=int(1e9);Dfs(1,0);
	for(int i=1;i<=n;++i) ans+=max(0,mx[i]-mn[i]+1);
	printf("%lld\n",ans);
	return 0;
}



Measured memory_bytes: 19328
use proconio::{input, marker::Chars};

fn main() {
    input! {
        s: Chars,
        t: Chars,
    }

    let n = s.len() - t.len();
    let mut r = t.len();
    for i in 0..=n {
        let mut v = 0;
        for j in 0..t.len() {
            if s[i + j] != t[j] {
                v += 1;
            }
        }
        r = r.min(v);
    }
    println!("{}", r);
}


Measured memory_bytes: 2180
#include <iostream>
#include <cmath>
using namespace std;
int main(){
    int n;
    cin >> n;
    double x;
    while(n!=0){
        x = (double) pow(n,0.5);
        if((int)x*(int)x==n){
            cout << n << endl;
            return 0;
        }
        n--;
    }
    return 0;
}

Measured memory_bytes: 4092
t[80000],j,c;main(i){for(;++i<256;)for(j=i;t[j+=i]=j<4e4;);for(;j=scanf("%d",&i)*i/2;c=!printf("%d\n",c))for(;j>1;)c+=!t[j]&!t[i-j--];}

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

int main()
{
    int N, K;
    cin >> N >> K;
    int res = 1;
    for(int i = 0; i < N; ++i) res = min(res + K, res * 2);
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Security.Cryptography.X509Certificates;
using System.Text.RegularExpressions;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var f = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var N = f[0];
            var X = f[1];
            int minMaterial = int.MaxValue;
            for (int i = 0; i < N; i++)
            {
                var material = int.Parse(Console.ReadLine());
                X -= material;
                if (minMaterial >= material)
                {
                    minMaterial = material;
                }
            }

            var countMinMaterial = X / minMaterial;
            Console.WriteLine(N + countMinMaterial);
        }
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

bool ismm(int x){
    if(1<=x && x <= 12) return true;
    return false;
}
bool isyy(int x){
    if(x != 0) return true;
    return false;
}
bool isover(int x){
    if(x > 12) return true;
    if(x==0) return true;
    return false;
}

int main(){
    string s; cin>>s;
    int x = stoi(s);
    int x1 = x/100;
    int x2 = x%100;
    string ans = "";
    if(ismm(x1)){
        if(ismm(x2)){
            ans = "AMBIGUOUS";
        } else {
            ans = "MMYY";
        }
    } else {
        if(ismm(x2)){
            ans = "YYMM";
        }
        else {
            ans = "NA";
        }
    }
    cout << ans <<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define int ll
#define pb push_back
#define setbits(x)          __builtin_popcountll(x)
#define endl "\n"
typedef long long ll;
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n,d;
cin>>n>>d;
if(n>=10)
{
    cout<<d<<endl;
    return 0;
}
int ans=100*(10-n)+d;
cout<<ans<<endl;
    return 0;
}

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

using namespace std;

//#define FILE_IO

typedef pair<int, int> pii;

int N, K, xr;
int a[100005], b[100005];
int v[100005], w[100005];
vector <int> edg[100005];
vector <pii> edges;
multiset <int> mst;
int grd[100005];
int f[100005];

void answer(int x) { printf("%d\n", x); exit(0); }

void DFS(int nod)
{
    if(f[nod])  return;
    f[nod] = 1;
    for(auto x: edg[nod])
        DFS(x);
}

class Normalizator
{
public:
    map<int, int> mp;
    vector <int> ord;

    void add(int x)
    {
        if(mp.count(x)) return;
        mp[x];
        ord.push_back(x);
    }

    void normalize()
    {
        sort(ord.begin(), ord.end());
        for(int i = 0; i < ord.size(); i++)
            mp[ ord[i] ] = i + 1;
    }

    int get(int x) { return mp[x]; }
}nrm;

int main()
{
    #ifdef FILE_IO
    freopen("1.in", "r", stdin);
    freopen("1.out", "w", stdout);
    #endif

    scanf("%d", &N);
    for(int i = 1; i <= N; i++)
    {
        scanf("%d", &a[i]);
        v[i] = a[i];
        xr ^= a[i];
    }
    for(int i = 1; i <= N; i++)
    {
        scanf("%d", &b[i]);
        w[i] = b[i];
    }

    v[N + 1] = xr;
    sort(v + 1, v + N + 2);
    sort(w + 1, w + N + 1);
    v[N + 2] = 1 << 30;

    int cnt = 0;
    for(int i = 1; i <= N; i++)
    {
        if(w[i] != v[i + cnt])
        {
            cnt++;
            if(w[i] != v[i + cnt])  cnt++;
            if(cnt > 1) answer(-1);
        }
    }

    nrm.add(xr);
    for(int i = 1; i <= N; i++) nrm.add(a[i]);

    nrm.normalize();

    xr = nrm.get(xr);
    for(int i = 1; i <= N; i++) a[i] = nrm.get(a[i]);
    for(int i = 1; i <= N; i++) b[i] = nrm.get(b[i]);

    mst.insert(xr);
    for(int i = 1; i <= N; i++)
    {
        if(a[i] == b[i])    continue;
        edges.push_back({b[i], a[i]});
        mst.insert(a[i]);
    }

    for(int i = 1; i <= N; i++)
    {
        if(a[i] == b[i])    continue;
        mst.erase(mst.find(b[i]));
    }

    int str = xr;
    int lst = *(mst.begin());

    edges.push_back({lst, str});

    for(auto e: edges)
    {
        grd[e.first]++;
        grd[e.second]--;
        edg[e.first].push_back(e.second);
    }

    cnt = edges.size();
    for(int i = 1; i <= nrm.ord.size(); i++)
        if(grd[i] > 0)  cnt += grd[i];

    for(int i = 1; i <= nrm.ord.size(); i++)
        if(!f[i] && !edg[i].empty())
        {
            cnt++;
            DFS(i);
        }
    cnt--;

    printf("%d\n", cnt - 1);

    return 0;
}


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

int
gcd ( int a, int b )
{
  int c;
  while ( a != 0 ) {
     c = a; a = b%a;  b = c;
  }
  return b;
}

int cmpfunc(const void *a, const void *b){
    return *(int*)a - *(int*)b;
}

int main(void){
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    int g;
    g=gcd(a,b);
    if(c%g==0) printf("YES\n");
    else printf("NO\n");
    return 0;
}


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;

class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    Scanner cin;


    void calc()
    {
        cin = new Scanner();
        char[] S = cin.next().ToCharArray();
        char[] T = cin.next().ToCharArray();
        int[] s=new int[26];
        int[] t=new int[26];
        for(int i=0;i<S.Length;i++)
        {
            s[S[i] - 'a']++;
            t[T[i] - 'a']++;
        }
        Array.Sort(s);
        Array.Sort(t);
        bool ans=true;
        for(int i=0;i<26;i++)
        {
          if(s[i]!=t[i])ans=false;
        }
       if(ans==false)Console.WriteLine("No");
       else Console.WriteLine("Yes");
        
    }


}



class Scanner
{
    string[] s;
    int i;

    char[] cs = 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(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(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 nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(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 nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

Measured memory_bytes: 14816
#include <stdio.h>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <math.h>
#include <queue>
#include <string.h>
#include <stdlib.h>
#include <map>
#include <set>

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

const long long INF = 1LL << 60;

using namespace std;
typedef unsigned long long ull;
typedef  long long ll;

ll power(ll x, ll n, ll p) {
	if (n == 0) {
		return 1;
	}
	if (n % 2 == 0) {
		return power(x * x % p, n / 2, p) % p;
	}
	else {
		return x * power(x, n - 1, p) % p;
	}
}

int main()
{
	ll m, n;
	scanf("%lld%lld", &m, &n);
	ll p = 1000000007;
	cout << power(m, n, p) << endl;
	return 0;
}


Measured memory_bytes: 3236
// in the name if Allah
// YA Ali!
#include <bits/stdc++.h>

using namespace std;

typedef long long ll ;

const ll INF = 1<<30 ;
const ll N= 1e6 ;

#define f first
#define s second

ll n , a[N] , ans = 0  ;

int main()
{
std::ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n ;
for(int i = 1 ; i <= n ; i ++){
    cin >> a[i] ;
    ans += (i != a[i]) ;
}
if(ans <= 2)cout << "YES" ;
else cout << "NO" ;

    return 0;
}
 /*
              _     _   __
        /_\  (_    (_)  __)
       /   \  _) . (_) (__
 */


Measured memory_bytes: 256
N, K = map(int, input().split())
S = input()
A = ""

for i in range(N):
    if i == K-1:
        if S[K-1] == "A":
            A += "a"
        elif S[K-1] == "B":
            A += "b"
        else:
            A += "c"
    else:
        A += S[i]
    
print(A)

Measured memory_bytes: 38256
//atcoder knapsack 1
#include<bits/stdc++.h>
#define N_ 101000000
using namespace std;
long long D[N_];

int main()
{
	int a,b,n,W;
	cin>>n>>W;
	for(int i=1;i<=n;i++)
	{
		cin>>a>>b;
		for(int j=W;j>=0;j--)
			D[j+a]=max(D[j+a],D[j]+b);
	}
	long long r=0;
	for(int i=0;i<=W;i++)
		r=max(r,D[i]);
	cout<<r<<endl;
	return 0;
}

Measured memory_bytes: 1792
import java.io.*;
import java.util.*;

public class Main {
    public static PrintWriter out;
    public static FastScanner in;

    private void solve(){
        String a = in.next();
        String b = in.next();

        if(a.charAt(0) == b.charAt(0)|| a.charAt(0) == b.charAt(0)){
            out.print('H');
            return;
        }

        out.print('D');
    }

    private void runIO() {
        in = new FastScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));
        solve();
        out.close();
    }
    private static class FastScanner {
        BufferedReader bufferedReader;
        StringTokenizer stringTokenizer;

        private FastScanner() {
            bufferedReader = new BufferedReader(new InputStreamReader(System.in));
        }

        private String next() {
            if (stringTokenizer == null || !stringTokenizer.hasMoreElements()) {
                try {
                    stringTokenizer = new StringTokenizer(bufferedReader.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return stringTokenizer.nextToken();
        }

        private int nextInt() {
            return Integer.parseInt(next());
        }

        private long nextLong() {
            return Long.parseLong(next());
        }

        private String nextLine() {
            String ret = "";
            try {
                ret = bufferedReader.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return ret;
        }
    }

    public static void main(String[] args) {
        new Main().runIO();
    }
}


Measured memory_bytes: 21076
#include <bits/stdc++.h>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
using ll = long long;
using ld = long double;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

struct UnionFind {
    vector<ll> par; // par[i]:iの親の番号  (例) par[3] = 2 : 3の親が2
    vector<ll> rank; // 木の深さ
    vector<ll> siz; // 集合のサイズを表す配列

    UnionFind(ll N) : par(N), rank(N), siz(N) { //最初は全てが根であるとして初期化
        for(ll i = 0; i < N; i++){
            par[i] = i;
            rank[i] = 0;
            siz[i] = 1;
        }
    }

    ll root(ll x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(ll x, ll y) { // xとyの木を併合
        x = root(x);
        y = root(y);
        if (x == y) return; //xとyの根が同じ(=同じ木にある)時はそのまま

        //if(rank[x] < rank[y]){
        if(siz[x] < siz[y]){
            //par[x] = y;
            swap(x, y);
        }
        //else{
        siz[x] += siz[y];
        par[y] = x;
        if(rank[x] == rank[y]) rank[x]++;
        //}
    }

    bool same(ll x, ll y) { // 2つのデータx, yが属する木が同じならtrueを返す
        ll rx = root(x);
        ll ry = root(y);
        return rx == ry;
    }

    ll size(ll x){ // 集合のサイズ
        return siz[root(x)];
    }
};

int main(void)
{
    ll N, M, i, A[100001], B[100001], ans[100001];

    cin >> N >> M;

    for(i=1; i<=M; i++){
        cin >> A[i] >> B[i];
    }

    UnionFind tree(N+1);

    for(i=M; i>=1; i--){
        if(i==M){
            ans[i] = N*(N-1)/2;
        }

        else{
            if(tree.root(A[i+1])==tree.root(B[i+1])){
                ans[i] = ans[i+1];
            }
            else{
                ans[i] = ans[i+1]-tree.size(A[i+1])*tree.size(B[i+1]);
            }

            tree.unite(A[i+1], B[i+1]);
        }
    }

    for(i=1; i<=M; i++){
        cout << ans[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 6016
def main():
    s = list(input())
    k = int(input())
    lst = []
    cnt = 1
    flg = 0
    ans = 0
    prev = s[0]
    for i in range(1, len(s)):
        if prev == s[i]:
            cnt += 1
        else:
            lst.append(cnt)
            cnt = 1
            prev = s[i]
            flg = 1
    lst.append(cnt)
    if len(lst) == 1:
        ans = len(s) * k // 2
    else:
        ans += sum(list(map(lambda x: x // 2, lst[1:len(lst)-1]))) * k
        # for l in lst[1: len(lst) - 1]:
        #     ans += l // 2 * k
        if s[-1] == s[0]:
            ans += (lst[0] + lst[-1]) // 2 * (k - 1)
            ans += lst[0] // 2 + lst[-1] // 2
        else:
            ans += (lst[0] // 2 + lst[-1] // 2) * k
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9116
//بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ
#include <bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    int x[n], a[n];
    for(int i = 0; i < n; i++) cin >> x[i], a[i] = x[i];
    sort(a, a+n);
    for(int i : x){
        if(i <= a[n/2-1]) cout << a[n/2] << endl;
        else if(i >= a[n/2]) cout << a[n/2-1] << endl;
    }
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
#define fore(i, a, b) for (int i = a, to = b; i < to; i++)
#define all(v) v.begin(), v.end()
#define SZ(v) (int)v.size()
#define pb push_back
typedef long long Long;
typedef pair<int, int> Pair;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  Long h,a;cin>>h>>a;
  cout<<(h+a-1)/a<<endl;

  return 0;
}

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

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

    int d[300000];
    for(int i=0;i<N;i++){
        cin >> d[i];
    }
    int D = 0;

    for(int i=0;i<N-1;i++){
        D = max(D,d[i]);

        if(D<10){
            cout << "no" << endl;
            return 0;
        }

        D -=10;
    }
    D = 0;
    
    for(int i=N-1;i>0;i--){
        D = max(D,d[i]);

        if(D<10){
            cout << "no" <<endl;
            return 0;
            }
        D -= 10;
    }
    cout << "yes" << endl;

    return 0;
}


Measured memory_bytes: 4248
import itertools
N,K=map(int,input().split())
d=[]
A=[]
for i in range(1,K+1):
    d.append(int(input()))
    A.append(list((map(int,input().split()))))
A=list(itertools.chain.from_iterable(A))
print(N-len(set(A)))

Measured memory_bytes: 9360
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

ll f(ll n, ll x) {
  if(n == 0) return 1;
  ll d = pow(2, n + 1) - 3;
  ll a = pow(2, n) - 1;
  if(x <= 1)
    return 0;
  else if(x <= d + 1)
    return f(n - 1, x - 1);
  else if(x == d + 2)
    return a + 1;
  else if(x <= d * 2 + 1)
    return a + 1 + f(n - 1, x - d - 2);
  else
    return a * 2 + 1;
}

int main() {
  ll n, x;
  cin >> n >> x;
  cout << f(n, x) << endl;
}

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

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

    int n;
    cin >> n;
    int s = n * n * n;
    cout << s;
    return 0;
}


Measured memory_bytes: 3564
/*input
10 100
7 10 4 5 9 3 6 8 2 1
*/

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	int N, T;

	cin >> N >> T;

	vector<int> A(N);

	for(int i=0;i<N;i++){
		cin >> A[i];
	}

	// for(auto a:A){
	// 	cout << a << " ";
	// }
	// cout << endl;

	vector<int> P(N-1);

	int min_value = A[0];
	int profit_value = 0;
	int profit_count = 0;

	for(int i=1;i<N;i++){
		if(A[i] < min_value) min_value = A[i];
		if(A[i] - min_value > profit_value){
			profit_value = A[i] - min_value;
			profit_count = 1;
		}else if(A[i] - min_value == profit_value){
			profit_count++;
		}
	}

	// cout << "min_value   : " << min_value << endl;
	// cout << "profit_value: " << profit_value << endl;
	// cout << "profit_count: " << profit_count << endl;

	cout << profit_count << endl;

	return 0;
}


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

typedef long long ll;
typedef long double ld;

int main()
{
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
#endif
	int n, a, b;
	cin >> n >> a >> b;
	if (n == 1 && a == b)
	{
		cout << 1 << endl;
		return 0;
	}
	if (a > b || n == 1)
	{
		cout << 0 << endl;
		return 0;
	}
	ll minVal = 1LL * (n - 1) * a + b;
	ll maxVal = 1LL * (n - 1) * b + a;
	cout << maxVal - minVal + 1 << endl;
}



Measured memory_bytes: 256
N = int(input())
W = list(map(int, input().split()))
ans = abs(W[0] - sum(W[1:]))
for t in range(1, N-1):
  dif = abs(sum(W[:t+1]) - sum(W[t+1:]))
  if dif < ans:
    ans = dif

print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
using namespace std;
int main() {
    int y, m, d;
    scanf("%d/%d/%d", &y, &m, &d);
    if (y == 2019) {
        if (m > 4) {
            cout << "TBD" << endl;
        } else {
            cout << "Heisei" << endl;
        }
    } else if (y > 2019) {
        cout << "TBD" << endl;
    } else {
        cout << "Heisei" << endl;
    }
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

bool check(ll X, const vector<ll>& v){
  if(v.size()%2!= 0){
    vector<ll> a;
    rep(i,v.size()){
      if(v[i] <= X) a.push_back(v[i]);
    }
    if(a.size() >= v.size()/2+1) return true;
    else return false;
  }else{
    vector<ll> a, b;
    rep(i,v.size()){
      if(v[i] <= X) a.push_back(v[i]);
      else b.push_back(v[i]);
    }
    sort(ALLOF(a));
    sort(ALLOF(b));
    if(a.size() == 0) return false;
    else if(b.size() == 0) return true;
    else{
      if(a.size() == b.size()){
        if(a[a.size()-1] <= 2 * X - b[0]) return true;
        return false;
      }
      else if(a.size() > b.size()){
        return true;
      }
      else{
        return false;
      }
    }
  }
}

bool check2(ll X, const vector<ll>& v){
  if(v.size()%2!= 0){
    vector<ll> b;
    rep(i,v.size()){
      if(v[i] >= X) b.push_back(v[i]);
    }
    if(b.size() >= v.size()/2+1) return true;
    else return false;
  }else{
    vector<ll> a, b;
    rep(i,v.size()){
      if(v[i] >= X) b.push_back(v[i]);
      else a.push_back(v[i]);
    }
    sort(ALLOF(a));
    sort(ALLOF(b));
    if(a.size() == 0) return true;
    else if(b.size() == 0) return false;
    else{
      if(a.size() == b.size()){
        if(2 * X - a[a.size()-1] <= b[0]) return true;
        return false;
      }
      else if(a.size() < b.size()){
        return true;
      }
      else{
        return false;
      }
    }
  }
}

int main(){
  int N;
  cin >> N;
  vector<ll> v, w;
  rep(i,N){
    ll a, b;
    cin >> a >> b;
    if(N%2!=0){
      v.push_back(a);
      w.push_back(b);
    }else{
      v.push_back(2*a);
      w.push_back(2*b);
    }
  }


  ll x = -1, y = -1;
  {
    ll lb = 0, ub = (ll)1e11;
    while(ub-lb>1){
      ll mid = lb + (ub-lb)/2;

      if(!check(mid, v)) lb = mid;
      else ub = mid;
    }
    cerr << ub << endl;
    x = ub;
  }
  {
    ll lb = 0, ub = (ll)1e11;
    while(ub-lb>1){
      ll mid = lb + (ub-lb)/2;

      if(check2(mid, w)) lb = mid;
      else ub = mid;
    }
    cerr << ub << endl;
    y = ub;
  }

  cout << y - x << endl;
  
  return 0;
}


Measured memory_bytes: 10244
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		boolean key = true;
		for (int i = 0; i < N; i++) {
			int num = sc.nextInt();
			if (num%2 == 0 && num%3 != 0 && num%5 != 0) key = false;
		}
		System.out.println(key?"APPROVED":"DENIED");
	}
}

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

int main() {
  int N;
  cin >> N;
  vector<int> P(N);
  for(int i = 0; i < N; i++) {
    cin >> P.at(i);
  }
  int cnt = 0;
  int mini;
  for(int i = 0; i < N; i++) {
    if(i==0) {
      mini = P.at(i);
    }
    else {
      mini = min(mini,P.at(i));
    }
    if(P.at(i) <= mini) {
      cnt++;
    }
  }
  cout << cnt << endl;
}


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

int main(){
  int W, a, b;
  cin >> W >> a >> b;

  if (a + W < b){
    cout << b - (a + W) << endl;
  }
  else if (a + W == b)
  {
    cout << 0 << endl;
  }
  else if (b + W < a)
  {
    cout << a - (b + W) << endl;
  }
  else
  {
    cout << 0 << endl;
  }
  
  
  
}

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

int main(){
	string w[1000];
	int max=0,maxc=0,maxi=0,idx=0;
	for(int i=0;cin>>w[i];i++){
		if(w[i].size()>w[max].size()) max=i;
		idx++;
	}for(int i=0;i<idx;i++){
		int cnt=0;
		for(int j=0;j<idx;j++){
			if(w[i]==w[j]) cnt++;
		}if(cnt>maxc){
			maxi=i;
			maxc=cnt;
		}
	}cout<<w[maxi]<<" "<<w[max]<<endl;
	return 0;
}

Measured memory_bytes: 1196
#include <iostream>

using namespace std;

int main() {
	int x,y,z,count=0;

	cin>>x>>y>>z;

	if(x==5) {
		count++;
	} else if(x==7) {
		count++;
	}

	if(y==5) {
		count++;
	} else if(y==7) {
		count++;
	}

	if(z==5) {
		count++;
	} else if(z==7) {
		count++;
	}

	if(count==3 && x+y+z==17) {
		cout<<"YES"<<endl;
	} else {
		cout<<"NO"<<endl;
	}

	return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}
using namespace std;

int main() {
    int a;
    cin >> a;
    vector<vector<int>> z(10, vector<int>(10));
    for (int i = 1; i < a + 1; i++) {
        int k = i;
        while (k >= 10) {
            k /= 10;
        }
        z.at(k).at(i % 10)++;
    }
    int ans = 0;
    for (int i = 1; i < 10; i++) {
        for (int j = 1; j < 10; j++) {
            ans += z.at(i).at(j) * z.at(j).at(i);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
eval"A,B,C,D,E,F="+`tr \\  ,`;d={};f=->a,b=0{a*100+b>F||a*E<b||d[[a*100+b,b]]||=(f[a+A,b];f[a+B,b];f[a,b+C];f[a,b+D];b.quo a)};f[A];f[B];p *d.max_by{|_,v|v}[0]

Measured memory_bytes: 4748
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int N;
    cin>>N;
    vector<double> p(N);
    for (double &t: p)
        cin>>t;
    vector<vector<double>> T(N, vector<double>(N+1));
    T[0][0] = 1 - p[0];
    T[0][1] = p[0];
    for (int i=1; i<N; i++)
    for (int j=0; j<=i; j++)
        T[i][j] += T[i-1][j] * (1-p[i]),
        T[i][j+1] += T[i-1][j] * p[i];
    double ans = 0;
    for (int i=N/2+1; i<=N; i++)
        ans += T[N-1][i];
    printf("%.16f\n", ans);
}


Measured memory_bytes: 70656
x,y=map(int,input().split())
a=[0 for i in range(4)]
a[0]=y-x
a[1]=y+x+1
a[2]=-y-x+1
a[3]=-y+x+2
b=[]
for i in range(4):
    if a[i]>0:
        b.append(a[i])
print(min(b))


Measured memory_bytes: 3060
/*

    author : s@if

*/

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

#define 		NIL 			-1
#define		 	fi	 		    first
#define 		sec 			second
#define 		MAX 			INT_MAX
#define			INF 			99999999
#define 		ll 			    long long
#define 		PI 			    acos(-1.0)
#define			MOD 			1000000007
#define 		PLL 			pair<ll,ll>
#define 		PII			    pair<int,int>
#define 		ull 			unsigned long long
#define 		For(i,a,b) 		for(int i=a;i<=(int)b;i++)


bool Check(int N , int pos)	{	return (bool) (N & (1<<pos));}
int Set(int N, int pos) {	return N = N | (1<<pos);}

int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};
int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};
int hr[]={-2,-2,-1,+1,+2,+2,-1,+1};
int hc[]={+1,-1,+2,+2,-1,+1,-2,-2};
int dx[]={+1,-1,+0,+0};
int dy[]={+0,+0,+1,-1};

const int MAXN = (int)1e5+9;

int main()
{
/*	freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);  */

    int i,j,k,l,m,n,p,q,x,y,u,v,r,tc,t;

    cin>>n>>m;
    
    if(n<=5)
        cout<<0<<endl;
    else if(n<=12)
        cout<<m/2<<endl;
    else
        cout<<m<<endl;

    return 0;
}


Measured memory_bytes: 256
//g++ -std=c++14 test.cpp -o test.out
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
using namespace std;

int N,K;
string S;

int ans = 0;

void solve(){
	vector<int> segment;//segmentには　1の数、0の数、1の数、0の数......1の数　と記録する
	if(S[0]=='0') segment.push_back(0);
	int left_index = 0;
	for(int right_index=0;right_index<N;){
		while(right_index<N){
			if(S[left_index]==S[right_index]) right_index++;
			else break;
		}
		segment.push_back(right_index-left_index);
		left_index = right_index;
	}
	if(S[N-1]=='0') segment.push_back(0);

	// for(int i=0;i<segment.size();i++){
	// 	cout << segment[i] << " ";
	// }
	//cout << endl;

	int sumof1 = segment[0];
	for(int i=1;i<=K;i++){
		if(2*i-1>=segment.size()){
			ans = sumof1;
			return;
		}
		sumof1 += (segment[2*i-1]+segment[2*i]);
	}
	ans = sumof1;
	for(int i=2*K+1;i<segment.size();i+=2){
		sumof1 += (segment[i]+segment[i+1]);
		sumof1 -= (segment[i-(2*K+1)]+segment[i+1-(2*K+1)]);
		if(ans<sumof1) ans = sumof1;
	}
}
 
int main(){
	cin >> N >>K;
	cin >> S;
 
	solve();

	cout << ans << endl;
	return 0;
}


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	int N=in();
	string S=in<string>();
	int M=S.size();
	REP(i,M){
		S[i] -= 'A';
		S[i] += N;
		S[i] %= 26;
		S[i] += 'A';
	}
	
	out(S);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define PA pair<int,int>
#define MA make_pair
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define POS(i) cout<<(i?"POSSIBLE":"IMPOSSIBLE")<<endl
#define Pos(i) cout<<(i?"Possible":"Impossible")<<endl
#define co(i) cout<<i<<endl
#define fcout cout<<fixed<<setprecision(10)
using namespace std;

const int INF=1e9+7;
const int MOD=1e9+7;

const int MAX_N=200001;
int par[MAX_N];
int rnk[MAX_N];

void init(int n){
    FOR(i,0,n){
        par[i]=i;
        rnk[i]=0;
    }
}

int find(int x){
    if(par[x]==x) return x;
    else return par[x]=find(par[x]);
}

void unite(int x,int y){
    x=find(x);
    y=find(y);
    if(x==y) return;
    if(rnk[x]<rnk[y]){
        par[x]=y;
    }else{
        par[y]=x;
        if(rnk[x]==rnk[y]) rnk[x]++;
    }
}

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

int main(){
	int n,k,l; cin>>n>>k>>l;
	init(n);
	FOR(i,0,k){
		int p,q; cin>>p>>q;
		unite(p-1,q-1);
	}
	int a[MAX_N],b[MAX_N];
	FOR(i,0,n){
		a[i]=find(i);
	}
	init(n);
	FOR(i,0,l){
		int r,s; cin>>r>>s;
		unite(r-1,s-1);
	}
	FOR(i,0,n){
		b[i]=find(i);
	}
	map<PA,int> m;
	FOR(i,0,n){
		PA p=PA(a[i],b[i]);
		auto itr=m.find(p);
		if(itr==m.end())
			m[p]=1;
		else{
			m[p]++;
		}
	}
	FOR(i,0,n){
		int ans=0;
		PA p=PA(a[i],b[i]);
		cout<<m[p]<<" ";
	}
}

Measured memory_bytes: 15104
N, W = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(N)]

dp = [[0] * (W + 1) for _ in range(N + 1)]

for i in range(1, N + 1):
    for j in range(W):
        w = wv[i - 1][0]
        v = wv[i - 1][1]
        if j + w <= W:
            dp[i][j + w] = max(dp[i][j + w], dp[i - 1][j] + v)
        dp[i][j] = max(dp[i][j], dp[i - 1][j])
        
print(max(dp[-1]))

Measured memory_bytes: 120812
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

template <class T>
T solve(int N, const vector<int>& A, const vector<int>& B) {
  vector<T> dp(N + 1);
  dp[0] = 0;
  for (int i = 1; i <= N; i++) {
    dp[i] = i;
    for (int j = 0; j < 3; j++) {
      if (A[j] <= i && B[j] > A[j]) {
        chmax(dp[i], dp[i - A[j]] + B[j]);
      }
    }
  }
  return dp[N];
}

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  ll N;
  while (cin >> N) {
    vector<int> A(3), B(3);
    for (int& x : A) cin >> x;
    for (int& x : B) cin >> x;
    int y1 = solve<int>(N, A, B);
    ll res = solve<ll>(y1, B, A);
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 195584