akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
/*
    s.find_by_order(k) ---> returns iterator to the element at index(from 0) k
    s.order_of_key(val) ---> number of elements that are strictly smaller than the given value
*/
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long int> vl;
typedef vector<vector<int>> vvi;
typedef vector<vector<long long int>> vvl;
typedef pair<int, int> pii;
typedef pair<long long int, long long int> pll;
typedef vector<pair<int, int>> vii;
typedef vector<pair<long long int, long long int>> vll;
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define test() long long int tc; cin >> tc; cin.ignore(); while(tc--) 
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define MOD 1000000007
#define SMOD 998244353
#define pq priority_queue
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sp " "
#define inp(a) ll a;cin>>a;cin.ignore()
#define inps(a,b) ll a,b;cin>>a>>b;cin.ignore()
#define out(a) cout<<SP(20)<<a<<'\n'
#define outs(a,b) cout<<SP(20)<<a<<" "<<b<<'\n'
#define ins insert
#define er erase
#define lb lower_bound
#define ub upper_bound
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define inpa(a,n) ll a[n]; for(int i=0; i<n; i++){cin>>a[i];}
#define inpv(a,n) vl a; for(int i=0; i<n; i++){inp(x);a.pb(x);}
#define outa(a,n) for(int i=0;i<n;i++){cout<<a[i]<<" ";}cout<<'\n';
#define outv(v) for(auto i:v){cout<<i<<" ";}cout<<'\n';
set<char> vow = {'a','e','i','o','u','A','E','I','O','U'};
ll xpow(ll n, ll m){if(m==0){return 1;}else{ll x = xpow(n, m/2);if(m&1){return x*x*n;}else{return x*x;}}}
ll xmod(ll a, ll m){return (((a%m)+m)%m);}
ll xmodpow(ll n, ll m, ll y){if(m==0){return 1;}else{ll x = xmodpow(n, m/2, y);if(m&1){return xmod((xmod((xmod(x,y)*xmod(x,y)),y)*xmod(n,y)),y);}else{return xmod((xmod(x,y)*xmod(x,y)),y);}}}

int main() {
	fast();
 
    /*NA – JEONG – MO – SA – JI – MI – DA – CHAE – TZU*/
    
    deque <char> d;
    string s;
    cin >> s;
    for(auto i:s){
        d.pb(i);
    }
    int turn = 0;
    test(){
        ll x;
        cin >> x;
        if(x==1){
            turn^=1;
            continue;
        }
        else{
            cin >> x;
            char z;
            cin >> z;
            if(x==1&&turn){
                d.pb(z);
            }
            else if(x==1){
                d.push_front(z);
            }
            else if(x==2&&turn){
                d.push_front(z);
            }
            else{
                d.pb(z);
            }
        }
    }
    if(turn){
        reverse(all(d));
    }
    for(auto i:d){
        cout << i;
    }
}

Measured memory_bytes: 976
n = gets.to_i
l = []
n.times do
    a, b = gets.split.map(&:to_i)
    l << [b, a]
end
l.sort!
t = 0
for i in 0 .. n - 1
    if t + l[i][1] > l[i][0]
        puts "No"
        exit
    end
    t += l[i][1]
end
puts "Yes"

Measured memory_bytes: 18552
#include<bits/stdc++.h>
using namespace std;
string S;int n,d,c;
int main(){
	cin>>n>>S;
	for(int i=0;i<S.size();i++){if(S[i]=='(')c++;else c--;d=min(d,c);}
	for(int i=0;i<-d;i++)cout<<"(";cout<<S;for(int i=0;i<c-d;i++)cout<<")";
	return 0;
}

Measured memory_bytes: 256
#include <stdlib.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
const long long INF=1LL << 60;
long long a,b;
long long dp[100200][110];
long long w[110],v[110];





int main(){
 long long a,b;
 cin>>a>>b;
 int ans=0;
 bool flag=true;
 while(flag){
     a/=b;
     ans++;
     //cout<<a<<endl;
     if(a==0){
         break;
     }
 }
 cout<<ans<<endl;
}



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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
template <typename T> bool chmax(T &a, const T& b){if(a < b){a = b;return true;}return false;}
template <typename T> bool chmin(T &a, const T& b){if(a > b){a = b;return true;}return false;}
using ll = long long;

int main()
{
    ll i,j;
    ll n;
    cin >> n;
    vector<ll> a(n);
    for(i = 0;i < n;++i){
        cin >> a.at(i);
    }
    vector<vector<vector<ll>>> dp(n,vector<vector<ll>>(2, vector<ll>(2, -1e9)));
    dp.at(0).at(1).at(1) = a.at(0);
    //dp.at(0).at(1).at(0) =  
    dp.at(0).at(0).at(1) = 0;
    dp.at(0).at(0).at(0) = 0;

    dp.at(1).at(1).at(1) = a.at(1);
    dp.at(1).at(1).at(0) = a.at(0);
    //dp.at(1).at(0).at(1) = 
    dp.at(1).at(0).at(0) = 0;
    for(i = 2;i < n;++i){
        j = i+1;
        if(j%2 == 0){
            dp.at(i).at(1).at(1) = dp.at(i-1).at(0).at(0) + a.at(i);
            dp.at(i).at(1).at(0) = dp.at(i-1).at(1).at(1);
            dp.at(i).at(0).at(0) = max(dp.at(i-1).at(0).at(1), dp.at(i-1).at(0).at(0)); 
        }else if(j%2 == 1){
            dp.at(i).at(1).at(1) = dp.at(i-1).at(1).at(0) + a.at(i);
            dp.at(i).at(0).at(1) = dp.at(i-1).at(0).at(0) + a.at(i);
            dp.at(i).at(0).at(0) = max(dp.at(i-1).at(1).at(1), dp.at(i-1).at(1).at(0)); 
        }
    }
    if(n%2 == 0){
        cout << max(dp.at(n-1).at(1).at(1), dp.at(n-1).at(1).at(0)) << endl;
    }else{
        cout << max(dp.at(n-1).at(0).at(1), dp.at(n-1).at(0).at(0)) << endl;
    }
    return 0;
}

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

