akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;
using   ll=long long;

#define fast        	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

#define endl        	"\n"
#define pb          	push_back
#define mp          	make_pair
#define F           	first
#define S           	second
#define int             long long int
#define pll				pair<int , int>

#define ALL(v)      	v.begin(),v.end()
#define ALLR(v)     	v.rbegin(),v.rend()
#define pii         	3.14159265358979323
#define inf     		LLONG_MAX
#define ones(x)     	__builtin_popcount(x)
#define fill(a,b)   	memset(a,b,sizeof(a))
#define mod 			1000000007
#define hell            998244353 

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

ll mod_inverse(ll a) 
{
	return mod_pow(a , mod-2 , mod);
}
 
void solve()
{
	int n;
	
	cin >> n;
	
	int a[n];
	
	int cnt = 0;
	
	for(int i = 0; i < n; ++i) {
		cin >> a[i];
		
		if(a[i] < 0) {
			cnt++;
		}
		
		a[i] = abs(a[i]);
	}
	
	sort(a , a+n);
	
	if(cnt % 2) {
		a[0] = -a[0];
	}
	
	int sm = 0;
	
	for(int i = 0; i < n; ++i) {
		sm += a[i];
	}
	
	cout << sm;
}

signed main() {
    fast;
    
    int t = 1;
    
	//cin >> t;
    
    while(t--) {
        solve();
    }
 
    return 0;
}


Measured memory_bytes: 4332
import itertools
import math
import sys

n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))

if p == q:
    print(0)
    exit()

x = []
for i in range(n):
    x.append(i+1)

li = list(itertools.permutations(x))

for i in range(len(li)):
    if list(li[i]) == p:
        a = i
    elif list(li[i]) == q:
        b = i
print(abs(a-b))

Measured memory_bytes: 13848
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i = 0; i<n; i++)
int main()
{
//   RRRR…RWWWW…Wとなればよい
	ll N;
	cin >> N;
	ll numR = 0;
	vector<char> A(N);

	rep(i,N){
		cin >> A[i];
		if (A[i] == 'R')
			numR++;
	}

//	cout << numR << " ";
	ll num = numR;
	rep(i,num){
		if(A[i] == 'R')
			numR--;
	}

	cout << numR;
	cin >> N;

	return 0;	
}


Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <stack>
#include <cmath>
#include <map>
#include <set>
#define inf 0x3f3f3f3f
//extern "C"{void *__dso_handle=0;}
using namespace std;
typedef long long ll;
const int maxn=1005;
vector<int> g[maxn];
int d[maxn];
set <int> s;
void del(int u)
{
	for(int i=0;i<g[u].size();i++)
	{
		d[g[u][i]]--;
		if(d[g[u][i]]==1) 
		{
			s.insert(g[u][i]);
//			cout << i << endl;
			cout.flush();
		}
	}
}

void print(int ans)
{
	cout << "! " << ans << endl;
	cout.flush();
}
int main() 
{
	int n;
	cin >> n;
	cout << ceil(n*1.0/2);
}

Measured memory_bytes: 256
N = int(input())
words = []
for i in range(N) :
    words.append(input())

win = False
for j in range(1, N) :
    if words[j].startswith(words[j-1][-1]) and words[j] not in words[:j]:
       win = True
    else :
        win = False
        break

if win == True :
    print("Yes")
else :
    print("No")


Measured memory_bytes: 3060
#include <cmath>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstring>

using namespace std;

#define forsn(i,s,n) for (int i = (s);i < (int)(n);i++)
#define forn(i,n) forsn(i,0,n)
#define dforsn(i,s,n) for (int i = (n-1);i >= (int)(s);i--)
#define dforn(i,n) dforsn(i,0,n)
#define all(v) (v).begin(), (v).end()
#define F first
#define S second

pair<int,int> a[100000];

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

	int n; cin >> n;
	forn(i,n) {
		cin >> a[i].F;
		a[i].S = i;
	}
	sort(a, a + n);

	int bad = 0;
	forn(i,n) {
		bad += (i % 2) != (a[i].S % 2);
	}
	assert(!(bad % 2));
	
	cout << bad / 2 << endl;
}


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

using namespace std;
typedef long long ll;


const int N=1e5+100;

int vis[200];

struct node
{
    int h=0;

}no[N];
vector<node>ve[N];

