akhauriyash/Code-Regression huggingface dataset:
/**
*    created: 05.07.2020 17:48:14
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b) {if (b < a) {a = b; return 1;} return 0;}
const long double pi = acos(-1.0);
const int INF = 1LL << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;
    if (n >= 64) cout << 64 << endl;
    else if (n >= 32) cout << 32<< endl;
    else if (n >= 16) cout << 16 << endl;
    else if (n >= 8) cout << 8 << endl;
    else if (n >= 4) cout << 4 << endl;
    else if (n >= 2) cout << 2 << endl;
    else cout << 1 << endl;
    return 0;
}

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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;
// const int mod = 998244353;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

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

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

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

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

int main() {
  int N;
  cin >> N;
  auto D = make_v< int >(N, 2);
  cin >> D;
  for(int i = 0; i + 2 < N; i++) {
    if(D[i][0] == D[i][1] && D[i + 1][0] == D[i + 1][1] && D[i + 2][0] == D[i + 2][1]) {
      cout << "Yes\n";
      return 0;
    }
  }
  cout << "No\n";
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define MAX_N 100011
#define N MAX_N
#define rank dfasfds
using namespace std;
typedef long long ll;
typedef vector<int> S;
int par[MAX_N],rank[MAX_N];
ll val[MAX_N];
S G[N];

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]);
}

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

void unite(int x,int y){
  x=find(x),y=find(y);
  if(x==y)return;
  if(rank[x]<rank[y])par[x]=y,val[y]+=val[x];
  else{
    par[y]=x;
    val[x]+=val[y];
    if(rank[x]==rank[y])rank[x]++;
  }
}

int used[N];
vector<int> path;
void dfs(int pos,int pre){
  if(used[pos]||pos!=find(pos)) {
    while(path.size())unite(0,path.back()),path.pop_back();
    return;
  }
  used[pos]=1;
  path.push_back(pos);

  for(S::iterator it=G[pos].begin();it!=G[pos].end();it++)if(*it!=pre)dfs(*it,pos);
  used[pos]=0;
  if(path.size()&&path.back()==pos) path.pop_back();
}

vector<int>col[N];
ll get_mx(int pos){
  pos=find(pos);
  used[pos]=1;
  ll res=0;
  
  for(int i=0;i<col[pos].size();i++)
    for(S::iterator it=G[col[pos][i]].begin();it!=G[col[pos][i]].end();it++)
      if(!used[find(*it)])res=max(res,get_mx(find(*it)));
  return res+val[find(pos)];
}

int main(){
  int n,m;
  cin>>n>>m;
  for(int i=0;i<n;i++) cin>>val[i];
  for(int i=0,a,b;i<m;i++){
    cin>>a>>b;a--,b--;
    G[a].push_back(b);
    G[b].push_back(a);

    //    G[a].insert(b);
    //  G[b].insert(a);
  }
  init(n);
  dfs(0,-1);
  for(int i=0;i<n;i++) col[find(i)].push_back(i);
  cout <<get_mx(find(0))<<endl;

  return 0;
}

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

int main(){
   string s[110];
   string d[4] = {"P","W","G","Y"};
   int res = 0;
   int n;

   cin>>n;

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

   bool four = true;

   for(int i  = 0;i < 4;){
        bool four = false;
        string a = d[i];
        for(int j= 0; j < n; j++){
            if(s[j] == a){
               res++;
               i++;
               four = true;
               break;
           }
       }
       if(!four) break;
   }

   if(res == 4) cout<<"Four\n";
   else cout<<"Three\n";


}
   

Measured memory_bytes: 256
import bisect
from collections import defaultdict

N = int(input())
As  = sorted(map(int, input().split()))
Bs  = sorted(map(int, input().split()))
Cs  = sorted(map(int, input().split()))

b_counts = []
for b in Bs[::-1]:
    count = len(Cs) - bisect.bisect(Cs, b)
    if len(b_counts) > 0:
        count += b_counts[-1]
    b_counts.append(count)
b_counts = b_counts[::-1]

total = 0
for a in As:
    i = bisect.bisect(Bs, a)
    if i >= len(Bs):
        continue
    total += b_counts[i]

print(total)

Measured memory_bytes: 23616
#include <stdio.h>


int main() {
    long long int n, sum=0, rem,p;
    scanf("%lld", &n);
        p=n;

        while(n!=0){
        rem=n%10;
        sum=sum+rem;
        n=n/10;
        }
        if(p%sum!=0)
            printf("No\n");
        else
            printf("Yes\n");

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
 
#define rep(i, n) for(int i = 0; i < n; i ++)
#define ALL(T) T.begin(), T.end()
#define mp make_pair
#define pb push_back
#define X first
#define Y second

using namespace std;
 
typedef pair<int, int> pii;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
 
int cnt, w, h;
int m[100][100];
const int dx[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
const int dy[8] = {-1, 0, 1, 1, 1, 0, -1, -1};

void dfs(pii);

int main(void){
    for(;cin >> w >> h, w; cout << cnt << endl){
        cnt = 0;
        rep(y, h) rep(x, w) cin >> m[y][x];
        rep(y, h) rep(x, w) if(m[y][x] == 1) cnt ++, dfs(mp(x, y));
    }
 
    return 0;
}

void dfs(pii p){
    if(p.X < 0 || w <= p.X ||
       p.Y < 0 || h <= p.Y) return;
    
    if(m[p.Y][p.X] == 1) m[p.Y][p.X] = 0;
    else return;

    rep(i, 8) dfs(mp(p.X + dx[i], p.Y + dy[i]));
}

Measured memory_bytes: 1252
gcd = lambda x,y: x if y==0 else gcd(y,x%y)

t = int(input())
for i in range(t):
    a,b,c,d = map(int,input().split())
    dx = d%b
    if a<b:
        print('No')
    elif d<b:
        print('No')
    elif c>=b:
        print('Yes')
    elif a%b>c:
        print('No')
    elif dx==0:
        print('Yes')
    else:
        if b - gcd(b,d) + a%gcd(b,d) > c:
            print('No')
        else:
            print('Yes')


Measured memory_bytes: 42224
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

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

  int a = s / 100;
  int b = s % 100;

  if(1 <= a  && a <= 12){
    if(1 <= b && b <= 12){
      cout << "AMBIGUOUS" << endl;
    }
    else{
      cout << "MMYY" << endl;
    }
  }
  else{
    if(1 <= b && b <= 12){
      cout << "YYMM" << endl;
    }
    else{
      cout << "NA" << endl;
    }
  }

  return 0;
}

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

int main(){
    int H,W;
    while(1){
        cin >> H >> W;
        if(H==0&&W==0) break;
        for(int i=1;H>=i;i++){
            for(int j=1;W>=j;j++){
                if((i+j)%2==0){
                    cout << "#";                    
                }
                else cout << ".";;
                if(W==j) cout << endl;
            }
        }
    cout << endl;
    } 
}


Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
int main()
 {
	int n,acc=0,tlec=0,wac=0,re=0;
	cin >> n;
	while(n--)
    {
        string s;
        cin >> s;
        if(s=="AC")
            acc++;
        else if(s=="WA")
            wac++;
        else if(s=="TLE")
            tlec++;
        else if(s=="RE")
            re++;
    }
    cout << "AC x " << acc << endl;
    cout << "WA x " << wac << endl;
    cout << "TLE x " << tlec << endl;
    cout << "RE x " << re << endl;
	return 0;
}


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

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

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

int main() {
	int n; scanf("%d", &n); std::vector<i64> a(n);
	for(int i = 0; i < n; i++) scanf("%lld", &a[i]);

	if(a.back() != 2) {
		printf("-1\n");
		return 0;
	}

	i64 L = 2, R = 3;
	reverse(begin(a), end(a));
	for(auto A: a) {
		L = (L + A - 1) / A * A;
		R = (R + A - 1) / A * A;
		
		if(R - L < 1) {
			printf("-1\n");
			return 0;
		}
	}
	printf("%lld %lld\n", L, R - 1);
	return 0;
}


Measured memory_bytes: 1024
#include <string>
#include <iostream>
using namespace std;
string s, t;
string solve(int sl, int sr, int tl, int tr) {
	if (sl == sr || tl == tr) return "";
	int d1 = 0, sp = -1;
	for (int i = sl; i < sr; i++) {
		if (s[i] == '(') d1++;
		if (s[i] == ')') d1--;
		if (d1 == 0) {
			sp = i; break;
		}
	}
	int d2 = 0, tp = -1;
	for (int i = tl; i < tr; i++) {
		if (t[i] == '(') d2++;
		if (t[i] == ')') d2--;
		if (d2 == 0) {
			tp = i; break;
		}
	}
	int sv = 0, se = -1; sp++;
	for (se = sp + 1; s[se] >= '0' && s[se] <= '9'; se++) sv = sv * 10 + (s[se] - 48); se++;
	int tv = 0, te = -1; tp++;
	for (te = tp + 1; t[te] >= '0' && t[te] <= '9'; te++) tv = tv * 10 + (t[te] - 48); te++;
	string retl = solve(sl + 1, sp - 1, tl + 1, tp - 1);
	string retr = solve(se + 1, sr - 1, te + 1, tr - 1);
	return "(" + retl + ")[" + to_string(sv + tv) + "](" + retr + ")";
}
int main() {
	cin >> s >> t;
	cout << solve(0, s.size(), 0, t.size()) << endl;
	return 0;
}

Measured memory_bytes: 3288
#include<iostream>
using namespace std;
int main()
{
    // スペース区切りの整数の入力
    int a,b,c,d,e,len,tmp,answer;
	cin >> a >> b;
    c=a+b;
    d=a-b;
    e=a*b;

	int sort[] = {c,d,e};
  len=sizeof(sort) / sizeof(0);
  for(int i=0; i<len; i++){
    for (int j=len-1; j>i; j--){
      if (sort[j]<sort[j-1]){
         tmp=sort[j];
         sort[j]=sort[j-1];
        sort[j-1]=tmp;
      }
    }
  }
  
    cout << sort[2] << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define w(t) int t;cin>>t;while(t--)
#define pb   push_back
#define mk   make_pair
#define u_s  unordered_set
#define endl "\n"
#define prDouble(x) cout<<fixed<<setprecision(10)<<x
#define ll long long int
#define ipair pair<int,int>
#define all(x) (x).begin(), (x).end()

const int mod=pow(10,9)+7;

bool compare(pair<int,int>p1,pair<int,int>p2){
    return p1.second<p2.first;
}
void open_file(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
}
void fast_io(){
    ios_base::sync_with_stdio(false); 
    cin.tie(nullptr); 
    cout.tie(nullptr);
      
}
/*
  ll C(ll n,ll k){
  
  if(k>n)return 0;
  
  ll ans=1;

  if(k>n-k)
    k=n-k;
  for(ll i=1;i<=k;i++)
    ans*=(n-i+1),ans/=i;

  return ans;
  }
  unsigned long long fact(long long a)
  {
  unsigned long long res=1;
  for(long long i=a;i>0;i--)
    res*=i;
  return res;
  }
  unsigned long long comb(long long a,long long b)
  {
  if((a-b)<b) b=a-b;
  if(a<=19) return fact(a)/(fact(a-b)*fact(b));
  if(a==b||b==0) return 1;
  if(b==1) return a;
  return comb(a-1,b-1)+comb(a-1,b);
  }
*/

