akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const long double EPS = 1e-9;

#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<char> &o) {
    string a;
    in >> a;
    for (char c : a) o.insert(c);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<char> &s, char a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<P, vector<P>, greater<P> > PQ_ASK;


int main() {
    int n;
    cin >> n;
    vector<unsigned long long> v(n);
    rep(i, n) cin >> v[i];


    if (count(v.begin(), v.end(), 0) > 0) {
        cout << 0 << endl;
        ret();
    }


    vector<long double> vl(n);
    rep(i, n) vl[i] = log10l(v[i]);

    long double keta = accumulate(vl.begin(), vl.end(), (long double) 0.0);
    if (keta > 18.0) {
        cout << -1 << endl;
        ret();
    }


    unsigned long long border = 1000000000000000000ll;

    unsigned long long ans = 1;

    rep(i, n) {
        ans *= v[i];

        if (ans > border) {
            cout << -1 << endl;
            ret();
        }

    }

    cout << ans << endl;
}


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


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

  ll k;
  cin >> k;
  ll sum =0;
  rep1(i,k)rep1(j,k)rep1(l,k){
    sum += gcd(gcd(i,j),l);
  }
  cout << sum << endl;
  return 0;
    

}


Measured memory_bytes: 3652
#include<cstdio>
#include<cstring>
#include<queue>
#define maxn 1002
#define maxc 10
using namespace std;
struct point{
    int r,c;
};
char graph[maxn][maxn];
int len[maxn][maxn];
bool mark[maxn][maxn];
point node[maxc];
int dir[4][2]={1,0,-1,0,0,1,0,-1};
int main(void){
    int h,w,cheese,tr,tc,answer=0;
    scanf("%d%d%d",&h,&w,&cheese);
    memset(graph,0,sizeof(graph));
    memset(node,0,sizeof(node));
    for(int i=1;i<=h;i++) for(int j=1;j<=w;j++){
        do scanf("%c",&graph[i][j]);
        while(graph[i][j]==' ' || graph[i][j]=='\n');
        if(graph[i][j]>='0' && graph[i][j]<='9'){
            node[graph[i][j]-'0'].r=i;
            node[graph[i][j]-'0'].c=j;
        }
        else if(graph[i][j]=='S'){
            node[0].r=i;
            node[0].c=j;
        }
    }
    for(int cnt=0;cnt<cheese;cnt++){
        memset(len,0,sizeof(len));
        memset(mark,false,sizeof(mark));
        for(int i=0;i<=h+1;i++){mark[i][0]=true;mark[i][w+1]=true;}
        for(int j=0;j<=w+1;j++){mark[0][j]=true;mark[h+1][j]=true;}
        queue<point> q;
        q.push(node[cnt]);
        len[node[cnt].r][node[cnt].c]=0;
        point ongo,togo;
        while(!q.empty()){
            ongo=q.front();
            q.pop();
            if(mark[ongo.r][ongo.c]) continue;
            mark[ongo.r][ongo.c]=true;
            if(ongo.r==node[cnt+1].r && ongo.c==node[cnt+1].c){
                answer+=len[ongo.r][ongo.c];
                break;
            }
            for(int i=0;i<4;i++){
                togo.r=ongo.r+dir[i][0];togo.c=ongo.c+dir[i][1];
                if(mark[togo.r][togo.c]==false && graph[togo.r][togo.c]!='X'){
                    len[togo.r][togo.c]=len[ongo.r][ongo.c]+1;
                    q.push(togo);
                }
            }
        }
    }
    printf("%d\n",answer);
    return 0;
}


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

int main() {
    int X, Y;
    cin >> X >> Y;
    if (Y%2==1) {
        cout << "No" << endl;
    } else {
        int n_4 = (Y - 2 * X) / 2;
        if (n_4 >= 0 && n_4 <= X) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}


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

int main(){
  int n, p;
  cin>>n>>p;
  bool flag=0;
  rep(i,n){
    int a;
    cin>>a;
    if(a%2==1)flag=1;
  }
  ll ans=1;
  rep(i,n-1){
    ans*=2;
  }
  if(flag){
    cout<<ans<<endl;
  }else{
    if(p==1) cout<<0<<endl;
    else cout<<ans*2<<endl;
  }
}

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

int keta(int n) {
    int res;
    for(int i = 0; i < 100; i++) {
        n = n / 10;

        if(n == 0) {
            res = i + 1;
            break;
        }
    }
    return res;
}

signed main(){
    ll n,d;cin>>n>>d;
    ll ans=0;
    rep(i,n){
        ll x,y;cin>>x>>y;
        if(x*x+y*y<=d*d) ans++;
    }
    cout<<ans<<endl;
    return 0;
}

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

int main(){
  int N, K;
  cin >> N >> K;
  int result = 1;
  for (int i = 0; i < N; i++){
    if (result < K){
      result *= 2;
    }else{
      result += K;
    }
  }
  cout << result << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int c = sc.nextInt();
        int[][] differences = new int[c][c];
        int[][] colors = new int[n][n];
        int[][] patterns = new int[3][c];
        for (int i = 0; i < c ; i++) {
            for (int j = 0 ; j < c ; j++) {
                differences[i][j] = sc.nextInt();
            }
        }
        for (int i = 0; i < n ; i++) {
            for (int j = 0 ; j < n ; j++) {
                colors[i][j] = sc.nextInt();
                patterns[(i+j)%3][colors[i][j]-1]++;
            }
        }

        long min = Long.MAX_VALUE;
        for (int i = 0 ; i < c ; i++) {
            for (int j = 0 ; j < c ; j++) {
                if (i != j) {
                    for (int k = 0 ; k < c ; k++) {
                        if (i != k && j != k) {
                            long tmp = 0;
                            for (int m = 0 ; m < c ; m++) {
                                tmp += patterns[0][m] * differences[m][i];
                                tmp += patterns[1][m] * differences[m][j];
                                tmp += patterns[2][m] * differences[m][k];
                            }
                            min = Math.min(tmp, min);
                        }
                    }
                }
            }
        }
        System.out.println(min);
    }
}

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