int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++){
            scanf("%d",&no[i].h);
    }
    int a,b;
    for(int i=1;i<=m;i++){
        scanf("%d%d",&a,&b);
        ve[a].push_back(no[b]);
        ve[b].push_back(no[a]);
    }
    int ans=0;
    for(int i=1;i<=n;i++){
            int f=0;
        if(ve[i].size()==0) {
                ans++;
                continue;
        }
        for(auto v:ve[i]){
            if(no[i].h<=v.h) {
                    f=1;
                    break;
            }
        }
        if(!f)
         ans++;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 9280
#include <stdio.h>

int main(){
	int i,j,tmp;
	int N = 10;
	int num[N];

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

	for(i = 0; i < N;i++){
        for(j = N - 1;j > i;j--){
            if(num[j] < num[j-1]){
                tmp = num[j-1];
                num[j-1] = num[j];
                num[j] = tmp;
            }
        }
    }

	//高い順から3つ出力
	for(i = N - 1;i > N - 4;i--){
		printf("%d\n", num[i]);
	}

    return 0;
}

Measured memory_bytes: 600
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define _USE_MATH_DEFINES
#include <math.h>
#define rep(i,n) for(int i = 0;i < n;i++)
#define NIL = -1;

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

ll lcm(ll a,ll b){
    a / gcd(a,b) * b;
}
const ll mod = 1e9 + 7;
const ll INF = 1e9 + 7;

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


/////////////////////////////////////////////////////////////////////////////////////////
int par[100000],rank_[100000];

void init(int N){
    for (int i = 0;i < N;i++){
        par[i] = i;
        rank_[i] = 0;
    }
}

int find(int x){
    if (par[x] == x){
        return x;
    }

    return par[x] = find(par[x]);
}

void unite(int x,int y){
    x = find(x);
    y = find(y);

    if (x == y) return;

    if (rank_[x] < rank_[y]){
        par[x] = y;
    }
    else {
        par[y] = x;
        if (rank_[x] == rank_[y]){
            rank_[x]++;
        }
    }
}

bool same(int x,int y){
    return (find(x) == find(y));
}

struct edge{
    int u,v,cost;
};

bool comp(const edge &e1,const edge &e2){
    return e1.cost < e2.cost;
}

int V,E;
edge es[100000];

int kruskal(){
    sort(es,es+E,comp);
    init(V);
    int res = 0;
    for (int i = 0;i < E;i++){
        edge e = es[i];
        if (!same(e.u,e.v)){
            unite(e.u,e.v);
            res += e.cost;
        }
    } 
    return res; 
}


int main(){
    int s,t,w;
    cin >> V >> E;
    for (int i = 0;i < E;i++){
        cin >> s >> t >> w;
        es[i] = (edge){s,t,w};
    }
    cout << kruskal() << endl;
    return 0;
}   



Measured memory_bytes: 4372
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 233333;
int x,y,n,sx,sy;char s[N],t[N];
int a[N],b[N];Pii f[N];
Pii getjiao(Pii a, Pii b){return Pii(max(a.fi,b.fi),min(a.se,b.se));}
Pii getbing(Pii a, Pii b){
	if(a.fi>a.se)return b;
	if(b.fi>b.se)return a;
	return Pii(min(a.fi,b.fi),max(a.se,b.se));
}
void solve(int mx){
	f[n+1]=Pii(1,mx);
	per(i,n,1){
		f[i]=Pii(0,mx);
		rep(x,-1,1)if(x==a[i]||x==0){
			Pii now=Pii(mx,0);
			rep(y,-1,1)if(y==b[i]||y==0){
				Pii cur=getjiao(Pii(f[i+1].fi-x-y,f[i+1].se-x-y),Pii(1,mx));
				if(x==1&&y==-1)cur=getjiao(cur,Pii(1,mx-1));
				if(x==-1&&y==1)cur=getjiao(cur,Pii(2,mx));
			//	if(i==2)printf("%d %d [%d,%d]\n",x,y,cur.fi,cur.se);
				now=getbing(now,cur);
			}
			f[i]=getjiao(f[i],now);
		}
	//	printf("%d:[%d,%d]\n",i,f[i].fi,f[i].se);
	}
}
int main() {
	read(x);read(y);read(n);read(sx);read(sy);
	scanf("%s%s",s+1,t+1);
	
	rep(i,1,n){a[i]=0;if(s[i]=='R')a[i]=1;if(s[i]=='L')a[i]=-1;}
	rep(i,1,n){b[i]=0;if(t[i]=='R')b[i]=1;if(t[i]=='L')b[i]=-1;}
	solve(y);
	if(!(sy>=f[1].fi&&sy<=f[1].se)){puts("NO");return 0;}
	
	rep(i,1,n){a[i]=0;if(s[i]=='D')a[i]=1;if(s[i]=='U')a[i]=-1;}
	rep(i,1,n){b[i]=0;if(t[i]=='D')b[i]=1;if(t[i]=='U')b[i]=-1;}
	solve(x);
	if(!(sx>=f[1].fi&&sx<=f[1].se)){puts("NO");return 0;}
	puts("YES");
	return 0;
}


Measured memory_bytes: 4096
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <ostream>
#include <string>
#include <vector>
#include <cstring>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
#include <queue>
#include <deque>

using namespace std;

int main(){
    string S;
    cin>>S;
    int zero1=0,zero0=0,one1=0,one0=0,ji=0,ou=0;
    for(int i=0;i<S.size();i++){
        if(i%2==0){
            ou++;
            if(S[i]=='0')
                zero0++;
            else one0++;
        }
        else{
            ji++;
            if(S[i]=='0')
                zero1++;
            else one1++;
        }
    }
    cout<<min(ou-zero0+ji-one1,ou-one0+ji-zero1);
}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int H, W;
std::string M[50];
const int dx[4] = {-1, 1, 0, 0}, dy[4] = {0, 0, -1, 1};

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

    std::cin >> H >> W;

    for(int i=0;i<H;++i){
        std::cin >> M[i];
    }

    for(int i=0;i<H;++i){
        for(int j=0;j<W;++j){
            if(M[i][j] != '#'){
                continue;
            }

            bool ok = false;

            for(int k=0;k<4;++k){
                int y = i + dy[k], x = j + dx[k];

                if(0 <= y && y < H && 0 <= x && x < W &&
                   M[y][x] == '#'){
                    ok = true;
                    break;
                }
            }

            unless(ok){
                std::cout << "No" << std::endl;
                return 0;
            }
        }
    }

    std::cout << "Yes" << std::endl;
}


Measured memory_bytes: 256
d,n = map(int,input().split())
if d ==0:
  if n!=100:
    print(n)
  else:
    print(101)
elif d == 1:
  if n!=100:
    print(n*100)
  else:
    print(101*100)
