akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int n; scanf("%d", &n); std::vector<i64> a(n);
	for(auto& v: a) scanf("%lld", &v);

	std::vector<int> b(n);
	std::iota(begin(b), end(b), 0);
	sort(begin(b), end(b), [&](int i, int j) { return a[i] > a[j]; });

	auto dp = make_v<i64>(n, n);
	for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) dp[i][j] = -1;
	auto solve = [&](auto&& solve, int l, int r) -> i64 {
		if(l + r >= n) return 0;
		if(dp[l][r] != -1) return dp[l][r];
		
		int L = l, R = n - r - 1, idx = b[l + r];
		i64 A = solve(solve, l + 1, r) + a[idx] * std::abs(idx - L);
		i64 B = solve(solve, l, r + 1) + a[idx] * std::abs(idx - R);
		return dp[l][r] = std::max(A, B);
	};

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


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

int main(){
  int a,b;
  cin >>a>>b;
  
  int d = b-a;
  int B = 0;
  rep(i,1,d) B+=i;
  
  int ans = B-b;
  
  cout<<ans<<endl;
}

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

template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

long long ans = 0;
int n;
string s;
vector<int> pos[10];
int main(){
    cin >> n;
    cin >> s;

    rep(i, n) pos[s[i]-'0'].push_back(i);

    rep(i, 1000){
        int h = i/100;
        int t = i/10;
        t %= 10;
        int o = i % 10;
        if(pos[h].size() == 0 || pos[t].size() == 0 || pos[o].size() == 0) continue;

        int p_h = pos[h][0];
        int p_t=0, p_o;
        rep(j, pos[t].size()){
            if(pos[t][j] > p_h){
                p_t = pos[t][j];
                break;
            }
        }
        if(p_t == 0) continue;

        rep(j, pos[o].size()){
            if(pos[o][j] > p_t){
                ans++;
                break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3772
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5+5;
int u[N], v[N], n, m;

int hed[N],to[N<<1],nxt[N<<1],cnt;
inline void adde(int u,int v){
	++cnt;to[cnt]=v,nxt[cnt]=hed[u];hed[u]=cnt;
}

int col[N],vis[N],dfn[N],num;

inline void dfs(int x,int pre){
	vis[x]=1,dfn[x]=++num;
	for(int i=hed[x];i;i=nxt[i]){
		int v=to[i];
		if(!vis[v])dfs(v,x);
	}
	for(int i=hed[x];i;i=nxt[i]){
		int v=to[i];
		if(dfn[v]>dfn[x]){
			if(col[v]){
				printf("%d %d\n",v,x);
				col[v]^=1;
			}else{
				printf("%d %d\n",x,v);
				col[x]^=1;
			}
		}
	}
}

int main()
{
	cin >> n >> m;
	if(m%2){puts("-1");return 0;}
	for(int i=1;i<=m;i++){
		scanf("%d%d",&u[i],&v[i]);
		adde(u[i],v[i]);
		adde(v[i],u[i]);
	}
	dfs(1,0);
}


Measured memory_bytes: 7552
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
using namespace std;
 
int main()
{
    int n;
    vector<double> x(3), y(3), x2(3), y2(3);
    cin >> n;
 
    for(int p=0; p<n; p++)
    {
        cin >> x[0] >> y[0] >> x[1] >> y[1] >> x[2] >> y[2];
        for(int i=0; i<3; i++) { x2[i] = x[i]*x[i]; y2[i] = y[i]*y[i]; }
 
        double a, b, c, a2, b2, c2;
        a2 = abs((x[2]-x[1])*(x[2]-x[1]) + (y[2]-y[1])*(y[2]-y[1]));
        b2 = abs((x[0]-x[2])*(x[0]-x[2]) + (y[0]-y[2])*(y[0]-y[2]));
        c2 = abs((x[1]-x[0])*(x[1]-x[0]) + (y[1]-y[0])*(y[1]-y[0]));
        a = sqrt(a2); b = sqrt(b2); c = sqrt(c2);
        double s, S2;
        s = (a + b + c) / 2;
        S2 = s * (s-a) * (s-b) * (s-c);
 
        double cx, cy;
        cx = (a2*(b2+c2-a2)*x[0] + b2*(c2+a2-b2)*x[1] + c2*(a2+b2-c2)*x[2]) / (16 * S2);
        cy = (a2*(b2+c2-a2)*y[0] + b2*(c2+a2-b2)*y[1] + c2*(a2+b2-c2)*y[2]) / (16 * S2);
        cout << setprecision(3) << fixed <<
            cx << " " << cy << " " << sqrt(abs((cx-x[0])*(cx-x[0])+(cy-y[0])*(cy-y[0]))) << endl;
    }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
const int maxe = 2e5+5;
 
int t=1, n, w;
const int INF = 1e9+5;
vector<int> arr[maxe];
int dp[100005][105];
void solve(){
	cin >> n >> w;
	int maxval=0;
	for(int i = 1; i<=n; i++){
		arr[i].resize(2);
		cin >> arr[i][0] >> arr[i][1];
		maxval += arr[i][1];
	}
	
	for(int i = 0; i<=n; i++){
		dp[0][i] = 0;
	}
	for(int i = 1; i<=maxval; i++){
		dp[i][0] = INF;
	}
	for(int i = 1; i<=n; i++){
		for(int j = 0; j<=maxval; j++){
			dp[j][i] = min(arr[i][0]+dp[max(0, j-arr[i][1])][i-1], dp[j][i-1]);
		}
	}
	int ans = INT_MIN;
	for(int i=0; i<=maxval; i++){
		if(dp[i][n] <= w){
			ans = max(i, ans);
		}
	}
	cout << ans;
	
}
 
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	while(t--){
		solve();
	}
	return 0;
}

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


int main() {
  
  string S;
  cin>>S;
  
  if(S[0]==S[1]||S[1]==S[2]||S[2]==S[3]){
    cout<<"Bad"<<endl;
  }else{
    cout<<"Good"<<endl;
  }
  
  
  
}



Measured memory_bytes: 256
from itertools import accumulate

n = int(input())
a = tuple(sorted(map(int, input().split())))

acc = (0,) + tuple(accumulate(a))

ng = 0
for idx, (acc_, a_) in enumerate(zip(acc, a)):
    if a_ > acc_ * 2:
        ng = idx  # 0-indexed -> 注目しているa_より前の要素数を表す
print(n - ng)


Measured memory_bytes: 69372
dic = []
dic = ('a'..'z').to_a
value = Array.new(26,0)
until (a = gets) ==nil
  a=a.downcase.split("")
  a.each do |i|
    dic.each do |d|
      if i == d
        value[dic.index(d)] = value[dic.index(d)]+1
        break
      end
    end
  end
end
  26.times do |i|
    puts "#{dic[i]} : #{value[i]}"
  end



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

typedef long long ll;

int main() {
    int N, M, ans = 1;
    cin >> N >> M;
    for (int i = 1; i * i <= M; i++) {
        if (M % i) continue;
        if (M / i <= M / N) {
            ans = M / i;
            break;
        }
        if (i <= M / N) ans = i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<math.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;

struct Edge {
    int to, id;
};

vector<vector<Edge>> g;
vector<int> ans;

void dfs(int v, int p = -1, int c = -1){
    int k = 1;
    rep(i,g[v].size()){
        int u = g[v][i].to, ei = g[v][i].id;
        if(u == p) continue;
        if(k == c) k++;
        ans[ei] = k++;
        dfs(u, v, ans[ei]);
    }
}

int main(){
    int n;
    cin >> n;
    g.resize(n);
    ans.resize(n-1);
    rep(i,n-1){
        int a, b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back((Edge){b,i});
        g[b].push_back((Edge){a,i});
    }
    dfs(0);
    int mx = 0;
    rep(i,n) mx = max(mx, int(g[i].size()));
    cout << mx << endl;
    rep(i, n-1) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 8320
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Code author: Saurabh Singhal
Code copy karne vaale tera muh kaala
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/

#include<bits/stdc++.h>
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define ppb pop_back

using namespace std;
typedef long long int ll;
typedef vector<int> vi_t;
typedef vector<ll> vll_t;
int t=1;
vll_t a,b;
int  main(){
	// #ifndef ONLINE_JUDGE
 //    // for getting input from input.txt
 //    freopen("input.txt", "r", stdin);
 //    // for writing output to output.txt
 //    freopen("output.txt", "w", stdout);
	// #endif
	int n,ans=0;
	cin>>n;
	for(int i=0;i<n;i++){
		int a;
		cin>>a;
		ans+=a;
	}
	cout<<ans-n<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int x,y;
int i=1;

main(){
	while(i<=3000){
		scanf("%d%d",&x,&y);
		if(x == 0 && y == 0){
			break;
		}else{
			if(x<y){
				printf("%d %d\n",x,y);
			}else{
				printf("%d %d\n",y,x);
			}
		}
		
		i++;
	}
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define debug(a) cout<<#a<<":"<<a<<endl;
const int INF=0x3f3f3f3f;
const int N=1e6+7;
const int mod=1e9+7;
int maxn,minn;
int T,n,m;
int dp[2000][2000];
char mp[2000][2000];

int main(){
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		scanf("%s",mp[i]+1);
	}
	dp[0][1]=1;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(mp[i][j]=='.'){
				dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
			}
			else{
				dp[i][j]=0;
			}
		}
	}
	cout<<dp[n][m]<<endl;

	return 0;
}





Measured memory_bytes: 12416
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,n) for (int64_t i=0; i<(n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    int a,b; cin>>a>>b;
    vector<vector<char>> ans(100,vector<char>(100,'#'));
    rep(i,50){
        rep(j,100){
            ans[i+50][j]='.';
        }
    }
    rep(i,a-1){
        int x=i%50; x*=2;
        int y=i/50; y*=2;
        ans[y][x]='.';
    }
    rep(i,b-1){
        int x=i%50; x*=2;
        int y=i/50; y*=2; y+=51;
        ans[y][x]='#';
    }
    cout<<"100 100"<<endl;
    rep(i,100){
        rep(j,100){
            cout<<ans[i][j];
        }
        cout<<endl;
    }
}

Measured memory_bytes: 3652
#include <stdio.h>
char txt[4];
int main(){
	scanf("%s",txt);
	int A=0,B=0;
	for(int i=0;i<3;i++){
		A+=txt[i]=='A';
		B+=txt[i]=='B';
	}
	printf("%s",A>0&&B>0?"Yes":"No");
}

Measured memory_bytes: 128
from itertools import*
from numpy import*
n,k=map(int,input().split())
k=2*k+1
s=input()
x=[0]*(s[0]=="0")+[len(list(v))for k,v in groupby(s)]+[0]*(s[-1]=="0")
#print(x)
x1=array(x[k:])
x2=array(x[:-k])
x3=sum(x[:k])
y=[x3]+list(x3+cumsum(x1-x2))
print(max(y[::2]))

Measured memory_bytes: 19508
// 以下のライブラリを使ってみる.
// Lapinpon氏.
// http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=2648369#1
#include<bits/stdc++.h>
using namespace std;
const int INF = INT_MAX;
typedef pair<int, pair<int, int> > Edge;

long long edmonds(vector<Edge> edges, int v, int st){
    vector< pair<int, int> > mins(v, pair<int, int>(INF, -1));
    for(int i = 0; i < (int)edges.size(); i++){
        Edge edge = edges[i];
        mins[edge.second.second] = min(mins[edge.second.second], pair<int,int>(edge.first, edge.second.first));
    }
    mins[st] = pair<int,int>(-1, -1);
    
    vector<int> gr(v, 0);
    vector<bool> tfc(v, false), f(v, false);
    int cnt = 0;
    
    for(int i = 0; i < v ; i++){
        if(f[i]) continue;
        vector<int> ch;
        int cu = i;
        for(; cu !=-1 && !f[cu];){
            f[cu] = true;
            ch.push_back(cu);
            cu = mins[cu].second;
        }
        if(cu != -1){
            bool tfc2 = false;
            for(int j = 0; j < (int)ch.size(); j++){
                gr[ch[j]] = cnt;
                if(ch[j] == cu){
                    tfc[cnt] = true;
                    tfc2 = true;
                }
                if(!tfc2) cnt++;
            }
            if(tfc2) cnt++;
        }
        else for(int j = 0; j < (int)ch.size(); j++, cnt++) gr[ch[j]] = cnt;
    }
    if(cnt==v){
        long long ans = 1;
        for(int i = 0; i < v; i++) ans += mins[i].first;
    return ans;
    }
    long long res = 0;
    for(int i = 0; i < v; i++) if(i != st && tfc[gr[i]]) res += mins[i].first;
    
    vector<Edge> nedges;
    for(int i = 0; i < (int)edges.size(); i++){
        Edge edge=edges[i];
        int fto = edge.second.second, gfr = gr[edge.second.first], gto = gr[edge.second.second];
        if(gfr == gto) continue;
        else if(tfc[gto]) nedges.push_back(make_pair(edge.first - mins[fto].first, pair<int,int>(gfr, gto)));
        else nedges.push_back(make_pair(edge.first, pair<int,int>(gfr, gto)));
    }
    return res + edmonds(nedges, cnt, gr[st]);
}
 
int main(){
    int v, e, r;
    scanf("%d %d %d", &v, &e, &r);
    vector<Edge> es;
    for(int i = 0; i < e; i++){
        int s, t, w;
        scanf("%d %d %d", &s, &t, &w);
        es.push_back(make_pair(w, pair<int, int>(s, t)));
    }
    printf("%d\n", edmonds(es, v, r));
    return 0;
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,k;
  	cin>>n>>k;
  	int* h =new int[n];
  	for(int i=0;i<n;i++){
      cin>>h[i];
    }
  	int* dp=new int[n];
  	for(int i=n-1;i>=0;i--){
      dp[i]=1000000000;
    	if(i==n-1)
          dp[i]=0;
      	else {
          for(int j=1;j<=k&&i+j<n;j++){
          	dp[i]=min(dp[i],abs(h[i+j]-h[i])+dp[i+j]);
          }
        }
      //cout<<dp[i]<<" ";
    }
	cout<<dp[0]<<endl;
}

Measured memory_bytes: 4388
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++) //(i, 0, n)でi=0~n-1までn回
#define REPn(i, a, n) for(int i=a; i<=n; i++) //(i, 1, n)でi=1~nまでn回
#define sortv(v) sort(v.begin(), v.end());
#define sortg(v) sort(v.begin(), v.end(), greater<>());
#define rev(v) reverse(v.begin(), v.end()); //逆順に並べ替え

int main() {
  long long n, total=0;
  cin >> n;
  REP(Q, 1, 1+pow(n, 0.55)){
    if(n%Q==0 && n/Q-1>Q)total+=n/Q-1;
  }
  cout << total << endl;    
}


Measured memory_bytes: 256
#include <stdio.h>
#define max(a, b) ((a) > (b) ? (a) : (b))

int main(void)
{
    int ans = 0;
    int a[26], b[26];
    int n;
    char s[101];

    scanf("%d", &n);
    scanf("%s", s);

    for (int i = 0; i < n - 1; i++)
    {
        int tmp = 0;
        for (int j = 0; j < 26; j++)
        {
            a[j] = 0;
            b[j] = 0;
        }

        for (int j = 0; j < i + 1; j++)
            a[s[j] - 'a']++;
        for (int j = i + 1; j < n; j++)
            b[s[j] - 'a']++;

        for (int j = 0; j < 26; j++)
            if ((a[j] != 0) && (b[j] != 0))
                tmp++;
        ans = max(ans, tmp);
    }

    printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 128
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <iostream>

using namespace std;
typedef long long ll;
const ll MOD = (ll)1e9 + 7;

ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

vector<ll> fact, ifact;

void init_table(int n) {
  fact.assign(n + 1, 1), ifact.assign(n + 1, 1);
  for (int i = 2; i < n + 1; ++i) fact[i] = i * fact[i - 1] % MOD;
  ifact[n] = modinv(fact[n], MOD);
  for (int i = n; i > 2; --i) ifact[i - 1] = i * ifact[i] % MOD;
}

ll comb(int n, int r) {
  return fact[n] * (ifact[r] * ifact[n - r] % MOD) % MOD;
}

ll f2(int n, int k) {
  return comb(n + k - 1, k - 1);
}

ll f(int n, int k) {
  if (n < k) return 0;
  if (n == 0 && k == 0) return 1;
  if (k < 1) return 0;
  return f2(n - k, k);
}

int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  init_table(4000);
  for (int i = 1; i <= k; ++i) {
    ll b = f(k, i);
    ll r = 0;
    r += f(n - k, i - 1);
    r += f(n - k, i);
    r += f(n - k, i);
    r += f(n - k, i + 1);
    r %= MOD;
    ll ans = (b * r) % MOD;
    printf("%lld\n", ans);
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e9 + 7, MOD = 1e9 + 7;
const long long LINF = 1e18;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {
	int d;
	string n;
	cin >> d >> n;
	if (n == "100") {
		cout << "101";
		for (int i = 0; i < d; i++) {
			cout << "00";
		}
		cout << endl;
		return 0;
	}
	for (int i = 0; i < d; i++) {
		n += "00";
	}
	cout << n << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

int main(){
  int n,k;
  cin >> n >> k;
  
  int ans = 0;
  int sum = 0;
  
  while(sum < n){
    ans++;
    sum = k + (k-1) * (ans-1);
  }
  
  cout << ans;

  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(A) (A).begin(),(A).end()
#define ll long long

int main(void){
	ll ans = 0;
	string s;
	cin >> s;
	vector<ll> v;
	for(int i=0;i<s.size();i++){
		if(s[i]=='A')v.push_back(0);
		else if(i<s.size()-1&&s[i]=='B'&&s[i+1]=='C'){
			v.push_back(1);
			i++;
		} else v.push_back(2);
	}
	//for(auto x:v)cout << x;
	int i = 0,start=0,cnt=0;
	while(i<v.size()){
		if(v[i]==2){
			start =i+1;
			i++;
			continue;
		}
		if(v[i]==1){
			ans += i - start;
			start++;
		}
		i++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 2680
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

set<char>se[26];
set<int>a[26],b[26];
signed main(){
	string s,t;cin>>s>>t;
	rep(i,s.size()){
		a[s[i]-'a'].insert(i);
		b[t[i]-'a'].insert(i);
		se[s[i]-'a'].insert(t[i]);
	}
	rep(i,26){
		if(se[i].size()>1){
			puts("No");return 0;
		}
		if(se[i].size()==1){
			if(a[i]!=b[*se[i].begin()-'a']){
				puts("No");return 0;
			}
		}
	}
	puts("Yes");
}

Measured memory_bytes: 19464
#include<iostream>
#include<iomanip>
#include<limits>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>

#define big ((long long)(1e9)+7)

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main()
{
  int a,b;
  cin >> a >> b;
  if(a != 1 && b != 1)
    cout << 1 << endl;
  else if(a != 2 && b != 2)
    cout << 2 << endl;
  else
    cout << 3 << endl;
  
}


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

int main(){
  	string s;
  	cin >> s;
  	int counter = 0;
  	if(s[0] == '1') counter++;
  	if(s[1] == '1') counter++;
  	if(s[2] == '1') counter++;
  	cout << counter << endl;
}

Measured memory_bytes: 3636
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
using namespace std;

int main() {
	int N, C;
	cin>>N>>C;
	int s[N], t[N], c[N];
	vector<vector<int> >tmpschedule;
	vector<int>tmparr;
	for(int i=0;i<C;++i){
		tmpschedule.push_back(tmparr);
	}

	for(int i=0;i<N;++i){
		cin>>s[i]>>t[i]>>c[i];
		c[i]--;
	}
	for(int i=0;i<N;++i){
		tmpschedule[c[i]].push_back(s[i]);
		tmpschedule[c[i]].push_back(t[i]);
	}
	for(int i=0;i<C;++i){
		sort(tmpschedule[i].begin(), tmpschedule[i].end());
	}

	vector<vector<int> >schedule;
	for(int i=0;i<C;++i){
		schedule.push_back(tmparr);
	}

	int j;
	int size;
	for(int i=0;i<C;++i){
		j = 0;
		while(true){
			size = tmpschedule[i].size();
			if(j >= size-1) break;
			if(tmpschedule[i][j]==tmpschedule[i][j+1])j+=2;
			else {
				schedule[i].push_back(tmpschedule[i][j]);
				j++;
			}
		}
		if(tmpschedule[i].size()>0){
			schedule[i].push_back(tmpschedule[i][j]);
		}
	}
	/**
	for(int i=0;i<C;++i){
		for(int j=0;j<schedule[i].size();++j){
			cout<<schedule[i][j]<<" ";
		}
		cout<<endl;
	}
	cout<<endl;
	**/
	vector<pair<int, int> > tvschedule;
	for(int i=0;i<C;++i){
		for(int j=0;j<schedule[i].size();++j){
			if(j % 2 == 0){
				tvschedule.push_back(make_pair(schedule[i][j], 0));
			}
			else{
				tvschedule.push_back(make_pair(schedule[i][j], 1));
			}
		}
	}
	sort(tvschedule.begin(), tvschedule.end());
	int usetv = 0;
	int ans = 0;
	for(int i=0;i<tvschedule.size();++i){
		if(tvschedule[i].second == 0) usetv++;
		else usetv--;
		if(ans < usetv)ans = usetv;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 5688
import math
import bisect
A,B,C,D,E,F = map(int, input().split())
x = [A * a + B * b for b in range(31) for a in range(31)]
y = [C * c + D * d for d in range(1501) for c in range(1501)]
x.remove(0)
x = list(set(x))
y = list(set(y))
x.sort()
y.sort()
x = x[:bisect.bisect_right(x,F//100+1)]
y = y[:bisect.bisect_left(y,F)]


water = A
suger = 0
for i in x:
    for j in y:
        if j <= i * E and i * 100 + j <= F:
            if j / (i * 100 + j) > suger / (water * 100 + suger):
                water = i
                suger = j
print("{} {}".format(water * 100 + suger, suger))

Measured memory_bytes: 94888
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = input()
ans = 0
for i in range(n):
    if((i - k) < 0):
        if(t[i] == 'r'):ans += p
        elif(t[i] == 's'):ans += r
        else:ans += s
        continue
    
    else:
        if(t[i-k] == t[i]):t = t[:i] + 'n' + t[i+1:]
        else:
            if(t[i] == 'r'):ans += p
            elif(t[i] == 's'):ans += r 
            else:ans += s
print(ans)


Measured memory_bytes: 122092
module.exports=function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=0)}([function(t,e,n){"use strict";var r=n(1);n(2)(r.readFileSync("/dev/stdin","utf8"))},function(t,e){t.exports=require("fs")},function(t,e,n){"use strict";var r=n(3),i=n(5);t.exports=function(t){var e=new r(t);i(e)}},function(t,e,n){"use strict";var r=n(4);t.exports=class{constructor(t){var e=t.trim().split(/\s+/g);this.inp=new r(e)}inr(){return this.inp.deq()}in(){return parseInt(this.inp.deq(),10)}fin(){this.inp.clear()}}},function(t,e,n){"use strict";t.exports=class{constructor(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.size=t.length,this.items=t,this.ind=0}enq(t){this.size+=1,this.items.push(t)}deq(){var t=this.items[this.ind];return this.size-=1,this.ind+=1,t}clear(){this.items=[],this.size=0,this.ind=0}}},function(t,e,n){"use strict";t.exports=function(t){var e=t.in(),n=t.in(),r=e*n/function(t,e){var n=Math.max(t,e),r=Math.min(t,e);for(;0!=r;){var i=r;r=n%r,n=i}return n}(e,n);console.log(r)}}]);


Measured memory_bytes: 21192
#include<stdio.h>
int main(void)
{
    int n,i,m,t;
    double x[100],y[100],r,c;
    while(scanf("%d",&n)*n){
        for(i=0;i<n;i++)scanf("%lf,%lf",&x[i],&y[i]);
        for(t=0,r=0.;r<=10.;r+=.1){
            for(c=0.f;c<=10.;c+=.1){
                for(m=0,i=0;i<n;i++){
                    if((x[i]-c)*(x[i]-c)+(y[i]-r)*(y[i]-r)<=1.01)m++;
                }
                if(m>t)t=m;
            }
        }
        printf("%d\n",t);
    }
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<fstream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#include<random>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n,a[100010],b[100010];
    ll suma[100010],sumb[100010];
    cin>>n;
    rep(i,n){
        cin>>a[i];
        suma[i+1]=suma[i]+a[i];
    }
    rep(i,n){
        cin>>b[i];
    }
    repr(i,n){
        sumb[i]=sumb[i+1]+b[i];
    }
    ll ans=0;
    rep2(i,1,n+1){
        ans=max(ans,suma[i]+sumb[i-1]);
    }
    cout<<ans<<endl;
    return 0;
}


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

int main()
{
  int n;
  cin>>n;
  if(n>0 && n<10) cout<<n;
   if(n>9 && n<100) cout<<"9";
   if(n>99 && n<1000) cout<<(n-100+1+9);
   if(n>999 && n<10000) cout<<"909";
   if(n>9999 && n<100000) cout<<(n-10000+1+909);
    if(n==100000) cout<<"90909";
}



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

#define _GLIBCXX_DEBUG
#define F first
#define S second
#define R cin>>
#define O cout<<
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())

// ループ系
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)

#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)

// #define fou(i,a,n) for(int i=a;i<n;i++)
#define elif(c) else if(c)


// 出力系
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
template<Z A>void PR1(A a){rep(i,a.size()){if(i)cout<<' ';cout<<a[i];}ln;}
template<Z A>void PR2(A a){rep(i, a.size()){PR1(a[i]);}}


ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}

const ll MAX=1000000007,MAXL=1LL<<61,dx[8]={-1,-1,-1,0,0,1,1,1},dy[8]={-1,0,1,-1,1,-1,0,1};

typedef pair<int,int> P;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;
typedef vector<VS> VVS;
typedef vector<char> VC;
typedef vector<VC> VVC;




void Main() {
    int h, w; R h >> w;

    VVC a(h);
    char tmp;

    rep(i,h){
        rep(j, w){
            R tmp;
            a[i].pb(tmp);
        }
    }


    map<int, int> b, c;


    bool ok = false;

    rep(i, h){
        ok = false;
        rep(j, w){
            if (a[i][j] == '#') break;
            if (j == w-1) ok = true;
        }
        if (ok) b[i] = 1;
    }

    rep(i, w) {
        ok = false;
        rep(j, h) {
            if(a[j][i] == '#') break;
            if (j == h-1) ok = true;
        }
        if(ok) c[i] = 1;
    }


    rep(i, h){
        if (b[i] == 1) continue;
        rep(j, w){
            if (c[j] != 1) O a[i][j];
        }
        ln;
        
    }
    

}
 
int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(D: int, G: int, p: "List[int]", c: "List[int]"):
    cm = sum(p)
    for i in range(1<<D):
        s = 0
        ct = 0
        for j in range(D):
            if((i>>j)&1):
                s += (j+1)*100*p[j]+c[j]
                # print(s)
                ct += p[j]
    
        for j in range(D, 0, -1):
            if(s >= G): break
            if((i>>(j-1))&1): continue
            u = 100*j
            n = (G-s+u-1)//u
            s += p[j-1]*u
            ct += min(n, p[j-1])

        cm = min(cm, ct)

    print(cm)
    
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    D = int(next(tokens))  # type: int
    G = int(next(tokens))  # type: int
    p = [int()] * (D)  # type: "List[int]"
    c = [int()] * (D)  # type: "List[int]"
    for i in range(D):
        p[i] = int(next(tokens))
        c[i] = int(next(tokens))
    solve(D, G, p, c)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    int n;
    cin >> n;
    vector<ll> h(n);
    rep(i,n) cin >> h[i];
    int ans=0;
    int cnt=0;
    rep(i,n-1){
        if(h[i]>=h[i+1])cnt++;
        else cnt = 0;
        ans = max(ans,cnt);
    }
    cout << ans << endl;
}

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

using namespace std;
const int N = 2e5+5;
int n, Q;
char s[N], t[N][2], d[N][2];

int move(int p){
    int i;
    for(i = 1; i <= Q && 1 <= p && p <= n; i++){
        if(s[p] != t[i][0]) continue;
        if(d[i][0] == 'L') p--;
        else p++;
    }
    return p;
}

int findL(int l, int r){
    if(l > r) return 0;
    int m = (l+r)/2, p;
    p = move(m);
    if(p < 1){
        int t = findL(m+1, r);
        return max(m, t);
    }
    else return findL(l, m-1);
}

int findR(int l, int r){
    if(l > r) return n+1;
    int m = (l+r)/2, p;
    p = move(m);
    if(p > n){
        int t = findR(l, m-1);
        return min(m, t);
    }
    else return findR(m+1, r);
}

int main(){
    int i, j;
    while(scanf("%d%d", &n, &Q) != EOF){
        scanf("%s", s+1);
        for(i = 1; i <= Q; i++) scanf("%s%s", t[i], d[i]);
        int L = findL(1, n), R = findR(1, n);
        printf("%d\n", R-L-1);
    }

    return 0;
}

Measured memory_bytes: 1280
N = int(input())
A = list(map(int, input().split()))

ans = 'APPROVED'
for a in A:
    if a % 2 == 0:
        if a % 3 == 0 or a % 5 == 0:
            continue
        else:
            ans = 'DENIED'
            break

print(ans)


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

public class Main {

     static Scanner scanner;

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

         String s=gs();
         int min=Integer.MAX_VALUE;
         String abc="abcdefghijklmnopqrstuvwxyz";
         
         for(int i=0; i<26;i++) {
        	 String c=abc.substring(i,i+1);
        	 if(s.contains(c)) {
        		 int max=0;
        		 int tmp=0;
        		 for (int j=0; j<s.length();j++) {
        			 String cj=s.substring(j,j+1);
        			 if(c.equals(cj)) {
        				 max=Math.max(tmp, max);
        				 tmp=0;
        			 } else {
        				 tmp++;
        			 }
        		 }
        		 max=Math.max(tmp, max);
        		 min=Math.min(min, max);
        	 }
         }

         System.out.println(min);
     }


     // 文字列として入力を取得
     public static String gs() {
          return scanner.next();
     }

     // intとして入力を取得
     public static int gi() {
          return Integer.parseInt(scanner.next());
     }

     // longとして入力を取得
     public static long gl() {
          return Long.parseLong(scanner.next());
     }

     // doubleとして入力を取得
     public static double gd() {
          return Double.parseDouble(scanner.next());
     }
}

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

int main() {
	string str;
	cin >> str;
	for (int i = 0; i < str.length(); i++) {
		cout << str[i];
		if (i == 3) {
			cout << " ";
		}
	}
	cout << endl;
	return 0;
}


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

#define equals(a, b) (fabs((a)-(b)) < EPS)
const double EPS = (1e-10);

class Point {
public:
    double x, y;

    Point(double x = 0, double y = 0): x(x), y(y) {}

    Point operator + (Point p) {
        return Point(x+p.x, y+p.y);
    }
    Point operator - (Point p) {
        return Point(x-p.x, y-p.y);
    }
    Point operator * (double a) {
        return Point(x*a, y*a);
    }
    Point operator / (double a) {
        return Point(x/a, y/a);
    }

    double abs() {
        return sqrt(norm());
    }
    double norm() {
        return x*x + y*y;
    }

    bool operator < (const Point &p) const {
        return x != p.x ? x < p.x : y < p.y;
    }

    bool operator == (const Point &p) const {
        return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS;
    }
};

typedef Point Vector;
// 内積
double dot(Vector a, Vector b) {
    return a.x*b.x + a.y*b.y;
}
// 外積
double cross(Vector a, Vector b) {
    return a.x*b.y - a.y*b.x;
}

class Segment {
public:
    Point p1, p2;

    Segment(Point p1, Point p2): p1(p1), p2(p2) {}
};
typedef Segment Line;

Point project(Segment s, Point p) {
    Vector base = s.p2 - s.p1;
    Vector hypo = p - s.p1;
    double r = dot(hypo, base) / base.norm();
    return s.p1 + base*r;
}

class Circle {
public:
    Point c;                    // 中心
    double r;                   // 半径
    Circle(Point c = Point(), double r = 0.0): c(c), r(r) {}
};

pair<Point, Point> getCrossPoints(Circle c, Line l) {
    Vector pr = project(l, c.c);
    Vector e = (l.p2 - l.p1) / (l.p2 - l.p1).abs();
    double base = sqrt(c.r*c.r - (pr-c.c).norm());
    return make_pair(pr + e*base, pr - e*base);
}

int main(void) {
    double cx, cy, r;
    cin >> cx >> cy >> r;
    Circle c(Point(cx, cy), r);

    int q; cin >> q;
    double x1, y1, x2, y2;
    for (int i = 0; i < q; i++) {
        cin >> x1 >> y1 >> x2 >> y2;
        Line l(Point(x1, y1), Point(x2, y2));

        pair<Point, Point> ans = getCrossPoints(c, l);
        if (ans.first < ans.second) {
            printf("%.9f %.9f %.9f %.9f\n", ans.first.x, ans.first.y,
                   ans.second.x, ans.second.y);
        } else {
            printf("%.9f %.9f %.9f %.9f\n", ans.second.x, ans.second.y,
                   ans.first.x, ans.first.y);
        }
    }

    return 0;
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
const ll mod = ll(1e9) + 7;
const ll INF = ll(1e14);
struct edge
{
    int to;
    ll cost;
};
typedef pair<int, int> P;
int nodeN;
vector<edge> G[100000];
ll d[100000];
int pre[100000];
int N;
void dijkstra(int s)
{
    priority_queue<P, vector<P>, greater<P>> que;
    fill(d, d + N, INF);
    fill(pre, pre + N, -1);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty())
    {
        P p = que.top();
        que.pop();
        int v = p.second;
        if (d[v] < p.first)
            continue;
        for (int i = 0; i < G[v].size(); i++)
        {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost)
            {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
                pre[e.to] = v;
            }
        }
    }
}
vector<int> get_path(int t)
{
    vector<int> path;
    for (; t != -1; t = pre[t])
        path.push_back(t);
    reverse(path.begin(), path.end());
    return path;
}
int main()
{

    cin >> N;
    rep(i, N - 1)
    {
        int u, v, w;
        cin >> u >> v >> w;
        u--;
        v--;
        G[u].push_back({v, w});
        G[v].push_back({u, w});
    }
    dijkstra(0);
    //rep(i, N) cout << d[i] << endl;

    rep(i, N)
    {
        if (d[i] % 2 == 1)
        {
            cout << 0 << endl;
        }
        else
            cout << 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 9088
import java.util.Scanner;

//Lunch
public class Main{

	static int[] ans;
	static String[] name;
	static int n;
	static int[] w;
	static int[] s;
	static int[] order;
	static boolean[] used;
	static double best;
	
	static void dfs(int k, int num, int total){
		if(k==0){
			double g = num*1.0/total;
			if(g<best){
				best = g;
				for(int i=1;i<=n;i++)ans[i-1]=order[i];
			}
			return;
		}
		for(int i=0;i<n;i++){
			if(!used[i]&&total<=s[i]){
				used[i] = true;
				order[k] = i;
				dfs(k-1, num+k*w[i], total+w[i]);
				used[i] = false;
			}
		}
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			n = sc.nextInt();
			if(n==0)break;
			name = new String[n];
			w = new int[n];
			s = new int[n];
			order = new int[n+1];
			best = Integer.MAX_VALUE;
			for(int i=0;i<n;i++){
				name[i] = sc.next();
				w[i] = sc.nextInt();
				s[i] = sc.nextInt();
			}
			used = new boolean[n];
			ans = new int[n];
			dfs(n, 0, 0);
			for(int i=0;i<n;i++){
				System.out.println(name[ans[i]]);
			}
		}
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef double D;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
 
#define rd(x) scanf("%d",&x)
#define rd2(x,y) scanf("%d %d",&x,&y)
#define rl(x) scanf("%lld",&x)
#define rl2(x,y) scanf("%lld %lld",&x,&y)
#define wd(x) printf("%d" ,x)
#define wd2(x,y) printf("%d %d",x,y)
#define wl(x) printf("%lld",x)
#define wl2(x,y) printf("%lld %lld",x,y)
#define PC(x) putchar(x)
#define GC() getchar()
#define NL printf("\n")
#define SP printf(" ")
 
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define F first
#define S second
#define MP make_pair
#define PB push_back

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define fr(i,s,e) for(int i=s;i<e;i++)
#define frl(i,s,e) for(ll i=s;i<e;i++)
#define frr(i,s,e) for(int i=s-1;i>=e;i--)
#define frv(i,a) for(int i = 0;i<(int)a.size();i++)
#define frvr(i,a) for(int i = a.size()-1;i>=0;i--)
#define tr(i,a) for(typeof(a.begin()) i = a.begin(); i != a.end();i++)

#define mod 1000000007
#define maxn 100009
#define maxr 100009

void solve()
{
	ll n;
	rl(n);
	VL arr(n);
	priority_queue<double,vector<double>,greater<double>> q;
	fr(i,0,n)
	{
		rl(arr[i]);
		q.push(arr[i]);
	}
	double ans=0;
	while(SZ(q)!=1)
	{
		 double x=q.top();
		 q.pop();
		 double y=q.top();
		 q.pop();
		 ans=(x+y)/2;
		 q.push(ans);
	}
	cout<<ans<<endl;
	return;
}
int main(){
	//sstd::ios::sync_with_stdio(false); cin.tie(NULL);
	solve();
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int n;
    cin >> n;
    if(n/10 == 9 || n%10 == 9)
        cout << "Yes" << endl;
    else
    {
        cout << "No" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MAX 2000009
#define MOD 1000000007
#define endl '\n'
ll h, w, k;
char g[8][8];
char b[8][8];

ll count_black()
{
    ll count = 0;
    for (ll x = 0; x <h; x++)
    {
        for (ll y = 0; y < w; y++)
        {
            if (b[x][y] == '#')
            {
                count++;
            }
        }
    }
    return count;
}
void copy()
{
    for (ll i = 0; i < h; i++)
    {
        for (ll j = 0; j < w; j++)
        {
            b[i][j] = g[i][j];
        }
    }
}
void color(ll i, ll j)
{
    for (ll x = 0; x < h; x++)
    {
        if (i & (1 << x))
        {
            for (ll y = 0; y < w; y++)
            {
                b[x][y] = '$';
            }
        }
    }
    for (ll x = 0; x < w; x++)
    {
        if (j & (1 << x))
        {
            for (ll y = 0; y < h; y++)
            {
                b[y][x] = '$';
            }
        }
    }
}
void print(){
    cout<<"*********"<<endl;
    for(ll i=0;i<h;i++){
        for(ll j=0;j<w;j++){
            cout<<b[i][j];
        }
        cout<<endl;
    }
    cout<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    cout << fixed << setprecision(15);
#ifndef ONLINE_JUDGE
    freopen("../input.txt", "r", stdin);
    freopen("../output.txt", "w", stdout);
#endif

    cin >> h >> w >> k;

    for (ll i = 0; i < h; i++)
    {
        for (ll j = 0; j < w; j++)
        {
            cin >> g[i][j];
        }
    }
    ll ans = 0;
    for (ll i = 0; i < (1 << h); i++)
    {
        for (ll j = 0; j < (1 << w); j++)
        {
            copy();
            color(i, j);
            //print();
            ll cnt = count_black();
           //cout<<cnt<<endl;

            if (cnt == k)
            {
                ans++;
            }
        }
    }

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

Measured memory_bytes: 3616
N, M = map(int, input().split())
students = [[int(i) for i in input().split()] for _ in range(N)]
checkpoints = [[int(i) for i in input().split()] for _ in range(M)]

for student in students:
    dist = []
    for checkpoint in checkpoints:
        dist.append(abs(student[0] - checkpoint[0]) + abs(student[1] - checkpoint[1]))
    print(dist.index(min(dist)) + 1)


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

int main()
{
    string a, b, c;
    cin >> a >> b >> c;
    if (a[a.size() - 1] == b[0] && b[b.size() - 1] == c[0])
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#define ll long long int

using namespace std;

int main()
{
    ll a, b;
    cin>>a>>b;
    ll common = __gcd(a, b);
    vector<ll> ans;

    for(ll i = 2; i*i <= common; i++)
    {
        if(common % i == 0) ans.push_back(i);
        while(common % i == 0) common /= i;
    }
    if(common != 1) cout<<ans.size() + 2<<endl;
    else cout<<ans.size() + 1<<endl;

}


Measured memory_bytes: 256
from sys import stdin


def a_minus_b_or_b_minus_a(a, b):
    if b % a == 0:
        return a + b
    else:
        return b - a

def main():
    input_line = stdin.readline().rstrip()
    a, b = [int(num_string) for num_string in input_line.split(' ')]
    answer = a_minus_b_or_b_minus_a(a, b)
    print(answer)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N, D = MAP()

ans = 0
for _ in range(N):
	X, Y = MAP()
	if X**2 + Y**2 <= D**2:
		ans += 1

print(ans)


Measured memory_bytes: 10572
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
    int n;
    cin>>n;
    double a[n],bunbo=0;
    rep(i,n){
        cin>>a[i];
        bunbo+=1/a[i];
    }
    printf("%f\n",1/bunbo);
    return 0;
}

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


using namespace std;

long long MOD = 1000000007;

long long power(long long m, long long n) {
    if (n == 0) return 1;
    else {
        if (n%2 == 0) return ((power(m, n/2)%MOD)*(power(m, n/2)%MOD))%MOD;
        else return (((power(m, n/2)%MOD)*(power(m, n/2)%MOD))%MOD*m)%MOD;
    }
}

int main() {
    long long m, n; cin >> m >> n;
    long long res = power(m, n)%MOD;
    cout << res << endl;
}


Measured memory_bytes: 3120
// C - Pyramid
#include <bits/stdc++.h>
using namespace std;
using TP = tuple<int,int,int>;//<x,y,h>
using VT = vector<TP>;//[i]<x,y,h>
#define rp(i,n) for(int i=0;i<(n);i++)
#define eb(x,y,h) emplace_back((x),(y),(h))
#define manhattan(x1,y1,x2,y2) abs((x1)-(x2))+abs((y1)-(y2))
#define XMAX 100
#define YMAX 100

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

	VT A;//h!=0
	VT B;//h==0
	VT C;//center candidate

	rp(i, N){
		int x,y,h; cin>>x>>y>>h;
		if(h != 0) A.eb(x,y,h);
		else B.eb(x,y,h);
	}

	rp(y0, YMAX+1){
		rp(x0, XMAX+1){
			bool exist = true;
			int x,y,h;
			tie(x,y,h) = A[0];
			int h0 = h + manhattan(x0,y0, x,y);//h0: hight of center candidate

			for(int i=1; i<A.size(); ++i){
				tie(x,y,h) = A[i];
				if(h0 != h + manhattan(x0,y0, x,y)){
					exist = false;
					break;
				}
			}

			if(exist) C.eb(x0,y0,h0);//set center candidate
		}
	}

	for(auto c:C){// hight zero check & output
		int x0,y0,h0; tie(x0,y0,h0) = c;

		bool exist = true;
		for(auto b:B){
			int x,y,h; tie(x,y,h) = b;
			int m = manhattan(x0,y0, x,y);
			int hi = h0 - m;
			if(hi > 0){
				exist = false;
				break;
			}
		}

		if(exist) cout<<x0<<" "<<y0<<" "<<h0<<"\n";
	}

}

Measured memory_bytes: 512
#include<iostream>
using namespace std;
 
 
int main(){
  
  int plus,zero,minus,num; 
  int result;
  cin >> plus >> zero >> minus >> num;
  
  int max = plus + zero; //最大値を取る最大の枚数
  
  if(num < plus){
    result = num;
  }else if(num >= plus && num <= max){
    result = plus;
  }else{
    result = plus - (num-max);
  }
  
  cout << result;
  
  return 0;
}

Measured memory_bytes: 3636
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int length = 100;
		StringBuilder sb = new StringBuilder();
		sb.append(length).append(" ").append(length).append("\n");
		for (int i = 0; i < length / 2; i++) {
		    char[] line = new char[length];
		    Arrays.fill(line, '#');
		    if (i % 2 == 0) {
		        for (int j = 0; j < length && a > 1; j++) {
		            if (j % 2 == 0) {
		                line[j] = '.';
    		            a--;
		            }
		        }
		    }
		    sb.append(new String(line)).append("\n");
		}
		for (int i =  length / 2; i < length; i++) {
		    char[] line = new char[length];
		    Arrays.fill(line, '.');
		    if (i % 2 == 1) {
		        for (int j = 0; j < length && b > 1; j++) {
		            if (j % 2 == 0) {
		                line[j] = '#';
    		            b--;
		            }
		        }
		    }
		    sb.append(new String(line)).append("\n");
		}
		System.out.print(sb);
    }
}



Measured memory_bytes: 23764