double dp[3001][3001];

double solve(vector<double>&A,int i,int x){
     
    if(x==0)
      return 1;
    if(i==0)
      return 0;

    if(dp[i][x]>-0.9)return dp[i][x];

    return dp[i][x]=A[i]*solve(A,i-1,x-1)+(1-A[i])*solve(A,i-1,x);

}
int main(){

  
  fast_io();
  
    int n; cin>>n; vector<double>A(n+1);
    memset(dp,-1,sizeof dp);

    for(int i=1;i<=n;i++)cin>>A[i];
    prDouble(solve(A,n,(n+1)/2));
    return 0;  
    
}


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_V 111

int n,m,l,k,a,h;
bool rf[111];
int d[111][111];

int main(){
	cin.sync_with_stdio(false);
	while(1){
		cin>>n>>m>>l>>k>>a>>h;
		if(n==0)break;
		memset(rf,0,sizeof(rf));
		rep(i,l){
			int r;
			cin>>r;
			rf[r]=true;
		}
		vector<P> G[111];
		rep(i,k){
			int v,u,t;
			cin>>v>>u>>t;
			G[v].pb(P(u,t)); G[u].pb(P(v,t));
		}
		rep(i,111)rep(j,111)d[i][j]=INF;
		priority_queue<PPI,vector<PPI>,greater<PPI> > que;
		que.push(PPI(P(0,m),a));
		d[a][m]=0;
		while(!que.empty()){
			int v=que.top().se,dist=que.top().fi.fi,rest=que.top().fi.se;que.pop();
			if(d[v][rest]<dist)continue;
			if(!rf[v]){
				rep(i,G[v].size()){
					int nv=G[v][i].fi, ncost=G[v][i].se;
					if(rest-ncost>=0&&d[nv][rest-ncost]>d[v][rest]+ncost){
						d[nv][rest-ncost]=d[v][rest]+ncost;
						que.push(PPI(P(d[v][rest]+ncost,rest-ncost),nv));
					}
				}
			}else{
				rep(i,G[v].size()){
					int nv=G[v][i].fi, ncost=G[v][i].se;
					repl(nrest,rest,m+1){
						if(nrest-ncost>=0&&d[nv][nrest-ncost]>d[v][rest]+ncost+(nrest-rest)){
							d[nv][nrest-ncost]=d[v][rest]+ncost+(nrest-rest);
							que.push(PPI(P(d[v][rest]+ncost+(nrest-rest),nrest-ncost),nv));
						}
					}
				}
			}
		}
		int res=INF;
		rep(i,111)minch(res,d[h][i]);
		if(res==INF)cout<<"Help!"<<endl;
		else cout<<res<<endl;
	}
	return 0;
}

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