#define rep(i,x,y) for(ll i=(ll)(x);i<(ll)(y);i++)
#define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(ll)(x);i--)
#define all(x) (x).begin(),(x).end()
#ifdef LOCAL
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define dassert(...) assert(__VA_ARGS__)
#else
#define dump(x)
#define debug(x)
#define dassert(...)
#endif
//#define int long long

typedef long long ll;
const ll MOD = 1e9 + 7;
const long double EPS = 1e-8;

bool match(char a, char b) {
    return a == b || a == '?' || b == '?';
}

void solve(std::string a, std::string b, std::string c){
    vector<bool> ab(20000,true), bc(20000,true), ac(20000,true);
    const int BASE = 10000;
    int A = a.size(), B = b.size(), C = c.size();

    rep(i,0,A) rep(j,0,B) if (!match(a[i], b[j])) ab[BASE + (i-j)] = false;
    rep(i,0,B) rep(j,0,C) if (!match(b[i], c[j])) bc[BASE + (i-j)] = false;
    rep(i,0,A) rep(j,0,C) if (!match(a[i], c[j])) ac[BASE + (i-j)] = false;

    int answer = INT_MAX;
    rep(abdiff, -4000, 4001) {
        rep(acdiff, -4000, 4001) {
            if (ab[BASE + abdiff] && ac[BASE + acdiff] && bc[BASE + (acdiff - abdiff)]) {
                int left = min<int>(0, min(abdiff, acdiff));
                int right = max<int>(A, max<int>(abdiff + B, acdiff + C));
                answer = min(answer, right - left);
            }
        }
    }
    cout << answer << endl;
}

signed main(){
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    std::string a;
    std::cin >> a;
    std::string b;
    std::cin >> b;
    std::string c;
    std::cin >> c;
    solve(a, b, c);
    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main() {
    int N, i, j, k, count = 1;
    scanf("%d", &N);
    //char *s = malloc(sizeof(char) * (N * 11));
    //char **S = malloc(sizeof(char*) * N);
    char S[N][11];
    for (i = 0; i < N; i++) {
        //S[i] = s + (i * 11);
        scanf("%s", S[i]);
    }
    qsort(S, N, sizeof(*S), strcmp);
    for (i = 1; i < N; i++) {
        if (strcmp(S[i - 1], S[i])) count++;
    }
    printf("%d\n", count);
    return 0;
}

Measured memory_bytes: 5740
n = int(input())
s = input()
w = [0] * n
e = [0] * n
for i in range(n):
    if i == 0:
        w[i] = 1 if s[i] == "W" else 0
        e[-i-1] = 1 if s[-i-1] == "E" else 0
    else:
        if s[i] == "W":
            w[i] = w[i-1] + 1
        else:
            w[i] = w[i-1]
        if s[-i-1] == "E":
            e[-i-1] = e[-i] + 1
        else:
            e[-i-1] = e[-i]
mp = 10 ** 9
for i in range(n):
    mp = min(mp, w[i] + e[i] - 1)
print(mp)


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

#define ms(s, n) memset(s, n, sizeof(s))
#define f(i, a, b) for (int i = (a); i <=(b); i++)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<ll> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int MOD2 = MOD + 2; //1007681537;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) - 1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
template<class T> inline int chkmin(T& a, const T& val) {return val < a ? a = val, 1 : 0;}
template<class T> inline int chkmax(T& a, const T& val) {return a < val ? a = val, 1 : 0;}
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}
inline int sign(ld x) {return x < -EPS ? -1 : x > +EPS;}
inline int sign(ld x, ld y) {return sign(x - y);}
int modulo(int a, int b) { return (a % b + b) % b; }
#define db(x) cerr << #x << " = " << (x) << " ";
#define endln cerr << "\n";

char s[21];
int main()
{
	IOS;
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ll n;
	cin >> n;
	string s;
	while (n) {
		s += (n - 1) % 26 + 'a';
		n = (n - 1) / 26;
	}
	reverse(s.begin(), s.end());
	cout << s << endl;
	// read the stuff at the bottom
	return 0;
}
/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
	* use int when constraints limits are tight
	* Time taken : global variable < pass by refernce < pass by value
	* It takes significant amt. of time in pass by value
	* Avoid Using endl
*/





























Measured memory_bytes: 3644
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