else:
  if n!=100:
    print(n*10000)
  else:
    print(1010000)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = " ";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/


const int N = 55555;
bool prime[N + 1];
vector<int> primes;

void hurui()
{
	memset(prime, true, sizeof(prime));
	prime[0] = prime[1] = false;
	for (int i = 2; i*i < N; i++)
	{
		if (!prime[i]) continue;
		for (int j = i; i*j < N; j++)
		{
			prime[i*j] = false;
		}
	}
	REP(i, N + 1)
	{
		if (prime[i]) primes.push_back(i);
	}
}


int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	hurui();
	int n; cin >> n;
	vi ans;
	for (auto i : primes)
	{
		if (i % 5 == 1) ans.push_back(i);
	}
	vi aans;
	REP(i, n) aans.push_back(ans[i]);
	cout << aans << endl;
	return 0;
}

Measured memory_bytes: 384
D = int(input())
C = [0] + list(map(int, input().split()))
S = [0] + [[0] + list(map(int, input().split())) for _ in range(D)]

last = [0] + [0 for _ in range(26)]

for d in range(1, D+1):
    vmax = -float('inf')
    for i in range(1, 27):
        v = 0
        last_ = [s for s in last]
        v += S[d][i]
        last_[i] = d
        for j in range(1, 27):
            v -= C[j] * (d - last_[j])
        if v > vmax:
            vmax = v
            t = i
    print(t)

Measured memory_bytes: 9400
// Aizu 1297: Swimming Jam
// 2017.11.2 bal4u@uu

#include <stdio.h>
#include <stdlib.h>

#define MAX 52
typedef struct { int t, c, a; } T;   // a: arive time
T q[2][MAX+2]; int top[2], end[2];
T p[MAX+2]; int sz;

int cmp(T *a, T *b) { return a->t - b->t; }

