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

using namespace std;

using ll = long long;

constexpr ll MOD = 1000000007;

#ifndef ONLINE_JUDGE
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
#else
#define print(...)
#endif


int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll n,m;
    cin >> n >> m;

    vector<ll> H(n,0);
    vector<ll> H_me_max(n,1);
    for(ll i=0; i<n; i++){
        cin >> H[i];
    }
    
    for(ll i=0; i<m; i++){
        ll a,b;
        cin >> a >> b;
        a--;b--;
        if(H[a] <= H[b]){
            H_me_max[a] = 0;
        }
        if(H[a] >= H[b]){
            H_me_max[b] = 0;
        }
    }

    ll ans=0;
    for(ll i=0; i<n; i++){
        if(H_me_max[i] == 1)
            ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4784
#include <bits/stdc++.h>
using namespace std;
int main()
{
    cout << fixed << setprecision(10);

    int n;
    cin >> n;
    vector<long double> x(n), y(n);
    for(int i = 0; i < n; i++)
        cin >> x[i];
    for(int i = 0; i < n; i++)
        cin >> y[i];
    
    long double m[4]{0};
    for(int i = 0; i < n; i++) {
        m[0] += abs(x[i] - y[i]);
        m[1] += (x[i] - y[i]) * (x[i] - y[i]);
        m[2] += abs((x[i] - y[i]) * (x[i] - y[i]) * (x[i] - y[i]));
        m[3] = max(m[3], abs(x[i] - y[i]));
    }
    m[1] = sqrtl(m[1]);
    m[2] = cbrtl(m[2]);
    for(int i = 0; i < 4; i++)
        cout << m[i] << '\n';
    return 0;
}


Measured memory_bytes: 3468
/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
        Comilla  University

*/
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define ll long long
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node
#define spc " "
#define  E  2.71828182845904523536
#define pb push_back
#define pp pop_back
#define valid(nx,ny) nx>=0 && nx<n && ny>=0 && ny<m
#define ee endl
#define pii pair<int,int>
#define infinity 10000000000000000
#define mod 1000000007
int fx[]={0,0,+1,-1};
int fy[]={+1,-1,0,0};

using namespace std;
///check n=1;
///check corner case;
const int maX=1e5+1;
vector<ll>Graph[maX],cost[maX];
ll visit[maX];


int main()
{
    ll a,b,c;
    cin>>a>>b>>c;
    cout<<c<<spc<<a<<spc<<b<<endl;
return 0;
}


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


using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007



int main(){
  
  int d;
  int res = 0;
  cin >> d;
  vector<int> c(26);
  rep(i,26)cin >> c[i];
  vector<vector<int>> v(d,vector<int>(26));
  vector<int> last(26,0);
  rep(i,d)rep(j,26){
    int x;cin >> x;
    v[i][j] = x;
  }
  for(int i = 1;i <= d;i++){
    int x;cin >> x;
    x--;
    last[x] = i;
    res += v[i-1][x];
    rep(j,26)res -= c[j]*(i-last[j]);
    cout << res << endl;
  }
  
  


  return 0;
}

Measured memory_bytes: 3644
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	scanInit()

	s1 := strings.ToUpper(nextStr())
	s2 := strings.ToUpper(nextStr())
	s3 := strings.ToUpper(nextStr())

	fmt.Printf("%c%c%c", s1[0], s2[0], s3[0])

}

// ---- readfunc
var sc = bufio.NewScanner(os.Stdin)

func scanInit() {
	const cap = 200 * 1024 // default=64*1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1784
S = input()
T = input()

l = len(S)

ad_list = [[] for i in range(l)]
ad_list2 = [[] for i in range(l)]

al_dict = {}
al_dict2 = {}

for i, moji in enumerate(S):
    if moji not in al_dict:
        al_dict[moji] = i
    else:
        ad_list[al_dict[moji]].append(i)

for i, moji in enumerate(T):
    if moji not in al_dict2:
        al_dict2[moji] = i
    else:
        ad_list2[al_dict2[moji]].append(i)

if ad_list==ad_list2:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 49200
#include<iostream>
#include<cstdio>
#include<list>
#include<algorithm>
#include<cstring>
#include<string>
#include<queue>
#include<cmath>
using namespace std;
int main(void)
{
	int a,b,c;
	cin>>a>>b>>c;
	if(a==b&&a!=c&&b!=c)
		cout<<"Yes"<<endl;
	else if(a!=b&&b==c&&a!=c)
		cout<<"Yes"<<endl;
	else if(a==c&&b!=c&&a!=b)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;

}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc149/tasks/abc149_e

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP(a, n) REP(i, n) printf("%d%c", a[i], i + 1 == n ? '\n' : ' ')
#define DUMP2D(a, n, m) REP(i, n) REP(j, m) printf("%d%c", a[i][j], j + 1 == m ? '\n' : ' '); puts("")

const int N_MAX = 1e5;

int N;
ll M;
int A[N_MAX];

ll acc[N_MAX + 1];
ll c;
ll ans;

void calc(int x, bool f) {
  c = 0; ans = 0;
  REP(i, N) {
    int j = lower_bound(A, A + N, x - A[i]) - A;
    c += N - j;
    if (f) {
      ans += acc[N] - acc[j];
      ans += (ll)A[i] * (N - j);
    }
  }
  if (f) ans -= (c - M) * x;
}

bool C(int x) {
  calc(x, false);
  return c < M;
}

void solve() {
  sort(A, A + N);
  REP(i, N) acc[i + 1] = acc[i] + A[i];

  int hi = 4e5;
  int lo = 0;
  while (hi - lo > 1) {
    // printf("hi: %d, lo :%d\n", hi, lo);
    int mi = (hi + lo) / 2;
    if (C(mi)) hi = mi;
    else lo = mi;
  }
  calc(lo, true);
  printf("%lld\n", ans);
}

void input() {
  scanf("%d%lld", &N, &M);
  REP(i, N) scanf("%d", A + i);
}

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


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

int main()
{
	int a, b, c;
	int tmp;
	cin >> a >> b >> c;

	if (b < a) {
		tmp = a;
		a = b;
		b = tmp;
	}
	
	if (c < b && a < c) {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}
	return 0;


}

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

using namespace std;
typedef long long ll;
const int MAXN = 100 * 1000 + 4;
const ll MOD = 1e9 + 7;
ll dp[MAXN];
ll n, k;

ll pw(ll a, ll b){
	if( b == (ll)0)
		return (ll)1;
	a %= MOD;
	if( b % 2 )
		return (pw(a * a, b/2) % MOD * a) % MOD;
	else
		return pw(a * a, b/2) % MOD;
}

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin >> n >> k;
	for( ll kp = k; kp >= 1; kp --){
		ll g = pw(k/kp, n) % MOD;
		ll p = 0;
		for( int j = 2 * kp; j <= k; j += kp)
			p = (p + dp[j]) % MOD;
		dp[kp] = (g - p + MOD) % MOD;
//		cout << dp[kp] << endl;
	}
	ll ans = 0;
	for( int i = 1; i <= k; i ++){
		ans = (ans + (dp[i] % MOD * i % MOD)) % MOD;
		ans %= MOD;
	}
	cout << ans % MOD << endl;
	return 0;
}


