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

typedef long long ll;
typedef pair<int,int> P;

#define fr first
#define sc second

int main(){
	static int n;
	static int x[200010];
	scanf("%d",&n);
	for(int i = 0 ; i < n ; i ++){
		scanf("%d",&x[i]);
	}
	
	static vector<int> vec;
	for(int i = 0 ; i < n ; i ++){
		vec.push_back(x[i]);
	}
	sort(vec.begin(),vec.end());
	
	for(int i = 0 ; i < n ; i ++){
		int t = lower_bound(vec.begin(),vec.end(),x[i])-vec.begin();
		if(t < n/2){
			printf("%d\n",vec[n/2]);
		}
		else {
			printf("%d\n",vec[n/2-1]);
		}
	}
}



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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 1e5 + 5;

ll a[7];

void solve(){
	REP(i, 0, 7){
		cin >> a[i];
	}
	ll ans = a[1] + a[0] / 2 * 2 + a[3] / 2 * 2 + a[4] / 2 * 2;
	if (a[0] && a[3] && a[4]){
		ll ans1 = a[1] + 3;
		ans1 += (a[0] - 1) / 2 * 2 + (a[3] - 1) / 2 * 2 + (a[4] - 1) / 2 * 2;
		ans = max(ans, ans1);
	}
	cout << ans<< endl;
	
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 256
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

n = int(input())
a = list(map(int, input().split()))
l = [0]
l2 = [0]
for i in range(n):
    l.append(gcd(l[-1], a[i]))
for i in range(n-1, -1, -1):
    l2.append(gcd(l2[-1], a[i]))

ans = 0

for i in range(n):
    ans = max(ans, gcd(l[i], l2[n-i-1]))
print(ans)

Measured memory_bytes: 14076
import copy
N,M=[int(s) for s in input().split()]
TO=[set() for _ in range(N)]
Edges=[[int(s) for s in input().split()] for _ in range(M)]
for [a,b] in Edges:
  TO[a-1].add(b-1)
  TO[b-1].add(a-1)
ans=0
for [a,b] in Edges:
  to=copy.deepcopy(TO)
  to[a-1].remove(b-1)
  reach={a-1}
  while(reach):
    k=reach.pop()
    if k==b-1:
      break
    while(to[k]):
      m=to[k].pop()
      reach.add(m)
  else:
    ans+=1
print(ans)

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

int main() {
    int n, k;
    long long ans = 0, b[100001], s[100001];
    cin >> n >> k;
    b[0] = s[0] = 0;
    for(int i=1;i<=n;i++){
        long long a;
        cin >> a;
        b[i] = b[i-1];
        if(a>0)b[i] += a;
        s[i] = s[i-1] + a;
    }
    for(int i=k;i<=n;i++){
        long long r = b[n] - b[i] + b[i-k];
        r += max((long long)0, s[i] - s[i-k]);
        ans = max(ans, r);
    }
    cout << ans << endl;
    
	return 0;
}

Measured memory_bytes: 1792
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<ctime>
#include<cstdlib>
#include<sys/time.h>
#include<cstring>
#include<cmath>
using namespace std;
typedef long long ll;
inline int ri()
{
	register int x=0;register bool f=0;register char ch=getchar();
	while(ch>'9'||ch<'0'){if(ch=='-')f=1;ch=getchar();}
	while(ch<='9'&&ch>='0'){x=x*10+ch-'0';ch=getchar();};
	return f?-x:x;
}
void wi(ll x)
{
	if(x<0)	x=-x,putchar('-');
	if(x>9)	wi(x/10);
	putchar('0'+x%10);
}
char mm[10]="0MARCH";
char str[20];
ll cnt[200];
int main()
{
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	int n=ri(),i,j,k;
	ll ans=0;
	for(i=1;i<=n;i++)
	{
		scanf("%s",str+1);
		cnt[str[1]]++;
	}
	for(i=1;i<=5;i++)
		for(j=i+1;j<=5;j++)
			for(k=j+1;k<=5;k++)
			{
			//	if(i==j||j==k||i==k)	continue;
				ans+=cnt[mm[i]]*cnt[mm[j]]*cnt[mm[k]];
			}
	wi(ans);
	return 0;
}


Measured memory_bytes: 256
n = int(input())
u = [int(x) for x in input().split()]
d = [int(x) for x in input().split()]

s = u[0]+sum(d)
m = s
for i in range(n-1):
    s = s-d[i]+u[i+1]
    if m < s:
        m = s
print(m)


Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main() {
	int n, h, a, b, i;
	cin >> n >> h;
	vector<int> v;
	vector<int> vv;
	for (int i = 0; i < n; i++) {
		cin >> a >> b;
		v.push_back(a);
		vv.push_back(b);
	}
	v.push_back(0);
	vv.push_back(0);
	sort(vv.begin(), vv.end(), greater<>());
	int max = *max_element(v.begin(), v.end());
	a = 0;
	for (i = 0; vv[i] > max; i++) {
		a += vv[i];
		if (a >= h) { cout << i+1; break; }
	}
	if (a < h) {
		if ((h - a) % max == 0) { cout << (h - a) / max+i; }
		else { cout << (h - a) / max + 1+i; }
	}
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define range(a) a.begin(), a.end()
#define endl "\n"
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
using Graph = vector<vector<int>>;
const unsigned long long mod = 1e9 + 7;
const long long INF = 1LL<<60;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }

int main(void){
	ios::sync_with_stdio(0);
	cin.tie(0);
	ld a,b,c;	cin>>a>>b>>c;

	if(a+b+2*sqrtl(a*b)<c)	Yes();
	else No();


    return 0;
}




Measured memory_bytes: 3752
import itertools
import math
N = int(input())
hoge = list(range(N))
# for v in itertools.permutations(hoge, N):
#     print(v)
zyunban = list(itertools.permutations(hoge, N))
zahyo = [list(map(int, input().split())) for _ in range(N)]

ans = 0
for i in range(math.factorial(N)):
    tmp = zyunban[i]
    for i, j in enumerate(tmp):
        if i == 0:
            now_x, now_y = zahyo[j]
        else:
            ans += ((zahyo[j][0]-now_x)**2+(zahyo[j][1]-now_y)**2)**(1/2)
            now_x, now_y = zahyo[j]

print(ans/math.factorial(N))


Measured memory_bytes: 8100
#pragma warning(disable:4996)
#include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)
#define TPL template
#define TNM typename

using ll = long long;
using ull = unsigned long long;
TPL<TNM T> using vec = vector<T>;
TPL<TNM T> using vec2 = vec<vec<T>>;
TPL<TNM T> using vec3 = vec<vec2<T>>;
TPL<TNM T> using vec4 = vec<vec3<T>>;
TPL<TNM T> using vec5 = vec<vec4<T>>;

TPL<TNM K, TNM V> using umap = unordered_map<K, V>;
TPL<TNM K, TNM V> using uset = unordered_set<K, V>;

TPL<class T> inline void OUT(const T &x) { cout << x << "\n"; }
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(6); } } pre__;