ll gcd(ll a, ll b) { return b ? gcd(b,a % b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b;}

int main() {
    ll n, m;
    string s, t;
    cin >> n >> m >> s >> t;
    ll l = lcm(n, m);
    ll p = l / n;
    ll q = l / m;
    ll l2 = lcm(p, q);
    for (int i = 0; i < l / l2; ++i) {
        if (s[l2 * i / p] == t[l2 * i / q]) continue;
        cout << -1 << endl;
        return 0;
    }
    cout << l << endl;
}


Measured memory_bytes: 512
N = int(input())
A = [int(a) for a in input().split()]
B = [int(b) for b in input().split()]

defeated = 0
for i in range(N):
    if B[i] <= A[i]:
        defeated += B[i]
    else:
        defeated += A[i]
        B[i] -= A[i]
        if B[i] <= A[i+1]:
            defeated += B[i]
            A[i+1] -= B[i]
        else:
            defeated += A[i+1]
            A[i+1] = 0
print(defeated)

Measured memory_bytes: 18624
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int a[10];
int main()
{
	for(int i=1;i<=4;i++) scanf("%d",&a[i]);
	sort(a+1,a+4+1);
	//for(int i=1;i<=4;i++) printf("%d ",a[i]);
	if(a[1]==1&&a[2]==4&&a[3]==7&&a[4]==9) printf("YES");
	else printf("NO");
}

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

using lint = long long int;
using pii = std::pair<int, int>;

lint ans[510][510];

int main(void) {
	int H, W, h, w;
	scanf("%d %d %d %d", &H, &W, &h, &w);

	if (H % h == 0 && W % w == 0) {
		printf("No");
	}
	else {
		printf("Yes\n");
		for (int i = 1; i <= H; i++) {
			for (int j = 1; j <= W; j++) {
				ans[i][j] = 1000;
			}
		}
		for (int i = h; i <= H; i += h) {
			for (int j = w; j <= W; j += w) {
				ans[i][j] = (h * w - 1) * (-1000);
				ans[i][j]--;
			}
		}
		for (int i = 1; i <= H; i++) {
			for (int j = 1; j <= W; j++) {
				printf("%d ", ans[i][j]);
			}
			printf("\n");
		}
	}

	return 0;
}

Measured memory_bytes: 3584
// ???
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

ll modpow(ll a, ll b, ll p = 1e9+7){
    if(b == 0)  return 1;

    if(b % 2 == 0){
        ll d = modpow(a, b/2, p);
        return (d*d) % p;
    }else{
        return (a%p * modpow(a, b-1, p)) % p;
    }
}

struct ModComb{
    vector<ll> po, inv;
    ll N;

    ModComb(ll n) : N(n), po(n), inv(n) {
        po[0] = 1;
        for(int i = 1; i < N; i++)  po[i] = (po[i-1] * i) % mod;
        inv[N-1] = modpow(po[N-1], mod-2, mod);
        for(int i = N-2; i >= 0; i--)   inv[i] = (inv[i+1] * (i+1)) % mod;
    }
    
    ll nCk(ll n, ll k){
        if(k == 0)  return 1;
        if(n < k)   return 0;
        return (((po[n]*inv[n-k])%mod)*inv[k])%mod;
    }

    ll nPk(ll n, ll k){
        if(k == 0)  return 1;
        if(n < k)   return 0;
        return (po[n]*inv[n-k])%mod;
    }

    ll nHk(ll n, ll k){
        if(n == 0 && k == 0)    return 1;
        return nCk(n+k-1, k-1);
    }
};

int main(){
    int n;
    cin >> n;
    vector<int> v(n);
    for(int i = 0; i < n; i++)  cin >> v[i];
    sort(v.begin(), v.end());
    ModComb mc(n+1);
    vector<ll> two(n+1, 1), four(n+1, 1);
    for(int i = 1; i <= n; i++){
        two[i] = two[i-1]*2%mod;
        four[i] = four[i-1]*4%mod;
    }
    ll ans = 0;
    for(int i = 0; i < n; i++){
        ll tmp = two[n-1-i]*four[i+1]%mod;
        int x = n-i-1+1;
        ll y = two[x-1]+ (x-1)*(x-2 >= 0 ? two[x-2] : 0);
        y %= mod;
        ans += v[i]*tmp%mod*y%mod;
        ans %= mod;
    }
    cout << ans*modpow(2,mod-2,mod)%mod << endl;
    return 0;
}

Measured memory_bytes: 7296
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> x(n), y(n);
    rep(i,n){
        cin >> x[i];
        y[i] = x[i];
    }
    sort(y.begin(), y.end());
    int l = y[n/2 - 1], r = y[n/2];
    rep(i,n){
        if(x[i] <= l) cout << r << endl;
        else cout << l << endl;
    }
    return 0;
}


