akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

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

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let (n,m) = get!(usize, usize);
    let xy = get!(usize, usize; m);

    let mut vec = vec![(1usize,false);n+1];
    vec[1].1 = true;
    for (x,y) in xy {
        if vec[x].1 {
            vec[y].0 += 1;
            vec[y].1 = true;
            vec[x].0 -= 1;
            if vec[x].0 == 0 {
                vec[x].1 = false;
            }
        } else {
            vec[y].0 += 1;
            vec[x].0 -= 1;
        }
    }
    println!("{}", vec.into_iter().filter(|e| e.1).count());        
}


Measured memory_bytes: 12540
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
#define forn(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define fore(i,b,a)for(int i=(b),_a=(a);i>=_a;i--)
#define rep(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define m_p make_pair
#define re return
#define pb push_back
#define si set<int>
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
#define mod 1000000007
#define INF 1000000007
#define x1 XZVJDFADSPFOE
#define y1 GASDIJSLDAEJF
#define x2 DFDAJKVOHKWIW
#define y2 PSFSAODSXVNMQ
#define LLINF 0x3f3f3f3f3f3f3f3fLL
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
ll quickpower(ll n,ll k){
	ll ans=1;
	while(k){
		if(k%2){
			ans*=n;
			ans%=mod;
		}
		n*=n;
		n%=mod;
		k/=2;
	}
	return ans;
}
string int_to_string(int n)
{
	string s="";
	while(n)
	{
		int now=n%10;
		s+=now+'0';
		n/=10;
	}
	reverse(s.begin(),s.end());
	return s;
}
int string_to_int(string s)
{
	int n=0;
	rep(i,s.size())
	{
		n*=10;
		n+=s[i]-'0';
	}
	return n;
}
int main()
{
	ios::sync_with_stdio(0);
	//think twice,code once
	int a,b,c;
	cin>>a>>b>>c;
	cout<<c<<" "<<a<<" "<<b<<endl;
	return 0;
}



Measured memory_bytes: 256
import numpy as np
N=int(input()) 
num=0
count=0
allcount=0
diglen=len(str(N)) #Nの桁数
#print(N%10,int(N/pow(10,diglen-1)),str(diglen))
table=np.zeros((10,10))

for i in range(N):
    num=str(i+1)
    b=int(num[len(num)-1])
    a=int(num[0])
    table[a][b]=table[a][b]+1
#print(table)
for i in range(10):
    for j in range(10):
        count=count+table[i][j]*table[j][i]
        
print(int(count))

Measured memory_bytes: 14432
#include<stdio.h>
#include<string.h>
#include<queue>
using namespace std;

struct AO
{
	int tx;
	int ty;
	int kx;
	int ky;
	int cnt;
};

queue<AO> Q;
AO TK,f;
int d[52][52];
int sa[51][51][51][51];

int main()
{
	int X,Y,F; //     tx ty kx ky
	int mv[4][4] ={{ 0,-1, 0, 1}, //???
				   { 0, 1, 0,-1}, //???
				   {-1, 0, 1, 0}, //???
				   { 1, 0,-1, 0}};//???
	while(1){
		F = 1;
		for(int i=0;i<52;i++){
			for(int j=0;j<52;j++){
				d[i][j] = 1;
			}
		}
		memset(sa,0,sizeof(sa));
		//printf("%d\n",d[0][0]);
		scanf("%d %d",&X,&Y);
		if(X == 0 && Y == 0) break;
		scanf("%d %d %d %d",&TK.tx,&TK.ty,&TK.kx,&TK.ky);
		sa[TK.ty][TK.tx][TK.ky][TK.kx] = 1;
		TK.cnt = 0;
		Q.push(TK);
		for(int i=1;i<=Y;i++){
			for(int j=1;j<=X;j++){
				scanf("%d",&d[i][j]);
			}
		}

		while(!Q.empty()){    //!Q.empty()
			TK = Q.front();
			Q.pop();
			//printf("?????? ??????:%d %d  ??????:%d %d\n",TK.tx,TK.ty,TK.kx,TK.ky);
			if(TK.cnt >= 100){
				break;
			}
			if(TK.tx == TK.kx && TK.ty == TK.ky){
				F = 0;
				break;
			}
			if(TK.cnt >= 100){
				break;
			}
			for(int i=0;i<4;i++){
				f.tx = TK.tx + mv[i][0];
				f.ty = TK.ty + mv[i][1];
				f.kx = TK.kx + mv[i][2];
				f.ky = TK.ky + mv[i][3];
				f.cnt = TK.cnt + 1;
				//printf("A");
				if(d[f.ty][f.tx] == 0 || d[f.ky][f.kx] == 0){
					if(d[f.ty][f.tx] == 1){
						f.tx = TK.tx;
						f.ty = TK.ty;
					}
					if(d[f.ky][f.kx] == 1){
						f.kx = TK.kx;
						f.ky = TK.ky;
					}
				}
				else if(d[f.ty][f.tx] == 1 && d[f.ky][f.kx] == 1){
					continue;
				}
				if(  sa[f.ty][f.tx][f.ky][f.kx] == 1 || f.tx < 0 || f.kx < 0 || f.ty < 0 || f.ky < 0 || f.tx > X || f.kx > X || f.ty > Y || f.ky > Y){
					continue;
				}
				sa[f.ty][f.tx][f.ky][f.kx] = 1;
				Q.push(f);
				//printf("??????%d %d\n?????? %d %d\n",f.tx,f.ty,f.kx,f.ky);
			}
			//printf("------------\n");
		}
		if(F==0)
			printf("%d\n",TK.cnt);
			//printf("%d %d %d %d\n",TK.tx,TK.ty,TK.kx,TK.ky);
		else
			printf("NA\n");
		while(!Q.empty())
			Q.pop();
	}
	return 0;
}

Measured memory_bytes: 27716
N,M = map(int, input().split())
a = []
for i in range(N):
    a.append(list(map(int, input().split())))

b = []
for i in range(M):
    b.append(list(map(int, input().split())))

