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

#pragma region Macros
using ll = long long;
#define int ll
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
template<class T = ll> using V = vector<T>;
template<class T = ll> using VV = V<V<T>>;
#define IOS\
    ios::sync_with_stdio(false);\
    cin.tie(0);\
    cout.tie(0);
#define FOR(i,l,r) for(ll i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(ll i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define SORT(name) sort(name.begin(), name.end())
#define RSORT(name)\
    SORT(name);\
    reverse(all(name));
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
inline void Yes(bool b = true) {cout << (b ? "Yes" : "No") << '\n';}
inline void YES(bool b = true) {cout << (b ? "YES" : "NO") << '\n';}
template <class T> inline void print(T x){ cout << x << '\n';}
template<typename T1,typename T2> inline void chmin(T1 &a, T2 b){ if(a > b) a = b; }
template<typename T1,typename T2> inline void chmax(T1 &a, T2 b){ if(a < b) a = b; }

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
#pragma endregion

#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const int MOD = 1000000007;
const int MAX_N = 100010;

signed main() {
    IOS;

    int N;
    V<> A;
    cin >> N;
    A.resize(N);
    REP(i, N) { cin >> A[i]; }

    int ans = 0;
    int cur = A[0];
    for(int i = 1; i < N; ++i) {
        if(cur > A[i]) {
            ans += cur - A[i];
        }
        chmax(cur, A[i]);
    }
    print(ans);

    return 0;
}


Measured memory_bytes: 4780
from enum import Enum
import sys
import math
 
BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001
 
 
while True:
    N = int(input())
    if N == 0:
        break
    table = list(map(int,input().split()))
 
    tmp_sum = 0
    for i in range(len(table)):
        tmp_sum += table[i]
    B = tmp_sum/len(table) #平均
 
    squared_sum = 0
    for i in range(len(table)):
        squared_sum += table[i]*table[i]
    A = squared_sum/len(table)
 
    print("%.10f"%(math.sqrt(A-B*B)))


Measured memory_bytes: 6392
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
#define INF 100000000
class element{
public:
    int a;
    int b;
    element(int c,int d):a(c),b(d){}
};
class node{
public:
    int parent;
    vector<int> children;
    int heavy;
    vector<element> data;
};


void input(vector<node>&);
vector<node*> sortingtree(vector<node> &);
int searchmin(vector<element>&,int);

int main(){
    vector<node> tree;
    vector<node*> sortedtree;
    input(tree);
    sortedtree = sortingtree(tree);
    for(int i=0;i<sortedtree.size();++i){
        node d = *sortedtree[i];
        int parent = d.parent;
        if(d.data.size()==0){
            if(d.parent>0){
                tree[parent].data.push_back(element(d.heavy,0));
            }
        }else{
            int num = searchmin(d.data,d.heavy);
            if(num==INF){
                cout<<"IMPOSSIBLE"<<endl;
                return 0;
            }
            if(parent>0){
                tree[parent].data.push_back(element(d.heavy,num));
            }
        }
    }
    cout<<"POSSIBLE"<<endl;
    return 0;
}
int searchmin(vector<element>& data,int maxheavy){
    vector<int> line(maxheavy+1,INF);
    line[0]=0;
    for(int i=0;i<data.size();++i){
        element d = data[i];
        for(int j=maxheavy;j>=0;--j){
            int num = line[j];
            line[j]=INF;
            if(j+d.a<=maxheavy){
                line[j+d.a]=min(line[j+d.a],num+d.b);
            }
            if(j+d.b<=maxheavy){
                line[j+d.b]=min(line[j+d.b],num+d.a);
            }
        }
    }
    int res=INF;
    for(int i=0;i<=maxheavy;++i){
        res=min(res,line[i]);
    }
    return res;
}
void input(vector<node>& tree){
    int N;
    cin>>N;
    tree.resize(N+1);
    tree[1].parent=-1;
    
    for(int i=2;i<=N;++i){
        int parent;
        cin>>parent;
        tree[parent].children.push_back(i);
        tree[i].parent=parent;
    }
    for(int i=1;i<=N;++i){
        cin>>tree[i].heavy;
    }
}
vector<node*> sortingtree(vector<node> &tree){
    vector<node*> res;
    res.push_back(&tree[1]);
    for(int i=0;i<res.size();++i){
        vector<int> children;
        children = res[i]->children;
        for(auto i = children.begin();i!=children.end();++i){
            res.push_back(&tree[*i]);
        }
    }
    reverse(res.begin(),res.end());
    return res;
}

Measured memory_bytes: 384
def md(n):
    d=[]
    da=d.append
    for i in range(1,int(n**0.5)+1):
        if n%i==0:
            da(i)
            if i!=n//i:da(n//i)
    d.sort()
    return d
A,B,K = map(int,input().split())
c = sorted(set(md(A)) & set(md(B)),reverse = True)
print(c[K-1])

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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define endl '\n'

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;

const ll mod=1000000007;
//head
const int nax = 1e5+2;
int st[60][nax];
int main()
{
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

    string s;
    cin >> s;
    int n = s.size();
    for(int i = 0; i < n; i++) {
        st[0][i] = i;
        st[1][i] = i + (s[i] == 'R' ? 1 : -1);
    }

    for(int i = 2; i <= 59; i++) {
        for(int j = 0; j < n; j++) {
            int nxt = st[i-1][j];
            st[i][j] = st[i-1][nxt];
        }
    }

    vector<int> cnt(n,0);
    for(int i = 0; i < n; i++) {
        cnt[st[59][i]]++;
    }
    trav(c,cnt) cout << c << " ";
    cout << endl;

    return 0;
}


Measured memory_bytes: 24528
fun main(args: Array<String>){
  var input = readLine()!!.split(" ")
  val n = input[0].toInt()
  val k = input[1].toInt()
  input = readLine()!!.split(" ")
  val h = IntArray(n){ input[it].toInt() }

  var result = 0
  for( hi in h )
    if( k <= hi )
      result++

  println(result);
}


Measured memory_bytes: 47976
import heapq as hq
n,m = map(int,input().split())

ls = list(map(int,input().split()))
ls = [-1*a for a in ls]

hq.heapify(ls)