Measured memory_bytes: 4748
#include <iostream>
#include <cstdio>
#include <string>

using namespace std;

int main() {
    // char S[15];
    // char T[1000];
    string S;
    string T;
    cin >> S;
    int cnt = 0;
    while(1) {
        cin >> T;
        if(T == "END_OF_TEXT") break;
        for(int i = 0; i < T.length(); i++) {
            if(T[i] >= 'A' && T[i] <= 'Z') {
                T[i] += 32;
            }
        }
        if(T == S) cnt++;
    }
    cout << cnt << endl;
    return 0;
}


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

string dp2[310][310];
int dp[310][310];

int main()
{
	string s;
	while (cin >> s){
		if (s == "#END")return 0;
		int res = 0, id = 0;
		for (int k = 1; k < s.length(); ++k){
			string s1 = s.substr(0, k);//从头到k的子序列
			string s2 = s.substr(k);//从k往后的子序列
			memset(dp, 0, sizeof dp);
			for (int i = 0; i < s1.length(); ++i){
				for (int j = 0; j < s2.length(); ++j){
					if (s1[i] == s2[j])dp[i + 1][j + 1] = dp[i][j] + 1;
					else dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i + 1][j]);
				}
			}
			if (res < dp[s1.length()][s2.length()]){
				res = dp[s1.length()][s2.length()];
				id = k;
			}
		}
		//从id处分隔字符串
		string s1 = s.substr(0, id);
		string s2 = s.substr(id);
		for (int i = 0; i <= s1.length(); ++i){
			for (int j = 0; j <= s2.length(); ++j)dp2[i][j] = "";
		}
		for (int i = 0; i < s1.length(); ++i){
			for (int j = 0; j < s2.length(); ++j){
				if (s1[i] == s2[j])dp2[i + 1][j + 1] = dp2[i][j] + s1[i];
				else{
					if (dp2[i][j + 1].size() <= dp2[i + 1][j].size())dp2[i + 1][j + 1] = dp2[i + 1][j];
					if (dp2[i][j + 1].size() > dp2[i + 1][j].size())dp2[i + 1][j + 1] = dp2[i][j + 1];
				}
			}
		}
		cout << dp2[s1.size()][s2.size()] << endl;
	}
	return 0;
}


Measured memory_bytes: 6700
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n = I()
    if n == 1:
        return "a"
    r = []
    def f(t, k):
        u = chr(ord(k)+1)
        lf = len(t) == n - 1
        for c in string.ascii_lowercase:
            if c > u:
                break
            if lf:
                r.append(JA(t+[c], ""))
            else:
                if c > k:
                    f(t+[c], c)
                else:
                    f(t+[c], k)
    f(['a'], 'a')

    return JA(r, "\n")


print(main())





Measured memory_bytes: 17860
#include <bits/stdc++.h>
#define fore(i,a,b) for(int i=int(a); i < int(b); i++)
#define foro(i,a,b) for(int i=int(a); i >= int(b); i--)
 
using namespace std;
 
int main(){
	int N; cin >> N;
	
	string S, T;
	
	cin >> S >> T;
	
	string answer;
	
	fore(i,0,N){
		answer += S[i];
		answer += T[i];
	}
	
	cout << answer;
	
	return 0;
}

Measured memory_bytes: 256
s = input()
ans = 0
if s[0] == "R":
    ans += 1
    if s[1] == "R":
        ans += 1
        if s[2] == "R":
            ans += 1
elif s[1] == "R":
    ans += 1
    if s[2] == "R":
        ans += 1
elif s[2] == "R":
    ans += 1
print(ans)

