akhauriyash/Code-Regression huggingface dataset:
##======================================python3

import sys
import collections
sys.setrecursionlimit(10**6)

class Run:

    def build(gv):
        gv.N, gv.X, gv.Y = map(int, sys.stdin.readline().split(' '))

    def solve(gv):
        ans = [0 for _ in range(1, gv.N+1)]
        for start in range(1, gv.N):
            for end in range (start +1, gv.N +1):
                pass_1 = end - start
                pass_2 = abs(gv.X -start) + abs(gv.Y -end) + 1
                ans[min(pass_1, pass_2)] += 1
        
        for i in range(1, gv.N):
            print(ans[i])

if __name__ == '__main__':
    run = Run()
    run.build()
    run.solve()

Measured memory_bytes: 3692
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<stack>
#include<queue>
#include<map> 
#include<list>
#include<string>
#include<cstring>
#include<set>
#include<vector>
#define ll long long
#define memset(a,n) memset(a,n,sizeof(a))
#define mp make_pair 
#define pb push_back
using namespace std;
const int maxn = 1e6 + 100;


int main()
{
	int n;cin >> n;deque<int> q;
	for(int i = 1; i <= n;i++){
		int x;cin >> x;
		int it = lower_bound(q.begin(),q.end(),x) - q.begin();
		if(!it){
			q.push_front(x);
		}else{
			q[it - 1] = x;
		}
	}
	printf("%d\n",q.size());
}


Measured memory_bytes: 640
x,y=map(int,input().split())
if x==y==1:
    print(300000*2+400000)
    exit()
a=0
if x==1:
    a+=300000
elif x==2:
    a+=200000
elif x==3:
    a+=100000
if y==1:
    a+=300000
elif y==2:
    a+=200000
elif y==3:
    a+=100000
print(a)

Measured memory_bytes: 3060
//
//AtCoder Beginner Contest 168
//D - .. (Double Dots) 
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;

const double PI = 3.14159265358979323846;

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

using Graph = vector<vector<int>>;
vector<bool> seen;
vector<int> first_order; // 行きがけ順
vector<int> last_order; // 帰りがけ順

void dfs(const Graph &G, int v, int& first_ptr, int& last_ptr) {
    // 行きがけ順をインクリメントしながらメモ
    first_order[v] = first_ptr++;

    seen[v] = true; 
    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue;
        dfs(G, next_v, first_ptr, last_ptr);
    }

    // 帰りがけ順をインクリメントしながらメモ
    last_order[v] = last_ptr++;
}

int main()
{
    int n, m;

    cin >> n >> m;

    Graph G(n);
    REP(i, m){
        int a, b;
        cin >> a >> b;
        G[a-1].push_back(b-1);
        G[b-1].push_back(a-1);
    }

  // BFS のためのデータ構造
    vector<int> dist(n, -1); // 全頂点を「未訪問」に初期化
    vector<vector <int>> mem(n); // 全頂点を「未訪問」に初期化
    queue<int> que;

    // 初期条件 (頂点 0 を初期ノードとする)
    dist[0] = 0;
    mem[0].push_back(0);
    que.push(0); // 0 を橙色頂点にする

    // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty()) {
        int v = que.front(); // キューから先頭頂点を取り出す
        que.pop();

        // v から辿れる頂点をすべて調べる
        for (int nv : G[v]) {
            if (dist[nv] != -1) continue; // すでに発見済みの頂点は探索しない

            // 新たな白色頂点 nv について距離情報を更新してキューに追加する
            dist[nv] = dist[v] + 1;
            mem[nv].push_back(v);
            que.push(nv);
        }
    }

    // 結果出力 (各頂点の頂点 0 からの距離を見る)
    //for (int v = 0; v < n; ++v) cout << v << ": " << dist[v] << ":" << mem[v][0] << endl;

    string f = "Yes";
    FOR(i, 1, n-1){
        if (dist[i] == 0) f="No";
    }
    cout << f << endl;
    if (f=="Yes"){
        FOR(i, 1, n-1){
            if (dist[i] == 1) cout << dist[i] << endl;
            else{
                cout << mem[i][0]+1 << endl;
            }
        }
    }
    
    return 0;
}


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

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

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