Measured memory_bytes: 4376
#include <iostream>
#include <string>
#include <vector>
#include <tuple>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <cstdio>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#define int long long
#define rep(i,n) for(int i=0; i<n; i++)
#define all(v) v.begin(),v.end()
using namespace std;

signed main(){
	int n,a;
	double N;
	cin>>n;
	a=(n+1)/2;
	N=a*1.0/n;
	printf("%.8lf",N);
}


Measured memory_bytes: 256
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T
import Data.Bool (bool)

main :: IO ()
main = do
  [x, y] <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  putStrLn . bool "No" "Yes" $ even y && 2 * x <= y && y <= 4 * x

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n
{-# INLINE unsafeTextToInt #-}


Measured memory_bytes: 3740
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
    int W , H ;
    while(1){
        cin >> H >> W;
        if ( H == 0 && W == 0 ) break;
        for (int i = 0; i < H; i++ ){
            for(int j = 0; j < W; j++ ){
                if( (i+j)%2 == 0  ){
                cout << '#';       
                } else {
                cout << '.';  
            }
        }
        cout << "\n";
    }
        cout << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1152
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main(){
  ll n;cin>>n;
  vl a(n);
  rep(i,n)cin>>a[i];
  ll count=0;
  ll i=1;
  while(i!=2){
    count++;
    i=a[i-1];
    if(count>2*n){
      cout<<-1<<endl;
      return 0;
    }
  }
  cout<<count<<endl;
}

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

#define swap(X, Y) {char temp; temp = (X); (X) = (Y); (Y) = temp;}

void rotate(char str[]);

int main()
{
    char s[128], t[128];
    int len;
    int cnt;
    
    scanf("%s", s);
    scanf("%s", t);

    len = strlen(s);
    cnt = 0;
    while (cnt < len && strcmp(s, t) != 0) {
        rotate(s);
        cnt++;
    }

    if (cnt < len) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }

    return 0;
}

void rotate(char str[])
{
    int i, j;
    int end = strlen(str) - 1;

    for (i = end - 1; i >= 0; i--) {
        swap(str[i], str[end]);
    }

    return;
}


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

int main(){
  int n;
  cin>>n;
  int arr[n];
  for(int i=0;i<n;i++){
    cin>>arr[i];
  }
  n--;
  int count = 0;
  for(int i=1;i<n;i++){
    if((arr[i]<arr[i-1] && arr[i]>arr[i+1]) || (arr[i]>arr[i-1] && arr[i]<arr[i+1])){
      count++;
    }
  }
  cout<<count<<endl;
  
    return 0;
}

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

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

    ll n;
    cin >> n;
    vector<ll> x(n);
    for (ll i = 0;i < n;i++){
        cin >> x[i];
    }
    vector<ll> s(n);
    for (ll i = 0;i < n;i++){
        s[i] = x[i];
    }
    sort(s.begin(), s.end());
    ll ms = s[(n/2)-1];
    ll ml = s[n/2];

    if (ms == ml){
        for (ll i = 0; i < n; i++){
            cout << ms << "\n";
        }
    }
    else{
        for (ll i = 0; i < n; i++){
            if (x[i] >= ml){
                cout << ms << "\n";
            }
            else{
                cout << ml << "\n";
            }
        }
    }
}

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

int main(){
	int n,m;
    cin>>n>>m;
    int ans=n;
    for(int i=0;i<m;i++){
    	int a; cin>>a;
        ans-=a;
    }
  if(ans>=0) cout<<ans;
  else cout<<"-1";
}


Measured memory_bytes: 3576
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int min = 1000000;
		int max = -1000000;
		long sum = 0;
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			if (n < 0 || n > 10000) {
				throw new RuntimeException();
			}
			int ai;
			for (int i = 1; i <= n; i++) {
				ai = sc.nextInt();
				if (ai < min) {
					min = ai;
				}
				if (ai > max) {
					max = ai;
				}
				sum += ai;
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		System.out.printf("%d %d %d\n", min, max, sum);
	}
}

Measured memory_bytes: 41420
/***************************************************************
	File name: ARC096E.cpp
	Author: ljfcnyali
	Create time: 2020年07月23日 星期四 21时42分23秒
***************************************************************/
#include<bits/stdc++.h>

using namespace std;

#define REP(i, a, b) for ( int i = (a), _end_ = (b); i <= _end_; ++ i ) 
#define mem(a) memset ( (a), 0, sizeof ( a ) ) 
#define str(a) strlen ( a ) 
#define pii pair<int, int>
#define int long long
typedef long long LL;

const int maxn = 3010;

int n, Mod, s[maxn][maxn], ans, fac[maxn], inv[maxn];

inline int power(int a, int b, int Mod) { int r = 1; while ( b ) { if ( b & 1 ) r = r * a % Mod; a = a * a % Mod; b >>= 1; } return r; }

inline int C(int n, int m) { return n < m ? 0 : (fac[n] * inv[m] % Mod) * inv[n - m] % Mod; }

inline int sgn(int x) { return x & 1 ? -1 : 1; }

