akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define OUT(x)                cout << #x << " = " << x << endl; 
#define rep(i, n)             for (int (i) = 0; (i) < (int)(n); (i)++)
#define rer(i, l, r)          for (int (i) = (int)(l); (i) <= (int)(r); (i)++)
#define reu(i, l, r)          for (int (i) = (int)(l); (i) < (int)(r); (i)++)
#define each(i, v)            for (auto i : v)
#define all(x)                (x).begin(), (x).end()
#define rall(x)               (x).rbegin(), (x).rend()
#define pb(x)                 push_back(x)
#define bp(x)                 __builtin_popcount(x)
#define mp(x, y)              make_pair((x), (y))
#define fi                    first
#define se                    second
#define setp(x)               setprecision(x)
#define mset(m, v)            memset(m, v, sizeof(m))
#define sz(x)                 (int)(x.size())
static const int INF        = 0x3f3f3f3f;
static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
static const int MOD        = 1000000007;
static const double PI      = 3.14159265358979;

#define int                   long long

typedef vector<double>        vd;
typedef vector<string>        vs;
typedef vector<bool>          vb;
typedef vector<int>           vi;
typedef pair<int, int>        pii;
typedef vector<pii>           vpii;

template<typename T> void pv(T a, T b) { for (T i = a; i != b; i ++) cout << *i << " "; cout << endl; }
template<typename T, typename U> inline void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if (x < y) x = y; }
int in() { int _x; scanf("%d", &_x); return _x; }
long long lin() {long long _x; scanf("%lld", &_x); return _x; };

signed main() { 
        int n = lin();
        vi a(n);
        rep(i, n) a[i] = lin();
        set<int> s;
        s.insert(0);
        s.insert(n + 1);
        vi pos(n);
        rep(i, n) pos[a[i] - 1] = i + 1;
        int ans = 0;
        rep(i, n) {
                auto lb = s.lower_bound(pos[i]);
                int left = pos[i] - *(-- lb);
                int right = *(++ lb) - pos[i];
                ans += left * right * (i + 1);
                s.insert(pos[i]);
        }
        cout << ans << endl;
        return 0;
}               


Measured memory_bytes: 12800
import collections

N = int(input())
a = list(map(int,input().split()))
a = collections.Counter(a)
ans = 0
for i in a:
    if a[i] > i:
        ans += a[i]-i
    elif a[i] == i:
        pass
    else:
        ans += a[i]
print(ans)


Measured memory_bytes: 18672
#include <iostream>

int main(void) {
    int N;
    std::string unit;
    
    std::cin >> N;
    
    switch (N%10) {
        case 3:
            unit = "bon";
            break;
        case 0:
        case 1:
        case 6:
        case 8:
            unit = "pon";
            break;
        default:
            // 2,3,5,7,9
            unit = "hon";
            break;
    }
    
    std::cout << unit << std::endl;
    
    return 0;
}


Measured memory_bytes: 3628
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<vector>
#include<queue>
#include<map>
#include<set>
using namespace std;
#define lowbit(x) (x)&(-x)
#define rep(i,a,b) for (int i=a;i<=b;i++)
#define per(i,a,b) for (int i=a;i>=b;i--)
#define maxd (ll)10000000000007
typedef long long ll;
const int N=100000;
const double pi=acos(-1.0);
int n,a,b,num[5050];
ll dp[5050][5050];

int read()
{
	int x=0,f=1;char ch=getchar();
	while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
	while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
	return x*f;
}

