akhauriyash/Code-Regression huggingface dataset:
from collections import Counter,defaultdict,deque
import sys
import bisect
import math
import itertools
import string
import queue
import copy
from heapq import heappop, heappush
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7

def inp(): # n=1
    return int(input())
def inpm(): # x=1,y=2
    return map(int,input().split())
def inpl(): # a=[1,2,3,4,5,...,n]
    return list(map(int, input().split()))
def inpls(): # a=['1','2','3',...,'n']
    return list(input().split())
def inplm(n): # x=[] 複数行
    return list(int(input()) for _ in range(n))
def inpll(n): # [[1,1,1,1],[2,2,2,2],[3,3,3,3]]
    return sorted([list(map(int, input().split())) for _ in range(n)])
def sortx(x,n,k):
    if k == 0:x.sort(key=lambda y:y[1,n])
    else:x.sort(reversed=True, key=lambda y:y[1,n])
def graph():
    n=inp()
    g=[[] for _ in range(n)]
    for i in range(n):
        a=inp()
        a-=1
        g[i].append(a)
        g[a].append(i)
    return n,g
def graphm():
    n,m=inpm()
    g=[[] for _ in range(n)]
    for _ in range(m):
        a,b,w=inpm()
        a-=1
        b-=1
        g[a].append((b,w))
        g[b].append((a,w))
    return n,m,g

def dijkstra(s,n,g): # sからの最短距離 頂点数n
    s -= 1
    que = []
    d = [10**15 for _ in range(n)]
    d[s] = 0
    heappush( que,(0,s) )
    while len(que)>0:
        p =  heappop(que)
        v = p[1]
        if d[v] < p[0]:
            continue
        for i in range(len(g[v])):
            edge = g[v][i]
            if d[edge[0]] > d[v] + edge[1]:
                d[edge[0]] = d[v] + edge[1]
                heappush( que,(d[edge[0]] , edge[0]) )
    return d