signed main()
{
    scanf("%lld%lld", &n, &Mod);
    fac[0] = inv[0] = 1; REP(i, 1, n) fac[i] = fac[i - 1] * i % Mod;
    inv[n] = power(fac[n], Mod - 2, Mod); for ( int i = n - 1; i >= 1; -- i ) inv[i] = inv[i + 1] * (i + 1) % Mod;
    s[0][0] = 1;
    REP(i, 1, n + 1) REP(j, 1, i) s[i][j] = (s[i - 1][j - 1] + s[i - 1][j] * j) % Mod;
    REP(i, 0, n) REP(j, 0, i)
    {
        int ret = sgn(i) * power(2, power(2, n - i, Mod - 1), Mod) * s[i + 1][j + 1] % Mod;
        ret = ret * C(n, i) % Mod;
        ret = ret * power(power(2, n - i, Mod), j, Mod) % Mod;
        ans = (ans + ret) % Mod;
    }
    printf("%lld\n", (ans + Mod) % Mod);
    return 0;
}


Measured memory_bytes: 50060
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;

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

    ll N, L;
    cin >> N >> L;

    ll taste = 0;
    Rep (i, N) {
        taste += L + i;
    }

    if (0 < L) taste -= L;
    else if (L <= 0 && 0 <= L+N-1) taste -= 0;
    else taste -= L+N-1;

    cout << taste << "\n";
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
using namespace std;
typedef long long LL;
const int SIZEN = 110;
int L[SIZEN];
int ans = 0;
int main(){
    int N;scanf("%d",&N);
    for(int i = 1;i <= N;i++)scanf("%d",&L[i]);
    sort(L+1,L+1+N);
    for(int i = 1;i <= N;i++){
        for(int j = i + 1;j <= N;j++){
            for(int k = j + 1;k <= N;k++){
                if(L[i] == L[j] || L[i] == L[k] || L[k] == L[j])continue;
                if(L[i] + L[j] > L[k]){
                    ans++;
                }
            }
        }
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define M 1000000007
#define ll long long
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define REPI(i,a,b) for(ll i=b-1;i>=a;i--)
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define G(a,b) get<a>(b)
#define VI vector<int>
#define VLL vector<long long>

#define o_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define o_setll tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
//member functions :
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set

ll modI(ll a, ll m);
ll gcd(ll a, ll b);
ll powM(ll x, unsigned ll y, unsigned ll m);
void pairsort(int a[], int b[], int n);
void pairsortll(ll a[],ll b[],ll n);
ll logint(ll x,ll y);


ll gcd(ll x,ll y)
{
    if(x==0) return y;
    return gcd(y%x,x);
}

ll powM(ll x,ll y,ll m)
{
    if(y==0) return 1;
    ll p=powM(x,y/2,m)%m;
    p=(p*p)%m;
    return (y%2==0)?p:(x*p)%m;
}

ll modI(ll a, ll m)
{
    ll m0=m,y=0,x=1;
    if(m==1) return 0;
    while(a>1)
    {
        ll q=a/m;
        ll t=m;
        m=a%m;
        a=t;
        t=y;
        y=x-q*y;
        x=t;
    }
    if(x<0) x+=m0;
    return x;
}

void pairsort(int a[],int b[],int n)
{
    pair<int,int> v[n];
    REP(i,0,n)
    {
        v[i].F=a[i];
        v[i].S=b[i];
    }
    sort(v,v+n);
    REP(i,0,n)
    {
        a[i]=v[i].F;
        b[i]=v[i].S;
    }
}

void pairsortll(ll a[],ll b[],ll n)
{
    pair<ll,ll> v[n];
    REP(i,0,n)
    {
        v[i].F=a[i];
        v[i].S=b[i];
    }
    sort(v,v+n);
    REP(i,0,n)
    {
        a[i]=v[i].F;
        b[i]=v[i].S;
    }
}

ll logint(ll x,ll y)
{
    ll ans=0;
    ll a=1;
    for(ll i=0;i<=x;i++)
    {
        if(x<a)
        {
            return ans;
        }
        ans++;
        a*=y;
    }
    return -1;
}

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

    /*
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    */

    ll q=1;
    //cin>>q;
    while(q--)
    {
        ll n,m;
        cin>>n>>m;
        static ll a[1005][1<<12];
        REP(i,0,1<<12)
        {
            REP(j,0,1005)
            {
                a[j][i]=M;
            }
        }
        a[0][0]=0;
        REP(i,0,m)
        {
            ll v,b;
            cin>>v>>b;
            ll t=0;
            REP(j,0,b)
            {
                ll tt;
                cin>>tt;
                t|=(((ll)1)<<(tt-1));
            }
            REP(j,0,1<<n)
            {
                a[i+1][j]=min(a[i+1][j],a[i][j]);
                a[i+1][t|j]=min(a[i+1][t|j],v+a[i][j]);
            }
        }
        if(a[m][(1<<n)-1]==M) cout<<-1;
        else cout<<a[m][(1<<n)-1];
    }

    return 0;
}


Measured memory_bytes: 32384
import math
N,D=map(int,input().split())
xy = [map(int, input().split()) for _ in range(N)]
x, y = [list(i) for i in zip(*xy)]
b=0
for k in range(N):
  if math.sqrt(x[k]*x[k]+y[k]*y[k])<=D:
    b+=1
print(b)    

Measured memory_bytes: 116668
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var l = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int A = l[0], B = l[1];

            Console.WriteLine(Math.Max(0, A - B * 2));
        }
    }
}


Measured memory_bytes: 13268
n, m = map(int, input().split())
A = 0
arr = [int(i) for i in input().split() ]
arr.sort(reverse = True)
A = sum(arr)
x = A/(4 * m)
count = 0
for i in arr:
	if i >= x:
		count +=1
	else:
		break

if count >= m:
	print("Yes")
else: print("No")



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

#define int long long 

int ans[510][510];

void dfs(int left, int right, int val){ 
  
  if( right - left == 1 ){ 
    return ;
  }
    
  // 半開区間[left,right)
  
  int mid = (left+right)/2;
  
    for(int i = left; i < mid; i++){ 
      for(int j = mid; j < right; j++){
        ans[i][j] = val; ans[j][i] = val;
      }
    }
  
    dfs(left,mid,val+1); dfs(mid,right,val+1);
  
}