int main()
{
    int h,a,sum=0,w;
    cin>>h>>a;
  for(int i=0;i<a;i++)
  {  cin>>w;
    sum=sum+w;}
  
    if(sum>=h)
    cout<<"Yes"<<endl;
    else
    {
        cout<<"No"<<endl;
    }
     
     return 0;

}

Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define int long long
#define CONTAINS_VEC(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
#define CONTAINS_SET(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }

int N, K;
int a[100001];

signed main()
{
	cin >> N >> K;

	for (int i = 1; i <= N; i++)
	{
		int cnt = 0;
		int n = i;
		while (true)
		{
			if (n >= K) break;
			n *= 2;
			cnt++;
		}
		a[i] = cnt;
	}

	int m = 1;
	for (int i = 2; i <= N; i++)
	{
		int b = a[1] - a[i];
		m += pow(2, b);
	}
	int c = N * pow(2, a[1]);

	cout << fixed << setprecision(10) << (m / (double)c) << endl;;

}



Measured memory_bytes: 4096
#include<iostream>

using namespace std;

class Dice{
  private:
    int d_1,d_2,d_3,d_4,d_5,d_6;
  public:
    void setDice(int a,int b,int c,int d,int e,int f){
      d_1 = a;
      d_2 = b;
      d_3 = c;
      d_4 = d;
      d_5 = e;
      d_6 = f;
    }
    void roll_w(){
      int tmp = d_1;
      d_1 = d_3;
      d_3 = d_6;
      d_6 = d_4;
      d_4 = tmp;
    }
    void roll_e(){
      int tmp = d_1;
      d_1 = d_4;
      d_4 = d_6;
      d_6 = d_3;
      d_3 = tmp;
    }
    void roll_n(){
      int tmp = d_1;
      d_1 = d_2;
      d_2 = d_6;
      d_6 = d_5;
      d_5 = tmp;
    }
    void roll_s(){
      int tmp = d_5;
      d_5 = d_6;
      d_6 = d_2;
      d_2 = d_1;
      d_1 = tmp;
    }

    void spin(){
      int tmp = d_2;
      d_2 = d_3;
      d_3 = d_5;
      d_5 = d_4;
      d_4 = tmp;
    }

    int findRight(int top,int front){
      for(int i=0;i < 6;i++){
        for(int j=0;j < 4;j++){
          if((*this).d_1 == top && (*this).d_2 == front) return (*this).d_3;
          (*this).spin();
        }
        if(i % 2 == 0)
        (*this).roll_n();
        else
        (*this).roll_w();
      }
      return -1;
    }

    int getDice(){
      return d_1;
    }

};


int main(){
  int a,b,c,d,e,f,n;
  string cmd;
  Dice D;
  cin >> a >> b >> c >> d >> e >> f;
  D.setDice(a,b,c,d,e,f);
  cin >> n;
  while(n--){
    int t,f;
    cin >> t >> f;
    cout << D.findRight(t,f) << endl;
  }
  return 0;
}


Measured memory_bytes: 3088
{
  const main = (input: string): void | string | number => {
    const r = _reader(input)
    const N = r.n()
    const xys = r.nnls()

    xys.forEach((ab, i) => (ab[2] = i))
    const edges: Edge<number>[] = []

    xys.sort((a, b) => a[0] - b[0])
    // console.log(xys)

    for (let i = 0; i < xys.length - 1; i++) {
      const a = xys[i]
      const b = xys[i + 1]
      const l = Math.min(Math.abs(a[0] - b[0]), Math.abs(a[1] - b[1]))

      edges.push([a[2], b[2], l])
    }
    xys.sort((a, b) => a[1] - b[1])
    for (let i = 0; i < xys.length - 1; i++) {
      const a = xys[i]
      const b = xys[i + 1]
      const l = Math.min(Math.abs(a[0] - b[0]), Math.abs(a[1] - b[1]))

      edges.push([a[2], b[2], l])
    }

    const nodes = _range(N)
    const mst = _kruskal(nodes, edges)

    // console.log(edges)
    // console.log(mst)

    return mst.reduce((p, b) => p + b[2], 0)
  }

  type Edge<T> = [T, T, number]

  const _range = (n: number) => Array.from(Array(n).keys())
  const _unionFind = (n: number) => {
    const par: number[] = Array.from(Array(n).keys())
    const siz: number[] = Array(n).fill(1)

    // 根の検索
    const root = (x: number): number => {
      while (par[x] !== x) x = par[x] = par[par[x]]
      return x
    }
    const merge = (x: number, y: number): boolean => {
      x = root(x)
      y = root(y)
      if (x === y) return false
      if (siz[x] < siz[y]) [x, y] = [y, x]
      // merge technique（データ構造をマージするテク．小を大にくっつける）
      siz[x] += siz[y]
      par[y] = x
      return true
    }
    const issame = (x: number, y: number) => root(x) === root(y)
    const size = (x: number) => siz[root(x)]

    return { root, merge, issame, size }
  }

  const _kruskal = <T>(nodes: T[], edges: Edge<T>[]) => {
    const mst: Edge<T>[] = []
    const sortedEdges = edges.sort((a, b) => a[2] - b[2])
    const keys: string[] = nodes.map(String)
    const lib = keys.reduce((p, c, i) => Object.assign({}, lib, { [c]: i }), {})
    const uf = _unionFind(nodes.length)

    nodes.forEach((v, i) => (lib[String(v)] = i))

    sortedEdges.forEach(edge => {
      const u = lib[String(edge[0])]
      const v = lib[String(edge[1])]

      if (uf.issame(u, v)) return
      mst.push(edge)
      uf.merge(u, v)
    })
    return mst
  }

  const _reader = (str: string, i = 0) => {
    const lines = str.trim().split('\n')
    const s = () => lines[i++] || ''
    const n = () => Number(s())

    const mn = (v: string[]) => v.map(Number)
    const sp = (v: string) => v.split(' ')
    const ss = () => sp(s())
    const nn = () => mn(ss())
    const nls = () => mn(lines.slice(i))
    const nnls = () => lines.slice(i).map(v => mn(sp(v)))

    return { lines, s, n, ss, nn, nls, nnls }
  }

  const _getInput = () => require('fs').readFileSync('/dev/stdin', 'utf8')
  const _res = main(_getInput())

  if (typeof _res === 'number' || typeof _res === 'string') console.log(_res)
}


