akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;



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

        str = br.readLine();
        String[] strs = str.split("\\s");
        int n = Integer.parseInt(strs[0]);
        int q = Integer.parseInt(strs[1]);

        Queue<Myp> d = new ArrayDeque<Myp>();
        for(int i =0;i<n;i++){
            str = br.readLine();
            String[] temp = str.split("\\s");
            d.offer(new Myp(temp[0],Integer.parseInt(temp[1])));
        }
        
        int endtime = 0;
        while(!d.isEmpty()){
            Myp p = d.poll();
            if(p.gettime() > q){
                p.settime(p.gettime() - q);
                d.offer(p);
                endtime += q;
            }else{
                endtime += p.gettime();
                System.out.println(p.getname() + " " + endtime);
            }
        }

        br.close();
    }
   
}

class Myp{
    private String name;
    private int time;
    
    Myp(String n,int t){
        this.name= n;
        this.time = t;
    }

    Myp(){
        this("",0);
    }
    public String getname(){
        return this.name;
    }

    public int gettime(){
        return this.time;
    }

    public void settime(int t){
        this.time = t;
    }
}


Measured memory_bytes: 76304
#include<bits/stdc++.h>
using namespace std;
vector<int>arr;

int binary_search(int start,int fin,int limit){
	int temp = fin+1;
	while(start<=fin){
		int mid = (start+fin)/2;
		if(arr[mid]<=limit) start = mid+1;
		else fin = mid-1;
	}
	
	
	return temp - start;
}
int main(){
	int n;
	cin>>n;
	arr = vector<int>(n);
	for(int i=0; i<n; i++) cin>>arr[i];
	sort(arr.begin(),arr.end());
	int ret = 0;
	for(int i=arr.size()-1; i>=2; i--){
		for(int j=i-1; j>=1; j--){
			ret+=binary_search(0,j-1,arr[i]-arr[j]);
		}
	}
	cout<<ret;
}

Measured memory_bytes: 3648
#define FNAME ""

#undef __STRICT_ANSI__

#include <bits/stdc++.h> 

using namespace std;

#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define fst first
#define snd second
#define sz(x) (int)((x).size()) 
#define forn(i,n) for (int i = 0; (i) < (n); ++i)
#define fornr(i,n) for (int i = (int)(n) - 1; (i) >= 0; --i)
#define forab(i,a,b) for (int i = (a); (i) < (b); ++i)
#define forba(i,a,b) for (int i = (int)(b) - 1; (i) >= (a); --i)
#define forit(it,c) for(__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(),(c).end()

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) static_cast<void>(0)   
#endif

#ifdef _WIN32
	#define I64 "%I64d"
	#define U64 "%I64u"
#else
	#define I64 "%lld"
	#define U64 "%llu"
#endif

typedef long long ll;
typedef unsigned long long ull;
typedef double dbl;
typedef long double ld;
typedef unsigned int uint;
typedef vector <int> vi;
typedef pair <int, int> pii;

const int N = 1000;

bitset<N> ones[N], allOnes;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int h, w, a, b;
	cin >> h >> w >> a >> b;
	forn(i, w) {
		allOnes[i] = 1;
	}
	forn(i, a) {
		ones[0][i] = 1;
	}
	forab(i, 1, h) {
		ones[i] = ones[i - 1];
	}
	forn(i, b) {
		ones[i] ^= allOnes;
	}
	forn(i, h) {
		forn(j, w) {
			cout << ones[i][j];
		}
		cout << '\n';
	}
	return 0;
}

Measured memory_bytes: 1408
//Started at 18:30

#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 2e5 + 5;

int h, w, n;
int sr, sc;
string s, t;

int32_t main()
{
	IOS;
	int u = 0, d = 0, r = 0, l = 0, up = 0, down = 0, left = 0, right = 0;
	cin >> h >> w >> n;
	cin >> sr >> sc;
	cin >> s >> t;
	int cu = sr, cr = sc, cl = sc, cd = sr;
	for(int i = 0; i < n; i++)
	{
		if(s[i] == 'U')
			cu--;
		else if(s[i] == 'D')
			cd++;
		else if(s[i] == 'R')
			cr++;
		else
			cl--;
		if(cu <= 0)
		{
			cout << "NO";
			return 0;
		}
		if(cd > h)
		{
			cout << "NO";
			return 0;
		}
		if(cr > w)
		{
			cout << "NO";
			return 0;
		}
		if(cl <= 0)
		{
			cout << "NO";
			return 0;
		}
		if(t[i] == 'U')
			cd = max(1LL, cd - 1);
		else if(t[i] == 'D')
			cu = min(h, cu + 1);
		else if(t[i] == 'R')
			cl = min(cl + 1, w);
		else
			cr = max(1LL, cr - 1);
		if(cu <= 0)
		{
			cout << "NO";
			return 0;
		}
		if(cd > h)
		{
			cout << "NO";
			return 0;
		}
		if(cr > w)
		{
			cout << "NO";
			return 0;
		}
		if(cl <= 0)
		{
			cout << "NO";
			return 0;
		}
	}
	cout << "YES";
	return 0;
}

Measured memory_bytes: 920
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define MAXN 20
int a[MAXN+5];
long long ans;
int main()
{
    for(int i=1;i<=3;i++)scanf("%d",&a[i]);
    sort(a+1,a+3+1);
    ans=a[2]-a[1]+a[3]-a[2];
    printf("%lld",ans);
}


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

using namespace std;

int main()
{
	int a[] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
	int k;
	cin >> k;
	cout << a[k - 1] << endl;
}

