akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define EPS 1e-9

int que[100010],quecnt;
int dp[100010];
int a[100010];
int main(){
	int n;
	scanf("%d",&n);
	rep(i,0,n)scanf("%d",a+i);
	dp[0]=1;
	que[0]=0,quecnt=1;
	rep(i,0,quecnt){
		int p=que[i];
		rep(i,1,7)if(p+i<n&&!dp[p+i]){
			int q=p+i;
			while(a[q]&&!dp[q]){
				dp[q]=dp[p];
				q+=a[q];
			}
			if(!a[q]&&!dp[q]){
				dp[q]=dp[p]+1;
				que[quecnt++]=q;
			}
		}
	}
//	rep(i,0,quecnt)printf("%d ",que[i]);puts("");
//	rep(i,0,quecnt)printf("%d ",dp[que[i]]);
	printf("%d\n",dp[n-1]-1);
}


Measured memory_bytes: 2688
#include<bits/stdc++.h>
using namespace std;
        int main(){
        cout<<fixed<<setprecision(6);

        double n;
        cin>>n;
        double pai = acos(-1);
        double menseki =n*n*pai;
        double enshyuu =2*n*pai;
        cout<<menseki<<" "<<enshyuu<<" "<<endl;
}


Measured memory_bytes: 3236
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
#define endn "\n"
typedef pair<int,int> P;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const int MOD = 1000000007;
//const int MOD = 998244353;
template<class T> inline int add(T& a, T b, T M = MOD){a=(a+M)%M;b=(b+M)%M;a=(a+b)%M;return a;};
template<class T> inline int mul(T& a, T b, T M = MOD){if(a>=M)a%=M;if(b>=M)b%=M;a*=b;if(a>=M)a%=M;return a;};
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
const string abc="abcdefghijklmnopqrstuvwxyz";
const string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

////////////////////////////////////////////////////////////////////
///////////////////////___modpow___////////////////////
ll modpow(ll a,  ll n, const ll &MOD = MOD){
  ll ret = n == 0 ? 1 : modpow(a, n/2, MOD);
  (ret *= ret) %= MOD;
  if(n%2)((ret *= a) %= MOD);
  return ret;
}
///////////////////////___modinv___////////////////////
ll modinv(ll d, const ll &MOD = MOD){
  return modpow(d, MOD-2, MOD);
}
////////////////////////////////////////////////////////////////////

int n,q, cost[210000];vector<int> g[210000];

void dfs(int x, int par){
  if(g[x].size() == 1 && x != 0)return;
  rep(i,g[x].size()){
    int to = g[x][i];
    if(par == to)continue;
    cost[to] += cost[x];
    dfs(to, x);
  }
}

signed main(){
  cin>>n>>q;
  rep(i,n-1){
    int aa, bb;cin>>aa>>bb;aa--;bb--;
    g[aa].push_back(bb);
    g[bb].push_back(aa);
  }
  rep(i,q){
    int p, x;cin>>p>>x;p--;
    cost[p] += x;
  }
  dfs(0, -1);
  rep(i,n){
    cout << cost[i] << (i == n-1 ? endn : " ");
  }
}


Measured memory_bytes: 24448
#include <bits/stdc++.h>
#define ll long long 
#include<vector>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
const int mod=1e9+7;
int main(){
	IOS;
	string s;
	cin>>s;
	for(int i=0;i<s.length();i++)
	cout<<"x";
	
	
	}

Measured memory_bytes: 3604
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <map>

#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int INF = pow(2,29);
const int MOD = 1000000007;

struct UnionFind {
  vector<ll> par;

  UnionFind(ll N) : par(N) { rep(i, N) par[i] = i; }

  int root(ll x) { 
    if (par[x]==x) return x;
    else 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;
  }

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

};