Measured memory_bytes: 105760
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10, mod = 998244353;
typedef long long ll;

ll f[N]; // 阶乘

ll fp(ll a, ll b){
    ll res = 1;
    while(b){
        if(b & 1) res = res * a % mod;
        b >>= 1;
        a = a * a % mod;
    }
    return res;
}

ll C(ll a, ll b){ // 计算组合数
    return f[a] * fp(f[b], mod - 2) % mod * fp(f[a - b], mod - 2) % mod;   
}

int main(){
    ll n, m, k; cin >> n >> m >> k;
    f[0] = 1;
    for(int i = 1; i <= n; i ++) f[i] = f[i - 1] * i % mod;
    ll ans = 0;
    for(int i = n - k; i <= n; i ++){
        ll tmp = C(n - 1, i - 1) * m  % mod * fp(m - 1, i - 1) % mod;
        ans = (ans + tmp) % mod;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  int N,D;
  cin >> N >> D;
  int ans = 0;
  int term1,term2;
  vector<vector<int>> X(N,vector<int> (D));
  for (int i=0; i<N; i++) {
    for (int j=0; j<D; j++) {
      cin >> X[i][j];
    }
  }
  for (int i=0; i<N-1; i++) {
    for (int j=i+1; j<N; j++) {
      term1 = 0;
      for (int k=0; k<D; k++) {
        term1 += (X[i][k] - X[j][k]) * (X[i][k] - X[j][k]);
      }
      term2 = sqrt(term1);
      if (term1 == term2 * term2) {
        ans++;
      }
    }
  }
  
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
import numpy as np
IN = [list(map(int, input().split())) for _ in range(3)]
c = np.array(IN)
column = np.sum(c, axis=0)
row = np.sum(c, axis=1)
S = np.sum(c)
if S%3==0:
    S_ = S//3
    for i in range(S_+1):
        x = i
        y = S_ - x
        row_ = row - y
        column_ = column - x
        if all(col % 3 == 0 for col in column_) and all(ro % 3 == 0 for ro in row_):
            print("Yes")
            break
    else:
        print("No")
else:
    print("No")

Measured memory_bytes: 27236
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSR(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,m;
char f[305][305],ff[305][305];
ll ans ;
int pos[605][305][305];
vector<int>cnt[605];
ll sol(){
	rep(i,605) {cnt[i].clear(); rep(j,305)rep(k,305) pos[i][j][k]=0;}
	rep(i,n) rep(j,m){
		if(f[i][j] != '#') continue;
		cnt[i+j].pb(i);
	}
	rep(i,605) SORT(cnt[i]);
	rep(i,605){
		if(cnt[i].empty()) continue;
		rep(j,cnt[i].size()) for(int k=j+1;k<cnt[i].size();k++){
			int dif = cnt[i][k]-cnt[i][j];
			pos[i][dif][cnt[i][j]]++;
		}
	}
	rep(i,605)rep(j,305)rep(k,305){ if(k) pos[i][j][k] += pos[i][j][k-1];}
	ll ret = 0;
	rep(i,n) rep(j,m){
		if(f[i][j] != '#') continue;
		for(int k=i+j+2;k<=n-1+m-1;k+=2){
			int lb = i+1, ub = k-j-(k-i-j)/2-1;
			int x = 0;
			if(0<=lb-1 && lb-1<305) x+=pos[k][(k-i-j)/2][lb-1];//POSL(pos[k][(k-i-j)/2],lb);
			int y = 0;
			if(0<=ub) y+=pos[k][(k-i-j)/2][min(303,ub)];//POSR(pos[k][(k-i-j)/2],ub);
			ans += y-x;
		}
		for(int k=i+j-2;k>=0;k-=2){
			int lb = k-j+1, ub = i-(i+j-k)/2-1;
			int x = 0;
			if(0<=lb-1 && lb-1<305) x+=pos[k][(i+j-k)/2][lb-1];//POSL(pos[k][(i+j-k)/2],lb);
			int y = 0;
			if(0<=ub) y+=pos[k][(i+j-k)/2][min(303,ub)];//POSR(pos[k][(i+j-k)/2],ub);
			ans += y-x;
		}
		
	}
	return ret;
}
int main(){
	scanf("%d%d",&n,&m);
	rep(i,n) scanf("%s",&f[i]);
	rep(i,n){
		rep(j,m) for(int k=j+1;k<m;k++){
			if(f[i][j]=='#'&&f[i][k]=='#'&&j%2==k%2){
				int mm = (j+k)/2;
				int d = (k-j)/2;
				if(0<=i-d&&i-d<n&&f[i-d][mm]=='#') ans++;
				if(0<=i+d&&i+d<n&&f[i+d][mm]=='#') ans++;
			}
		}
	}
	rep(i,m){
		rep(j,n) for(int k=j+1;k<n;k++){
			if(f[j][i]=='#'&&f[k][i]=='#'&&j%2==k%2){
				int mm = (j+k)/2;
				int d = (k-j)/2;
				if(0<=i-d&&i-d<m&&f[mm][i-d]=='#') ans++;
				if(0<=i+d&&i+d<m&&f[mm][i+d]=='#') ans++;
			}
		}
	}
	//本質
	ans += sol();
	rep(i,n)rep(j,m) ff[i][j] = f[i][m-1-j];
	rep(i,n)rep(j,m) f[i][j] = ff[i][j];
	ans += sol();
	cout << ans << endl;
}

Measured memory_bytes: 220800
//g++ -std=c++11 -Wall -O2 -o main.exe main.cpp
//g++ -std=c++14 -Wall -O2 -o main.exe main.cpp
 
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <functional>
#include <algorithm>
#include <complex>
#include <numeric>
#include <queue>
#include <stack>
//最大公約数: gcd()
//最小公倍数: lcm()

#define ll long long int

using namespace std;
 
template <typename T>
void sortasc(vector<T> &v){ //vectorを昇順にソート
    sort(v.begin(), v.end(), std::greater<int>());
    return;
}
 
template <typename T>
void sortdesc(vector<T> &v){ //vectorを降順にソート
    sort(v.begin(), v.end(), std::less<int>());
    return;
}

//------

int X, Y;

int main(){
    cin >> X >> Y;

    cout << (X + Y / 2) << endl;

    return 0;
}

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

int main(){
  string S,N;
  cin >> S >> N;
  if(S[0]==N[2] && S[1]==N[1] && S[2]==N[0]){
  cout << "YES" << endl;
  }
  else{
  cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1000000007, INF = 1e9;

int main()
{
    ll n, max_n = 0;
    cin >> n;
    set<string> s;
    map<string, ll> m;
    vector<string> sv(n);
    rep(i, n){
        string t;
        cin >> t;
        s.insert(t);
        if(s.count(t)){
            m[t]++;
            max_n = max(max_n, m[t]);
        }
    }
    int i = 0;
    vector<string> ans(s.size(), "-1");
    for(auto itr = s.begin(); itr != s.end(); itr++){
        if(m[*itr] == max_n){
            ans[i++] = *itr;
        }
    }
    sort(ans.begin(), ans.end());
    rep(i, s.size()){
        if(ans[i] != "-1"){
            cout << ans[i] << endl;
        }
    }
    system("pause");
}

Measured memory_bytes: 37888
#include <iostream>
#include<vector>
#include<algorithm>
using namespace std;
int euqrid(int a,int b){
      return (a % b == 0) ? b : euqrid(b,a % b);
}
int main(void){
   int x;
   cin >> x;
   cout << 360 / euqrid(360,x) << endl;
}


Measured memory_bytes: 3572
var try_count = 0;
function Main(input) {
  var input_splited = input.split('\n');
  var n = input_splited[0];
  var a_array = input_splited[1].split(' ');
  var half_a_array = [];
  
  var all_even = true;
  for (var i = 0; i < a_array.length; i+=1) {
    var n_a = parseInt(a_array[i], 10);
    if (n_a % 2 != 0) {
      all_even = false;
      break;
    } else {
      half_a_array.push(n_a / 2);
    }
  }
 
  if (!all_even) {
    console.log(try_count);
    return;
  }

  try_count += 1;
  var next_input = n+'\n'+half_a_array.join(' ');
  Main(next_input);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 30732
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int H, W;

int main()
{
    cin >> H >> W;
    vector<vector<char>> maze(H + 2, vector<char>(W + 2, '#')); // 迷路のデータを格納
    rep(1, i, H + 1)
    {
        rep(1, j, W + 1)
        {
            char a;
            cin >> a;
            if (a == '.')
            {
                maze[i][j] = '.';
            }
        }
    }

    // 四方向探索用の配列
    vector<int> dx(4), dy(4);
    dx = {1, 0, -1, 0};
    dy = {0, 1, 0, -1};

    int ans = 0;

    // すべてのマスを始点にbfsする
    rep(1, i, H + 1)
    {
        rep(1, j, W + 1)
        {
            // 始点にできないならスルー
            if (maze[i][j] == '#')
            {
                continue;
            }

            // bfsのためのデータ構造
            vector<vector<int>> dist(H + 2, vector<int>(W + 2, -1));
            queue<P> que;

            // 初期化
            dist[i][j] = 0;
            que.push(P(i, j));

            // bfs本体
            while (que.size())
            {
                P v = que.front();
                que.pop();
                rep(0, k, 4)
                {
                    int nx = v.first + dx[k];
                    int ny = v.second + dy[k];
                    // 壁か探索みならスルー
                    if ((maze[nx][ny] == '#') || (dist[nx][ny] != -1))
                    {
                        continue;
                    }
                    dist[nx][ny] = dist[v.first][v.second] + 1;
                    que.push(P(nx, ny));
                    ans = max(ans, dist[nx][ny]);
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define st first
#define nd second

using namespace std;

void debug_out() { cerr << endl; }
template<class T> ostream& prnt(ostream& out, T v) { for(auto e : v) out << e << ' '; return out;}
template<class T> ostream& operator<<(ostream& out, vector <T> v) { return prnt(out, v); }
template<class T> ostream& operator<<(ostream& out, set <T> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, map <T1, T2> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, pair<T1, T2> p) { return out << '(' << p.st << ' ' << p.nd << ')'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}

#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(long long _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"

const long long N = 400100;
long long n, a[N], jmp[44][N], last[N], k, f[N];

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

	cin >> n >> k;
	for(long long i = 0; i < n; i++)
		cin >> a[i];

	for(long long i = n; i < 2 * n; i++)
		a[i] = a[i % n];
	memset(last, -1, sizeof last);

	for(long long i = 0; i < 2 * n; i++) {
		if(last[a[i]] != -1)
			jmp[0][last[a[i]]] = i - last[a[i]] + 1;
		// dbg(i, a[i], last[a[i]]);
		last[a[i]] = i;
	}
	// dbg_v(jmp, n);

	for(int i = 1; i <= 40; i++) 
		for(int j = 0; j < n; j++)
			jmp[i][j] = jmp[i - 1][j] + jmp[i - 1][(j + jmp[i - 1][j]) % n];
	// dbg(jmp[1][0]);

	long long x = 0;
	for(int j = 40; j >= 0; j--){
		while(x + jmp[j][x % n] + 1 < n * k)
			x += jmp[j][x % n];
	}

	vector <long long> ans;
	// x++;
	while(x < n * k) {
		// dbg(x, a[x]);
		if(f[a[x % n]])
			while(f[a[x % n]])  {
				f[ans.back()]--;
				ans.pop_back();
			}
		else {
			ans.push_back(a[x % n]);
			f[a[x % n]]++;
		}
		x++;
	}
	cout << ans << '\n';
	// dbg_v(jmp, 2 * n + 1);
}	

	

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

int main() {
  int N;
  cin >> N;
  vector <int> box(N);
  for (int i = 0; i < N; i++) {
    cin >> box.at(i);
  }
  int result = 0;
  for (int i = 0; i < N; i += 2) {
    if (box.at(i) % 2 == 1) {
      result++;
    }
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 3620
// https://atcoder.jp/contests/abc066/tasks/arc077_a

#include <bits/stdc++.h>

using namespace std;

#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 = 2*1e5;
const int A_I_MAX = 1e9;

int n;
int a[N_MAX];

void solve() {
  int i;
  for (i = n - 1; i >= 0; i -= 2) {
    if (i < n - 1) printf(" ");
    printf("%d", a[i]);
  }
  for (i = -1 - i; i < n; i += 2) {
    printf(" ");
    printf("%d", a[i]);
  }
  printf("\n");
}

void input() {
  scanf("%d", &n);
  REP(i, n) scanf("%d", a + i);
}

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


Measured memory_bytes: 2944
#include <iostream>
#include <vector>
#include <algorithm> 
int main(){
 int n,k;
 int infinite = 1000000000; 
 std::cin>>n>>k;
 std::vector<int> stones {};
 std::vector<int> dp {}; 
stones.resize(n);
dp.resize(n); 
int h; 
for (int i {}; i<n;i++) {
 std::cin>>h; 
  stones[i]=h;
 dp[i] = infinite;
 } 
dp[0]=0; 
for (int pos {}; pos<n; pos++) {
 for (int m {1}; pos+m<n && m <= k; m++) { 
dp[pos+m]=std::min(dp[pos+m], dp[pos] + abs(stones[pos]-stones[pos+m]));
 }
 } 
std::cout<<dp[n-1];
 }

Measured memory_bytes: 1024
// https://atcoder.jp/contests/dp/tasks/dp_b

#include <bits/stdc++.h>

using namespace std;

#define ll long long 
#define REPL(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define radrad(a)  180.0 * a / M_PI
#define pow(x) x*x
static const int MAX = 1000010;
static const ll INFTY = 1e12;
static const ll NUMMAX = 1000000007;
static const ll MOD = 1000000007;
#define LOOP 10000000
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

// 入力
int H, W;
vector<string> field;
int result = 100;
int dfs_res = 0;

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


const long long INF = 1LL << 60;

// 入力
int N;
long long h[110000];

// DP テーブル
long long dp[110000];

int main() {
    int N, K; cin >> N >> K;
    for (int i = 0; i < N; ++i) cin >> h[i];

    // 初期化 (最小化問題なので INF に初期化)
    for (int i = 0; i < 110000; ++i) dp[i] = INF;

    // 初期条件
    dp[0] = 0;

    // ループ
    for (int i = 0; i < N; ++i) {
        for (int j = 1; j <= K; ++j) {
            chmin(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
        }
    }

    // 答え
    cout << dp[N-1] << endl;
}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/




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

using namespace std;
#define vsort(v) sort(v.begin(), v.end());
#define vsort_reverse(v) sort(v.begin(), v.end(), greater<int>());
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	set<char> S;
	for(int i = 0; i < N; i++) {
		char c;
		cin >> c;
		S.insert(c);
	}

	if(S.size() == 3) cout << "Three" << endl;
	else cout << "Four" << endl;
		
}


Measured memory_bytes: 256
from heapq import heappush, heappop
from itertools import permutations, accumulate, combinations
import math
import bisect
import numpy as np
from collections import defaultdict, deque, Counter
from operator import itemgetter
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)
# MOD = 10 ** 9 + 7
# INF = float("inf")


def main():
    n = int(input())
    A = list(map(int, input().split()))
    ans = [0] * n
    for a in A:
        ans[a-1] += 1
    for a in ans:
        print(a)




if __name__ == '__main__':
    main()

Measured memory_bytes: 51144
//@author yash2040
#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 ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long
#define int long long
#define pb push_back
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
main()
{
	fast();
	int t=1;
	//cin>>t;
	set<string> se;
	while(t--)
	{
		int h,w,K;
		cin>>h>>w>>K;
		string s[h];
		for(int i=0;i<h;i++)
		cin>>s[i];
		string temp1[h];
		for(int i=0;i<h;i++)
		temp1[i]=s[i];
		int temp=0;
		int ans=0;

		for(int i=0;i<=pow(2,h);i++)
		{
			for(int j=0;j<=pow(2,w);j++)
			{
				int flag1=0;
				int flag2=0;
				for(int k=0;k<h;k++)
				{
					if((1<<k)&i)
					{
					//	cout<<"row"<<k<<" ";
						flag1=1;
						for(int l=0;l<w;l++)
						{
							s[k][l]='$';
						}
					}
				}
				for(int k=0;k<w;k++)
				{
					if((1<<k)&j)
					{
						flag2=1;
					//	cout<<"col"<<k<<" ";
						for(int l=0;l<h;l++)
						{
							s[l][k]='$';
						}
					}
				}
				//cout<<endl;
				int cnt=0;
				for(int k=0;k<h;k++)
				{
					for(int l=0;l<w;l++)
					{
						if(s[k][l]=='#')
						cnt++;
					}
				}
				//cout<<cnt<<endl;
				if(cnt==K and flag1==0 and flag2==0 and ans==0)
				{
					
					ans++;
					temp++;
				}
				string p="";
				p+='r';
				if((flag1==1 or flag2==1) and cnt==K)
				{
				//	cout<<"row"<<endl;
					for(int k=0;k<h;k++)
					{
						if((1<<k)&i)
						{
							p+=(char)(k+48);
						}
					}
					p+='c';
					//cout<<"col"<<endl;
					for(int k=0;k<w;k++)
					{
						if((1<<k)&j)
						{
							p+=(char)(k+48);
						}
						
					
					}
					if(se.find(p)==se.end())
					{
						temp++;
						se.insert(p);
					}
				}
					
				//cout<<endl;
				for(int i1=0;i1<h;i1++)
				{
					s[i1]=temp1[i1];
				}
			}
		}
		cout<<temp<<endl;
	}
	
}




Measured memory_bytes: 4084
#include <algorithm>
#include <bitset>
#include <cctype>
#include <climits>
#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>
using namespace std;

int main() {
    int h, w;
    while (cin >> h >> w, h || w) {
        for (int y = 0; y < h; y++) {
            if (y == 0 || y == h - 1) {
                cout << string(w, '#') << endl;
                continue;
            }
            cout << "#" << string(w - 2, '.') << "#" << endl;
        }
        cout << endl;
    }
}

Measured memory_bytes: 1196
/*Author - Shubham Gupta (@shubham107)*/
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<ll> vl;      typedef vector<int> vi;
typedef vector<vl> vvl;     typedef vector<vi> vvi;
typedef pair<ll, ll> pll;   typedef pair<int, int> pii;
#define forn(i,n) for(int i=0;i<n;i++)
#define rforn(i,n) for(int i=n-1;i>=0;i--)
#define forne(i,n) for(int i=1;i<=n;i++)
#define forse(i,s,e) for(int i=s;i<e;i++)
#define rforse(i,s,e) for(int i=e-1;i>=s;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define MOD 1000000007
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define fill(a,x) memset(a,x,sizeof a);
#define trav(a,x) for(auto &a:x)
#define INF ll(1e18)
#ifdef SHUBHAM107
#include "../trace.h"
#else
#define trace(args...)
#endif
void solve() {
    int n;
    cin >> n;
    map<string, int> cnt;
    for(int i = 0; i < n; i++) {
        string s;
        cin >> s;
        cnt[s]++;
    }
    vector<string> ct = {"AC", "WA", "TLE", "RE"};
    for(string t: ct) {
        cout << t << " x " << cnt[t] << '\n';
    }
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifdef SHUBHAM107
    freopen("inp.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("err.txt", "w", stderr);
#endif
    int t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

using namespace std;
int l[131072],r[130172],a[131072];
int main(void)
{
  int n;
  cin >> n;
  FOR(i,1,n+1) cin >> a[i];
  FOR(i,1,n+1)
    if(a[i]<0){
      l[i]=-a[i];
      r[i]=-a[i];
    }else{
      l[i]=1048576;
      r[i]=1048576;
    }
  l[0]=0;
  REP(i,n) if(a[i+1]) l[i+1]=min(l[i]-1,l[i+1]);
  r[n+1]=0;
  REP(i,n) if(a[n-i]) r[n-i]=min(r[n-i+1]-1,r[n-i]);
  int answer=0;
  FOR(i,1,n+1) l[i]=max(l[i],r[i]);
  FOR(i,1,n+1){
    if(min(a[i],l[i])>0) answer+=min(a[i],l[i]);
  }
  cout << answer << endl;
  return 0;
}

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

class Program
{
    public static void Main()
    {
        int N = int.Parse(Console.ReadLine());
        string[] s = Console.ReadLine().Split(' ');
        int[] h = new int[N];
        for (int i = 0; i < N; i++)
            h[i] = int.Parse(s[i]);

        int[] dp = new int[N];
        dp[0] = 0;
        dp[1] = Math.Abs(h[1] - h[0]);
        for (int i = 2; i < N; i++)
            dp[i] = Math.Min(
                dp[i - 1] + Math.Abs(h[i] - h[i - 1]),
                dp[i - 2] + Math.Abs(h[i] - h[i - 2]));

        Console.WriteLine(dp[N - 1]);
    }
}

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n){
        cin >> a.at(i);
    }
    sort(a.begin(),a.end());
    cout << abs(a.at(0) - a.at(n-1)) << endl;
    
}

Measured memory_bytes: 256
import scala.io.StdIn

object Main {
  def main(args: Array[String]): Unit = {
    val inputs = Iterator.continually(StdIn.readLine()).takeWhile(_ != null)
    inputs.toList.zipWithIndex.foreach{
      case ("0", _) =>
      case (e, idx) => println(s"Case ${idx+1}: $e")
    }
  }
}

Measured memory_bytes: 55568
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;

int main() {
	int Q;
	cin >> Q;
	for (int i = 0; i < Q; i++) {
		ll A, B;
		cin >> A >> B;
		if (A > B) swap(A, B);
		if (A == B) {
			cout << 2 * A - 2 << endl;
			continue;
		}
		ll l = 0, r = 1e10;
		while ((r - l) > 1) {
			ll m = (l + r) / 2;
			bool ok = 1;
			for (int i = -10; i <= 10; i++) {
				ll a = (m + 1) / 2 + i;
				ll b = (m / 2) + 1 - i;
				if (a <= 0 || a > m || b <= 0 || b > m) continue;
				if (a >= A) a++;
				if (b >= B) b++;
				if (a*b >= A * B) {
					ok = 0;
					break;
				}
			}
			if (ok) l = m;
			else r = m;
		}
		cout << l << endl;
	}
}


Measured memory_bytes: 256
import math
a,b=map(int,input().split())
c=list(map(int,input().split()))
d=list(map(int,input().split()))
c.sort()
d.sort(reverse=True)
e=[0 for i in range(a)]
for i in range(a):
  e[i]=c[i]*d[i]
def s(e,x):
  k=0
  for i in range(a):
    if e[i]<x:
      continue
    else:
      k+=math.ceil((e[i]-x)/d[i])
  if k>b:
    return False
  else:
    return True
    
left=0
right=max(e)
while left!=right:
  mid=(left+right)//2
  if s(e,mid):
    right=mid
  else:
    left=mid+1
print(left)

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

using namespace std;

const int64_t INF = INT64_C(1) << 60;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<int64_t> X(N), Y(N), P(N);
  for (int i = 0; i < N; i++) {
    cin >> X[i] >> Y[i] >> P[i];
  }
  vector<vector<int64_t>> SX(1 << N, vector<int64_t>(N, INF)), SY(1 << N, vector<int64_t>(N, INF));
  for (int bit = 0; bit < (1 << N); bit++) {
    for (int i = 0; i < N; i++) {
      SX[bit][i] = min(SX[bit][i], abs(X[i]));
      SY[bit][i] = min(SY[bit][i], abs(Y[i]));
      if ((bit >> i) & 1) {
        for (int j = 0; j < N; j++) {
          SX[bit][j] = min(SX[bit][j], abs(X[i] - X[j]));
          SY[bit][j] = min(SY[bit][j], abs(Y[i] - Y[j]));
        }
      }
    }
  }
  vector<int64_t> res(N + 1, INF);
  for (int bitx = 0; bitx < (1 << N); bitx++) {
    int m = ((1 << N) - 1) ^ bitx;
    for (int bity = m;; bity = (bity - 1) & m) {
      int64_t sum = 0;
      for (int i = 0; i < N; i++) {
        sum += P[i] * min(SX[bitx][i], SY[bity][i]);
      }
      int b = __builtin_popcount(bitx) + __builtin_popcount(bity);
      res[b] = min(res[b], sum);
      if (bity == 0) break;
    }
  }
  for (auto r : res) {
    cout << r << '\n';
  }
  return 0;
}


Measured memory_bytes: 12968
import java.util.Scanner;

public class Main{
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);

		int num = scan.nextInt();
		int ones = num % 10;
		if(ones == 3){
			System.out.println("bon");
		}else if(ones == 0 || ones == 1 || ones == 6 || ones == 8){
			System.out.println("pon");
		}else{
			System.out.println("hon");
		}
	}
}

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

int main(){
  string S;
  cin>>S;
  int ans = 0;
  int count =0;
  int n = S.length();
  if(S[0]!='A') ans +=1;
  if((S[1]>='A')&&(S[1]<='Z')) ans+=1;
  for(int i=2;i<n-1;++i){
    if(S[i]=='C')count+=1;
    else if((S[i]>='A')&&(S[i]<='Z')) ans+=1;
  }
  if((S[n-1]>='A')&&(S[n-1]<='Z')) ans+=1;
////////////////
  if(ans>0 || count>=2||count==0)cout<<"WA"<<endl;
  else cout<<"AC"<<endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
n,a,b,c,d = map(int,input().split())
s = input()
a -= 1
b -= 1
c -= 1
d -= 1
truth = [[0 for i in range(n)],[0 for j in range(n)]]

def solve(now,dest):
    for i in  range(now,dest):
        if s[i] == '#' and s[i+1] == '#':
            return False
    return True
if c < d:
    if solve(a,c) and solve(b,d):
        print('Yes')
    else:
        print('No')

else:
    q = False
    for i in range(b,d+1):
        if s[i-1] == '.' and s[i] == '.' and s[i+1] == '.':
            q = True
            break
    if q and solve(a,c) and solve(b,d):
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 54864
N,M,C=map(int, input().split())
B=list(map(int, input().split()))
A=[]
for i in range(N): A.append(list(map(int, input().split())))
R=[0]*N
for i in range(N):
    S=C
    for j in range(M):
        S+=A[i][j]*B[j]
    R[i]= 1 if S > 0 else 0
print(sum(R))


Measured memory_bytes: 3060
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools, os, queue
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def _I(): return int(sys.stdin.readline())
def _F(): return float(sys.stdin.readline())
def _pf(s): return print(s, flush=True)
def perr(s): return print(s, file=sys.stderr)


N = _I()


V = queue.PriorityQueue()
for v in LI():
    V.put(v) 
initial = True
while not V.empty():
    current = V.get()
    new = (current + V.get())/2
    if V.empty():
        V.put(new)
        break

    V.put(new)

print(V.get())


Measured memory_bytes: 6356
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn=15;
int a[maxn]; int n;
void dfs(int pos,int limit)
{
	if(pos==n+1)
	{
		for(int i=1;i<=n;i++) printf("%c",a[i]+'a'-1);
		printf("\n");
		return ;
	}
	for(int i=1;i<=limit;i++)
	{
		a[pos]=i;
		dfs(pos+1,limit+(i==limit));
	}
}
int main(void)
{
	scanf("%d",&n);
	dfs(1,1);
	return 0;
}

Measured memory_bytes: 1536
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        while (true) {
            int H = sc.nextInt();
            int W = sc.nextInt();
            if (H == 0 && W == 0)
                break;
            for (int i = 1; i < H+1; i++) {
                for (int j = 1; j < W+1; j++) {
                    if(i%2 == j%2)System.out.print("#");
                    else System.out.print(".");
                }
                System.out.print("\n");
            }
            System.out.print("\n");
        }
    }
}


Measured memory_bytes: 38200
object Main extends App {
  val Array(n, m) = io.StdIn.readLine().split(' ').map(_.toInt)
  val against = (for(_ <- 0 until m) yield
    io.StdIn.readLine().split(' ').map(_.toInt) match {
      case Array(a, b) => (a-1, b-1)
    }).sortWith{case (x, y) => x._2 < y._2}

  var end = 0
  var count = 0
  var i = 0
  while (i < m) {
    val (a, b) = against(i)
    if (end <= a) {
      end = b
      count += 1
    }
    i += 1
  }

  println(count)
}

Measured memory_bytes: 65676
package main

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

func main() {
	scan_init()
	n := scanInt()
	m := scanInt()
	x := scanInt()
	c := make([]int, n)
	a := make([][]int, n)
	for i:= 0; i<n; i++ {
		c[i] = scanInt()
		a[i] = make([]int, m)
		for j:= 0;j <m; j++ {
			a[i][j] = scanInt()
		}
	}
	sum := x*int(math.Pow(10,12))+1
	submit := false
	for i := 0; i < (1<<n); i++ {
			// 1をNから左シフト
			// bit全探索
			// cost := 0
			// fmt.Println("Start!!", i)
			ms := make([]int, m)
			for j:= 0; j<m; j++ {
				ms[j] = x
			}
			take := 0
			for j := 0; j<n; j++ {
				if (i>>j&1) == 1 {
				// 	fmt.Println("maybe...", j, a[j])
					get := a[j]
					for k := 0; k<len(get); k++ {
						ms[k] -= a[j][k]
					}
					take += c[j]
				}
			}
			check := false
			// fmt.Println(ms)
			for j:= 0; j<m; j++ {
				if ms[j]>0{
					check  = true
					break
				}
			}
			if !check && sum > take{
				// fmt.Println(take)
				submit = true
				sum = take
			}
		}
		if submit {
			fmt.Println(sum)
		} else {
			fmt.Println(-1)
		}
}

var sc = bufio.NewScanner(os.Stdin)

func scan_init() {
	sc.Split(bufio.ScanWords)
}
func scanInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}
func scan() string {
	sc.Scan()
	return sc.Text()
}

var rdr = bufio.NewReaderSize(os.Stdin, 200000)

func readLine() string {
	buf := make([]byte, 0, 200000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}
func readLineToNumber() int {
	S := readLine()
	number, _ := strconv.Atoi(S)
	return number
}
func readLineToSlice() []string {
	S := readLine()
	list := strings.Split(S, "")
	return list
}
func readLineToNumberSlice(memo map[string]int) []int {
	// err時は-1を代入
	S := readLine()
	intList := make([]int, len(S))
	for i := 0; i < len(S); i++ {
		if val, ok := memo[string(S[i])]; ok {
			intList[i] = val
		} else {
			intList[i] = -1
		}
	}
	return intList
}

Measured memory_bytes: 2188
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

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

void dfs(int x, int y, int &bl, int &wh, vector<vector<bool>> &visited, VS &s) {
    int h = s.size(), w = s[0].size();
    if (visited[x][y]) return;
    visited[x][y] = true;
    ++bl;
    REP(i,0,4) {
        int nx = x + dx[i], ny = y + dy[i];
        if (nx < 0 || nx >= h || ny < 0 || ny >= w) continue;
        if (s[nx][ny] == s[x][y]) continue;
        dfs(nx,ny,wh,bl,visited,s);
    }
}

void solve() {
    int h,w;
    cin >> h >> w;
    VS s(h);
    REP(i,0,h) cin >> s[i];
    LL ans = 0;
    vector<vector<bool>> visited(h,vector<bool>(w));
    REP(i,0,h) REP(j,0,w) {
        if (visited[i][j]) continue;
        int bl = 0, wh = 0;
        dfs(i,j,bl,wh,visited,s);
        ans += 1LL * bl * wh;
    }
    cout << ans << endl;
}

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



Measured memory_bytes: 20480
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
typedef long long ll;

const int maxn = 0;
int n , four = 0 , two = 0 , none = 0;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(NULL);
	cin >> n;
	for(int i=0;i<n;i++)
	{
		int x;
		cin >> x;
		if(x % 4 == 0) four++;
		else if(x % 2 == 0) two++;
		else none++;
	}
	int potato = 0;
	if(!two) potato = 1;
	if(four + potato >= none) cout << "Yes";
	else cout << "No"; 
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <bitset>

using namespace std;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define reppe(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)
#define repme(i,a,b) for(int i = (int)(a) ; i >= (int)(b) ; --i)

typedef long long ll;

long long GCD(long long a, long long b){if(b==0)return a;return GCD(b,a%b);}

int main() {
    int N; cin >> N;
    set<string> S; 
    repp(i,0,N) {
        string s; cin >> s;
        S.insert(s);
    }
    cout << S.size() << endl;
}


Measured memory_bytes: 19116
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	
	static Scanner sc =  new java.util.Scanner(System.in);

	public static void main(String[] args) {
		
		int n = sc.nextInt();
		
		for (int x = 0 ; x < n ; x++){
			
			int a = sc.nextInt();
			int b = sc.nextInt();
			int c = sc.nextInt();
			
			int [] array = new int [] {a,b,c};
			Arrays.sort(array);
			
			int a2 = array[0];
			int b2 = array[1];
			int c2 = array[2];
			
			if( a2 * a2 + b2 * b2 == c2 * c2 ){
				System.out.println( "YES" );
				}else{
					System.out.println( "NO" );
				}
			
		}
	}

}

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

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

const int INF = 1e9;
const int MOD = 1e9 + 7;

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

int cnt[100010];

int main() {
  int N, M;
  cin >> N >> M;
  int h[N];
  for (int i = 0; i < N; i++) cin >> h[i];
  int a[M], b[M];
  for (int i = 0; i < M; i++) cin >> a[i] >> b[i];

  for (int i = 0; i < M; i++) {
    a[i]--; b[i]--;
    if (h[a[i]] == h[b[i]]){
      cnt[a[i]]++;
      cnt[b[i]]++;
      continue;
    }

    if (h[a[i]] < h[b[i]]) {
      cnt[a[i]]++;
    } else {
      cnt[b[i]]++;
    }
  }

  int ans = 0;
  for (int i = 0; i < N; i++) if (cnt[i] == 0) ans++;

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

Measured memory_bytes: 5148
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <typename T> using vec = std::vector<T>;
using namespace std;

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

  vec<ll> B(M);
  REP(i, M) { cin >> B[i]; }

  ll answer = 0;
  ll Aij;
  REP(i, N) {
    ll lhs = C;
    REP(j, M) {
      cin >> Aij;
      lhs += Aij * B[j];
    }
    if (lhs > 0) {
      answer++;
    }
  }
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 256