int main()
{
	int n, i, j, k, t, a, ans, t0, t1;

    while(scanf("%d", &n) && n > 0) {
		for (i = 0; i < n; i++ ) scanf("%d%d", &p[i].t, &p[i].c), p[i].a = p[i].t;
		qsort(p, n, sizeof(T), cmp);
		for (i = 0; i < n; i++)	q[0][i] = p[i];
		top[0] = top[1] = end[0] = end[1] = 0, end[0] = n;

		ans = 0;
		while (n > 0) {
			t0 = t1 = 0x7fffffff;
			if (top[0] != end[0]) t0 = q[0][top[0]].a;
			if (top[1] != end[1]) t1 = q[1][top[1]].a;
			if (t0 <= t1) j = 0;
			else j = 1;

			sz = t = 0;
			while (top[j] != end[j]) {
				k = top[j];
				a = q[j][k].a;
				if (!t) t = a; else if (t < a) break;
				if (j == 1) q[j][k].c--;
				if (!q[j][k].c) n--, ans = t;
				else p[sz] = q[j][k], p[sz].a = t + p[sz].t, sz++; 
				if (++k == MAX) k = 0;
				top[j] = k;
			}
			if (n == 0) break;
			qsort(p, sz, sizeof(T), cmp);

			j = !j, k = end[j];
			for (i = 0; i < sz; i++) {
				q[j][k] = p[i]; if (++k == MAX) k = 0;
			}
			end[j] = k;
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1700
#include <iostream>
#include <unordered_map>
#include <utility>

using namespace std;

pair<int, int> get_max_element(unordered_map<int,int>& umap, int key_except=-1)
{
  int max_key = 0;
  int max_count = 0;
  for (auto kv : umap) {
    int key = kv.first;
    int count = kv.second;

    if (count > max_count && key != key_except) {
      max_key = key;
      max_count = count;
    }
  }

  return make_pair(max_key, max_count);
}

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

  int count_even = (N+1)/2;
  int count_odd = N/2;

  unordered_map<int,int> umap_even, umap_odd;

  for (int n=0; n<N; ++n) {
    auto& umap = n%2 ? umap_odd : umap_even;
    int v;
    cin >> v;
    if (umap.count(v)==0)
      umap.emplace(v,1);
    else
      umap.at(v)++;
  }

  auto kv_even = get_max_element(umap_even);
  auto kv_odd = get_max_element(umap_odd);
  int max_key_even, max_count_even;
  int max_key_odd, max_count_odd;
  max_key_even = kv_even.first;
  max_count_even = kv_even.second;
  max_key_odd = kv_odd.first;
  max_count_odd = kv_odd.second;

  int ops;
  if (max_key_even != max_key_odd) {
    ops = (count_even - max_count_even) + (count_odd - max_count_odd);
  } else {
    
    auto kv_even2 = get_max_element(umap_even,max_key_even);
    //int second_max_key_even = kv_even2.first;
    int second_max_count_even = kv_even2.second;

    auto kv_odd2 = get_max_element(umap_odd,max_key_odd);
    //int second_max_key_odd = kv_odd2.first;
    int second_max_count_odd = kv_odd2.second;

    ops = min((count_even - second_max_count_even) + (count_odd - max_count_odd),
	      (count_even - max_count_even) + (count_odd - second_max_count_odd));
  }

  cout << ops << endl;
  
  return 0;
}


Measured memory_bytes: 4376
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <iomanip>
#include <math.h>

using namespace std;

long long mod = 1000000007;

long long pow(long long x, long long k)
{
    if (k == 0)
    {
        return 1LL;
    }
    long long temp = pow(x, k / 2);
    if (k % 2 == 1)
    {
        return (((temp * temp) % mod) * x) % mod;
    }
    else
    {
        return (temp * temp) % mod;
    }
}

long long modular_inverse(long long x)
{
    return pow(x, mod - 2);
}

long long binomial(long long n, long long k)
{
    long long rez = 1;
    for (int i = n - k + 1; i <= n; i++)
    {
        rez *= i;
        rez %= mod;
    }
    long long temp = 1;
    for (int i = 1; i <= k; i++)
    {
        temp *= i;
        temp %= mod;
    }
    rez *= modular_inverse(temp);
    rez %= mod;
    return rez;
}

int main()
{
    int n, k, rez = 0;
    cin >> n >> k;
    while (n != 0)
    {
        n /= k;
        rez++;
    }
    cout << rez << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }



int main() {
    int N;
    cin >> N;
    vector<long long> A(N);
    long long B = 0;
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
        B ^= A[i];
    }
    for (int i = 0; i < N; ++i) cout << (B^A[i]) << " ";
    cout << endl;
}

















Measured memory_bytes: 4780
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;


int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

int main(int argc, const char * argv[]) {
    
    // source code
	int X=inputValue();
	if(X==7 | X==5 | X==3){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
#define INF 10e12
#define MOD 1000000000 + 7
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))

using namespace std;

vector<ll> kumiawase(ll s, ll N)
{
    vector<ll> ans;
    rep(i, N)
    {
        if (s & (1 << i))
            ans.push_back(i);
    }
    return ans;
}
int main(void)
{
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<ll> A(N);
    multiset<ll, greater<ll>> st;
    rep(i, N)
    {
        cin >> A[i];
        st.insert(A[i]);
    }
    ll m1 = *st.begin();
    ll m2 = *++st.begin();
    rep(i, N)
    {
        if (A[i] == m1)
            cout << m2 << endl;
        else
            cout << m1 << endl;
    }
}


Measured memory_bytes: 12544
#include<stdio.h>
int main(void)
{
	int x,y,cnt,ans,i;
	double a,b,c;
	scanf("%d %d",&x,&y);
	cnt=2;
	a=(double)x/y;
	b=(double)y/x;
	for(i=1;i<y;i++){
		c=x*i%y;
		if(c==0){
			cnt++;
		}
	}
	ans=(x+1+y+1)-cnt;
	printf("%d\n",ans);
	return 0;
}


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

#define ll long long
int k, a, b;

int main()
{
	while (scanf("%d%d%d", &k, &a, &b) != EOF)
	{
		if (a >= (b - 2) || k < a) printf("%d\n", k + 1);
		else
		{
			k -= a - 1;
			int Loop = k / 2;
			if (Loop == 0) printf("%d\n", a + k % 2);
			else printf("%lld\n", 1ll * b + 1ll * (Loop - 1) * (b - a) + k % 2);
		}
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String S = sc.next();
		String T = sc.next();
		StringBuilder sb = new StringBuilder();
		for(int i = 0 ; i < N ; ++i){
			sb.append(S.charAt(i));
			sb.append(T.charAt(i));
		}
		System.out.println(sb.toString());
	}
}


Measured memory_bytes: 23252
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

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 RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

const int MAX = 1 << 19;
int N, C;
LL S[MAX];

int main(void) {
    cin >> N;
    C = 1 << N;
    REP(i, C) cin >> S[i];

    sort(S, S + (1 << N));
    reverse(S, S + (1 << N));

    map<LL, int> cnt;
    FOR(i, 1, C) {
        cnt[S[i]]++;
    }

  	VL v({S[0]});
    REP(i, N) {
        VL tmp;
        FORE(cur, v) {
            auto itr = cnt.lower_bound(cur);
            if (itr == begin(cnt)) {
                cout << "No" << endl;
                return 0;
            }
            itr = prev(itr);
            const auto val = itr->first;
            if (--itr->second == 0) {
                cnt.erase(itr);
            }
            tmp.EB(val);
        }
        FORE(e, tmp) v.EB(e);
    }

    cout << "Yes" << endl;
}


Measured memory_bytes: 20736
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

struct data {
  int par;
  ll val;
  data(int par_=0, ll val_=0LL) : par(par_), val(val_) {}
};

int main() {
  int N, Q;
  cin >> N >> Q;
  vector<data> D(N);
  vector<vector<int> > Edge(N, vector<int>());
  rep(i, N-1) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    Edge[a].push_back(b);
    Edge[b].push_back(a);
  }
  {
    vector<bool> flag(N);
    queue<int> next;
    next.push(0);
    flag[0] = true;
    while(!next.empty()) {
      int tmp = next.front();
      next.pop();
      for(vector<int>::iterator itr=Edge[tmp].begin();
          itr != Edge[tmp].end();
          itr++) {
        if(!flag[*itr]) {
          D[*itr].par = tmp;
          flag[*itr] = true;
          next.push(*itr);
        }
      }
    }
  }
  rep(i, Q) {
    int p;
    ll x;
    cin >> p >> x;
    p--;
    D[p].val += x;
  }

  vector<ll> A(N);
  {
    vector<bool> flag(N);
    queue<int> next;
    next.push(0);
    flag[0] = true;
    A[0] = D[0].val;
    while(!next.empty()) {
      int tmp = next.front();
      next.pop();
      for(vector<int>::iterator itr=Edge[tmp].begin();
          itr != Edge[tmp].end();
          itr++) {
        if(!flag[*itr]) {
          D[*itr].val += D[tmp].val;
          A[*itr] = D[*itr].val;
          flag[*itr] = true;
          next.push(*itr);
        }
      }
    }
  }
  rep(i, N) {
    cout << A[i] << " ";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 19444
n = int(input())
a = list(map(int,input().split()))
baisu = [0,0,0]
flag = 0

for i in a:
    if i % 4 == 0:
        baisu[2] += 1
    elif i % 2 == 0:
        baisu[1] += 1
    else:
        baisu[0] += 1

if baisu[0] == 0 and (baisu[2] != 0 or baisu[1] != 1):
    flag = 1

if baisu[1] == 0 and baisu[2]+1 == baisu[0]:
    flag = 1

while baisu[2] != 0:
    baisu[2] -= 1
    baisu[0] -= 1

if baisu[0] < 1 or flag == 1:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 20360
# -*- coding: utf-8 -*-
from collections import Counter
from itertools import product
def inpl(): return tuple(map(int, input().split()))
   
 
S = input()
x, y = inpl()
M = []
 
d = 0
for s in S:
    if s == "F":
        d += 1
    else:
        M.append(d)
        d = 0
M.append(d)
 
Cx = Counter(M[2::2])
Cy = Counter(M[1::2])
 
Lx = []
Ly = []
 
for k, v in Cx.items():
    if k == 0:
        pass
    else:
        Lx.append(list(range(-k*v, k*v+1, 2*k)))
        
for k, v in Cy.items():
    if k == 0:
        pass
    else:
        Ly.append(list(range(-k*v, k*v+1, 2*k)))
 
def bfss(Ls, t, f):
    N = set([f])
    for L in Ls:
        nN = set(([n+l for n, l in product(N, L)]))
        N = nN
    if t in N:
        return True
    else:
        return False
 
if bfss(Lx, x, M[0]) and bfss(Ly, y, 0):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 8572
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

void makePrimeNumber(int N, vector<bool>& prime) // 0ツ暗按湘」Nツ暗按可コツづ個青ョツ青板つゥツづァツ素ツ青板づーツ探ツつキ
{
    prime.assign(N+1, true);
    prime [0] = prime[1] = false;
    for(int i=2; i*i<=N; i++){
        if(prime[i]){
            for(int j=i; i*j<=N; j++){
                prime[i*j] = false;
            }
        }
    }
}

int main()
{
    vector<bool> prime;
    makePrimeNumber(110000, prime);

    vector<int> num(1, 0);
    for(int i=0; i<=110000; ++i){
        if(prime[i])
            num.push_back(*(num.rbegin()) + i);
    }

    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            return 0;

        cout << num[n] << endl;
    }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(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(v) v.begin(), v.end()
typedef long long ll;
typedef long double ld;
using namespace std;
struct Fast {Fast(){std::cin.tie(0);std::ios::sync_with_stdio(false);}} fast;
template <class T = int> T in(){T x; cin >> x; return (x);}

int main(void){
    ll N;
    cin >> N;
    vector<ll> H;
    rep(i, N){
        ll x;
        cin >> x;
        H.push_back(x);
    }
    ll result = 1;
    
    ll max = H[0];
    For(i, 1, N){
        if(max <= H[i]){
            result ++;
            max = H[i];
        }
    }
    
    cout << result << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>   
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
     
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
using Graph = vector<vector<int>>;
Graph G;

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

    int n; cin >> n;
    string s; cin >> s;
    string t = s;
    sort(s.begin(), s.end());
    int ans = 0;
    rep(i, n){
        if(s[i] != t[i]) ans++;
    }
    cout << ans / 2 << endl; 
}

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

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

using pii = pair<int, int>;

int main()
{
    int N; cin >> N;
    vector<vector<int>> A(N, vector<int>(N-1)); cin >> A;

    vector<vector<int>> vid(N, vector<int>(N));
    int id = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            if (i == j) continue;
            if (i < j) vid[i][j] = id++;
            else vid[i][j] = vid[j][i];
        }
    }


    int NV = N * (N-1) / 2;
    vector<vector<int>> g(NV);
    vector<int> in_deg(NV);
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N-2; j++) {
            int v = vid[i][A[i][j]-1];
            int u = vid[i][A[i][j+1]-1];
            g[v].push_back(u);
            in_deg[u]++;
        }
    }

    vector<int> start_v;
    for (int i = 0; i < NV; i++) {
        if (in_deg[i] == 0) {
            start_v.push_back(i);
        }
    }

    vector<int> topo_sorted(start_v);
    int i = 0;
    while (i < topo_sorted.size()) {
        const int& v = topo_sorted[i];
        for (const auto& u : g[v]) {
            in_deg[u]--;
            if (in_deg[u] == 0) {
                topo_sorted.push_back(u);
            }
        }
        i++;
    }
    if (topo_sorted.size() != NV) {
        cout << -1 << endl; return false;
    }

    int ans = 1;
    vector<int> dp(NV, 0);
    for (auto v : start_v) dp[v] = 1;
    for (auto v : topo_sorted) {
        for (const auto& u : g[v]) {
            if (dp[v] + 1 > dp[u]) {
                dp[u] = dp[v] + 1;
                ans = max(ans, dp[u]);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 41456
#include<stdio.h>

int isnp[1001001] = {1,1};
int ecnt[1001001];

int main(void){
    register long i,j;
    for(i = 2;i < 1001001;i++)if(!isnp[i])for(j = 2;i*j < 1001001;j++)isnp[i*j] = 1;
    long long n;
    scanf("%lld",&n);
    if(n == 1){
        puts("0");
        return 0;
    }
    static int nispf;
    for(i = 2;i < 1001001;i++)if(!isnp[i])while(!(n % i)){n /= i;ecnt[i]++;}
    if(n != 1)nispf = 1;
    static long long ans;
    for(i = 2;i < 1001001;i++)if(ecnt[i]){
        j = 1;
        do{ecnt[i] -= j;ans++;}while(ecnt[i] >= ++j);
    }
    if(nispf)ans++;
    printf("%lld",ans);
}

Measured memory_bytes: 5644
def d_knapsack1(N, W, Goods):
    """
    N個の品物のi番目について、重さはw_i, 価値はv_iである。
    品物のいくつかを選んでナップサックに入れるが、品物の重さの総和はW以下とする。
    品物の価値の総和の最大値を求めよ。
    ※ 1 <= w_i <= W <= 10^5 と、重さの制約がゆるめ
    """
    import numpy as np
    # dp[w]: 重さwの品物の入れ方で達成できる価値の最大値
    dp = np.zeros(W + 1, dtype=np.int64)
    for w, v in Goods:
        # 重さi(0<=i<=W-w)のときの価値に対し注目している荷物を入れて、
        # 重さi+wのときの価値を更新する
        np.maximum(dp[:W + 1 - w] + v, dp[w:], out=dp[w:])
        # outで指定した箇所のみ上書き。与えないと新しく配列が作られる
    return dp[-1]

N, W = [int(i) for i in input().split()]
Goods = [[int(i) for i in input().split()] for j in range(N)]
print(d_knapsack1(N, W, Goods))

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

typedef long long ll;

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

const int INF = (1LL<<30);

int main() {
  int n;
  int a[305][305], dp[305][305];
  cin >> n;
  REP(i, n) REP(j, n) cin >> a[i][j];
  
  REP(k, n) REP(i, n) REP(j, n) {
    if(k == i || k == j || i == j || a[i][k] == INF || a[k][j] == INF || a[i][j] == INF) continue;
    if(a[i][k] + a[k][j] == a[i][j]) {
      a[i][j] = INF;
    } else if(a[i][k] + a[k][j] < a[i][j]) {
      cout << -1 << endl;
      return 0;
    }
  }

  ll sum = 0;
  REP(i, n) REP(j, n) if(a[i][j] != INF) sum += a[i][j];
  cout << sum/2 << endl;

  return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <iostream>

using namespace std;

int main() {

	int x, y, ink, blank=0, max=0, m[10][10];
	int mx[]={0, 1, 0, -1, 1, 1, -1, -1, 0, 2, 0, -2};
	int my[]={1, 0, -1, 0, 1, -1, -1, 1, 2, 0, -2, 0};

	for(int i=0; i<10; i++) {
		for(int j=0; j<10; j++) {
			m[i][j]=0;
		}
	}

	while(scanf("%d, %d, %d", &x, &y, &ink)!=EOF) {
		m[x][y]++;
		for(int i=0; i<ink*4; i++) {
			int dx=x+mx[i];
			int dy=y+my[i];
			if(dx>=0&&dx<=9&&dy>=0&&dy<=9)
				m[dx][dy]++;
		}
	}

	for(int x=0; x<10; x++) {
		for(int y=0; y<10; y++) {
			if(m[y][x]==0)
				blank++;
			if(m[y][x]>max)
				max=m[y][x];
		}
	}

	cout << blank << endl << max << endl;

	return 0;

}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

ll n, ans = 0;
void dfs(ll x) {
  if (x > n) return;

  int a[10] = {0};
  ll t = x;
  while (t != 0) a[t % 10]++, t /= 10;
  if (a[3] && a[5] && a[7]) ans++;

  dfs(x * 10 + 3);
  dfs(x * 10 + 5);
  dfs(x * 10 + 7);
}

int main() {
  cin >> n;
  dfs(0);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll MOD=1e9+7;
const int INF=1<<30;

int main(){
  int N; cin >> N;
  string S; cin >> S;
  int ans=0;
  rep(i,N-2){
    if(S[i]=='A'&&S[i+1]=='B'&&S[i+2]=='C'){
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		int n = sc.nextInt();
		long[][] t=new long[h][w];
		long[] a = new long[n];
		int h1=0; 
		int w1=-1;
		int one=1;
		for(int i = 0; i<n; i++){
			a[i]=sc.nextLong();
			for(long j = 0; j<a[i]; j++){
				if(w1==w-1 && one==1){
					h1++;
					w1++;
					one=-1;
				}
				if(w1==0 && one==-1){
					h1++;
					w1--;
					one=1;
				}
				w1+=one;
				t[h1][w1]=i+1;
			}
		}
		for(int i=0; i<h; i++){
			if(i!=0){
				System.out.println();
			}
			for(int j=0; j<w; j++){
				System.out.print(t[i][j]+" ");
			}
		}
	}
}

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

int main() {
  int n,m,a,b;cin>>n>>m;
  vector<vector<int>>v(n);
  rep(i,m){
    cin>>a>>b;a--,b--;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  queue<int> que;
  que.push(0);
  vector<bool> fin(n);
  vector<int> flag(n);
  while(!que.empty()){
    int now=que.front();
    que.pop();
    rep(i,v[now].size()){
      int nxt=v[now][i];
      if(!fin[nxt]){
        flag[nxt]=now;
        fin[nxt]=true;
        que.push(nxt);
      }
    }
  }
  cout<<"Yes"<<endl;
  rep(i,n-1)cout<<flag[i+1]+1<<endl;
}

Measured memory_bytes: 10064
#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; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    int a, b; cin >> a >> b;
    int ans = 0;

    if(a >= b){
        ans += a;
        a--;
    }
    else{
        ans += b;
        b--;
    }

    cout << ans + max(a, b) << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.math.*;
import java.util.*;
public class Main { //USE LONGS TO AVOID OVERFLOW THEN CAST
 
	public static void main(String[] args) { 
		FastScanner input = new FastScanner();
		PrintWriter w = new PrintWriter(System.out);
		int N = input.nextInt();
		int M = input.nextInt();
		long[] a = new long[N];
		long[][] u = new long[M][2];
		long ans = 0;
		int L = 0; //Pointer of original cards
		int R = M-1; //Pointer of big cards
		for (int i = 0; i < N; i++) {
			a[i]=input.nextLong();
			ans+=a[i];
		}
		for (int i = 0; i < M; i++) {
			u[i][0]=input.nextLong();
			u[i][1] = input.nextLong();
		}
		Arrays.sort(a);
		Arrays.sort(u,(z,b)->Long.compare(z[1], b[1])); //Sorting by maximum value
		while (L<N) {
			if (u[R][1]>a[L]) {
				ans+=u[R][1]-a[L];
				u[R][0]--;
				if (u[R][0]==0) R--;
				if (R<0) break;
				L++;
			}else break; //Everything is worse off from here then since array is sorted
		}
		w.println(ans);
		w.flush();
	}
	public static long GCD(long a, long b) {
		if (a==0||b==0) return Math.max(a,b);
		return GCD(Math.min(a, b),Math.max(a, b)%Math.min(a, b));
	}
	public static long FastExp(long base, long exp, long mod) {
		long ans=1;
		while (exp>0) {
			if (exp%2==1) ans*=base;
			exp/=2;
			base*=base;
			base%=mod;
			ans%=mod;
		}
		return ans;
	}
	public static long ModInv(long num,long mod) {return FastExp(num,mod-2,mod);}
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}
}

Measured memory_bytes: 58036
#include <stdio.h>
int main(void){
  int n;  scanf("%d", &n);
  int a[21], b[51], c[51], sumb=0;
  
  for(int i=1; i<=n; i++)
    scanf("%d", &a[i]);
  for(int i=1; i<=n; i++){
    scanf("%d", &b[i]);
   	sumb += b[i];
  }
  for(int i=1; i<n; i++)
    scanf("%d", &c[i]);
  
  for(int i=1; i<=n-1; i++){
    if(a[i]+1 == a[i+1])
      sumb += c[a[i]];
  }
  
  printf("%d", sumb);
  
  return 0;
}
      

Measured memory_bytes: 128
#include<stdio.h>

int main(){

    long N=0;
    int K=0;
    int h[100001]={};
    long can=0;
    scanf("%ld %d",&N,&K);
    
    for(int i=0;i<N;i++){
        scanf("%d",&h[i]);
    }

    for(int i=0;i<N;i++){
        if(h[i]>=K){
            can++;
        }
    }

    printf("%ld\n",can);

    return 0;
}

Measured memory_bytes: 512
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstdint>
#include <functional>

int main() {
  int N;
  scanf("%d", &N);

  std::vector<int> a(N);
  for (int i=0; i<N; ++i)
    scanf("%d", &a[i]);

  std::sort(a.begin(), a.end(), std::greater<int>());
  int res=0;
  int sgn=1;
  for (int i=0; i<N; ++i) {
    res += sgn*a[i];
    sgn = -sgn;
  }
  printf("%d\n", res);
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <unordered_map>

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

  int n;
  std::cin>>n;

  std::unordered_map<std::string,int> map;

  std::string s;
  for(int i=0;i!=n;i++)
  {
    std::cin>>s;
    map[s]++;
  }

  std::cout<<
    "AC x "<<map["AC"]<<"\n"
    "WA x "<<map["WA"]<<"\n"
    "TLE x "<<map["TLE"]<<"\n"
    "RE x "<<map["RE"]<<std::endl;

  return 0;
}

Measured memory_bytes: 3668
import sys

N,M = map(int,input().split())

AB = [list(map(int,input().split())) for _ in range(N)]

AB.sort()

#print(AB)

total_buttle = 0
total_cost = 0
for _ in range(N):
    total_buttle = total_buttle + AB[_][1]
    if (total_buttle >= M):
        total_cost = total_cost + AB[_][0]*AB[_][1] - AB[_][0]*(total_buttle-M)
        #print(total_buttle,total_cost)
        #print(total_buttle,M)
        break

    total_cost = total_cost + AB[_][0]*AB[_][1]


print(total_cost)


Measured memory_bytes: 29428
//------------------------------>> tsukasa_diary's template <<------------------------------//
#include <bits/stdc++.h>
using namespace std;

#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define allof(a) (a).begin(),(a).end()
using lint = long long;
template< typename T > using Vec = vector< T >;

template< typename T > bool inRange(T x, T lb, T ub) { return lb <= x && x < ub; }
template< typename T > bool inRange(T x, T y, T lb, T ub) { return in_range(x, lb, ub) && in_range(y, lb, ub); }
template< typename T > void modAdd(T& a, T b, T mod) { a = (a + b + mod) % mod; }
template< typename T > void modMul(T& a, T b, T mod) { a = (a * b) % mod; }
template< typename T > void minUpdate(T& a, T b) { a = min(a, b); }
template< typename T > void maxUpdate(T& a, T b) { a = max(a, b); }
inline int bitCount(int x) { return __builtin_popcount(x); }
inline int bitCount(lint x) { return __builtin_popcountll(x); }

const int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
const int Dx[8] = {0,1,1,1,0,-1,-1,-1}, Dy[8] = {-1,-1,0,1,1,1,0,-1};
const double PI = acos(-1);

//--------------8---------------->> coding space <<-----------------8-------------//

int N;
Vec< Vec< int > > adj;
int c[10004], ans[10004];

void dfs(int v, int& i, int p) {
	ans[v] = c[i++];
	for (int u : adj[v]) if (u != p) dfs(u, i, v);
}

int main() {
	cin >> N;
	adj.assign(N, Vec< int >());
	for_(i,0,N-1) {
		int a, b;
		cin >> a >> b;
		--a; --b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	for_(i,0,N) cin >> c[i];
	
	sort(c, c+N);
	reverse(c, c+N);
	
	int M = accumulate(c, c+N, int());
	M -= c[0];
	cout << M << endl;
	
	for_(v,0,N) {
		if (adj[v].size() == 1) {
			int i = 0;
			dfs(v, i, -1);
			break;
		}
	}
	
	for_(i,0,N) cout << ans[i] << (i<N-1 ? " " : "\n");
}
//--------------8---------------->> coding space <<-----------------8-------------//

Measured memory_bytes: 1408
import sys
from math import log2,floor,ceil,sqrt
# import bisect
# from collections import deque

Ri = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()
 
def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
INF = 10 ** 18
MOD = 10**9+7

k = int(ri())
s = ri()
if len(s) <= k:
    print(s)
else:
    print(s[:k]+"...")



Measured memory_bytes: 62248
#include <bits/stdc++.h>
#define f(i,n) for(int i=0;i<n;i++)
#define P pair<int,int>
#define F first
#define S second
#define int long long
#define mod 1000000007
#define mmod 998244353
#define all(v) v.begin(), v.end()
#define INF LLONG_MAX/3
using namespace std;
int mypow(int a, int b, int c) {
	if (b == 0)return 1;
	if (b % 2)return mypow(a, b - 1, c)*a%c;
	int z = mypow(a, b / 2, c);
	return z * z%c;
}
int x[15][1010];
signed main() {
	int a, b, c, ans = INF;
	cin >> a >> b >> c;
	f(i, a) {
		string s;
		cin >> s;
		f(j, b) {
			x[i + 1][j + 1] = s[j] - '0';
			x[i + 1][j + 1] += x[i + 1][j];
		}
	}
	f(j, b) {
		f(i, a) {
			x[i + 1][j + 1] += x[i][j + 1];
		}
	}
	f(k, mypow(2, a-1, mod)) {
		int z = k, cnt = 0;
		vector<int> v;
		v.push_back(0);
		f(i, a-1) {
			if (z % 2) {
				v.push_back(i + 1);
				cnt++;
			}
			z /= 2;
		}
		v.push_back(a);
		int e = 0;
		for (int j = 1; j < b; j++) {
			for (int i = 1; i < v.size(); i++) {
				if (x[v[i-1]][e] + x[v[i]][j] - x[v[i]][e] - x[v[i-1]][j] > c)goto loop;
				if (x[v[i-1]][e] + x[v[i]][j + 1] - x[v[i]][e] - x[v[i-1]][j + 1] > c) {
					cnt++;
					e = j;
				}
			}
		}
		ans = min(ans, cnt);
	loop:;
	}
	cout << ans << endl;
}

Measured memory_bytes: 512
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    final int k = scanner.nextInt();
    final int x = scanner.nextInt();
    if(500 * k >= x) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}


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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(condition) if(condition){cout << "POSSIBLE" << endl;}else{cout << "IMPOSSIBLE" << endl;}
#define Possible(condition) if(condition){cout << "Possible" << endl;}else{cout << "Impossible" << endl;}
#define possible(condition) if(condition){cout << "possible" << endl;}else{cout << "impossible" << endl;}
#define Size(n) (n).size()

typedef long long ll;


using namespace std;

const int INF = 1e9,MOD = 1e9 + 7,ohara = 1e6;
const ll LINF = 1e18;


long long int n,cnt=0,ans=0,a=0,b=0,c=0,d,cmp,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl=true;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

      
      cin>>n;
      rep(i,n){
        cin>>d;
        if(d%4==0)a++;
        else if(d%2==0)b++;
        else c++;
      }
     if(b)b=1;
     b+=c;
     if(a+1>=b)Cout("Yes");
     else Cout("No");
     

       
return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)
from collections import deque

INF = 10**9
H,W = map(int,input().split())
G = [input() for _ in range(H)]
C = 0
for l in G:
    C += l.count("#")

def BFS(start,end,grid):
    queue = deque([])
    visited = []
    start += [1]
    dist = INF
    queue.append(start)
    while queue:
        label = queue.popleft()
        x = label[0]
        y = label[1]
        d = label[2]
        pos = [x,y]
        if pos == end:
            if d < dist:
                dist = d
        elif pos not in visited:
            visited.append(pos)
            if x+1 <= W-1:
                if [x+1,y] not in visited:
                    if grid[y][x+1] == ".":
                        queue.append([x+1,y,d+1])
            if x-1 >= 0:
                if [x-1,y] not in visited:
                    if grid[y][x-1] == ".":
                        queue.append([x-1,y,d+1])
            if y+1 <= H-1:
                if [x,y+1] not in visited:
                    if grid[y+1][x] == ".":
                        queue.append([x,y+1,d+1])
            if y-1 >= 0:
                if [x,y-1] not in visited:
                    if grid[y-1][x] == ".":
                        queue.append([x,y-1,d+1])
    return dist
res = BFS([0,0],[W-1,H-1],G)
if res == INF:
    print(-1)
else:
    print(H*W-res-C)

Measured memory_bytes: 41948