int main(){
    int N;cin>>N;
    int F[110][6][3],P[110][11];
    for(int i=1;i<=N;i++){
        for(int j=1;j<=5;j++){
            cin>>F[i][j][1]>>F[i][j][2];
        }
    }
    for(int i=1;i<=N;i++){
        for(int j=0;j<=10;j++)
            cin>>P[i][j];
    }
    int ans=-2*pow(10,9);
    for(int bit=1;bit<(1<<10);bit++){
        int M=0;
        for(int i=1;i<=N;i++){
            int c=0;
            for(int j=1;j<=5;j++){
                if(F[i][j][1]==1 && bit & (1<<2*(j-1)))
                    c++;
                if(F[i][j][2]==1 && bit & (1<<(2*(j-1)+1)))
                    c++; 
            }
            M+=P[i][c];
        }
        ans=max(ans,M);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------
def gcd(a,b):
    return a if b == 0 else gcd(b,a%b)
def lcm(a,b):
    return a*b // gcd(a,b)

# -------------------------------------------------------------
# main
# -------------------------------------------------------------
A,B,C,D = map(int,input().split())

def f(x):
    return x - (x//C + x//D - x//lcm(C,D))

print(f(B) - f(A-1))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define pb push_back
#define sz(a) (int)(a.size())
#define x first
#define y second
using namespace std;
const int MAXV = 405;
const int MAXT = 10005;
vector<pair<int, int> > g[MAXV];
int id[MAXT] , dst[MAXT] , Tmax , n , m , f[MAXV];
void inputG()
{
	cin >> n >> m;
	for(int i = 0; i < m; i++) {
		int u, v, d; cin >> u >> v >> d;
		u--; v--;
		g[u].push_back({v, d});
		g[v].push_back({u, d});
	}
	for(int i = 0; i < n; i++) cin >> f[i];
}
void inputQueries()
{
	cin >> Tmax;
	memset(id , -1 , sizeof id);
	for(int i = 0; i < Tmax; i++) {
		int Nnew; cin >> Nnew;
		for(int j = 0; j < Nnew; j++) {
			cin >> id[i] >> dst[i];
		}
	}
}
vector<pair<int , int> > spanTree[MAXV];
int p[MAXV];
int find(int u)
{
	return p[u] = p[u] == u ? u : find(p[u]);
}
void unite(int u , int v , int c)
{
	int U = find(u) , V = find(v);
	if(U != V)
	{
		p[V] = U;
		spanTree[u].pb({v , c});
		spanTree[v].pb({u , c});
	}
}

void buildSpan()
{
	for(int u = 0; u < n; u++)p[u] = u;
	vector<pair<int , pair<int , int> > > edges;
	for(int u = 0; u < n; u++)
		for(auto v : g[u])
			if(u < v.x)
				edges.pb({v.y , {u , v.x}});
	sort(edges.begin() , edges.end());
	for(auto e : edges)
		unite(e.y.x , e.y.y , e.x);
}

vector<int> route;
void dfs(int u , int p = -1)
{
	for(auto v : spanTree[u])
		if(v.x != p)
		{
			for(int i = 0; i < v.y; i++)
				route.pb(v.x);
			dfs(v.x , u);
			for(int i = 0; i < v.y; i++)
				route.pb(u);
		}
			
}
void findRoute()
{
	dfs(0);
}
void inputInfo()
{
	int nNew; cin >> nNew;
	for(int i = 0; i < nNew; i++)
	{
		int mem , kek;	cin >> mem >> kek;
	}
	int nPut; cin >> nPut;for(int i = 0; i < nPut; i++){int mem; cin >> mem;}
}
void inputRes()
{
	string verdict;cin >> verdict;
	if(verdict == "NG")	exit(0);
	int nAchieve;cin >> nAchieve;
	for(int i = 0; i < nAchieve; i++){int mem; cin >> mem;}
}
int main() {
	inputG();
	//inputQueries();
	
	buildSpan();
	findRoute();
	int cntStop = 400;
	cin >> Tmax;
	
	for(int i = 0; i < Tmax; i++)
	{
		inputInfo();
		if(i < cntStop)
			cout << -1 << endl;
		else
			cout << route[(i - cntStop) % sz(route)] + 1 << endl;
		inputRes();
	}
	return 0;
}


Measured memory_bytes: 1364
#include<stdio.h>

int main(){
    int i, j, n, c, count = 0, minj;
    int a[100];
    
    scanf("%d", &n);
    for(i = 0; i < n; i++){
        scanf("%d", &a[i]);
    }
    
    for(i = 0; i < n; i++){
        minj = i;
        for(j = i; j < n; j++){
            if(a[j] < a[minj]){
                minj = j;
            }
        }
        if(minj != i){
            count++;
            c = a[minj];
            a[minj] = a[i];
            a[i] = c;
        }
    }

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


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
	EACH(x,vec) is >> x;
	return is;
}
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
	REP(i,vec.size()) {
		if (i) os << " ";
		os << vec[i];
	}
	return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
	REP(i,vec.size()) {
		if (i) os << endl;
		os << vec[i];
	}
	return os;
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int N, T, L, B;
	while ( cin >> N >> T >> L >> B, N || T || L || B ) {
		vector<int> event(N+1, 0);
		REP(i, L) {
			int x; cin >> x;
			event[x] = 1;
		}
		REP(i, B) {
			int x; cin >> x;
			event[x] = 2;
		}
		vector< vector<ld> > dp(T+2, vector<ld>(N+1, 0)); dp[0][0] = 1.0;
		REP(i, T) {
			REP(j, N+1) {
				if (j == N) {
					dp[i+1][j] += dp[i][j];
				}
				else {
					FOR(k, 1, 7) {
						ld per = 1/6.0;
						int ni = i+1;
						int nj = j + k; if (nj > N) nj = 2 * N - nj;
						if (event[nj] == 2) {
							nj = 0;
						}
						if (event[nj] == 1) {
							++ni;
						}
						dp[ni][nj] += dp[i][j] * per;
					}
				}
			}
		}
		cout << fixed << setprecision(10) << dp[T][N] << endl;
	}
}

Measured memory_bytes: 3372
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<math.h>
#include<bitset>
using namespace std;
int main(){
	int a,b;
	char map[64];
	int movex[4]={1,0,-1,0},movey[4]={0,1,0,-1};
	while(cin>>map[0]){
		for(int i=1;i<64;i++){
			cin>>map[i];
		}
		int i,j;
		for(i=0;i<64;i++){
			if(map[i]=='1'){
				break;
			}
		}
		if(map[i+1]=='1'){
			if(map[i+8]=='1'&&map[i+9]=='1'){
				cout<<"A"<<endl;
			}
			else if(map[i+2]=='1'&&map[i+3]=='1'){
				cout<<"C"<<endl;
			}
			else if(map[i+9]=='1'&&map[i+10]=='1'){
				cout<<"E"<<endl;
			}
			else if(map[i+7]=='1'&&map[i+8]=='1'){
				cout<<"G"<<endl;
			}
		}
		else if(map[i+8]=='1'){
			if(map[i+16]=='1'&&map[i+24]=='1'){
				cout<<"B"<<endl;
			}
			else if(map[i+7]=='1'&&map[i+15]){
				cout<<"D"<<endl;
			}
			else if(map[i+9]=='1'&&map[i+17]=='1'){
				cout<<"F"<<endl;
			}
		}
		memset(map,'0',sizeof(map));
	}
	return 0;
}

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

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

	vector<string> s(n); for (int i = 0; i < n; i++) { cin >> s[i];	}

	sort(s.begin(), s.end());

	int max_cnt = 0;
	vector<int> maxCnt(n, 0);
		
	for (int i = 0; i < n; ) {

		int tmpCnt = 1;

		for (int j = i; j < n - 1; j++) {

			if (s[j] == s[j + 1]) {
				tmpCnt++;
			}
			else {
				break;
			}

		}

		if (max_cnt <= tmpCnt) {
			max_cnt = tmpCnt;
			maxCnt[i] = max_cnt;
		}
			
		i += tmpCnt;
	}
	
	
	for (int i = 0; i < n; i++) {
		
		if (maxCnt[i] == max_cnt) {

				cout << s[i] << endl;
	
		}

	}

	return 0;
}

Measured memory_bytes: 16896
n = int(input())
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))