Measured memory_bytes: 256
N = int(input())
XYH = [[int(i) for i in input().split()] for _ in range(N)]

XYH.sort(key = lambda x:-x[2])#ソートしておくと早く見つかる

X0,Y0,H0 = XYH[0]#コーナーケース、入力が１個の場合
if N == 1:
    print(X0,Y0,H0)
    exit()

for Cx in range(101):#XとYで全探索
    for Cy in range(101):
        H = H0 + abs(X0 - Cx) + abs(Y0 - Cy)
        flag = True#フラグ管理、上手く行ったとき
        for X,Y,h in XYH[1:]:
            if h == max(H - abs(X - Cx) - abs(Y - Cy), 0):
                continue
            flag = False
        if flag:#上手く行ったときだけ出力
            print(Cx,Cy,H)
            exit()#答は１個だけ

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


int main(){
    int n;
    cin >> n;
    int cnt = 0;
    for(int i = 1; i < n; i++){
        for(int j = 1; j < n; j++){
            if((ll)(i * j) >= n) break;
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0; 
}


Measured memory_bytes: 3596
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;

ll invmod(ll x) {
  ll e = mod - 2;
  ll sum = 1;
  ll cur = x;
  while (e > 0) {
    if (e % 2 == 1) {
      sum = sum * cur % mod;
    }
    cur = cur * cur % mod;
    e /= 2;
  }
  return sum;
}

const int N = 900100;
ll fact[N];
ll pow3[N];

ll comb(ll x, ll y) {
  ll ret = fact[x];
  ret *= invmod(fact[y]);
  ret %= mod;
  ret *= invmod(fact[x - y]);
  return ret % mod;
}

int main(void){
  int n, m, k;
  cin >> n >> m >> k;
  fact[0] = 1;
  pow3[0] = 1;
  REP(i, 1, N) {
    fact[i] = (fact[i - 1] * i) % mod;
    pow3[i] = pow3[i - 1] * 3 % mod;
  }
  
  // \sum_{b', c'} fact(b' + c' + n - 1) / fact(b') / fact(c') / fact(n - 1) * 3^(m - b' + k - c')
  // = \sum_{d = 0}^{m + k} fact(d + n - 1) / fact(n - 1) / fact(d) \sum_{b = max(0, d - k)}^{min(d, m)} C(d, b) 3^{m + k - d}
  ll sum = 0;
  ll cur = 1;
  REP(d, 0, m + k + 1) {
    ll tmp = fact[d + n - 1];
    tmp *= invmod(fact[n - 1]);
    tmp %= mod;
    tmp *= invmod(fact[d]);
    tmp %= mod;
    tmp *= pow3[m + k - d];
    tmp %= mod;
    tmp *= cur;
    sum += tmp;
    sum %= mod;
    cur *= 2;
    if (d >= k) {
      cur += mod - comb(d, d - k);
    }
    if (d >= m) {
      cur += mod - comb(d, m);
    }
    cur %= mod;
  }
  cout << sum << endl;
}


Measured memory_bytes: 14336
#include <bits/stdc++.h>
using namespace std;
long long  w[1001],v[1001],f[107][100007];
#define ll long long
#define F(i,a,b) for(long long i=a;i<=b;i++)
int main()
{
ll n,W,s=0,i,j;
cin>>n>>W;
F(i,1,n){   cin>>w[i]>>v[i]; s+=v[i]; }
F(i,1,s)f[0][i]=30000000000;
F(i,1,n)F(j,1,s)
{
   f[i][j]=f[i-1][j];
   if(j>=v[i])f[i][j]=min(f[i][j],f[i-1][j-v[i]]+w[i]);
}
for(i=s;i>=1;i--)
if(f[n][i]<=W){ cout<<i;  break;}
}


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

int main(){
int H,W;
while(1){
cin>>H>>W;
if(H==0&&W==0) break;
for(int i=0;i<H;i++){
for(int i=0;i<W;i++) cout<<"#";
cout<<endl;
}
cout<<endl;
}
}

Measured memory_bytes: 3056
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define MOD 1000000007
template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }

int main(){
    int H, W;
    cin >> H >> W;
    vector<string> a(H);
    vector<vector<long long>> dp(H+1, vector<long long>(W+1));
    REP(i, H)
        cin >> a[i];

    dp[1][1] = 1;
    for(int i=1; i<=H; i++)
        for(int j=1; j<=W; j++)
            if(a[i-1][j-1] == '.'){
                dp[i][j] += (dp[i-1][j] + dp[i][j-1]) % MOD;
                dp[i][j] %= MOD;
            }
    cout << dp[H][W] << endl;
    return 0;
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

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

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

ll Get(int x){
  static ll dp[100];
  if(x == 0) return 2;  
  if(x == 1) return 1;
  if(dp[x]) return dp[x];
  return dp[x] = Get(x-1) + Get(x-2);
}

int main(){
  int x; cin >> x;
  cout << Get(x) << endl;
  return 0;
}


Measured memory_bytes: 3584
#include<iostream>
#include<cstdlib>
#define int long long
using namespace std;
int ans=(1LL<<31)-1,x[105],n;
signed main(){
	int n;cin>>n;
	for(int i=1;i<=n;++i)cin>>x[i];
	for(int i=1;i<=100;++i){
		int tmp=0;
		for(int j=1;j<=n;++j){
			tmp+=(i-x[j])*(i-x[j]);
		}
		ans=min(ans,tmp);
	}cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

int main() {
  string s, t = "";
  vector<string> add = {"dream", "dreamer", "erase", "eraser"};
  cin >> s;
  reverse(s.begin(), s.end());
  rep(i, add.size()) reverse(add[i].begin(), add[i].end());
  while (1) {
    rep(i, add.size()) {
      string tmp = t;
      tmp.append(add[i]);
      if (s.compare(0, tmp.size(), tmp) == 0) {
        t = tmp;
        break;
      }
      if (i == (add.size() - 1)) t = tmp;
    }
    if (s.size() <= t.size()) {
      break;
    }
  }
  cout << ((t.compare(0, t.size(), s) == 0) ? "YES" : "NO") << endl;
  return 0;
}


Measured memory_bytes: 696
h, w = map(int, input().split())
a = [list(input()) for _ in range(h)]
s = [set(), set()]
for i in range(h):
    f = True
    for j in range(w):
        f &= (a[i][j] == ".")
    if f:
        s[0].add(i)

for i in range(w):
    f = True
    for j in range(h):
        f &= (a[j][i] == ".")
    if f:
        s[1].add(i)

for i in range(h):
    if i in s[0]:
        continue
    for j in range(w):
        if j in s[1]:
            continue
        print(a[i][j], end="")
    print()


Measured memory_bytes: 9288
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		if (a==b) {
			System.out.println(c);
		}
		if (b == c) {
			System.out.println(a);
		}
		if (c==a) {
			System.out.println(b);
		}
		System.out.println("");
	}
}


Measured memory_bytes: 21844
#include<cstdio>
#include<cstring>
#include<algorithm>
#define MAXN 10000006
using namespace std;
long long n,m,d;
int main()
{
	scanf("%lld%lld%lld",&n,&m,&d);
	double k1=1.0*(n-d)/n;
	double ans=k1*1.0*(m-1)/(1.0*n);
	if(d!=0) ans*=2.0;
	printf("%.10lf",ans);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pb emplace_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define F first
#define S second
#define vll vector<ll>
#define fast ios:: sync_with_stdio(false),cin.tie(0);
#define COUT cout<<fixed<<setprecision(12)
#define SET set<ll,greater<ll>>gquiz
#define ITERATOR set<ll,greater<ll>> :: iterator itr
#define V vector<ll>vector
#define sz size()
//#define A vector<pair<ll,ll>>vect
ll N=100000,M=100000;
#define B vect.push_back(make_pair(N,M));
ll MOD=1000000007;
 
ll gcd(ll a,ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
/*ll ncr(ll n,ll r)
{
	if(n==1 || r==0)
	return 1;
	if(r>n/2)
	r=n-r;
	ll ans=1;
	for(ll i=1;i<=r;i++)
	{
		ans=((ans * n )/i);
		n--;
	}
	return ans;
}*/
ll pow1(ll n,ll k,ll mm){
    if(k==0)return 1;
    if(k%2==0)return (pow1((n%mm)*(n%mm),k/2,mm))%mm;
    return ((n%mm)*(pow1((n%mm)*(n%mm),k/2,mm)%mm))%mm;
}
ll pow(ll a,ll b,ll m)
{
	ll ans=1;
	while(b>0)
	{
		if(b&1)
			ans=(ans*a)%m;
		b=b/2;
		a=(a*a)%m;
	}
	return ans;
}
 
ll modinv(ll k)
{
	return pow(k,MOD-2,MOD);
}

ll ncr(ll n,ll c)
{
    ll t=1;
    c=min(c,n-c);
    for(ll i=1;i<=c;i++)
    {
     	t=(t*(n-i+1))%MOD;
        t=(t*modinv(i))%MOD;
	}
    return t;
}
int main()
{
	ll a,b;
	cin>>a>>b;
    for(ll i=0;i<=100000;i++)
    {
    	if(i*8/100==a && i*10/100==b)
    	{
    		cout<<i;
    		return 0;
    	}
    }
	cout<<"-1";
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <unordered_map>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
const int MAXN = 3456;
int dp[MAXN];
vector<int> G[MAXN];

int main() {
    int N, T;
    scanf("%d %d", &N, &T);
    vector<pii> V;
    for (int i = 0; i < N; i++) {
        int A, B;
        scanf("%d %d", &A, &B);
        V.push_back(make_pair(A, B));
    }
    for (int i = 0; i < MAXN; i++) {
        sort(G[i].rbegin(), G[i].rend());
    }
    sort(V.begin(), V.end());
    int ans = 0;
    for (int i = 0; i < N; i++) {
        int A = V[i].first, B = V[i].second;
        ans = max(ans, dp[T - 1] + B);
        for (int j = T - 1; j >= A; j--) {
            dp[j] = max(dp[j], dp[j - A] + B);
            //printf("i = %d j = %d\n", i, j);
        }
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <math.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <map>

int main (){
	long long N;
	long long temp;
	long long index1;

	scanf("%lld",&N);
	std::vector<long long> A(N+5);
	for (long long i=0; i<N; i++){
		scanf("%lld", &temp);
		//temp = fmin(i,4);
		if (temp==0){
			index1 = i;
		}
		A[temp]++;
	}
	if (A[0]==0 || A[0]>=2 || index1!=0){
		printf("0\n");
		return 0;
	}

	long long ans = 1;
	for (long long i=1; i<N-1; i++){
		for (long long j=0; j<A[i+1];j++){
					ans *= A[i];
					ans = ans%(long long)998244353;
		}

	}
	printf("%lld\n", ans);
	return 0;
}

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

#ifdef _DEBUG
#define debug(x) cerr << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#else
#define debug(x)
#endif

#define all(s) begin(s), end(s)
#define rall(s) rbegin(s), rend(s)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = ((a)-1); i >= (b); i--)
#define pb push_back
#define sz(a) int((a).size())
#define put(a) ((cout) << (a) << (endl))
#define putf(a, n) ((cout) << (fixed) << (setprecision(n)) << (a) << (endl))

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;

static constexpr ll LL_INF = 1LL << 60;
static constexpr int I_INF = 1 << 28;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class T> static inline T gcd(T a, T b);
template <class T> static inline T lcm(T a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);

int main(int argc, char* argv[]) {
  long long N;
  scanf("%lld", &N);

  ll h = sqrt(double(N));

  ll ans = LL_INF;
  rep(i, 1, h + 2) {
    if (N % i) continue;
    ll j = N / i;

    chmin(ans, i + j - 2);
  }

  put(ans);
  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

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

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

template <class T> inline T gcd(T a, T b) { return __gcd(a, b); }

template <class T> inline T lcm(T a, T b) { return (a * b) / gcd(a, b); }

template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}


Measured memory_bytes: 256
#include <cmath>
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<set>
#include<tuple>
#include<bitset>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
ll a[100005];
ll b[100005];
ll c[100005];
int main(void) {
	ll n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> b[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> c[i];
	}
	sort(a, a + n);
	sort(b, b + n);
	sort(c, c + n);
	ll sum = 0;
	for (int i = 0; i < n; i++) {
		int x = lower_bound(a + 0, a + n, b[i]) - a;
		int y = upper_bound(c + 0, c + n, b[i])-c;
		sum += x * (n - y);
	}
	cout << sum << endl;
	return 0;
}


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

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

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

int32_t main(){
   ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
   string s[] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
   string t;
   cin >> t;
   for(int i = 0 ; i < 7 ; i++)
      if(t == s[i])
         cout << 7 - i;
   return 0;
}


Measured memory_bytes: 3660
#include <iostream>
#include <set>
using namespace std;
typedef long long i64;
 
int a[100];
int main() {
    i64 n, k;
    cin >> n >> k;
    set<int> v;
    i64 low = n;
    while (n) {
        if (n >= k) {
            n %= k;
            if (v.count(n)) break;
            v.insert(n);
            low = min(n, low);
        }

        // cout << n << endl;
        if (n < k) {
            n = k - n;
            if (v.count(n)) break;
            v.insert(n);
            low = min(n, low);
        }
    }
    cout << low << endl;
}

// 100000000 1


Measured memory_bytes: 256
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

H, W = nl()

pixels = []
for i in range(H):
    row = s()
    pixels.append(row)
    pixels.append(row)

for i in range(2*H):
    print(pixels[i])



Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#define repp(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define repm(i,a,b) for(int i=(int)a;i>(int)b;--i)
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

int main() {
	int h, w;
	cin >> h >> w;
	vector<string>s;
	string ss;
	repp(i, 0, h) {
		cin >> ss;
		s.push_back(ss);
	}
	int dx[4] = { -1,0,1,0 }; int dy[4] = { 0,1,0,-1 };
	repp(i, 0, h) {
		repp(j, 0, w) {
			if (s[i][j] != '#')continue;
			int count = 0;
			repp(k, 0, 4) {
				int nx = i + dx[k]; int ny = j + dy[k];
				if (nx < 0 || ny < 0 || nx >= h || ny >= w)continue;
				if (s[nx][ny] == '#')++count;
			}
			if (count == 0) {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
bool solve(){
  string s,t;
  cin>>s>>t;
  rep(i,0,s.length()){
    if(s[i]!=t[i]) return false;
  }
  return true;
}
int main(){
    optimizeIO();
    // tc
    // { bool x=solve();
    //   if(x) cout<<"Yes\n";
    //   else cout<<"No\n";
    // }
    int h1,h2,m1,m2,k;
    cin>>h1>>m1>>h2>>m2>>k;
    int ans=(h2-(h1+1))*60+(60-m1)+m2;
    ans-=k;
    cout<<ans<<endl;
}


Measured memory_bytes: 3652
fn main() {
    let nk = read_vec::<usize>();
    let n = nk[0];
    let k = nk[1];
    let v = read_vec::<usize>();

    let mut ret = 0;
    for i in 0..n {
        let h = v[i];
        if h >= k {
            ret += 1;
        }
    }

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

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}


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

int cnt[10];
char s[10];

int main()
{
    scanf("%s", s);
    for (int i = 0; i < strlen(s); ++i)
    {
        cnt[s[i]-'a'] ++;
    }
    if (cnt[0] && cnt[1] && cnt[2]) printf("Yes\n");
    else printf("No\n");
    return 0;
}

Measured memory_bytes: 256
Scanf.scanf "%d" (fun n ->
    let i = int_of_float @@ ceil (sqrt (2. *. float n) -. 0.5) in

    let s =
        if i * (i + 1) >= 2*n && i * (i - 1) < 2 * n then i else
        if i * (i - 1) >= 2*n                        then i - 1 else i + 1
    in

    let rec loop rest cur =
        if rest = 0 then () else
            if rest >= cur then (Printf.printf "%d\n" cur; loop (rest - cur) (cur - 1))
                           else loop rest (cur - 1)
    in
    loop n s
)

Measured memory_bytes: 1280
/*
* Author:sam51305
*/
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(0);
#define endl '\n'
#define f first
#define s second
#define mp make_pair
#define ll long long
#define pii pair <int, int>
#define pll pair <ll, ll>
#define pb push_back
#define ary array
#define MAX 10000010

#define Yes cout << "Yes" <<endl;
#define No cout << "No" << endl;
int main() {
    fastio
    vector<ll> cntDiv(MAX);
    for (int i=1; i < MAX; i++)
        for (int j = i; j < MAX; j += i)
            ++cntDiv[j];
    for (int i = 2; i < MAX; i++)
        cntDiv[i] = cntDiv[i - 1] + i * cntDiv[i];

    int n;
    while (cin >> n)
        cout << cntDiv[n] << endl;
    return 0;
}


Measured memory_bytes: 81236
#include<stdio.h>
int main()
{
	int a,b,c,d;
	scanf("%d %d %d %d", &a,&b,&c,&d);

	while(1){
      c=c-b;
      if(c<=0){
        printf("Yes\n");
        break;
      }
      a=a-d;
      if(a<=0){
		printf("No\n");
        break;
      }

	}
 
	return 0;
}


Measured memory_bytes: 1624
import java.util.*;
public class Main{
    void run(){
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()){
            int N = sc.nextInt();
            int M = sc.nextInt();
            int[] cost = new int[N];
            int[][] rank = new int[3][N];
            for(int i = 0; i < N; i++){
                sc.nextLine();//空白読み込み
                sc.nextLine();//名前読み込み
                cost[i] = sc.nextInt();
                rank[0][i] = sc.nextInt();
                rank[1][i] = sc.nextInt();
                rank[2][i] = sc.nextInt();
                
            }
            int[][] dp = new int[3][M+1];
            for(int i = 0; i < 3; i++){
                for(int ii = 0; ii < N; ii++){
                    for(int iii = 0; iii <= M - cost[ii]; iii++){
                        dp[i][iii+cost[ii]] = Math.max(dp[i][iii+cost[ii]], dp[i][iii]+rank[i][ii]);
                    }
                }
            }
            /*
            System.out.println(Arrays.toString(dp[0]));
            System.out.println(Arrays.toString(dp[1]));
            System.out.println(Arrays.toString(dp[2]));
            */

            int max = 0;
            for(int[] d: dp){
                for(int c: d){
                    max = Math.max(max, c);
                }
            }
            System.out.println(max);
        }
    }
    public static void main(String[] args){
        new Main().run();   
    }
}

Measured memory_bytes: 159432
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;

int main()
{
	int N;
	cin >> N;
	vector<int> count(100001);
	for (auto i = 0; i < N; ++i)
	{
		int A;
		cin >> A;
		++count[A];
	}

	auto odd = 0;
	auto even = 0;
	for (auto i = 1; i < count.size(); ++i)
	{
		if (count[i] > 0)
		{
			if (count[i] % 2 == 0)
			{
				++even;
			}
			else
			{
				++odd;
			}
		}
	}

	if (even > 0 && even % 2 > 0)
	{
		--even;
	}

	cout << odd + even << endl;

	return 0;
}

Measured memory_bytes: 640
#pragma region includes, macros
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <map>
#include <set>
#include <list>
#include <unordered_set>
#include <unordered_map>
#include <stdlib.h>

using namespace std;

typedef int64_t i64;
typedef pair<i64, i64> P;

template<class T>
const T INF = numeric_limits<T>::max();
template<class T>
const T SINF = numeric_limits<T>::max() / 10;
static const i64 MOD = 1000000007;

//int dx[5] = {-1,0,0,0,1}, dy[5] = {0,-1,0,1,0};
//int dx[8] = {-1,0,1,1,1,0,-1,-1}, dy[8] = {1,1,1,0,-1,-1,-1,0};
//int dx[9] = {-1,0,1,1,1,0,-1,-1,0}, dy[9] = {1,1,1,0,-1,-1,-1,0,0};

struct edge {
    i64 from, to, cost;
    edge(i64 to, i64 cost) : from(-1), to(to), cost(cost) {}
    edge(i64 src, i64 to, i64 cost) : from(src), to(to), cost(cost) {}
};

// 多重vectorを可変引数テンプレートで http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<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);
}
//

#pragma endregion

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

int main() {
    i64 n;
    cin >> n;
    i64 f, t, o;
    f = t = o = 0;
    for (int i = 0; i < n; ++i) {
        i64 x;
        cin >> x;
        if(x % 4 == 0) ++f;
        else if(x % 2 == 0) ++t;
        else ++o;
    }
    for (int i = 0; i < n; ++i) {
        if (i % 2 == 0) {
            if (o == 0) {
                break;
            }
            else {
                --o;
            }
        }
        else {
            if (f == 0) {
                cout << "No" << endl;
                return 0;
            }
            else {
                --f;
            }
        }
    }
    cout << "Yes" << endl;
}


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

int main(){
   string str;
  cin>>str;
  int n;
  cin>>n;
  
  for(int i=0;i<str.size();i++)if('z'+1-str[i]<=n && str[i]!='a')n-='z'+1-str[i],str[i]='a';
       
  
  if(n>0){
    if(str[str.size()-1]+(n%26)>'z')str[str.size()-1]='a'+(str[str.size()-1]+(n%26))%('z'+1);
    else str[str.size()-1]+=(n%26);
	   }
    
  cout<<str<<endl;
  



    
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long n,i,j,ans;
  cin>>n;
  ans=n-1;
  for(i=2; i*i<=n; i++){
    if(n%i==0){
      ans=i+n/i-2;
    }
  }
  cout<<ans;
}

Measured memory_bytes: 256
/**************************************************************************
Coded by: Saba Karimi(_VINTAGE)
Institution: AIT PUNE
***************************************************************************/
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back 
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define ld long double
#define int long long int 
/**************************************************************************/
signed main()
{
    fast;
    string s;
    cin>>s;
    map<char,int> mp;
    int n = s.size();
    for(int i=0;i<n;i++)
    {
        mp[s[i]]++;
    }
    if(mp.size()==2)
    {
        int flag = 1;
        for(auto it:mp)
        {
            if(it.second!=2)
            {
                flag = 0;
                break;
            }
        }
        if(flag)cout<<"Yes";
        else cout<<"No";
    }
    else cout<<"No";
}

Measured memory_bytes: 256
import math

def is_int(s):
  if s.is_integer():
  	return int(s)
  else:
  	s

n,d = map(int, input().split())

A = [list(map(int, input().split())) for _ in range(n)]
ans=0

for i in range(n):
	for j in range(i+1,n):
		sum = 0
		for k in range(d):
			sum+=(A[i][k]-A[j][k])**2
		q=is_int(math.sqrt(sum))
		# print(math.sqrt(sum))
		# print(q)
		if isinstance(q, int):
			ans+=1
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
 
#define fi first
#define se second
#define endl '\n'
#define MOD(n,k) ( (n % k) + k ) % k
#define isOn(S, j) (S & (1 << j) )
#define setBit(S, j) (S | (1 << j ) )
#define LSB(S) (S & (-S))

struct ST {
    vi st, v;

    ST (int n) : st(4*n), v(n+2, 1e9) {}

    void cons (int i, int j, int pos) {
        if (i == j) {
            st[pos] = i;
            return;
        }

        int m = (i+j) / 2;
        cons(i, m, pos*2);
        cons(m+1, j, pos*2+1);

        if (v[st[pos*2]] < v[st[pos*2+1]])
            st[pos] = st[pos*2];
        else
            st[pos] = st[pos*2+1]; 
    }

    int query (int i, int j, int a, int b, int pos) {
        if (i > b || j < a)
            return -1;

        if (i >= a && j <= b)
            return st[pos];

        int m = (i+j) / 2;
        int x = query(i, m, a, b, pos*2);
        int y = query(m+1, j, a, b, pos*2+1);

        if (y == -1 || (x != -1 && v[x] < v[y]))
            return x;
        else
            return y;
    }
};

int n, a;
ST st[2](2e5);

struct rango {
    int l, r, mn;

    rango () {}
    rango (int _l, int _r, int _mn) : l(_l), r(_r), mn(_mn) {}

    bool operator < (const rango b) const {
        return st[l%2].v[mn] > st[b.l%2].v[b.mn];
    }
};

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

    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> st[i%2].v[i];
    st[0].cons(1, n, 1);
    st[1].cons(1, n, 1);

    priority_queue<rango> pq;
    pq.emplace(1, n, st[1].query(1, n, 1, n, 1));
    while (pq.size()) {
        rango r = pq.top(); pq.pop();
        int seg = st[1-r.l%2].query(1, n, r.mn, r.r, 1);

        cout << st[r.l%2].v[r.mn] << " " << st[1-r.l%2].v[seg] << " ";

        if (r.mn != r.l)
            pq.emplace(r.l, r.mn-1, st[r.l%2].query(1, n, r.l, r.mn-1, 1));
        if (r.mn != seg-1)
            pq.emplace(r.mn+1, seg-1, st[1-r.mn%2].query(1, n, r.mn+1, seg-1, 1));
        if (seg != r.r)
            pq.emplace(seg+1, r.r, st[1-seg%2].query(1, n, seg+1, r.r, 1));
    }

    return 0;
}  

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

int main( void ) {
    
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    
    string str1, str2;
    for( int i = y1; i < y2; i ++ ) {
        str1.push_back( 'U' );
        str2.push_back( 'D' );
    }
    
    for( int j = x1; j < x2; j ++ ) {
        str1.push_back( 'R' );
        str2.push_back( 'L' );
    }
    
    cout << str1 << str2 << "LU" << str1 << "RDRD" << str2 << "LU";
    
    return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        LongestCommonSubsequence solver = new LongestCommonSubsequence();
        solver.solve(1, in, out);
        out.close();
    }

    static class LongestCommonSubsequence {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            while (n-- != 0) {
                final String x = in.next();
                final String y = in.next();

                out.printf("%d\n", lcs(x, y));
            }
        }

        private int lcs(final String a, final String b) {
            final int alen = a.length();
            final int blen = b.length();

            int[][] dp = new int[alen + 1][blen + 1];

            for (int i = 1; i < alen + 1; i++) {
                for (int j = 1; j < blen + 1; j++) {
                    if (a.charAt(i - 1) == b.charAt(j - 1)) {
                        dp[i][j] = dp[i - 1][j - 1] + 1;
                    } else {
                        dp[i][j] = Math.max(dp[i][j - 1], dp[i - 1][j]);
                    }
                }
            }

            return dp[alen][blen];
        }

    }
}




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

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

    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i, h) cin >> s[i];

    vector<vector<pair<char, int>>> wcnt(h);
    rep(i, h){
        vector<pair<char, int>> c;
        c.push_back(make_pair(s[i][0], 1));
        rep1(j, w){
            if(s[i][j] == c.back().first) ++c.back().second;
            else c.push_back(make_pair(s[i][j], 1));
        }
        wcnt[i] = c;
    }

    vector<vector<pair<char, int>>> hcnt(w);
    rep(i, w){
        vector<pair<char, int>> c;
        c.push_back(make_pair(s[0][i], 1));
        rep1(j, h){
            if(s[j][i] == c.back().first) ++c.back().second;
            else c.push_back(make_pair(s[j][i], 1));
        }
        hcnt[i] = c;
    }

    vector<vector<int>> wmap(h, vector<int>(w, -1));
    rep(i, h){
        int ptr = 0;
        rep(j, wcnt[i].size()){
            int val = -1;
            if(wcnt[i][j].first == '.') val = wcnt[i][j].second;
            for(int k = ptr; k < ptr+wcnt[i][j].second; ++k) wmap[i][k] = val;
            ptr += wcnt[i][j].second;
        }
    }

    vector<vector<int>> hmap(h, vector<int>(w, -1));
    rep(i, w){
        int ptr = 0;
        rep(j, hcnt[i].size()){
            int val = -1;
            if(hcnt[i][j].first == '.') val = hcnt[i][j].second;
            for(int k = ptr; k < ptr+hcnt[i][j].second; ++k) hmap[k][i] = val;
            ptr += hcnt[i][j].second;
        }
    }

    int res = 0;
    rep(i, h) rep(j, w){
        if(wmap[i][j] == -1 || hmap[i][j] == -1) continue;
        res = max(res, wmap[i][j] + hmap[i][j] - 1);
    }

    cout << res << endl;

    return 0;
}

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

int F[101][10];
int P[101][11];

int dp[10];

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

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

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

    int ans = -1e9;
    for(int i = 1; i < 1024; i++) {
        int j = 0;
        int C[101] = {0};
        for(int j = 0; j < N; j++) {
            int k = 0;
            for(int n = i; n > 0; n >>= 1, k++) {
                if((n&1) & F[j][k]) C[j]++;
            }
        }
        int sum = 0;
        for(int j = 0; j < N; j++) {
            sum += P[j][C[j]];
        }
        ans = max(ans, sum);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,d;
    int b=0;
    long double a=0;
    long int x,y;
    cin >> n >> d;
    
    for(int f=0;f<n;f++){
        cin >> x >> y;
        a=sqrt(x*x+y*y);
        if(a<=d){
            b=b+1;
        }
    }
    cout << b;
    return 0;
}

Measured memory_bytes: 3640
#include <stdio.h>

int main(void){
    double w;

    while (scanf("%lf",&w)!=EOF){
        if (w <= 48.0){
            printf("light fly\n");
        } else if(w<=51.0){
            printf("fly\n");
        } else if(w<=54.0){
            printf("bantam\n");
        } else if(w<=57.0){
            printf("feather\n");
        } else if(w<=60.0){
            printf("light\n");
        } else if(w<=64.0){
            printf("light welter\n");
        } else if(w<=69.0){
            printf("welter\n");
        } else if(w<=75.0){
            printf("light middle\n");
        } else if(w<=81.0){
            printf("middle\n");
        } else if(w<=91.0){
            printf("light heavy\n");
        } else {
            printf("heavy\n");
        }
    }    
    return 0;
}

Measured memory_bytes: 1036
#include <iostream>

int main() {
    int i, N, A[210];
    int cnt = 29;
    int pow = 536870912;
    std::cin >> N;
    for (i = 0; i < N; i++) {
        std::cin >> A[i];
        while (A[i] % pow) {
            pow /= 2;
            if (--cnt == 0)
                break;
        }
        if (cnt == 0)
            break;
    }
    std::cout << cnt << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF=1e18,MOD=1e9+7;
const int iINF=1e9;
int main(){
    int n;
    cin>>n;
    vector<int>v(n);
    for(int i=0;i<n;i++)cin>>v[i];
    sort(v.begin(),v.end());
    double sum=v[0];
    for(int i=1;i<n;i++){
        sum=(sum+v[i])/2;
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
#define LL long long
#define PB push_back
#define MP make_pair

int N;
LL s[100000];

int main(){
	cin >> N;
	for(int i=0; i<N; i++) cin >> s[i];
	LL ans = 0;
	for(int D=1; D<N; D++){
		bool visited[100000] ={};
		int l = 0;
		int r = N-1;
		LL sum = 0;
		while(l+D < N && r-D >= 0){
			if(visited[l]) break;
			visited[l] = true;
			if(visited[r]) break;
			visited[r] = true;
			sum += s[l];
			sum += s[r];
			ans = max(ans, sum);
			l += D;
			r -= D;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
#define maxn 500000
char a[maxn],b[maxn];
int s=1;
int main(){
	while(cin>>a[s]){
		s++;
	}
	for(int i=1;i<=s-1;i++){
		b[i]=a[i];
	}
	for(int i=1;i<=s/2;i++){
		swap(a[i],a[s-i]);
	}

	for(int i=1;i<=s-1;i++){
		if(a[i]=='b'){a[i]='d';continue;
		}
		 if(a[i]=='d'){a[i]='b';continue;
		 }
		if(a[i]=='p'){a[i]='q';continue;
		}
		if(a[i]=='q'){a[i]='p';continue;
		}
	}
	
	for(int i=1;i<=s-1;i++){
		if(a[i]!=b[i]){
			cout<<"No"<<endl;return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
// #include <boost/dynamic_bitset.hpp>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <chrono>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <typeindex>
#include <typeinfo>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define DEBUG(x) cout << #x << ": " << x << endl
#define INFILE() freopen("input.txt", "r", stdin)
#define REP(i, a, b) for (int i = (a); i < (b); i++)
#define REPC(i, a) REP(i, 0, a)
#define RREP(i, a, b) for (int i = (a); i >= (b); i--)
#define RREPC(i, a) RREP(i, a, 0)
#define ALL(s) begin(s), end(s)
#define RALL(s) rbegin(s), rend(s)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_i = pair<ll, int>;
using i_ll = pair<int, ll>;
using d_i = pair<double, int>;
using ll_ll = pair<ll, ll>;
using d_d = pair<double, double>;

static constexpr ll LL_MOD = 1000000009;
static constexpr ll LL2_MOD = 1000000007;
static constexpr double EPS = numeric_limits<double>::epsilon();
static constexpr double PI = 3.14159265358979323846264338327950288;

static map<type_index, const char *const> scanType = { { typeid(int), "%d" },
{ typeid(ll), "%lld" },
{ typeid(double), "%lf" },
{ typeid(char), "%c" } };

template <class T> static void scan(vector<T> &v);
static void scan(vector<string> &v, bool isWord = true);
// static boost::dynamic_bitset<> scan(char trueValue = 'o');

int main(int argc, char *argv[]) {
	 //INFILE();

	 ll l;
	 cin >> l;
	 string s;
	 cin >> s;
	 vector<ll> v(l);

	 ll count = 0, minCount;
	 for (int i = 0; i < l; i++) {
		 v[i] = count;
		 if (s[i] == '#') count++;
	 }

	 minCount = count;
	 if (minCount == 0) {
		 cout << 0 << endl;
		 return 0;
	}

	 count = 0;
	 for (int i = l - 1; i >= 0; i--) {
		 if (s[i] == '.') count++;
		 v[i] += count;
		 if (v[i] < minCount) minCount = v[i];
	 }

	 if (minCount > count) minCount = count;

	 if (count == 0) {
		 cout << 0 << endl;
		 return 0;
	}

	 cout << minCount << endl;
	return 0;
}

template <class T> static void scan(vector<T> &v) {
	auto tFormat = scanType[typeid(T)];
	for (T &n : v) {
		scanf(tFormat, &n);
	}
}

static void scan(vector<string> &v, bool isWord) {
	if (isWord) {
		for (auto &n : v) {
			cin >> n;
		}
		return;
	}

	int i = 0, size = static_cast<int>(v.size());
	string s;
	getline(cin, s);

	if (s.size() != 0) {
		i++;
		v[0] = s;
	}

	for (; i < size; ++i) {
		getline(cin, v[i]);
	}
}

//static boost::dynamic_bitset<> scan(char trueValue) {
//	string s;
//	getline(cin, s);
//
//	if (s.size() == 0) {
//		getline(cin, s);
//	}
//
//	for_each(begin(s), end(s),
//		[trueValue](char &c) { c = (c == trueValue) ? '1' : '0'; });
//	return boost::dynamic_bitset<>(string(rbegin(s), rend(s)));
//}


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

int main(){
    int W,H,x,y,r;
    cin>>W>>H>>x>>y>>r;
    if(x>=0 && y>=0 && x+r<=W && y+r<=H)
    cout <<"Yes"<<endl;
    else
    cout <<"No"<<endl;
}


Measured memory_bytes: 3108
S = input()
K = int(input())

if K == 1:
    print(S[0])
else:
    if len(S) == 1:
        print(S)
    else:
        for i in range(min(K,len(S))):
            if S[i] != '1':
                print(S[i])
                exit()
        print(1)


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

int main(){
    int n;
    cin >> n;

    int a[2][n];
    int ans[n];
    for(int i = 0; i < 2; i++){
        for(int j = 0; j < n; j++){
            cin >> a[i][j];
            ans[j] = 0;
        }
    }

    int flag = 0;
    for(int i = 0; i < n; i++){
        flag = 0;
        for(int j = 0; j < n; j++){
            if(i == j){
                ans[i] += a[flag][j];
                flag = 1;
                ans[i] += a[flag][j];
            }else{
                ans[i] += a[flag][j];
            }
        }
    }

    int max_ans = 0;
    for(int i = 0; i < n; i++){
        if(max_ans <= ans[i]){
            max_ans = ans[i];
        }
    }

    cout << max_ans << endl;
}

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

int main(void)
{
        int x,y,z;
        char a[11],b[11],c[11];

        scanf("%s %s %s",a,b,c);
        x=strlen(a)-1;
        y=strlen(b)-1;

        if((a[x]==b[0])&&(b[y]==c[0]))
        printf("YES\n");
        else
        printf("NO\n");

        return 0;
}


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


using namespace std;
using ll = long long;
const int N = 1e6 + 600;



int n,a;
multiset<int>st;
map<int,int>cnt;
vector<int>vec;
int main() {
    cin >> n;
    for(int i = 0; i < (1<<n); ++i){
            cin >> a;
            vec.push_back(a);
            cnt[a]++;
    }
    sort(vec.begin(),vec.end());
    int fst = vec.back();
    if(cnt[vec.back()] > 1)
            fst++,vec.push_back(fst);
    reverse(vec.begin(),vec.end());
    int t = 0;
    vector<int>heads;
    heads.push_back(vec[0]);
    vec.erase(vec.begin());
    while(!vec.empty()){
            vector<int>tmp,tt;
            int indx = 0;
            for(int i = 0; i < vec.size(); ++i){
                    if(vec[i] < heads[indx] && indx < heads.size()){
                            tt.push_back(vec[i]);
                            indx++;
                    }else{
                        tmp.push_back(vec[i]);
                    }
            }
            t++;
            for(auto i:tt)
                    heads.push_back(i);
            sort(heads.rbegin(),heads.rend());
            vec = tmp;
    }
    if(t == n){
            cout << "Yes\n";
            return 0;
    }
    cout << "No\n";


	return 0;
}


Measured memory_bytes: 17564