Measured memory_bytes: 9060
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)
	var memo map[int]int
	memo = map[int]int{}
	sosu := true
	iti := false
	if N == 1 {
		iti = true
	}
	// fmt.Println(N)
	for i:=2; i * i <= N; i++ {
		if N % i == 0{
			target := i
			check := true
			for check {
				check = false
				for j, value := range memo {
					if target%j == 0 {
						target = target / j
						memo [j] = value + 1
						check = true
						break
					}
				}
			}
			if target != 1 {
				// fmt.Println(target)
				memo[target] = 1
				sosu = false
			}
			N = N/i
		}
	}
	target := N
	check := true
	for check {
		check = false
		// fmt.Println(memo,target)
		for j, value := range memo {
			// fmt.Println(j,value,target)
			if target%j == 0 {
				target = target / j
				memo [j] = value + 1
				check = true
				break
			}
		}
	}
	if target != 1 {
		// fmt.Println("check",target)
		memo[target] = 1
	}
	if sosu {
		if iti {
			fmt.Println(0)
		} else {
			fmt.Println(1)
		}
	} else {
		sum := 0
		for _,value := range memo {
			count := value
			for i:=1; i<=value; i++ {
				if count-i >= 0 {
					count -= i
					sum += 1
					// fmt.Println(sum,count,j)
				} else {
					break
				}
			}
		}
		fmt.Println(sum)
	}

}


Measured memory_bytes: 1848
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a%b==0){
    cout<<(c==0?"YES":"NO");
  }else{
    for(int i=1;i<=b;i++){
      if(a*i%b==c){
        cout<<"YES";
        return 0;
      }
    }
    cout<<"NO";
  }
}

Measured memory_bytes: 256
def setHeapDown_max(heap, pos):
    targetkey = heap[pos]
    while pos > 0:
        parentpos = (pos - 1) >> 1
        parent = heap[parentpos]
        if parent < targetkey:
            heap[pos] = parent
            pos = parentpos
            continue
        break
    heap[pos] = targetkey

def setHeapUp_max(heap, pos):
    endpos = len(heap)
    targetkey = heap[pos]
    childpos = 2*pos + 1
    while childpos < endpos:
        rightpos = childpos + 1
        if rightpos < endpos and not heap[rightpos] < heap[childpos]:
            childpos = rightpos
        childkey = heap[childpos]
        if targetkey > childkey:
            break
        heap[pos] = childkey
        pos = childpos
        childpos = 2*pos + 1
    heap[pos] = targetkey

def heapPush_max(heap, key):
    heap.append(key)
    setHeapDown_max(heap, len(heap) - 1)

def heapPop_max(heap):
    lastkey = heap.pop()
    if heap:
        returnkey = heap[0]
        heap[0] = lastkey
        setHeapUp_max(heap, 0)
        return returnkey
    return lastkey


import sys

S = []

for x in sys.stdin.readlines():
    if x[0] == 'i':
        k = int(x[7:])
        heapPush_max(S, k)
    elif x[1] == 'x':
        print(heapPop_max(S))
    else:
        pass

Measured memory_bytes: 189316
#include <cstdio>
#include <cstring>
#include <iostream>

using namespace std;

#define LL long long
#define reg register
#define debug(x) cerr<<#x<<" = "<<x<<endl;
#define rep(a,b,c) for(reg int a=(b),a##_end_=(c); a<=a##_end_; ++a)
#define ret(a,b,c) for(reg int a=(b),a##_end_=(c); a<a##_end_; ++a)
#define drep(a,b,c) for(reg int a=(b),a##_end_=(c); a>=a##_end_; --a)

inline int Read() {
	int res=0,f=1;
	char c;
	while(c=getchar(),c<48||c>57)if(c=='-')f=0;
	do res=(res<<3)+(res<<1)+(c^48);
	while(c=getchar(),c>=48&&c<=57);
	return f?res:-res;
}

template<class T>inline bool Min(T &a,T const&b) {
	return a>b?a=b,1:0;
}
template<class T>inline bool Max(T &a,T const&b) {
	return a<b?a=b,1:0;
}

const int N=1e4+5;

char S[5];

int f=0;

int main() {
	int n=Read(),a=Read(),b=Read();
	cout<<min(b,n*a);
	
//	if(f)puts("Yes");
//	else puts("No");
	return 0;
}

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

ll const INF = -1e+10;

int main(){
	int N;
	cin >> N;
	vector<ll> A(N);
	rep(i,N){
		cin >> A[i];
	}
	
	ll dp[100005][2];
	
	dp[0][0] = A[0];
	dp[0][1] = -A[0];
	
	REP(i,N-1){
		dp[i][0] = max(A[i]+dp[i-1][0], -A[i]+dp[i-1][1]);
		dp[i][1] = max(-A[i]+dp[i-1][0], A[i]+dp[i-1][1]);
	}
	
	cout << dp[N-1][0] << endl;
	
    return 0;
}

Measured memory_bytes: 2560
N = int(input())
H = list(map(int,input().split()))

cnt = 0
ret = 0
for i in range(N-1):
  if H[i] >= H[i+1]:
    cnt += 1
  else:
    ret = max(cnt,ret)
    cnt = 0
  if i == N-2:
    ret = max(cnt,ret)
print(ret)


Measured memory_bytes: 15020
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repp(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;

const int MAX_N = 1000000;

vector<int> prime;
bool is_prime[MAX_N + 1];
void sieve(int n){
    for(int i = 0; i <= n; i++) is_prime[i] = true;
    is_prime[0] = is_prime[1] = false;
    for(int i = 2; i <= n; i++){
        if(is_prime[i]){
            prime.push_back(i);
            for(int j = 2*i; j <= n; j += i) is_prime[j] = false;
        }
    }
}

signed main(){
    sieve(MAX_N);
    //rep(i,0 , 100) cout << prime[i] << endl;
    int n, p;
    while(1){
        cin >> n >> p;
        if(n == -1 && p == -1) break;
        vector<int> sum;
        int ind = upper_bound(all(prime), n) - prime.begin();
        //cout << ind << endl;
        rep(i ,0 ,p){
            rep(j, i, p){
                int tmp = prime[ind + i] + prime[ind + j];
                //cout << tmp << endl;                
                sum.push_back(tmp);
            }
        }
        sort(all(sum));
        cout << sum[p - 1] << endl;
    }
}

Measured memory_bytes: 2960
import java.util.Scanner;


public class Main {
    static Scanner sc = new Scanner(System.in);


    public static void main(String[] args) {
        int n = sc.nextInt();
        int sum = 0;
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            int value = sc.nextInt();
            a[i] = value;
            sum += value;
        }
        int avg = (int) Math.round((double) sum / n);
        int ans = 0;
        for (int i = 0; i < n; i++) {
            ans += Math.pow(a[i] - avg, 2);
        }
        System.out.println(ans);
    }

}