int main() {
  ll H, W; cin >> H >> W;
  ll m[H][W];
  rep(i, H) {
    string S; cin >> S;
    rep(j, W) m[i][j] = S[j]=='#' ? 1 : 0;
  }

  UnionFind tree(H*W);
  rep(i, H) rep(j, W) {
    if (i!=0 && m[i][j]!=m[i-1][j]) tree.unite((i-1)*W+j,i*W+j);
    if (j!=0 && m[i][j]!=m[i][j-1]) tree.unite(i*W+j-1,i*W+j);
  }

  map<ll, map<ll, ll>> num; 
  rep(i, H) rep(j, W) { num[tree.root(i*W+j)][(i+j)%2]++; }

  ll result = 0;
  for (auto x: num) result += x.second[0]*x.second[1]; 

  // rep(i, H) { rep(j, W) cout << tree.root(i*W+j) << " "; cout << endl; }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 24320
N, = map(int, input().split())
X = input().strip()
i,j = 0,N-1
R = 0
while i<=j:
    if X[i] == "R":
        i += 1
        continue
    if X[j] == "W":
        j -= 1
        continue
    R += 1
    i += 1
    j -= 1
print(R)


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

int calc(int x) {
    int cnt = 0;
    while (x > 0) {
        x /= 10;
        cnt++;
    }
    return cnt;
}

int main() {
    int n;
    cin >> n;
    int ans = 0;
    rep(i, 1, n + 1) {
        if (calc(i) % 2 == 1) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<algorithm>
#include<cassert>
using namespace std;

int main(void) {
	int n;
	cin >> n;
	vector<pair<int,int>> p(n);

	for (int i = 0; i < n; i++) {
		cin >> p[i].first;
		p[i].second = i;
	}

	sort(p.begin(), p.end());
	
	for (int i = 0; i < n; i++) {
		cout << p[i].second+1<<" ";
	}
}

Measured memory_bytes: 1536
#include <iostream>
#include <iomanip> 
#include <cstdlib>
#include <cmath>
#include<map>
#include<string.h>
#include <algorithm>
#include <bits/stdc++.h> 
#include<vector>
 
using namespace std;
#define rep(i,a,b)    for(int i=a;i<b;i++)
#define repn(i,a,b)   for(int i=a;i>=b;i--)
#define vi vector<int>
#define vb vector<bool>
#define vs vector<string>
#define vl vector<long long int>
//#define viadj[n+1] vector<int>adj[n+1] 
#define sortA(arr)   sort(arr.begin(),arr.end())
#define sortC(arr,n)   sort(arr,arr+n,comparefunc())
#define search(arr,c)  binary_search(arr.begin(),arr.end(),c)
#define pb   push_back
#define ll long long
#define LCM(a,b) boost::math::lcm(a,b)
#define mp make_pair
#define pll pair<long long int,long long int>
 vb isprime(1e7+1,true);
 
struct node{
     ll lenght;};
        
void Sieve(ll maxn){ 
    ll j;isprime[0]=isprime[1]=false;
    rep(i,2,sqrt(maxn)+1)
    {
        if(isprime[i]){
            for(j=i*i;j<=maxn;j+=i){
                isprime[j]=false;
            }
        }
    }
} 
 struct comparefunction{
bool operator()(const pll c,const pll d)const{
    ll lenc=c.second-c.first+1;
    ll lend=d.second-d.first+1;
    if(lenc!=lend)
    return lenc>lend;
    else
    return c.first<d.first;
   
     
}};
 
  
 
   void dfs(ll v,vb visited,vi adj[]) {
    visited[v] = true;
 
    
    for (int u : adj[v]) {
       if (!visited[u])
            dfs(u,visited,adj);
    }
   
    
}
 
 ll modpow(ll x, ll n,ll p){
     if(n==0)
     return 1;
     if(n==1)
     return x%p;
     if(n%2==0)
     return (modpow(x,n/2,p)%p)*(modpow(x,n/2,p)%p);
     else
     return (x%p)* (modpow(x,n/2,p)%p)*(modpow(x,n/2,p)%p);
 }
 
 
 
int main()
{
    
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 
   
    ll check1=0,check2=0,check3=0;
    ll counti=0, i=0,j;
    ll sum=0,count=0;ll t;ll p;
  // cin>>t;
  //while(t--){
  long double a,b,h,m;long double pi=3.14159265358979323846;
  cin>>a>>b>>h>>m;
  long double theta=abs(30*h-5.5*m);
  long double ans;
  ans=sqrt(pow(a,2)+pow(b,2)-(2.0*a*b*cos((pi/180.0)*theta)));
  cout<<setprecision(10)<<ans;
//}
    
}
  



 
   
 
 

Measured memory_bytes: 4384
#include<bits/stdc++.h>
 
#define rep(i,n) for(ll i = 0;i < n;++i)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
typedef pair<int,int> P;
 
const int INF = 1001001001;
const long double PI = (acos(-1));
const int mod = 1e9+7;
const int vx[6] = {0,1,0,-1,1,-1};
const int vy[6] = {1,0,-1,0,1,1};




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

    ll n,p;
    cin >> n >> p;
    ll ans = 1;
    if(n==1) {
        cout << p << endl;
        return 0;
    }
    for(ll i = 2;i * i <= p;++i){
        if(p % i == 0){
            int a = 0;
            ll t = p;
            while(t%i==0){
                t /= i;
                a++;
                if(a == n){
                    ans = max(ans,i);
                    break;
                }
            }
        }
    }
    cout << ans << endl;

    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)

ll ans = 0;
vector<int> A;

vector<int> count(int l, int r, bool isL){
	if(r-l == 1){
		ans++;
		//cout<<l<<" "<<r<<" "<<1<<endl;
		vector<int> ret;
		ret.push_back(A[l]);
		return ret;
	}
	vector<int> left = count(l,(l+r)/2,true);
	vector<int> right = count((l+r)/2,r,false);
	int li=0, ri=right.size()-1;
	while(li < left.size() && ri>=0){
		while(li+1 < left.size() && (left[li+1]&right[ri])==0){
			li++;
		}
		if((left[li]&right[ri]) == 0){
			//cout<<l<<" "<<r<<" "<<(li+1)*(ri+1)<<endl;
			ans += (li+1);
			ri--;
		}else{
			ri--;
		}
	}

	vector<int> ret;
	int memo=0;
	if(isL){
		for(int i=r-1;i>=l;i--){
			if((memo&A[i]) == 0){
				memo ^= A[i];
				ret.push_back(memo);
			}else{
				break;
			}
		}
	}else{
		for(int i=l;i<r;i++){
			if((memo&A[i]) == 0){
				memo ^= A[i];
				ret.push_back(memo);
			}else{
				break;
			}
		}
	}
	return ret;
}

int main(void){
	int n,a;
	cin>>n;
	rep(i,n){
		cin>>a;
		A.push_back(a);
	}

	count(0,n,true);
	cout<<ans<<endl;

	return 0;
}


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

using namespace std;

typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<llint, llint> pll;
typedef vector<int> vi;
typedef vector<llint> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define ci cin
#define co cout
#define en endl
#define ln cout<< '\n'
#define rep(i, n) for(int i = 0; i < n; i++)
#define outl(x) cout<< (x) << '\n'
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007

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

template<typename Tn> Tn lcm(Tn a, Tn b)
{
  return a / gcd(a, b) * b;
}

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

llint n, k;
llint a[1001];

int main()
{  
  ci >> n >> k;
  for(int i = 1; i <= n; i++) {
    llint b;
    ci >> b;
    a[i] = a[i - 1] + b;
  }

  vl v;
  for(int i = 0; i <= n; i++) {
    for(int j = i + 1; j <= n; j++) {
      v.pb(a[j] - a[i]);
    }
  }

  sort(v.begin(), v.end(), greater<int>());

  llint ans = 0;
  int vs = v.size();
  for(int i = 62; i >= 0; i--) {
    llint bit = 1LL << i;

    vl vv;
    int cnt = 0;
    int j;
    for(j = 0; j < vs; j++) {
      if(bit & v[j]) {
	vv.pb(v[j]);
	cnt++;
      }
    }
    if(cnt >= k) {
      ans |= bit;
      v = vv;
      vs = vv.size();
    }
  }
  
  co << ans << en;
  
  return 0;
}


Measured memory_bytes: 6256
"use strict"

const main = arg => {
  arg = arg.trim().split("\n");
  const N = parseInt(arg[0]);

  arg = arg.slice(1, (2 * N) + 1).map(n=>n.split(" ").map(l=>parseInt(l))).map(xy => {
    return {x: xy[0], y: xy[1]}
  });

  const red  = arg.slice(0, N);
  const blue = arg.slice(N);
  const paired = [...Array(N)].fill(0);

  blue.sort((a, b) => a.x - b.x);

  for (let i=0; i<N; i++) {
    let max_y = -1;
    let idx = '';

    for (let j = 0; j < N; j++) {
      if(red[j].x >= blue[i].x) continue;
      if(red[j].y >= blue[i].y) continue;
      if(paired[j] === 1)       continue;
      if(max_y >= red[j].y)     continue;

      max_y = red[j].y;
      idx = j;
    }

    if (idx !== '') paired[idx] = 1;
  }

  const ans = paired.filter(n=>n===1).length;

  console.log(ans);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7628
#include <stdio.h>

int main(){
	long long int a,b,tmp,gcd,lcm,ab;
	while(scanf("%lld%lld",&a,&b) != EOF){
		gcd = 0;
		lcm = 0;
		ab = a*b;
		if(a>=b){
			while(1){
			tmp = a % b;
			if(tmp == 0){
				gcd = b;
				break ;
			}
			a = b;
			b = tmp;
			}
		}
		else if (a<=b){
			while(1){
			tmp = b % a;
			if(tmp == 0){
				gcd = a;
				break ;
			}
			b = a;
			a = tmp;
			}
		}
		lcm = ab/gcd;
		printf("%lld %lld\n",gcd,lcm);
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

using ll = long long;

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

#define input(...) __VA_ARGS__; in(__VA_ARGS__)

template<class T>
void print(vector<T> a) {
  cout << "[ ";
  REP(i, a.size()) cout << a[i] << " ";
  cout << "]" << endl;
}

void print() {
  std::cout << std::endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  std::cout << head << " ";
  print(std::forward<Tail>(tail)...);
}

void in() { }

template <class Head, class... Tail>
void in(Head&& head, Tail&&... tail) {
  cin >> head;
  in(std::forward<Tail>(tail)...);
}

vector<vector<ll>> table(100 + 1, vector<ll>(10000 + 1, -1));
ll N, W;
vector<ll> v, w;
ll dfs(ll i, ll weight) {
  if (i == N) return 0;
  if (table[i][weight] != -1) return table[i][weight];

  if (weight + w[i] <= W) {
    return table[i][weight] = max(dfs(i + 1, weight), dfs(i + 1, weight + w[i]) + v[i]);
  } else {
    return table[i][weight] = dfs(i + 1, weight);
  }
}

int main() {
  ll input(n, bag);
  v = vector<ll>(n);
  w = vector<ll>(n);
  REP(i, n) cin >> v[i] >> w[i];
  N = n;
  W = bag;

  cout << dfs(0, 0) << endl;
}



Measured memory_bytes: 10640
A, B, C, D = map(int, input().split())

import fractions

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


def f(x, c, d):
    cd = lcm(c, d)
    
    divisible = x//c + x//d - x//cd
    
    return x - divisible

print(f(B, C, D) - f(A-1, C, D))


Measured memory_bytes: 5488
# -*- coding: utf-8 -*-
"""
Created on Sat Jan  4 16:34:06 2020

@author: masat
"""

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

A_last = 0
B_last = 0

if K <= A:
    A_last = A-K
    B_last = B
elif K <= A+B:
    A_last = 0
    B_last = B-K+A
else:
    A_last = 0
    B_last = 0

print("{} {}".format(A_last, B_last))


Measured memory_bytes: 3060
n = int(input())
s = input()
 
ans = s.count("R") * s.count("G") * s.count("B")
for i in range(n-2):
    for j in range(i+1,n-1):
        k = 2*j-i
        if k < n:
            if s[k] != s[i] and s[k] != s[j] and s[i] != s[j]:
                    ans -= 1
                    
print(ans)

Measured memory_bytes: 9176
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
const LL MOD = 1000000007LL;
typedef pair<LL, int> P;
vector<P> prime_factorize(LL n) {
	vector<P> ret;
	for (LL i = 2; i*i <= n; i++) {
		int cnt = 0;
		while (n%i == 0) {
			n /= i;
			cnt++;
		}
		ret.emplace_back(i, cnt);
	}
	if (n > 1) ret.emplace_back(n, 1);
	return ret;
}
int main() {
	int n;
	cin >> n;
	vector<P> v = prime_factorize(n);
	cout << n << ":";
	for (P p : v) {
		for (int i = 0; i < p.second; i++) cout << " " << p.first;
	}
	cout << endl;
}


Measured memory_bytes: 3388
n=int(input())
s=[]
r=[]
c=0
for i in range(n):
    a=input()
    b=[]
    for k in a:
      b.append(k)
    b.sort()
    s.append(b)
s.sort()
for i in range(n-1):
    if s[i]==s[i+1]:
        c+=1
        r.append(c)
    else:
        c=0
        r.append(c)
print(sum(r))

Measured memory_bytes: 28276
#include<iostream>
#include<cmath>
using namespace std;
int main(){

  int a,b,c,n,r[10000];
  double d1,d2,d3,d4,e;
   
  while(1){
    
    cin >>a>>b>>c;
    
    if( a == 0 && b == 0 && c == 0 )break;
    
    d1=sqrt(a*a+b*b);
    d2=sqrt(b*b+c*c);
    d3=sqrt(a*a+c*c);
    d4=sqrt(d1*d1+c*c);

    cin >>n;

    for(int i=0 ; i < n ; i++){
      cin >>r[i];
    }
    
    for(int i=0 ; i < n ; i++){
      
      e=2*sqrt(2*r[i]*r[i]);
      
      if( d1 < 2*r[i] ){
	
	cout <<"OK"<<endl;
	
      }else if( d2 < 2*r[i] ){
	
	cout <<"OK"<<endl;
	
      }else if( d3 < 2*r[i] ){
      
	cout <<"OK"<<endl;
	
      }else if(d4 < 2*r[i] ){
	  
	cout <<"OK"<<endl;

      }else{
	
	cout <<"NA"<<endl;
      
      }
      
    }
    
  }
  return 0;
  
}

Measured memory_bytes: 1164
#include<iostream>
#include<numeric>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<map>
#include<utility>
#include<cmath>
#include<tuple>
#include<string>
#include<bitset>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
using namespace std;
typedef long long ll;

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

    ll ans=0;
    for(int i=1;i<=k;i++){
        for(int j=1;j<=k;j++){
            for(int l=1;l<=k;l++){
                ans+=__gcd(i,__gcd(j,l));
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3584
#include <algorithm>
#include <iostream>
#include <set>
#include <vector>

using namespace std;

int main()
{
    vector<int> v(3);
    cin >> v[0] >> v[1] >> v[2];
    sort(v.begin(), v.end());

    set<vector<int>> seen;
    int c = 0;
    while (v[0] % 2 == 0 && v[1] % 2 == 0 && v[2] % 2 == 0) {
        if (seen.find(v) != seen.end()) {
            c = -1;
            break;
        }

        seen.insert(v);

        vector<int> nv({v[0] / 2 + v[1] / 2,
                    v[1] / 2 + v[2] / 2,
                    v[2] / 2 + v[0] / 2});
        sort(nv.begin(), nv.end());
        v.swap(nv);
        ++c;
    }

    cout << c << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define each(a,x) for(auto a : (x))
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) ((a) = min((a),(b)))
#define chmax(a,b) ((a) = max((a),(b)))
#define in_range(x,l,r) ((l)<=(x) && (x)<(r))
#define fs first
#define sc second
#define pb push_back
#define sz size() 
#define MP make_pair
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<string> vs;

const int INF = 1e8;
const D EPS = 1e-8;

int main(){
  int n,l;
  cin >> n >> l;
  vs s(n);
  rep(i,n) cin >> s[i];
  sort(all(s));
  cout << accumulate(all(s), string("")) << endl;
}


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

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

using ll = long long;
using lb = long double;
using P = pair<string,string>;
using graph = vector<vector<ll>>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll INF = 1LL<<60;
const ll mod = 1000000007LL;

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

int main() {
  ll N,K;
  cin>>N>>K;
  vector<ll> v(N);
  rep(i,N) cin>>v[i];
  vector<ll> p,m,z;
  rep(i,N){
    if(v[i]<0) m.push_back(v[i]);
    if(v[i]==0) z.push_back(v[i]);
    if(v[i]>0) p.push_back(v[i]);
  }
  for(auto &x:m) x = -x;
  sort(m.begin(),m.end());
  sort(p.begin(),p.end());
  ll l = -INF,r = INF;
  while(r-l>1){
    ll mid = (r+l)/2;
    ll cnt = 0;
    if(mid<0){
      for(auto x:m) {
        ll t = (-mid-1)/x+1;
        cnt += p.end()-lower_bound(p.begin(),p.end(),t);
      }
    }
    if(mid == 0){
      cnt += (ll)m.size()*(ll)p.size();
      cnt += (ll)m.size()*(ll)z.size();
      cnt += (ll)z.size()*(ll)p.size();
      cnt += (ll)z.size()*((ll)z.size()-1)/2;
    }
    if(mid>0){
      cnt += (ll)m.size()*(ll)p.size();
      cnt += (ll)m.size()*(ll)z.size();
      cnt += (ll)z.size()*(ll)p.size();
      cnt += (ll)z.size()*((ll)z.size()-1)/2;
      ll s = 0;
      for(auto x:m){
        ll t = mid/x;
        s += upper_bound(m.begin(),m.end(),t)-m.begin();
        if(x*x<=mid) s--;
      }
      for(auto x:p){
        ll t = mid/x;
        s += upper_bound(p.begin(),p.end(),t)-p.begin();
        if(x*x<=mid) s--;
      }
      cnt += (s/2);
    }
    if(cnt>=K) r = mid;
    else l = mid;
  }
  cout<<r<<endl;
}

Measured memory_bytes: 6956
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <tuple>
#include <cassert>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b))
#define mt(a,b,c) make_tuple((a),(b),(c))

typedef long long ll;


template< typename T >
struct BinaryIndexedTree {
  vector< T > data;

  BinaryIndexedTree(int sz) {
    data.assign(++sz, 0);
  }

  T sum(int k) {
    T ret = 0;
    for(++k; k > 0; k -= k & -k) ret += data[k];
    return (ret);
  }

  void add(int k, T x) {
    for(++k; k < data.size(); k += k & -k) data[k] += x;
  }
};


int main(){
    int n; cin >> n;
    string s; cin >> s;
    int q; cin >> q;
    vector<BinaryIndexedTree<int>> bv(30, BinaryIndexedTree<int>(n));
    rep(i,s.length())  bv[s[i]-'a'].add(i, 1);
    // cout << "ok" << endl;
    rep(f, q){
        int qu; cin >> qu;
        if(qu==1){
            int a; char b; cin >> a >> b;
            if(s[a-1]!=b){
                bv[s[a-1]-'a'].add(a-1,-1);
                bv[b-'a'].add(a-1,1);
                s[a-1] = b;
            }
        }else{
            int a,b; cin >> a >> b;
            int ans = 0;
            for(int i=0; i<='z'-'a'; i++) if(bv[i].sum(b-1) - (a-1 == 0 ? 0 : bv[i].sum(a-2)) > 0) ans++;
            cout << ans << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 61560
n = int(input())
nim = []
for i in range(n):
  a,k = map(int,input().split())
  while a%k != 0 and a>k:
    t = a//k
    if t+1>=a%k:
      a -= t+1
    else:
      y = a%k
      a -= y//(t+1)*(t+1)
  if a<k:
    x = 0
  elif a%k == 0:
    x = a//k
  nim.append(x)
ans = 0
for i in nim:
  ans ^= i
if ans == 0:
  print("Aoki")
else:
  print("Takahashi")

Measured memory_bytes: 41708
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define P pair<int,int>
#define PI 3.141592653589793
const int INF = 1001001001;
const ll MX = 1e18;
const int mod = 1000000007;

int main() {
	int x;
	cin >> x;
	if (x >= 30) cout << "Yes" << endl;
	else cout << "No" << endl;

}


Measured memory_bytes: 3620
n, x = map(int,input().split())
m = []
for i in range(n):
    q = int(input())
    m.append(q)
M = 0
for i in range(len(m)):
    M += m[i]
X = x - M
m.sort()
ans = X / m[0]
print(int(ans)+n)

Measured memory_bytes: 3064
#include <iostream>
#include <cstring>//string的头文件
using namespace std;
int main()
{
    string a;//定义
    cin >> a;//输入
    if (a[0] == '9' || a[1] == '9')//嘿嘿10<=N<=99，那我就不客气了
        cout << "Yes";//输出"Yes"
    else
        cout << "No";//输出"No"
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define gcd(m,n) __gcd(m,n)
#define lcm(m,n) m*(n/gcd(m,n))
#define fast std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pi acos(-1.0)
#define endl '\n'
#define MOD 1000000007
#define ull unsigned long long
#define ll long long
#define ld long double
#define pb push_back
#define dbg(x) cout << #x << "  " << x << endl;
 
ll power(ll base, ll exp) 
{ll res=1;while(exp>0) {if(exp%2==1) res=(res*base);base=(base*base);exp/=2;}return res;}
ll mod(ll a, ll b) {return (a % b + b) % b;}
ll powerm(ll base,ll exp,ll mod) 
{ll ans=1;while(exp){if(exp&1) ans=(ans*base)%mod;exp>>=1,base=(base*base)%mod;}return ans;}
 
struct custom_hash 
{
    static uint64_t splitmix64(uint64_t x) 
	{
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const 
	{
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
/* DSU 
int find_set(int v) {
    if (v == parent[v])
        return v;
    return parent[v] = find_set(parent[v]);
}
void make_set(int v) {
    parent[v] = v;
    rank[v] = 0;
}
void union_sets(int a, int b) {
    a = find_set(a);
    b = find_set(b);
    if (a != b) {
        if (rank[a] < rank[b])
            swap(a, b);
        parent[b] = a;
        if (rank[a] == rank[b])
            rank[a]++;
    }
}
*/ 
int main()
{  
	fast; 
	ll n; cin>>n;
	priority_queue<ll>pq;
	for(ll i = 0; i < n; i++)
	{
		ll x; cin>>x;
		pq.push(x);
	}
	ll tries = n-2; ll ans = pq.top(); pq.pop();
	while(!pq.empty() && tries > 0)
	{
		if(tries >= 2)
		{
			tries -= 2;
			ans += pq.top()*2;
			pq.pop();
		}
		else if(tries >= 1)
		{
			tries -= 1;
			ans += pq.top();
			pq.pop();
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5324
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl

struct data{
    int x, s, t;
};

bool cmp(const data &a, const data &b){
    if(a.x != b.x){return a.x < b.x;}
    if(a.s != b.s){return a.s < b.s;}
    return a.t < b.t;
}

int main(){
    ll n, q;
    cin >> n >> q;
    vector<data> xst(n);
    for(int i = 0; i < n; i++){
        cin >> xst[i].s >> xst[i].t >> xst[i].x;
        xst[i].s -= xst[i].x;
        xst[i].t -= xst[i].x;
    }
    sort(all(xst),cmp);
    set<pii> d;
    for(int i = 0; i < q; i++){
        int dd;
        cin >> dd;
        d.insert({dd, i});
    }
    vector<int> ans(q, -1);

    for(int i = 0; i < n; i++){
        auto it = d.lower_bound({xst[i].s, -1});
        while(it != d.end()){
            if(it->first >= xst[i].t){break;}
            ans[it->second] = xst[i].x;
            d.erase(it++);
        }
    }
    for(int i = 0; i < q; i++){
        cout << ans[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 14336
#include "bits/stdc++.h"
using namespace std;


/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define pb push_back


/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;


/* constant */
const int inf = pow(2, 62);
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};
const string alpha = "abcdefghijklmnopqrstuvwxyz";

/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
string readline(){string s;getline(cin, s);return s;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}


/* general_method */
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; }




/* main */



signed main(){

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



    int n = input();

    vi arr; rep(i,0,n) arr.push_back(input());


    sort(all(arr));

    int ans = 0;
    rep(i,0,n - 1){
        ans += arr[i];
    }

    ans += arr.back() / 2;

    print(ans);

    

    

}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next());
    int K = Integer.parseInt(sc.next());
    int Q = Integer.parseInt(sc.next());
    int[] B = new int[N];
    
    for (int i = 0; i < N; i++) {
      B[i] = Q;
    }
    
    for (int i = 0; i < Q; i++) {
      B[Integer.parseInt(sc.next())-1]--;
    }
    
    for (int i = 0; i < N; i++) {
      if (K - B[i] > 0) {
        System.out.println("Yes");
      } else {
        System.out.println("No");
      }
    }
  }
}

Measured memory_bytes: 71444
<?php
    // 自分の得意な言語で
    // Let's チャレンジ！！

    $n_tree = fgets(STDIN);

    while ($n_tree != 0) {

        $input_line = fgets(STDIN);
        $number = preg_split("/[\s,]+/", $input_line);
        $area_w = intval($number[0]);
        $area_h = intval($number[1]);
     
        // ①、配列を作る。
        $area = [];
    //マス目を作る。
        for ($i = 0; $i < $area_h; $i++) {
            // ②、横の配列を作る。
            $area_row = [];
            for ($j = 0; $j < $area_w; $j++) {
                //　③、横の配列にfalseが入る。
                    $area_row[] = false;
            }
            // ④、２次元配列の完成。
            $area[] = $area_row;
        }
    //柿の木を植える。
        for ($i = 0; $i < intval($n_tree); $i++) {
            $input_line = fgets(STDIN);
            $number = preg_split("/[\s,]+/", $input_line);
            $tree_w = intval($number[0]);
            $tree_h = intval($number[1]);
            $area[$tree_h - 1][$tree_w - 1] = true;
        }
    
        // foreach($area as $are){
        //     foreach($are as $ar) {
        //         if ($ar) {
        //             echo 'X';
        //         } else {
        //             echo '.';
        //         }
        //     }
        //     echo "\n";
        // }
    
    // 柿の木の最大位置を探す。
        $input_line2 = fgets(STDIN);
        $number = preg_split("/[\s,]+/", $input_line2);
        $own_w = intval($number[0]);
        $own_h = intval($number[1]);
        //カウントの最大値（柿の木の数）
        $count = 0;
        for ($i = 0; $i <= $area_w - $own_w; $i++) {
            for ($j = 0; $j <= $area_h - $own_h; $j++) {
                //一時的なカウントの変数（全ての柿の木の数が入る。）
                $c = 0;
                for ($k = $i; $k < $own_w + $i; $k++) {
                    for ($l = $j; $l < $own_h + $j; $l++) {
                        if( $area[$l][$k] == true) {
                            $c += 1;
                        }
                    }
                }
                if ($count < $c){
                    $count = $c;
                }       
                // print $c;
            }
        }
    
        echo $count;
        echo "\n";

        $n_tree = fgets(STDIN);

    }



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

int main(){
    int a=0;
    int b=0;
    int c=0;
    cin >> a>> b>>c; 
    if ((a < c && c< b)|| (a>c)&&(c>b)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <unordered_map>
#include <climits>
#include <set>
#include <unordered_set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>
#include <locale>
#include <random>
#include <type_traits>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

using LL = long long;

//------------------------------------------
//------------------------------------------

int main() {

    int N, K;
    cin >> N >> K;

    vector<int> P(N);
    for (int i = 0; i < N; i++) cin >> P[i];

    vector<int> a(N, 0);
    for (int i = 1; i < N; i++) {
        if (P[i - 1] < P[i]) a[i] = 1;
        a[i] += a[i - 1];
    }

    set<int> st;
    for (int i = 0; i < K; i++) st.insert(P[i]);

    bool cute = a[K - 1] == K - 1;
    int ans = !cute;

    for (int i = 0; i < N - K; i++) {
        bool ok = (*st.begin() == P[i]);
        st.erase(P[i]);
        st.insert(P[i + K]);
        //SHOW_VECTOR(st);
        ok &= (*st.rbegin() == P[i + K]);
        if (a[i + K] - a[i + 1] == K - 1) {
            cute = true;
        } else if (!ok) {
            ans++;
        }
    }

    cout << ans + cute << endl;

    return 0;
}




































Measured memory_bytes: 11136
//  [amitdu6ey]
// g++ -std=c++11 -o2 -Wall filename.cpp -o filename
#include <bits/stdc++.h>
#define hell 1000000009
#define bug1(x) cout<<"$ "<<x<<" $"<<endl
#define bug2(x) cout<<"% "<<x<<" %"<<endl
#define bug3(x) cout<<"# "<<x<<" #"<<endl
#define ll long long
#define pb push_back
#define mp make_pair
#define tr(z) for(auto it=z.begin(); it!=z.end(); it++)
#define rloop(i,a,b) for(long long i=a; i>=b;i--)
#define loop(i,a,b) for(long long i=a; i<b; i++)
#define vbool vector< bool >
#define vvbool  vector< vector<bool> >
#define vchar vector<char>
#define vi vector<int>
#define vvi vector< vector<int> >
#define pll pair<long long, long long>
#define vll vector<long long>
#define vvl vector< vector<long long> >
#define ninf numeric_limits<long long>::min()
#define pinf numeric_limits<long long>::max()
#define comp(a,b) (abs(a-b)<1e-9) // to compare doubles
using namespace std;

void solve(){
    int n;
    cin>>n;
    vector< vector<ll> > mat(n, vector<ll>(3,0));
    loop(i,0,n){
        loop(j,0,3){
            cin>>mat[i][j];
        }
    }
    vector< vector<ll> > dp(n, vector<ll>(3,ninf));
    dp[0][0] = mat[0][0];
    dp[0][1] = mat[0][1];
    dp[0][2] = mat[0][2];
    loop(i,1,n){
        loop(j,0,3){
            loop(k,0,3){
                if(j==k) continue;
                dp[i][j] = max(dp[i][j],dp[i-1][k] + mat[i][j]);
            }
        }
    }
    cout<<max({dp[n-1][0],dp[n-1][1],dp[n-1][2]})<<endl;
    return;
}

int main(){
    ios_base::sync_with_stdio(0);
    cout.tie(0);
    cin.tie(0);
    int test_cases=1;
    //cin>>test_cases;
    while(test_cases--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 14296
#include <bits/stdc++.h>
#define rep(i, n) for (ll(i) = 0; (i) < (n); (i)++)
#define all(x) (x).begin(), (x).end()
#define print(x) cout << (x) << endl;

typedef long long ll;
const ll INF = 99999999999999;
const ll MOD = 1000000007;

using namespace std;

int main()
{
    ll a, b;
    cin >> a >> b;
    ll ans;
    if (a > 0 && a < 10 && b > 0 && b < 10)
    {
        ans = a * b;
    }
    else
    {
        ans = -1;
    }

    cout << ans << endl;

    return 0;
}

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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

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

int main(){
    int n, d, x;
    cin >> n >> d >> x;
    vi a(n);
    rep(i, n) cin >> a[i];
    int ans = 0;
    rep(i, n) ans += (d+a[i]-1)/a[i];
    ans += x;
    cout << ans << endl;
    return 0;
}


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

#define rep(i, a) for (int i = 0; i < (a); i++ )
#define FOR(i, m, n) for(int i = m; i < n; i++)
 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);


long long gcd(long long a, long long b) {
   if (a%b == 0) {
       return(b);
   }
   else {
       return(gcd(b, a%b));
   }
}

long long lcm(long long a, long long b) {
   long long tmp = max(a,b)/gcd(a,b);
   return min(a,b)*tmp;}

int main() {
    int N;
    cin >> N;
    int ans = N%1000;
    ans = 1000-ans;
    if (ans==1000) ans = 0;
    cout << ans << endl;        
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); (i)--)
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
using namespace std;

struct UnionFind{
  vector<int> par;
  vector<int> treerank;
  
  UnionFind(int n){
    init(n);
  }
  
  void init(int n){
    par.resize(n); treerank.resize(n);
    rep(i, n) par[i] = i, treerank[i] = 0;
  }
  
  int find(int x){
    if(par[x] == x) return x;
    return par[x] = find(par[x]);
  }
  
  void unite(int x, int y){
    x = find(x); y = find(y);
    if(x == y) return;
    if(treerank[x] < treerank[y]) swap(x, y);
    if(treerank[x] == treerank[y]) treerank[x]++;
    par[y] = x;
    return;
  }
  
  bool same(int x, int y){
    return find(x) == find(y);
  }
};

int main(){
  int n; cin >> n;
  vector<int> to[n];
  rep(i, n-1){
    int a, b; cin >> a >> b;
    to[a-1].push_back(b-1); to[b-1].push_back(a-1);
  }
  int prev[n]; rep(i, n) prev[i] = -1;
  queue<int> que;
  que.push(0);
  prev[0] = 0;
  while(!que.empty()){
    int now = que.front(); que.pop();
    rep(i, to[now].size()){
      if(prev[to[now][i]] >= 0) continue;
      prev[to[now][i]] = now;
      que.push(to[now][i]);
    }
    if(prev[n-1] >= 0) break;
  }
  vector<int> route;
  int i = n-1;
  while(i != 0){
    route.push_back(i);
    i = prev[i];
  }
  route.push_back(0);
  int ng1 = route[(int)route.size() / 2 - 1];
  int ng2 = route[(int)route.size() / 2];
  UnionFind uf(n);
  rep(i, n)rep(j, to[i].size())if((i!=ng1 || to[i][j]!=ng2) && (i!=ng2 || to[i][j]!=ng1)){
    uf.unite(i, to[i][j]);
  }
  int cnt = 0;
  rep(i, n)if(uf.same(0, i)) cnt++;
  cout << (cnt*2 > n ? "Fennec" : "Snuke") << endl;
}

Measured memory_bytes: 7416
from collections import deque

N = int(input())
S = input()

count = deque()

left = {'W':0, 'E':0}
w = S.count('W')
right = {'W':w, 'E':N-w}

for i in range(N):
    base = S[i]
    right[base] -= 1
    count.append(left['W']+right['E'])
    left[base] += 1
print(min(count))

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

#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll ;
typedef unsigned long long ull ;
typedef long double ld ;

const ll MOD = 1E9 + 7, INF = 2E18 + 5 ;
const double PI = 2 * acos(0.0) ;
const long double EPS = 1.0E-14 ;

int main()
{
    ll n ;
    cin >> n ;
    if (n == 1) cout << 0 ;
    else if (n == 0)    cout << 1 ;

    return 0 ;
}


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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<string> vst;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;


const ll mod=(1e+9)+7;
const ll inf=1e+16; 

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m;i>=n;i--)

int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
 
 ll n,m=0,index;
  cin >> n;
  vll a(n);
  vpll res;
 
  rep(i,0,n) {
    cin >> a[i];
    if(m<abs(a[i])) {
      index=i;
      m=abs(a[i]);
    }
    }
  
  rep(i,0,n) if(a[index]*a[i]<0) res.push_back(make_pair(index+1,i+1));
  
  if(a[index]>=0) rep(i,0,n-1) res.push_back(make_pair(i+1,i+2));
  else repr(i,n-1,1) res.push_back(make_pair(i+1,i));
  
  
  
  
 
 cout << res.size() << endl;
 for(auto p:res) cout << p.first << " " << p.second << endl;
  
}


Measured memory_bytes: 256
from collections import deque

H,W=map(int,input().split())
sy,sx=[int(i)-1 for i in input().split()]
gy,gx=[int(i)-1 for i in input().split()]

c=[]
for i in [0]*H:
    c.append(input())

dic=[]
for i in range(-2,3):
    for j in range(-2,3):
        if i!=0 or j!=0:
            dic.append((i,j))
    
INF=10**9
vis=[[INF]*W for _ in [0]*H]

q=deque()
q.appendleft((sx,sy))
vis[sy][sx]=0
res=-1
while q:
    x,y=q.popleft()
    if (x,y)==(gx,gy):
        res=vis[y][x]
    for dx,dy in dic:
        nx,ny=x+dx,y+dy
        if 0<=nx<=W-1 and 0<=ny<=H-1:
            if vis[ny][nx]>vis[y][x] and c[ny][nx]!='#':
                if dx**2+dy**2<2:
                    vis[ny][nx]=vis[y][x]
                    q.appendleft((nx,ny))
                else:
                    vis[ny][nx]=vis[y][x]+1
                    q.append((nx,ny))
        if res>-1:
            break
    if res>-1:
            break
                
print(res)

Measured memory_bytes: 139152
#include<bits/stdc++.h>
using namespace std;
#define int long long
//#undef int
#define mk make_pair
typedef pair<int, int> pii;
typedef pair<pii, int> ppi;
#define mod 1000000007

int N;
char s[1000006];
int Q, k[100];
int d[1000006], m[1000006];

signed main()
{
    cin >> N;
    for(int i = 1; i <= N; i++){
        cin >> s[i];
        if(s[i] == 'D'){
            d[i]++;
        }
        else if(s[i] == 'M'){
            m[i]++;
        }
        d[i] += d[i - 1];
        m[i] += m[i - 1];
    }
    cin >> Q;
    for(int i = 0; i < Q; i++){
        cin >> k[i];
    }
    for(int i = 0; i < Q; i++){
        int K = k[i];
        int l = 1;
        int dm = 0, dmc = 0;
        for(int j = 1; j <= N; j++){
            if(j - l >= K && l < N){
                if(s[l] == 'D'){
                    dm -= (m[j - 1] - m[l - 1]);
                }
                l++;
            }
            if(s[j] == 'M'){
                dm += (d[j - 1] - d[max(j - K, 0ll)]);
            }
            else if(s[j] == 'C'){
                dmc += dm;
            }
        }
        cout << dmc << endl;
    }

    return 0;
}

/*

*/


Measured memory_bytes: 16896
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#define debug(x) cerr << __LINE__ << ' ' << #x << ':' << x << '\n'
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);

	int k, t;
	cin >> k >> t;
	vector<int> a(t);
	int m = 0;
	rep(i, t) {
		cin >> a[i];
		chmax(m, a[i]);
	}
	int r = k - m;
	r = 2 * r + 1;
	k -= r;
	cout << (k <= 0 ? 0 : k) << '\n';
}

Measured memory_bytes: 3616
#include<stdio.h>

int wt(int b);
int main()
{
    int n,a;
    scanf("%d %d",&n,&a);
    printf("%d",(a!=100)?(wt(n)*a):(wt(n)*101));
}

int wt(int b)
{
    int c=1,i;
    for(i=0;i<b;i++)
    {
        c*=100;
    }
    return c;
}

Measured memory_bytes: 128
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>

#include <math.h>
using namespace std;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int n;
    cin >> n;
    if(n%2 == 0 ){
        cout << 0.5 << endl;
    }else{
        double s = n + 1;
        double b = 2 * n;
        cout << s / b << endl;
    }
}


Measured memory_bytes: 256
#include "atcoder/all"
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using namespace atcoder;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define VVV(T, a, b, c, d)                                                     \
  vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d)))
#define SP(a) fixed << setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N, M;
  cin >> N >> M;
  vl A(N), B(M);
  REP(i, N) cin >> A[i];
  REP(i, M) cin >> B[i];

  AUTO(c, convolution(A, B)) cout << c << " ";
  cout << endl;

  return 0;
}


Measured memory_bytes: 27292