// O(sqrt(n))
vector<ll> get_divisors(ll n){
    vector<ll> divisors;
    for(ll i=1;i*i<=n;i++){
        if(n % i == 0){
            divisors.push_back(i);
            if(i != (n / i)) divisors.push_back(n / i);
        }
    }
    return divisors;
}

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    ll n; cin >> n;
    ll ans = 0;
    // no division
    ans += get_divisors(n - 1).size() - 1;
    // division at least once
    vector<ll> divisors = get_divisors(n);
    for(ll k: divisors){
        if(k == 1) continue;
        ll tmp = n;
        while(tmp % k == 0){
            tmp /= k;
        }
        if(tmp % k == 1) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
    using namespace std;
    #define rep(i,b) for(i=0;i<b;++i)
    #define repp(i,a,b) for(i=a;i<b;++i)
    #define per(i,n) for(i=n-1;i>=0;i--)
    #define endl "\n"
    #define pb push_back
    typedef long long int lli;
    const lli mod=1000000007;
    typedef vector<lli> vi;
    typedef pair<lli,lli> pi;
    #define mp make_pair
    #define pb push_back
    int main(){
       //ios_base::sync_with_stdio(false);
       //cin.tie(NULL);
        lli n,t,i,k,j,f,g,m;
        string s;
        vi v;
        map<lli,lli> mm;
        map<lli,lli> :: iterator it;
        cin>>n>>t;
        lli ans=999999999999;
        rep(i,n){
            cin>>f>>g;
            if(g<=t){
                if(f<ans)
                    ans=f;
            }
        }
        if(ans==999999999999)
            cout<<"TLE"<<endl;
        else
            cout<<ans<<endl;
        return 0;
    }



Measured memory_bytes: 256
import itertools

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

MOD = 10**9 + 7
MAX_NUM = 10**5 + 10

def inv_mod(n):
  return pow(n, MOD-2, MOD)

FACTS = [1 for _ in range(MAX_NUM+1)]
for n in range(1, MAX_NUM+1):
  FACTS[n] = (n*FACTS[n-1]) % MOD

INV_FACTS = [1 for _ in range(MAX_NUM+1)]
INV_FACTS[MAX_NUM] = inv_mod(FACTS[MAX_NUM])
for n in range(MAX_NUM-1, -1, -1):
  INV_FACTS[n] = (INV_FACTS[n+1]*(n+1)) % MOD
  
for i in range(MAX_NUM+1):
  assert (FACTS[i]*INV_FACTS[i])%MOD == 1

def ncr(n, r):
  if r > n:
    return 0
  if r < 0:
    return 0
  # C(n, r) = n!/(n-r)!r!
  ans = FACTS[n]*INV_FACTS[n-r]*INV_FACTS[r]
  return ans % MOD

from collections import defaultdict
v2i = defaultdict(list)
for i, v in enumerate(A):
  v2i[v].append(i)

fst, snd = -1, -1
for v in v2i:
  if len(v2i[v]) == 2:
    fst, snd = v2i[v]

K = snd - fst - 1
for ell in range(1, N+2):
  ans = ncr(N+1, ell) - ncr(N-1-K, ell-1)
  print(ans%MOD)


Measured memory_bytes: 105864
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;
LL p = 1000000007ll;

int main(void)
{
  LL n,l;
  cin >> n >> l;
  LL r = n+l-1;
  LL answer = 0;
  FOR(i,l,n+l) answer+=i;
  if(l*r>0) answer -= abs(l)<abs(r)?l:r;
  cout << answer << endl;
  return 0;
}


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

int main() {
	long l;
	cin >> l;
	long long s = 0;
	for (int i = 1; i <= l; i++)
		if (!(i % 3 == 0 || i % 5 == 0))
			s += i;
	cout << s;
	cin >> l;
	return 0;
}

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

int main(){
  int A, B, C, X;
  cin >> A >> B >> C >> X;
  int ans = 0;

  for(int i = 0; i <= A; i++){
    for(int j = 0; j <= B; j++){
      for(int k = 0; k <= C; k++){
        if(500 * i + 100 * j + 50 * k == X){
          ans++;
        }
      }
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)



int main(){
	int x,n;
	cin >> x >> n;
	vector<int> p(n);
	REP(i,n) cin>>p[i];
	

	
	int flag=1;
	REP(i,n){
		if(x==p[i]){
			flag=0;
		}
	}
	if(flag){
		cout << x << endl;
		return 0;
	
	}
	
	int ue=x+1,shita=x-1;
	int uflag,sflag;
	
	while(true){
		uflag=1;
		sflag=1;
		REP(i,n){
			if(ue==p[i]) uflag=0;
			if(shita==p[i]) sflag=0;
		}
		if(sflag){
			cout << shita << endl;
			return 0;
		}
		
		if(uflag){
			cout << ue << endl;
			return 0;
		}
		ue++;
		shita--;
		
	}
	
	return 0;
	
}

Measured memory_bytes: 3628
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <utility>
#include <set>
#include <map>
#include <tuple> 
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
using namespace  std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(long long (i)=0, i_bound = (long long)(n); (i)<i_bound; ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
const long long MOD = static_cast<long long>(1e9) + 7LL;
const long long INF = 1234567891234567890LL;

vector<vector<ll>> G;
vector<ll> SC;
void dfs(ll v){
    if(G[v].empty()) return;
    for(auto &nv: G[v]){
        SC[nv] += SC[v];
        dfs(nv);
    }
}

signed main(){
    ll N, Q; cin>>N>>Q;
    G.resize(N, vector<ll>());
    SC.resize(N, 0);
    REP(i, N-1){
        ll a, b; cin>>a>>b;
        G[--a].emplace_back(--b);
    }
    REP(i, Q){
        ll p, x; cin>>p>>x;
        SC[--p] += x;
    }
    dfs(0);
    for(int i=0; i<N; i++){
        if(i) cout << " ";
        cout << SC[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 21120
h, w = map(int, input().split())
s = [list(input()) for i in range(h)]

dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1,  0,  1, -1, 1,-1, 0, 1]

for i in range(h):
    for j in range(w):
        if s[i][j] == '#':
            continue
        elif s[i][j] == '.':
            num = 0
            for a in range(8):
                ni = i + dx[a]
                nj = j + dy[a]

                if (0 <= ni < h) and (0 <= nj < w) and (s[ni][nj] == '#'):
                    num += 1
            s[i][j] = num

[print(*i,sep='') for i in s]


Measured memory_bytes: 3572
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define MAX(list) std::max(list)
#define MIN(list) std::min(list)

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

using ll = long long;
using namespace std;
ll mod = 1'000'000'007;

const int INF = 1'050'000'000;

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

    vector<int> A(N);
    REP(i, N) {
        A[i] = L + i;
    }

    int sum = accumulate(ALL(A), 0);

    int ans = 0;
    REP(i, N) {
        int sum2 = sum - A[i];
        if (abs(sum - sum2) < abs(sum - ans)) {
            ans = sum2;
        }
    }

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

Measured memory_bytes: 256
import java.util.*;

public class Main
{
	public static  void main(String args[])
	{
		Scanner scan = new Scanner(System.in);
		String w1 = scan.nextLine();
		String w2="ABC";
		if(w1.equals(w2))
		{
			System.out.println("ARC");
		}
		else
			System.out.println("ABC");
	}
}

Measured memory_bytes: 35524
#include <iostream>
#include <cmath>
#include <vector>

using namespace std;

typedef long long ll;

void count_one(vector<ll>& d, int max_digit, ll N) {

    for (int i=1; i<=max_digit; i++) {
        ll a = (N+1) / (ll)pow(2, i);
        ll b = (N+1) % (ll)pow(2, i);
        d[i-1] = (ll)pow(2, i-1) * a;
        if ((ll)pow(2, i-1) < b) {
            d[i-1] += b - (ll)pow(2, i-1);
        }
    }
}

int main() {
    ll A, B;
    cin >> A >> B;

    // 0からある数までの各位の1の数を数える。
    int digit = 0;
    while (pow(2, digit) <= B) ++digit;

    vector<ll> dA(digit, 0);
    vector<ll> dB(digit, 0);

    if (0 < A) --A;
    count_one(dA, digit, A);
    count_one(dB, digit, B);

    ll res = 0;
    for (int i=0; i<digit; i++) {
        if ((dA[i] - dB[i]) % 2 != 0) {
            res += pow(2, i);
        }
    }

    cout << res << endl;

    return 0;
}

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


#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

#define X real()
#define Y imag()

using namespace std;
using namespace __gnu_pbds;

template<class T> using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
using ll  = long long;

using point = complex<double>;


void err(istream_iterator<string> it) {cerr << endl;}
template<typename T, typename... Args>void err(istream_iterator<string> it, T a, Args... args) {cerr << *it << " = " << a << endl;err(++it, args...);}


const double EPS = 1e-8;
const long long mod = 1e9+7;

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

const int N = 1e5 + 5;


int n , a[N],b[N];
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    for(int i = 0; i < n + 1; ++i)
            cin >> a[i];
    for(int i = 0; i < n ; ++i)
            cin >> b[i];
    long long ans = 0,x;
    for(int i = 0; i < n; ++i){
        x = min(a[i],b[i]);
        ans += x;
        a[i] -= x;
        b[i] -= x;
        x = min(a[i + 1],b[i]);
        b[i] -= x;
        a[i + 1]-=x;
        ans+= x;
    }
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int A, B;
    int N = 0;
    cin >> A >> B;
    for (int i = A; i <= B; i++){
        string s;
        s = to_string(i);
        string s1 = s;
        reverse(s.begin(), s.end());
        if (s1 == s){
            N++;
        }
    }
    cout << N << endl;
}

Measured memory_bytes: 256
#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++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 5*1e5;

int main() {
    int a, b, c, x;
    cin >> a >> b >> c >> x;
    int ct = 0;
    for (int i = 0; i <= a; i++) {
        for (int j = 0; j <= b; j++) {
            for (int l = 0; l <= c; l++) {
                int sum = i*500+j*100+l*50;
                if (sum == x) ct++;
            }
        }
    }
    cout << ct << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
int arr[100010][3];
int dp[100010][3];
signed main()
{
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++){
		for (int j = 1; j <= 3; j++){
			cin >> arr[i][j];
		}
	}
	for (int i = 0; i < 3; i++){
		dp[1][i+1] = arr[0][i];
	}
	for (int i = 1; i <= n; i++){
		for (int j = 1; j <= 3; j++){
			if (j==1){
				dp[i][1] = max(dp[i-1][2], dp[i-1][3]) + arr[i][j];
			}else if (j == 2){
				dp[i][2] = max(dp[i-1][1], dp[i-1][3]) + arr[i][j];
			}else if (j == 3){
				dp[i][3] = max(dp[i-1][1], dp[i-1][2]) + arr[i][j];
			}
		}
	}
	cout << max(dp[n][1], max(dp[n][2], dp[n][3]));
} 

Measured memory_bytes: 4992
import java.util.*;

public class Main{
	private static final Scanner scan = new Scanner(System.in);

	public static void main(String[] args){

		while(scan.hasNext()){
			int[][] mas = new int[8][8];
			for(int i = 0; i < 8; i++){
				String in = scan.next();
				for(int j = 0; j < 8; j++){
					char c = in.charAt(j);
					String s = String.valueOf(c);
					int n = Integer.parseInt(s);
					mas[i][j] = n;
				}
			}
			boolean flag = false;
			String type = "";
			Loop:for(int i = 0; i < 8; i++){
				for(int j = 0; j < 8; j++){
					if(mas[i][j] == 1){
						if(j+1 < 8 && i+1 < 8){
							if(mas[i][j+1] == 1 && mas[i+1][j] == 1 && mas[i+1][j+1] == 1){
								flag = true;
								type = "A";
								break Loop;
							}
						}
						if(i+1 < 8 && i+2 < 8 && i+3 < 8){
							if(mas[i+1][j] == 1 && mas[i+2][j] == 1 && mas[i+3][j] == 1){
								flag = true;
								type = "B";
								break Loop;
							}
						}
						if(j+1 < 8 && j+2 < 8 && j+3 < 8){
							if(mas[i][j+1] == 1 && mas[i][j+2] == 1 && mas[i][j+3] == 1){
								flag = true;
								type = "C";
								break Loop;
							}
						}
						if(j+1 < 8 && i+1 < 8 && j+2 < 8){
							if(mas[i][j+1] == 1 && mas[i+1][j+1] == 1 && mas[i+1][j+2] == 1){
								flag = true;
								type = "E";
								break Loop;
							}
						}
						if(i+1 < 8 && j+1 < 8 && i+2 < 8){
							if(mas[i+1][j] == 1 && mas[i+1][j+1] == 1 && mas[i+2][j+1] == 1){
								flag = true;
								type = "F";
								break Loop;
							}
						}
					} else if(mas[i][j] == 0){
						if(j+1 < 8 && i+1 < 8 && i+2 < 8){
							if(mas[i][j+1] == 1 && mas[i+1][j] == 1 && mas[i+1][j+1] == 1 && mas[i+2][j] == 1){
								flag = true;
								type = "D";
								break Loop;
							}
						}
						if(j+1 < 8 && j+2 < 8 && i+1 < 8){
							if(mas[i][j+1] == 1 && mas[i][j+2] == 1 && mas[i+1][j] == 1 && mas[i+1][j+1] == 1){
								flag = true;
								type = "G";
								break Loop;
							}
						}
					}
				}
			}
			System.out.printf("%s\n", type);
		}
	}
}

Measured memory_bytes: 27648
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll = long long;
using P = pair<int,int>;
void Yes() {
    cout << "Yes" << endl;
}
void No() {
    cout << "No" << endl;
}
int main(void) {
    string s; cin >> s;
    s[3] = '8';
    cout << s;
}


Measured memory_bytes: 256
/*input
1 2 1 1
*/
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <climits>
#include <random>

using namespace std; 

template<typename T>
using minpq = priority_queue<T, vector<T>, greater<T>>;
int GCD(int x,int y){return y?GCD(y,x%y):x;}
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define rep(i,n) for(int i=0;i<(n);i++)
#define repl(i,a,b) for(int i=(a);i<(b);i++)
#define repm(i,a,b) for(int i=(a);i>(b);i--)
#define rept(v) for(auto it=v.begin();it<v.end();it++)
#define all(v) v.begin(),v.end()
const int INF = 1<<30;
typedef long long ll;
typedef pair<int,int> pii;

int const MOD = 1e9+7;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << max({
		a*c,
		a*d,
		b*c,
		b*d
	});
	return 0;	
}

Measured memory_bytes: 3652
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
#include <functional>
#include <random>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vvvl> vvvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef long double LD;
typedef vector<LD> vld;
typedef vector<pair<LD, LD>> vpld;
typedef pair<ll, ll> PL;
typedef vector<PL> vpl;
typedef vector<vector<PL>> vvpl;
typedef vector<vvpl> vvvpl;
typedef pair<ll, PL> TL;
typedef vector<TL> vtl;
typedef vector<vtl> vvtl;
typedef long double ld;
typedef vector<ld> vld;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back
#define ALL(X) (X).begin(),(X).end()

template <typename T> T gcd(T a, T b) {return (a == 0) ? b : gcd(b%a, a);}
template <typename T> T lcm(T a, T b) { return a / gcd(a, b) * b;}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec /* copy */){
    sort(ALL(vec)); vec.erase(unique(vec.begin(), vec.end()), vec.end()); return vec;
}

inline ll popcnt(ll x){return __builtin_popcountll((unsigned long long)x);};
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; }
//friend bool operator<(const tpl& lhs, const tpl& rhs){
//    return std::tie(lhs.l, lhs.r) < std::tie(rhs.l, rhs.r);
//}

bool bit(ll st, ll b){return ((st>>b)&1) == 1;}


int main(){
#ifdef __DEBUG_LOCAL__
    ifstream file("../../../../../in.txt"); if(file.is_open()) cin.rdbuf(file.rdbuf());
#endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    
    ll N, R; cin >> N >> R;
    if(N >= 10){
        cout << R << endstr;
    }
    else{
        cout << R + 100 * (10 - N) << endstr;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); i += 2) cout << s[i]; cout << endl;
    return 0;
}

Measured memory_bytes: 512
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		String  a = sc.next();
		
		if (a.equals("SUN")){
			System.out.print("7");
		}
		if (a.equals("MON")){
			System.out.print("6");
		}
		if (a.equals("TUE")){
			System.out.print("5");
		}
		if (a.equals("WED")){
			System.out.print("4");
		}
		if (a.equals("THU")){
			System.out.print("3");
		}
		if (a.equals("FRI")){
			System.out.print("2");
		}
		if (a.equals("SAT")){
			System.out.print("1");
		}
	}
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