Measured memory_bytes: 23380
import java.util.*;


public class Main{

	public static void main(String args[]){

		Scanner s = new Scanner(System.in);
		int num1 = s.nextInt();
		int num2 = s.nextInt();
		int surplus = 0;
		int i = 0;


		while( i < 100000000){
			if(num1>=num2){
				surplus = num1%num2;
				num1 = num2;
				num2 = surplus;
				if(surplus == 0){
					System.out.println(num1);
					break;
				}else{
					i++;
				}

			}else if(num2>=num1){
				surplus = num2%num1;
				num1 = num2;
				num2 = surplus;
				if(surplus == 0){
					System.out.println(num2);
					break;
				}else{
					i++;
				}
			}
		}
	}
}


Measured memory_bytes: 26304
#include <iostream>
#include <stdlib.h>
using namespace std;
int main(void){
	int N,L;
	cin >>  N >> L;
	int taste;
	long int total = 0;
	int min = L;
	for(int i=1; i <= N; ++i){
		taste = L+i-1;
		total+=taste;
		if(abs(taste)<abs(min)){
			min =taste;
		}
	}
	cout << (long)(total - min)<< endl;
	return 0;
}

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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

using ll=long long;
using ld=long double;
using pii=pair<int, int>;
using vi=vector<int>;
using vii=vector<vector<int>>;

const ll LINF=1LL<<60;
const int INF=1<<29;
const int MOD=1e9+7;


int main(){
    int k; cin >> k;
    for(int i=0; i<k; i++){
        cout << "ACL";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n,a,b,cnt=0,cntt=1;
  string s;
  cin >> n >> a >> b >> s;
  bool f[n];
  for(int i=0;i<n;i++){
    f[i]=true;
  }
  for(int i=0;i<n;i++){
    if(s[i]=='a'){
      if(cnt>=a+b){
        f[i]=false;
      }else{
        cnt++;
      }
    }else if(s[i]=='b'){
      if(cnt>=a+b){
        f[i]=false;
      }else{
        if(cntt<=b){
          cnt++;
          cntt++;
        }else{
          f[i]=false;
        }
      }
    }else{
      f[i]=false;
    }
  }
  for(int i=0;i<n;i++){
    cout << ((f[i])?"Yes":"No") << endl;
  }
  return 0;
}


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

int main(){
	int N;
	cin >> N;
	vector<pair<long long,long long>> xy;
	for(int i=0;i<N;i++){
		int x,y;
		cin >> x >> y;
		xy.push_back(make_pair(x,y));
	}
	
	long long ans=0;
	long long maxsum=-1000000000,minsum=1000000000,maxdif=-1000000000,mindif=1000000000;
	
	for(int i=0;i<N;i++){
		long long x=xy[i].first,y=xy[i].second;
		maxsum=max(maxsum,x+y);
		minsum=min(minsum,x+y);
		maxdif=max(maxdif,x-y);
		mindif=min(mindif,x-y);
	}
	
	ans=max(maxsum-minsum,maxdif-mindif);
	cout << ans << endl;
	return 0;
}

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

int main(){
    int n,m;
    cin>>n>>m;
    vector<ll>x(n),y(n),z(n);
    rep(i,n)cin>>x[i]>>y[i]>>z[i];
    ll ans=0;
    rep(bit,1<<3){
        vector<ll>a(n);
        rep(i,n){
            if(bit&(1<<0))a[i]+=x[i];
            else a[i]-=x[i];
            if(bit&(1<<1))a[i]+=y[i];
            else a[i]-=y[i];
            if(bit&(1<<2))a[i]+=z[i];
            else a[i]-=z[i];
        }
        sort(a.rbegin(),a.rend());
        ll cnt=0;
        rep(i,m)cnt+=a[i];
        ans=max(ans,cnt);
    }
    cout<<ans<<endl;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

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

	REP(i, M){
		a[i]--;
		b[i] -= 2;

	}
	vector<pll> tui(M);
	REP(i, M){
		tui[i].first = b[i];
		tui[i].second = a[i];
	}
	sort(tui.begin(), tui.end());
	REP(i, M) swap(tui[i].first, tui[i].second);

	ll res = 0;
	ll k = 0;
	ll d = -1;
	while(k<M){
		if(d<tui[k].first){
			res++;
			d = tui[k].second;
		}
		k++;
	}

	cout << res << endl;

    return 0;
}

Measured memory_bytes: 3328
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int t = sc.nextInt();
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < n; i++) {
            int c = sc.nextInt();
            int tmp = sc.nextInt();
            if (tmp <= t) {
                min = Math.min(min, c);
            }
        }
        if (min == Integer.MAX_VALUE) {
            System.out.println("TLE");
        } else {
            System.out.println(min);
        }
    }
}


Measured memory_bytes: 21716
s=input()
t=input()
S=len(s)
T=len(t)
dp=[[0]*(T+1) for _ in range(S+1)]
for i in range(1,S+1):
    for j in range(1,T+1):
        dp[i][j] = max(dp[i-1][j],dp[i][j-1])
        if s[i-1]==t[j-1]:
            dp[i][j]=dp[i-1][j-1]+1
ans=""
x=S
y=T
l=dp[-1][-1]
while len(ans)<dp[-1][-1]:
    if dp[x][y-1]==l:
        y-=1
    elif dp[x-1][y]==l:
        x-=1
    else:
        ans+=t[y-1]
        x-=1
        y-=1
        l-=1