def distance(i,j):
    return abs(a[i][0]-b[j][0]) + abs(a[i][1]-b[j][1])

m = []
for i in range(N):
    mdis = distance(i,0)
    mn = 0+1
    for j in range(1,M):
        if(mdis > distance(i,j)):
            mdis = distance(i,j)
            mn = j+1

    m.append(mn)

for i in range(N):
    print(m[i])

Measured memory_bytes: 3064
def z_algorithm(S):
    n = len(S)
    A = [0] * n
    A[0] = n
    L = 0
    R = 0
    # 過去にS[R]まで調べたとする
    for i in range(1, n):
        if R <= i:
            L = R = i
            while R < n and S[R] == S[R - L]:
                R += 1
            A[i] = R - L
        elif A[i - L] < R - i:
            A[i] = A[i - L]
        else:
            L = i
            while R < n and S[R] == S[R - L]:
                R += 1
            A[i] = R - L
    return A


def main():
    N = int(input())
    S = input()
    answer = 0
    for i in range(N):
        a = z_algorithm(S[i:])
        for j in range(1, N - i):
            cnt = min(j, a[j])
            if cnt > answer:
                answer = cnt

    print(answer)


if __name__ == '__main__':
    main()


Measured memory_bytes: 48220
s=input()
boo=True
if s[0]!='A':
    boo=False
C=0
for i in range(2,len(s)-1):
    if s[i]=='C':
        C+=1
if C>1 or C<1:
    boo=False
l=0
for i in range(len(s)):
    if s[i].lower()!=s[i]:
        l+=1
if l>2 or l<2:
    boo=False
if boo:
    print("AC")
else:
    print("WA")


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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int M, K;
    cin >> M >> K;
    if (K >= 1 << M) {
        cout << -1 << endl;
        return 0;
    }
    if (M == 0) {
        cout << 0 << ' ' << 0 << endl;
    }
    else if (M == 1) {
        if (K == 1) cout << -1 << endl;
        else cout << 1 << ' ' << 1 << ' ' << 0 << ' ' << 0 << endl;
    }
    else {
        for (int i = 0; i < (1 << M); i++) {
            if (i == K) continue;
            cout << i << ' ';
        }
        cout << K << ' ';
        for (int i = (1 << M) - 1; i >= 0; i--) {
            if (i == K) continue;
            cout << i << ' ';
        }
        cout << K << endl;
    }
    return 0;
}

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

/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
*/

using namespace std;

#if DEBUG && !ONLINE_JUDGE
    #include "debug.h"
#else
    #define debug(...)
#endif

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<vector<int> > vvi;
typedef vector<vector<ii> > vvii;

#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
//#define fill(a,x) memset(a,x,sizeof(a))
#define ff first
#define ss second
#define trav(a, x) for(auto& a : x) 
#define FOR(i,a,b) for(int i = a; i<=b; ++i)
#define NFOR(i,a,b) for(int i = a; i>=b; --i)
const ll INF = 1e18;
const int mod =  998244353;
const int N = 1e5;
ll gcd(ll a,ll b){if (a==0) return b;return gcd(b%a,a);}
ll lcm(ll a,ll b){return a*(b/gcd(a,b));}
ll Abs(ll a){if(a>0)return a;return -a;}
ll Ceil(ll a,ll b){if(a%b==0)return a/b;else return a/b+1;}
double Abs(double a){if(a>0)return a;return -a;}

//*X.find_by_order(2) element at index=2
//X.order_of_key(1) how many elements strictly less than 1

/*
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,
    tree_order_statistics_node_update>;
*/

inline int pow_(ll x, ll y,ll p){
  int r = 1; while(y){if(y & 1) r = r * x % p; y >>= 1; x = x * x % p;} return r;
}
inline int inv_(int x){return pow_(x, mod - 2, mod);}
inline int add(int a, int b){a += b; if(a >= mod) a -= mod; return a;}
inline int mul(int a, int b){return a * 1LL * b % mod;}
inline int sub(int a, int b){a -= b; if(a < 0) a += mod; return a;}


int main()
{
	#ifdef LOCAL_TEST
    freopen("in.txt","r",stdin);
    //freopen("out.txt", "w", stdout);
    #else
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    #endif
    ll n,W;
    cin>>n>>W;
    ll w[100005] = {0};
    ll v[100005] = {0};
    ll dp[105][100005] = {0};
    for(int i=1;i<=n;i++)
    {
    	cin>>w[i]>>v[i];
    }
    
    for(int i=1;i<=n;i++)
    {
    	for(int j=1;j<=W;j++)
    	{
    		if(w[i] <= j)
    		{
    			dp[i][j] = max(dp[i-1][j-w[i]]+v[i],dp[i-1][j]);
    		}
    		else
    		{
    			dp[i][j] = dp[i-1][j];
    		}
    	}
    }

    cout << dp[n][W] << '\n';
	return 0;
}

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

typedef long long int ll;
const int maxn = 2e5 + 10;
ll cnt[maxn],a[maxn];
void solved(){
	ll n;cin>>n;
	ll M = 0;
	for(ll i = 1; i <= n; i++){
		cin>>a[i],cnt[a[i]]++;M = max(M,a[i]);
	}
	ll ans = 0;
	for(ll i = 1;i <= M;i++){
		if(cnt[i] > 0)
		ans = ans + (cnt[i] * (cnt[i] - 1))/2; 
	}
	for(ll i = 1; i <= n; i++){
		cout<<(ans - cnt[a[i]] + 1)<<endl;
	}
}
int main(){
	solved();
	return 0;
} 

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

using namespace std;