int main() {
    int X,Y; cin >> X >> Y;
    cout << X + Y/2 << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>

#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n;i++)
#define repf(i, a, b) for (int i = (int)a; i < (int)b;i++)
#define repv(x, arr) for (auto& x:arr)
#define all(v) (v).begin(), (v).end()
#define vec(name, num) vector<ll> name((num), 0);
#define mp(a,b) make_pair(a,b)
#define op(i) cout << (i) << endl;

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

const ll mod = 1e9 + 7;



int main(){
    string S;
    cin >> S;
    int N = S.size();
    if (S[0]==S[N-1]){
        if (N%2==0){
            cout << "First" << endl;
        }
        else
        {
            cout << "Second" << endl;
        }
    }
    else{
        if(N%2==0)
        {
            cout << "Second" << endl;
        }
        else
        {
            cout << "First" << endl;
        }
    }
}


Measured memory_bytes: 512
D = int(input())
C = list(map(int, input().split()))
S = [list(map(int, input().split())) for _ in range(D)]

scores = []
last = [-1]*26
score = 0
for i in range(D):
    t = int(input())
    t -= 1
    score += S[i][t]
    last[t] = i
    for j in range(26):
        score -= C[j]*(i-last[j])
    scores.append(score)
print(*scores, sep='\n')

Measured memory_bytes: 9424
#include <algorithm>
#include <cstdio>
#include <fstream>
#include <iostream>
#include <string.h>
#include <vector>

using namespace std;

// #define DEBUG 1
#define DFILE "t1.1"

typedef struct
{
  char name[12];
  int score;
  int key;
} TT;

void merge_data(TT a[], TT b[], int low, int mid, int high)
{
  int h, i, j, k;
  h = low;
  i = low;
  j = mid + 1;

  while ((h <= mid) && (j <= high)) {
    int c = strcmp(a[h].name, a[j].name);
    if (c == 0) {
      c = a[j].score - a[h].score;
    }
    if (c <= 0) {
      b[i] = a[h];
      h++;
    } else {
      b[i] = a[j];
      j++;
    }
    i++;
  }
  if (h > mid) {
    for (k = j; k <= high; k++) {
      b[i] = a[k];
      i++;
    }
  } else {
    for (k = h; k <= mid; k++) {
      b[i] = a[k];
      i++;
    }
  }
  for (k = low; k <= high; k++)
    a[k] = b[k];
}

void merge_sort(TT data[], TT temp[], int left, int right)
{
  if (left < right) {
    int mid = left + (right - left) / 2;
    merge_sort(data, temp, left, mid);
    merge_sort(data, temp, mid + 1, right);
    merge_data(data, temp, left, mid, right);
  }
}

int main()
{
#ifdef DEBUG
#define cin fin
  fstream fin(DFILE);
#endif
  int n;
  cin >> n;
  TT* a;
  TT* t;
  a = new TT[n];
  t = new TT[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i].name >> a[i].score;
    a[i].key = i + 1;
  }
  merge_sort(a, t, 0, n - 1);
  for (int i = 0; i < n; i++) {
    // cout << a[i].name << " " << a[i].score << " " << a[i].key << endl;
    cout << a[i].key << endl;
  }
  return 0;
}