print(ans[::-1])

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

using namespace std;

int n,l;
int a[201];

int main()
{
    int ans = 0;
    scanf("%d%d",&n,&l);
    int te = 0x7f7f7f7f;
    int cou = 0;
    for(int i = 1;i <= n;i++)
    {
        a[i] = (l + i - 1);
        if(abs(a[i]) < te)
        {
            te = abs(a[i]);
            cou = i;
        }
    }
    for(int i = 1;i <= n;i++)
    {
        if(i != cou)
            ans += a[i];
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int
#define mk make_pair
#define pb push_back
#define ff first
#define ss second
#define ar array
#define del 1e-8

double pi=3.141592653589793238;
const int M = 1e9+7;
const int Nmax=5005;
const int MM = 998244353;
const int N=100001;

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int T=1;
	//cin>>T;
	while(T--){
      string s;
      cin>>s;
      if(s=="RRR")cout<<"3";
      else if(s=="RRS"||s=="SRR")cout<<"2";
      else if(s=="SSS")cout<<"0";
      else cout<<"1";
	}
	return 0;
}


Measured memory_bytes: 3608
#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <complex>
#include <iomanip>
using namespace std;
typedef long long LL;
void guan() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); }
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define ls (rt<<1)
#define rs (rt<<1|1)
#define F first
#define S second
#define mst(x,a) memset(x,a,sizeof(x))
#define Pr pair<int,int>
#define Prl pair<LL, LL>
#define Prd pair<double, double>
#define root 1,cnum,1
#define For(i,b,c) for(int i=b;i<=c;i++)
#define lowbit(x) (x&(-x))
const LL mod = 1e9 + 7;
const LL mod2 = mod - 1;
const int INF = 0x7FFFFFFF;
const LL LINF = 0x7FFFFFFFFFFFFFFF;
const double pi = acos(-1.0);
const LL maxx = 1LL<<61;
const double eps = 1e-8;

int n, m, q;
typedef struct EDGE {
    int v;
    int next;
}Edge;
const int maxn = 202020;
int t[maxn<<2];
vector<int> g[maxn];
vector<int> qu[maxn];
vector<int> id[maxn];
int ans[maxn];

void build(int l, int r, int rt) {
    t[rt] = 0;
    if(l == r) return ;
    int mid = l + r >> 1;
    build(lson);
    build(rson);
}

void change(int L, int R, int l, int r, int rt) {
    t[rt]++;
    if(L == l && R == r) return ;
    int mid = l + r >> 1;
    if(R <= mid) change(L, R, lson);
    else change(L, R, rson);
}

int query(int L, int R, int l, int r, int rt) {
    if(L == l && R == r) return t[rt];
    int mid = l + r >> 1;
    if(R <= mid) return query(L, R, lson);
    else if(mid < L) return query(L, R, rson);
    else return query(L, mid, lson) + query(mid + 1, R, rson);
}

void solve() {
    for(int i = 1;i <= n;i++) g[i].clear(), qu[i].clear(), id[i].clear();
    for(int i = 1, l, r;i <= m;i++) {
        scanf("%d%d", &l, &r);
        g[l].push_back(r);
    }
    for(int i = 1, l, r;i <= q;i++) {
        scanf("%d%d", &l, &r);
        qu[l].push_back(r);
        id[l].push_back(i);
    }
    int cnum = n;
    build(root);
    for(int i = n;i >= 1;i--) {
        for(auto r:g[i]) {
            change(r, r, root);
        }
        for(int j = 0;j < qu[i].size();j++) {
            ans[id[i][j]] = query(i, qu[i][j], root);
        }
    }
    for(int i = 1;i <= q;i++) printf("%d\n", ans[i]);
    //printf("%d\n", ans[q]);
}

void init() {
}
int main() {
    init();
    while(scanf("%d %d %d", &n, &m, &q) != EOF) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 19200
/// kAAzuki Hoshino
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define inf 1000000000
#define mod 1000000007
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple

int n,sum[202020];
string s;

signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  cin >> n >> s;
  s = " "+s;
  for(int i=1;i<=n;i++){
    if(i==0){
      if(s[i]=='.')sum[i+1]++;
      continue;
    }
    sum[i] = sum[i-1];
    if(s[i]=='.')sum[i]++;
  }
  int ans;
  ans = min( sum[n], n-sum[n] );
  for(int i=1;i<=n;i++){

    ans = min(ans,  (i-sum[i])+(( sum[n]-sum[i] )) );
  //cout << ans << endl;
  }
  cout << ans << endl;


return 0;
}
///....


Measured memory_bytes: 2128
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

i64 A,B,C,D,E;
int main(){
  cin >> A >> B >> C >> D >> E;

  i64 ans = 0;
  if(A < 0){
    ans += -A * C;
    A = 0;
  }

  if(A == 0){
    ans += D;
  }

  ans += (B - A) * E;

  cout << ans << endl;
}



Measured memory_bytes: 3092
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
template <typename T> using posteriority_queue = priority_queue<T, vector<T>, greater<T> >;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
template <typename T> void unique(vector<T> &a) { a.erase(unique(ALL(a)), a.end()); }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  int n; cin >> n;
  map<string, int> cnt;
  while (n--) {
    string s; cin >> s;
    ++cnt[s];
  }
  int mx = 0;
  for (auto pr : cnt) chmax(mx, pr.second);
  vector<string> ans;
  for (auto pr : cnt) {
    if (pr.second == mx) ans.emplace_back(pr.first);
  }
  sort(ALL(ans));
  for (string e : ans) cout << e << '\n';
  return 0;
}


Measured memory_bytes: 25584
using System;