for _ in range(m):
  t = -1*hq.heappop(ls)
  hq.heappush(ls,t//2*(-1))
  
print(-1*sum(ls))

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

int main() 
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int x;
    for(int i=1;i<=6;i++)
    {
        cin>>x;
        if(x==0){cout<<i<<endl;
        return 0;}
    }
	return 0;
}

Measured memory_bytes: 3604
n,m=map(int,input().split())
s=list(map(int,input().split()))
odd=0
even=0
p=0
for i in s:
    if i%2==1:
        odd+=1
    else:
        even+=1
even=2**even
from math import factorial
def f(n,m):
    return factorial(n)//(factorial(n-m)*factorial(m))
for i in range(1,odd+1,2):
    p+=f(odd,i)
if m==1:
    print(p*even,)
else:
    print(2**(len(s))-p*even)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
const int maxn=3e5+10;
int bit[maxn],n,b[maxn];
int get(int idx){
    int sum=0;
    while(idx>0){
        sum+=(bit[idx]);
        idx-=(idx&(-idx));
    }
    return sum;
}
void update(int idx,int val){
    while(idx<=n){
        bit[idx]+=val;
        idx+=(idx&(-idx));
    }
    return;
}
map<int,int> m;
vector<int> a;


int main(){
    scanf("%d",&n);
    a.push_back(-1);
    for(int i=1;i<=n;i++){
        scanf("%d",&b[i]);
        a.push_back(b[i]);
    }
    sort(a.begin(),a.end());
    a.erase(unique(a.begin(),a.end()),a.end());
    for(int i=1;i<(int)a.size();i++){
        m[a[i]]=i;
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        if(get(m[b[i]]-1)==0){
            ans++;
            update(m[b[i]],1);
            continue;
        }
        int pos=0,val=0,c=get(m[b[i]]-1);
        for(int i=19;i>=0;i--){
            if(pos+(1<<i)<=n&&val+bit[pos+(1<<i)]<c){
                pos+=(1<<i);
                val+=bit[pos];
            }
        }
        pos++;
        update(pos,-1);
        update(m[b[i]],1);
    }
    printf("%d\n",ans);
}
/*
    Good Luck
        -Lucina
*/


Measured memory_bytes: 6008
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define vlli vector<ll>
#define vi vector<int>
#define vs vector<string>
#define vplli vector< pair< ll,ll> >
#define plli pair< ll,ll >
#define vps vector< pair< string, string> >
#define vpi vector< pair< int, int> >
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,a,n) for(ll i=a;i<n;i++)
#define forr(i,n,a) for(ll i=n-1;i>=a;i--)
#define scan(arr,a,n) for(ll i=(a);i<(n);i++)cin>>(arr)[i];
#define print(arr,a,n) for(ll i=(a);i<(n);i++)cout<<(arr)[i]<<" ";

const ll inf = 1e18;

ll add(ll x, ll y) {ll res = x + y; return (res >= mod ? res - mod : res);}
ll mul(ll x, ll y) {ll res = x * y; return (res >= mod ? res % mod : res);}
ll sub(ll x, ll y) {ll res = x - y; return (res < 0 ? res + mod : res);}
ll power(ll x, ll y) {ll res = 1; x %= mod; while (y) {if (y & 1)res = mul(res, x); y >>= 1; x = mul(x, x);} return res;}
ll mod_inv(ll x) {return power(x, mod - 2);}


int main(){
    fast;
    #ifndef ONLINE_JUDGE
    freopen("input1.txt","r",stdin);
    freopen("output1.txt","w",stdout);
    #endif
    ll a, b, c, d;
    cin>>a>>b>>c>>d;
    vlli v;
    v.pb(a*c);
    v.pb(a*d);
    v.pb(b*c);
    v.pb(b*d);
    cout<<*max_element(all(v));
}

Measured memory_bytes: 3644
// Good Sequence.cpp
// https://atcoder.jp/contests/arc087/tasks/arc087_a

#include <iostream>
#include <map>
using namespace std;
typedef unsigned long long int llu;

int main(){

    // freopen("input.txt", "r", stdin); 
    // freopen("output.txt", "w", stdout); 
    // cout<<"Good Sequence.cpp\n";

    int size;
    cin>> size;

    if(size == 0){
        cout<<0;
        return 0;
    }

    int value;

    map<int, int> m;
    map<int, int>:: iterator itr;
    int elemToRemove = 0;

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

        cin >>value;

        if(m.find(value) != m.end()){
            m[value] += 1;
        }else{
            m[value] = 1;
        }   

        if(m[value] > value){
            ++elemToRemove;
            m[value] -= 1;
        }

    }    

    for(itr = m.begin(); itr != m.end(); ++itr){

        if(itr->second != itr->first){
            elemToRemove += itr->second;
        }
    }

    cout<<elemToRemove;

    return 0;
}



Measured memory_bytes: 4736
//testing unlocked
#include <bits/stdc++.h>
#define gc getchar()
#define pc(x) putchar(x)
template<typename T> void scan(T &x){x = 0;register bool _=0;register T c=gc;_=c==45;c=_?gc:c;while(c<48||c>57)c=gc;for(;c<48||c>57;c=gc);for(;c>47&&c<58;c=gc)x=(x<<3)+(x<<1)+(c&15);x=_?-x:x;}
template<typename T> void printn(T n){register bool _=0;_=n<0;n=_?-n:n;char snum[65];int i=0;do{snum[i++]=n%10+48;n/= 10;}while(n);--i;if (_)pc(45);while(i>=0)pc(snum[i--]);}
template<typename First, typename ... Ints> void scan(First &arg, Ints&... rest){scan(arg);scan(rest...);}
template<typename T> void print(T n){printn(n);pc(10);}
template<typename First, typename ... Ints> void print(First arg, Ints... rest){printn(arg);pc(32);print(rest...);}
 