int main() {

    int n,a,b;
    cin >> n >> a >> b;
    
    int d = n;
    while(n < a) n += d;

    cout << (a <= n and n <= b ? "OK" : "NG") << "\n";
    return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define crap ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef long long int ll;
typedef unsigned long long ull;
typedef std::vector<int> vi;
typedef std::vector<ll> vll;
typedef std::vector<vi > vvi;
typedef std::vector<vll > vvll;
typedef std::pair<int,int> ii;
typedef std::pair< ll, ll > lp;
typedef std::vector<ii> vii;
typedef std::vector<vii > vvii;


#define pb push_back 
#define PB pop_back
#define pf push_front
#define PF pop_front
#define mp make_pair
#define ub(a,b) upper_bound(all(a),b)
#define lb(a,b) lower_bound(all(a),b)
#define bs(a,b) binary_search(all(a),b)
#define mem(a,b) memset(a,b,sizeof(a))
#define in(a,n) f(i,0,n-1)cin>>a[i]
#define in1(a,n) f(i,1,n)cin>>a[i]
#define out(a,n) f(i,0,n-1)cout<<fixed<<setprecision(20)<<a[i]<<" ";cout<<"\n"
#define ff first
#define ss second
#define f(i,a,b) for (int i=a;i<=b;i++)
#define rf(i,a,b) for(int i=a;i>=b;i--)
#define rep(i,n) f(i,0,n-1)
#define clr(a) (a).clear()
#define rz resize
#define sqr(a) ((a) * (a))
#define sz(a) int((a).size())
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin() ,(a).rend()
#define endl '\n'

const int mod=(int)1e9+7;

ll dp[1005][1005];

int main(int argc, char const *argv[])
{
	crap;
	int n, m;
	cin>>n>>m;
	string x[n];
	rep(i,n)	
		cin>>x[i];

	dp[0][0]=1;
	int fl=1;
	f(i,1,m-1)
	{
		if (x[0][i]=='.')
		{
			if (fl)dp[0][i]=1;
		}
		else
		{
			fl=0;
		}
	}
	fl=1;
	f(i,1,n-1)
	{
		if (x[i][0]=='.')
		{
			if (fl)dp[i][0]=1;
		}
		else
		{
			fl=0;
		}
	}

	f(i,1,n-1)
	{
		f(j,1,m-1)
		{
			if (x[i][j]=='#')continue;

			if (x[i-1][j]=='.')
				dp[i][j]=(dp[i][j]+dp[i-1][j])%mod;

			if (x[i][j-1]=='.')
				dp[i][j]=(dp[i][j]+dp[i][j-1])%mod;
		}
	}

	cout<<dp[n-1][m-1]<<endl;
	return 0;
}

Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll n,w;
ll wei[110];
ll val[110];
ll dp[500010];

int main(){
	scanf("%lld%lld",&n,&w);
	for (int i=1;i<=n;i++) scanf("%lld%lld",&wei[i],&val[i]);
	for (int i=1;i<=n;i++){
		int weight=wei[i];
		for (int j=w;j>=weight;j--){
			dp[j]=max(dp[j],dp[j-weight]+val[i]);
		}
	}
	printf("%lld",dp[w]);
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int n;
	cin>>n;
	int a[n+1],sum=0;
	for(int i=1; i<=n; i++)
	{
		cin>>a[i];
	}
	for (int i=1; i<n; i++)
	{
		for (int j=i+1; j<=n; j++)
		{
			sum+=a[i]*a[j];
		}
	}
	cout<<sum;
	return 0;
}


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

long long BinarySearch(long long l, long long r, function<bool(long long)> f) {
  /* O(log(r-l) * O(f)) */
  /* Find the boundary T and F that satisfies (f(T)==true && f(F)==false && abs(T-F)==1). */
  bool fl = f(l), fr = f(r);
  assert(fl!=fr);
  long long &T = fl ? l : r, &F = fr ? l : r;
  while(r-l>1) {
    long long m = l + (r-l) / 2;
    if(f(m)) T = m;
    else F = m;
  }
  return T;
}

double BinarySearch(double l, double r, int iteration, function<bool(double)> f) {
  /* O(iteration * O(f)) */
  /* Find the boundary T and F that satisfies (f(T)==true && f(F)==false) for (iteration) times. */
  bool fl = f(l), fr = f(r);
  assert(fl!=fr);
  double &T = fl ? l : r, &F = fr ? l : r;
  while(iteration--) {
    double m = l + (r-l) / 2;
    if(f(m)) T = m;
    else F = m;
  }
  return T;
}

signed main() {
#if 1 // https://atcoder.jp/contests/abc174/tasks/abc174_e
  int n,k; cin >> n >>k;
  vector<int> a(n);
  for(int i=0; i<n; ++i) cin >> a[i];

  auto f = [&](long long x) {
    if(x==0) return false;
    int kk = k;
    for(int i=0; i<n; ++i) kk -= (a[i] + x-1) / x - 1;
    return kk >= 0;
  };

  cout << BinarySearch(0, *max_element(a.begin(),a.end()), f) << endl;
#elif 1 // https://atcoder.jp/contests/arc050/tasks/arc050_b
  long long r,b; cin >> r >> b;
  int x,y; cin >> x >> y;

  auto f = [&](long long k) {
    return r>=k && b>=k && ((r-k) / (x-1) + (b-k) / (y-1) >= k);
  };

  cout << BinarySearch(0, max(r,b)+1, f) << endl;
#else // https://atcoder.jp/contests/abc034/tasks/abc034_d
  int n,k; cin >> n >> k;
  vector<double> w(n), p(n);
  for(int i=0; i<n; ++i) cin >> w[i] >> p[i];

  auto f = [&](double x) {
    vector<double> v(n);
    for(int i=0; i<n; ++i) v[i] = w[i] * (p[i] - x);
    sort(v.begin(), v.end(), greater<double>());
    double sum = accumulate(v.begin(), v.begin()+k, 0.0);
    return sum > 0;
  };

  cout << setprecision(12) << BinarySearch(0.0, 100.0, 100, f) << endl;
#endif
}


Measured memory_bytes: 3952
#include <bits/stdc++.h>
using namespace std;
void solve() {
   long long a,b,c,k; cin>>a>>b>>c>>k;
   if(k<=a + b) {
       cout<<min(k,a);
   }
   else {
       cout<<a - (k - a - b);
   }
}
int main() {
    int t; t = 1;
    while(t--) {
        solve();
    }
}


Measured memory_bytes: 3556
#: Author - Soumya Saurav
import sys,io,os,time
from collections import defaultdict
from collections import Counter
from collections import deque
from itertools import combinations
from itertools import permutations
import bisect,math,heapq
alphabet = "abcdefghijklmnopqrstuvwxyz"

input = sys.stdin.readline

########################################

# #n = int(input())
n = int(input()) 
ans = (10**n) - 2*(9**n) + (8**n) 
print(ans%(10**9+7))





'''
# Wrap solution for more recursion depth
#submit as python3
import collections,sys,threading
sys.setrecursionlimit(10**9)
threading.stack_size(10**8)



threading.Thread(target=solve).start()
'''


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

#define INF ((1<<30)-1)  //int32_t
#define MOD 1000000007
#define MOD2  

#define all(a)  (a).begin(),(a).end()

#define mkp make_pair
#define pb push_back

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;



int main(){
    bool flag=true;
    ll ans=0,sum=0;

    int n,k;
    cin >>n>>k;
    int a[n],maxa=0;
    vector<ll> cds;

    for (int i = 0; i < n; i++){
        cin >>a[i];
        sum += a[i];
        maxa = max(maxa,a[i]);
    }
    
    for (ll i = 1; i*i <= sum; i++){
        if(sum % i == 0){
            cds.push_back(i);
            cds.push_back(sum/i);
        }
    }
    
    int mod[n]={};
    ll modsum,opr;
    
    for (int i = 0; i < cds.size(); ++i){
        modsum=0;

        for (int j = 0;j < n; ++j){
            mod[j]=a[j]%cds[i];
            modsum += mod[j];
        }
        sort(mod,mod+n,greater<int>());

        int p = modsum/cds[i];
        opr=0;
        for (int k = 0; k < p; ++k){
            opr += cds[i]-mod[k];
        }
        if(opr <= k)ans = max(ans,cds[i]);
    }

    //cout <<fixed<<setprecision(16)<< << endl;
    cout << ans << endl;

    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


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

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

Measured memory_bytes: 3632
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
import java.util.Stack;

class Main {

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

    void compute() {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int[] imos = new int[s.length() + 1];
        for (int i = 1; i < s.length() + 1; i++) {
            imos[i] = imos[i - 1] ^ 1 << s.charAt(i - 1) - 'a';
        }
        int[] kaibuns = new int[27];
        for (int i = 0; i < 26; i++) {
            kaibuns[i + 1] = 1 << i;
        }
        int[] dp = new int[1 << 26];
        Arrays.fill(dp, 1 << 26);
        dp[0] = 0;
        for (int i = 1; i < s.length() + 1; i++) {
            int min = 1 << 26;
            for (int j = 0; j < 27; j++) {
                min = Math.min(min, dp[imos[i] ^ kaibuns[j]] + 1);
            }
            dp[imos[i]] = Math.min(min, dp[imos[i]]);
            if (i == s.length()) {
                System.out.println(min);
            }
        }
    }
}


Measured memory_bytes: 293584
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define Vd vector<double>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b?gcd(b,a%b):a;} //最小公倍数

// デフォルト変数定義
int n,m,a,b,c,x,y,z;
double d,e,f;
char s,t;
//

signed main() {
  RAPID;
  IN(s);
  if(s=='A') OUT('T');
  if(s=='C') OUT('G');
  if(s=='G') OUT('C');
  if(s=='T') OUT('A');
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;



int main(){
  ll N;
  cin>>N;
  vector<ll> A(N);
  ll Now=1000;
  rep(i, N){
    cin>>A[i];
    if(i>0){
      if(A[i-1]<A[i]){
        ll Tax=Now/A[i-1];
        ll Amari=Now-A[i-1]*Tax;
        Now=Amari+Tax*A[i];

      }
    }
  }
  cout<<Now<<endl;
  
} 

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i < (int)(n); i++)
using ll = long long;
using namespace std;

int main() {
	string s;
	cin >> s;
	bool ans = true;
	char tmp;
	rep(i, 4) {
		tmp = s[i];
		if (s[i + 1] == tmp)ans = false;
	}

	if (ans) {
		cout << "Good" << endl;
	}
	else {
		cout << "Bad" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string S;
  cin >> S;
  if(S.at(0) == S.at(1) && S.at(0) != S.at(2)){
    if(S.at(2) == S.at(3)){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
  }
  else if(S.at(0) == S.at(2) && S.at(0) != S.at(1)){
    if(S.at(1) == S.at(3)){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
  }
  else if(S.at(0) == S.at(3) && S.at(0) != S.at(1)){
    if(S.at(1) == S.at(2)){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
// 2012/05/21 Tazoe

#include <iostream>
using namespace std;

void DFS(const int M[30][30], int D[30][30], int Y, int X, int C)
{
	D[Y][X] = C;

	if(M[Y][X]%2==0&&D[Y-1][X]>C+1)
		DFS(M, D, Y-1, X, C+1);

	if(M[Y][X]/2%2==0&&D[Y+1][X]>C+1)
		DFS(M, D, Y+1, X, C+1);

	if(M[Y][X]/4%2==0&&D[Y][X-1]>C+1)
		DFS(M, D, Y, X-1, C+1);

	if(M[Y][X]/8%2==0&&D[Y][X+1]>C+1)
		DFS(M, D, Y, X+1, C+1);
}

int main()
{
	while(true){
		int w, h;
		cin >> w >> h;

		if(w==0&&h==0)
			break;

		int M[30][30];
		for(int y=0; y<h; y++){
			for(int x=0; x<w; x++){
				M[y][x] = 0;
				if(y==0)
					M[y][x] += 1;
				if(y==h-1)
					M[y][x] += 2;
				if(x==0)
					M[y][x] += 4;
				if(x==w-1)
					M[y][x] += 8;
			}
		}

		for(int i=0; i<2*h-1; i++){
			if(i%2==0){
				for(int j=0; j<w-1; j++){
					int w;
					cin >> w;

					if(w==1){
						M[i/2][j]   += 8;
						M[i/2][j+1] += 4;
					}
				}
			}
			else{
				for(int j=0; j<w; j++){
					int w;
					cin >> w;

					if(w==1){
						M[i/2][j]   += 2;
						M[i/2+1][j] += 1;
					}
				}
			}
		}

		int D[30][30];
		for(int y=0; y<h; y++){
			for(int x=0; x<w; x++){
				D[y][x] = 1000;
			}
		}
		D[0][0] = 1;

		DFS(M, D, 0, 0, 1);

		if(D[h-1][w-1]!=1000){
			cout << D[h-1][w-1] << endl;
		}
		else{
			cout << 0 << endl;
		}

/*
		for(int y=0; y<h; y++){
			for(int x=0; x<w; x++){
				cout << hex << M[y][x];
			}
			cout << endl;
		}
*/
	}

	return 0;
}

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

using namespace std;


int main(){
    long N;
    cin >> N;
    long p=N-1;
    long i=1;
    while(pow(26L, i) <= p){
        p -= pow(26L, i);
        i++;
    }
    for(long k=0;k<i;k++){
        long ka = p / pow(26L, i-1-k);
        cout << (char)('a'+ka);
        p -= ka * pow(26L, i-1-k);
    }
    cout << endl;


    return 0;
}


Measured memory_bytes: 4064
#include <string>
#include <iostream>
#include <stdio.h>
#include <vector>

using namespace std;

void swap(vector<int> &arr, int b, int e, int t) {
  int tmp;
  for (int k = 0; k < e - b; k++) {
    tmp = arr[b + k];
    arr[b + k] = arr[t + k];
    arr[t + k] = tmp;
  }
}

int main() {
  ios::sync_with_stdio(false);

  int len_array;
  cin >> len_array;

  vector<int> v(len_array);

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

  int num_query;
  cin >> num_query;
  int b, e, t;
  for (int i = 0; i < num_query; i++) {
    cin >> b >> e >> t;
    swap(v, b, e, t);
  }

  cout << v[0];
  for (int i = 1; i < len_array; i++) {
    cout << " " << v[i];
  }
  cout << endl;
}




Measured memory_bytes: 3128
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k;
    cin>>n>>k;
    k=min(k,n-1);
    int h[n];
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    int dp[n];
    dp[0]=0;
    for(int i=0;i<k;i++){
        if(i){
            dp[i]=dp[i-1]+abs(h[i]-h[i-1]);
        }
        for(int j=2;j<=i;j++){
            dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
        }
    }
    for(int i=k;i<n;i++){
        dp[i]=dp[i-1]+abs(h[i]-h[i-1]);
        for(int j=2;j<=k;j++){
            dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
        }
    }
    cout << dp[n-1]<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
int main(void){
	int a;
	int b;
	int wari;
	int amari;
	double syousuu;

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

	wari = a / b;
	amari = a%b;
	syousuu = (double)a / (double)b;
	printf("%d %d %f\n",wari,amari,syousuu);
	return 0;
	}

Measured memory_bytes: 636
#include<iostream>

using namespace std;

int a[10];

bool check(){
  static int c[][3]={
    {0,1,2},
    {3,4,5},
    {6,7,8},
    {0,3,6},
    {1,4,7},
    {2,5,8},
    {0,4,8},
    {2,4,6},
  };
  int r=-1;
  bool f=false;
  for(int j=0;j<8;j++){
    if(a[c[j][0]]==0||a[c[j][1]]==0||a[c[j][2]]==0)continue;
    int s=(a[c[j][0]]+a[c[j][1]]+a[c[j][2]])%a[9];
    if(r==-1){
      r=s;
    }else if(r!=s){
      f=true;
    }
  }
  return !f;
}

int dfs(int x,int u){
  if(x<0)return check();
  if(a[x])return dfs(x-1,u);
  int s=0;
  for(int i=1;i<=10;i++){
    if(u>>i&1)continue;
    a[x]=i;
    if(check()){
      s+=dfs(x-1,u|1<<i);
    }
    a[x]=0;
  }
  return s;
}

int main(){
  for(;;){
    int u=0;
    for(auto &e:a){
      cin>>e;
      u|=1<<e;
    }
    if(a[0]==-1)break;
    cout<<dfs(9,u)<<endl;
  }
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
using ll = long long;

int main(){
    int N,K; cin >> N >> K;
    vector<ll> x(N), y(N);
    vector<pair<ll,ll> > P(N);
    for(int i=0;i<N;i++){
        cin >> x[i] >> y[i];
        P[i] = make_pair(x[i], y[i]);
    }
    
    sort(x.begin(), x.end());
    sort(y.begin(), y.end());

    unsigned long long ans = 1ull * (x[N-1] - x[0]) * (y[N-1] - y[0]);

    for(int i1=0;i1<N;i1++){
        for(int i2=i1+1;i2<N;i2++){
            for(int j1=0;j1<N;j1++){
                for(int j2=j1+1;j2<N;j2++){
                    int x1 = x[i1], x2 = x[i2];
                    int y1 = y[j1], y2 = y[j2];
                    unsigned long long area = 1ull * (x2-x1) * (y2-y1);
                    int cnt = 0;
                    for(int i=0;i<N;i++){
                        if(x1 <= P[i].first && P[i].first <= x2 && y1 <= P[i].second && P[i].second <= y2) cnt++;
                    }
                    if(cnt >= K){
                        ans = min(ans, area);
                    }
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <string.h>
#include <ctype.h>
#include <algorithm>

using namespace std;

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  if(a == b) cout << c << endl;
  if(b == c) cout << a << endl;
  if(a == c) cout << b << endl;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pii pair<int, int>
#define fr(n) for (int i = 0; i < n; i++)
#define fr1(n) for (int i = 1; i <= n; i++)
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    int n, s = 0, a[328] = {}, b[328] = {}, d[328][90328] = {};
    d[0][0] = 1;
    cin >> n;
    //fr1(n) a[i] = 300;
    fr1(n) cin >> a[i];
    fr1(n) s += a[i];
    //cout << s << ' ';
    sort(a + 1, a + n + 1);
    fr1(n) b[i] = b[i - 1] + a[i];
    fr1(n) {
        int b[328] = {};
        for (int j = 1; j <= i; j++) b[j] = a[i - j + 1];
        for (int j = 1; j <= i; j++) b[j] += b[j - 1];
        for (int k = i; k; k--) {
            for (int j = b[k]; j >= a[i]; j--) {
                d[k][j] += d[k - 1][j - a[i]];
                if (d[k][j] >= 998244353) d[k][j] -= 998244353;
            }
        }
    }
    //for (int j = 0; j <= n; j++) {fr(10) cout << d[j][i] << ' '; cout << '\n';}
    ll c[328] = {};
    fr1(n) for (int j = (s + 1) / 2; j <= 90004; j++) c[i] = (c[i] + d[i][j]) % 998244353;
    ll e = 0;
    if (s % 2 == 0) {
        //fr1(n) cout << d[i][s / 2] << ' '; cout << '\n';
        fr1(n) e = (e + d[i][s / 2]) % 998244353;
    }
    e = e * 3 % 998244353;
    //fr(n + 1) cout << c[i] << ' '; cout << e << '\n';
    ll z = 0, p[328] = {1};
    fr1(n) p[i] = p[i - 1] * 2 % 998244353;
    fr1(n) {
        z += c[i] * p[n - i] * 3 % 998244353;
        //cout << c[i] << ' ' << p[n - i] << '\n';
    }
    z %= 998244353;
    ll y = 1;
    fr1(n) y = y * 3 % 998244353;
    z = y - z;
    if (z < 0) z += 998244353;
    z += e;
    z %= 998244353;
    cout << z;
}


Measured memory_bytes: 115968
#include<bits/stdc++.h>
using namespace std;
#define ll long long                                    // long long省略
#define pb push_back                                    // push_back省略
#define mp make_pair                                    // make_pair省略
#define fi first                                        // first省略
#define se second                                       // second省略
#define itn int                                         // int誤字保険
#define count cout                                      // cout誤字保険
#define vecotr vector                                   // vector誤字保険
#define ednl endl                                       // endl誤字保険
#define opt() cin.tie(0); ios::sync_with_stdio(false)   // 入出力速度改善

#define rep(i,l,r) for(ll i=(l);i<(r);i++)               // 範囲[l, r)で刻み1のfor文(順方向)
#define repp(i,l,r,k) for(ll i=(l);i<(r);i+=(k))         // 範囲[l, r)で刻みkのfor文(順方向)
#define rrep(i,l,r) for(ll i=(r-1);i>=(l);i--)           // 範囲[l, r)で刻み1のfor文(逆方向)
#define rrepp(i,l,r,k) for(ll i=(r-1);i>=(l);i-=(k))     // 範囲[l, r)で刻みkのfor文(逆方向)
#define all(x) (x).begin(), (x).end()                   // vectorのポインタ位置指定用
#define max(p,q)((p)>(q)?(p):(q))                       // max拡張
#define min(p,q)((p)<(q)?(p):(q))                       // min拡張
#define bit(n,m)(((n)>>(m))&1)                          // 変数nのm番目のbitを取り出す

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

int dy[]={0, 1, 0, -1};                                 // 4方向近傍
int dx[]={1, 0, -1, 0};                                 // 4方向近傍


int main(){
	ll n;cin>>n;
    ll a[n],b[n];rep(i,0,n)cin>>a[i];rep(i,0,n)cin>>b[i];
    //どうしても達成できない場合
    ll s1=0,s2=0;
    rep(i,0,n){
        s1 += a[i];
        s2 += b[i];
    }
    if(s1 < s2){
        cout << -1 << endl;
        return 0;
    }
    //何もしなくても達成できている場合
    bool f=true;
    rep(i,0,n)if(a[i]<b[i])f=false;
    if(f){
        cout << 0 << endl;
        return 0;
    }
    // 上記以外
    // a[i]-b[i]で0以上なら触らなくてよい
    vector<ll> c;
    rep(i,0,n)c.pb(a[i]-b[i]);
    sort(all(c));
    ll cnt=0,sum=0;
    rep(i,0,n){
        if(c[i] >= 0)break;
        sum+=c[i];cnt++;
    }
    ll tmp = 0,ccc=0;
    vector<pair<ll,ll>> p;
    rrep(i,0,n){
        if(c[i] < 0)break;
        tmp += c[i];
        ccc++;
        p.pb(mp(tmp,ccc));
    }
    rep(i,0,p.size()){
        if(p[i].fi + sum >= 0){
            cout << cnt + p[i].se << endl;
            return 0;
        }
    }



}


Measured memory_bytes: 4464
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
  int N;
  cin >> N;
  int f = 0;
  int g = N;
  int x,y;
  
  for (int i = 0; i < 9; i++) {
    x = std::pow(10, 8-i);
    y = g / x;
    f += y;
    g -= x*y;
  }
  
  int judge = N % f;
  
  if (judge == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
 
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <fstream>
#include <set>
#include <utility>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <numeric>
#include <sstream>
#include <list>
#include <map>
#include <functional>
#include <iterator>

#define rep(i,p,n) for(int i=(int)p;i<(int)n;i++)
#define repp(i,p,n) for(int i=(int)p;i>=(int)n;i--)
#define Sort(x) sort(x.begin(),x.end());
#define PSort(x) sort(begin(x), end(x), pairCompare)
#define ll long long
#define INF 2000000000

using namespace std;

int main() {
	int n;
	cin >> n;
	int even = 1, all = 1;
	rep(i, 0, n) {
		int x;
		cin >> x;
		if (x % 2 == 0) even *=2;
		all *= 3;
	}
	cout << all - even << endl;

	return 0;
}



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


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin>>n;
    int a=n%10;
    switch(a){
    case 2:case 4:case 5:case 7:case 9:{cout<<"hon";break;}
    case 0:case 1:case 6: case 8:{cout<<"pon";break;}
    case 3:{cout<<"bon";break;}
    }

return 0;
}


Measured memory_bytes: 3600
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(){
int N,M; cin >> N >> M;
  vector<int> switches(N,0);
 
  for(int i = 0; i < M; i++){
int k ; cin >> k;
    for(int j = 0; j < k ; j++){
      int s; cin >> s; s--;
      switches[s] |= 1 << i;}}
  
  int cnt = 0; int p = 0;
  for(int i = 0; i < M; i++){ int q = 0; cin >> q; p |= q << i;}
                             
  
  for(int i = 0; i < (1 << N); i++){
    int l = 0; 
    for(int j = 0; j < N; j++){
      if( (i >> j) & 1){ l  ^= switches[j];}}
      
      if( l == p){ cnt++;}}
    
    cout << cnt << endl; return 0;}
      

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

int dist[2001];

vector<int> edge[2001];

int u[2001],v[2001];
int n,k;

int check_e(int x,int y){
	memset(dist,-1,sizeof dist);
	dist[x]=dist[y]=0;
	queue<int> q;
	q.push(x);q.push(y);
	while(!q.empty()){
		int now=q.front();q.pop();
		if(dist[now]==k/2)	continue;
		for(int it:edge[now])
			if(dist[it]==-1){
				dist[it]=dist[now]+1;
				q.push(it);
			}
	}
	int res=0;
	for(int i=1;i<=n;i++)
		res+=(dist[i]!=-1);
	return res;
}

int check_v(int x){
	memset(dist,-1,sizeof dist);
	dist[x]=0;
	queue<int> q;
	q.push(x);
	while(!q.empty()){
		int now=q.front();q.pop();
		if(dist[now]==k/2)	continue;
		for(int it:edge[now])
			if(dist[it]==-1){
				dist[it]=dist[now]+1;
				q.push(it);
			}
	}
	int res=0;
	for(int i=1;i<=n;i++)
		res+=(dist[i]!=-1);
	return res;
	
}


int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin>>n>>k;
	for(int i=1;i<n;i++){
		cin>>u[i]>>v[i];
		edge[u[i]].emplace_back(v[i]);
		edge[v[i]].emplace_back(u[i]);
	}
	int ans=0;
	if(k&1)
		for(int i=1;i<n;i++)
			ans=max(ans,check_e(u[i],v[i]));
	else
		for(int i=1;i<=n;i++)
			ans=max(ans,check_v(i));
	cout<<n-ans<<endl;
}


Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;

namespace Atcoder
{
    class Program
    {
        static StreamWriter sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
        static void Main(string[] args)
        {
            try
            {
                SetOut(sw);
                Solve.Answer();
                Out.Flush();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
                Out.Flush();
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            var S = ReadLine();
            int b_cnt = 0;
            long ans = 0;
            for (int i = 0; i < S.Length; i++)
            {
                if (S[i] == 'B') b_cnt++;
                else ans += b_cnt;
            }
            WriteLine(ans);
        }
    }

    public class IO
    {
        #region Input
        public static int RInt => int.Parse(ReadLine());
        public static long RLong => long.Parse(ReadLine());
        public static double RDouble => double.Parse(ReadLine());

        public static string[] RSString => ReadLine().Split();
        public static int[] RSInt => ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        public static long[] RSLong => ReadLine().Split().Select(s => long.Parse(s)).ToArray();
        public static double[] RSDouble => ReadLine().Split().Select(s => double.Parse(s)).ToArray();
        #endregion

        #region Output
        public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
        public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");
        public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES" : "NO");
        #endregion
    }

    public class Mod
    {
        #region
        private readonly static long M = 1000000007;

        public static long Add(long a, long b) => (a * b) % M;
        public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
        public static long Multi(long a, long b) => (a * b) % M;
        #endregion
    }
}

Measured memory_bytes: 17484
import java.io.{BufferedReader, InputStream, InputStreamReader}
import java.util.StringTokenizer

import scala.collection.mutable
import scala.util.Sorting
import math.{abs, max, min}

object Main {
  val MOD = 1000000007
  def solve(): Unit = {
    val sc = new InputReader(System.in)
    val N = sc.nextInt()

    var L: Long = 0
    val left = mutable.PriorityQueue[Long]()(Ordering[Long].reverse)
    (0 until N) foreach { _ =>
      val a = sc.nextLong()
      left.enqueue(a)
      L += a
    }

    val mid = Array.fill[Long](N)(sc.nextLong())

    var R: Long = 0
    val right = mutable.PriorityQueue[Long]()
    (0 until N) foreach { _ =>
      val a = sc.nextLong()
      right.enqueue(a)
      R += a
    }

    val dL = Array.ofDim[Long](N + 1)
    dL(0) = L
    val dR = Array.ofDim[Long](N + 1)
    dR(N) = R

    (0 until N) foreach { i =>
      val add = mid(i)
      left.enqueue(add)
      val remove = left.dequeue()
      dL(i + 1) = dL(i) + add - remove
    }

    (0 until N) foreach { j =>
      val i = N - 1 - j
      val add = mid(i)
      right.enqueue(add)
      val remove = right.dequeue()
      dR(i) = dR(i + 1) + add - remove
    }

    val ans = (dL zip dR map { case (l, r) => l - r }).max

    println(ans)
  }


  def main(args: Array[String]): Unit = {
    solve()
  }


  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = null

    def next: String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next.toInt
    def nextLong(): Long = next.toLong
    def nextChar(): Char = next.charAt(0)
  }

}


Measured memory_bytes: 100732
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<queue>
#include<functional>

using namespace std;

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

//const ll INF = 1e15;
const ll MOD = 1e9 + 7;

int main(){
	int M;
	cin >> M;
	cout << 48 - M << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define N 20000

typedef struct Eq{
    int map, eq;
}s;

int s1[N], n, ad, j, sum=0;
s s2[N];
int top1=0, top2=0;
char ch[N];

void push1(int x){
    s1[top1]=x;
    top1++;
}

int pop1(){
    top1--;
    return s1[top1];
}

void push2(int x, int add){
    s2[top2].map = x;
    s2[top2].eq = add;
    top2++;
}

s pop2(){
    top2--;
    return s2[top2];
}

int main(void){
    scanf("%s", ch);
    n = strlen(ch);
    for(int i=0 ; i<n ;i++){
        if(ch[i] == '\\') push1(i);
        else if(top1 > 0 && ch[i] == '/'){
            j = pop1();
            ad = i-j;
            sum +=ad;
            while( top2 > 0 && s2[top2-1].map > j) ad += pop2().eq;
            push2(j, ad);
        }
    }

    printf("%d\n", sum);
    printf("%d", top2);
    for(int i=0 ; i<top2 ; i++)
        printf(" %d", s2[i].eq);
    printf("\n");

    return 0;
}





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

int main() {
  string S;
  cin >> S;
  long long sum = 0;
  int num_cases = pow(2, S.size()-1);
  string e = "";
  
  if(S.size() == 1){
    cout << S << endl;
    return 0;
  }
  for(int i=0; i<num_cases; i++){
    e = S.at(0);
    for(int j=0; j<S.size()-1; j++){
      if (!(i>>j&1)){
        e += S.at(j+1);
      }else{
        sum += (long long) stoll(e);
        e = S.at(j+1);
      }
    }
    sum += (long long) stoll(e);
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
#define RANGE_1(e) (boost::irange(0,(e)))
#define RANGE_2(s,e) (boost::irange((s),(e)))
#define RANGE_3(s,e,step) (boost::irange((s),(e),(step)))
#define RANGE_SELECTER(_1,_2,_3,SELECT,...) SELECT
#define range(...) RANGE_SELECTER(__VA_ARGS__, RANGE_3, RANGE_2, RANGE_1) (__VA_ARGS__)
#define guard(x) if(x);
#define CINS(x) for(auto&& __E__:(x))cin>>__E__
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define CALL(x) (x).cbegin(),(x).cend()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define BIT(n) (1LL<<(n))
#define MOD 1000000007

using namespace std;
using lint = long long;

// template<class T>class irange{private:struct I{T x;T operator*(){return x;}bool operator!=(I&lhs){return x<lhs.x;}void operator++(){++x;}};I i,n;public:irange(T i,T n):i({i}),n({n}){}I&begin(){return i;}I&end(){return n;}};
// template<class T>class srange{private:struct I{T x,s;T operator*(){return x;}bool operator!=(I&lhs){if(s<(T)0)return x>lhs.x;return x<lhs.x;}void operator++(){x=x+s;}};I i,n;public:srange(T i,T n,T s):i({i,s}),n({n,s}){}I&begin(){return i;}I&end(){return n;}};
// template<class T>irange<T>range(T n){return irange(0,n);}template<class T>irange<T>range(T i,T n){return irange(i,n);}template<class T>srange<T>range(T i,T n,T s){return srange(i,n,s);}
template<class T>bool amax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool amin(T &a,const T &b){if(a>b){a=b;return true;}return false;}

struct initialize{initialize(){cin.tie(nullptr);ios::sync_with_stdio(false);};}__ini__;

int main() {
    int x, y; // 頭, 足
    cin >> x >> y;
    
    guard (!(y & 1)) else {
        cout << "No" << endl; // 足が奇数ならその時点で破綻している
        return 0;
    }
    
    int t = 2 * x - y / 2; // tsuru. 2t + 4(X - t) = Yの解
    
    string judge = t >= 0 && t <= x ? "Yes" : "No"; // 数学的解と現実(負の鶴や亀はいない)が剥離していなければ組み合わせが存在する
    cout << judge << endl;
}


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

int main(){
    string S;
    cin >> S;
    string s1,s2,s3;
    s1 = S.substr(0,4);
    s2 = S.substr(5,2);
    s3 = S.substr(8,2);
    int y,m,d;
    y = stoi(s1);
    m = stoi(s2);
    d = stoi(s3);
    if(y <2019){
        cout << "Heisei" << endl;
    }else if(y == 2019 && m <= 4){
        if(m == 4){
            if(d>30){
                cout << "TBD" << endl;
                return 0;
            }
        }
        cout << "Heisei" << endl;
    }else{
        cout << "TBD" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
/* cerberus97 - Hanit Banga */

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 2e5 + 10, mod = 1e9 + 7;

ll fact[N], finv[N];

ll f(ll n, ll i, ll a, ll b);
ll inverse(ll x);
ll pwr(ll x, ll e);

int main() {
	fast_cin();
	fact[0] = finv[0] = 1;
	for (int i = 1; i < N; ++i) {
		fact[i] = (i * fact[i - 1]) % mod;
		finv[i] = inverse(fact[i]);
	}
	ll n, a, b, c;
	cin >> n >> a >> b >> c;
	ll ans = 0;
	for (int i = 0; i < n; ++i) {
		ans += f(n, i, a, b) + f(n, i, b, a);
		ans %= mod;
	}
	ans *= 100;
	ans %= mod;
	ans *= inverse(a + b);
	ans %= mod;
	cout << ans << endl;
}

ll f(ll n, ll i, ll a, ll b) {
	ll p = a * inverse(a + b);
	p %= mod;
	ll ans = fact[n + i - 1] * finv[n - 1];
	ans %= mod;
	ans *= finv[i];
	ans %= mod;
	ans *= pwr(p, n);
	ans %= mod;
	ans *= pwr(mod + 1 - p, i);
	ans %= mod;
	ans *= (n + i);
	ans %= mod;
	return ans;
}

ll inverse(ll x) {
	return pwr(x, mod - 2);
}

ll pwr(ll x, ll e) {
	ll res = 1;
	while (e) {
		if (e & 1) {
			res = (res * x) % mod;
		}
		x = (x * x) % mod;
		e /= 2;
	}
	return res;
}

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

int N;
const int MAX_N = 200005;
std::multiset<int> vs;
int arr[MAX_N];

int main() {
  scanf("%d", &N);
  for (int i = 0; i < N; ++i) {
    scanf("%d", arr + i);
    vs.insert(arr[i]);
  }
  for (int i = 0; i < N; ++i) {
    vs.erase(vs.find(arr[i]));
    printf("%d\n", *(--vs.end()));
    vs.insert(arr[i]);
  }

}


Measured memory_bytes: 11776