namespace AOJ.Volume1
{
    public class ExitSurvey
    {
        public static int Main()
        {
            int n = int.Parse(Console.ReadLine());
            ulong sum = 0;
            for (int p = 0; p < n; p++)
            {
                sum += ulong.Parse(Console.ReadLine());
            }
            ulong ans = (ulong)Math.Floor((double)sum / n);
            Console.WriteLine(ans);
            return 0;
        }
    }
}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    set<int> st;
    int d;
    for (int i = 0; i < N; ++i) {
        cin >> d;
        st.insert(d);
    }
    cout << st.size() << endl;

    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

func Run(in io.Reader, out io.Writer) error {
	sc := bufio.NewScanner(in)

	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
	s := make(map[string]int, n)
	for i := 0; i < n; i++ {
		sc.Scan()
		s[sc.Text()]++
	}

	sc.Scan()
	m, _ := strconv.Atoi(sc.Text())
	t := make(map[string]int, m)
	for i := 0; i < m; i++ {
		sc.Scan()
		t[sc.Text()]++
	}

	var max = 0
	for name, scnt := range s {
		cnt := scnt - t[name]
		if cnt > max {
			max = cnt
		}
	}

	fmt.Fprintf(out, "%d\n", max)
	return nil
}

func main() {
	in, out := os.Stdin, os.Stdout
	Run(in, out)
}


Measured memory_bytes: 640
<?php

// https://atcoder.jp/contests/abc098/tasks/arc098_a
// 累積和

$n = intval(fgets(STDIN));
$str = trim(fgets(STDIN));

$count_e = [];
$count_w = [];

if ($str[0] === 'W') {
    $count_w[0] = 1;
} else {
    $count_w[0] = 0;
}

if ($str[$n - 1] === 'E') {
    $count_e[0] = 1;
} else {
    $count_e[0] = 0;
}

for ($i = 1; $i < $n; $i++) {
    if ($str[$i] === 'W') {
        $count_w[$i] = $count_w[$i - 1] + 1;
    } else {
        $count_w[$i] = $count_w[$i - 1];
    }

    if ($str[$n - $i - 1] === 'E') {
        $count_e[$i] = $count_e[$i - 1] + 1;
    } else {
        $count_e[$i] = $count_e[$i - 1];
    }
}

$count_e = array_reverse($count_e);

$min = $count_e[1];

for ($i = 1; $i < $n - 1; $i++) {
    $min = min($min, $count_w[$i - 1] + $count_e[$i + 1]);
}

$min = min($min, $count_w[$n - 1]);

echo $min . PHP_EOL;


Measured memory_bytes: 36584
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m; i >= n; --i)
#define ALL(v) (v).begin(),(v).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,q;cin >> a >> b >> q;
    vector<ll> s(a+2),t(b+2);
    s[0]=-INF,t[0]=-INF;
    s[a+1]=INF,t[b+1]=INF;
    REP(i,a){
        cin >> s[i+1];
    }
    REP(i,b){
        cin >> t[i+1];
    }
    REP(i,q){
        ll x;cin >> x;
        int u=lower_bound(ALL(s),x)-s.begin();
        int v=lower_bound(ALL(t),x)-t.begin();
        ll ans=INF;
        REP(j,2){
            REP(k,2){
                int p=u-j,q=v-k;
                chmin(ans,abs(s[p]-x)+abs(t[q]-s[p]));
                chmin(ans,abs(t[q]-x)+abs(s[p]-t[q]));
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 4688
n = gets.to_i
as = gets.split.map(&:to_i)

flag = true
i = 0
count = 0

while flag
  flag = false

  (n - 1).downto(i + 1) do |j|
    next unless as[j] < as[j - 1]

    as[j], as[j - 1] = as[j - 1], as[j]
    count += 1
    flag = true
  end

  i += 1
end

puts as.join(' ')
p count



Measured memory_bytes: 8880
def main():
    import sys
    input = sys.stdin.readline
    a, b = map(int, input().rstrip('\n').split())
    s = input().rstrip('\n')
    ls = list("1234567890")
    for i in range(len(s)):
        if i < a:
            if s[i] not in ls:
                print("No")
                exit()
        elif i == a:
            if s[i] != "-":
                print("No")
                exit()
        elif b <= i:
            if s[i] not in ls:
                print("No")
                exit()
    print("Yes")


if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

struct UnionFind{
    vector<ll> par;
    vector<ll> num;

    UnionFind(ll N):par(N),num(N){
        for(ll i=0;i<N;i++){
          par[i]=i;
          num[i]=1;
        }
    }

    ll root(ll x){
        if(par[x]==x){
          return x;
        }
        return par[x]=root(par[x]);
    }

    void unite(ll x,ll y){
        ll rx = root(x);
        ll ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
        num[ry] += num[rx];
    }

    bool same(ll x,ll y){
        ll rx = root(x);
        ll ry = root(y);
        return rx == ry;
    }
};

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

  ll N=in<ll>(),M=in<ll>();
  deque<pair<ll,ll>> AB;
  REP(i,M){
    ll a=in<ll>(),b=in<ll>();
    AB.emplace_front(a-1,b-1);
  }
  ll total=N*(N-1)/2;
  vector<ll> p;
  UnionFind u(N);
  for(auto itr=AB.begin();itr!=AB.end();++itr){
    p.push_back(total);
    ll a=itr->first,b=itr->second;
    if(!u.same(a,b)){
      ll v=u.num[u.root(a)]*u.num[u.root(b)];
      total -= v;
      u.unite(a,b);
    }
    //PRINTALL(u.num);
  }
  
  reverse(ALL(p));
  for(auto x:p) cout << x << endl;
  return 0;
}


Measured memory_bytes: 5496
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A, B, C;
  cin >> A >> B >> C;
  int result;
  if (A == B) result = C;
  else if (B == C) result = A;
  else result = B; 
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256