int main()
{
	n=read();a=read();b=read();
	rep(i,1,n) num[i]=read();
	rep(i,0,n)
		rep(j,0,n) dp[i][j]=maxd;
	dp[0][0]=0;
	rep(i,1,n)
	{
		rep(j,0,n)
		{
			if (dp[i-1][j]==maxd) continue;
			if (num[i]>j)
			{
				dp[i][j]=min(dp[i][j],dp[i-1][j]+a);
				dp[i][num[i]]=min(dp[i][num[i]],dp[i-1][j]);
			}
			else 
			{
				dp[i][j]=min(dp[i][j],dp[i-1][j]+b);
			}
		}
	}
	ll ans=maxd;
	rep(i,1,n) ans=min(ans,dp[n][i]);
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 198912
#include <iostream>

int main()
{
    std::cout.sync_with_stdio(false);

    char S[3], T[3];
    std::cin >> S[0] >> S[1] >> S[2] >> T[0] >> T[1] >> T[2];
    int count = 0;
    for (char i = 0; i < 3; i++)
    {
        if (S[i] == T[i]) count++;
    }
    std::cout << count;

    return 0;
}


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

int main(){

    int n;
    int t, x, y;
    int tt=0, xx=0, yy=0;
    scanf("%d", &n);

    int len = 0;
    bool ans = true;
    for (int i = 0; i < n; i++){
        scanf("%d %d %d", &t, &x, &y);
        t = t - tt; x = x - xx; y = y - yy;
        tt = t; xx = x; yy = y;
        len = std::abs(x) + std::abs(y);
        if( t < len) ans = false;
        if( len%2 != t%2) ans = false;
    }

    if(ans)
        printf("Yes\n");
    else
        printf ("No\n");

    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
int main()
{
	ld n;
	cin>>n;
	ld x=100.0;
	ll count=0;
	while(x<n){
		x=(x+(0.01*x));
		ll p=x;
		x=p;
		count++;
	}
	cout<<count<<endl;
}

Measured memory_bytes: 3724
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cmath>
using namespace std;

const int maxn = 1e4+7;
typedef long long LL;
struct Eg{
    int u,v;
    LL c;
}E[maxn*100];

int par[maxn];
int rk[maxn];
void init(int n){
    int len=min(n,maxn);
    for(int i=0;i<len;i++){
        par[i]=i;
        rk[i]=0;
    }
}
int fd(int x){
    if(x==par[x]) return x;
    return par[x]=fd(par[x]);
}

void mg(int x,int y){
    x=fd(x);
    y=fd(y);
    if(x==y) return ;
    if(rk[x]<rk[y]){
        par[x]=y;
    }else {
        par[y]=x;
        if(rk[x]==rk[y]) rk[x]++;
    }
}
bool same(int x,int y){
    return fd(x)==fd(y);
}
bool cmp(Eg e1,Eg e2){
    return e1.c>e2.c;
}
int X[maxn];
int Y[maxn];

int N,M;
bool vis[maxn*100];
int main(){

    scanf("%d%d",&N,&M);
    for(int i=1;i<=N;i++){
        scanf("%d%d",X+i,Y+i);
    }

    int u,v;
    for(int i=1;i<=M;i++){
        scanf("%d%d",&u,&v);
        LL dis=((LL)X[u]-X[v])*(X[u]-X[v])+((LL)Y[u]-Y[v])*(Y[u]-Y[v]);
        E[i].u=u;
        E[i].v=v;
        E[i].c=dis;
    }
    init(N+3);
    sort(E+1,E+M+1,cmp);
    int res=0;
    for(int i=1;i<=M;i++){
        Eg e=E[i];
        if(!same(e.u,e.v)){
            mg(e.u,e.v);
            vis[i]=1;
        }
    }
    double ans=0;
    for(int i=1;i<=M;i++){
        if(!vis[i]){
            ans+=(sqrt(1.0*E[i].c));
        }
    }
    printf("%.4f\n",ans);
return 0;
}




Measured memory_bytes: 3880
import math

A, B, N = map(int, input().split())

# f(x)=f(x+B)となる(周期性)
# ex. A=5,B=7の時　0,0,1,2,2,3,4,0,0,...
# f(x)は（広義）単調増加
# f(B-1)を取りたいところだが、xはN以下の制限より、答えはf(min(B-1,N))

# 引数を確定させる
temp = min(B - 1, N)

ans = math.floor(A * temp / B) - A * math.floor(temp / B)
print(ans)


Measured memory_bytes: 8944
#include <algorithm>
#include <iostream>
#include <cstring>
#include <climits>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>

#define Re register
#define LL long long
#define U unsigned
#define FOR(i,a,b) for(Re int i = a;i <= b;++i)
#define ROF(i,a,b) for(Re int i = a;i >= b;--i)
#define SFOR(i,a,b,c) for(Re int i = a;i <= b;i+=c)
#define SROF(i,a,b,c) for(Re int i = a;i >= b;i-=c)
#define CLR(i,a) memset(i,a,sizeof(i))
#define BR printf("--------------------\n")
#define DEBUG(x) std::cerr << #x << '=' << x << std::endl

const int MAXN = 100+5;
int N,a[MAXN],cnt[MAXN];

int main(){
    scanf("%d",&N);
    FOR(i,1,N) scanf("%d",a+i),cnt[a[i]]++;
    std::sort(a+1,a+N+1);
    if(a[N-1] != a[N]) {puts("Impossible");return 0;}
    cnt[a[N]] -= 2;
    FOR(i,1,a[N]-1){
        int d = std::max(i,a[N]-i);
        if(!cnt[d]){
            puts("Impossible");return 0;
        }
        cnt[d]--;
    }
    FOR(i,1,(a[N]+1)/2){
        if(cnt[i]){
            puts("Impossible");return 0;
        }
    }
    puts("Possible");
    return 0;
}

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

int main()
{
	long long sum[31] = {0};
	
	sum[0] = 1;
	
	for(int i = 1; i < 31; ++i) {
		
		sum[i] = 0;
		if(i - 1 >= 0)
			sum[i] += sum[i - 1];
		if(i - 2 >= 0)
			sum[i] += sum[i - 2];
		if(i - 3 >= 0)
			sum[i] += sum[i - 3];
	}
	
	while(true) {
		
		int n;
		
		scanf("%d", &n);
		if(n == 0)
			break;
		
		printf("%lld\n", (sum[n] - 1LL) / 3650LL + 1LL);
	}
	
	return 0;
}

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

#ifdef MYDEBUG
#define dbp(x) cout<<#x<<": "<<x<<endl
#define dbp2(x,y) cout<<#x<<","<<#y<<": "<<x<<","<<y<<endl
#define dbp3(x,y,z) cout<<#x<<","<<#y<<","<<#z<<": "<<x<<","<<y<<","<<z<<endl
#define dbp4(w,x,y,z) cout<<#w<<","<<#x<<","<<#y<<","<<#z<<": "<<w<<","<<x<<","<<y<<","<<z<<endl
#else
#define dbp(x)
#define dbp2(x,y)
#define dbp3(x,y,z)
#define dbp4(w,x,y,z)
#endif
#define ll long long
#define ull unsigned long long
#define eps 1e-14
#define all(x) x.begin(), x.end()
#define rep(i, from, to) for(int i=from; i<to; ++i)

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
	out << "[";
	size_t last = v.size() - 1;
	for (size_t i = 0; i < v.size(); ++i) {
		out << v[i];
		if (i != last)
			out << ",";
	}
	out << "]";
	return out;
}

struct edge {
	int from, to, cost;
	edge(int from, int to, int cost) {
		this->from = from;
		this->to = to;
		this->cost = cost;
	}
	edge() {
		from = -1;
		to = -1;
		cost = -1;
	}
	bool operator<(const edge& e) const {
		return this->cost < e.cost;
	}
	bool operator>(const edge& e) const {
		return e < *this;
	}
	bool operator>=(const edge& e) const {
		return !(*this < e);
	}
	bool operator<=(const edge& e) const {
		return !(*this > e);
	}
};

typedef struct edge edge;
typedef pair<int, int> P;
const int MAXV = 110;
const int MAXE = 10000;
const int INF = 2140000000;
edge eg[MAXE];
int V, E;
int d[MAXV][MAXV];
const string NEGATIVE = "NEGATIVE CYCLE";

void warshall_floyd() {
	rep(i,0,V)
	{
		fill(d[i], d[i] + MAXV, INF);
		d[i][i] = 0;
	}
	rep(i,0,E)
	{
		edge e = eg[i];
		d[e.from][e.to] = e.cost;
	}
	rep(k,0,V)
	{
		rep(i,0,V)
		{
			rep(j,0,V)
			{
				if (d[i][k] != INF && d[k][j] != INF) {
					d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
				}
			}
			if (d[i][i] < 0) {
				cout << NEGATIVE << endl;
				return;
			}
		}
	}
	rep(i,0,V)
	{
		rep(j,0,V)
		{
			if (j != V - 1) {
				if (d[i][j] == INF) {
					cout << "INF" << " ";
				} else {
					cout << d[i][j] << " ";
				}
			} else {
				if (d[i][j] == INF) {
					cout << "INF";
				} else {
					cout << d[i][j];
				}
			}
		}
		cout << endl;
	}
}

void solve() {
	cin >> V >> E;
	rep(i,0,E)
	{
		int s, t, d;
		cin >> s >> t >> d;
		eg[i] = edge(s, t, d);
	}
	warshall_floyd();
}

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

Measured memory_bytes: 3348
bingo=[]
for i in range(3):
    array=map(int,input().split())
    bingo.append(list(array))

N=int(input())
b=[]
for i in range(N):
    b.append(int(input()))

for i in range(3):
    for j in range(3):
        for k in b:
            if bingo[i][j]==k:
                bingo[i][j]=-1

flg=False
for i in range(3):
    if bingo[i][0]==-1 and bingo[i][1]==-1 and bingo[i][2]==-1:
        flg=True
        break
    if bingo[0][i]==-1 and bingo[1][i]==-1 and bingo[2][i]==-1:
        flg=True
        break

if bingo[0][0]==-1 and bingo[1][1]==-1 and bingo[2][2]==-1:
    flg=True
elif bingo[0][2]==-1 and bingo[1][1]==-1 and bingo[2][0]==-1:
    flg=True

if flg:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 62096
#include <iostream>
#include <math.h>
//#include <numeric>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;
#define n_max 100000

#define rep(i, a, n) for(int i = a; i < n; i++)
#define rep2(i, a, n) for(int i = a; i <= n; i++)
#define rrep(i, a, n) for(int i = a; i > n; i--)
#define rrep2(i, a, n) for(int i = a; i >= n; i--)
#define lrep(i, a, n) for(long int i = a; i < n; i++)
#define in(a) cin >> a
#define out(a) cout << a << endl

int main()
{
    int N;

    cin >> N;
    //int a[N];
    double ans = 0;

    rep(i, 0, N) {
        //cin >> a[i]; 
        int tmp;
        cin >> tmp;
        ans += (1.0/tmp);
    }
    
    ///cout << (1.0 / ans) << endl;
    printf("%.13f\n", 1.0 / ans);

    return 0;
}


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

int main()
{
    int n,sum=0;
    cin>>n;
    int a[n],b[n],c[n-1];

    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    for(int i=1;i<=n;i++)
    {
        cin>>b[i];
    }
    for(int i=1;i<=n-1;i++)
    {
        cin>>c[i];
    }
    for(int i=1;i<=n;i++)
    {
        sum = sum+b[a[i]];
        if(a[i-1]==a[i]-1)
           sum+=c[a[i-1]];

       // cout<<sum<<endl;
    }

    cout<<sum<<endl;
    
    return 0;

}


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

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

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define EPS (1e-8)
#define INF (1e9)
#define X real()
#define Y imag()
#define N 105
#define M 15
using namespace std;
typedef pair<string,string> P1;
typedef complex<double> P;
int n,a,b,Slen,mark[M],ans;
vector<P> v[N];
set<string> S;
string s[N];
string d[M];
set<P1> z;

double dot(P A,P B){return real(conj(A)*B);}
double cross(P A,P B){return imag(conj(A)*B);}

int ccw(P A, P B, P C){
  B-=A;
  C-=A;
  if(cross(B,C)>EPS)return 1;
  if(cross(B,C)<-EPS)return -1;
  if(dot(B,C)<-EPS)return 2;
  if(norm(B)<norm(C))return -2;
  return 0;
}

bool check(P A1,P A2,P B1,P B2){
  int r1=ccw(A1,A2,B1);
  int r2=ccw(A1,A2,B2);
  int r3=ccw(B1,B2,A1);
  int r4=ccw(B1,B2,A2);
  if(r1==1||r1==-1||r2==1||r2==-1)return false;
  A2-=A1,B1-=A1,B2-=A1,A1-=A1;
  B1=B1*conj(A2)/abs(A2);
  B2=B2*conj(A2)/abs(A2);
  A2=A2*conj(A2)/abs(A2);
  if(A1.X>A2.X)swap(A1,A2);
  if(B1.X>B2.X)swap(B1,B2);
  double left=max(A1.X,B1.X);
  double right=min(A2.X,B2.X);
  if(right-left<=EPS)return false;
  if(!r1||!r2||!r3||!r4)return true;
  return false;
}

void func(int x){
  for(int i=0;i<x;i++){
    for(int j=i+1;j<x;j++){
      if(mark[i]!=mark[j])continue;
      string s1=min(d[i],d[j]);
      string s2=max(d[i],d[j]);
      if(z.find(P1(s1,s2))!=z.end())return;
    }
  }
  if(x==Slen){
    set<int> cnt;
    for(int i=0;i<Slen;i++)cnt.insert(mark[i]);
    ans=min(ans,(int)cnt.size());
    return;
  }
  for(int i=0;i<=x;i++)mark[x]=i,func(x+1);
}

int main(){
  while(1){
    cin>>n;
    if(!n)break;
    for(int i=0;i<n;i++){
      cin>>s[i];
      S.insert(s[i]);
      while(1){
	cin>>a;
	if(a<0)break;
	cin>>b;
	v[i].push_back(P(a,b));
      }
    }
    Slen=S.size();
    set<string>::iterator ite;
    int k=0;
    for(ite=S.begin();ite!=S.end();ite++,k++)d[k]=(*ite);
    for(int i=0;i<n;i++){
      for(int j=i+1;j<n;j++){
	int leni=v[i].size();
	int lenj=v[j].size();
	string s1=s[i],s2=s[j];
	if(s1==s2)continue;
	if(s1>s2)swap(s1,s2);
	for(int k=0;k<leni;k++)
	  for(int l=0;l<lenj;l++){
	    P A1=v[i][k],A2=v[i][(k+1)%leni];
	    P B1=v[j][l],B2=v[j][(l+1)%lenj];
	    if(check(A1,A2,B1,B2))z.insert(P1(s1,s2));
	  }
      }
    }
    ans=INF;
    func(0);
    cout<<ans<<endl;
    for(int i=0;i<n;i++)v[i].clear();
    S.clear();
    z.clear();
  }
  return 0;
}

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

#define ms(a,b) memset(a, b, sizeof(a))
#define rep(a,b,c) for(int a = (int)(b); a < (int)(c); a++)
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define m_p(a,b) make_pair(a, b)
#define lson l,mid,o << 1
#define rson mid + 1,r,o << 1 | 1
#define ls o << 1
#define rs o << 1 | 1
#define inf 0x3f3f3f3f

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair<int,int> pii;

inline bool isdigit(char& ch) {
	return ch >= '0' && ch <= '9';
}
template<class T>
void read(T &x) {
	x = 0;
	ll f = 1;char ch = getchar();
	for (;!isdigit(ch);ch = getchar()) 
		if (ch == '-') f = -1;
	for (; isdigit(ch);ch = getchar())
		x = (x << 1) + (x << 3) + ch - '0';
	x *= f;
}
template<class T>
inline void write(T x) {
	if (x == 0) {putchar('0');return ;}
	if (x < 0) {putchar('-');x = -x;}
	int _stk[65],_top = 0;
	for (;x;x /= 10) _stk[++_top] = x % 10 + 48;
	for (;_top;_top--)putchar(_stk[_top]);
}

int main () {
	ll A, B, w, v, T;
	cin >> A >> v >> B >> w >> T;
	if (v <= w && A != B) {
		cout << "NO";
		return 0;
	}
	if (A <= B) {
		A += v * T;
		B += w * T;
		if (A >= B)
			cout << "YES";
		else
			cout << "NO";
	}
	else {
		A -= v * T;
		B -= w * T;
		if (A <= B)
			cout << "YES";
		else
			cout << "NO";	
	}
	
	return 0;
}

Measured memory_bytes: 3632
/*Author SHUBH AGRAWAL  */

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pu push  //  adds the value to the last of the queue 
#define lld long long int
#define ins insert /// used in set to insert the values 
#define adv advance  /// used to increment the iterator
#define mp make_pair
#define fi first
#define se second
#define all(c) c.begin(),c.end()
#define PI 3.1415926
//a power n mod p

#define vl  vector<long long int >
#define vpl vector< pair<lld ,lld> >
#define vvl vector<vector<lld> > 

long long int modp(lld a,lld p,lld n)
{
    int d[100];
    int i,j,k,l;
    if(n==0) return 1;
    for(i=0;n>=1;i++)
    {
        d[i]=n%2;
        n/=2;
    }
    l=i;
    long long int e=1;
    if(d[0]==1) e*=(a%p);
    for(i=1;i<l;i++)
    {
        a*=a;
        a=a%p;
        if(d[i]==1) 
        {
            e*=a;
            e=e%p;
        }
    }
    return e%p;
}
lld modInverse(lld n, lld p) 
{ 
    return modp(n, p, p-2); 
}

long long int nCrModPFermat(lld n, lld r,lld p) 
{ 
   // Base case 
   if (r==0) 
      return 1; 
    
    // Fill factorial array so that we 
    // can find all factorial of r, n 
    // and n-r 
    lld fac[n+1]; 
    fac[0] = 1; 
    for (lld i=1 ; i<=n; i++) 
        fac[i] = fac[i-1]*i%p; 
  
    return (fac[n]* modInverse(fac[r], p) % p * 
            modInverse(fac[n-r], p) % p) % p; 
}


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


lld l,r,mid,ans;
lld n,m,i,j,k;
lld x,w,y,z;
lld n1,n2,m1,m2;
string s;
char c;
vector<char> vf,vb;
void solve()
{
    cin>>s;
    cin>>n;
    m=0;
    while(n--)
    {
        cin>>l;
        if(l==1) 
        {
            m=(m+1)%2;
        }
        else
        {
            cin>>k>>c;
            if((k+m)%2==1)
            {
                vf.pb(c);
            }
            else
            {
                vb.pb(c);
            }
        }
    }
    x=vf.size();
    y=s.size();
    z=vb.size();
    if(m==0)
    {
        for(i=x-1;i>=0;i--) cout<<vf[i];
        cout<<s;
        for(i=0;i<z;i++) cout<<vb[i];
    }
    else
    {
        for(i=z-1;i>=0;i--) cout<<vb[i];
        for(i=y-1;i>=0;i--) cout<<s[i];
        for(i=0;i<x;i++) cout<<vf[i];
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lld t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 976
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;
using ll = long long;

int main()
{
  int N; cin >> N;
  vector<ll> A(N); REP(i, N) cin >> A[i];

  ll ans = 0, s = 0;
  for (int i = 0, l = 0; i < N; ++i) {
    s += A[i];

    if (i == N-1 || A[i] == 0) {
      ans += s/2;
      l = i;
      s = 0;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<set>
#include<algorithm>
//#include<numeric>
using namespace std;

int main(){
  int N;
  cin >> N;
  multiset<int>max;
  for(int i=1; i<=N; i++) {
    int M;
    cin >> M;
    for(int j=1; j<=M; j++) {
      int c;
      cin >> c;
      max.insert(c);
      if(max.size() > i) max.erase(max.begin());
    }
  }
  //cout << accumulate(max.cbegin(), max.cend(), 0) << endl;
  unsigned long long ans = 0;
  for(auto it=max.begin(); it!=max.end(); it++) ans += *it;
  cout << ans << endl;
}




Measured memory_bytes: 17148
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define y0 yy
#define y1 Yy
#define yn YY
#include <assert.h>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;

int n,k,l,cnt,v1[200005],v2[200005];
vector<int> g[200005],h[200005];
map<pair<int,int>,int> res;

void dfs1(int x){
    v1[x]=cnt;
    for(size_t i=0;i<g[x].size();i++)if(v1[g[x][i]]==-1)dfs1(g[x][i]);
}

void dfs2(int x){
    v2[x]=cnt;
    res[make_pair(v1[x],v2[x])]++;
    for(size_t i=0;i<h[x].size();i++)if(v2[h[x][i]]==-1)dfs2(h[x][i]);
}

int main(){
    scanf("%d %d %d",&n,&k,&l);
    for(int i=0;i<k;i++){
        int u,v;
        scanf("%d %d",&u,&v);
        u--;v--;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    for(int i=0;i<l;i++){
        int u,v;
        scanf("%d %d",&u,&v);
        u--;v--;
        h[u].push_back(v);
        h[v].push_back(u);
    }
    memset(v1,-1,sizeof v1);
    for(int i=0;i<n;i++)if(v1[i]==-1)dfs1(i),cnt++;
    memset(v2,-1,sizeof v2);
    for(int i=0;i<n;i++)if(v2[i]==-1)dfs2(i),cnt++;
    for(int i=0;i<n;i++)printf("%d ",res[make_pair(v1[i],v2[i])]);
    return 0;
}


Measured memory_bytes: 27904
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
// 繰り返し二乗法 O(log n)
ll f[200010000] = {0}; // f(n) = (n!) % mod
//階乗テーブルの初期化を忘れない
//f[0] = f[1] = 1;
//for(int i=2; i<=w+h-2; ++i) f[i] = (i * f[i-1]) % mod;
ll mod_pow(ll x, ll n){
    ll res = 1LL;
    while(n > 0){
        if(n & 1) res = res * x % mod;
        x = x*x % mod;
        n >>= 1;
    }
    return res;
}
ll mod_inv(ll x){
    return mod_pow(x, mod-2) % mod;
}
// nCr % mod
ll comb(int n, int r){
    return (((f[n] * mod_inv(f[r])) % mod) * mod_inv(f[n-r])) % mod;
}
int main(){
    ll x,y;
    cin>>x>>y;
    if((x+y)%3!=0) cout<<0<<endl;
    else{
        int n,m;
        n = (2*y-x)/3;
        m = (2*x-y)/3;
        //cout<<n<<" "<<m<<endl;
        if(n<0 || m<0){
            cout<<0<<endl;
            return 0;
        }
        f[0]=f[1]=1;
        for(int i=2;i<=n+m;++i) f[i]=(i*f[i-1])%mod;
        //cout<<"a"<<endl;
        cout<<comb(n+m,n)<<endl;
    }
    return 0;
}

Measured memory_bytes: 6400
#include <iostream>
#include <math.h>
using namespace std;
int main(void){
    int N;
    int M;
    cin >> N >> M;
    long ai[N], bi[N], ci[N];
    int eat_flag[N];
    
    long out_mode;
    long out = 0;
    
    int sign[3] = {1,1,1};
    for (int i = 0; i < N; ++i){
        cin >> ai[i]>> bi[i]>> ci[i];
    }
    for (int k = 0; k < 8; ++k){
        if(k%2 == 0){sign[0] = 1;}else{sign[0] = -1;}
        if((k/2)%2 == 0){sign[1] = 1;}else{sign[1] = -1;}
        if((k/4)%2 == 0){sign[2] = 1;}else{sign[2] = -1;}

        long tmp_max = 0;
        int flag_tmp = 0;
        long eati[3] = {0,0,0};
        for (int i = 0; i < N; ++i){
            eat_flag[i] = 0;
        }
        for (int i = 0; i < N; ++i){
            if(tmp_max  <= abs(eati[0]+ai[i]) + abs(eati[1]+bi[i]) + abs(eati[2]+ci[i]) && eat_flag[i] == 0 && 0 <= sign[0]*ai[i] && 0 <= sign[1]*bi[i] && 0 <= sign[2]*ci[i]){
                tmp_max = abs(eati[0]+ai[i]) + abs(eati[1]+bi[i]) + abs(eati[2]+ci[i]);
                flag_tmp = i;
            }
        }
        eati[0] = ai[flag_tmp];
        eati[1] = bi[flag_tmp];
        eati[2] = ci[flag_tmp];
        eat_flag[flag_tmp] = 1;
        for(int j = 0; j < M-1; ++j){
            long tmp_max = 0;
            int flag_tmp = 0;
            for (int i = 0; i < N; ++i){
                if(tmp_max  <= abs(eati[0]+ai[i]) + abs(eati[1]+bi[i]) + abs(eati[2]+ci[i]) && eat_flag[i] == 0){
                    tmp_max = abs(eati[0]+ai[i]) + abs(eati[1]+bi[i]) + abs(eati[2]+ci[i]);
                    flag_tmp = i;
                }
            }
            eati[0] += ai[flag_tmp];
            eati[1] += bi[flag_tmp];
            eati[2] += ci[flag_tmp];
            eat_flag[flag_tmp] = 1;
        }
        out_mode = abs(eati[0])+abs(eati[1])+abs(eati[2]);
        out = max(out, out_mode);
    }
    if (M==0){out = 0;}
    cout << out << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.Deque;
   
public class Main {
     
    public static void main(String[] args) throws IOException {
        new Main().exec();
    }
     
    public void exec() throws IOException {
        SimpleInputUtil in = new SimpleInputUtil();
        PrintWriter out = new PrintWriter(System.out);
        out.print(new SectionDiagram().analyze(in.br.readLine()));
        out.flush();
    }
}

class SectionDiagram {
	public static final String EOF = System.lineSeparator();

	Deque<Integer> downhillDeque = new ArrayDeque<>();
	Deque<WaterHazardElement> waterHazardDeque = new ArrayDeque<>();
	int A = 0;
	int[] L = null;
	
	public SectionDiagram analyze(String s) {
		int len = s.length();
		for(int i=0; i<len; i++) {
			switch(s.charAt(i)) {
			case '\\':
				downhillDeque.push(i);
				break;
			case '/':
				if(!downhillDeque.isEmpty()) {
					int start = downhillDeque.pop();
					WaterHazardElement wh = new WaterHazardElement(start,i);
					while(true) {
						if(!waterHazardDeque.isEmpty()){
							WaterHazardElement whPre = waterHazardDeque.getFirst();
							if(wh.include(whPre)) {
								wh.merge(whPre);
								waterHazardDeque.removeFirst();
							} else {
								waterHazardDeque.addFirst(wh);
								break;
							}
						}else{
							waterHazardDeque.addFirst(wh);
							break;
						}
					}
				}
				break;
			}
		}
		
		L = new int[waterHazardDeque.size()];
		for(int i=0; !waterHazardDeque.isEmpty(); i++){
			A += L[i] = waterHazardDeque.removeLast().getCapacity();
		}

		return this;
	}
	
	public String toString() {
		StringBuilder sb = new StringBuilder();
		sb.append(A).append(EOF);
		if(L != null && L.length>0){
			sb.append(L.length).append(" ");
			for(int i=0; i<L.length; i++) {
				if(i>0) sb.append(" ");
				sb.append(L[i]);
			}
			sb.append(EOF);
		} else {
			sb.append(0).append(EOF);
		}
		return sb.toString();
	}
	
}

class WaterHazardElement {
	int st = -1;
	int ed = -1;
	int childCapacity = 0;
	
	public WaterHazardElement(int st, int ed) {
		this.st = st;
		this.ed = ed;
	}
	
	public void merge(WaterHazardElement s) {
		childCapacity += s.getCapacity();
	}
	
	public int getCapacity() {
		return childCapacity + ed - st;
	}
	
	public boolean include(WaterHazardElement s) {
		return this.st < s.st && s.ed < this.ed;
	}
	
}
 
class SimpleInputUtil {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
 
    public String[] readStrArray(String delim) throws NumberFormatException, IOException{
        return br.readLine().split(delim);
    }
     
    public int readInt() throws NumberFormatException, IOException{
        return Integer.parseInt(br.readLine());
    }
     
    public int[] readIntArray(int[] a) throws NumberFormatException, IOException{
        int i=0;
        while(i<a.length) {
            for(String s: br.readLine().split(" ")){
                if(i<a.length) {
                    a[i++] = Integer.parseInt(s);
                }
            }
        }
        return a;
    }
 
     
}

Measured memory_bytes: 25644
from sys import stdin
import sys
import math
from functools import reduce
import itertools

n = int(stdin.readline().rstrip())
p = [int(x) for x in stdin.readline().rstrip().split()]

m = n
count = 0
for i in range(n):
    m = min([m, p[i]])
    if m == p[i]: count = count + 1

print(count)

Measured memory_bytes: 31916
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<map>
#include<string>
#include<stdlib.h>
#define ran(x) (x).begin(),(x).end()
using namespace std;
int main() {
	int n, x, t;
	cin >> n >> x >> t;
	cout << (n + x - 1) / x * t << endl;
}

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

int main(){
	string S;
	cin >> S;
	int start = 0;
	int compare = start + 1;
	int count = 0;
	priority_queue<int> bs;
	while(compare < S.size()){
		if(S[start] != S[compare]){
			count += 2;
			while(true){
				if(bs.size() == 0){
					start = compare + 1;
					compare = start + 1;
					break;
				}
				if(start > bs.top()){
					start = bs.top();
					compare++;
					break;
				}
				if(bs.top() == 0){
					start = compare + 1;
					compare = start + 1;
					break;
				}
				bs.pop();
			}
		}
		else{
			bs.push(start);
			start = compare;
			compare = start + 1;
		}
	}

	cout << count << endl;
	return 0;
}

Measured memory_bytes: 1020
n, m = map(int, input().split())
s = input()
t = input()

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

c = gcd(n, m)
flag = True
for i in range(c):
    if s[n * i // c] != t[m * i // c]:
        flag = False
        break
if flag == True:
    print(n * m // c)
else:
    print(-1)

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

int main() {
  set<int> s;
  int a, b, c;
  cin >> a >> b >> c;

  s.insert(a);
  s.insert(b);
  s.insert(c);

  if(s.size() == 2) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3588
#include <stdio.h>

int main() {

  int n,m,i,j;
  int a,b;
  int A[100][100] = {0};
  int B[100] = {0};
  int c[100] = {0};

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

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

  for(j=0; j<m; j++) {
    scanf("%d",&b);
    B[j] = b;
  }

  for(j=0;j<n ; j++){ 
  for(i = 0; i<m; i++){
     c[j] = c[j] + A[j][i]*B[i];
    }
  }

  for(i=0;i<n;i++) {
    printf("%d\n",c[i]);
  }
  return 0;
}


Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
constexpr int gcd(int a,int b){return b?gcd(b,a%b):a;}
constexpr int lcm(int a,int b){return a*b/gcd(a,b);}
 
class Eratosthenes{
  public:
    int n, sqlim;
    vector<bool> prime;
    Eratosthenes(int N):n(N+1){
        sqlim=(int)ceil(sqrt(n));
        prime=vector<bool>(n,1); prime[0]=prime[1]=0;
        for(int i=2;i<=sqlim;i++) if(prime[i]) for(int j=i*i;j<=n;j+=i) prime[j]=0;}
    vector<int> primeArray(int s=0, int l=10000){vi ret; for(int i=s;ret.size()!=l;i++) if(prime[i]) ret.push_back(i); return ret;}
};
using vvd=vector<vector<double>>;
using vd=vector<double>;

vvd c;
double a=-1;
void combi(int n, int s, vi t){
    if(s==0){
        double ans=0;
        for(auto i:t)for(auto j:t)ans+=c[i][j];
        a=max(a,ans);
        return;
    }
    if(n==0)return;
    combi(n-1,s,t);
    t.pb(n-1);
    combi(n-1,s-1,t);
}
using t3i=tuple<int,int,int>;

int main(){
	int n;
	map<t3i,vi> rnd;
	rep(s,16)rep(a,16)rep(c,16){
	    vi tmp(256,s);
	    range(i,1,256){
	        tmp[i]=(a*tmp[i-1]+c)%256;
	    }
	    rnd[make_tuple(s,a,c)]=tmp;
	}
	while(cin>>n,n){
	    vi l(n);
	    rep(i,n) cin>>l[i];
	    double ans=1e9;
	    t3i at;
	    for(auto rn:rnd){
	        auto r=rn.sc;
	        vi p(256,0);
	        rep(i,n){
	            p[(l[i]+r[i+1])%256]++;
	        }
	        double ent=0;
	        for(auto i:p){
	            if(i==0)continue;
	            double P=(double)i/n;
	            ent-=P*log(P);
	        }

	        if(ans>ent+1e-9){
	            ans=ent;
	            at=rn.fs;
	        }
	    }
        cout<<get<0>(at)<<" "<<get<1>(at)<<" "<<get<2>(at)<<endl;
	}
	return 0;
}

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

typedef long double Double;

Double solve(int n,int m,int d){
    Double r;
    if (d == 0) {
        r = (Double)1.0 / n;
    } else {
        r = (Double)2.0 * (n - d) / n / n;
    }
    return r * (m - 1);
}

int main() {
    int n,m,d; cin >>n>>m>>d;
    Double ans = solve(n,m,d);
    printf("%.10f\n", (double)ans);
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(void){
    int a,b,c;
    cin>>a>>b>>c;
    if(a+b+c==17&&a*b*c==175){
        cout<<"YES"<<endl;        
    }
    else{
        cout<<"NO"<<endl;
    }
}

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

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define dump_1(x1) cerr << #x1 << ": " << x1 << endl
#define dump_2(x1, x2) \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define dump_3(x1, x2, x3)                                                \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << endl
#define dump_4(x1, x2, x3, x4)                                            \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << ", " #x4 << ": " << x4 << endl
#define dump_5(x1, x2, x3, x4, x5)                                        \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#define dump(...) \
  CHOOSE((__VA_ARGS__, dump_5, dump_4, dump_3, dump_2, dump_1, ~))(__VA_ARGS__)
#define check(s) cerr << s << endl

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

using namespace std;

using ll = long long;

vector<int> dx = {0, 1, 0, -1};
vector<int> dy = {1, 0, -1, 0};

const ll LINF = 2e18;
const int INF = 1e9;

void solve(ll N, std::string S) {
  rep(i, sz(S)) {
    if (S.at(i) + N > 'Z') {
      cout << (char)(S.at(i) + N - ('Z' - 'A' + 1));
    } else {
      cout << (char)(S.at(i) + N);
    }
  }
  cout << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  ll N;
  cin >> N;
  std::string S;
  std::cin >> S;
  solve(N, S);
  return 0;
}


Measured memory_bytes: 3684
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>

using namespace std;
typedef long long ll;

int main() {
  ll N;
  cin >> N;
  cout << N * (N - 1) / 2 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
  int n, sum=0, ans, i, j;
  cin >> n;
  int a[2][n];
  for(i=0; i<2; i++)
    for(j=0; j<n; j++)
      cin >> a[i][j];
  sum+=a[0][0];
  for(j=0; j<n; j++)
    sum+=a[1][j];
  ans=sum;
  for(j=0; j<n-1; j++){
    sum+=(a[0][j+1]-a[1][j]);
    if(sum>ans) ans=sum;
  }
  cout << ans;
  return 0;
}

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

int main(){
    vector<bool> b(64,false);
    int n; cin >> n;
    vector<vector<int>> m(n,vector<int>(65));
    rep(i , n) {
        cin >> m[i].at(0);
        for(int j = 1 ; j <= m[i].at(0) ; ++j) {
            cin >> m[i].at(j);
        }
    }
    int q; cin >> q;
    rep(i , q){
        int l;
        int query; cin >> query;
        int counter;
        uint64 val , base;
        bool flag = false;
        switch (query)
        {
        case 0: //test(i)
            cin >> l;
            if(b[l] == true) cout << 1;
            else cout << 0;
            cout << endl;
            break;
        case 1: //set(i)
            cin >> l;
            for(int j = 1 ; j <= m[l].at(0) ; ++j){
                b[m[l].at(j)] = true;
            }
            break;
        case 2: //clear(i)
            cin >> l;
            for(int j = 1; j <= m[l].at(0) ; ++j){
                b[m[l].at(j)] = false;
            }
            break;
        case 3: //flip(i)
            cin >> l;
            for(int j = 1; j <= m[l].at(0) ; ++j){
                if(b[m[l].at(j)] == true ) b[m[l].at(j)] = false;
                else b[m[l].at(j)] = true;
            }
            break;
        case 4: //all
            cin >> l;
            for(int j = 1; j <= m[l].at(0) ; ++j){
                if(!b[m[l].at(j)]) { cout << 0 << endl; flag = true; break;}
            }
            if (!flag) cout << 1 << endl;
            break;
        case 5: //any
            cin >> l;
            for(int j = 1; j <= m[l].at(0) ; ++j){
                if(b[m[l].at(j)]) { cout << 1 << endl; flag = true; break;}
            }
            if(!flag) cout << 0 << endl;
            break;
        case 6: //none
            cin >> l;
            for(int j = 1; j <= m[l].at(0) ; ++j){
                if(b[m[l].at(j)]) { cout << 0 << endl; flag = true; break;}
            }
            if(!flag) cout << 1 << endl;
            break;
        case 7: //count
            counter = 0;
            cin >> l;
            for(int j = 1; j <= m[l].at(0) ; ++j){
                if(b[m[l].at(j)]) ++counter;
            }
            cout << counter << endl;
            break;
        case 8: //val
            val = 0;
            cin >> l;
            for(int j = 1 ; j <= m[l].at(0) ; ++j){
                base = pow(2 , m[l].at(j));
                if( b[m[l].at(j)]) val += base;
            }
            cout << val << endl;
            break;
        case 9: //list;
            rep(j , 64){
                cout << b[j];
            }
            cout << endl;
            break;
        default:
            break;
        }
    }
}


Measured memory_bytes: 3348
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cctype>
#include<string>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <utility> 

#define rep(i,m,n) for(int i = m;i < n;i++)
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;

//combination table
ll C[51][51];

void comb_table(int N) {
	for (int i = 0; i <= N; i++) {
		for (int j = 0; j <= i; j++) {
			if (j == 0 or j == i) {
				C[i][j] = 1LL;
			}
			else {
				C[i][j] = C[i - 1][j - 1] + C[i - 1][j];
			}
		}
	}
}

int main(){
	int N, A, B;
	cin >> N >> A >> B;

	vector<ll> data;
	rep(i, 0, N) {
		ll x;
		cin >> x;
		data.push_back(x);
	}

	sort(data.begin(), data.end());
	reverse(data.begin(), data.end());

	
	R max_ave = 0.0;
	//まず平均を出力
	rep(i, 0, A) {
		max_ave += data[i];
	}
	max_ave /= A;



	//組み合わせの計算
	comb_table(N);


	int a_th_cnt=0;
	int a_th_in_cnt = 0;
	rep(i, 0, N) {
		if (data[i] == data[A - 1]) {
			a_th_cnt++;
			if (i <= A - 1) {
				a_th_in_cnt++;
			}
		}
	}


	ll ans = 0LL;
	if (data[0] == data[A-1]) {
		for(a_th_in_cnt = A; a_th_in_cnt <= B;a_th_in_cnt++) {
			ans += C[a_th_cnt][a_th_in_cnt];
		}
	}
	else {
		ans = C[a_th_cnt][a_th_in_cnt];
	}



	cout.precision(20);
	cout << fixed << max_ave << endl;
	cout << ans << endl;





	

	
	



	return 0;
}

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

const int N = 100010;
const ll INF = 1e18;
ll a[N], b[N], n, m;

ll solve (ll x) {
  ll t1 = *lower_bound(a, a + n + 2, x);
  ll t2 = *(upper_bound(a, a + n + 2, x) - 1);
  assert(t1 >= x); assert(t2 <= x);

  ll s1 = *lower_bound(b, b + m + 2, x);
  ll s2 = *(upper_bound(b, b + m + 2, x) - 1);
  assert(s1 >= x); assert(s2 <= x);

  t1 = t1 - x;
  t2 = x - t2;
  s1 = s1 - x;
  s2 = x - s2;

  ll ans = INF;
  ans = min(ans, max(s1, t1));
  ans = min(ans, max(s2, t2));
  ans = min(ans, t1 + s2 + min(t1, s2));
  ans = min(ans, t2 + s1 + min(t2, s1));
  return ans;
}

int main() {
  ll x, q;
  scanf("%lld%lld%lld", &n, &m, &q);
  for (int i = 1; i <= n; i++) scanf("%lld", &a[i]);
  for (int i = 1; i <= m; i++) scanf("%lld", &b[i]);

  a[0] = b[0] = -INF;
  a[n + 1] = b[m + 1] = INF;
  
  while (q--) {
    scanf("%lld", &x);
    printf("%lld\n", solve(x));
  }
}



Measured memory_bytes: 2816
s=input()
n=len(s)
s2=s[:(n-1)//2]
s3=s[(n+3)//2-1:]

count=0
for i in range(n//2):
    if s[i]==s[-(i+1)]:
        count+=1
for i in range((n-1)//2):
    if s2[i]==s2[-(i+1)]:
        count+=1
for i in range(n-(n+3)//2+1):
    if s3[i]==s3[-(i+1)]:
        count+=1

if count==n//2+(n-1)//2+n-(n+3)//2+1:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)(b); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n;
    cin >> n;
    ll sum[n + 1] = {};
    rep(i, 0, n) {
        int a;
        cin >> a;
        sum[i + 1] = sum[i] + a;
    }
    map<ll, ll> mp;
    rep(i, 0, n + 1) mp[sum[i]]++;
    ll ans = 0;
    for (auto i: mp) ans += i.second * (i.second - 1) / 2;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 14336
s = input()
r = 0
l = list(s)
for i in range(1 << len(s)-1):
    li = []
    for j in range(len(s)):
#         print(i,j)
        li += l[j]
        if j != len(s)-1:
            if i & 1 <<j:
                li += ['+']
#     print(li)
        
    r += eval(''.join(li))
print(r)

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


int main() {
    int A,B,C,D; cin >> A >> B >> C >> D;
    if(A+B>C+D) cout << "Left" << endl;
    else if(A+B<C+D) cout << "Right" << endl;
    else cout << "Balanced" << endl;
    return 0;
}

Measured memory_bytes: 3592
import sys
readline = sys.stdin.readline

while True:
    A, L = (int(x) for x in readline().split())
    if A == 0 and L == 0: break
    cnt = 0
    past = {A: 0}
    while True:
        A = list(str(A).rjust(int(L), '0'))
        A.sort()
        minA = int("".join(A))
        maxA = int("".join(reversed(A)))
        A = maxA - minA
        try:
            pre = past[A]
            print "%d %d %d" % (pre, A, cnt - pre + 1)
            break
        except:
            cnt += 1
            past[A] = cnt

Measured memory_bytes: 4240
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef  long long ll;
typedef  vector<int> vi;
typedef  pair<int,int> pii;
typedef  pair<int,string> pis;
double pi=3.1415926535898;
#define speed      ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
#define lop(i,n)   for(int i=0;i<int(n);i++)
#define rep(i,a,b) for(int i=a;i<=int(b);i++)
#define rng(i,a,b) for(int i=a;i>=int(b);i--)
#define ms(x,a)    memset(x,a,sizeof(x))
#define all(x)     (x).begin(),(x).end()
#define sz(x)      int(x.size())
#define pb         push_back
#define r0         return 0;
#define CC         continue;
#define bb(x)      cerr<< x <<endl;
#define F          first
#define S          second       //  __builtin_popcount;
//freopen("output.txt","w",stdout),freopen("input.txt","r",stdin);
const ll M  = 1e9+7 ;
const int N = 100100;
const int inf = INT_MAX;
const double eps = 1e-7;
const ll iinf = -1e18 ;
//////////////////////    Hi    ^_^  hack me if you can :P


int main()
{
    //speed;
    int n, m;
    cin >>n>>m;
    n+=1;
    m+=1;
    rep(i,0,n)
    {
        rep(j,0,m)
        {
            if (i == 0 || j == 0 || i ==n || j == m)
            {
                cout<< '#';
            }
            else
            {
                char c ;
                cin >> c;
                cout << c;
            }
        }
        cout << endl;
    }

}


Measured memory_bytes: 256
W,H,x,y=[int(i) for i in input().split(" ")]


x=abs(x-W/2)
y=abs(y-H/2)
W=W/2
H=H/2


print(W*H*2,end=" ")

if x==0 and y==0:
    print("1")
else:
    print("0")


Measured memory_bytes: 2940
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	public static void main(String[] args)throws IOException{
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader reader = new BufferedReader(isr);
		String string;
		while(!(string = reader.readLine()).equals("0 0")){
			for(int i = 0; i < Integer.parseInt(string.split(" ")[0]); i++){
				for(int j = 0; j < Integer.parseInt(string.split(" ")[1]); j++){
					System.out.print("#");
				}
				System.out.println();
			}
			System.out.println();
		}
		reader.close();
	}
}

Measured memory_bytes: 47008
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    string s;
    cin>>s;
    bool x=false,y=false;
    int in;
    for(int i=0;i!=s.size();++i){
        if(s[i]=='C'){
            x=true;
            in=i;
        }
        if(s[i]=='F' && i>in)
            y=true;
    }
    cout<<((x&&y) ? "Yes":"No")<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <math.h>
#include <time.h>

typedef int32_t i32;
typedef int64_t i64;
typedef double f64;

void *const null=(void *)0;
i64 const llinf=4611686018427387903LL;
i64 const mod=1000000009LL;
f64 const pi=3.141592653589793;
f64 const rad=57.295779513082323;

#define CODE_

i32 main(void){
    i64 n;
    scanf("%lli%*c",&n);
    i64 *x=(i64 *)calloc(n+1LL,sizeof(i64));
    x[n]=2020LL;
    for(i64 i=0LL;i<n;++i) scanf("%lli%*c",&x[i]);
    i64 m;
    scanf("%lli%*c",&m);
    for(i64 i=0LL;i<m;++i){
        i64 a;
        scanf("%lli%*c",&a);
        if(x[a-1LL]<x[a]-1LL) ++x[a-1LL];
    }
    for(i64 i=0LL;i<n;++i) printf("%lli\n",x[i]);
    return 0;
}



Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Matrix;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
static const int INF = 2000000000;


int main() {
  // input
  ll N;
  cin >> N;
  vector<ll> A(N), B(N), C(N);
  rep(i, N) cin >> A[i];
  rep(i, N) cin >> B[i];
  rep(i, N) cin >> C[i];
  sort(A.begin(), A.end());
  sort(B.begin(), B.end());
  sort(C.begin(), C.end());

  // calculation
  ll now_B, num_A, num_C, res = 0;
  ll idx_bound_A, idx_bound_C;

  for (ll i = 0; i < N; ++i) {
    now_B = B[i];
    num_A = 0;
    num_C = 0;

    // 1 段目: now_B 未満の数を求める
    auto iter_A = lower_bound(A.begin(), A.end(), now_B);
    auto iter_C = upper_bound(C.begin(), C.end(), now_B);
    ll num_A = iter_A - A.begin();
    ll num_C = C.end() - iter_C;

    res += num_A*num_C;
  }

  cout << res << "\n";

  return 0;
}

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


int main() {
    int h,w,n;
    cin >> h >> w >> n;
    vector<int> a(n);
    for (int i=0;i<n;i++) cin >> a[i];
    int itr=0;
    vector<vector<int>> ans(h,vector<int>(w));
    for (int y=0;y<h;y++) {
        if (y%2==0) {
            for (int x=0;x<w;x++) {
                if (a[itr]==0) itr++;
                a[itr]--;
                ans[y][x]=itr+1;
            }
        } else {
            for (int x=w-1;x>=0;x--) {
                if (a[itr]==0) itr++;
                a[itr]--;
                ans[y][x]=itr+1;
            }
        }
    }
    for (int y=0;y<h;y++) {
        for (int x=0;x<w;x++) cout << ans[y][x] << ' ';
        cout << endl;
    }
}

Measured memory_bytes: 384