using namespace std;
 
 
int main(){
    
    int a, b;
    scan(a, b);
    if(a > 9 || b > 9){
        return 0*puts("-1");
    }
    print(a*b);
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;

const int MAX = 1e5 + 5;
vector <int> adj[MAX];
int main()
{
	boost;
	int n, m, i, a, b;
	cin >> n >> m;
	int h[n + 1];
	foe(i, 1, n)
	cin >> h[i];
	fo(i, 0, m) {
		cin >> a >> b;
		adj[a].pb(b);
		adj[b].pb(a);
	}
	int ans = 0;
	foe(i, 1, n) {
		bool ok = 1;
		for(int v : adj[i]) {
			if(h[v] >= h[i])
			ok = 0;
		}
		ans += ok;
	}
	cout << ans;
}


Measured memory_bytes: 9112
#include<bits/stdc++.h>
using namespace std;
#define int     long long
#define F       first
#define S       second
#define _READ   freopen("input.txt","r", stdin);
#define _FAST   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
void solve()
{
    string s,t;
    cin>>s>>t;
    t.erase(t.begin()+(int)(t.size()-1));
    if(s==t)
        cout<<"Yes\n";
    else
    {
        cout<<"No\n";
    }
    
}
int32_t main()
{
    clock_t tStart = clock();
    #ifndef ONLINE_JUDGE
    _READ
    #endif
    
    solve();
    
    #ifndef ONLINE_JUDGE
    cout<<fixed<<setprecision(5)<<"\nTime taken: "<<(double)(clock() - tStart)/CLOCKS_PER_SEC;
    #endif
    
    return 0;
}
/*
===FOR N-Dimensional Vector===
https://codeforces.com/blog/entry/76149
g++ -std=c++17 -Wshadow -Wall -g -fsanitize=address -fsanitize=undefined a.cpp -o a -D_GLIBCXX_DEBUG
*/

Measured memory_bytes: 3644
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {
	public static void main(String[] args){
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String tes = null;

		List<Double> al = new ArrayList<Double>();
		try {
			tes = br.readLine();
		} catch (IOException e) {
			// TODO 自動生成された catch ブロック
			e.printStackTrace();
		}
		
		double a = Double.parseDouble(tes);
		al.add(a);

		while(true){
			try {
				tes = br.readLine();
			} catch (IOException e) {
				// TODO 自動生成された catch ブロック
				e.printStackTrace();
			}
			if(tes == null){
				break;
			}
			
			try{
				a = Double.parseDouble(tes);
			}catch(NumberFormatException e){
				break;
			}
			
			al.add(a);
		}
		
		for(int i=0;i<al.size();i++){
			for(int j=i+1;j<al.size();j++){
				if(al.get(i) < al.get(j)){
					double tmp = al.get(i);
					al.set(i, al.get(j));
					al.set(j, tmp);
				}
			}
		}
		System.out.println(al.get(0) - al.get(al.size() - 1));
		
	}

}

Measured memory_bytes: 16980
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(ll i = (ll)(s); i < (ll)(t); i++)
#define rrep(i,s,t) for(ll i = (ll)(s-1);(ll)(t) <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
constexpr ll INF = numeric_limits<ll>::max()/4;
constexpr ll n_max = 1e6+10;
#define int ll

template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {return '"' + s + '"';}
string to_string(const char *c) {return to_string((string) c);}
string to_string(bool b) {return (b ? "true" : "false");}
template <size_t N>
string to_string(bitset<N> v){
    string res = "";
    for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
    return res;
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

void debug_out() {cerr << endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

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

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    vector<ll> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    ll ans = 0;
    vector<ll> cnt(n_max);
    rep(i,0,n){
        if(cnt[a[i]]){
            cnt[a[i]]++;
            continue;
        }
        for(int j = a[i]; j < n_max; j += a[i]){
            cnt[j]++;
        }
    }
    rep(i,0,n){
        if(cnt[a[i]] == 1)ans++;
    }

    cout << ans << endl;
}

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

#define vt          vector
#define sz(x)       int((x).size())
#define all(x)      (x).begin(), (x).end()
#define rall(x)     (x).rbegin(), (x).rend()
#define fi          first
#define se          second

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

const int mod = 1e9 + 7;

ll modExp(ll b, int e) {
    ll r = 1;
    for (; e; e /= 2, b = b * b % mod) {
        if (e & 1) r = r * b % mod;
    }
    return r;
}

void solve() {
    int n;
    cin >> n;
    cout << ((modExp(10, n) - 2 * modExp(9, n) + modExp(8, n))
        % mod + mod) % mod;
}

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

    int tcs = 1;
    for (int tc = 1; tc <= tcs; tc++) {
        // cout << "Case " << tc << ": ";
        solve();
    }
}


Measured memory_bytes: 3644
use std::io::Read;
use std::collections::BinaryHeap;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

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

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let m: usize = iterator.next().unwrap().parse().unwrap();

    let mut h: BinaryHeap<(usize, usize)> = BinaryHeap::new();
    for _ in 0..n {
        let ai: usize = iterator.next().unwrap().parse().unwrap();
        h.push((ai, 1));
    }
    for _ in 0..m {
        let bi: usize = iterator.next().unwrap().parse().unwrap();
        let ci: usize = iterator.next().unwrap().parse().unwrap();
        h.push((ci, bi));
    }

    let mut ans = 0;
    for _ in 0..n {
        let p = h.pop().unwrap();
        ans += p.0;
        if p.1 > 1 {
            h.push((p.0, p.1 - 1));
        }
    }
    return ans.to_string();
}


Measured memory_bytes: 13556
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>

using lint = long long int;
using Graph = std::vector<std::vector<lint>>;

template<class T>
struct edge
{
	T dist;
	lint to;
	edge(){}
	edge(const T &a_dist,const lint &a_to) : dist(a_dist), to(a_to) {}
	~edge(){}
};

int main(int argc,char *argv[])
{
	lint n;
	std::cin >> n;

	lint i;
	for(i = sqrt(n);i > 0;i--) if(n%i == 0) break;

	lint j = n/i;
	std::cout << i-1 + j-1 << std::endl;
	return 0;
}


Measured memory_bytes: 384
/*+lmake
 * STD = c++14
 * DEFINE += WAAUTOMATON
 */
#include <bits/stdc++.h>
using namespace std;
using LL=long long;
using ULL=unsigned long long;
#ifdef WAAUTOMATON
#define debug(args...)                                                                             \
    {                                                                                              \
        dbg, args;                                                                                 \
        cerr << endl;                                                                              \
    }
