akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
    int l, r;
    cin >> l >> r;
    int ans = 2020;
    bool flg=0;
    for(int i=l; i<=r-1; i++){
        if(l==0) l++;
        if(l==2019||r==2019){
            ans=0;
            break;
        }
        for(int j=l+1; j<=r; j++){
            ans = min( ans, ((i%2019)*(j%2019)%2019) );
            if(ans==0){
                flg=1;
                break;
            }
        }
        if(flg) break;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3592
#include<stdio.h>
#include<string.h>
int main()
{
    int i, count=0;
    char ara1[4],ara[4];
    scanf("%s%s",ara1,ara);
    for(i=0;i<3;i++)
    {
        if(ara1[i]==ara[i])
            count++;
    }

    printf("%d\n",count);


    return 0;
}


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

int main(){
  string s;
  cin>>s;
  bool seven=false;
  for(int i=0;i<3;i++){
    if(s[i]=='7'){
      seven=true;
    }
  }
  if(seven){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}

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

long long k, n = 50, a[51];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> k;
	a[0] = 1;
	for(int i=1; i<n; ++i) a[i] = i;
	long long c = k / n;
	k %= n;
	for(int i=0; i<n; ++i) a[i] += c;
	for(int i=0; i<k; ++i){
		a[i] += n;
		for(int j=1; j<n; ++j)
			a[(i+j)%n] -= 1;
	}
	cout << n << "\n";
	for(int i=0; i<n; ++i) cout << a[i] << " \n"[i==n-1];
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define long int64_t

struct Solver {
	void solve() {
		string S, T;
		cin >> S >> T;

		int ans = 0;
		for( int i = 0; i < S.size(); ++i ) {
			if( S[i] != T[i] ) { ans += 1; }
		}
		cout << ans << endl;
	}
};

int main() {
	ios::sync_with_stdio( false );
	cout << fixed << setprecision( 10 );
	Solver().solve();
	return 0;
}


Measured memory_bytes: 3820
#include <cstdio>
using namespace std;

int main(int argc, char** argv)
{
	char s[1010];
	int len = 0;
	scanf("%s", s);
	for(; s[len]; len++);
	if(s[len - 1] == 's')
		s[len] = 'e', s[len + 1] = 's', s[len + 2] = '\0';
	else s[len] = 's', s[len + 1] = '\0';
	puts(s);
	return 0;
}

Measured memory_bytes: 1664
package main

import (
    "fmt"
    "math"
)


func main() {
    var N int 
    len, ans := 0, 0

    fmt.Scan(&N)
    for tmp:=N;tmp>0;tmp,len=tmp/10,len+1 {}
    
    if len%2==1 {
        ans+=N
    }
    len--
    
    for i := len; i > 0; i-- {
        if i%2==1 {
            ans+=int(math.Pow10(i))-1
        }else{
            ans-=int(math.Pow10(i))-1            
        }
    }
fmt.Println(ans)
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define m_p make_pair

long long n;

long long ans;

int main()
{
    cin >> n;
    long long v;
    for (long long i = 1; i <= n; ++i)
    {
        if (n / i != n / (i + 1))
        {
            long long l = n / (i + 1) + 1, r = (n / i);
            while ((r - l) > 4)
            {
                long long m = (l + r) / 2;
                if (i * m + i <= n)
                    l = m;
                else
                    r = m;
            }
            for (long long m = l; m <= r; ++m)
            {
                if (i * m + i == n)
                {
                    ans += m;
                    break;
                }
            }
            v = (n / (i + 1));
        }
        else
            break;
    }
    for (long long i = 1; i <= v; ++i)
        if (n / i == n % i)
            ans += i;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
use std::vec::Vec;

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()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn read_touple<T: std::str::FromStr + Copy>() -> (T, T) {
  let v: Vec<T> = read_vec();
  assert_eq!(v.len(), 2);
  (v[0], v[1])
}

fn main() {
  let s: Vec<char> = read::<String>().chars().collect();
  let n = s.len();
  for w in 0..n {
    for i in 0..n-w {
      let mut x = vec![]; 
      for j in 0..n {
        if j <= i || i+w <= j {
           x.push(s[j]);
        }
      }

      if check(&x) {
        println!("YES");
        return
      }
    }  
  }
  println!("NO");
}

fn check(cs: &Vec<char>) -> bool {
  let v = vec!['k', 'e', 'y', 'e', 'n', 'c', 'e'];
  let n = v.len();
  if v.len() != cs.len() {
    return false
  }
  for i in 0..n {
    if cs[i] != v[i] {
      return false
    }
  }

  return true
}

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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

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

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

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"; return os;}
template<class T,size_t n> ostream& operator<<(ostream &os, const array<T,n> &t) {os<<"{"; rep(i,n) {os<<t[i]<<",";} os<<"}"; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const ll INF = 1e9+7;

ll a[32][32];
ll dp[32][1<<22];

int main(){
	ios_base::sync_with_stdio(false);
	ll N, ans=0;

	cin >> N;
	rep(i,N){
		rep(j,N){
			cin >> a[i][j];
		}
	}

	dp[0][0] = 1;
	rep(m, N){
		rep(s, 1<<N){
			if(dp[m][s]){
				rep(w, N){
					if(!(s&(1<<w)) && a[m][w]){
						dp[m+1][s|(1<<w)] += dp[m][s]; 
						dp[m+1][s|(1<<w)] %= INF;
					}
				}
			}
		}

	}

	ans += dp[N][(1<<N)-1];

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 321792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
#define all(x) (x).begin(),(x).end()
const int INF=1e9+5;
const int N=2e6+10;
const ll mod=1e9+7;

ll fac[N];

ll mul(ll a,ll b){
	return a*b%mod;
}

ll poww(ll a,ll b){
	ll r=1;
	while(b){
		if(b&1) r=mul(r,a);
		a=mul(a,a);
		b>>=1;
	}
	return r;
}

ll inv(ll x){
	return poww(x,mod-2);
}

void add_self(ll& a,ll b){
	a+=b;
	a%=mod;
}

void init(){
	fac[0]=fac[1]=1;
	for(int i=2;i<N;++i){
		fac[i]=mul(fac[i-1],1ll*i);
	}
}

ll bino(ll n,ll k){
	if(k<0) return 1;
	if(!k) return 1;
	return mul(fac[n],mul(inv(fac[n-k]),inv(fac[k])));
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	init();
	ll k;
	ll ans=0;
	string s;
	cin>>k>>s;
	ll n=(ll)s.size();
	ll maxx=n+k;
	for(int len=n;len<=maxx;++len){
		ll last=maxx-len;
		ll ch_last=poww(26,last);
		ll pos=bino(maxx-last-1,n-1);
		ll ch25=poww(25,len-n);
		ll cur=mul(mul(pos,ch25),ch_last);
		add_self(ans,cur);
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 19852
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(ll i=0;i<n;i++)
#define ll long long
using namespace std;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
signed main() {
	ll k, a, b;
	cin >> k >> a >> b;
	if (a > b || abs(a - b) <= 2)cout << k + 1 << endl;
	else if (k <= a)cout << k + 1 << endl;
	else cout << (k - (a - 1)) / 2 * (b - a) + a+(k - (a - 1))%2 << endl;
	getchar(); getchar(); return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub


import sys
# sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
buff_readline = sys.stdin.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()

def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(S):
    return 'A' if S.isupper() else 'a'


def main():
    S = read_str()
    print(slv(S))


if __name__ == '__main__':
    main()


Measured memory_bytes: 10300
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int,  int>;
using pll = pair<ll, ll>;
using edge = pair<int, ll>;
using Graph = vector<vector<int>>; 
using WeightedGraph = vector<vector<edge>>;
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

int main(){
  int n; cin >> n;
  ll ans = 0;
  ll tmp = INF;
  ll sum = 0;
  for(int i = 0; i < n; ++i){
    ll a, b;cin >> a >> b;
    sum += b;
    if(a>b){
      tmp = min(tmp, b);
    }
  }
  if(tmp == INF) ans = 0;
  else ans = sum - tmp;
  cout << ans << endl;
}


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

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) if(DEBUG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DEBUG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
using ll = long long; using ull = unsigned long long; using pii = pair<int, int>;
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
static const int MOD = 1e9 + 7;
static const bool DEBUG = false;

signed main() {
	int N, A, B; string S;
	cin >> N >> A >> B >> S;
	int a = 0, b = 0;
	rep(i, 0, N) {
		if (S[i] == 'a'&&a + b < A + B) {
			a++;
			cout << "Yes" << endl;
			continue;
		}
		if (S[i] == 'b'&&a + b < A + B&&b < B) {
			b++;
			cout << "Yes" << endl;
			continue;
		}
		cout << "No" << endl;
	}
	return 0;
}

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

typedef long long LL;

int main(){
  int h,w;
  cin >> h >> w;
  vector<int> a(26,0);
  char c;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin >> c;
      a[c-'a']++;
    }
  }
  int kisu=0,gu=0;
  if(h%2==0&&w%2==0){
    for(int i=0;i<26;i++){
      if(a[i]%4){
        cout << "No" << endl;
        return 0;
      }
    }
    cout << "Yes" << endl;
  }else if(h%2==1&&w%2==1){
    for(int i=0;i<26;i++){
      if(a[i]%2){
        kisu++;
      }
      if(a[i]%4>=2){
        gu++;
      }
    }
    if(kisu!=1){
      cout << "No" << endl;
      return 0;
    }
    if(gu>(h-1)/2+(w-1)/2){
      cout << "No" << endl;
      return 0;
    }
    cout << "Yes" << endl;
  }else{
    for(int i=0;i<26;i++){
      if(a[i]%2){
        kisu++;
      }
      if(a[i]%4>=2){
        gu++;
      }
    }
    if(kisu>0){
      cout << "No" << endl;
      return 0;
    }
    if(gu>(w%2)*h/2+(h%2)*w/2){
      cout << "No" << endl;
      return 0;
    }
    cout << "Yes" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>

namespace asdfg
{
	const int N=101000;

	int begin[N],next[N*2],to[N*2];
	int fa[N],ind[N];

	int n,m,e,S,T;

	void add(int x,int y,bool k=1)
	{
		to[++e]=y;
		next[e]=begin[x];
		begin[x]=e;
		if(k)add(y,x,0);
	}
	int bfs(int p)
	{
		static std::queue<int> Q;

		for(int i=1;i<=n;i++)ind[i]=0;
		while(!Q.empty())Q.pop();

		int ret=-1;

		for(Q.push(p);!Q.empty();)
		{
			ret=p=Q.front(),Q.pop();
			ind[p]=1;
			for(int i=begin[p],q;i;i=next[i])
				if(!ind[q=to[i]])Q.push(q);
		}
		return ret;
	}
	void dfs(int p,int h=0)
	{
		fa[p]=h;
		for(int i=begin[p],q;i;i=next[i])
			if((q=to[i])!=h)dfs(q,p);
	}
	void initialize()
	{
		scanf("%d",&n);
		for(int i=1,u,v;i<n;i++)
			scanf("%d%d",&u,&v),add(u,v);

		T=bfs(S=bfs(1)),dfs(S);

		for(int i=1;i<=n;i++)ind[i]=0;
		for(int p=T;p;p=fa[p])ind[p]=++m;
	}
	bool check(int p)
	{
		for(int i=begin[p],q;i;i=next[i])
			if(ind[q=to[i]]==0)return 0;
		return 1;
	}
	int seq[N];
	bool judge()
	{
		for(int i=1;i<=m;i++)seq[i]=1;
		for(int p=T;p;p=fa[p])
		{
			for(int i=begin[p],q;i;i=next[i])
				if(ind[q=to[i]]==0)
				{
					if(!check(q))return 0;
					seq[ind[p]]++;
				}
		}
		return 1;
	}

	int s[N],t0[N],t1[N],t[N];

	void adjust()
	{
		for(int i=1;i<=n;i++)
			if(t0[i]!=t1[i])
			{
				if(t0[i]<t1[i])memcpy(t+i,t0+i,(n-i+1)*4);
				else memcpy(t+i,t1+i,(n-i+1)*4);
				break;
			}
			else t[i]=t0[i];
	}

	void work(int *ans)
	{
		int lst=0,tmp=0;
		for(int i=1;i<=m;i++)
		{
			s[++tmp]=lst+seq[i];
			for(int j=1;j<seq[i];j++)
				s[++tmp]=lst+j;
			lst+=seq[i];
		}
		for(int i=1;i<=n;i++)
			ans[s[i]]=i;
	}
	void solve()
	{
		initialize();
		if(!judge()){printf("-1\n");return;}

		work(t0);
		std::reverse(seq+1,seq+m+1);
		work(t1);

		adjust();

		for(int i=1;i<=n;i++)
			printf("%d ",t[i]);
		printf("\n");
	}
}

int main()
{
	asdfg::solve();
	return 0;
}


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

using u32 = uint32_t;
using u64 = uint64_t;
using i32 = int32_t;
using i64 = int64_t;


std::unordered_map<i64, i64> memo;


i64 f(i64 n)
{
	if(n==1)
	{
		return 1;
	}

	auto it = memo.find(n);
	if(it==memo.end())
	{
		i64 ret = 1 + f(n/2) + f(n/2);
		memo[n] = ret;

		return ret;
	}

	return memo[n];;
}

int main()
{
	std::ios_base::sync_with_stdio(0);
	
	i64 n;

	std::cin >> n;

	std::cout << f(n) << "\n";
	
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
l = [0] *n
for i in range(n):
    tmp = a[i] if i % 2 == 0 else -a[i]
    l[0] += tmp
for i in range(n):
    if i < n-1:
        l[i + 1] = 2 * a[i] - l[i]
    else:
        l[i] = 2*a[i] -l[0]
for i in range(n):
    print(l[i], end = " ")

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

int N;
int edge[8][8];

int dfs(int cur, vector<bool> visited, int cnt) {
  if (cnt == N) {
    return 1;
  }
  int ret = 0;
  for (int i = 0; i < N; i++) {
    if (edge[cur][i] && !visited[i]) {
      visited[i] = true;
      ret += dfs(i, visited, cnt + 1);
      visited[i] = false;
    }
  }
  return ret;
}

int main() {
  int M;
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    edge[a][b] = edge[b][a] = 1;
  }
  vector<bool> visited(N);
  visited[0] = true;
  cout << dfs(0, visited, 1) << endl;
}

Measured memory_bytes: 256
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let n: usize = sc.read();
    let a: Vec<usize> = sc.vec(n);

    if n == 2 {
        if a[0] == a[1] {
            println!("YES");
        } else {
            println!("NO");
        }
        return;
    }

    let mut graph = vec![vec![]; n];
    for _ in 1..n {
        let a = sc.read::<usize>() - 1;
        let b = sc.read::<usize>() - 1;
        graph[a].push(b);
        graph[b].push(a);
    }

    for v in 0..n {
        if graph[v].len() == 1 {
            continue;
        }
        match dfs(v, v, &graph, &a) {
            Some(out) => {
                if out != 0 {
                    println!("NO");
                    return;
                } else {
                    println!("YES");
                    return;
                }
            }
            None => {
                println!("NO");
                return;
            }
        }
    }
    unreachable!()
}

fn dfs(v: usize, p: usize, graph: &Vec<Vec<usize>>, a: &Vec<usize>) -> Option<usize> {
    if graph[v].len() == 1 {
        return Some(a[v]);
    }
    let va = a[v];
    let mut sum_children = 0;
    let mut max_child = 0;
    for &next in graph[v].iter() {
        if next == p {
            continue;
        }

        match dfs(next, v, graph, a) {
            Some(child) => {
                sum_children += child;
                if max_child < child {
                    max_child = child;
                }
            }
            None => {
                return None;
            }
        }
    }

    if max_child > va {
        return None;
    }
    if sum_children > va * 2 {
        return None;
    }

    let out = va * 2 - sum_children;
    if out > va {
        return None;
    }
    Some(out)
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 21884
d[4],e[9],f,k;char s[30];z(){int b,c,a=e[f++];a>9?s[k++]=40,b=z(),s[k++]=a,c=z(),s[k++]=41,a=a-43?a-45?b*c:b-c:b+c:(s[k++]=a+48);return a;}y(o,n,i,j){if(i==7){f=k=0;if(z()==10){s[k]=0;puts(s);return 1;}return 0;}if(o)for(;j<3;j++){e[i]="+-*"[j];if(y(o-1,n+1,i+1,0))return 1;}if(n|i==6)for(j=4;j--;)if(e[i]=d[j]){d[j]=0;if(y(o,n-1,i+1,0))return 1;d[j]=e[i];}return 0;}main(){for(;scanf("%d%d%d%d",d,d+1,d+2,d+3),f=*d;)y(3,0,0,0)||puts("0");}

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

namespace AtCorder_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(y => int.Parse(y));
            var x = input.Skip(1).First();
            var l = Console.ReadLine().Split(' ').Select(y => int.Parse(y)).ToArray();

            var ans = Enumerable.Repeat(l, l.Length)
                .Select((y, i) => y.Take(i + 1))
                .TakeWhile((y, i) => y.Sum() <= x)
                .Count() + 1;
            Console.WriteLine(ans);
        }
    }
}


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

typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector <ll> vi;
typedef vector <pi> vpi;
#define f first
#define s second
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0)

string S;

int main(){
	fast;
	
	cin>>S;
	
	FOR(i,0,S.size() - 1){
		if (S[i] == '?') S[i] = 'D';
	}
	cout<<S;
}



Measured memory_bytes: 3736
N = int(input())
H = list(map(int,input().split()))

count = []
dammy=0
for i in range(N-1):
    if H[i] >= H[i+1]:
        dammy+=1
    else:
        count.append(dammy)
        dammy=0

count.append(dammy)
print(max(count))

Measured memory_bytes: 63984
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = double;
const ld eps = 1e-9;

int adiv(int a) {
	map<int,int>mp;
	int num(a);
	for (int i = 2; i <= a; ++i) {
		while (num%i == 0) {
			mp[i]++;
			num/=i;
		}
	}
	int anum=0;
	for (auto m : mp) {
		anum-=m.first;
	}
	anum+=2*prev(mp.end())->first;
	return anum;
}

int main() {
	while (true) {

		int x,y;cin>>x>>y;
		if(!x)break;
		map<int,int>mp;
		vector<int>v(1e6+1,-1);
		int ans1=0,ans2=0;
		while (true) {
			x*=10;
			int a=x/y;
			int b=x%y;

			if (b == 0) {
				ans1++;
				break;
			}
			else {
				if (v[x/10]==-1) {
					v[x/10]=ans1;
					ans1++;
					x = b;
				}
				else {
					ans2=ans1-v[x/10];
					ans1=v[x/10];
					break;
				}
			}
		}
		cout<<ans1<<" "<<ans2<<endl;
	}
	return 0;
}


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

int main (){
  int n, i;
  scanf("%d", &n);
  char s[10001];
  scanf("%s", s);

  char ns;
  for(i=0; s[i]!='\0'; i++){
    ns = s[i]+n;

    if(ns>90) {
      ns = ns - 26;
    }

    printf("%c", ns);
  }

  printf("\n");

  return 0;
}

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

using namespace std;

using button_t = std::pair<int, int>;

int64_t solve(const std::vector<button_t>& buttons) {
  int64_t ret = 0;
  for (auto itr = buttons.crbegin(); itr != buttons.crend(); itr++) {
    const auto& button = *itr;
    int64_t const a = button.first + ret;
    if (a % button.second == 0) {
      continue;
    }

    if (a <= button.second) {
      ret += (button.second - a);
      continue;
    }

    ret += button.second - a % button.second;
  }
  return ret;
}

int main() {
  int n;
  std::cin >> n;
  std::vector<button_t> buttons(n);
  for (auto& button : buttons) {
    std::cin >> button.first >> button.second;
  }
  std::cout << solve(buttons) << std::endl;
  return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Edge=pair<int,int>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  int X;
  cin>>X;
  for(int i=179; i>=1; --i){
    if(360%i==0 && X%i==0){
      co(360/i);
      return 0;
    }
  }
}

Measured memory_bytes: 3564
#include <string>
#include <iostream>
 
using namespace std;
 
int main() {
  long n,m,i,ans=1;
  cin >> n>>m;
  if(n-m==1 || m-n==1){
    for(i=1;i<=n;i++){
      ans = ans*i;
      ans = ans%(1000000007);
    }
    for(i=1;i<=m;i++){
      ans = ans*i;
      ans = ans %(1000000007);
    }
  }else if(n==m){
    for(i=1;i<=n;i++){
      ans = ans * i;
      ans = ans %(1000000007);
      ans = ans * i;
      ans = ans %(1000000007);
    }
    ans *= 2;
    ans = ans %(1000000007);
  }else{
    ans = 0;
  }
  cout << ans << endl;
  return 0;
}
  
  
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=300005;
int s[N],t[N],Q,a,b,c,d;
char S[N],T[N];
int main(){
	scanf("%s%s",S,T);
	scanf("%d",&Q);
	for (int i=0;S[i];i++)s[i+1]=s[i]+(S[i]=='A'?1:2);
	for (int i=0;T[i];i++)t[i+1]=t[i]+(T[i]=='A'?1:2);
	while (Q--){
		scanf("%d%d%d%d",&a,&b,&c,&d);
		if ((s[b]-s[a-1])%3==(t[d]-t[c-1])%3)puts("YES");
		else puts("NO");
	}
}


Measured memory_bytes: 1664
#include<stdio.h>
#include<math.h>
int main()
{
	int n;
	int a;
	int num[100000];
	int i;
	int j;
	int br = 0;
	int number;
	long long int module = 1000000007;

	scanf("%d",&n);

	for(i=0;i<100000;i++){
		num[i] = 0;
	}
	
	if(n%2 == 0){
		for(i=1;i<=n;i++){
			scanf("%d",&a);
			if(a%2 == 1){
				j=(a-1)/2;
				num[j]++;
			}
		}
		n /= 2;
		for(i=0;i<n;i++){
			//printf("num[%d]=%d\n",i,num[i]);
			if(num[i] != 2){
				br = 1;
			}
		}
		if(br == 0){
			number = 1;
			for(i=1;i<=n;i++){
				number = number * 2;
				number = number % module;
			}
			printf("%d\n",number);
		}
		else printf("0\n");
	}
	else if(n%2 == 1){
		for(i=1;i<=n;i++){
			scanf("%d",&a);
			if(a%2 == 0){
				j=a/2;
				num[j]++;
			}
		}
		//printf("num[0]=%d\n",num[0]);
		if(num[0] != 1){
			br = 1;
		}
		n=(n+1)/2;
		for(i=1;i<n;i++){
			//printf("num[%d]=%d\n",i,num[i]);
			if(num[i] != 2){
				br = 1;
			}
		}
		if(br == 0){
			number = 1;
			for(i=1;i<n;i++){
				number = number * 2;
				number = number % module;
			}
			printf("%d\n",number);
		}
		else printf("0\n");
	}
	return 0;
}



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

int main()
{
int a,b,c,k,p=0;
    cin>>a>>b>>c>>k;
    if(c>a && c>b && b>a)
        cout<<"Yes";
    else
    {
         while(b<=a)
        {
            b*=2;
            p++;
        }
        while(c<=b)
        {
            c*=2;
            p++;
        }
       
        
        if(p<=k && c>b && c>a && b>a)
            cout<<"Yes";
        else
            cout<<"No";
    }
	return 0;
}

Measured memory_bytes: 3628
#include <cmath>
#include <iostream>
#include <stdio.h>
#include <string>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <limits.h>
#include <map>
#include <numeric>

namespace test {
	std::string to_string (char val) {
		return std::string (1, val);
		// return std::string{val};
	}
	//if( str.find ("r") != string::npos)
}

using namespace std;
typedef long long int llint;

int main (void) {
	int a,b; cin >> a >> b;
	if (a + b < 24) {
		cout << a + b << endl;
	}
	else {
		cout << a + b - 24 << endl;
	}
	return 0;
}

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	vector<string> s(3);cin >> s.at(0) >> s.at(1) >> s.at(2);
	int cur=0;
	vector<int> iter(3);
	while(true){
		if(iter[cur]==s[cur].size()){
			char ans='A'+cur;
			cout << ans << endl;
			return 0;
		}
		char c=s[cur][iter[cur]];
		iter[cur]++;
		if(c=='a') cur=0;
		else if(c=='b') cur=1;
		else cur=2;
	}
}

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

int main(void){
    int A, B, C;
    cin >> A >> B >> C;
    if(A==B)
        cout << C << endl;
    else if(B==C)
        cout << A << endl;
    else
        cout << B << endl;
}

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

int main(void)
{
    string S;
    cin >> S;

    if (S == "AAA" || S == "BBB")
        cout << "No" << endl;
    else
        cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#define ll long long
#define rep(i, a, b) for(ll i = (ll)a; i < (ll)b; i++)
using namespace std;

int main() {
  string s;
  cin >> s;
  int n = 0;
  rep(i, 0, 3) {
    if(s[i] == '1') n++;
  }
  cout << n << "\n";
}


Measured memory_bytes: 3596
N = int(input())
T = [0 for _ in range(N)]
X = [0 for _ in range(N)]
Y = [0 for _ in range(N)]
count = 0
t = 0
x = 0
y = 0

for i in range(N):
    T[i], X[i], Y[i] = map(int, input().split())
    t = abs(T[i] -t)
    x = abs(X[i] -x)
    y = abs(Y[i] -y)
    if t>= x+y and (t-(x+y))%2 == 0:
        count +=1
    else:
        break
    #     else:
    #         print('No1')
    #         exit()
    # else:
    #     print('No2')
    #     break

print('Yes' if count==N else 'No')

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

int n;
char raw_data[1000][128];
int kaisou[1000];
char* data[1000];

int calc(int pos) {
	if (data[pos][0] == '+' || data[pos][0] == '*') {
		int ret = (data[pos][0] == '+' ? 0 : 1);
		int i;
		for (i = pos + 1; i < n && kaisou[i] > kaisou[pos]; i++) {
			if (kaisou[i] == kaisou[pos] + 1) {
				if (data[pos][0] == '+') ret += calc(i);
				else ret *= calc(i);
			}
		}
		return ret;
	} else {
		return atoi(data[pos]);
	}
}

int main(void) {
	while (scanf("%d", &n) == 1 && n > 0) {
		int i, j;
		for (i = 0; i < n; i++) {
			if (scanf("%s", raw_data[i]) != 1) return 1;
			for (j = 0; raw_data[i][j] == '.'; j++);
			kaisou[i] = j;
			data[i] = raw_data[i] + j;
		}
		printf("%d\n", calc(0));
	}
	return 0;
}

Measured memory_bytes: 616
using System;

class MainClass
{
    public static void Main(string[] args)
    {
        string[] str=Console.ReadLine().Split(' ');

        int a=Convert.ToInt32(str[0]);
        int b=Convert.ToInt32(str[1]);

        Console.WriteLine("{0} {1} {2:f5}",a/b,a%b,(double)a/(double)b);
    }
}

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

#define sz(x) (int)(x.size())
#define FOR(x,y,z) for(int x = y; x <= z; x++)
#define int long long

const int N = 1e7 + 2, inf = 1e18;

int divs[N + 2] = {};

int32_t main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);  

    FOR(i,1,N) for(int j = i; j <= N; j += i) {
        divs[j]++;
    }
    int n, ans = 0;
    cin >> n;
    FOR(i,1,n) {
        ans += i * divs[i];
    }
    cout << ans << '\n';
}


Measured memory_bytes: 81768
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 998244353 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main(){
  int N, D[SIZE];
  map<int,int> mm;

  cin >> N;

  ll ans = 1;

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

  if (D[0] != 0) ans = 0;

  sort(D, D+N);

  for (int i=0; i<N; i++) {

    if (i) {
      ans = ans * mm[D[i]-1] % mod;
    }

    mm[D[i]]++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 5376
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
// clang-format on

int N;
int H[MAX_N + 5];

void solve()
{
  bool flag = true;
  for (int i = N - 1; i > 0; i--) {
    if (H[i] < H[i - 1]) H[i - 1]--;
    if (H[i - 1] > H[i]) {
      flag = false;
      break;
    }
  }
  cout << (flag ? "Yes" : "No") << endl;
}

int main(void)
{
  cin >> N;
  REP(i, N) cin >> H[i];
  solve();
  return 0;
}


Measured memory_bytes: 888
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define mod 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define MOD 1000000007
    
long long mod_pow(long long a,long long b)
{
    a %= MOD;
    long long res = 1;
    while(b){
        if(b & 1){
            res = res * a % MOD;
        }
        a = a * a % MOD;
        b >>= 1;
    }
    return res;
}
    
ll dp[110][110];

int main(){
    int n;
    cin >> n;
    vector<int> a(n+1);
    a[0] = 0;
    rep(i,n) cin >> a[i+1];
    n++;
    vector<int> b = a;
    b.push_back(1);
    sort(b.begin(),b.end());
    b.erase(unique(b.begin(),b.end()),b.end());
    int m = b.size();
    map<ll,int>mp;        
    rep(i,b.size()){
        mp[b[i]] = i;
    }
    
    dp[0][0] = 1;
    for(int i=1;i<n;i++){
        int K = mp[a[i]];
        if(a[i]<=a[i-1]){
            for(int j=K+1;j<m;j++){
                dp[i-1][0] += dp[i-1][j];
                dp[i-1][0] %= mod;
            }
            dp[i][0] = dp[i-1][0]*2%mod;
            for(int j=1;j<=K;j++){
                dp[i][j] = dp[i-1][j];
            }
        }else{
            int L = mp[a[i-1]];
            dp[i][0] = dp[i-1][0]*2%mod;
            //cerr <<"L: "<<  L << " K: " << K << endl;
            for(int j=1;j<=L;j++){
                dp[i][j] = dp[i-1][j]*mod_pow(2,a[i]-a[i-1])%mod;    
            }
            for(int j=L+1;j<=K;j++){
                if(a[i-1]==0){
                    if(b[j]!=1)dp[i][j] = 2*((mod + mod_pow(2,a[i]-b[j-1]) - mod_pow(2,a[i]-b[j]) )%mod)%mod;
                }else if(b[j]!=1)dp[i][j] = 2*dp[i-1][0]*((mod + mod_pow(2,a[i]-b[j-1]) - mod_pow(2,a[i]-b[j]) )%mod)%mod;        
                //cerr <<a[i-1] << " " << a[i] << " " << b[j] << endl;
                //cerr << dp[i-1][0] << " " << (mod + mod_pow(2,a[i]-a[i-1]) -2*mod_pow(2,a[i]-b[j]) )%mod << endl;
            }
        }
        // rep(j,m){
        //     cerr << dp[i][j] << " ";
        // }
        // cerr << endl;
    }
    ll sm = 0;
    for(int i=0;i<m;i++){
        sm += dp[n-1][i];
        sm %= mod;
    }
    cout << sm << endl;
    return 0;
}

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

#define pu push_back
#define fi first
#define se second
#define mp make_pair
#define int long long
#define pii pair<int,int>
#define mm (s+e)/2
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(int i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define sz 200000
signed main()
{
	
		int A[50];
		memset(A,0,sizeof(A));
		for(int i=0;i<5;i++)
		{
			int a;
			cin>>a;
			A[a]=1;
		}
		for(int i=1;i<=5;i++)
		{
			if(A[i]==0) cout<<i<<endl;
		}
	
}

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

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-12;
static const double PI = acos(-1.0);

template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define dbg(x) true
#endif

void solve(long long N, std::vector<long long> L) {
  ll ans = 0;
  sort(ALL(L));
  REP(x, N) {
    FOR(y, x + 1, N) {
      FOR(z, y + 1, N) {
        if (L[x] == L[y]) continue;
        if (L[y] == L[z]) continue;
        if (L[z] == L[x]) continue;
        if (L[x] + L[y] > L[z]) {
          ans++;
        }
      }
    }
  }
  cout << ans << endl;
}

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


Measured memory_bytes: 3708
// finish date: 2018/03/13

#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvvi vector<vector<vector<int>>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vvd vector<vector<double>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define bigmod 1000000007
#define INF 1050000000
#define pii pair<int,int>


int main() {
    int N;
    string s, t;
    cin >> N >> s >> t;
    rep(i, N) {
        if (s.substr(i) == t.substr(0, N - i)) {
            cout << (s.substr(0, i) + t).length() << endl;
            return 0;
        }
    }
    cout << (s + t).length() << endl;
    return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
edges_from = [[] for _ in range(n)]

for _ in range(m):
    _from, to = map(lambda x: int(x)-1, input().split())
    edges_from[_from].append(to)

E_dist_to_goal = [0] * n
for node in range(n-2, -1, -1):
    routes = edges_from[node]
    num_of_routes = len(routes)
    for next_node in routes:
        dist = E_dist_to_goal[next_node] + 1
        E_dist_to_goal[node] += dist/num_of_routes


def recalculate_dist(node, E_dist_to_goal):
    recal_E_dist = [0]*(node+1)
    routes = edges_from[node]
    num_of_routes = len(routes)
    if num_of_routes == 1:
        return False

    heaviest_route = max(E_dist_to_goal[next_node]+1 for next_node in routes)
    new_dist = E_dist_to_goal[node] - heaviest_route/num_of_routes
    new_dist *= num_of_routes / (num_of_routes - 1)
    recal_E_dist[node] = new_dist

    for v in range(node-1, -1, -1):
        routes = edges_from[v]
        num_of_routes = len(routes)
        for nv in routes:
            if nv > node:
                dist = E_dist_to_goal[nv] + 1
            else:
                dist = recal_E_dist[nv] + 1
            recal_E_dist[v] += dist
        recal_E_dist[v] /= num_of_routes
    return recal_E_dist[0]


ans = [E_dist_to_goal[0]]
for i in range(n-2):
    candidate = recalculate_dist(i, E_dist_to_goal)
    if candidate:
        ans.append(candidate)

print(min(ans))


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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using Graph = vector<vector<int>>;

int main(){
  int a,b,c,d; cin>>a>>b>>c>>d;
  cout<<min(a,b)+min(c,d)<<endl;
}


Measured memory_bytes: 256
A, B, K = map(int,input().strip().split())

res = []

for a in range(A,min(A + K,B)):
    res.append(a)
for b in range(max(A,B - K + 1),B + 1):
    res.append(b)

for r in sorted(list(set(res))):
    print(r)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, W;
  cin >> N >> W;
  vector<int> w(N), v(N);
  for (int i = 0; i < N ; i++){
    cin >> w[i] >> v[i];
  }
  vector<vector<long long>> dp(N + 1, vector<long long>(W + 1, 0));
  for (int i = 0; i < N; i++){
    for (int j = 0; j <= W; j++){
      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];
}

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

using namespace std;

void solve() {
    int n, k;
    cin >> n >> k;
    vector<int> vt(n);
    for (int i = 0; i < n; i++) {
        cin >> vt[i];
    }
    sort(vt.rbegin(), vt.rend());
    long long sum = 0;
    for (int i = k; i < n; i++) {
        sum += vt[i];
    }
    cout << sum;
}

int main() {
    ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
    cout.setf(ios::fixed), cout.precision(20);
    solve();
}


Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep2(i, s, e) for(int i=s; i<e; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)

int main(){

    int n; cin >> n;
    cout << n*n*n;

    return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;

int po(int a, int p) {
	if (p == 0)return 1;
	int res = po(a, p / 2);
	res = (res * res) % MOD;
	if (p & 1) {
		res = (res * a) % MOD;
	}
	return res;
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string S;
	cin >> S;
	int N = S.size();
	int base = 1;
	int res = 0;
	for (int i = 0; i < N; i++) {
		if (S[i] == '1') {
			res = (res + base * po(3, N - i - 1)) % MOD;

			base = (base * 2) % MOD;
		}
		else {

		}
	}
	res = (res + base) % MOD;
	cout << res << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<string.h>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	if(a%3==0||b%3==0||(a+b)%3==0)cout<<"Possible"<<endl;
	else cout<<"Impossible"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
 
int main() {
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i,n) cin >> p.at(i);
    int count=0;
    rep(i,n-2){
        if((p.at(i)-p.at(i+1))*(p.at(i+2)-p.at(i+1))<0)count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 256
N=int(input())
s=list(map(int,input().split()))
a=1
b=0
s.sort()
mod=10**18
for i in range(N):
  a*=s[i]
  if a>mod:
    b=1
    break
if b==1:
  print(-1)
else:
  print(a)

Measured memory_bytes: 21652
S = input()

MOD = 10 ** 9 + 7
MAX_LEN = len(S)
dp = [[0] * 13 for _ in range(MAX_LEN + 1)]
dp[0][0] = 1

for i in range(MAX_LEN):
    c = int(S[i]) if S[i] != '?' else -1
    for j in range(10):
        if c != -1 and c != j:
            continue
        
        for k in range(13):
            idx = (k * 10 + j) % 13
            dp[i + 1][idx] += dp[i][k]
            dp[i + 1][idx] %= MOD
        
print(dp[-1][5])



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

#define MIN(x, y) ((x) < (y) ? (x) : (y))
#define MAX(x, y) ((x) > (y) ? (x) : (y))
#define ABS(x, y) ((x) > (y) ? ((x) - (y)) : ((y) - (x)))
#define MOD(x, y) ((x) % (y))
#define DIVCEIL(x, y) (((x) + ((y) - 1)) / (y))
#define DIVFLOOR(x, y) ((x) / (y))
#define DIVROUND(x, y) (MOD(x, y) * 2 >= (y) ? DIVCEIL(x, y) : DIVFLOOR(x, y))

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

  cout << DIVCEIL(N, D*2+1) << endl;

  return 0;
}


Measured memory_bytes: 256
a=[]

for i in range(4):
    x=int(input())
    a.append(x)

p=int(input())
r1=p*a[0]
r2=0

if(p>a[2]):
    r2=a[1]+(p-a[2])*a[3]
else:
    r2=a[1]

print(min(r1,r2))

Measured memory_bytes: 7684
#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1);
typedef long long ll;
typedef pair<int64_t,int64_t> pll;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define ALL(a) begin(a),end(a)
#define sz(s) (s).size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second

void solve()
{   
    
  string s;cin>>s;
  ll k;cin>>k;
  if(s[0]!=s[s.size()-1])
  {
    int ans=0;
    for(int i=1;i<s.size();i++)
    {
      if(s[i]==s[i-1]){i++;ans++;}
    }
    cout<<ans*k<<endl;
    return;
  }
  
  
  int a=-1,b=-1,aa,bb;
  REP(i,s.size()-1)
    if(s[i]!=s[i+1]){a=i+1;break;}
  
  aa=a-1;
  
  if(a==-1){cout<<k*s.size()/2<<endl;return;}
  
  for(int i=s.size()-1;i>0;i--)
    if(s[i]!=s[i-1]){b=s.size()-i;break;}

  bb=s.size()-b;
  
  int ans=0;
    for(int i=aa+1;i<bb;i++)
    {
      if(s[i]==s[i-1]){i++;ans++;}
    }
    //cout<<ans<<" "<<a<<" "<<b<<" "<<endl;
    cout<<ans*k+(a+b)/2*(k-1)+a/2+b/2<<endl;
}


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

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

int main() {
int N, M;
  cin >> N >> M;
  vector<int> L(M);
  vector<int> R(M);
  rep(i, M)
    cin >> L.at(i) >> R.at(i);
  sort(L.begin(), L.end());
    sort(R.begin(), R.end());
reverse(L.begin(), L.end());
  if(R.at(0) - L.at(0) >= 0)
    cout << R.at(0) - L.at(0) + 1 << endl;
  else
    cout << 0 << endl;
}

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

int main() {
  int64_t m,d;
  cin>>m>>d;
if(d<=21||m<=3){
  cout<<0;
}
  int count=0;
  if(d>21&&m>3){
    for(int i=4;i<=m;i++){
      for(int j=22;j<=d;j++){
        int a=j%10;
        int b=j/10;
        if(a>=2&&b>=2&&a*b==i){
          count++;
        }
      }
    }
  
  cout<<count;
  }
}

Measured memory_bytes: 256