Measured memory_bytes: 256
//============================================================================
// Name        : abc141_d.cpp D - Powerful Discount Tickets
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : https://atcoder.jp/contests/abc141/tasks/abc141_d
//============================================================================

#pragma GCC optimize ("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

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

// 数値の読み取り, 低速な cin の使用を回避する
inline int read() {
	int f = 1, x = 0; // 負数フラグ、絶対値
	char ch = getchar();
	while (ch < '0' || ch > '9') { // 数値以外を飛ばす
		if (ch == '-') { // ただし '-' のとき負数フラグを立てる
			f = -1;
		}
		ch = getchar();
	}
	while (ch >= '0' && ch <= '9') { // 数値の読み取り
		x = x * 10 + (ch - '0');
		ch = getchar();
	}
	return x * f;
}

// 数値の書き出し, 低速な cout の使用を回避する
template<typename T>inline void write(T n) {
	int i = 0;
	char b[30];
	if (!n) {
		putchar('0');
	} else {
		if (n < 0) { // 負数のとき負号出力
			putchar('-');
			n *= -1;
		}
		i = 0;
		while (n) { // 下の桁から順番に文字にして b に格納
			b[i++] = '0' + (n % 10);
			n /= 10;
		}
		while (i--) { // 上の桁から順番に出力
			putchar(b[i]);
		}
	}
	putchar('\n');
}