signed main(void){ 
  
  int N; cin >> N; 
  
  dfs(0,N,1); // (今見ているサイズ / 持っている値) 
  
  
  for(int i = 0; i < N; i++){
    for(int j = i+1; j < N; j++){ 
      cout << ans[i][j] << " ";
    }
    cout << endl;
  }
  
  return 0;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MAX 100000
#define  MOD  998244353
const int mod=1e9+7;
#define tezz std::ios::sync_with_stdio(false);std::cin.tie(NULL);std::cout.tie(NULL);
#define ull unsigned long long
#define pb push_back
#define vll vector<ll>
int main(){
        long long int NUMBER1,NUMBER2,NUMBER3,NUMBER4;
        cin>>NUMBER1>>NUMBER2>>NUMBER3>>NUMBER4;
        for(ll i=0;NUMBER1>0 && NUMBER3>0;i++)
        {
            if(i%2==0)
                NUMBER3-=NUMBER2;
            else
                NUMBER1-=NUMBER4;
        }
        if(NUMBER1>0 && NUMBER3<=0)
            cout<<"Yes";
        else
            cout<<"No";
        return 0;
}

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

int main() {
  long n, a, b;
  cin >> n >> a >> b;

  long x;
  long base = (n / (a + b)) * a;
  if (n <= (a + b)) {
    if (n <= a) {
      x = n;
    } else {
      x = a;
    }
  } else if (n % (a + b) < a) {
    x = base + n % (a + b);
  } else {
    x = base + a;
  }
  cout << x << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int test;
    scanf("%d",&test);
    while(test--)
    {
        int x1,y1,x2,y2,x3,y3,x4,y4;
        scanf("%d%d%d%d%d%d%d%d", &x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4);
        int X1,X2,Y1,Y2;
        if((y2-y1)*(x4-x3)-(y4-y3)*(x2-x1)==0)
            printf("2\n");
        else if((y2-y1)*(y4-y3)+(x4-x3)*(x2-x1)==0)
            printf("1\n");
        else
            printf("0\n");

    }
}



Measured memory_bytes: 2140
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
ld eps=1e-9;

struct aa {
	int x;
	int y;
	int n;
	int w;
};
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,1,0,-1 };
class Compare {
public:
	//aa?????????????????¶
	bool operator()(const aa&l, const aa&r) {
		return l.n> r.n;
	}
};