#define massert(x) assert(x)
#else
#define debug(args...) // Just strip off all debug tokens
#define massert(x)
#endif
struct debugger
{
    template<typename T> debugger& operator , (const T& v)
    {    
        cerr<<v<<" ";    
        return *this;    
    }
} dbg;
LL a[100];
deque<int> dfs(LL x)
{
	if (x==1) return deque<int>();
	if (x%2==0) {
		auto t=dfs(x/2);
		t.push_back(t.size()+1);
		return t;
	} else {
		auto t=dfs(x-1);
		t.push_front(t.size()+1);
		return t;
	}
}
int main(){	
#ifdef WAAUTOMATON
	//freopen("in.txt","r",stdin);
#endif
	LL n;
	cin>>n;
	auto ans=dfs(n+1);
	cout<<ans.size()*2<<endl;
	for(auto i:ans) {
		cout<<i<<' ';
	}
	for(auto i:ans) {
		static int cnt=1;
		cout<<cnt<<' ';
		++cnt;
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 2100000010;
constexpr ll INF= 2000000000000000000;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<ll,ll> P;
typedef pair<int,P> PP;

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

void mod(ll &val, ll M) {
    val = val % M;
    if(val < 0) {
        val += M;
    }
}

template<typename T>
T RS(T N, T P, T M){
    if(P == 0) {
        return 1;
    }
    if(P < 0) {
        return 0;
    }
    if(P % 2 == 0){
        ll t = RS(N, P/2, M);
        if(M == -1) return t * t;
        return t * t % M;
    }
    if(M == -1) {
        return N * RS(N,P - 1,M);
    }
    return N * RS(N, P-1, M) % M;
}

struct Union_find {
	int par[200010]; //親
	int siz[200010]; //根ノードiの木に含まれる要素数。iが根ノード出ない場合無意味な値となる。

	//n要素で初期化
	Union_find(int n) {
		for(int i = 0;i < n;i++) {
			par[i] = i;
			siz[i] = 1;
		}
	}

	//木の根を求める
	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(siz[x] < siz[y]) {
			swap(x,y);
		}
		par[y] = x;
		siz[x] += siz[y];
	}

	//ｘとｙが同じ集合に属するか否か
	bool same(int x,int y) {
		return find(x) == find(y);
	}

	int size(int x) {
		return siz[find(x)];
	}
};

struct edge {
    int u,v;
    ll cost;
};

bool comp(const edge &e1,const edge &e2) {
    return e1.cost < e2.cost;
}

int V,E;
edge graph[200010];

ll Kruskal() {
    sort(graph,graph + E,comp);
    Union_find uf(V);
    ll ret = 0;
    for(int i = 0;i < E;i++) {
        edge e = graph[i];
        if(!uf.same(e.u,e.v)) {
            uf.unite(e.u,e.v);
            ret += e.cost;
        }
    }
    return ret;
}

int main() {
    cin >> V;
    E = V * 2 - 2;
    vector<tuple<int,int,int>> vec(V);
    for(int i = 0;i < V;i++) {
        int A,B;
        cin >> A >> B;
        vec.at(i) = make_tuple(A,B,i);
    } 
    sort(vec.begin(),vec.end());
    for(int i = 0;i < V - 1;i++) {
        graph[i] = edge{get<2>(vec.at(i)),get<2>(vec.at(i + 1)),get<0>(vec.at(i + 1)) - get<0>(vec.at(i))};
        swap(get<0>(vec.at(i)),get<1>(vec.at(i)));
    }
    swap(get<0>(vec.at(V - 1)),get<1>(vec.at(V - 1)));
    sort(vec.begin(),vec.end());
    for(int i = 0;i < V - 1;i++) {
        graph[V - 1 + i] = edge{get<2>(vec.at(i)),get<2>(vec.at(i + 1)),get<0>(vec.at(i + 1)) - get<0>(vec.at(i))};
    }
    cout << Kruskal() << endl;
}

Measured memory_bytes: 8220
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
const int M=105;
const int dx[8]={-1,-1,-1,0,0,1,1,1};
const int dy[8]={-1,0,1,1,-1,1,0,-1};
int n,m;
char s[M][M];
int a[M][M];
int main(){
	cin>>n>>m;
	for (int i=0;i<=n;i++)
		s[i][0]='?';
	for (int j=0;j<=m;j++)
		s[0][j]='?';
	for (int i=1;i<=n;i++)
		for (int j=1;j<=m;j++)
			cin>>s[i][j];
	for (int i=1;i<=n;i++){
		for (int j=1;j<=m;j++){
			if (s[i][j]=='#') a[i][j]=-1;
			else{
			for (int k=0;k<8;k++){
				if (s[i+dy[k]][j+dx[k]]=='#') a[i][j]++;
			}
		}
		}
	}
	for (int i=1;i<=n;i++){
		for (int j=1;j<=m;j++){
			if (a[i][j]==-1)
			cout<<'#';
			else
			cout<<a[i][j];
		}
		cout<<endl;
	}
	//system("pause");
	return 0;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
ls = [i for i in range(m)]
rs = [i for i in range(m)]
cnt = 0
for _ in range(m):
    ls[_],rs[_] = map(int,input().split())

maxl = max(ls)
minr = min(rs)

for nn in range(1,n+1):
    if maxl <= nn and minr >= nn:
        cnt += 1
print(cnt)

Measured memory_bytes: 11056
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>	// upper_bound(A, A+N, num), lower_bound(A, A+N, num)
#include <functional>
#include <string>
#include <sstream>
#include <complex>
#include <vector>		// V[i],  push_back(x), pop_back(), insert(index, x), erase(index), sort(v.begin(), v.end(), greater<int>())
#include <list>			// push_front(x), push_back(x), pop_front(), pop_back(), insert(index, x)
#include <queue>		// push(x), front(), pop()
#include <deque>
#include <stack>		// push(x), top(), pop()
#include <map>			// M[key],  insert(key, val), erase(key), find(key), 
#include <set>			// insert(key), erase(key), find(key)

using namespace std;
typedef long long ll;
// typedef pair<int, int> P;

#define PI 3.141592653589793)
#define MOD 1000000007
#define REP(i, n) for(int i = 0; i < n; i++)

int N, A, B;
int h[100001];

bool enough(int t) {
	ll cnt = 0LL;
	for (int i = 0; i < N; i++) {
		ll top = (ll)h[i] - (ll)B*t;
		if (top <= 0) continue;
		cnt += top / (A - B);
		if (top % (A - B)) cnt++;
	}
	return cnt <= t;
}

void solve() {
	cin >> N >> A >> B;
	for (int i = 0; i < N; i++) cin >> h[i];

	int lb = 0, ub = 1000000001;	
	while (ub - lb > 1) {
		int mid = (lb + ub) / 2;
		if (enough(mid)) ub = mid;
		else lb = mid;
	}
	cout << ub << endl;
}

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

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

using namespace std;

int main(){
    int n,k;
    cin >> n >> k;
    int p[n];
    for (int i = 0; i < n; i++){
        cin >> p[i];
    }
    sort(p,p+n);
    int ans = 0;
    for (int i = 0; i < k;i++){
        ans += p[i];
    }

    cout << ans <<endl;
}


Measured memory_bytes: 3592
// D - Road to Millionaire
#include <bits/stdc++.h>
using namespace std;

int main(){
	int N; cin>>N;
	int64_t yen = 1000, stock = 0;
	int now,nxt; cin>>now;
	while(--N){
		cin>>nxt;
		if(now < nxt){
			stock += yen / now;
			yen -= yen / now * now;
		}
		else{
			yen += stock * now;
			stock = 0;
		}
		now = nxt;
	}
	cout<< yen + stock * now <<endl;
}


Measured memory_bytes: 3604
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = System.Console.ReadLine().Trim().Split(' ');
            int iN = int.Parse(sS[0]);

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            Dictionary<int, int> dicRat = new Dictionary<int, int>() { { 1, 1800 }, { 2, 1600 }, { 3, 1400 }, { 4, 1200 }, { 5, 1000 }, { 6, 800 }, { 7, 600 }, { 8, 400 },  };
            int iOut = 0;
            for (int i = 1; i < 9; i++)
            {
                if (dicRat[i] <= iN) { iOut = i; break; }
            }

            // 出力
            System.Console.WriteLine("{0}", iOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

}


Measured memory_bytes: 27828
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let t = read::<String>();
    for ch in t.chars() {
        if ch == '?' {
            print!("D");
        } else {
            print!("{}", ch);
        }
    }
    println!("");
}

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


Measured memory_bytes: 2336
#include <bits/stdc++.h>
#define mem(ar,num) memset(ar,num,sizeof(ar))
#define me(ar) memset(ar,0,sizeof(ar))
#define lowbit(x) (x&(-x))
#define Pb push_back
#define  FI first
#define  SE second
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define IOS ios::sync_with_stdio(false)
#define DEBUG cout<<endl<<"DEBUG"<<endl; 
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const int    prime = 999983;
const int    INF = 0x7FFFFFFF;
const LL     INFF =0x7FFFFFFFFFFFFFFF;
const double pi = acos(-1.0);
const double inf = 1e18;
const double eps = 1e-6;
const LL     mod = 1e9 + 7;
LL qpow(LL a,LL b){LL s=1;while(b>0){if(b&1)s=s*a%mod;a=a*a%mod;b>>=1;}return s;}
LL gcd(LL a,LL b) {return b?gcd(b,a%b):a;}
int dr[2][4] = {1,-1,0,0,0,0,-1,1};
typedef pair<int,int> P;
const int maxn = 1e5+10;
LL dp[maxn][14];
char ar[maxn];
int main(void)
{
	cin>>ar;
	int n = strlen(ar);
	reverse(ar,ar+n);
	dp[n][0] = 1;
	for(int i = n-1;i >= 0; --i){
		if(ar[i] == '?'){
			for(int j  = 0;j <= 13; ++j){
				for(int k = 0;k <= 9;++k){
					(dp[i][(j*10+k)%13] += dp[i+1][j])%=mod;
				}
				
			}
		}
		else{

			// cout<<i<<endl;
			for(int j = 0;j <= 13; ++j){

				dp[i][(j*10+ar[i]-'0')%13] += dp[i+1][j];
				// cout<<i<<" "<<j<<" "<<(j+ar[i]-'0')%13<<" "<<dp[i+1][j]<<" "<<dp[i][(j+ar[i]-'0')%13]<<endl;
			}

			// cout<<dp[0][5]<<endl;
		}
	}
	LL ans = 0;
	ans = (ans+dp[0][5])%mod;
	cout<<ans<<endl;

    

   return 0;
}

Measured memory_bytes: 11264
#include<bits/stdc++.h>
using namespace std;
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
/*template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;

#define LOCAL 0
#define dbg(x) cout << #x << " is " << x << "\n"
#define gll(x) scanf("%d",&x)
#define gll2(x,y) scanf("%d%d",&x,&y)
#define gll3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define gllarr(arr,n) f(i,n) gll(arr[i]);
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,n) for(int i=n-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)

const ll mod = (ll)1e9 + 7;
const ll inf = (ll)1e16;
const ld eps = 1e-12;
const ll N = (int)1e5 + 5;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
inline ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
inline ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
inline ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    if (LOCAL) {
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\input.txt", "r", stdin);
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\output.txt", "w", stdout);
    }
    int n;
    cin>>n;
    int h[n];
    f(i, n) cin>>h[i];
    int dp[n];
    dp[0] = 0;
    rep(i, 1, n - 1){
        dp[i] = dp[i - 1] + abs(h[i] - h[i - 1]);
        if(i > 1) dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
    }
    cout<<dp[n - 1];
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int n;
vector <string> str;
string mem[15][15];

string con(string a,string b){
  int K=0;
  for(int i=0;i<a.size();i++){
    int j=i,k=0;
    while(a[j]&&b[k]&&a[j]==b[k]) j++,k++;
    if(!a[j]||!b[k])K=max(K,k);
  }
  return b.substr(K,b.size());
}

string solve(){
  string dp[1<<14][14];
  for(int i=0;i<n;i++) dp[1<<i][i]=str[i];
  
  for(int i=0;i<(1<<n);i++)
    for(int k=0;k<n;k++){
      if(dp[i][k]=="")continue;
      for(int j=0;j<n;j++){
	if((i&(1<<j)))continue;
	string nx=dp[i][k]+mem[k][j],&ndp=dp[i|1<<j][j];
	if(!ndp.size()||nx.size()<ndp.size()||(nx.size()==ndp.size()&&ndp>nx))ndp=nx;
      }
    }

  string res=dp[(1<<n)-1][0];
  for(int i=1;i<n;i++) {
    string a=dp[(1<<n)-1][i];
    if(res.size()>a.size()||(a.size()==res.size()&&res>a)) res=a;
  }
  return res;
}

int main(){
  
  while(cin>>n,n){
    str.resize(n);
    for(int i=0;i<n;i++)cin>>str[i];

    for(int i=0;i<n;i++)
      for(int j=0;j<n;j++)
	if(i!=j&&con(str[i],str[j])=="") str.erase(str.begin()+j),j=-1,i=0,n--;

    for(int i=0;i<n;i++)
      for(int j=0;j<n;j++) mem[i][j]=con(str[i],str[j]);

    cout<<solve()<<endl;
  }
  return 0;
}

Measured memory_bytes: 3444
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,ans;
signed main()
{
	ios::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<=n;i++)
		ans+=i*(n-i+1);
	for(int i=1;i<n;i++)
	{
		int u,v;
		cin>>u>>v;
		if(u>v)
			swap(u,v);
		ans-=u*(n-v+1);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3640
n = gets.to_i
i = gets.chomp.split(" ").map(&:to_i)
c=[]
if n%2==0
    (n/2).times{|t|
        c.push(i[n-(t*2+1)])
    }
    (n/2).times{|t|
        c.push(i[t*2])
    }
else
    (n/2+1).times{|t|
        c.push(i[n-t*2-1])
    }
    (n/2).times{|t|
        c.push(i[(t+1)*2-1])
    }
end
c.each{|item|
    print item," "
}

Measured memory_bytes: 27404
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

int main(void){

    int a, b, c;

    scanf("%d%d%d", &a, &b, &c);

    if(b-a == c-b){
        printf("YES\n");
    }else{
        printf("NO\n");
    }

    return 0;
}

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

int main(){
  
  int N;
  int ans=0;
  bool a=true;
  cin>>N;
  vector<int> test(N);
  for(int i=0;i<N;i++){
  cin>>test.at(i);
  }
 while(a){
  for(int i=0;i<N;i++){
  if(test.at(i)%2==1){
  a=false;
  }
  }
  if(a){
  
    for(int i=0;i<N;i++){
  test.at(i)=test.at(i)/2;}
    ans++;
    
  }
   
 }
  cout<<ans<<endl;
}

Measured memory_bytes: 3560
#include<stdio.h>
#define N 8
#define NF 1
#define F 0
int Q[N],ta[N],yo[N],nhi[15],nmg[15],fq[N][N];
//ta = col,yo=row,nhi=dpos,nmg=dneg
void putqueen(int);
void printboard();
int main(){
  int k,i,kin,qin;
  scanf("%d",&k);
  for(i=0;i<k;i++){
    scanf("%d%d",&kin,&qin);
    fq[kin][qin]=NF;
  }
  putqueen(0);
  return 0;
}
void printboard(){
  int i,j;
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(fq[i][j]==NF&&Q[i]!=j) return;
    }
  }
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(Q[i]!=j) printf(".");
      else printf("Q");
    }
    printf("\n");
  }
}
void putqueen(int i){
  int j;
  if(i==N){
    printboard();
    return;
  }
  for(j=0;j<N;j++){
    if(ta[j]!= NF && nhi[i+j]!=NF && nmg[i-j+N-1] != NF){
      Q[i]=j;
      ta[j]=nhi[i+j]=nmg[i-j+N-1]=NF;
      putqueen(i+1);
      Q[i]=ta[j]=nhi[i+j]=nmg[i-j+N-1]=F;
    }
  }
}


Measured memory_bytes: 2112
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#define print(n) std::cout << n << std::endl
#define print_no_indention(n) std::cout << n
using namespace std;


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

    int count = 0;

    for (int i = 0; i < s.size(); ++i) {
        if(i % 2 == 0){
            if(s.at(i) == 'L')count++;
        }else if(i % 2 != 0){
            if(s.at(i) == 'R')count++;
        }
    }
    if(count == 0)print("Yes");
    else print("No");
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <numeric>
using namespace std;

int main() {
    int n, k, q;
    cin >> n >> k >> q;
    vector<int> a(q);
    for (int i = 0; i < q; i++) cin >> a[i];

    vector<int> p(n, k-q);
    for (int i = 0; i < q; i++) {
        p[a[i]-1]++;
    }

    for (int i = 0; i < n; i++) {
        if (p[i] > 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}


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

int main(){
    int d, g;
    cin >> d >> g;
    vector <int> p(d);
    vector <int> c(d);
    
    for(int i = 0; i < d; ++i) cin >> p[i] >> c[i];

    int ans = 1e9;
    for(int mask = 0; mask < (1 << d); ++mask){
        int point = 0, num  = 0, rest_max = -1; 
        for(int i = 0; i < d; ++i){
            if(mask >> i & 1){
                point += 100 * (i + 1) * p[i] + c[i];
                num += p[i];
            }else{ 
                rest_max = i;
            }
        }
        if(point < g){
             int p1 = 100 * (rest_max + 1);
            int need = (g - point + p1 - 1)/p1;
            if(need >= p[rest_max])continue;
            num+= need;
        }
        ans = min(ans, num);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <map>
#include <sstream>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <iterator>
#include <stack>
#include <list>
using namespace std;
#define INF 100000000
typedef long long int lli;
typedef pair<int,int> P;
double dp[16][9];

void room(char c,int &x){
	switch(c){
		case 'A':
		x=0;
		break;
		
		case 'B':
		x=1;
		break;
		
		case 'C':
		x=2;
		break;
			
		case 'D':
		x=3;
		break;
		
		case 'E':
		x=4;
		break;
		
		case 'F':
		x=5;
		break;
		
		case 'G':
		x=6;
		break;
		
		case 'H':
		x=7;
		break;
		
		case 'I':
		x=8;
		break;
		
		default:
		break;
	}
}

int main(){
	int n;
	while(cin>>n&&n){
		char s,t,b;
		cin >> s >> t >> b;
		int sr,tr,br;
		room(s,sr);
		room(t,tr);
		room(b,br);
		for(int i=0; i<=n; ++i){
			for(int j=0; j<9; ++j){
				dp[i][j]=0;
			}
		}
		dp[0][sr]=1;
		for(int i=1; i<=n; ++i){
			for(int j=0; j<9; ++j){
				/*
				if(j!=br){
					switch(j){
						case 0:
						dp[i][j]+=(dp[i-1][1]/2+dp[i-1][3]/2+dp[i-1][0])/2;
						break;
						
						case 1:
						dp[i][j]+=(dp[i-1][0]+dp[i-1][4]+dp[i-1][2]+dp[i-1][1])/4;
						break;
						
						case 2:
						dp[i][j]+=(dp[i-1][1]/2+dp[i-1][5]/2+dp[i-1][2])/2;
						break;
						
						case 3:
						dp[i][j]+=(dp[i-1][0]+dp[i-1][4]+dp[i-1][6]+dp[i-1][3])/4;
						break;
					
						case 4:
						dp[i][j]+=(dp[i-1][1]+dp[i-1][5]+dp[i-1][7]+dp[i-1][3])/4;
						break;
					
						case 5:
						dp[i][j]+=(dp[i-1][2]+dp[i-1][4]+dp[i-1][8]+dp[i-1][5])/4;
						break;
						
						case 6:
						dp[i][j]+=(dp[i-1][3]/2+dp[i-1][7]/2+dp[i-1][6])/2;
						break;
						
						case 7:
						dp[i][j]+=(dp[i-1][6]+dp[i-1][4]/2+dp[i-1][8]/2+dp[i-1][7]/2)/2;
						break;
						
						case 8:
						dp[i][j]+=(dp[i-1][5]/2+dp[i-1][7]/2+dp[i-1][8])/2;
						break;
						
						default:
						break;
					}
				}
				*/
				if(j%3!=0&&j-1!=br){
					dp[i][j]+=dp[i-1][j-1]/4;
				} else {
						dp[i][j]+=dp[i-1][j]/4;
				}
				if(j>=3&&j-3!=br){
					dp[i][j]+=dp[i-1][j-3]/4;
				} else{
					dp[i][j]+=dp[i-1][j]/4;
				}
				if(j%3!=2&&j+1!=br){
					dp[i][j]+=dp[i-1][j+1]/4;
				} else {
					dp[i][j]+=dp[i-1][j]/4;
				}
				if(j<=5&&j+3!=br){
					dp[i][j]+=dp[i-1][j+3]/4;
				} else {
					dp[i][j]+=dp[i-1][j]/4;
				}
			}
		}
		printf("%.8f\n",dp[n][tr]);
		//cout << dp[n][tr] << "\n";
	}
	return 0;
}