ml = [[0 for i in range(n)] for j in range(2)]

for i in range(n):
    if i==0:
        ml[0][i] = l1[i]
    else:
        ml[0][i] = ml[0][i-1] + l1[i]
for i in range(n):
    if i==0:
        ml[1][i] = ml[0][i] + l2[i]
    else:
        ml[1][i] = max(ml[0][i], ml[1][i-1]) + l2[i]

print(ml[1][n-1] , flush=True)


Measured memory_bytes: 62136
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 1073741823;
const ll LINF = 4611686018427387903;
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main() {
	int n, m, x; cin >> n >> m >> x;
	VI c(n);
	VVI a(n,VI(m));
	REP(i,n){
		cin >> c[i];
		REP(j,m)
			cin >> a[i][j];
	}
	ll ans=LINF;
	REP(p,(1<<n)){
		VI r(m,0);
		ll sum=0;
		REP(i,n){
			if(p>>i&1){
				sum+=c[i];
				REP(j,m)
					r[j]+=a[i][j];
			}
		}
		bool no=0;
		REP(i,m){
			if(r[i]<x)
				no=1;
		}
		if(!no)
			ans=min(ans,sum);
	}
	if(ans==LINF)
		cout << -1 << endl;
	else
		cout << ans << endl;
	return 0;
}

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