vector<vector<int>>wheres(4);
vector<vector<int>>anext;
int main() {
	while (1) {
		int H, W, N; cin >> H >> W >> N;
		anext.clear();
		wheres.resize(4);
		if (!H)break;
		string st;
		cin >> st;
		int way = 3;
		vector<int>ways;
		ways.push_back(way);
		wheres[way].push_back(0);
		for (int i = 0; i < N; ++i) {
			if (st[i] == 'L') {
				way = (way + 1) % 4;
			}
			else {
				way = (way + 3) % 4;
			}
			ways.push_back(way);
			wheres[way].push_back(i + 1);
		}
		for (int i = 0; i < N; ++i) {
			vector<int>v;
			for (int j = 0; j < 4; ++j) {
				auto it = upper_bound(wheres[j].begin(), wheres[j].end(), i);
				if (it == wheres[j].end())v.push_back(1e8);
				else v.push_back(*it);
			}
			for (int j = 0; j < ways[i]; ++j) {
				rotate(v.begin(), v.end(),v.end());
			}
			anext.push_back(v);
		}
		wheres.clear();
		vector<vector<int>>field(H + 2, vector<int>(W + 2, 0));
		for (int x = 0; x <= W + 1; ++x) {
			int y = 0;
			field[y][x] = 1;
			y = H + 1;
			field[y][x] = 1;
		}
		for (int y = 0; y <= H + 1; ++y) {
			int x = 0;
			field[y][x] = 1;
			x = W + 1;
			field[y][x] = 1;
		}
		int memo[1001][1001][4];
		for (int i = 0; i < 1001; ++i) {
			for (int j = 0; j < 1001; ++j) {
				for (int k = 0; k < 4; ++k) {
					memo[i][j][k] = 1e8;
				}
			}
		}
		int gx, gy;
		int sx, sy;
		for (int i = 0; i < H; ++i) {
			string ast; cin >> ast;
			for (int j = 0; j < W; ++j) {
				if (ast[j] == 'G') {
					gx = j + 1; gy = i + 1;
				}
				else if (ast[j] == 'S') {
					sx = j + 1; sy = i + 1;
				}
				else if (ast[j] == '#') {
					field[i + 1][j+1] = true;
				}
			}
		}
		priority_queue<aa, vector<aa>, Compare>que;
		que.push(aa{ sx,sy,0 ,3});
		memo[sy][sx][3] = 0;
		string ans = "No";
		while (!que.empty()) {
			aa atop(que.top());
			que.pop();
			const int px = atop.x;
			const int py = atop.y;
			const int pn = atop.n;
			const int pw = atop.w;
			if (px == gx&&py == gy) {
				ans = "Yes"; break;
			}
			{
				const int nx = px + dx[pw];
				const int ny = py + dy[pw];
				if (!field[ny][nx]) {
					if (memo[ny][nx][pw] > pn) {
						memo[ny][nx][pw] = pn;
						que.push(aa{ nx,ny,pn,pw });
					}
				}
			}
			
			if (pn != N) {
				for (int i = 0; i<4; ++i) {
					if (anext[pn][i]<1e8) {
						if (memo[py][px][i] >anext[pn][i]) {
							memo[py][px][i] = anext[pn][i];
							que.push(aa{ px,py,anext[pn][i],i });
						}
					}
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}

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

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

void ABC133C()
{
	int L, R;
	cin >> L >> R;
	int dx = R - L;
	if (dx >= 2019)
	{
		cout << 0 << endl;
		return;
	}

	int minX = 2018;
	for (int i = L; i < R; ++i)
	{
		int ii = i % 2019;
		for (int j = i + 1; j <= R; ++j)
		{
			int jj = j % 2019;
			int k = (ii * jj) % 2019;
			minX = min(k, minX);
		}
	}
	cout << minX << endl;
}
int main()
{
	ABC133C();
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <algorithm>

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<double, double> Pdd;
typedef pair<ll, ll> P;
typedef pair<P, ll> PP;

const ll mod = 1e9+7;
const int INF = 2e9;
const double epsilon = 1e-7;
const double PI = 3.1415926535;

ll mi(ll x, ll y){
    if(x<y)return x;
    return y;
}

vector <int> v[100000];
priority_queue <int, vector<int>, greater<int>> p[100000];

int depth(int k){
    if(v[k].size() == 0)return 0;
    for(int i = 0;i < v[k].size();i++){
        p[k].push(depth(v[k][i]));
    }
    int maa = 0;
    for(int i = 0;i < v[k].size();i++){
        int pi = p[k].top(); p[k].pop();
        if(pi + v[k].size() - i > maa)maa = pi + v[k].size() - i;
    }
    //cout << k << " " << maa << endl;
    return maa;
}
int main(void){
    int n; cin >> n;
    for(int i = 0;i < n - 1;i++){
        int a; cin >> a; a--; v[a].push_back(i+1);
    }
    cout << depth(0) << endl;
 	return 0;
}


Measured memory_bytes: 18176
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		double []x = new double [n];
		double sum = 0;
		for(int i = 0; i < n ; i++) {
			x[i] = sc.nextDouble();
			String u = sc.next();
			
			if(u.equals("JPY")) {
				 sum += x[i];
			}
			if(u.equals("BTC")) {
				sum += (x[i] * 380000);
			}
		}
		System.out.println(sum);

	}

}


Measured memory_bytes: 24532
@d = gets.to_i
@c = gets.split.map &:to_i
@s = @d.times.map { gets.split.map &:to_i }

def score(schedule)
  last = [0] * 26
  sat = 0
  schedule.each_with_index do |type, day|
    sat += @s[day][type]
    day += 1
    last[type] = day
    sat -= 26.times.sum { |i, day_last| @c[i] * (day - last[i]) }
  end
  sat
end

schedule = [0] * @d
last = [0] * 26
@d.times do |day|
  cmax = last.each_with_index.map { |last, i| [@c[i] * (day - last + 1), i] }.max
  smax = @s[day].each_with_index.map { |s, i| [s, i] }.max
  i = [cmax, smax].max[1]
  schedule[day] = i
  last[i] = day + 1
end

schedule.each do |type|
  p type + 1
end


Measured memory_bytes: 14300
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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; }

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

    bool dp[200000]={};
    dp[0]=1;
    ll pr[6]={100,101,102,103,104,105};

    rep(i,100000)if(dp[i]){
        rep(j,6)dp[i+pr[j]]=true;
    }
    int x;cin>>x;
    if(dp[x]) cout<<1<<endl;
    else cout<<0<<endl;
    return 0;
}


Measured memory_bytes: 512
use std::io::Read;

pub fn read_stdin() -> String {
    let mut s = String::new();
    ::std::io::stdin().read_to_string(&mut s).unwrap();
    s
}

pub trait Parse {
    fn to<T>(&mut self) -> T
    where
        T: std::str::FromStr;
}

impl<'a> Parse for std::str::SplitWhitespace<'a> {
    fn to<T>(&mut self) -> T
    where
        T: std::str::FromStr,
    {
        let word = self.next().unwrap();
        word.parse().ok().unwrap()
    }
}

fn main() {
    let source = read_stdin();
    let mut iter = source.split_whitespace();
    let _: usize = iter.to();
    let mut v = iter.to::<String>().chars().collect::<Vec<_>>();
    v.dedup();
    println!("{}", v.len());
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    cin >> N;
    int ans;
    if(N<2) ans = 1;
    else if(N<4) ans = 2;
    else if(N<8) ans = 4;
    else if(N<16) ans = 8;
    else if(N<32) ans = 16;
    else if(N<64) ans = 32;
    else ans = 64;
    
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	int x = 3;
	if (a == b)
		x -= 1;
	if (b == c)
		x -= 1;
	if (a == c)
		x -= 1;
	if (x == 0)
		cout << "1" << "\n";
	else
		cout << x << "\n";
}

Measured memory_bytes: 3588
//-------------------------------------------
//-               Train Fare                -
//-                                         -
//-       autumn_eel niha katemasen!        -
//-------------------------------------------

#include<iostream>
#include<functional>
#include<queue>
#include<deque>
#include<vector>
#include<algorithm>
using namespace std;

void reader(int *x) {
	int k = getchar_unlocked(); *x = k - '0';
	while (true) {
		k = getchar_unlocked();
		if (k < '0') break;
		*x = ((*x) << 1) + ((*x) << 3) + k - '0';
	}
}
inline void writeln(int x) {
	int s = 0; char f[7];
	while (x) {
		f[s++] = x % 10;
		x /= 10;
	}
	if (!s) f[s++] = 0;
	while (s--) putchar_unlocked(f[s] + '0');
	putchar_unlocked('\n');
}
#pragma warning(disable:4996)
int n, m, q, a[200003], b[200003], c[200003], d[200003], e[100003], f[100003], g[100003];
int h1[100003], h2[100003], dist[100003], E[200003];
vector<pair<int, int> > z[100003]; vector<int> x[100003];
vector<int>D[100003];
int main() {
	reader(&n); reader(&m); reader(&q);
	fill(d, d + m + 1, 1 << 30);
	for (int i = 1; i <= m; i++) { reader(&a[i]), reader(&b[i]); f[a[i]]++; f[b[i]]++; }
	for (int i = 1; i <= q; i++) reader(&c[i]), d[c[i]] = i;
	for (int i = 1; i <= n; i++) { x[i].resize(f[i]); }
	for (int i = 1; i <= m; i++) {
		x[a[i]][g[a[i]]] = b[i]; g[a[i]]++;
		x[b[i]][g[b[i]]] = a[i]; g[b[i]]++;
	}
	fill(dist, dist + n + 1, -1); dist[1] = 0;
	queue<int> Q1; Q1.emplace(1);
	while (!Q1.empty()) {
		int a1 = Q1.front(); Q1.pop();
		for (int i : x[a1]) {
			if (dist[i] == -1) {
				dist[i] = dist[a1] + 1;
				Q1.emplace(i);
			}
		}
	}
	for (int i = 1; i <= m; i++) {
		if (dist[a[i]] > dist[b[i]]) h1[a[i]]++;
		if (dist[b[i]] > dist[a[i]]) h1[b[i]]++;
	}
	for (int i = 1; i <= n; i++)z[i].resize(h1[i]);
	for (int i = 1; i <= m; i++) {
		if (dist[a[i]] > dist[b[i]]) { z[a[i]][h2[a[i]]] = make_pair(b[i], d[i]); h2[a[i]]++; }
		if (dist[b[i]] > dist[a[i]]) { z[b[i]][h2[b[i]]] = make_pair(a[i], d[i]); h2[b[i]]++; }
	}
	for (int i = 1; i <= n; i++) D[dist[i]].push_back(i);
	e[1] = (1 << 30);
	for (int i = 1; i < n; i++) {
		for (int j : D[i]) {
			for (pair<int, int>k : z[j]) {
				e[j] = max(e[j], min(e[k.first], k.second));
			}
		}
	}
	for (int i = 2; i <= n; i++) {
		if (e[i] < 300000) E[e[i]]++;
	}
	for (int i = 1; i <= q; i++) {
		E[i] += E[i - 1];
		writeln(E[i]);
	}
	return 0;
}

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

int main(){

    int m,f,r,num=0;
    std::vector<int> vec_m,vec_f,vec_r;

    while(1){
        cin >> m >> f >> r;
        if(m==-1 && f==-1 && r==-1){
            break;
        }else{
            vec_m.push_back(m);
            vec_f.push_back(f);
            vec_r.push_back(r);
            num++;
        }
    }

    for(int i=0;i<num;i++){
        int sum = vec_m[i] + vec_f[i];
        if(vec_m[i]==-1 || vec_f[i]==-1){
            cout << "F" << endl;
        }else if(sum >= 80){
            cout << "A" << endl;
        }else if(sum >= 65 && sum < 80){
            cout << "B" << endl;
        }else if(sum >= 50 && sum < 65){
            cout << "C" << endl;
        }else if((sum >= 30 && sum < 50) && vec_r[i] >= 50){
            cout << "C" << endl;
        }else if((sum >= 30 && sum < 50) && vec_r[i] < 50){
            cout << "D" << endl;
        }else if(sum < 30){
            cout << "F" << endl;
        }
    }

}


Measured memory_bytes: 3160
#include <iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main()
{
    int n;
    cin>>n;
    int a[n];
    rep(i,n)
    {
        cin>>a[i];
    }
    int cnt=0;
    rep(i,n)
    {
        if(a[a[i]-1]==i+1)cnt++;
        else;
    }
    cout<<cnt/2<<endl;
    return 0;
}


Measured memory_bytes: 640
from collections import deque

N, u, v = map(int, input().split())
u -= 1
v -= 1
table = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    table[a].append(b)
    table[b].append(a)

depthu = [-1] * N
depthu[u] = 0
depthv = [-1] * N
depthv[v] = 0

par = deque([u])
while par:
    p = par.popleft()
    for q in table[p]:
        if depthu[q] == -1:
            depthu[q] = depthu[p] + 1
            par.append(q)

par = deque([v])
while par:
    p = par.popleft()
    for q in table[p]:
        if depthv[q] == -1:
            depthv[q] = depthv[p] + 1
            par.append(q)

p = [i for i in range(N) if depthu[i] < depthv[i]]
if p:
    print(max(depthv[i] - 1 for i in p))
else:
    print(depthu[v] - 1)

Measured memory_bytes: 32692
#include<stdio.h>
 main(void)
{
    int n,m;
    scanf("%d %d",&n,&m);
     
    int a[n][m];
    int b[m];
    long c[n];
     
    int i,j;
     
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            scanf(" %d",&a[i][j]);
        }
    }
    for(i=0;i<m;i++){
        scanf(" %d",&b[i]);
    }
     
    for(i=0;i<n;i++){
        c[i] = 0;
        for(j=0;j<m;j++){
            c[i] += a[i][j]*b[j];
        }
        printf("%d\n",c[i]);
    }
    return 0;
}