Measured memory_bytes: 1188
#include<stdio.h>
 
int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    int a[n];
    for(int i=0;i<n;i++){
        scanf("%d", &a[i]);
    }
    for(int i=k;i<n;i++){
        (a[i-k]<a[i])?printf("Yes\n"):printf("No\n");
        }
    return 0;
}

Measured memory_bytes: 2440
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
//max=({});
//条件式が真ならwhileの中身を回し続ける

int g[15][15];
bool flag[1050000];
const int INF = 1001001001;
const int di[] = { -1,0,1,0 };
const int dj[] = { 0,-1,0,1 };

int main() {
	int n;
	cin >> n;
	rep(i, n)rep(j, n) {
		g[i][j] = -1;
	}
	rep(i, n) {
		int m;
		cin >> m;
		rep(j, m) {
			int a, x;
			cin >> a >> x;
			--a;
			g[i][a] = x;
		}
	}
	int ans = 0;
	rep(i, 1 << n) {
		vector<int>d(n);
		rep(j, n) {
			if (i >> j & 1) {
				d[j] = 1;
			}
		}
	    bool ok = true;
	    rep(j,n){
			if (d[j]) {
				rep(k, n) {
					if (g[j][k] == -1)continue;
					if (g[j][k] != d[k])ok = false;
				}
			}
		}
		if (ok)ans = max(ans, __builtin_popcount(i));
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define fast_io()                \
    ios::sync_with_stdio(false); \
    std::cin.tie(0);
#define mod 998244353
typedef long long ll;
typedef long double ld;
using namespace std;

int main()
{
    fast_io();
    string s;
    int cnt = 0, m = 0;
    cin >> s;
    for (int i = 0; i < s.length(); i++)
        if (s[i] == 'R')
            cnt++;
        else
        {
            m = max(m, cnt);
            cnt = 0;
        }

    cout << max(m, cnt);
    return 0;
}


Measured memory_bytes: 3192
from heapq import heappush, heappop

def main():
  h, w = map(int, input().split())
  mp = [[-1] + list(input()) + [-1] for _ in range(h)]
  mp.insert(0, [-1] * (w + 2))
  mp.append([-1] * (w + 2))
  
  que = []
  for y in range(1, h + 1):
    for x in range(1, w + 1):
      if "1" <= mp[y][x] <= "9":
        mp[y][x] = int(mp[y][x])
      elif mp[y][x] == ".":
        mp[y][x] = 0
        heappush(que, (0, x, y))
  
  vec = ((0, 1), (0, -1), (1, 1), (1, 0), (1, -1), (-1, 1), (-1, 0), (-1, -1))
  while que:
    turn, x, y = heappop(que)
    for dx, dy in vec:
      nx, ny = x + dx, y + dy
      if mp[ny][nx] > 0:
        mp[ny][nx] -= 1
        if mp[ny][nx] == 0:
          heappush(que, (turn + 1, nx, ny))
  
  print(turn)

main()


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

using namespace std;

typedef long long ll;
typedef long double ld;

#define pb push_back
#define mp make_pair

struct Edge {
    int a, b;
    ll c;
};

const int N = 5005;
const ll INF = 2e18 + 7;

int n, m;
ll p;
Edge edges[N];
vector<int> graph[N];
ll dist[N];
int last[N];
bool is[N];
bool used[N];

void bfs() {
    for (int i = 0; i < n; i++) {
        used[i] = false;
    }
    queue<int> q;
    for (int i = 0; i < n; i++) {
        if (last[i] >= n - 1) {
            q.push(i);
            used[i] = true;
        }
    }
    while (!q.empty()) {
        int v = q.front();
        q.pop();
        for (auto &u : graph[v]) {
            if (!used[u]) {
                q.push(u);
                used[u] = true;
            }
        }
    }
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
    cin >> n >> m >> p;
    for (int i = 0; i < m; i++) {
        cin >> edges[i].a >> edges[i].b >> edges[i].c;
        edges[i].a--;
        edges[i].b--;
        graph[edges[i].a].push_back(edges[i].b);
        edges[i].c -= p;
    }
    for (int i = 0; i < n; i++) {
        last[i] = -1;
        dist[i] = -INF;
    }
    dist[0] = 0;
    for (int t = 0; t < n; t++) {
        for (auto &edge : edges) {
            ll nw = dist[edge.a] + edge.c;
            if (nw > dist[edge.b] && dist[edge.a] != -INF) {
                dist[edge.b] = nw;
                last[edge.b] = t;
            }
        }
    }
    bfs();
    if (used[n - 1]) {
        cout << "-1\n";
    } else {
        cout << max(dist[n - 1], 0LL) << '\n';
    }
	return 0;
}


Measured memory_bytes: 640
#pragma comment(linker, "/STACK:256000000")

#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
#include <map>
#include <string>
#include <algorithm>
#include <iostream>
#include <memory.h>
#include <assert.h>
#include <functional>
#include <vector>
#include <string>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <deque>
#define _USE_MATH_DEFINES
#include <math.h>
#include <bitset>
#include <list>
#include <iomanip>      // std::setprecision
#include <random>
#include <array>

typedef std::mt19937 rng_type;
std::uniform_int_distribution<rng_type::result_type> udist(0, 1);

rng_type rng;

using namespace std;

FILE * in, *out;

#define fo(a,b,c) for(int a = ( b ); a < ( c ); ++ a )
#define fr(a,b) fo( a, 0, ( b ) )
#define fi(a) fr( i, ( a ) )
#define fj(a) fr( j, ( a ) )
#define fk(a) fr( k, ( a ) )
#define mp make_pair
#define pb push_back
#define all(v) (v).begin( ), (v).end( )
#define _(a,b) memset( a, b, sizeof( a ) )

#define LL long long

int ri() { int a; fscanf(in, "%d", &a); return a; }
double rf() { double a; fscanf(in, "%lf", &a); return a; }
char sbuf[100005];
string rstr()
{
	//fscanf(in, "%lf", sbuf); 
	char c;
	char * b = sbuf;
	while(c = fgetc(in))
	{
		if(c == '\n' || c == 255) break;
		*b++ = c;
	}
	*b = 0;
	return sbuf;
}


long long nod(long long a, long long b)
{
	if(a == 1 || b == 1) return 1;
	if(a == 0) return b;
	if(b == 0) return a;

	return nod(b%a, a);
}

vector<int> primes;
void calculatePrimes()
{
	primes.push_back(2);
	for(int i = 3; i < 100000; i += 2)
	{
		bool bFound = false;
		int m = (int)sqrt((float)i);
		for(int j = 1; j < primes.size() && !bFound && primes[j] <= m; j++)
			bFound = ((i%primes[j]) == 0);
		if(!bFound)
			primes.push_back(i);
	}
}

bool isPrime(int p)
{
	for(int i : primes)
		if(p != i && (p%i) == 0) return false;
	return true;
}


//	std::cout.setf(std::ios_base::fixed, std::ios_base::floatfield);
//	std::cout.precision(7);


void egcd(int a, int b, int &g, int &x, int &y)
{
	if(a == 0)
	{
		g = b;
		x = 0;
		y = 1;
		return;
	}
	egcd(b%a, a, g, y, x);
	x = x - (b / a)*y;
}

int modinv(int a, int m)
{
	int g = 0, x = 0, y = 0;
	egcd(a, m, g, x, y);
	return (x+m)%m;
}

long long modpow(int a, long long n, int p)
{
	long long res = 1;
	long long curp = (a%p);
	while(n)
	{
		if(n&1)
		{
			res = (res*curp)%p;
		}
		curp = (curp*curp)%p;
		n /= 2;
	}
	return res;
}


#define MODP  998244353 //1000000007
long long nf(int n)
{
	if(n == 1) return 1;
	return (n*nf(n-1))%MODP;
}

long long intpowmod(long long base, long long exp)
{
	if(exp == 0) return 1;
	if(exp == 1) return base;
	if((exp & 1) != 0) return (base * intpowmod((base * base)%MODP, exp / 2))%MODP;
	return intpowmod((base * base)%MODP, exp / 2);
}

#ifdef _WIN32
#define LOCAL_TEST
#endif

int main()
{
	long long n;
	cin >> n;
	vector<int> v(n);
	fi(n)
		cin >> v[i];


	vector<int> s(n);
	fi(n)
	{
		if(v[i] - i > 0 || (i>0 && v[i]-v[i-1] > 1))
		{
			cout << -1;
			return 0;
		}
		s[i-v[i]] = i;
	}

	long long len = 0;
	fi(n)
		if(s[i]) len += s[i]-i;



	cout << len;
}


Measured memory_bytes: 1792
#include<stdio.h>

int A[100001];
int partition(p, r)
{
  int x, i, j, tmp;
  x = A[r];
  i = p - 1;
  for(j = p; j <= r - 1; j++)
    {
      if(A[j] <= x)
	{
	  i = i + 1;
	  tmp = A[i];
	  A[i] = A[j];
	  A[j] = tmp;
	}
    }
  tmp = A[i+1];
  A[i+1] = A[r];
  A[r] = tmp;
  return i+1;
}
int main()
{
  int i, q, n;
  scanf("%d", &n);
  for(i = 1; i <= n; i++)
    {
      scanf("%d", &A[i]);
    }
  q = partition(1, n);
  for(i = 1; i < n; i++)
    {
      if(q == i)
	{
	  printf("[%d] ", A[i]);
	}
      else
	{
	  printf("%d ", A[i]);
	}
    }
  printf("%d\n", A[n]);
  return 0;
}



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

int main() {
  while (true) {
    int ans = 0;
    vector<int> vec(10);
    for (int i = 0; i < 10; i++) cin >> vec.at(i);
    if (vec.at(0) == 0) break;
    ans = vec.at(0);
    for (int i = 1; i < 10; i++) ans -= vec.at(i);
    cout << ans << endl;
  }
}


Measured memory_bytes: 3076