def main():
    n=inp()
    if n%2==0:
        x=( n*(n-1) )//2
        print(x-(n//2))
    else:
        x=( n*(n-1) )//2
        print(x-((n-1)//2))
    for i in range(1,n):
        for j in range(i+1,n+1):
            if n%2==0:
                if i+j!=n+1:
                    print(i,j)
            else:
                if i+j!=n:
                    print(i,j)
    
if __name__ == "__main__":
    main()




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

#define MOD_1_000_000_007 (1000000007LL)
#define rep(i, n)   for (long long i = 0; i <  (long long)(n); i++)
#define rep1(i, n)  for (long long i = 1; i <  (long long)(n); i++)
#define rep2(i, n)  for (long long i = 2; i <  (long long)(n); i++)
#define rep0c(i, n) for (long long i = 0; i <= (long long)(n); i++)
#define rep1c(i, n) for (long long i = 1; i <= (long long)(n); i++)
#define rep2c(i, n) for (long long i = 2; i <= (long long)(n); i++)
#define repc0(n, i) for (long long i = (long long)(n); i >= 0; i--)
#define repc1(n, i) for (long long i = (long long)(n); i >= 1; i--)
#define repc2(n, i) for (long long i = (long long)(n); i >= 2; i--)

namespace solver {
  using namespace std;
  typedef long long ll;

  static const ll MAX = 10LL;
  ll N;
  ll xs[MAX], ys[MAX];

  void init() {
    scanf("%d", &N);
    rep(i, N) scanf("%d %d", &xs[i], &ys[i]);
  }

  void solve() {
    vector<int> v;
    rep(i, N) v.push_back(i);
    double total = 0.0;
    int denominator = 0;
    do {
      denominator++;
      int px = xs[*v.begin()], py = ys[*v.begin()];
      for(const int& i : v) {
        int nx = xs[i], ny = ys[i];
        total += sqrt(pow(nx-px, 2) + pow(ny-py, 2));
        px = nx;
        py = ny;
      }
    } while(next_permutation(v.begin(), v.end()));
    printf("%.10lf\n", (total)/((double)denominator));
  }
}


int main() {
  solver::init();
  solver::solve();
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val m = sc.nextInt()

    if (n == 0) {
        println(m * (m - 1) / 2)
        return
    }

    println(n * (n - 1) / 2 + m * (m - 1) / 2)
}

Measured memory_bytes: 29596
#include<bits/stdc++.h>
#define int long long 
using namespace std;
const int N=1e6+5,P=998244353,Gi=332748118;
 
#define PII pair<int,int>
inline int add(const int &x,const int &y){return x+y>P?x+y-P:x+y;}
inline int dec(const int &x,const int &y){return x-y<0?x-y+P:x-y;}
inline int mul(const int &x,const int &y){return 1LL*x*y>P?1LL*x*y%P:x*y;}
 
int ksm(int x,int y=P-2){
    int ans=1;
    for(;y;y>>=1,x=mul(x,x))
        if(y&1)ans=mul(ans,x);
    return ans;
}
 
int lim,r[N],a[N],b[N],o[N],l;
int n,h[N],m,p[N],ans,fac[N],inv[N];
vector<int>f[N];
void init(int len){
    lim=1,l=-1;
    while(lim<=len)lim<<=1,++l;
    for(int i=1;i<lim;i++)r[i]=(r[i>>1]>>1)|((i&1)<<l);
}
void NTT(int *A,int ty){
    for(int i=0;i<lim;i++)
        if(i<r[i])swap(A[i],A[r[i]]);
    for(int p=1;p<lim;p<<=1){
        int D=p<<1,wn=ksm(ty==1?3:Gi,(P-1)/D);
        o[0]=1;
        for(int i=1;i<p;i++)o[i]=mul(o[i-1],wn);
        for(int i=0;i<lim;i+=D){
            for(int j=0;j<p;j++){
                int x=A[i+j],y=mul(A[i+j+p],o[j]);
                A[i+j]=add(x,y),A[i+j+p]=dec(x,y);
            }
        }
    }
    if(ty==-1)
        for(int i=0,INV__=ksm(lim);i<lim;i++)
            A[i]=mul(A[i],INV__);
}
int C(int x,int y){
	return mul(fac[y],mul(inv[x],inv[y-x]));
}
int A(int x,int y){
	return mul(fac[y],inv[y-x]);
}
priority_queue<PII,vector<PII>,greater<PII> >Q;
signed main(){
    scanf("%lld",&n),n*=2;
    for(int i=1;i<=n;i++)scanf("%lld",&h[i]);
    sort(h+1,h+1+n);
    for(int i=1;i<=n;i++){
    	if(h[i]!=h[i-1])p[++m]=1;
    	else p[m]++;
	}
	fac[0]=1;
	for(int i=1;i<=n;i++)fac[i]=mul(fac[i-1],i);
	inv[n]=ksm(fac[n]);
	for(int i=n-1;~i;i--)inv[i]=mul(inv[i+1],i+1);
    for(int i=1;i<=m;i++){
    	for(int j=0;j<=(p[i]>>1);j++){
    		f[i].push_back(mul(mul(A(j,p[i]),C(j,p[i]-j)),ksm(ksm(2,j))));
		}
		Q.push(PII(f[i].size(),i));
	}
	while(Q.size()>1){
		int u=Q.top().second;
		Q.pop();
		int v=Q.top().second;
		Q.pop(); 
		int su=f[u].size(),sv=f[v].size();
		init(su+sv-2);
		for(int i=0;i<=lim;++i) a[i]=b[i]=0;
		for(int i=0;i<su;++i) a[i]=f[u][i];
		for(int i=0;i<sv;++i) b[i]=f[v][i];
		NTT(a,1),NTT(b,1);
		for(int i=0;i<lim;i++) a[i]=mul(a[i],b[i]);
		NTT(a,-1);
		++m;
		if(!Q.size()){
			for(int i=0;i<=su+sv-2;++i)
				ans=add(ans,mul(mul(ksm(P-1,i),a[i]),mul(A((n-2*i)>>1,n-2*i),ksm(ksm(2,(n-2*i)>>1)))));
			break;
		}
		for(int i=0;i<=su+sv-2;++i) f[m].push_back(a[i]);
		Q.push(PII(f[m].size(),m));
	}
	printf("%lld\n",(ans+P)%P);
}

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

using namespace std;

int main()
{
    int N, M, C;
    cin >> N >> M >> C;
    vector<int> A(M);
    for (int i = 0; i < M; i++)
    {
        cin >> A[i];
    }
    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        int sum = C;
        for (int j = 0; j < M; j++)
        {
            int b;
            cin >> b;
            sum += b * A[j];
        }
        if (sum > 0)
        {
            ans++;
        }
    }

    cout << ans << endl;
}


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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    int N; cin >> N;
    vector<vec> a(N);
    rep(i, N-1){
        int x; cin >> x;
        x--;
        a[x].push_back(i);
    }

    rep(i, N){
        cout << a[i].size() << endl;
    }
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 18248
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <ctype.h>
#include <cmath>
#include <iomanip>
#include <ios>
#include <set>
#define ll long long
using namespace std;

int main(void){
    
    int n,l;
    cin>>n>>l;
    string s[n];
    for(int i=0;i<n;i++)cin>>s[i];
    sort(s,s+n);
    for(int i=0;i<n;i++)cout<<s[i];
    cout<<endl;
    
    
    return 0;
}




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

int main(){
    // input
    int N;
    double ans;
    cin >> N;
    if( N % 2 == 0 ){
        ans = 0.5;
    }else{
        ans = (N/2 + 1) / (N + 0.0);
    }
    cout << ans << endl;
} 

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
long a,b,c,d,e,f;
double g;
for(;;){
cin>>a>>b>>c>>d>>e>>f;
if(cin.eof())break;
g=a*e-b*d;
if(g>0)printf("%.3f %.3f\n",(c*e-b*f)/g,(a*f-c*d)/g);
else printf("%.3f %.3f\n",(b*f-c*e)/(-g),(c*d-a*f)/(-g));
}
return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
#define ll long long
#define sz(x) (int)(x).size()
using namespace std;

ll binpow(ll a, ll b) {
    if (b == 0)
    {
        return 1;
    }
    ll res = binpow(a, b / 2);
    res*=res;
    if (b % 2)
    {
        return res * a;
    }
    return res;
}

ll gcd(ll a,ll b)
{
    if (b==0) return a;
    return gcd(b,a%b);
}

string to_upper(string a)
{
    for (int i=0;i<(int)a.size();++i) if (a[i]>='a' && a[i]<='z') a[i]-='a'-'A';
    return a;
}
 
string to_lower(string a)
{
    for (int i=0;i<(int)a.size();++i) if (a[i]>='A' && a[i]<='Z') a[i]+='a'-'A';
    return a;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    while (1)
    {
        c-=b;
        if (c<=0)
        {
            cout<<"Yes";
            return 0;
        }
        a-=d;
        if (a<=0)
        {
            cout<<"No";
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3636
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(int argc , char **argv)
{
	(void)argc;
	(void)argv;

	vector<int> v;
	int N , K;
	cin >> N >> K;
	for(int i=0;i<N;i++){
		int64_t a;
		cin >> a;
		v.push_back(a);
	}

	int sum = 0;
	stable_sort(v.begin(),v.end(), greater<int>());
	for(int i=0; i<K; i++)
	{
		sum += v[i];
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 256
#include<string>
#include<iostream>
#include <algorithm>
#include<vector>
#include<functional>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <numeric>
#include <math.h>
#define ll long long 
#define PI 3.14159265358979323846
#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep1(x,n) for(ll x=1;x<(ll)n+1;x++)
using namespace std;
const ll INF = 1000000000;


int main() {
	ll N, K, ans = 0;
	cin >> N >> K;
	vector <ll> p(N);
	rep(i, N) cin >> p[i];
	sort(p.begin(), p.end());
	rep(i, K) ans += p[i];
	cout << ans << endl;
	return 0;
}

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

#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define ALL(v) (v).begin(), (v).end()
#define INF 1e09
struct P{
  int x; int y; bool got=false;
};

using namespace std;

int main(){
  int n, m, x, y;
  while(cin >> n and n){
    x = 10; y = 10;
    P gem[n];
    REP(i, n) { cin >> gem[i].x >> gem[i].y; }
    cin >> m;
    int cnt = 0;
    REP(i, m) {
      char dir; int step;
      int dx = 0; int dy = 0;
      cin >> dir >> step;
      if(dir == 'N') dy = step;
      if(dir == 'S') dy = -step;
      if(dy != 0)
        REP(k, n)
          if(gem[k].got == false and gem[k].x == x and gem[k].y <= max(y, y+dy) and gem[k].y >= min(y, y+dy)){ gem[k].got = true; cnt++;}
      if(dir == 'E') dx = step;
      if(dir == 'W') dx = -step;
      if(dx != 0)
        REP(k, n)
          if(gem[k].got == false and gem[k].y == y and gem[k].x <= max(x, x+dx) and gem[k].x >= min(x, x+dx)){ gem[k].got = true; cnt++;}
      x += dx; y += dy;
    }
    cout << (cnt == n ? "Yes" : "No") << endl;
  }
}

Measured memory_bytes: 2984
n, k = [int(i) for i in input().split()]
h = [int(i) for i in input().split()]
 
def frog(n, k, h):
    d = [float('inf')] * n
    d[0] = 0
 
    for i in range(1, n):
        d[i] = min(
            d[j] + abs(h[i] - h[j]) for j in range(max(i - k, 0), i)
        )
    return d[n - 1]
 
 
print(frog(n, k, h))

Measured memory_bytes: 13976
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define era(t) t.erase(unique(be(t)),t.end())
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
typedef long long ll;
using namespace std;
const ll mod=1000000007,mod9=1000000009;
template <class T>inline T lcm(T a,T b){return (a*b/__gcd(a,b));}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    int n=s.length();
    int ans=0,num=0;
    for(int i=0;i<n;i++){
        if(s[i]=='A'||s[i]=='T'||s[i]=='C'||s[i]=='G'){
            num++;
        }
        else{
            num=0;
        }
        ans=max(ans,num);
    }
    cout << ans<<endl;
    return 0;
}


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

int main(){
    int n;cin>>n;
    int t[n+1];
    for(int i=0;i<n;i++)cin>>t[i];
    int m;cin>>m;
    int p[m+1],x[m+1];
    for(int i=0;i<m;i++)cin>>p[i]>>x[i];
    
    for(int i=0;i<m;i++){
        int sum=0;
        for(int j=0;j<n;j++){
            if(j==p[i]-1)sum+=x[i];
            else{
                sum+=t[j];
            }
        }cout<<sum<<endl;
    }

}

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

#define ll long long 
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()
ll inf = 1e18+7;
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    int n,m,s; cin >> n >> m >> s;
    vector<vector<tuple<ll,ll,ll>>> graph(n); //time_cost,money,next
    vector<ll> c(n); //get_money
    vector<ll> d(n); //time_cost
    rep(i,0,m){
        int a,b,q,w;
        cin >> a >> b >> q >> w;
        a--;b--;
        graph[a].push_back(make_tuple(w,q,b));
        graph[b].push_back(make_tuple(w,q,a));
    }
    rep(i,0,n) cin >> c[i] >> d[i];
    priority_queue<
        tuple<ll,ll,ll>,
        vector<tuple<ll,ll,ll>>,
        greater<tuple<ll,ll,ll>> //time,money,locate
    > que;
    int money = (s<2500 ? s : 2500);
    que.push(make_tuple(0,money,0));
    ll dist[51][2510];//答えのメモ
    rep(i,0,51)rep(j,0,2510) dist[i][j] = inf;
    dist[0][money] = 0; //startは0

    //dijkstra
    while(!que.empty()){
        auto [time,money,locate] = que.top(); que.pop();
        if(dist[locate][money]<time) continue;
        if(money<2500){ // お金を増やす側の移動を行うフェイズ
            ll add_money = c[locate]+money;
            if(add_money>2500) add_money = 2500;
            ll add_time = time + d[locate];
            if(dist[locate][add_money] > add_time){
                dist[locate][add_money] = add_time;
                que.push(make_tuple(add_time,add_money,locate)); //時間とお金のみ増
            }
        }
        // 駅を移動するフェイズ
        rep(i,0,graph[locate].size()){
            tuple<ll,ll,ll> next = graph[locate][i]; //time,money,locate
            int next_locate = get<2>(next);
            ll next_money = money - get<1>(next);
            ll next_time = time + get<0>(next);
            if(next_money<0) continue;
            // dist更新
            if(dist[next_locate][next_money] > next_time){
                dist[next_locate][next_money] = next_time;
                que.push(make_tuple(next_time,next_money,next_locate));
            }
        }
    }
    rep(i,1,n){
        ll ans=inf;
        rep(j,0,2500){
            ans = min(ans,dist[i][j]);
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 7316
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    cin>>a>>b;
    int k=b;
    long long int broken[b],dp[a+2]={0};
    dp[a]=1;
    for(int i=0;i<b;i++) cin>>broken[i];
    for(int i=a-1;i>=0;i--){
        if(k-1>=0&&i==broken[k-1]){
            dp[i]=0;
            k--;
            }
        else dp[i]=(dp[i+1]+dp[i+2])%1000000007;
    }
    cout<<dp[0]<<endl;
}


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

string s;
int p;

int parse() {
  int m = 0;
  if (p < s.size()) {
    if (s[p] == '[') {
      vector<int> v;
      while (s[p] == '[') {
        p++;
        v.push_back(parse());
        p++;
      }
      sort(begin(v), end(v));
      for (int i = 0; i < v.size() / 2 + 1; i++) {
        m += v[i];
      }
    } else {
      while ('0' <= s[p] && s[p] <= '9') {
        m = 10 * m + int(s[p] - '0');
        p++;
      }
      m = m / 2 + 1;
    }
  }
  return m;
}

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s;
    p = 0;
    cout << parse() << endl;
  }
  return 0;
}



Measured memory_bytes: 3236
import java.util.Scanner;

public class Main{

	public static void main (String[] args) {

		Scanner sc = new java.util.Scanner (System.in);

		String s = sc.next();
		String[] list = new String [s.length()];
		list = s.split("");
		int count = 0;
		for (int index=0; index<s.length()/2; index++) {
			if (list[index].equals(list[s.length()-index-1])) {
			} else {
				count++;
			}
		}

		System.out.println(count);
	}
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define IOS                                                                    \
  ios::sync_with_stdio(0);                                                     \
  cin.tie(0);                                                                  \
  cout.tie(0)
#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<ll, ll>;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
ll bpow(ll b, ll p, ll m = 1000000007LL) {
  ll rt = 1;
  for (; p; p >>= 1, b = b * b % m)
    if (p & 1)
      rt = rt * b % m;
  return rt;
}
int main() {
  IOS;
  int k;
  string s;
  cin >> k >> s;
  if (s.length() <= k)
    cout << s << endl;
  else
    cout << s.substr(0, k) << "..." << endl;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec     vector<int>
#define vecll   vector<ll>
#define vec2    vector<vector<int>>
#define vec2ll  vector<vector<ll>>
#define vpair   vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>
#define vecst   vector<string>
#define vecb    vector<bool>

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define mpair(v1, v2)    make_pair(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << var << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << var;
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt((ok ? "Yes" : "No"));}
//----------------------------------------------------------------

int main(void) {
  string s;
  cin >> s;
  reverse(all(s));

  vecst u={"maerd", "esare", "resare", "remaerd"};

  int id=0;
  while(id<s.size()){
    if(s.size()-id<5){
      prt("NO");
      return 0;
    }
    string sub=s.substr(id,5);
    if(sub==u[0] || sub==u[1]){
      id+=5;
      continue;
    }
    if(s.size()-id<6){
      prt("NO");
      return 0;
    }
    sub=s.substr(id,6);
    if(sub==u[2]) {
      id+=6;
      continue;
    }
    if(s.size()-id<7){
      prt("NO");
      return 0;
    }
    sub=s.substr(id,7);
    if(sub==u[3]){
      id+=7;
      continue;
    }
    prt("NO");
    return 0;
  }

  prt("YES");
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template < typename T > string tost( const T& n ) { ostringstream stm; stm << n; return stm.str();}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
int const INF = 1001001001;


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

string S; cin >> S; sort(all(S));
if(S == "abc") cout << "Yes" << endl;
else cout << "No" << endl;

return 0;
}

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

int main(int argc, char** argv) {
    int number1,number2;
    int readScan = scanf("%d", &number1);
    int array1[number1];
    for(int i=0;i<number1;i++)
    {
        int readScan = scanf("%d", &array1[i]);
    }
    int readScan1 = scanf("%d", &number2);
    int array2[number2];
    for(int i=0;i<number2;i++)
    {
        int readScan = scanf("%d", &array2[i]);
    }
    int key;
    int count=0;
    for(int i=0;i<number2;i++)
    {
        for(int j=0;j<number1;j++)
        {
            key=array2[i];
            if(key == array1[j])
            {
                count++;
                break;
            }
        }
    }
    printf("%d\n", count);
    return (EXIT_SUCCESS);
}


Measured memory_bytes: 2076
#include <stdio.h>

int main (){
	int n;
	int change;
	int i;
	scanf("%d", &n);
	if (n%1000==0){
		printf("0\n");
	}
	else if(n%1000!=0 && n>=1000){
		for(i=1; 1000*i<n; i++){
			change =1000+((1000*i)-n);
		}
		printf("%d\n", change);
	}
	else if (n<1000){
		change = 1000-n;
		printf("%d\n", change);
	}
	
	return 0;
}

Measured memory_bytes: 1732
#include <stdio.h>

int main(void) {
  int n;
  scanf("%d\n", &n);
  int x[n], y[n], b[n], p[n];

  int i;
  for (i = 0; i < n; i++) {
    if (i < n - 1) {
      scanf("%d%d%d%d\n", &x[i], &y[i], &b[i], &p[i]);
    } else {
      scanf("%d%d%d%d", &x[i], &y[i], &b[i], &p[i]);
    }
  }


  for (i = 0; i < n; i++) {
    if (b[i] >= 5 && p[i] >= 2) {
      printf("%d\n", (int)(((x[i] * b[i]) + (y[i] * p[i])) * 0.8));
    } else {
      if (b[i] < 5 && p[i] < 2) {
        if (((x[i] * b[i]) + (y[i] * p[i])) > (int)((x[i] * 5) + (y[i] * 2) * 0.8)) {
          printf("%d\n", (int)((x[i] * 5) + (y[i] * 2) * 0.8));
        } else {
          printf("%d\n", ((x[i] * b[i]) + (y[i] * p[i])));
        }
      } else if (b[i] < 5) {
        if (((x[i] * b[i]) + (y[i] * p[i])) > (int)(((x[i] * 5) + (y[i] * p[i])) *0.8)) {
          printf("%d\n", (int)(((x[i] * 5) + (y[i] * p[i])) *0.8));
        } else {
          printf("%d\n", ((x[i] * b[i]) + (y[i] * p[i])));
        }
      } else {
        if (((x[i] * b[i]) + (y[i] * p[i])) > (int)(((x[i] * b[i]) + (y[i] * 2)) * 0.8)) {
          printf("%d\n", (int)(((x[i] * b[i]) + (y[i] * 2)) * 0.8));
        } else {
          printf("%d\n", ((x[i] * b[i]) + (y[i] * p[i])));
        }
      }
    }
  }

  return 0;
}



Measured memory_bytes: 2112
#include<bits/stdc++.h>
#include<string>
using namespace std;
#define int long long int


int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout<<setprecision(30)<<fixed;

	string s,t;
	cin>>s>>t;
	int l1=s.length(),l2=t.length();
	int c=INT_MAX;
	for(int i=0;i<l1-l2+1;i++)
	{
		int c1=0;
		for(int j=0;j<l2;j++)
		{
			if(s[i+j]==t[j])
				c1++;
		}
		c=min(c,l2-c1);
	}
	cout<<c<<endl;
	return 0;
}


Measured memory_bytes: 3656
#include <iostream>
using namespace std;
void ABC90(void);
void ABC91(void);
void ABC92(void);
void ABC93(void);
void ABC94(void);
void ABC95(void);
void ABC96(void);
void ABC97(void);
void ABC98(void);
void ABC99(void);

int main(void){
    ABC95();
}

void ABC95(){
    int sum=700;
    string a;
    cin>>a;
    for(int i=0;i<=2;++i){
        if(a[i]=='o')sum+=100;
    }
    cout<<sum;
}

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

using namespace std;

int main()
{
    int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin>>k;
    cout<<a[k-1]<<"\n";
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.math.*;
import java.util.*;
public class Main {

	public static void main(String[] args) { //Consider repetition
		Scanner input = new Scanner(System.in);
		int N = input.nextInt();
		int M = input.nextInt();
		int ans=1;
		boolean[] pos = new boolean[N+1]; //Whether red ball can remain in box i
		int[] cnt = new int[N+1]; //How many balls in each box
		Arrays.fill(cnt, 1); //Every box has 1 ball to start
		pos[1]=true;
		for (int i = 0; i < M; i++) {
			int A = input.nextInt();
			int B = input.nextInt();
			if (pos[A]) {
				cnt[A]--;
				cnt[B]++;
				if (!pos[B]) {
					pos[B]=true;
					ans++;
				}
				if (cnt[A]==0) {
					ans--;
					pos[A]=false; //Box is literally empty
				}
			}else {
				cnt[A]--;
				cnt[B]++;
			}
		}
		System.out.println(ans);
	}
}

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

int main(){
  long long a,b,k;
  cin >> a >> b >> k;
  if(a>=k){
    cout << a-k << " " << b << endl;
  }else if(a+b>=k){
    cout << '0' << " " << b-(k-a) << endl;
  }else{
    cout << '0' << " " << '0' << endl;
  }
}
    


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

int isPrime(int);

int main(void)
{
  int num, A[10000];
  int i, cnt = 0;

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

  for(i = 0; i < num; i++){
    cnt += isPrime(A[i]);
  }

  printf("%d\n", cnt);
  return 0;
}


int isPrime(int x){
  int i;
  if(x == 2) return 1;
  if(x < 2 || x % 2 == 0) return 0;
  
  i = 3;
  while(i <= sqrt(x)){
    if(x % i == 0) return 0;
    i += 2;
  }
  return 1;
}
  

Measured memory_bytes: 628
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

int main(){
    
    long long int i, N, K, ans, T;
    cin >> N >> K;
    ans = 1;
    T = 1000000007;
    
    vector< long long int > A(N);
    vector< long long int > B;
    
    for (i = 0; i < N; i++){
        cin >> A[i];
    }
    
    sort(A.begin(), A.end(), greater<int>());
    
    for (i = N - 1; i >= 0; i--){
        if (A[i] >= 0) break;
        
        B.push_back(A[i]);
        A.pop_back();
    }
    
    if (N == K){
        
        for (i = 0; i < N; i++){
            
            ans *= A[i];
            ans %= T;
        }
        
        if (ans < 0) ans += T;
        
        cout << ans << "\n";
        return 0;
    }
    
    int A_size = A.size();
    int B_size = B.size();
    int A_pos = 0;
    int B_pos = 0;
    
    if (A_size == 0){
        if (K % 2 == 0){
            
            for (i = 0; i < K; i++){
                
                ans *= B[i];
                ans %= T;
            }
            
            if (ans < 0) ans += T;
            
            cout << ans << "\n";
            return 0;
            
        } else {
            
            for (i = 0; i < K; i++){
                
                ans *= B[B_size - 1 - i];
                ans %= T;
            }
            
            if (ans < 0) ans += T;
            
            cout << ans << "\n";
            return 0;
        }
    }
    
    if (K % 2 > 0){
        
        ans = A[0];
        A.erase(A.begin());
        A_size -= 1;
        K -= 1;
    }
    
    for (i = 0; i < K; i += 2){
        
        if (A_size  - A_pos < 2){
            
            ans *= B[B_pos];
            ans %= T;
            B_pos++;
            ans *= B[B_pos];
            ans %= T;
            B_pos++;
            
        } else if (B_size - B_pos < 2){
            
            ans *= A[A_pos];
            ans %= T;
            A_pos++;
            ans *= A[A_pos];
            ans %= T;
            A_pos++;
            
        } else if (A[A_pos] * A[A_pos + 1] > B[B_pos] * B[B_pos + 1]){
            
            ans *= A[A_pos];
            ans %= T;
            A_pos++;
            ans *= A[A_pos];
            ans %= T;
            A_pos++;
            
        } else if (A[A_pos] * A[A_pos + 1] <= B[B_pos] * B[B_pos + 1]){
            
            ans *= B[B_pos];
            ans %= T;
            B_pos++;
            ans *= B[B_pos];
            ans %= T;
            B_pos++;
            
        } else {
            cout << "error" << "\n";
            return 0;
        }
        
    }
    
    if (ans < 0) ans += T;
    cout << ans << "\n";
    
    return 0;
}


Measured memory_bytes: 6416
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace AtCoder {
    class Practice {
        static void Main() => CustomMain();

        static void Solve() {
            var n = ReadInt();
            WriteAnswer(n / 3);
        }


        static void CustomMain() {
#if DEBUG
            // ファイルからテストケースを読み込む
            global::Common.ChangeStdIn();
            // 時間計測
            var stopwatch = new Stopwatch();
            stopwatch.Start();
#endif
            // 出力高速化
            var streamWriter = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
            Console.SetOut(streamWriter);
            // 回答
            Solve();
#if DEBUG
            stopwatch.Stop();
            Console.WriteLine(stopwatch.Elapsed);
#endif
            Console.Out.Flush();
        }

        static string ReadString() => Console.ReadLine().Trim();
        static int ReadInt() => int.Parse(ReadString());
        static long ReadLong() => long.Parse(ReadString());
        static float ReadFloat() => float.Parse(ReadString());
        static double ReadDouble => double.Parse(ReadString());

        static string[] ReadStringArray() => ReadString().Split(' ');
        static int[] ReadIntArray() => Array.ConvertAll(ReadString().Split(' '), int.Parse);
        static long[] ReadLongArray() => Array.ConvertAll(ReadString().Split(' '), long.Parse);
        static float[] ReadFloatArray() => Array.ConvertAll(ReadString().Split(' '), float.Parse);
        static double[] ReadDoubleArray() => Array.ConvertAll(ReadString().Split(' '), double.Parse);

        static T TypeConversion<T>(string s) {
            if (typeof(T) == typeof(int)) {
                return (T) Convert.ChangeType(int.Parse(s), typeof(T));
            } else if (typeof(T) == typeof(long)) {
                return (T) Convert.ChangeType(long.Parse(s), typeof(T));
            } else if (typeof(T) == typeof(double)) {
                return (T) Convert.ChangeType(double.Parse(s), typeof(T));
            } else {
                return (T) Convert.ChangeType(s, typeof(T));
            }
        }

        static void ReadMulti<T, U>(out T a, out U b) {
            var str = ReadStringArray();
            a = TypeConversion<T>(str[0]);
            b = TypeConversion<U>(str[1]);
        }

        static void ReadMulti<T, U, V>(out T a, out U b, out V c) {
            var str = ReadStringArray();
            a = TypeConversion<T>(str[0]);
            b = TypeConversion<U>(str[1]);
            c = TypeConversion<V>(str[2]);
        }

        static void WriteAnswer(object ans) => Console.WriteLine(ans);

        static bool IsOdd(long num) {
            return (num & 1) == 1;
        }

        static bool IsEven(long num) {
            return (num & 1) == 0;
        }

        static long GCD(long a, long b) {
            return b != 0 ? GCD(b, a % b) : a;
        }
    }
}

Measured memory_bytes: 11092
(defun _ferris (a b)
  (cond ((<= a 5) 0)
        ((and (<= 6 a) (<= a 12)) (floor b 2))
        (t b)))

(defun ferris(a b)
  (print (_ferris a b)))

#|
(ferris 30 100)
(ferris 12 100)
(ferris 0 100)
|#
(let ((a (read))
      (b (read)))
  (ferris a b))

Measured memory_bytes: 13024
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cassert>
using namespace std;

#define REP(i,n) for (ll i = 0; i < n; i++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long ll;

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

long long lcm(long long a, long long b) {
    return a / gcd(a,b) * b;
}

int main ()
{
    ll N,M; cin >> N >> M;
    string S,T; cin >> S >> T;

    ll L = lcm(N,M);
    map < ll, char > used;
    REP(i,N) {
        ll tt = 1LL + (L / N) * (ll)(i);
        used[tt] = S[i];
    }
    REP(i,M) {
        ll tt = 1LL + (L / M) * (ll)(i);
        if (used.find(tt) != used.end()) {
            if (used[tt] != T[i]) {
                cout << -1 << endl;
                return 0;
            }
        }
    }

    cout << L << endl;

    return 0;
}


Measured memory_bytes: 6144
#include <bits/stdc++.h>
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

int main() {
	int n; scanf("%d", &n);
	int a, b; scanf("%d%d", &a, &b);
	std::vector<int> li(5, 0);
	for(int i = 0; i < n; i++) {
		int x; scanf("%d", &x);
		if(x <= a) li[0]++;
		if(a < x and x <= b) li[1]++;
		if(b < x) li[2]++;
	}
	printf("%d\n", std::min({li[0], li[1], li[2]}));
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		// 文字列の入力
		String[] s = sc.next().split("");
        List<String> sList = Arrays.asList(s);
        String ans = "yes";
        for (int i = 0; i < s.length; i++) {
          if (sList.indexOf(sList.get(i)) != i) {
            ans = "no";
            break;
          }
        }
    
		// 出力
		System.out.println(ans);
	}
}

Measured memory_bytes: 23764
import java.io.BufferedReader;
import java.io.*;
import java.util.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Collections;
public class Main {
	public static void main(final String[] args){
    
    Scanner sc = new Scanner(System.in);
    int r = sc.nextInt();
    System.out.println(r*r);
    
	}
}

Measured memory_bytes: 21844
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 210000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
long long C(int a,int b){
	if(a<b||b<0)return 0;
	return fact[a]*finv[b]%mod*finv[a-b]%mod;
}
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
// ここから編集しろ

int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	for(int i=a;i<=b;i++){
		if(i%2019==0){
			printf("0\n");return 0;
		}
	}
	int n=b-a+1;
	int ret=mod;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			long long val=(long long)(a+i)*(a+j)%2019;
			ret=min(ret,(int)val);
		}
	}
	printf("%d\n",ret);
}

Measured memory_bytes: 128
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#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 pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#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 sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#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) sort(v.begin(),v.end());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};

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

struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Timer TM;


    ll a,b;
    cin>>a>>b;
    if(a<9&&b<9) cout<<"Yay!"<<endl;
    else cout<<":("<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
constexpr ll mod = 1e9+7;

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

  ll l = 0, r = n;
  while (r - l > 1) {
    ll m = (r + l) / 2;
    if (m * (m + 1) / 2 >= n) r = m;
    else l = m;
  } 
  ll d = r * (r + 1) / 2 - n;
  for (int i = 1; i <= r; i++) {
    if (i == d) continue;
    cout << i << endl;
  }
  return 0;
} 

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	priority_queue<double, vector<double>, greater<double>> pq;
	for(int i=0;i<n;i++){
		int t;
		cin>>t;
		pq.push(t);
	}
	for(int i=0;i<n-1;i++){
		double d1=pq.top(), d2;
		pq.pop();
		d2=pq.top();
		pq.pop();
		pq.push((d1+d2)/2);	
	}
	cout<<pq.top();
}

Measured memory_bytes: 256
/*
ID: duttonl1
TASK: J_Sushi.cpp 
LANG: C++
*/
#include <bits/stdc++.h>

#define pb push_back
#define fst first
#define snd second
#define DEBUGA(a, b) cout << "[ "; for (auto _x = (a); _x != (b); _x++) cout << *_x << " "; cout << "]"<< endl
#define DEBUG(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string>_it(_ss); err(_it, args); };cout << endl
#define fr(i,x) for (int i = 0; i < int(x); i++)
#define frab(i,a,b) for (int i = int(a); i < int(b); i++)
#define sz(x) ((int) (x).size())
void run();
int main() {
    std::ios::sync_with_stdio(false);
    run();
    return 0;
}

using namespace std;

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

double dp[310][310][310];

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef long long ll;
int N;

double solve(int i, int j, int k) {
    if (i < 0 || j < 0 || k < 0) return 0;
    if (i == 0 && j == 0 && k == 0) return 0;
    if (dp[i][j][k] >= 0) return dp[i][j][k];
    double p = (double)(N-i-j-k)/(double)(N);
    double a = (double)i * solve(i-1,j,k) / (double)N, 
           b = (double)j * solve(i+1,j-1,k) / (double)N, 
           c = (double)k * solve(i,j+1,k-1) / (double)N;
    return dp[i][j][k] = (1+a+b+c)/((double)1-p); 
}

void run() {
    cin >> N;
    cout << setprecision(15);
    memset(dp, -1, sizeof(double) * 310 * 310 * 310); 
    int tmp, a, b, c; a = b = c = 0; 
    fr(i,N) {
        cin >> tmp;
        if (tmp == 1) a++;
        else if (tmp == 2) b++;
        else c++;
    }
    cout << solve(a,b,c) << endl;
}





Measured memory_bytes: 233088
n = int(input())
l = [str(input()) for i in range(n)]
l.sort()
i = 0
count = 1
ans = []
max = 1
while i < n-1:
  if l[i] == l[i+1]:
    count += 1
    i += 1
    if count >= max:
      max = count
    if i == n-1:
      ans.append([l[n-1], count])

  else:
      ans.append([l[i],count])
      count = 1
      i += 1

if max == 1:
  ans.append([l[n-1], 1])
      
for i in ans:
  if i[1] == max:
    print(i[0])





Measured memory_bytes: 39112
/*
　　こんにちは。あたしはｶｳｶﾞｰﾙ。
　　redcoderになるためAtCoderを巡る旅をしてます。

　　　 　 ＿_
　　　 ヽ|＿_|ノ　　　　ﾓｫ
　　　　||‘‐‘||ﾚ　　_)_, ―‐ 、
　　　　/(Ｙ (ヽ＿ /・ ヽ　　 ￣ヽ
　　　　∠ ＿ ゝ　 ｀^ヽ ﾉ.::::_(ノヽ
　　　　 _/ヽ　 　　  /ヽ￣￣/ヽ
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define dump(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define COUT(x) cout << (x) << endl

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

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

    string s; cin >> s;
    vector<bool> a(4, false);
    rep(i, s.size()) {
        if(s[i] == 'N') a[0] = true;
        else if(s[i] == 'S') a[1] = true;
        else if(s[i] == 'W') a[2] = true;
        else a[3] = true;
    }
    int flg = 0;
    if((!a[0] && a[1]) || (a[0] && !a[1]) || (!a[2] && a[3]) || (a[2] && !a[3])) flg = 1;
    if(flg) cout << "No" << endl;
    else cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,s,f) for(i=s;i<f;i++)
#define print(v) for(auto &z:v) cout<<z<<' ';cout<<'\n'
#define hi cout<<'h'<<'i'<<'\n' 
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define B begin()
#define E end()
#define sz(v) (int)((v).size())
#define vi vector<int>
#define vii vector<pair<int,int>>
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define clk1 clock_t start_time=clock()
#define clk2 cout<<(clock()-start_time)/(double)CLOCKS_PER_SEC
#define clean(arr) memset(arr,0,sizeof(arr))
#define mod 1000000007
#define mod2 998244353
#define space 100005
//<<fixed << setprecision(9)

int main()
{
    int i,j,n,t;
    boost;
    cin>>n;
    int arr[n];
    rep(i,0,n)cin>>arr[i];

    int want=1;
    int cnt=0;
    rep(i,0,n)
    {
        if(arr[i]==want)
        {
            want++;
        }
        else cnt++;
    }
    if(cnt==n)cout<<-1;
    else cout<<cnt;

    return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <set>
using namespace std;
int main()
{
    int n;
    cin>>n;
    vector<int> x,y,h;
    for(int i=0;i<n;i++)
    {
        int a,b,c;
        cin>>a>>b>>c;
        x.push_back(a);
        y.push_back(b);
        h.push_back(c);
    }
    for(int i=0;i<=100;i++)
    {
        for(int j=0;j<=100;j++)
        {
            set<int> v1;
            int maxi=2e9+1;
            for(int ii=0;ii<n;ii++)
            {
                if(h[ii]!=0)
                {
                    v1.insert(abs(i-x[ii])+abs(j-y[ii])+h[ii]);
                }
                else
                {
                    maxi=min(maxi,abs(i-x[ii])+abs(j-y[ii])+h[ii]);
                }
            }
            if(v1.size()>1)
                continue;
            else if(v1.size()==1)
            {
                if(*(v1.begin())<=maxi)
                {
                    if((*v1.begin())>=1){
                    cout<<i<<" "<<j<<" "<<*v1.begin()<<endl;
                    return 0;
                }
                }
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256