int main()
{
  int q;
  cin >> q;
  for (int i=0; i<q; i++)
  {
    int C, A, N;
    cin >> C >> A >> N;
    int cnt = 0;

    int min = (C < A)? C : A;
    min = (N < min)? N : min;
    cnt += min;
    int inc = ((C-cnt)/2 < A-cnt)? (C-cnt)/2 : A-cnt;
    cnt += inc;
    cnt += (C-(cnt+inc))/3;

    cout << cnt << endl;
  }

  return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 9, INF = 0x3f3f3f3f;

struct Edge {
	int to, res;
	Edge *next;
	Edge () {}
	Edge (int to, int res, Edge *next) : to(to), res(res), next(next) {}
}*head[N], pool[N << 2], *pis = pool, *cur[N];

void AddEdge (int u, int v, int c) {
	head[u] = new (pis++) Edge(v, c, head[u]);
	head[v] = new (pis++) Edge(u, c, head[v]);
}

int s, t, d[N];

int Dfs (int u, int f) {
	if (u == t || f == 0) return f;
	int fellow = 0, D;
	for (Edge *&now = cur[u]; now; now = now -> next) if (d[now -> to] == d[u] + 1 && (D = Dfs(now -> to, min(now -> res, f)))) {
		fellow += D; now -> res -= D;
		(pool + ((now - pool) ^ 1)) -> res += D; f -= D;
		if (!f) break;
	}
	return fellow;
}

queue<int>Q;
bool vis[N];

bool Bfs () {
	memset(vis, 0, sizeof vis);
	Q.push(s); d[s] = 0; vis[s] = 1; int u;
	while (!Q.empty()) {
		u = Q.front(); Q.pop();
		for (Edge *now = head[u]; now; now = now -> next) if (now -> res && !vis[now -> to]) {
			d[now -> to] = d[u] + 1;
			vis[now -> to] = 1;
			Q.push(now -> to);
		}
	}
	return vis[t];
}

int n;

void Dfs (int u, int fa, bool o) {
	if (o) AddEdge(s, u, 1); else AddEdge(u, t, 1);
	o ^= 1; for (Edge *now = head[u]; now; now = now -> next) if (now -> to != fa && now -> to != s && now -> to != t) Dfs(now -> to, u, o);
}

int main () {
	scanf("%d", &n); s = n + 1; t = s + 1;
	for (int i = 1, u, v; i < n; ++i) scanf("%d%d", &u, &v), AddEdge(u, v, 1);
	Dfs(1, 0, 0);
	int fellow = 0;
	while (Bfs()) {
		for (int i = 1; i <= t; ++i) cur[i] = head[i];
		fellow += Dfs(s, INF);
	}
//	printf("%d\n", fellow);
	puts((fellow << 1) == n ? "Second" : "First");
	return 0;
}

Measured memory_bytes: 8704
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

int main() {
    int size = 8;
    int k;
    cin >> k;
    vector<int> Q(size, -1);
    REP(i, k) {
        int x, y;
        cin >> y >> x;
        Q[y] = x;
    }
    // cerr << "debug" << endl;
    // REP(i, size) {
    //     cerr << Q[i] << endl;
    // }
    // cerr << "end debug" << endl;
    vector<int> nums(size);
    REP(i, size) nums[i] = i;
    do {
        bool valid = true;
        REP(i, size) if(Q[i] >= 0 && nums[i] != Q[i]) valid = false;
        if(!valid) continue;
        bool flag = true;
        REP(y1, size)
            REP(y2, size)
                if(y1 != y2) {
                    if(abs(y1 - y2) == abs(nums[y1] - nums[y2])) flag = false;
                }

        if(flag) {
            REP(y, size) {
                REP(x, size) {
                    if(nums[y] == x) cout << "Q";
                    else cout << ".";
                }
                cout << endl;
            }
            return 0;
        }
    } while (next_permutation(nums.begin(), nums.end()));
    return 0;
}


Measured memory_bytes: 3104
#include <iostream>
#include<iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <set>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
#define all(a) a.begin(),a.end()
#define P pair<int,int>
#define space ' '
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

const int maxn = 200000;

int main(){
    
    set<int> s;
    int d[maxn];
    vector<pair<int,int> > v;
    int n,q;
    
    cin >> n>>q;
    
    rep(i,n){
        int s,t,x;
        cin >> s>>t>>x;
        v.push_back(make_pair(s-x,x));
        v.push_back(make_pair(t-x,-x));
    }
    
    rep(i,q){
        cin >> d[i];
    }
    
    sort(d,d+q);
    sort(all(v));
    v.push_back(make_pair(INF,INF));
    
    int ite = 0;
    
    rep(i,q){
        int T = d[i];
        //cout << "T "<<d[i]<<endl;
        while(T>=v[ite].first){
            if(v[ite].second>0)s.insert(v[ite].second);
            else s.erase(-v[ite].second);
            ite++;
        }
        if(s.size()==0) cout << -1<<endl;
        else cout << *s.begin()<<endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 14700
import Data.List

main = do
  n <- readLn :: IO Int
  ss <- lines <$> getContents :: IO [String]
  putStrLn $ show $ count $ sort ss


foldlPairwise :: (a -> b -> b -> a) -> a -> [b] -> a
foldlPairwise f a l = foldl (\a (z, x) -> f a z x) a $ zip l (tail l)

count ss = foldlPairwise step 1 ss
    where step a z x = a + if z == x then 0 else 1


Measured memory_bytes: 135800
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();
    int M = sc.nextInt();
    int[] a = new int[M];
    int[] b = new int[M];
    int[][] road = new int[N][N];

    for (int i = 0; i < M; i++) {
      a[i] = sc.nextInt() - 1;
      b[i] = sc.nextInt() - 1;
      road[a[i]][b[i]]++;
    }

    sc.close();

    for (int i = 0; i < N; i++) {
      int count = 0;
      for (int j = 0; j < N; j++) {
        if (road[i][j] != 0) {
          count += road[i][j];
        }
        if (road[j][i] != 0 && j != i) {
          count += road[j][i];
        }
      }
      System.out.println(count);
    }

  }

}

Measured memory_bytes: 21588
# -*- coding: utf-8 -*-

import math

h,w=map(int, input().split())

if h==1 or w==1:
    ans=1
elif h%2==0:
    ans=(int)(h/2*(math.ceil(w/2)+math.ceil((w-1)/2)))
else:
    ans=(int)((h-1)/2*(math.ceil(w/2)+math.ceil((w-1)/2))+math.ceil(w/2))

print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;

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

		int x = Integer.parseInt(scan.next());//賞味期限を X 日まで過ぎた食品を食べてもお腹を壊しません
		int a = Integer.parseInt(scan.next());;//賞味期限の A 日前
		int b = Integer.parseInt(scan.next());;//買ってから B 日後

		if(a < b){//賞味期限または期限を過ぎている
			int Sa = Math.abs(a-b);//期限超過日数
			if(Sa < x+1){//safe
				System.out.println("safe");
			}
			else{//お腹壊した
				System.out.println("dangerous");
			}
		}
		else {
			//期限を過ぎていない
			System.out.println("delicious");
		}
	}

}

Measured memory_bytes: 21716
import bisect

s = list(input())
t = list(input())
len_s = len(s)
LEN = [0] * 26
s_set = set(s)
t_set = set(t)
d = [None] * 26
ans = 0
now = -1
if s_set >= t_set:
  for key,i in enumerate(s):
    index = ord(i) - ord("a")
    if d[index] == None:
      d[index] = [key]
    else:
      d[index].append(key)
    LEN[index] += 1
  for j in t:
    ORD = ord(j) - ord("a")
    g = bisect.bisect_right(d[ORD],now)
    if g == LEN[ORD]:
      ans += len_s
      now = d[ORD][0]
    else:
      now = d[ORD][g]
  ans += now + 1
  print(ans)
else:
  print(-1)