Measured memory_bytes: 2112
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};


int main() {
  int N, A, B;
  cin >> N >> A >> B;
  cout << min(A * N, B) << endl;
  return 0;
}

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

int main()
{

    int N, A, B;
    cin >> N >> A >> B;

    int answer = 0;
    for (int i = 1; i < N + 1; i++)
    {
        int a;
        a = i / 10000 + (i % 10000) / 1000 + (i % 1000) / 100 + (i % 100) / 10 + i % 10;
        if (a >= A && a <= B)
        {
            answer += i;
        }
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 256
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <vector>
#include <numeric>
#include <algorithm>
#include <iostream>
#include <string>
#include <cstring>
#include <sstream>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <cassert>
#include <bitset>

using namespace std;

using int64 = long long;

/////////////////////
// Code starts here//
/////////////////////


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

    string S;
    cin >> S;

    cout << (S[2] == S[3] && S[4] == S[5] ? "Yes\n" : "No\n");

    return 0;
}


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

#define mp make_pair
#define eb emplace_back
#define ff first
#define ss second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

#ifdef ONPC
mt19937 rnd(228);
#else
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#endif


const int MAXN = 500;
//#define int long long
const int INF = 1e9;

int dp[MAXN][MAXN];
int used[MAXN][MAXN];

signed main()
{
    #ifdef FILEIO
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(0);
    cin.tie(0);

 	int n;
 	cin >> n;
 	vector<int> p(n * n);

 	for (int i = 0; i < n; i++){
 		for (int j = 0; j < n; j++){
 			used[i][j] = 1;
 		}
 	}

 	for (int i = 0; i < n * n; i++){
 		cin >> p[i];
 	}

 	memset(dp, 0x3f3f3f3f, sizeof dp);

 	deque<pii> q;
 	for (int i = 0; i < n; i++){
 		dp[0][i] = 0;
 		q.eb(0, i);
 		dp[n-1][i] = 0;
 		q.eb(n-1, i);
 		dp[i][0] = 0;
 		q.eb(i, 0);
 		dp[i][n-1] = 0;
 		q.eb(i, n-1);
 	}

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

 	auto v = [&](int x, int y){
 		if (x < 0 || y < 0) return 0;
 		if (x > n-1 || y > n-1) return 0;
 		return 1;
 	};

 	while (!q.empty()){
 		pii cur = q.front();
 		q.pop_front();

 		for (int i = 0; i < 4; i++){
 			int x1 = cur.ff + dx[i];
 			int y1 = cur.ss + dy[i];
 			if (v(x1, y1) && dp[x1][y1] > dp[cur.ff][cur.ss] + 1){
 				dp[x1][y1] = dp[cur.ff][cur.ss] + 1;
 				q.eb(x1, y1);
 			}
 		}
 	}

 	auto bfs = [&](){
 		//deque<pii> q;
 		//q.eb(x, y);

 		while (!q.empty()){
	 		pii cur = q.front();
 			q.pop_front();

 			for (int i = 0; i < 4; i++){
 				int x1 = cur.ff + dx[i];
 				int y1 = cur.ss + dy[i];
 				if (v(x1, y1) && dp[x1][y1] > dp[cur.ff][cur.ss] + used[cur.ff][cur.ss]){
 					dp[x1][y1] = dp[cur.ff][cur.ss] + used[cur.ff][cur.ss];
 					q.eb(x1, y1);
 				}
 			}
 		}
 	};

 	auto cr = [&](){
 		for (int i = 0; i < n; i++){
 			for (int j = 0; j < n; j++){
 				cerr << dp[i][j] << ' ';
 			}
 			cerr << '\n';
 		}
 	};
 	//cr();
 	int ans = 0;
 	for (int i = 0; i < n * n; i++){
 		p[i]--;
 		ans += dp[p[i] / n][p[i] % n];
 		//cerr << ans << ' ';
 		int x = p[i] / n, y = p[i] % n;
 		used[x][y] = 0;
 		for (int k = 0; k < 4; k++){
 			int x1 = x + dx[k];
 			int y1 = y + dy[k];

 			if (v(x1, y1) && dp[x1][y1] > dp[x][y]){
 				dp[x1][y1] = dp[x][y];
 				q.eb(x1, y1);
 			}
 		}
 		bfs();
 		//cr();
 	}

 	cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 6144
N = int(input())
ac = 0
wa = 0
tle = 0
re = 0
for i in range(N):
	jud = input()
	if jud == 'AC':
		ac += 1
	elif jud == 'WA':
		wa += 1
	elif jud == 'TLE':
		tle += 1
	elif jud == 'RE':
		re += 1

print('AC x ' + str(ac))
print('WA x ' + str(wa))
print('TLE x ' + str(tle))
print('RE x ' + str(re))

Measured memory_bytes: 9020
#include <iostream>
#include <string>
#include<iomanip>

using namespace std;

int times(int K, int num) {
	if (num >= K)
		return 1;
	else
		return times(K, 2 * num)*2;
}

int main()
{
	int N, K;
	double rate = 0;
	cin >> N >> K;

	/*
		1からNまで確率を足す
	*/
	for (int i = 1; i <= N; i++) {
		rate += 1.0 / N / times(K, i);
	}
	cout << setprecision(12) << rate;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;
using ll = long long;
#define pi 3.1415926
 
 int a[100005];
 int b[100005];

int main()
{
    int n, k;
    cin >> n >> k;
    int brojac = 0;
    while(n > 0){
        brojac++;
        n = n / k;
    }
    cout << brojac;

}


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

int main(){
    int r, c;
    cin >> r >> c;
    int col[c+1]={};
    for (int i=0; i<r; i++){
        int row=0;
        for (int j=0; j<c; j++){
            int el;
            cin >> el;
            col[j] += el;
            row += el;
            cout << el << ' ';
        }
        col[c] += row;
        cout << row << endl;
    }
    for (int i=0; i<c; i++) cout << col[i] << ' ';
    cout << col[c] << endl;
}


Measured memory_bytes: 3112
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include <cmath>
using namespace std;

#define mod 1000000007
#define ten5 100005
#define ten52 200005
#define ten6 1000005
#define PI 3.1415926
#define pb(x) push_back(x)
#define all(x) x.begin(),x.end()
#define mkpr(x1,x2) make_pair(x1,x2)
typedef long long int ll;


//stack<char> stk;
//set<ll> sll;
//set<pair<ll,ll>> spll;
//map<string,ll> mp;
//map<pair<ll,ll>,ll>::iterator iter;
//map<ll,ll> mp;
//deque<ll> deq;
//vector<ll> vll;
ll num[ten5];
//priority_queue<ll> pq;          //decreasing

int main(void)
{
    ll m,n,i,j,k=0;
    string s;
    cin>>n;
    cin>>s;
    for(i=0;i<n;i++)
    {
        if(s[i]=='W')
            k++;
    }
    j=k;
    for(i=n-1;i>=n-k;i--)
    {
        if(s[i]=='W')
            j--;
    }
    cout<<j;
    return 0;
}





Measured memory_bytes: 3720
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<double,int,double> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf=sizeof(Def)==sizeof(long long)?2e18:1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};

int n,m;
int out;
vi in;
vvi G;
int dfs(int a){
	int t=inf;
	rep(i,G[a].size()){
		t=min(t,dfs(G[a][i]));
	}
	if(t==inf)t=0;
	t++;
	if(t<=m&&in[a])out++;
	return t;
}
int main(){
	out=0;
	cin>>n>>m;
	in=vi(n);
	rep(i,n)cin>>in[i];
	G=vvi(n);
	rep(i,n)if(in[i]){
		G[in[i]-1].pb(i);
	}
	rep(i,n)if(!in[i]){
		out++;
		dfs(i);
	}
	cout<<out<<endl;
}




/*
vi G;
vvi rG;
int out;
int n,k;
int dfs(int a){
	int t=inf;
	rep(i,rG[a].size())t=min(t,dfs(rG[a][i]));
	if(t==inf)t=0;
	t++;
	if(t<=k&&G[a])out++;
	return t;
}
int main(){
	cin>>n>>k;
	G=vi(n);
	rep(i,n)cin>>G[i];
	rG=vvi(n);
	rep(i,n)if(G[i])rG[G[i]-1].pb(i);
	out=0;
	rep(i,n)if(!G[i]){
		out++;
		dfs(i);
	}
	cout<<out<<endl;
}
*/

Measured memory_bytes: 13392
def main():
  import sys
  n=int(input())
  v=list(map(int,input().split()))
  w=sorted(v,reverse=False)

  ans=(w[0]+w[1])/2
  for i in range(2,n):
    ans=max(ans,ans/2+w[i]/2)
  print(ans)
  
if __name__=="__main__":
  main()

Measured memory_bytes: 3060
#include<stdio.h>
int main()
{
	int d, x, s;
	while (scanf("%d", &d)>0) {
		s = 0;
		for (x = d; x+d <= 600; x += d) {
			s += (x*x) * d;
		}
		printf("%d\n", s);
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
using namespace std;
int main (void) {
    int N;
    int D;
    int X;

    cin >> N;
    cin >> D >> X;
    int ans = X;
    for (int i = 0; i < N; i++) {
        int A;
        cin >> A;
        for (int j = 1; j <= D; j += A) {
            ans++;
        }
    }

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

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
     
    public void solve(){
		Scanner sc = new Scanner(System.in);
		
        int a,b,c,hozon;
		
		a = sc.nextInt();
		b = sc.nextInt();
		c = sc.nextInt();
		
		if(a > b){
			hozon = a;
			a = b;
			b = hozon;
		}if(b > c){
			hozon = b;
			b = c;
			c = hozon;
		}if(a > b){
			hozon = a;
			a = b;
			b = hozon;
		}
		
		System.out.println(a+" "+b+" "+c);
    }			
       public static void main(String[]args){
        Main obj = new Main();
        obj.solve();
     }
}

Measured memory_bytes: 17224
n = int(input())
a = list(map(int, input().split()))
a = [0] + a + [0]

d_1 = []
for i in range(1, n+2):
  d_1.append(abs(a[i]-a[i-1]))
d_2 = []
for i in range(1, n+1):
  d_2.append(abs(a[i+1]-a[i-1]))

s_d = sum(d_1)
for i in range(1, n+1):
  print(s_d - d_1[i-1] - d_1[i] + d_2[i-1])


Measured memory_bytes: 20628
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;int tp=0;long long dp[100005],sta[100005],pre[100005];
inline void dac(long long len,long long val) {
	int pos=upper_bound(sta+1,sta+tp+1,len)-sta-1;
	if (!pos) return pre[1]+=val,pre[len+1]-=val,void();
	dp[pos]+=val*(len/sta[pos]);return dac(len%sta[pos],val);
}int main() {int n,q;long long x;scanf("%d%d",&n,&q),sta[tp=1]=n;
	for (int i=1;i<=q;++i) {scanf("%lld",&x);
		while (tp&&sta[tp]>=x) --tp;sta[++tp]=x;
	}dp[tp]=1;for (int i=tp-1;i;--i) {
		dp[i]+=dp[i+1]*(sta[i+1]/sta[i]),dac(sta[i+1]%sta[i],dp[i+1]);
	}pre[1]+=dp[1],pre[sta[1]+1]-=dp[1];
	for (int i=1;i<=n;++i) pre[i]+=pre[i-1],printf("%lld\n",pre[i]);return 0;
}


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

int N,X,Y;
int par[20][200010],dep[200010];
vector<int> R[200010],B[200010];
int INF = 1001001001;
int ans = 0;
bool in[200010];

int LCA(int x,int y)
{
    if(dep[x] > dep[y])swap(x,y);
    int dif = dep[y] - dep[x];
    for(int i = 19; i >= 0; i--)if(dif & (1 << i))y = par[i][y];
    if(x == y)return x;
    for(int i = 19; i >= 0; i--)
    {
        if(par[i][x] != par[i][y])
        {
            x = par[i][x];
            y = par[i][y];
        }
    }
    return par[0][x];
}

int dis(int x,int y)
{
    return dep[x] + dep[y] - 2 * dep[LCA(x,y)];
}

void DFS(int v,int p,int d)
{
    par[0][v] = p;
    dep[v] = d;
    for(int i = 0; i < B[v].size(); i++)
    {
        int w = B[v][i];
        if(w == p)continue;
        DFS(w,v,d + 1);
    }
    return;
}

void DFS2(int v,int p)
{
    in[v] = true;
    for(int i = 0; i < R[v].size(); i++)
    {
        int w = R[v][i];
        if(w == p || dis(v,w) > 2)continue;
        DFS2(w,v);
    }
    return;
}

void DFS3(int v,int p,int d)
{
    if(d >= dis(Y,v) || !in[v])return;
    ans = max(ans,dis(Y,v) * 2);
    for(int i = 0; i < R[v].size(); i++)
    {
        int w = R[v][i];
        if(w == p)continue;
        if(!in[w])ans = INF;
        DFS3(w,v,d + 1);
    }
    return;
}

int main()
{
    scanf("%d%d%d",&N,&X,&Y);
    for(int i = 0; i < N - 1; i++)
    {
        int a,b;
        scanf("%d%d",&a,&b);
        R[a].push_back(b);
        R[b].push_back(a);
    }
    for(int i = 0; i < N - 1; i++)
    {
        int a,b;
        scanf("%d%d",&a,&b);
        B[a].push_back(b);
        B[b].push_back(a);
    }

    DFS(1,0,0);

    for(int i = 1; i < 20; i++)
    {
        for(int j = 1; j <= N; j++)
        {
            if(par[i - 1][j] == 0)par[i][j] = 0;
            else par[i][j] = par[i - 1][par[i - 1][j]];
        }
    }

    DFS2(X,0);

    DFS3(X,0,0);

    if(ans == INF)printf("-1\n");
    else printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 50688