TPL<TNM V, TNM H> void resize(vector<V>& v, const H h) { v.resize(h); }
TPL<TNM V, TNM H, TNM ... T> void resize(vector<V>& v, const H& h, const T ... t) { v.resize(h); for (auto& _v : v) resize(_v, t ...); }
TPL<TNM V, TNM T> void fill(V& x, const T& val) { x = val; }
TPL<TNM V, TNM T> void fill(vector<V>& vec, const T& val) { for (auto& v : vec) fill(v, val); }

int main(void) {
	ll N;
	cin >> N;
	vec<ll> A(N);
	vec<ll> B(N);
	REP(i, N) {
		cin >> A[i];
		B[i] = A[i] - i - 1;
	}
	sort(ALL(B));

	ll ans = 0;
	REP(i, N) {
		ans += abs(A[i] - i - 1 - B[N / 2]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define f(i,n) for(int i=0;i<n;i++)
#define F first
#define S second
#define P pair<int,int>
int x[100010];
signed main(){
	for(int i=3;i<100010;i+=2){
		for(int j=2;j*j<=i;j++){
			if(i%j==0||((i+1)/2)%j==0) goto mutu;
		}
		x[i]++;
		mutu:;
	}
	f(i,100009) x[i+1]+=x[i];
	int a,b,c;
	cin>>a;
	f(i,a){
		cin>>b>>c;
		cout<<x[c]-x[b-1]<<endl;
	}
	return 0;
}


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

signed main(){
  int N,M;
  cin >> N >> M;
  vector<int> A(N);
  vector<int> B(N);
  for(int i=0;i<N;i++){
    int a;
    cin >> a >> B.at(i);
    A.at(i)=100000*a+i;
  }
  sort(A.begin(),A.end());
  int money=0;
  for(int i=0;M>0;i++){
    int drink=A.at(i)/100000;
    int shop=A.at(i)%100000;
    int abi=B.at(shop);
    if(abi<=M){
      money+=abi*drink;
    }else{
      money+=M*drink;
    }
    M-=abi;
  }
  cout << money;
}

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

int main() {
	// your code goes here
	int n;
	cin>>n;
	set<string>s;
	for(int i=0;i<n;i++){
		string str;
		cin>>str;
		s.insert(str);
	}
	cout<<s.size();
	return 0;
}

Measured memory_bytes: 19228
#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;

typedef struct button{
  pii s, e;
  string link;
}button;

typedef struct window{
  string name;
  vector<button> b;
}window;

bool range(pii s, pii e, int w, int h){
  return s.first <= w and w <= e.first and
    s.second <= h and h <= e.second;
}

int main(){
  int n, m, l, W, H;
  while(std::cin >> n, n){
    vector<window> vw(n);
    map<string, int> next;
    std::cin >> W >> H;
    for (int i = 0; i < n; i++) {
      std::cin >> vw[i].name >> l;
      next[vw[i].name] = i;
      for (int j = 0; j < l; j++) {
        button tmp;
        std::cin >> tmp.s.first >> tmp.s.second
                 >> tmp.e.first >> tmp.e.second >> tmp.link;
        vw[i].b.push_back(tmp);
      }
    }
    std::cin >> m;
    string s;
    vector<string> buffer;
    buffer.push_back(vw[0].name);
    int pos = 0;
    for (int i = 0; i < m; i++) {
      std::cin >> s;
      if(s == "click"){
        int w, h;
        std::cin >> w >> h;
        int win = next[buffer[pos]];
        for (int j = 0; j < vw[win].b.size(); j++) {
          if(range(vw[win].b[j].s, vw[win].b[j].e,
                   w, h)){
            if(pos + 1 < buffer.size())
              buffer.erase(buffer.begin() + pos + 1, buffer.end());
            buffer.push_back(vw[win].b[j].link);
            pos++;
          }
        }
      }else if(s == "show"){
        std::cout << vw[next[buffer[pos]]].name << std::endl;
      }else if(s == "back"){
        pos = max(0, (int)(pos - 1));
      }else if(s == "forward"){
        pos = min((int)(buffer.size() - 1), pos + 1);
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1256
# N = int(input())
# N = map(int,input().split())
# N = list(map(int,input().split()))

a,b,c = map(int,input().split())

if a == b and a != c:
    print("Yes")
elif b==c and a!=c:
    print("Yes")

elif a==c and b!=c:
    print("Yes")

else:
    print("No")





# if :
#     print("YES")
# else:
#     print("NO")

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

Measured memory_bytes: 3060
package main

import (
	"bytes"
	"fmt"
)

func main() {
	var h, w int
	var s string
	fmt.Scan(&h, &w)
	a := make([]string, h+2)
	var bytes bytes.Buffer
	for i := 0; i < w+2; i++ {
		bytes.WriteString("#")
	}
	a[0] = bytes.String()
	a[len(a)-1] = bytes.String()
	for i := 1; i < h+1; i++ {
		l := ""
		fmt.Scan(&s)
		l = "#" + s + "#"
		a[i] = l
	}
	for i := 0; i < h+2; i++ {
		fmt.Println(a[i])
	}
}


Measured memory_bytes: 640
#include<stdio.h>
int main(){
int a,b,c,t;
scanf("%d %d %d",&a,&b,&c);
if(a>b){
t=a;
a=b;
b=t;
}
if(b>c){
t=b;
b=c;
c=t;
}
if(a>b){
t=a;
a=b;
b=t;
}
printf("%d %d %d\n",a,b,c);
return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int INF = 1000000005;

ll n, k;
vector<ll> a, f;

bool solved(ll x) {
  ll sum = 0;
  rep(i, n) {
    if (a[i]*f[i] > x) {
      sum += a[i] - (x / f[i]);
    }
  }
  if (sum <= k) return true;
  else return false;
}

int main() {
  ll ai, fi;
  cin >> n >> k;
  rep(i, n) {
    cin >> ai;
    a.push_back(ai);
  }
  rep(i, n) {
    cin >> fi;
    f.push_back(fi);
  }

  sort(a.begin(), a.end());
  sort(f.begin(), f.end(), greater<ll>());

  ll l = -1, r = 1e+12;
  while (l+1 < r) {
    ll m = (l+r) / 2;
    if (solved(m)) r = m;
    else l = m;
  }

  cout << r << endl;
  
  return 0;
}

Measured memory_bytes: 4848
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define pii pair<int, int>
#define pll pair<long long, long long>
const double PI = acos(-1);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
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;
}
///////////////////////////////////////////////////////////////
 
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    vector<pll> P(N);
    rep(i,N) {
        ll A,B; cin >> A >> B;
        P[i] = make_pair(B,A);
    }

    sort(all(P));
    vector<vector<ll>> dp(N+1, vector<ll>(N+1,1e18));
    dp[0][0] = 0;
    rep(i,N) {
        rep(j,N+1) dp[i+1][j] = dp[i][j];
        if (P[i].first < P[i].second) continue;
        int k = upper_bound(all(dp[i]),P[i].first-P[i].second) - dp[i].begin();
        rep(j,k) dp[i+1][j+1] = min(dp[i][j+1],dp[i][j]+P[i].second);
    }
    int ans = lower_bound(all(dp[N]),1e18) - dp[N].begin();
    cout << ans-1 << endl;
}


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

int main(void){
	int t,n,m,l;
	while(1){
		int ans=0;
		scanf("%d",&t);
		if(t==0)break;
		scanf("%d",&n);
		for(int a=0;a<n;a++){
			scanf("%d%d",&m,&l);
			ans+=l-m;
		}
		if(ans>=t)printf("OK\n");
		else printf("%d\n",t-ans);
	}
	return 0;
}

Measured memory_bytes: 0
def main():
  s=input()
  q=[0]
  m=len(s)
  l=["dream","dreamer","erase","eraser"]
  while q:
    i=q.pop()
    if i==m:
      print("YES")
      return
    for j in l:
      nj=len(j)
      if i+nj<=m and s[i:i+nj]==j:
        q.append(i+nj)
  print("NO")

main()

Measured memory_bytes: 3492
#include <iostream>
#include <string>

using namespace std;

int main()
{
	int n, k;
	string s;
	cin >> n >> s >> k;
	char c = s[k - 1];

	for (int i = 0; i < s.length(); i++) {
		if (c != s[i]) {
			s[i] = '*';
		}
	}
	cout << s << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) max_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)


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

    int N,M; cin >> N >> M;
    vei k(M);
    ve_vei s(M,vei(N));
    vei p(M);
    rep(i,M) {
        cin >> k[i];
        rep(j,k[i]){
            cin >> s[i][j];
            s[i][j]--;
        }
    }
    rep(i,M) cin >> p[i];
    int ans = 0;
    rep(bit, (1 << N) ) {
        vei v;
        rep(i,N) if(bit & (1 << i)) v.pub(i);

        int cnt2 = 0;
        rep(i,M) {
            int cnt = 0;
            rep(j,k[i]) if(find(all(v), s[i][j]) != v.end()) cnt++;
            if(cnt % 2 == p[i]) cnt2++;
        }
        if(cnt2 == M) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  ll n,c;
  cin >> n >> c;
  vector<P> v(n);
//  vector<P> v2(n);
vector<P> s1(n);
vector<P> s2(n);
vector<ll> S1(n);
vector<ll> S2(n);



  rep(i,n){
    cin>>v[i].first;
    cin>>v[i].second;
//    v2[i].first=
  }
  s1[0]=v[0];
  S1[0]=v[0].second-v[0].first;

  sort(v.begin(),v.end());
  //ll ans=max(ll(0),s1[0].second-s1[0].first);
  rep(i,n-1){
    s1[i+1].first=v[i+1].first;
    s1[i+1].second=s1[i].second+v[i+1].second;
    S1[i+1]=max(S1[i],s1[i+1].second-s1[i+1].first);
  //  cout<<S1[i+1]<<' '<<i+1<<endl;
//    cout<<ans<<' '<<i<<endl;
  }
  s2[n-1].first=c-v[n-1].first;
  s2[n-1].second=v[n-1].second;
//  S2[n-1].first=c-v[n-1].first;
  S2[n-1]=v[n-1].second-c+v[n-1].first;



  for(ll i=n-2;i>=0;i--){
    s2[i].first=c-v[i].first;
    s2[i].second=s2[i+1].second+v[i].second;
    S2[i]=max(S2[i+1],s2[i].second-s2[i].first);

  //  ans=max(ans,s2[i].second-s2[i].first);
  //  cout<<ans<<' '<<i<<endl;
  }
  ll ans=0;
  rep(i,n-1){
    ll temp=S1[i]+S2[i+1]-v[i].first;
  //  cout<<temp<<' '<<i<<endl;
    ans=max(ans,temp);
  }
//  cout<<endl;
  for(ll i=n-1;i>0;i--){
    ll temp=S2[i]+S1[i-1]-c+v[i].first;
  //  cout<<temp<<' '<<i<<endl;

    ans=max(ans,temp);
  }
  ans=max(ans,S1[n-1]);
  ans=max(ans,S2[0]);

cout<<ans;
}


Measured memory_bytes: 6528
import collections
from itertools import accumulate
from operator import add
import bisect

N = int(input())

def primef(n):
  i = 2
  p_nums = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      p_nums.append(i)
    i += 1
  if n > 1:
    p_nums.append(int(n))
  return p_nums

ans = primef(N)
ans = dict((collections.Counter(ans)))
con = 0

acadd = list(accumulate(range(1,30),add))

for k in ans.values():
  con += bisect.bisect_right(acadd,k)
    
print(con)

Measured memory_bytes: 9604
#include <stdio.h>
int main()
{   char s[17];
    scanf("%s",s);
    int ans=0;
    if(s[0]!='C')ans++;
    if(s[1]!='O')ans++;
    if(s[2]!='D')ans++;
    if(s[3]!='E')ans++;
    if(s[4]!='F')ans++;
    if(s[5]!='E')ans++;
    if(s[6]!='S')ans++;
    if(s[7]!='T')ans++;
    if(s[8]!='I')ans++;
    if(s[9]!='V')ans++;
    if(s[10]!='A')ans++;
    if(s[11]!='L')ans++;
    if(s[12]!='2')ans++;
    if(s[13]!='0')ans++;
    if(s[14]!='1')ans++;
    if(s[15]!='6')ans++;
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
int MIN(int a,int b){return a<b?a:b;}
int MAX(int a,int b){return a<b?b:a;}
int main(){
	char s[100010];
	int i,l,min;
	scanf("%s",s);
	for(l=0;s[l];l++);
	min=l;
	for(i=1;i<l;i++){
		if(s[i]-s[i-1])min=MIN(min,MAX(i,l-i));
	}
	printf("%d\n",min);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ut i=(a);i<(ut)(b);i++)
#define REP(i,b) FOR(i,0,b)
#define ALL(c) c.begin(),c.end()
#define PB push_back
#define cat //cout << __LINE__ << endl;
using namespace std;
typedef long long LL;
typedef double ld;
typedef LL ut;
typedef vector<ut> VI;
typedef pair<ut,ut> pr;
typedef pair<ut,pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<ut,VI> PQ;
const ut INF=1LL<<30;
const int SIZE=2001;
int nums[26];
int main(){
	int N,K;
	cin >> N >> K;
	string s;
	REP(i,N){
		cin >> s;
		nums[s[0]-'A']++;
	}
	PQ qu;
	REP(i,'Z'-'A'+1){
		if(nums[i])
			qu.push(nums[i]);
	}
	int ans=0;
	bool playable=true;
	while(true){
		VI tmp;
		REP(i,K){
			if(qu.empty()){
				playable=false;
				break;
			}
			tmp.PB(qu.top()-1);
			qu.pop();
		}
		if(playable){
			ans++;
			REP(i,K) if(tmp[i]) qu.push(tmp[i]);
		}
		else{
			break;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
// AUTHOR: ROSHAN SRIVASTAVA
// WEBSITE: https://www.youtube.com/channel/UC6uQdd7kLLOdlHSVklhV7Cw

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007

int n; 

int main(){

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ll d;
    cin >> n >> d;
    int ans = 0;
    d *= d;
    for(int i = 0; i < n; i++) {
        
        ll x, y;
        cin >> x >> y;

        ll ds =  (x * x) + ( y * y ); 
        
        if(ds <= d) ans++;
    }
    cout<<ans<<endl;

    return 0;
}

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

using namespace std;

int main()
{
   long long W,H,x,y;
   cin >> W >> H >> x >> y;

   cout << ((double)W*(double)H)/2 << " ";

   if(2*x == W && 2*y==H) cout << 1 << endl;
   else cout << 0 << endl;

   return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
const int N = 2e5 + 100;
 
ll n, k;
int val[N];
 
int Check(int len) {
	ll res = 0;
	for(int i = 1;i <= n; ++i)
		res += (val[i] - 1) / len;
	return res <= k;
}
 
int main() {
	scanf("%lld%lld", &n, &k); int L = 0, R = 1;
	for(int i = 1;i <= n; ++i) scanf("%d", &val[i]), R = max(R, val[i]);
	while(R - L > 1) {
		int mid = (L + R) >> 1;
		if(Check(mid)) R = mid;
		else L = mid;
	}
	cout << R << endl;
	return 0;
}

Measured memory_bytes: 4384
#include<stdio.h>
   
#define MAX 100
#define INF 100000000
#define white 0
#define gray 1
#define black 2
   
typedef struct{
  int data[MAX];
  int head;
  int tail;
}queue;
   
queue Q;
   
int n,d[MAX] = {INF};
int g[MAX][MAX] = {0};
int color[MAX] = {white};
   
void bfs(int);
void enqueue(int);
int dequeue(void);
   
int main(){
  int i,j,u,k,v;
   
  scanf("%d",&n);
   
  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d",&v);
      g[u-1][v-1] = 1;
    }
  }
  for(i=0;i<n;i++)
    d[i] = INF;
   
  bfs(0);
   
  for(i=0;i<n;i++){
    if(d[i] == INF)printf("%d %d\n",i+1,-1);
    else printf("%d %d\n",i+1,d[i]);
  }
  return 0;
}
   
void bfs(s){
  int v,u;
   
  d[s] = 0;
  color[s] = gray;
  Q.head = Q.tail = 0;
  enqueue(s);
   
  while(Q.tail < n){
    u = dequeue();
    if(u == INF)break;
    for(v=0;v<n;v++){
      if(g[u][v] == 0)continue;
      if(color[v] == white){
    d[v] = d[u] + 1;
    color[v] = gray;
    enqueue(v);
      }
    }
    color[u] = black;
  }
}
   
void enqueue(int s){
   
  if(Q.tail >= n)return;
     
  Q.data[Q.tail] = s;
  Q.tail++;
}
   
int dequeue(){
  int s;
   
  if(Q.head == Q.tail)return INF;
   
  s = Q.data[Q.head];
  Q.head++;
   
  return s;
}

Measured memory_bytes: 636
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
typedef long long ll;
using namespace std;

int main(void)
{
	int a, b, c, x, cnt = 0;
	cin >> a >> b >> c >> x;

	for (int i = 0; i <= a; i++)
	{
		for (int j = 0; j <= b; j++)
		{
			for (int k = 0; k <= c; k++)
			{
				if (i * 500 + j * 100 + k * 50 == x) cnt++;
			}
		}
	}

	cout << cnt << endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val input = readLine()?.split(" ")
    val a = input?.get(0)?.toInt() ?: 0
    val b = input?.get(1)?.toInt() ?: 0
    val c = input?.get(2)?.toInt() ?: 0

    if (a < b && b < c) {
        println("Yes")
    } else {
        println("No")
    }
}



Measured memory_bytes: 31952
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    n <- getInt
    xys <- replicateM n $ do
        [x,y] <- getIntList
        return (x,y)
    let ps = replicateM 2 xys
    print . (n -) . (\xs -> if null xs then 0 else maximum xs) . map length . group . sort . filter (/= (0,0)) $ map (\((x1,y1):(x2,y2):_) -> (x1-x2, y1-y2)) ps

Measured memory_bytes: 1404
#include<bits/stdc++.h>
using namespace std;
inline int_fast64_t read(){int_fast64_t x=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();return x*f;}
void Main(){
    int N = read(), M = read(), ans = 1;
    for (int i = 1; i*i<=M; i++) {
        if(M%i==0 && M/i >= N) {
            if (M/i >= N) ans = max(ans, i);
            if (i >= N) ans = max(ans, M/i);
        }
    }
    printf("%d\n", ans);
}
int main(){cin.tie(nullptr);ios::sync_with_stdio(false);Main();return 0;}

Measured memory_bytes: 256
// AOJ Volume 1 Problem 0142

#include <stdio.h>
#include <string.h>

int main(void)
{
    int freq1[10000];
    int freq2[5000];
    int n;
    int i, j;
    int diff;
    

    while (1){
        scanf("%d", &n);
        if (n == 0){
            break;
        }
    
        memset(freq1, 0, sizeof(freq1));
        memset(freq2, 0, sizeof(freq2));
    
        for (i = 1; i < n; i++){
            freq1[(i * i) % n] = 1;

//printf("<%d>", (i * i) % n);

        }
    
        for (i = 0; i < n; i++){
            if (freq1[i] != 0){
                for (j = 0; j < n; j++){
                    if (freq1[j] != 0){
                        diff = i - j;
                        if (diff < 0){
                            diff += n;
                        }
                        if (diff > (n - 1) / 2){
                            diff = n - diff;
                        }
//printf("(%d - %d = %d)", i, j, diff);
                        freq2[diff]++;
                    }
                }
            }
        }
        
        for (i = 1; i <= (n - 1) / 2; i++){
            printf("%d\n", freq2[i]);
        }
    }
    return (0);
}

Measured memory_bytes: 468
#include <bits/stdc++.h>
using namespace std;
template<class T> ostream& operator<<(ostream &os, vector<T> V) { os << "[ "; 
	for(auto v:V)os << v << " "; return os << "]";
}
template<class T> ostream& operator<<(ostream &os, set<T> S){ os << "{ "; 
	for(auto s:S) os<<s<<" ";  return os<<"}"; 
}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
	return os<<"("<<P.first<<","<< P.second << ")";
}
template<class L, class R> ostream& operator<<(ostream &os, map<L,R> M) {
	os<<"{ ";for(auto m:M)os<<"("<<m.F<<":"<<m.S<<")";
	return os<<"}";
}
#define cerr cout
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
#define ll unsigned long long
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define I insert 
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define For(i,n) for(int i=0;i<(int)n;++i)
#define Rev(i,n) for(int i=(int)n-1;i>=0;--i)
#define Rep(i,n) for(int i=1;i<=(int)n;++i)
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpii;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)


int main(){
	fio; cout<<fixed<<setprecision(25);	
	ll x; cin >> x;
	int no = 0;
	ll curr = 100;
	while(curr < x){
		++no;
		curr = curr+curr/100;
		// trace
	}
	cout << no << endl;









	return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef pair<ii, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef map<ll, ll> mpii;
typedef unordered_map<ll, ll> umpii;

#define pb(v) push_back(v)
#define all(v) v.begin(), v.end()
#define upb(v, key) (upper_bound(all(v), key) - v.begin())
#define lob(v, key) (lower_bound(all(v), key) - v.begin())

ll inf = 1e9;
ll INF = inf * 1ll * inf;
ll mod = 1e9 + 7;
double eps = 1e-9;
const ld pi = ld(3.1415926535897932384626433832795);
ll dr[] = {-1, 0, 0, 1};
ll dc[] = {0, 1, -1, 0};

template <class TH>
void _dbg(const char *sdbg, TH h) { cerr << sdbg << '=' << h << endl; }
template <class TH, class... TA>
void _dbg(const char *sdbg, TH h, TA... a)
{
  while (*sdbg != ',')
    cerr << *sdbg++;
  cerr << '=' << h << ',';
  _dbg(sdbg + 1, a...);
}
template <class T>
ostream &operator<<(ostream &os, vector<T> V)
{
  os << "[";
  for (auto vv : V)
    os << vv << ",";
  return os << "]";
}
template <class L, class R>
ostream &operator<<(ostream &os, pair<L, R> P)
{
  return os << "(" << P.st << "," << P.nd << ")";
}
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)

/*...................................................*/

main()
{
  string s, t;
  cin >> s >> t;
  int n = s.length(), m = t.length();
  vector<vector<int>> dp(n + 1, vector<int> (m + 1));
  dp[0][0] = 1;
  for(int i = 1; i <= n; i++)
  for(int j = 1; j <= m; j++)
  {
    dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
    if(s[i - 1] == t[j - 1])
    dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + 1);
  }
  string ans = "";
  int i = n, j = m;
  while(i)
  {
    if(dp[i][j] == dp[i - 1][j])
    i--;
    else if(dp[i][j] == dp[i][j - 1])
    j--;
    else i--, j--, ans += s[i]; 
  }
  reverse(all(ans));
  cout << ans;
}

Measured memory_bytes: 35584
//chiragjn
#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define gibe_de_fast_io_b0ss ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
const ll mod = 1e9 + 7;
const ll INF = 0x7FFFFFFFFFFFFFFF/2;
int h, w;
string s[50 + 1];
bool is_safe(int x, int y){
	return (x >=0 && x < h) && (y >=0 && y < w) && s[x][y] == '#';
}
int main(){
    gibe_de_fast_io_b0ss;
    cin>>h>>w;
    for(int i=0;i<h;i++) cin>>s[i];
    for(int x=0;x<h;x++){
    	for(int y=0;y<w;y++){
    		if(s[x][y] == '.'){
    			int ans = 0;
    			if(is_safe(x + 1, y)) ans++;
    			if(is_safe(x - 1, y)) ans++;
    			if(is_safe(x, y + 1)) ans++;
    			if(is_safe(x, y - 1)) ans++;
    			if(is_safe(x + 1, y + 1)) ans++;
    			if(is_safe(x - 1, y - 1)) ans++;
    			if(is_safe(x + 1, y - 1)) ans++;
    			if(is_safe(x - 1, y + 1)) ans++;
    			cout<<ans;
    		}
    		else{
    			cout<<s[x][y];
    		}
    	}
    	cout<<"\n";
    }
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	string a, b, c;
	cin>>n>>a>>b>>c;
	int ans=0;
	REP(i, n){
		if(a[i]==b[i]){
			if(b[i]!=c[i]){
				++ans;
			}
		}
		else{
			if(b[i]!=c[i]){
				if(a[i]!=c[i]){
					ans+=2;
				}
				else{
					++ans;
				}
			}
			else{
				++ans;
			}
		}
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 256
while get = gets do
	a,b,c,d,e,f = get.chomp.split(" ").map(&:to_i)
	x=((c*e-b*f)*1.0/(a*e-b*d)*1000.0).round/1000.0
	y=((f*a-c*d)*1.0/(a*e-d*b)*1000.0).round/1000.0
	puts sprintf( "%.3f ", x )+sprintf( "%.3f", y )
end

Measured memory_bytes: 6152
import java.math.BigInteger;
import java.util.*;

public class Main {

    public static void main(String[] args) {
	// write your code here
        Scanner sc = new Scanner(System.in);
        BigInteger inu = new BigInteger(sc.next());
        BigInteger t = new BigInteger("26");

        StringBuilder sb = new StringBuilder();
        while (inu.compareTo(BigInteger.ZERO) > 0) {
            inu = inu.subtract(BigInteger.ONE);
            BigInteger[] big = inu.divideAndRemainder(t);
            inu = big[0];
            char c = (char)(big[1].intValue() + 'a');
            sb.insert(0, c);
        }

        System.out.println(sb.toString());
    }
}


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

int n;
string s;
vector<int> ans(100001);
bool flag;

void l_search(void){
    // 全部埋める
    for(int i = 1; i < n-1; ++i){
        if(s[i] == 'o'){
            if(ans[i]){ // 羊
                ans[i+1] = ans[i-1];
            }else{ // 狼
                ans[i+1] = 1-ans[i-1];
            }
        }else{
            if(ans[i]) ans[i+1] = 1-ans[i-1];
            else ans[i+1] = ans[i-1];
        }
    }

    // 整合性の確認
    flag = true;
    rep(i,n){
        if(i == 0){
            if(s[i] == 'o'){
                if(ans[i]){
                    if(ans[n-1] != ans[1]) flag = false;
                }else{
                    if(ans[n-1] == ans[1]) flag = false;
                }
            }else{
                if(ans[i]){
                    if(ans[n-1] == ans[1]) flag = false;
                }else{
                    if(ans[n-1] != ans[1]) flag = false;
                }
            }
        }else if(i == n-1){
            if(s[i] == 'o'){
                if(ans[i]){
                    if(ans[n-2] != ans[0]) flag = false;
                }else{
                    if(ans[n-2] == ans[0]) flag = false;
                }
            }else{
                if(ans[i]){
                    if(ans[n-2] == ans[0]) flag = false;
                }else{
                    if(ans[n-2] != ans[0]) flag = false;
                }
            }
        }else{
            if(s[i] == 'o'){
                if(ans[i]){
                    if(ans[i-1] != ans[i+1]) flag = false;
                }else{
                    if(ans[i-1] == ans[i+1]) flag = false;
                }
            }else{
                if(ans[i]){
                    if(ans[i-1] == ans[i+1]) flag = false;
                }else{
                    if(ans[i-1] != ans[i+1]) flag = false;
                }
            }
        }
    }
}

void cout_ans(void){
    rep(i,n){
        if(ans[i]) cout << 'S';
        else cout << 'W';
    }
}

int main(){
    cin >> n >> s;
    // 0:羊, 1:羊
    ans[0] = 1; ans[1] = 1;
    l_search();
    if(flag){
        cout_ans();
        return 0;
    }
    // 0:羊, 1:狼
    ans[0] = 1; ans[1] = 0;
    l_search();
    if(flag){
        cout_ans();
        return 0;
    }
    // 0:狼, 1:羊
    ans[0] = 0; ans[1] = 1;
    l_search();
    if(flag){
        cout_ans();
        return 0;
    }

    // 0:狼, 1:狼
    ans[0] = 0; ans[1] = 0;
    l_search();
    if(flag){
        cout_ans();
        return 0;
    }

    cout << -1 << endl;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false), cin.tie(0)
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define ALL(x) (x).begin(), (x).end()
#define dump(x) cout << (x) << endl
#define LMAX 9223372036854775807LL
#define LMIN -9223372036854775807LL
using ll = int64_t;
template<typename T>
using vec = vector<T>;
using P = pair<ll, ll>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
	fill((T *)array, (T *)(array + N), val);
}

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//ll pas[51][52];
ll n, k;
ll D = 0;
vec<ll> g[2001];
bool used[2001];
ll cnt = 0;
void dfs2(ll x, ll dif,ll m,ll ng){
	used[x] = true;
	if(dif > m)cnt++;
	REP(i,g[x].size()){
		if(!used[g[x][i]] && g[x][i] != ng)dfs2(g[x][i],dif + 1,m, ng);
	}
}
signed main(){
	IOS;
	cin >> n >> k;
	vec<P> p(n - 1);
	REP(i, n - 1){
		int x, y;
		cin >> x >> y;
		p[i] = P(x, y);
		g[x].push_back(y);
		g[y].push_back(x);
	}
	ll ans = INF;
	if(k % 2 == 0){
		for(int i = 1;i <= n;i++){ //O(n^2)
			cnt = 0;
			Fill(used, false);
			dfs2(i,0,k / 2,0);
			ans = min(ans, cnt);
		}
	}
	else {
		REP(i, n - 1){
			int x = p[i].first;
			int y = p[i].second;
			cnt = 0;
			Fill(used, false);
			dfs2(x,0,k / 2,y);
			dfs2(y,0,k / 2,x);
			ans = min(ans, cnt);
		}
	}
	dump(ans);
}

Measured memory_bytes: 512
#include<iostream>

using namespace std;

int main()
{
	int s=0, sn=0, X=0, Max_X=0, i=1, j=1 , a,b;
	int x=0, y=0;
	while(1)
	{
		cin >> x >> y >> s;
		if((x==0)&&(y==0)&&(s==0)) break;
		
		sn=s/(100+x)/100;//s????¨?????????????

		for(i=1;i<s;i++)
		{
			a = i*(100+x)/100;//??????????????§?¨????
			for(j=1;j<s;j++)
			{
				b = j*(100+x)/100;//??????????????§?¨????			
				if(a+b==s)
				{
					int a_new = i*(100+y)/100;//??????1?????°?¨????
					int b_new = j*(100+y)/100;//??????2?????°?¨????
					X = a_new + b_new;
					if(Max_X < X ) Max_X = X;
				}
			}
		}

		cout << Max_X << endl;
		Max_X=0;
	}
}

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

#define rep(i, n)for((i) = 0;(i) < (n);++(i))

string city = "AXYZWB";
int G[6][2] = {1, 2, -1, 3, 1, -1, 4, 5, 5, 2, 2, 1};

int main(void){
	int i, j, now;
	string s;
	for(;;){
		cin >> s;
		if(s[0] == '#')break;
		now = 0;
		rep(i, s.size()){
			now = G[now][s[i] - '0'];
			if(now == -1)break;
		}
		puts((now == 5) ? "Yes" : "No");
	}
	return 0;
}

Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

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

const ll mod=1000000007;

ll countBits(ll in){
  int res=0;
  for(;in>0;in>>=1){
    if((in&0x01)!=0){
      res++;
    }
  }
  return res;
}

template<typename T>
void show2dVector(vector<vector<T>>& v){
  for(int i=0;i<v.size();i++){
    int m=v[i].size();
    cout<<i<<" : ";
    for(int j=0;i<m;i++){
      cout<<v[i][j]<<" ";
    }
    cout<<endl;
  }
}

void bfs(const vector<vector<int>>&g, int v, vector<bool>& seen){
  seen[v]=true;
  cout<<v<<" ";
  for(auto next: g[v]){
    if(seen[next]){
      continue;
    }
    bfs(g,next,seen);
  }
}

bool dfs(vector<vector<int>> &g,int start,int goal,vector<bool>&seen){
  bool res=false;
  seen[start]=true;
  if(start==goal){
    return true;
  }
  for(auto next: g[start]){
    if(seen[next]){
      continue;
    }
    res=dfs(g,next,goal,seen);
    if(res){
      break;
    }
  }
  return res;
}

ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}

ll powm(ll a,ll n, ll m){
  ll ret=1;
  while(n>0){
    if(n%2==1){
      ret=(ret*a)%m;
    }
    n>>=1;
    a=(a*a)%m;
  }
  return ret;
}

void primeFactor(ll val, map<ll,ll> &primeList){
  cerr<<__FUNCTION__<<":start"<<endl;
  if(val<1){
    return;
  }
  for(int i=2;i*i<val;i++){
    while(val%i==0){
      primeList[i]++;
      val/=i;
    }
  }
  if(val!=1){
    primeList[val]=1;
  }
  cerr<<__FUNCTION__<<":end"<<endl;

  return;
}

const string yesno(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  ll n;cin>>n;
  int ans=0;
  map<ll,int> pl;
  for(ll i=2;i*i<=n;i++){
    while(n%i==0){
      pl[i]++;
      n/=i;
    }
  }
  if(n!=1){
    pl[n]=1;
  }
  for(auto it:pl){
    for(int s=1;s<=it.second;s++){
      it.second-=s;
      ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3596
#include<iostream>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<stdlib.h>
#include<stack>
using namespace std;
#define PI 3.14159265358979
typedef  long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#include<set>
int main(void)
{
    int n;
    int k;
    cin>>n;
    cin>>k;

    vector<int> sunuke(n+3);

    rep(i,k)
    {
        int d;
        cin>>d;
        for(int j=1;j<=d;j++)
        {
           int a;
           cin>>a;
           sunuke[a]++;
        }


    }

    int ans =0;

    for(int q=1;q<=n;q++)
    {
        if(sunuke[q]==0) ans ++;

    }

    cout<<ans<<endl;
}

Measured memory_bytes: 3156
#ifdef Dhiraj
    #include "D:/dhiraj/Programming/debug.h"
#else
    #include <bits/stdc++.h>
    using namespace std;
    #define d(...) 11
    #define cerr if(0) cerr
#endif

// Macro --------------------------------------------------------------------

#define ll                  long long int
#define FOR(i, a, b, s)     for(ll i = (a); ((s) > 0 ? i < (b) : i > (b)); i += (s))
#define FOR1(b)             FOR(i, 0, b, 1)
#define FOR2(i, b)          FOR(i, 0, b, 1)
#define FOR3(i, a, b)       FOR(i, a, b, (a) <= (b) ? 1 :-1)
#define FOR4(i, a, b, s)    FOR(i, a, b, s)
#define GET5(a, b, c, d, e, ...) e
#define FORC(...)           GET5(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)
#define loop(...)           FORC(__VA_ARGS__)(__VA_ARGS__)
#define all(x)              x.begin(), x.end()
#define rall(x)             x.rbegin(), x.rend()
#define endl                '\n'

// Template -----------------------------------------------------------------

// multiple input
template <typename... T> 
inline void inp(T&... args) {
    ((cin >> args), ...);
}
// scan vector
template <typename T> 
inline istream& operator >>(istream &in, vector<T> &a) {
    for(auto &x : a) in >> x;
    return in;
}
// scan pair
template <typename T, typename U> 
inline istream& operator >>(istream &in, pair<T, U> &a) {
    in >> a.first >> a.second; 
    return in;
}

// Solve --------------------------------------------------------------------

void solve(int &T)
{
    ll n;
    cin >> n;

    string s;
    while(n > 0)
    {
        char c;
        ll d = n % 26;
        if(d == 0) {
            d = 26;
            c = 'z';
        }
        else c = 'a' + d - 1;
        n -= d;
        s.push_back(c);
        n /= 26;
    }
    reverse(all(s));
    cout << s << endl;
}

// Main ---------------------------------------------------------------------

int main()
{
    #ifdef Dhiraj
        freopen("D:/dhiraj/Programming/i1.txt", "r", stdin);
        freopen("D:/dhiraj/Programming/o1.txt", "w", stdout);
        // freopen("D:/dhiraj/Programming/e1.txt", "w", stderr);
    #endif

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

    int t = 1;
    for(int i = 1; i <= t; i++) {
        cerr << "Case #" << i << "\n";
        solve(i);
    }
    return 0;
}

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

int main()
{
	int n, m;
	int b[100];

	cin >> n;

	for (int i = 0; i < n - 1; i++)
		cin >> b[i];

	m = b[0] + b[n - 2];

	for (int i = 1; i < n - 1; i++)
		m += min(b[i - 1], b[i]);

	cout << m << endl;

	return 0;
}

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

int main() {
    int H, W;
    
    while(true) {
        cin >> H >> W;
        if (H == 0 && W == 0) {
            break;
        }
        for(int y = 0; y < H; y++) {
            for(int x = 0; x < W; x++) {
                if (y == 0 || x == 0 || x == W-1 || y == H-1) {
                    cout << "#";
                } else {
                    cout << ".";
                }
            }
            cout << endl;
        }
        cout << endl;
    }
    
    return 0;
}


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

using namespace std;

typedef int in;
#define int long long

int n;
vector<pair<int,int> > adj[100005];
int a[100005];
bool vis[100005];

void dfs(int node,int c){
    vis[node] = 1;
    for(int i = 0 ; i < adj[node].size() ; i ++){
        int f = adj[node][i].first,co = adj[node][i].second;
        if(vis[f]){
            continue;
        }
        if((co + c) % 2){
            a[f] = 1;
            dfs(f,co + c);
        }
        else{
            a[f] = 0;
            dfs(f,co + c);
        }
    }
}

in main()
{
    cin >> n;
    for(int i = 0 ; i < n - 1 ; i ++){
        int x,y,z;
        cin >> x >> y >> z;
        adj[x].push_back({y,z});
        adj[y].push_back({x,z});
    }
    dfs(1,0);
    for(int i = 1 ; i <= n ; i ++){
        cout << a[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 10240
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
/*--Input//////////////////////////////////////////////////*/
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
    cin >> first;
    IN(rest...);
    return;
}
#define SS(T, ...)      T __VA_ARGS__; IN(__VA_ARGS__);
#define SV(type,c,n) vector<type> c(n);for(auto& i:c)cin >> i;
/*--Output/////////////////////////////////////////////////*/
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
inline int p(void){cout << endl; return 0;}
template<class Head> int p(Head&& head){cout << head;p();return 0;} template<class Head,class... Tail> int p(Head&& head,Tail&&... tail){cout<<head<<" ";p(forward<Tail>(tail)...);return 0;}
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL<<(n))

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; }
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.second < b.second; }

const int MOD = 1000000007;

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

int main() {
    SS(string,s,S);
    set<int>abc[26];
    rep(i,S.size())abc[S[i]-'a'].insert(i);

    SS(ll,Q);
    rep(qi,Q){
        ll q;
        cin>>q;
        if(q==1){
            SS(int,i)
            SS(char,c)
            --i;
            abc[S[i]-'a'].erase(i);
            S[i]=c;
            abc[S[i]-'a'].insert(i);
        }else {
            SS(int, l, r)
            --l;
            ll cnt = 0;
            rep(j, 26) {
                auto it = abc[j].lower_bound(l);
                if(it != abc[j].end()&&*it<r)cnt++;
            }
            p(cnt);
        }
    }
}

Measured memory_bytes: 26268
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

a, b = MAP()
print("Even" if a*b%2==0 else "Odd")


Measured memory_bytes: 5148
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <map>
using namespace std;

typedef pair<int,int> P;

int main() {
  P a[101];
  int n=0;
  while(1) {
    scanf("%d%*c%d",&a[n].second,&a[n].first);
    if(a[n].first==0 && a[n].second==0) break;
    n++;
  }
  sort(a,a+n,greater<P> ());
  map<int,int> m;
  int rank=1;
  m[a[0].second]=rank;
  for(int i=1; i<n; i++) {
    if(a[i].first!=a[i-1].first) rank++;
    m[a[i].second]=rank;
  }
  int x;
  while(cin >> x) {
    cout << m[x] << endl;
  }
  return 0;
}


Measured memory_bytes: 1248