Measured memory_bytes: 9056
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
map<string,int> freq;
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n; string s; ll ans = 0;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> s;
        sort(s.begin(),s.end());
        freq[s]++;
    }
    for (auto a : freq) {
        ans += a.second * 1LL * (a.second-1)/2LL;
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 11264
#include <algorithm>
#include <cassert>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> pipii;
typedef vector<vector<ll>> matrix;

void solve() {
  string s;
  cin >> s;
  int lhs = 0;
  int rhs = (s.size() / 2);
  while(lhs != rhs) {
    int mid = (lhs+rhs)/2;
    set<char> ss;
    int lhslhs = mid;
    int rhsrhs = s.size() - mid;
    for(int i = lhslhs; i < rhsrhs; i++) {
      ss.insert(s[i]);
    }
    if(ss.size() == 2) lhs = mid+1;
    else rhs = mid;
  }
  cout << (s.size() - lhs) << "\n";
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
}


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

int main() {
	
	string S,T;
	cin>>S;
	cin>>T;
	
	int f=0;
	for(int i=0;i<S.size();++i)
	{
		if(S[i]!=T[i])
		{
			f=1;
			break;
		}
	}
	if(f==0)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
	
	
	
	return 0;
}

Measured memory_bytes: 3624
#include<cstdio>
int a,b,c;
int re[4]={-1};
void st(int* p,int* q){
int r;
if(*p<*q){
r=*p;*p=*q;*q=r;
}
return;
}
int main(void){
while(1){
re[0]++;
scanf("%d%d%d",&a,&b,&c);
st(&a,&b);st(&a,&c);st(&b,&c);
if(a>=b+c)break;
if(a*a>b*b+c*c)re[3]++;
else if(a*a<b*b+c*c)re[2]++;
else re[1]++;
}
printf("%d",re[0]);
for(a=1;a<4;a++){
printf(" %d",re[a]);
}
printf("\n");
return 0;
}

Measured memory_bytes: 1032
f=lambda:map(int,input().split())
n,d,a=f()
lt=sorted([tuple(f()) for _ in range(n)])
from collections import *
q=deque()
c=s=0
for x,h in lt:
  while q and q[0][0]<x: s+=q.popleft()[1]
  h-=s
  if h<1: continue 
  t=-h//a; c-=t; s-=t*a; q.append((x+d*2,t*a))
print(c)

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

int main() {
int n; cin>>n;
  string s;cin>>s;
  int rev[n];
  int east=0;
  int ans=10000000;
   int kaisu=0;
  
  rep(i, n){if(s[i]=='E') east++;}
  rep(i, n){if(!i){if(s[0]=='E')kaisu=east-1; 
                   else kaisu=east;
                   ans=kaisu;
                   continue;}
           
            if(s[i-1]=='W') kaisu++;
            if(s[i]=='E') kaisu--;
            ans=min(ans,kaisu);
           }
  cout<<ans<<endl;

}


Measured memory_bytes: 900
#include <iostream>
#include <algorithm>
using namespace std;
const int maxn = 101, maxw = 100001;
long long int ans[maxn][maxw];
long long int wt[maxn], ct[maxn];
int main(void)
{
	int n, w;
	cin >> n >> w;
	for (int i = 1; i <= n; i++)
		cin >> wt[i] >> ct[i];
	for (int i = 1;i <= n;i++)
		for (int j = 1; j <= w; j++)
		{
			long long int& ret = ans[i][j];
			if (j < wt[i])
				ret = ans[i - 1][j];
			else
				ret = max(ret, max(ans[i - 1][j], ans[i - 1][j - wt[i]] + ct[i]));
		}
	cout << ans[n][w] << endl;
	/*for (int i = 0; i <= n; i++)
		for (int j = 0; j <= w; j++)
			if (j < w)
				cout << ans[i][j] << " ";
			else
				cout << ans[i][j] << endl;*/
	return 0;
}

Measured memory_bytes: 78336
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <complex>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <assert.h>
#include <array>
#include <cstdio>
#include <cstring>
#include <random>
#include <functional>
#include <numeric>
#include <bitset>
#include <fstream>

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1e9 + 10;

int xs[5001], ys[5001];
int sum[5100][5100];

int main() {

  int N, M; cin >> N >> M;
  vector<int> X = {-inf, inf}, Y = {-inf, inf};
  rep(i, N) {
    scanf("%d%d", &xs[i], &ys[i]);
    X.push_back(xs[i]); Y.push_back(ys[i]);
  }

  sort(X.begin(), X.end()); X.erase(unique(all(X)), X.end());
  sort(Y.begin(), Y.end()); Y.erase(unique(all(Y)), Y.end());

  rep(i, N) {
    sum[upper_bound(all(Y), ys[i]) - Y.begin()][upper_bound(all(X), xs[i]) - X.begin()] ++;
  }

  rep(i, Y.size() + 10) rep(j, X.size() + 10) {
    if(i && j) sum[i][j] -= sum[i-1][j-1];
    if(i) sum[i][j] += sum[i-1][j];
    if(j) sum[i][j] += sum[i][j-1];
  }

  rep(i, M) {
    int rx1, ry1, rx2, ry2; scanf("%d%d%d%d", &rx1, &ry1, &rx2, &ry2);
    int x1 = lower_bound(all(X), rx1) - X.begin();
    int y1 = lower_bound(all(Y), ry1) - Y.begin();
    int x2 = upper_bound(all(X), rx2) - X.begin();
    int y2 = upper_bound(all(Y), ry2) - Y.begin();
    printf("%d\n", sum[y2][x2] - sum[y2][x1] - sum[y1][x2] + sum[y1][x1]);
  }

  return 0;
}

Measured memory_bytes: 103232
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

bool check(llint a, llint b) {
	return a > b;
}

int main() {
	int n, k;
	cin >> n >> k;
	string s;
	cin >> s;
	vint a;
	int cnt = 0;
	rep(i, n) {
		if (i != 0) {
			if (s[i - 1] != s[i]) {
				a.push_back(cnt);
				cnt = 0;
			}
		}
		if (s[i] == '0') {
			cnt--;
		}
		else {
			cnt++;
		}
	}
	a.push_back(cnt);
	cnt = 0;
	rep(i, a.size()) {
		if (a[i] < 0)cnt++;
	}
	k = min(k, cnt);
	vint b;
	b.push_back(0);
	cnt = 0;
	rep(i, a.size()) {
		cnt += abs(a[i]);
		if (i != a.size() - 1) {
			if (a[i + 1] < 0) {
				b.push_back(cnt + b[b.size() - 1]);
				cnt = 0;
			}
		}
	}
	b.push_back(cnt + b[b.size() - 1]);
	int ans = b[0];
	int tmp;
	rep(i, b.size() - k) {
		tmp = b[min(i + k, (int)b.size() - 1)] - b[i];
		if (a[0] < 0) {
			if (i != 0) {
				tmp += a[2 * i - 1];
			}
		}
		else {
			if (i != 0) {
				tmp += a[2 * i - 2];
			}
		}
		ans = max(ans, tmp);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1272
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = pow(10, 9) + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divCeil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << A << endl; exit(0);}

int main()
{
  ll N, K;
  cin >> N >> K;

  vector<ll> V0(N, 0);
  for (ll i = 0; i < N; i++)
  {
    ll A;
    cin >> A;
    V0.at(A - 1)++;
  }

  vector<ll> V;
  for (ll i = 0; i < N; i++)
  {
    if (V0.at(i) != 0)
      V.push_back(V0.at(i));
  }
  sort(V.begin(), V.end());

  ll ans = 0;
  for (ll i = 0; i < (ll)V.size() - K; i++)
  {
    ans += V.at(i);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3956
<?php
  $n = trim(fgets(STDIN));
  $a = [];
  for($i=0; $i<$n; $i++){
    $a[] = (int)trim(fgets(STDIN));
  }
  $b = $a;

  $max = max($a);
  rsort($b);
  $k = $max;
  for($i=0; $i<$n; $i++){
    $max = $k;
    if($max == $a[$i]){
      $max = $b[1];
    }
    echo $max."\n";
  }
  ?>


Measured memory_bytes: 22388
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

struct BoolName : numpunct<char> {
  string t, f;
  BoolName (string t = "Yes", string f = "No") : t(t), f(f) {}
  string do_truename() const {return t;}
  string do_falsename() const {return f;}
};

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15) << boolalpha;
    cout.imbue(locale(cout.getloc(), new BoolName));
  }
} initializer;

template<typename T> istream& operator>>(istream &s, vector<T> &v) {
  for (T &t : v) s >> t;
  return s;
}

template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
  for (const T &t : v) s << t << endl;
  return s;
}