int N, M;
int main() {
	N = read(); // 品物数
	M = read(); // 割引券枚数

	// 品物値段 A_1(=A[0]) ~ A_N(=A[N-1]) の読み取り
	priority_queue<long long> A;
	for (int i = 0; i < N; ++i) {
		A.push(read());
	}
	// 割引適用 M 枚
	long long max;
	for (int j = 0; j < M; ++j) {
		max = A.top();
		A.pop();
		// cerr << (max / 2) << endl;
		A.push(max / 2);
	}
	long long sum = 0;
	for (int i = 0; i < N; ++i) {
		sum += A.top();
		A.pop();
	}
	write(sum);
	return 0;
}


Measured memory_bytes: 1400
N = int(input())
def make_div(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    return sorted(divisors)
div = make_div(N)
minn = 100000000000000000000
for i in range(len(div)):
    a,b = div[i],div[-i-1]
    if a > b:
        break
    if (a + b) < minn:
        minn = a + b

print(minn-2)



Measured memory_bytes: 39152
#include<bits/stdc++.h>
#define N 100010
using namespace std;
string s;
char a[N];
int k;
int main(){
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(s[i]!='B') a[++k]=s[i];
        else{ k--; if(k<0) k=0; }
    }
    for(int i=1;i<=k;i++) cout<<a[i];
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
import math

N, M = map(int, input().split())

if abs(N-M) > 1:
    print(0)
elif abs(N-M) == 1:
    print((math.factorial(N)*math.factorial(M)) % 1000000007)
else:
    print((math.factorial(N)*math.factorial(M)*2) % 1000000007)


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

using namespace std;

int main(){
vector<int> v(5);
int ans = 0;

for(int i = 0;i < 5;i++){
	cin >> v[i];
	if(v[i] == 0){
		ans = i+1;
	}
}

cout << ans << endl;

return 0;
}


Measured memory_bytes: 3504
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
int main()
{
    int n,a,b;
    while(cin>>n>>a>>b)
    {
        int c=abs(a-b)-1;
        if(c%2==1)
            cout<<"Alice\n";
        else
            cout<<"Borys\n";
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) throws Exception {
        String[] lines = getStdin();
        for( int i = 0; i < 50; i++){
            String[] str = lines[i].split(" ");
            int m = Integer.parseInt(str[0]);
            int f = Integer.parseInt(str[1]);
            int r = Integer.parseInt(str[2]);
             if (m == - 1 && f == - 1 && r == -1){
                    break;
                }
                if( m == - 1 || f == -1){
                    System.out.println("F");
                } else if ( m + f >= 80){
                    System.out.println("A");
                } else if ( m + f >= 65 && m + f < 80){
                    System.out.println("B");
                } else if (( m + f  >= 50 && m + f < 65) || r >= 50){
                    System.out.println("C");
                } else if ( m + f >= 30 && m + f < 50){
                    System.out.println("D");
                } else if ( m + f < 30){
                    System.out.println("F");
                } 
               
        }
   }
  private static String[] getStdin() {
    Scanner scanner = new Scanner(System.in);
    ArrayList<String> lines = new ArrayList<>();
    while (scanner.hasNext()) {
      lines.add(scanner.nextLine());
    }
    return lines.toArray(new String[lines.size()]);
  }
}


Measured memory_bytes: 26224
# -*- coding: utf-8 -*-

# AtCoder Grand Contest
# Problem A


# See:
# https://img.atcoder.jp/agc022/editorial.pdf
# https://agc022.contest.atcoder.jp/submissions/2286541
def determine_next_word(given_word: str) -> str:
    while given_word:
        pi = ascii_lowercase.index(given_word[-1])
        given_word = given_word[:-1]

        for character in ascii_lowercase[pi + 1:]:
            if character not in given_word:
                return given_word + character


if __name__ == '__main__':
    from string import ascii_lowercase
    s = input()

    if len(s) < 26:
        result = [s + character for character in ascii_lowercase if character not in s][0]
        print(result)
    elif s == ascii_lowercase[::-1]:
        print(-1)
    else:
        print(determine_next_word(given_word=s))


Measured memory_bytes: 4088
#include<cstdio>
using namespace std;
int main(){
  bool data[30]{};
  int x;
  for(int i = 0 ; i < 30 ; i++)
    data[i] = true;
  for(int i = 0 ; i < 28 ; i++){
    scanf("%d",&x);
    data[x-1] = false;
  }
  for(int i = 0 ; i < 30 ; i++){
    if(data[i])
      printf("%d\n",i+1);
  }
 }



Measured memory_bytes: 2684
#include<bits/stdc++.h>
#define INF 9223372036854775807LL
#define inf 1000000007
#define SYOU(x) setprecision(x+1)
#define abs(x,y) (max(x,y)-min(x,y))
#define lol long long
#define mp make_pair
#define fi first
#define se second
using namespace std;
lol a,b,c;
int i[1000];
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >>a>>b>>c;
  if(a==0){
      if(a%c==0) cout <<b/c-a/c+1<<'\n';
      else cout <<b/c-a/c<<'\n';
  }else
      cout <<b/c-(a-1)/c<<'\n';
  return (0);
}