void set_bool_name(string t, string f) {
  cout.imbue(locale(cout.getloc(), new BoolName(t, f)));
}

template<typename T> bool chmin(T& a, T b) {return a > b ? a = b, true : false;}

template<typename T> bool chmax(T& a, T b) {return a < b ? a = b, true : false;}

template<typename T> void sort(vector<T>& v) {sort(v.begin(), v.end());}

int main() {
  int a, b;
  cin >> a >> b;
  cout << a * b / 2 << endl;
}



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

using namespace std;
typedef long long ll;
const int N=3e5+100;
ll mod=1e9+7;
ll a[N];
int main()
{
    int a;cin>>a;
    string s,c;
    cin>>s>>c;
    for(int i=0;i<s.size();i++) cout<<s[i]<<c[i];
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
const int MAXN=110000;
int n, a[MAXN];
bool check(int k)
{
	long long s=0;
	for (int i=1; i<=k; i++) s+=a[i];
	for (int i=k+1; i<=n; i++)
	{
		if (2*s<a[i]) return 0;
		s+=a[i];
	}
	return 1;
}
int main()
{
//	freopen("B.in", "r", stdin);
//	freopen("B.out", "w", stdout);
	scanf("%d", &n);
	for (int i=1; i<=n; i++) scanf("%d", &a[i]);
	sort(a+1, a+n+1);
	int l=1, r=n;
	while (l<r)
	{
		int mid=l+r>>1;
		if (check(mid)) r=mid;
		else l=mid+1;
	}
	printf("%d\n", n-l+1);
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define For(i,a,b) for(int i=a;i<b;i++)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define mp make_pair
#define bit(n) (1LL<<(n))
#define F first
#define S second
#define debug(x) cerr << x << endl
#define Complex complex<double>
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

map< ll , int > prime_factor(ll n) {
  map< ll , int > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}


int main() {
    ll n;
    cin >> n;
    int ans=0;
    map<ll,int> M=prime_factor(n);
    for(auto p:M){
        int now=1;
        while(now<=p.S){
            p.S-=now;
            ans++;
            now++;
        }
    }
    cout << ans;


}

/*



 */



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

public class Hello
{
    public static void Main()
    {
        while (true)
        {
            var s = Console.ReadLine();
            if (s == ".") break;
            var st = new Stack<int>();
            for (int i = 0; i < s.Length; i++)
                if (s[i] == '(') st.Push(1);
                else if (s[i] == '[') st.Push(2);
                else if ((s[i] == ')' | s[i] == ']') && st.Count() == 0) { Console.WriteLine("no"); goto next; }
                else if (s[i] == ')' && st.Pop() != 1) { Console.WriteLine("no"); goto next; }
                else if (s[i] == ']' && st.Pop() != 2) { Console.WriteLine("no"); goto next; }
            Console.WriteLine(st.Count() == 0 ? "yes" : "no");
            next:;
        }
    }
}



Measured memory_bytes: 10292
#include <stdio.h>
int main(void){
	int n,d,x;
	scanf("%d",&n);
	scanf("%d %d",&d,&x);
	int a[n];
	int i;
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	int ans=0;
	for(i=0;i<n;i++){
		ans += 1 + (d-1)/a[i];
	}
	ans += x;
	printf("%d",ans);
	
	return 0;
}

Measured memory_bytes: 128
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")

def MI(): return map(int, sys.stdin.readline().split())

def LI(): return list(map(int, sys.stdin.readline().split()))

def main():
    n, z, w = MI()
    aa = LI()
    if n - 2 >= 0:
        print(max(abs(aa[n - 1] - aa[n - 2]), abs(aa[n - 1] - w)))
    else:
        print(abs(aa[n - 1] - w))

main()


Measured memory_bytes: 3188
def F(a,b):A=len(a);r=[all([len(set([a[i+j],b[j],'?']))<3for j in range(min(A-i,len(b)))])for i in range(A)];return r+[1]
def Z(X):
 i,j,k=X;U,V,W=M[i][j],M[j][k],M[i][k];A,B,C=map(len,[S[i]for i in X]);q=A+B+C
 for l in range(A+1):
  if U[l]!=0:
   for r in range(l,A+B+1):
    if (B<r-l or V[r-l]==1) and W[min(A,r)]==1:q=min(q,max(A,l+B,r+C))
 return q
S=[input()for i in'abc']
T=range(3)
M=[[F(S[i],S[j])for j in T]for i in T]
from itertools import *;print(min([Z(i)for i in permutations(T)]))

Measured memory_bytes: 56156
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
INF = float("inf")
import sys
sys.setrecursionlimit(10000)


def solve(N, field):
    ans = 0
    for i in range(N):
        tmp = 0
        p = 0
        for j in range(N):
            if i == j:
                tmp += field[0][j]
                p = 1
            tmp += field[p][j]
        ans = max(ans, tmp)

    return ans


def main():
    N = int(input())
    field = []
    field.append(list(map(int, input().split())))
    field.append(list(map(int, input().split())))
    print(solve(N, field))


if __name__ == '__main__':
    main()

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

using namespace std;
int main() {
	string str,look;
	string ans = "No";
	int j,tmp;
	cin >> str>>look;
	str.append(str);
	//cout <<str<< str.length() << " " << look.length()<<" "<< str.length() - look.length() + 1;

	for (int i = 0; i < str.length() - look.length()+1; i++) {
		if (str[i] == look[0]) {
			tmp = i;
			for (j = 0; j < look.length(); j++) {
				if (str[tmp++] != look[j]) {
					break;
				}
				if (j == look.length() - 1) {
					ans = "Yes";
				}
			}
		}
		if (ans == "Yes") {
			break;
		}
		
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3228
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <deque>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define print(x) cout<<(x)<<endl
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define INF10 1001001001 
#define INF5 100000
#define EPS 1e-10


int main() {
	int N; cin >> N;
	vector<int>H(N);
	REP(i, N) cin >> H[i];
	int mx = 0;
	int cnt = 0;
	REP(i, N) {
		if (H[i] >= mx) {
			mx = H[i];
			cnt++;
		}
	}
	print(cnt);


	return 0;
}


Measured memory_bytes: 256
# 解説読後
import sys
sys.setrecursionlimit(100000)
H,W,D=map(int,input().split())
A=[list(map(int,input().split())) for i in range(H)]
mapper={}
for i in range(H):
    for j in range(W):
        mapper[A[i][j]]=(i,j)

Q=int(input().strip())
dist=[0]*(H*W+1)
for i in range(1,H*W+1):
    if i<=D:
        dist[i] = 0
    else:
        pos1=mapper[i]
        pos2=mapper[i-D]
        dist[i]=dist[i-D]+abs(pos1[0]-pos2[0])+abs(pos1[1]-pos2[1])
for i in range(Q):
    cst=0
    l,r=map(int,input().split())
    print(dist[r]-dist[l])

Measured memory_bytes: 25436
#include<bits/stdc++.h>
using namespace std;
int main(){
string s;
  cin>>s;
  int N=s.size();
  vector<int>A={-1};
  for(int i=0;i<N-1;i++){
  if(s.at(i)=='L' && s.at(i+1)=='R')
    A.push_back(i);
  }A.push_back(N-1);
  vector<int>B={};
  for(int i=0;i<N-1;i++){
  if(s.at(i)=='R' && s.at(i+1)=='L')
    B.push_back(i);
  }
  map<int,int>M;
  int n=B.size();
  for(int i=0;i<n;i++){
  int x=A.at(1+i)-A.at(i);
  if(x%2==0){
  M[B.at(i)]=x/2; M[1+B.at(i)]=x/2;
  }else{
  if((B.at(i)-A.at(i))%2==1){
    M[B.at(i)]=(x/2)+1;
    M[1+B.at(i)]=x/2;
      }else{
    M[B.at(i)]=x/2;
    M[1+B.at(i)]=(x/2)+1;
  }
     }
  }vector<int>Ans(N,0);
  for(int i=0;i<N;i++){
  if(M.count(i))
    Ans.at(i)=M.at(i);
  }for(int i=0;i<N-1;i++)
    cout<<Ans.at(i)<<" ";
  cout<<Ans.at(N-1)<<endl;
  
  return 0;
}

Measured memory_bytes: 6076