Measured memory_bytes: 256
#include<cstdio>
#include<stack>
#include<queue>
#include<algorithm>
using namespace std;
#define N 105
int dfn[N],low[N],scc[N],n,m,head[N],cnt,head2[N],cnt2,f1[N],f2[N],head3[N],cnt3,vis[N],is[N],ct,ct2,fg,e1[N][2],e2[N][2],in[N],T;
struct edge{int t,next;}ed[N*10],ed2[N*10],ed3[N*10];
stack<int> tp;
void adde(int f,int t){ed[++cnt]=(edge){t,head[f]};head[f]=cnt;ed[++cnt]=(edge){f,head[t]};head[t]=cnt;}
void adde2(int f,int t){ed2[++cnt2]=(edge){t,head2[f]};head2[f]=cnt2;ed2[++cnt2]=(edge){f,head2[t]};head2[t]=cnt2;}
void adde3(int f,int t){ed3[++cnt3]=(edge){t,head3[f]};head3[f]=cnt3;}
void dfs1(int u,int fa){f1[u]=fa;for(int i=head[u];i;i=ed[i].next)if(ed[i].t!=fa)dfs1(ed[i].t,u);}
void dfs2(int u,int fa){f2[u]=fa;for(int i=head2[u];i;i=ed2[i].next)if(ed2[i].t!=fa)dfs2(ed2[i].t,u);}
void dfs3(int u,int fa)
{
	vis[u]=1;
	for(int i=head2[u];i;i=ed2[i].next)if(ed2[i].t!=fa)is[ed2[i].t]=1;
	queue<int> tp;
	for(int i=head[u];i;i=ed[i].next)if(is[ed[i].t])tp.push(ed[i].t);
	for(int i=head2[u];i;i=ed2[i].next)if(ed2[i].t!=fa)is[ed2[i].t]=0;
	while(!tp.empty())dfs3(tp.front(),u),tp.pop();
}
void dfs4(int u)
{
	tp.push(u);
	dfn[u]=low[u]=++ct;
	for(int i=head3[u];i;i=ed3[i].next)
	{
		if(!dfn[ed3[i].t])dfs4(ed3[i].t),low[u]=min(low[u],low[ed3[i].t]);
		else if(!scc[ed3[i].t])low[u]=min(low[u],dfn[ed3[i].t]);
	}
	if(dfn[u]==low[u])
	{
		int st=++ct2,s=tp.top();
		tp.pop();scc[s]=st;
		while(s!=u)
		{
			s=tp.top();tp.pop();
			scc[s]=st,fg=1;
		}
	}
}
int check(int s)
{
	int as=0;
	for(int i=1;i<=n;i++)head[i]=head2[i]=head3[i]=scc[i]=low[i]=dfn[i]=vis[i]=0;
	ct=ct2=fg=cnt=cnt2=cnt3=0;
	for(int i=1;i<n;i++)adde(e1[i][0],e1[i][1]),adde2(e2[i][0],e2[i][1]);
	dfs1(s,0);dfs2(s,0);dfs3(s,0);
	for(int i=1;i<=n;i++)if(!vis[i]){as++;if(!vis[f1[i]])adde3(i,f1[i]);if(!vis[f2[i]])adde3(f2[i],i);}
	for(int i=1;i<=n;i++)if(!dfn[i])dfs4(i);
	if(fg)return -1;
	return as;
}
int main()
{
	scanf("%d",&T);
	while(T--)
	{
		scanf("%d",&n);
		for(int i=1;i<n;i++)scanf("%d%d",&e1[i][0],&e1[i][1]);
		for(int i=1;i<n;i++)scanf("%d%d",&e2[i][0],&e2[i][1]);
		int mn=1e9,fg2=0;
		for(int i=1;i<=n;i++){int st=check(i);if(st!=-1&&st<mn)mn=st;}
		if(mn<1e9)printf("%d\n",mn);
		else
		{
			for(int i=1;i<=n;i++)
			{
				int st=0;
				for(int j=1;j<n;j++)if(e1[j][0]==i||e1[j][1]==i){if(st)st=-1;else st=j;}
				if(st==-1)continue;
				int l1=e1[st][0],l2=e1[st][1];
				for(int j=1;j<=n;j++)if(j!=i){e1[st][0]=i,e1[st][1]=j;if(check(i)!=-1)fg2=1;}
				e1[st][0]=l1,e1[st][1]=l2;
			}
			if(fg2)printf("%d\n",n);
			else printf("-1\n");
		}
	}
}//

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,k,q;
int a[100010];
int b[100010];
int main()
{
	cin>>n>>k>>q;
	for(int i=1;i<=q;i++)
	cin>>a[i];
	for(int i=1;i<=n;i++)
	b[i]=k;
	for(int i=1;i<=q;i++)
	b[a[i]]++;
	for(int i=1;i<=n;i++)
	{
		if(b[i]-q>0)
		printf("Yes\n");
		else
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define downque(que)  priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;
typedef long long ll;
typedef vector<vector<int> > Matrix;
const int MOD = 1e9+7;


//051B
int main(){
int n,k; cin>>n>>k;
int x,y;
int res=0;

for(int i=0;i<=n;i++){
   for(int j=0;j<=n;j++){
       if(k-(i+j)>=0&&k-(i+j)<=n)res++;
     //cout<<"("<<i<<","<<j<<","<<k-(i+j)<<")"<<res<<endl;
     
   } 
}

cout<<res<<endl;

}

Measured memory_bytes: 256
import bisect,sys
from itertools import *
n=range(50001);a=list(n);a[1]=0
for i in range(2,224):a[i*2::i]=[0]*len(a[i*2::i])
p=list(compress(n,a))
for x in map(int,sys.stdin):
 if x:print(len([1 for d in p[:bisect.bisect(p,x//2)]if a[x-d]]))


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

using namespace std;

int main()
{
    size_t N, Q;
    vector<size_t> A, B, C;

    // 入力
    cin >> N;
    A.resize(N);
    for(size_t i = 0; i < N; ++i) { cin >> A[i];}

    cin >> Q;    
    B.resize(Q);
    C.resize(Q);
    for(size_t i = 0; i < Q; ++i) { cin >> B[i] >> C[i];}

    // ヒストグラム
    size_t sum = 0;
    vector<size_t> count(100001, 0);
    for(size_t i = 0; i < N; ++i)
    {
        count[A[i]]++;    
        sum += A[i];
    }

    // 変換処理
    vector<size_t> result(Q, 0);
    for(size_t i = 0; i < Q; ++i)
    {
        size_t temp = count[B[i]];

        if(B[i] < C[i])
        {
            sum += (C[i] - B[i]) * temp;
        }
        else
        {
            sum -= (B[i] - C[i]) * temp;
        }

        result[i] = sum;

        count[C[i]] += temp;
        count[B[i]] = 0;
    }

    for(size_t i = 0; i < Q; ++i)
    {
        cout << result[i] << endl;    
    }

    //cout << 

    return 0;    
}

Measured memory_bytes: 7216
N = gets.chomp.to_i
P = gets.chomp.split.map(&:to_i)

# A, B, C = gets.chomp.split.map(&:to_i)
# S = gets.chomp.chars

# This is same with the count of flip.

ans = 1
minV = P[0]
(1.upto(N-1)).each do |i|
  # p "minV: #{minV}"
  # p "P[i]: #{P[i]}"
  if (P[i] < minV) 
    ans += 1
  end
  if (P[i] < minV)
    minV = P[i]
  end
end

p ans

Measured memory_bytes: 16516
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextWord() string {
	sc.Scan()
	str := sc.Text()
	return str
}

func nextInt() int {
	i, e := strconv.Atoi(nextWord())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	var a []int
	for i := 0; i < n; i++ {
		a = append(a, nextInt())
	}
	ans := solve(a)
	fmt.Println(ans)
}

func solve(a []int) float64 {
	result := 0.0
	sort.Ints(a)
	for i, ai := range a {
		result += float64(ai) * math.Pow(0.5, float64(len(a)-i))
	}
	n := len(a) - 1
	result += float64(a[0]) * math.Pow(0.5, float64(n+1))
	return result
}


Measured memory_bytes: 640
X = str(input())

A_list = []
Z_list = []

for i in range(len(X)):
  if X[i] == 'A':
    A_list.append(i)
  if X[i] == 'Z':
    Z_list.append(i)

print(int(Z_list[-1] - A_list[0] + 1))


Measured memory_bytes: 11180
N = int(input())
S = input()

#振り向く人数の最小値
min = N

#まずは0番目をリーダーとした場合の振り向く人数を調べる。
left = 0    #リーダーの左側にいる人の振り向く人数     
right = 0   #リーダーの右側にいる人の振り向く人数
for i in S:
    if i =='E':
        right+=1

if S[0]=='E':
    right -=1

min = right

for i in range(1,N):
    if S[i-1]=='W':
        left += 1
    if S[i]=='E':
        right -= 1
    if min>left+right:
        min = left + right

print(min)

Measured memory_bytes: 3676
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define fs first
#define sc second
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(max(a,c)<=min(b,d))cout<<min(b,d)-max(a,c)<<endl;
  else cout<<0<<endl;
  
}

Measured memory_bytes: 256
#include <cstdio>

int LinearSearch(int A[], int n, int key) {
  int i = 0;
  A[n] = key;
  while (A[i] != key) {
    ++i;
  }
  return i != n;
}

int main() {
  int i, n, A[10000 + 1], q, key, sum = 0;

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

  scanf("%d", &q);
  for (i = 0; i < q; ++i) {
    scanf("%d", &key);
    if (LinearSearch(A, n, key)) {
      ++sum;
    }
  }

  printf("%d\n", sum);
}

Measured memory_bytes: 2656
fun main(arr: Array<String>) {
    val n = readLine()!!.toInt()
    val p = readLine()!!.split(" ").map { it.toInt() }
    val ans = (1 until p.lastIndex).filter { listOf(p[it-1], p[it], p[it+1]).sorted()[1] == p[it] }
    println(ans.size)
}


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

int main(){
	int a,b,c;
	while(cin>>a>>b>>c){
		while(1){
			if(c)a=a/2,b=b+a,c--;
			else break;
			if(c)b/=2,a=a+b,c--;
			
		}
		cout<<a<<' '<<b<<endl;
	}
}


Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <map>
#include <vector>

using namespace std;

int main() {
    int N, M;

    cin >> N >> M;

    int ans = 1;

    for (int i = 1; i <= floor(sqrt(M)); i++) {
        if (M % i == 0) {
            if (i <= M / N) ans = max(ans, i);
            if (N <= i) ans = max(ans, M / i);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
flicks = {
    "T": "a",
    "L": "i",
    "U": "u",
    "R": "e",
    "D": "o"
}

buttons = {
    "1": "",
    "2": "k",
    "3": "s",
    "4": "t",
    "5": "n",
    "6": "h",
    "7": "m",
    "8": "y",
    "9": "r",
    "0": "w"
}

def get_word(button, flick):
    if button == "0" and flick == "U":
        return "nn"
    return buttons[button] + flicks[flick]

cmds = input()

result = ""
for i in range(0, len(cmds), 2):
    result += get_word(cmds[i], cmds[i+1])

print(result)

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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void anss(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}

int main(){
  ll i,j,o;
  ll res=0,res1=0,res2=INF,buf=0,buf1=0,buf2=0,buf3=0,buf4=0;
  bool judge = true;
  ll n,k;cin>>n>>k;
  vector<ll>a(n);  
  for(i=0;i<n;i++)cin>>a[i];
  sort(ALLR(a));
  for(i=0;i<k;i++)res+=a[i];
  cout<<res<<endl;

  return 0;
}

Measured memory_bytes: 256
n = list(input())
if n[-1] == '3':
    print('bon')
elif n[-1] == '0':
    print('pon')
elif n[-1] == '1':
    print('pon')
elif n[-1] == '6':
    print('pon')
elif n[-1] == '8':
    print('pon')
elif n[-1] == '2':
    print('hon')
elif n[-1] == '4':
    print('hon')
elif n[-1] == '5':
    print('hon')
elif n[-1] == '7':
    print('hon')
elif n[-1] == '9':
    print('hon')

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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

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

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

// a^b mod M
long myPow(long a,long b,int M) {
    long ret = 1;
    long tmp = a;
    while(b>0) {
        if((b&1)==1) ret = (ret * tmp) % M;
        tmp = (tmp * tmp) % M;
        b = b>>1;
    }
    return ret;
}

 // nCk mod M
int nCk(int n,int k,int M) {
    long ret = 1;
    int mi = min(k, n-k);
    for(int i=1;i<=mi;i++) {
        ret = (ret * myPow(i,M-2,M)) % M;
    }
    for(int i=n-mi+1;i<=n;i++) {
        ret = (ret * i) % M;
    }
    return (int)ret;
};

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}


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

    map<int,int> mp;
    REP(i,N){
        int d;
        cin >> d;
        mp[d]++;
    }

    cin >> M;

    bool ans = true;
    REP(i,M){
        int t;
        cin >> t;
        if(mp[t]>0){
            mp[t]--;
        } else {
            ans = false;
        }
    }

    YES(ans)

    return 0;
}

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

int main() {
    int a[13] = {-1, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
    int x, y;

    cin >> x >> y;

    a[x] == a[y] ? cout << "Yes" : cout << "No";

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <iterator>
#pragma warning(disable:4996)

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define MOD 1000000007
using namespace std;

ll x[100005];
ll sv[100005];
ll max0[100005];
ll max1[100005];

int main(int argc, char* argv[])
{
    long n;
    ll c;
    scanf("%ld %lld", &n, &c);

    sv[0]=0;
    long i;
    for(i=0; i<n; i++) {
        long v;
        scanf("%lld %ld", &(x[i]), &v);
        sv[i+1]=sv[i]+v;
    }
    
    max0[0]=0;
    for(i=0; i<n; i++) {
        ll tmp = sv[i+1]-x[i];
        max0[i+1] = MAX(max0[i], tmp);
    }

    max1[n]=0;
    for(i=n-1; i>=0; i--) {
        ll tmp = sv[n]-sv[i]-(c-x[i]);
        max1[i] = MAX(max1[i+1], tmp);
    }

    ll ans = MAX(max0[n], max1[0]);

    for(i=0; i<n-1; i++) {
        ll tmp = sv[i+1]-x[i]*2+max1[i+1];
        ans = MAX(ans, tmp);
    }

    for(i=n-1; i>0; i--) {
        ll tmp = sv[n]-sv[i]-(c-x[i])*2+max0[i];
        ans = MAX(ans, tmp);
    }
    
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 3328