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

using ll = long long;
using ld = long double;
using P = pair<int, int>;
//using P = pair<double, double>;
using edge = struct {int to; ll cost;};

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()

const int di[] = {-1, 0, 1, 0, 1, 1, -1, -1};
const int dj[] = {0, -1, 0, 1, 1, -1, 1, -1};
const int INF = 1e9+100;
const ll INF64 = 7e18l;
const int mod = 1000000007;

struct prime
{
  vector<bool> num;
  prime(int n) : num(n+1, true)
  {
    num[0] = false;
    num[1] = false;
    for(int i = 2; i <= n; i++) {
      if(num[i]) {
        for(int j = 2; i*j <= n; j++) num[i*j] = false;
      }
    }
  }
  bool isPrime(int x)
  {
    return num[x];
  }
};
struct UnionFind {
    vector<int> par;
    UnionFind(int N) : par(N) {
        for(int i = 0; i < N; i++) par[i] = i;
    }
    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }
    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }
    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};
struct combination
{
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1)
  {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i)
      fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i)
      ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k)
  {
    if (k < 0 || k > n)
      return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
};

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

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


void solve()
{
  int a, b;
  cin >> a >> b;
  if(a <= 8 && b <= 8) cout << "Yay!" << "\n";
  else cout << ":(" << "\n";
}

int main()
{
  solve();
  return 0;
}


Measured memory_bytes: 256
INFTY = 10**12
def wf(H):
    d = [[INFTY for _ in range(N+1)] for _ in range(N+1)]
    for i in range(1,N+1):
        d[i][i] = 0
        if i in H:
            for x in H[i]:
                j,c = x[0],x[1]
                d[i][j] = c
    for k in range(1,N+1):
        for i in range(1,N+1):
            for j in range(1,N+1):
                d[i][j] = min(d[i][j],d[i][k]+d[k][j])
    return d
N,M,L = map(int,input().split())
G = {}
for _ in range(M):
    A,B,C = map(int,input().split())
    if A not in G:
        G[A] = []
    G[A].append((B,C))
    if B not in G:
        G[B] = []
    G[B].append((A,C))
d1 = wf(G)
F = {}
for i in range(1,N):
    for j in range(i+1,N+1):
        if d1[i][j]<=L:
            if i not in F:
                F[i] = []
            F[i].append((j,1))
            if j not in F:
                F[j] = []
            F[j].append((i,1))
d2 = wf(F)
Q = int(input())
for _ in range(Q):
    s,t = map(int,input().split())
    if d2[s][t]<INFTY:
        print(d2[s][t]-1)
    else:
        print(-1)


Measured memory_bytes: 68184
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cctype>
#include <map>
#include <set>

const int INT_INF = 1e9;
const long long LONG_INF = 1e18;
const long long MOD = 1e9 + 7;
const double PI = 3.14159265358979323846;

using namespace std;

int main()
{
    long long int a, b;
    cin >> a >> b;

    long long int ans = 0;
    if (a * b < 0) {
        ans++;
        a = -a;
    }
    else if (a > b) {
        if (a == 0 || b == 0) {
            ans++;
        }
        else {
            ans += 2;
        }
    }

    ans += abs(a - b);

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
int t[110000], x[110000], y[110000];
int main() {
    int N;
    
    cin >> N;
    t[0] = x[0] = y[0] = 0;  
    for (int i = 0; i < N; ++i) cin >> t[i+1] >> x[i+1] >> y[i+1];  
 
    bool can = true;
    for (int i = 0; i < N; ++i) {
        int dt = t[i+1] - t[i];
        int dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i]);
        if (dt < dist) can = false;
        if (dist % 2 != dt % 2) can = false; 
    }
 
    if (can) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 1408
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
#include<boost/operators.hpp>
#include<boost/dynamic_bitset.hpp>

namespace adaptor = boost::adaptors;
using index_t = std::size_t;

class union_find
{
	std::vector<boost::optional<index_t>> parent;
	std::vector<index_t> rank;
	std::set<index_t> tops;
	std::size_t sz;
public:
	union_find(std::size_t N) :parent(N), rank(N), tops(), sz(N)
	{
		for (auto i : boost::irange<index_t>(0, N))
		{
			tops.emplace(i);
		}
	}
	index_t find(index_t a)
	{
		if (!parent[a])
		{
			return a;
		}
		else
		{
			return *(parent[a] = find(*parent[a]));
		}
	}
	void merge(index_t a, index_t b)
	{
		auto x = find(a);
		auto y = find(b);
		if (x != y)
		{
			--sz;
			if (rank[x] < rank[y])
			{
				tops.erase(x);
				parent[x] = y;
			}
			else if (rank[y] < rank[x])
			{
				tops.erase(y);
				parent[y] = x;
			}
			else
			{
				tops.erase(y);
				parent[y] = x;
				++rank[x];
			}
		}
	}
	std::size_t size()const
	{
		return sz;
	}
	auto begin()const
	{
		return tops.begin();
	}
	auto end()const
	{
		return tops.end();
	}
};

bool run(std::size_t N, std::size_t M, std::vector<std::tuple<index_t, index_t, bool>>const& data)
{
	union_find disjoint(N);
	bool flag = false;
	for (auto&& t : data)
	{
		index_t a, b;
		bool c;
		std::tie(a, b, c) = t;
		if (c)
		{
			disjoint.merge(a, b);
		}
		else
		{
			flag = true;
		}
	}
	for (auto&& t : data)
	{
		index_t a, b;
		bool c;
		std::tie(a, b, c) = t;
		if (!c && disjoint.find(a) == disjoint.find(b))
		{
			return false;
		}
	}
	if (flag && disjoint.size() < 3)
	{
		return false;
	}
	auto g = disjoint.size();
	auto min = N - 1 + flag;
	auto max = N + g * (g - 1) / 2 - g;
	return min <= M && M <= max;
}

void Main()
{
	std::size_t N, M, Q;
	std::cin >> N >> M >> Q;
	std::vector<std::tuple<index_t, index_t, bool>> data;
	for (auto i : boost::irange<std::size_t>(0, Q))
	{
		index_t a, b, c;
		std::cin >> a >> b >> c;
		data.emplace_back(a, b, c == 0);
	}
	if (run(N, M, data))
	{
		std::cout << "Yes" << std::endl;
	}
	else
	{
		std::cout << "No" << std::endl;
	}
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

Measured memory_bytes: 10096
// ------------------------------------
// Date:2018/ 3/29
// Problem:_ _ _ b.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 2e5 + 1;

int road[MAX_N];
int train[MAX_N];

map< pair< int, int >, int > cnt;

int N, K, L;

int root(int* par, int n)
{
  if (par[n] < 0) return n;
  return par[n] = root(par, par[n]);
}

bool unite(int* par, int p, int q)
{
  p = root(par, p);
  q = root(par, q);
  if (p == q) return false;
  if (par[p] > par[q]) swap(p, q);
  par[p] += par[q];
  par[q] = p;
  return true;
}

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

  cin >> N >> K >> L;
  fill_n(road, N, -1);
  fill_n(train, N, -1);

  vector< int > p(K);
  vector< int > q(K);
  
  REP(i, K) {
    cin >> p[i] >> q[i];
    p[i]--; q[i]--;
    unite(road, p[i], q[i]);
  }

  vector< int > r(L);
  vector< int > s(L);
  REP(i, L) {
    cin >> r[i] >> s[i];
    r[i]--; s[i]--;
    unite(train, r[i], s[i]);
  }

  REP(i, N)
    cnt[{root(road, i), root(train, i)}]++;

  REP(i, N)
    cout << cnt[{root(road, i), root(train, i)}] << (i < N - 1 ? " " : "\n");

  return 0;
}



Measured memory_bytes: 15104
while True:
  s,t= map(int,input().split())
  if s+t == 0:break
  c=0
  for i in range(1,s+1):
    for j in range(i+1,s+1):
      for k in range(j+1,s+1):
        if i+j+k ==t:c+=1
  print(c)


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

using namespace std;

int main()
{
  string str;

  getline(cin, str);

  int n;

  n = str.size();

  for (int i = 0; i < n; i++)
  {
    char ch = str[i];
    if (islower(ch))
    {
      str[i] = toupper(ch);
    }
    else
    {
      str[i] = tolower(ch);
    }
  }

  cout << str << endl;
}



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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
  int a, b;
  cin >> a >> b;

  cout << (a > 8 || b > 8 ? ":(" : "Yay!");
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3616
A=raw_input()
S=0
X=0
for i in A:
    if(i==" "):
        S+=X
        X=0
    else:
        X*=10
        X+=int(i)
S+=X
B=raw_input()
T=0
Y=0
for i in B:
    if(i==" "):
        T+=Y
        Y=0
    else:
        Y*=10
        Y+=int(i)
T+=Y
if(S>T):
    print(S)
else:
    print(T)

Measured memory_bytes: 6444
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b;
  cin >> a >> b;
  
  if ( a % 2 == 1 && b % 2 == 1 ){
    cout << "Odd" << endl;
  }
  
  else {
    cout << "Even" << endl;
  }
}

Measured memory_bytes: 256
s = gets.to_s.chomp.bytes
q = gets.to_s.to_i

reverse_state = false

l = []
r = []
$<.each do |query|
  
  query.chomp!
  # p query
  if query == "1"
    reverse_state = !reverse_state
    # s.reverse!
  else
    if query[0,3] == "2 1"
      reverse_state ? (r << query[-1].ord)  : (l << query[-1].ord)
    else
      reverse_state ? (l << query[-1].ord) : (r << query[-1].ord)
    end
  end
end

if reverse_state
  puts (r.reverse + s.reverse + l ).pack("U*")
else
  puts (l.reverse + s + r ).pack("U*")
end

Measured memory_bytes: 10588
#include <iostream>
#include <iomanip>
#include<vector>
#include <algorithm>
#include <queue>
#include<string>
#include <map>
#include <cmath>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <utility>
#include <set>
#include <bitset>
#include <cstring>
typedef long long ll;
typedef long double ld;


#define REP(i,s,n)for(ll i=s;i<(n);++i)
#define rep(i,n) REP(i,0,n)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
using Graph = vector<vector<ll>>;
using P = pair<ll, ll>;

/* 4 方向への隣接頂点への移動を表すベクトル */
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int MAX_A = 100000;
const int MAX_B = 0;
ll H, W;
ll sX, sY, gX, gY;
ll N, M, L;
vector<int> graph;

int vector_finder(std::vector<int> vec, int number) {
	auto itr = std::find(vec.begin(), vec.end(), number);
	size_t index = std::distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}
int main() {
	cin >> N;
	cout << N + pow(N, 2) + pow(N, 3) << endl;
	return 0;
}

Measured memory_bytes: 4272
#include <stdio.h>

int main(void) {

int H,W,x,y;char s;
scanf("%d %d\n",&H,&W);
while((H!=0)||(W!=0)){
for(y=1;y<=H;y++){
for(x=1;x<=W;x++){
s=((x+y)%2==0)?'#':'.';
printf("%c",s);
}
printf("\n");
}
printf("\n");
scanf("%d %d\n",&H,&W);
}
return 0;
}

Measured memory_bytes: 576
// #include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;
typedef long long ll;

#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0; i<n; i++)

int Prime_factorize(ll n) {
    ll cnt=0;
    for (ll i=2; i*i<=n; i++) {
        ll th = 1;
        ll now = 0;
        while (n%i == 0) {
            now++;
            if (th == now) {
                cnt++;
                now = 0;
                th++;
            }
            n /= i;
        }
        if (i != 2) i++;
    }
    if(n != 1) cnt++;
    return cnt;
}

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

    int cnt = Prime_factorize(n);

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<bits/stdc++.h>
#define mod 1000000007
#define ps(x,noOfDecimal) fixed<<setprecision(noOfDecimal)<<x
using namespace std;

signed main()
{
    if (fopen("input.txt", "r")) {
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    }
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // cin>>t;
    while (t--) {
        int n,ans=0;
        cin>>n;
        vector<int>freq(n);
        for(int i=1;i<n;i++){
            for(int j=i;j<n;j+=i){
                freq[j]++;
            }
        }
        for(int i=1;i<n;i++){
            ans+=freq[i];
            // cout<<freq[i]<<" ";
        }
        cout<<ans;
    }   
    return 0;
}

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

int main(){
  long long N, A, B, C, D, E;
  cin >> N >> A >> B >> C >> D >> E;
  long long shrt= min({A, B, C, D, E});
  long long ans = (N + shrt - 1) / shrt + 4;
  cout << ans << endl;
}

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

using namespace std;

typedef long long ll;

#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define bit(n) (1<<(n))

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

int main(){
	string s, ans;
	cin >> s;
	s.replace(5, 1, " ");
	s.replace(13, 1, " ");
	cout << s << endl;
	
	return 0;
}


Measured memory_bytes: 256
def triangles(a): 
    n = len(a) 
    a.sort() 
    count = 0
    for i in range(0,n-2):
        k=i+2
        for j in range(i+1,n): 
            while (k < n and a[i] + a[j] > a[k]): 
                k += 1
            if(k>j): 
                count += k - j - 1
    return count
n=int(input())
a=list(map(int,input().split()))
print(triangles(a))

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long long unsigned int llu;
#define pb push_back
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
#define YUGEN ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define lp(i,start,end) for(int i=start;i<end;i++)
#define MAX 105
#define BPC(x)  __builtin_popcountll(x)
#define test() ll t; cin>>t; while(t--)
#define gcd(a,b)  __gcd(a,b)
ll gcd(ll a,ll b) {if (a==0) return b;return gcd(b%a,a);}

int main()
 {
    YUGEN;
      float d,t,s;
      cin>>d>>t>>s;
      if(t>=d/s)
        cout<<"Yes";
      else
        cout<<"No";




 return 0;
 }




Measured memory_bytes: 3724
N = int(input())
A = sorted(list(map(int,input().split())),key=lambda x: -x)
import heapq
Q = [-A.pop(0)]
ans = 0
for a in A:
    tmp = -heapq.heappop(Q)
    ans += tmp
    heapq.heappush(Q,-a)
    heapq.heappush(Q,-a)
print(ans)

Measured memory_bytes: 31592
#include<bits/stdc++.h>
using namespace std;
int main()
{

    long long a,b,c,d,sumw=0,sume=0;
    string sr;
    vector<long long>ww;
    vector<long long>ee;
    vector<long long>vc;
    cin>>a;
    getchar();
    cin>>sr;
    for(long long i=0; i<sr.size(); i++)
    {
        if(sr[i]=='W')
        {
            sumw++;
        }
        else
        {
            sume++;
        }
        ww.push_back(sumw);
        ee.push_back(sume);
    }

    for(long long i=0; i<sr.size(); i++)
    {

        long long summer=0;
        if(i>0)
            summer=summer+ww[i-1];
        summer=summer+sume-ee[i];


        vc.push_back(summer);
       // cout<<summer<<endl;

    }




    sort(vc.begin(),vc.end());
    cout<<vc[0];



}


Measured memory_bytes: 15336
def main():
    n, k, *x = map(int, open(0).read().split())
    l = x[0 + k - 1] - x[0] + min(abs(x[0 + k - 1]), abs(x[0]))

    for i in range(n - k + 1):
        y = x[i + k - 1] - x[i] + min(abs(x[i + k - 1]), abs(x[i]))
        if y < l:
            l = y

    print(l)


if __name__ == '__main__':
    main()


Measured memory_bytes: 14052
# 2019/07/07
# AtCoder Beginner Contest 133 - B

# Input
n, d = map(int,input().split())
xl = list()
for i in range(n):
    x = list(map(int,input().split()))
    xl.append(x)

ans = 0

for i in range(n-1):
    for j in range(i+1, n):
        wsum = 0
        for k in range(d):        
            wsum += (xl[i][k] - xl[j][k]) ** 2

        if wsum ** (1/2) % 1 == 0:
            ans += 1

# Output
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

const long long INF = 1e18;
const ll mod = 1000000007;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll ans = 0;
    ll sum = 0;
    for(int i = 0; i < N; i++) {
        ll a;
        cin >> a;
        sum += a;
        ans += mod - (a * a % mod);
    }
    sum %= mod;
    ans = ans + (sum * sum) % mod;
    ans %= mod;
    ans = ans * (mod + 1) / 2;
    ans %= mod;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3648
#include<iostream>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
#include <sstream>
#define rep(i,n) for(ll i=0;i<(n);++i)
using namespace std;
typedef long long ll;

int main()
{
    ll n;
    ll count=1;
    cin>>n;
    ll max,min;
    vector<ll> p(n);
    rep(i,n)
    {
        ll rec;
        cin>>rec;

        if(i==0)
        {
            max=rec;
            min=rec;
        }
        else if(rec>max)
        {   
            max=rec;
        }
        else if(rec<min)
        {
            min=rec;
            count++;
        }


    }
        cout<<count<<endl;


}

Measured memory_bytes: 1792
#include <iostream>
#include <math.h>
#include <iomanip>

using namespace std;

int main(int argc, const char * argv[]) {
    int N;
    int K;
    cin >> N >> K;
    
    double ans = 0;
    for (int i = 1; i <= N; i++) {
        //cout <<  ceil(log2((double)K/i)) << endl;

        if ((int)ceil(log2((double)K/i)) <= 0) {
            ans = ans + (1/(double)N);
        } else {
            //cout << (1/(double)N) << " " << (1/2.0) << " " << ceil(log2((double)K/i)) << endl;
            ans = ans + (1/(double)N) * pow((1/2.0), ceil(log2((double)K/i)));
        }
    }
    cout << fixed  <<  setprecision(12) << ans;
    return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Jaynil
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long n = in.nextLong();
            if (n % 2 != 0) {
                out.println(0);
                return;
            }
            long p = 5;
            long ans = 0;
            while (p <= 1000000000000000000L && n / p > 0) {
                ans += n / (p * 2);
                p *= 5;
            }
            out.println(ans);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}



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

using namespace std;

#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back

typedef unsigned int uint;
typedef long long ll;
typedef pair<int,int> pii;

int read(){
	int i;
	scanf("%d",&i);
	return i;
}

const int mod=1000000007;

int buf[2][1<<16];
int arr[17];

int main(){
	int n=read(),x=read(),y=read(),z=read();
	int *now=buf[0],*next=buf[1];
	now[0]=1;
	REP(_,n){
		fill(next,next+(1<<16),0);
		REP(k,1<<16){
			int s=0;
			for(int i=15;i>=0;i--){
				if((k>>i)&1)
					arr[s++]=1;
				else if(s>=1)
					arr[s-1]++;
			}
			s++;
			FOR(p,1,11){
				arr[s-1]=p;
				int ok=0,sum=0;
				for(int i=s-1;i>=0;i--){
					sum+=arr[i];
					if(sum==z)
						ok|=1;
					if(sum==y+z)
						ok|=2;
					if(sum==x+y+z)
						ok|=4;
				}
				if(ok!=7){
					int w=0,q=0;
					for(int i=s-1;i>=0;i--){
						q+=arr[i];
						if(q<=16)
							w|=(1<<(q-1));
					}
					next[w]=(next[w]+now[k])%mod;
				}
			}
		}
		swap(now,next);
	}
	ll ans=1;
	REP(_,n)
		ans=ans*10%mod;
	REP(k,1<<16)
		ans=(ans+mod-now[k])%mod;
	cout<<ans<<endl;
}


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

using namespace std;

using ll = long long;

ll n, k, m, z, p;
vector<ll> nums;

bool isokm(ll index, vector<ll> minus, vector<ll> plus) {
    ll sum = 0;
    for (int i = 0; i < p; i++) {
        ll d = (index - (plus[i] - 1)) / plus[i];
        sum += upper_bound(minus.begin(), minus.end(), d) - minus.begin();
    }
    return sum >= k;
}

bool isokp(ll index, vector<ll> minus, vector<ll> plus) {
    ll sum = 0;
    for (int i = 0; i < p; i++) {
        ll d = index / plus[i];
        ll tmp = upper_bound(plus.begin(), plus.end(), d) - plus.begin();
        sum += tmp;
        if (i < tmp) sum--;
    }

    for (int i = 0; i < m; i++) {
        ll d = index / minus[i];
        ll tmp = upper_bound(minus.begin(), minus.end(), d) - minus.begin();
        sum += tmp;
        if (i < tmp) sum--;
    }
    sum /= 2;
    return sum >= k;
}


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

    nums.resize(n);
    vector<ll> minus, zero, plus;
    
    for (int i = 0; i < n; i++) {
        ll a;
        cin >> a;
        nums[i] = a;
        if (a < 0) minus.push_back(a);
        else if (a == 0) zero.push_back(a);
        else plus.push_back(a);
    }
    
    m = minus.size();
    z = zero.size();
    p = plus.size();

    ll mpair = m * p;
    ll zpair = z * (n - z) + z * (z - 1) / 2;
    ll ppair = m * (m - 1) / 2 + p * (p - 1) / 2;
    
    if (k <= mpair) {
        sort(minus.begin(), minus.end());

        ll ng = -1e+18, ok = -1;
        while (ok - ng > 1) {
            ll mid = (ng + ok) / 2;
            if (isokm(mid, minus, plus)) ok = mid;
            else ng = mid;
        }
        cout << ok << endl;
    }
    else {
        k -= mpair;
        if (k <= zpair) {
        cout << 0 << endl;
        }
        else {
            k -= zpair;
            for (int i = 0; i < m; i++) minus[i] *= -1;
            sort(minus.begin(), minus.end());
            sort(plus.begin(), plus.end());

            ll ng = 1, ok = 1e+18;
            while (ok - ng > 1) {
                ll mid = (ok + ng) / 2;
                if (isokp(mid, minus, plus)) ok = mid;
                else ng = mid;
            }

            cout << ok << endl;
        }
    }

    return 0;
}

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

typedef long long ll;
int N, M;
vector<int> A;
vector<ll> psum;
vector<vector<int> > B;
vector<ll> P;
vector<stack<pair<ll, int> > > st;

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

    A.resize(N - 1);
    for(int i = 0; i < N - 1; i++) {
        scanf("%d", &A[i]);
    }
    psum.resize(N - 1);
    for(int i = 0; i < N - 1; i++) {
        psum[i] = A[i];
        if(i) psum[i] += psum[i - 1];
    }

    B = vector<vector<int> >(N, vector<int>(M));
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < M; j++) {
            scanf("%d", &B[i][j]);
        }
    }

    P = vector<ll>(N, 0);
    st = vector<stack<pair<ll, int> > >(M);
    ll ans = 0;

    for(int i = N - 1; i >= 0; i--) {
        ll sum = 0;
        for(int j = 0; j < M; j++) {
            while(!st[j].empty() && st[j].top().first <= B[i][j]) {
                pair<ll, int> t = st[j].top();
                st[j].pop();
                if(!st[j].empty()) P[ st[j].top().second ] -= (B[ st[j].top().second ][j] - t.first);
            }
            if(!st[j].empty()) P[ st[j].top().second ] += (B[ st[j].top().second ][j] - B[i][j]);
            st[j].push(make_pair(B[i][j], i));

            sum += B[i][j];
        }
        ans = max(ans, sum);
        for(int j = i + 1; j < N; j++) {
            sum += P[j];
            ans = max(ans, sum - (psum[j - 1] - (i == 0? 0 : psum[i - 1])));
        }
    }

    printf("%lld", ans);
}


Measured memory_bytes: 4608
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        final int N = sc.nextInt();
        int[] l1 = new int[N];
        int[] l2 = new int[N];
        for(int i = 0;i < N;i++){
            l1[i] = sc.nextInt();
            l2[i] = l1[i];
        }
        Arrays.sort(l2);
        int right = l2[N/2];
        int left = l2[N/2-1];
        if(right == left){
            for(int i = 0;i < N;i++)    System.out.println(right);
            return;
        }
        for(int i = 0;i < N;i++){
            if(l1[i] > left)    System.out.println(left);
            else if(l1[i] < right)  System.out.println(right);
        }
    }
}

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


int main(){
  int N, K, i, xi, s = 0;

  cin >> N >> K;
  
  for(i = 0; i < N; i++){
    cin >> xi;
    if(xi < K - xi)
      s += 2 * xi;
    else
      s += 2 * (K-xi);
  }
   
  cout << s << endl;    
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

def bubble_sort(a, n):
    counter = 0
    for i in range(n-1, 0, -1):
        for j in range(i):
            if a[j] > a[j+1]:
                a[j], a[j+1] = a[j+1], a[j]
                counter += 1

    return a, counter

a, counter = bubble_sort(a, n)
print(" ".join(map(str, a)))
print(counter)


Measured memory_bytes: 5600
n = int(input())

LIMIT = 100000

unit = [1]
for a in [6, 9]:
    b = a
    while b <= LIMIT:
        unit.append(b)
        b *= a
unit.sort()


unit_num = len(unit)
unit = [0] + unit

dp = [[float('inf')]*(n+1) for _ in range(unit_num+1)]
dp[0][0] = 0

for i in range(1, unit_num+1):
    for j in range(n+1):
        if j - unit[i] >= 0:
            dp[i][j] = min(dp[i-1][j], dp[i-1][j-unit[i]] + 1, dp[i][j-unit[i]] + 1)
        else:
            dp[i][j] = dp[i-1][j]          
print(dp[-1][-1])

Measured memory_bytes: 87356
import random

def down_score(d, c, last_d, score):
    sum = 0
    for i in range(26):
        sum += c[i]*(d-last_d[i])
        
    return (score - sum)

def main():
    D = int(input())

    c = list(map(int, input().split()))

    s = [list(map(int, input().split())) for i in range(D)]

    #print(c)

    #print(s)

    last_d = [0 for i in range(26)]
    
    ans = []
    
    score = 0
    
    for i in range(D):
        max = -1000000
        idx = 0
        for j in range(26):
            if max < score + s[i][j] - c[j] * (i-last_d[j]) and c[j] != 0:
                max = score + s[i][j] - c[j] * (i-last_d[j])
                idx = j
            elif max == (score + s[i][j] - c[j] * (i-last_d[j])) and c[j] != 0:
                x = random.random()
                if x < 0.5:
                    idx = j
        last_d[idx] = i+1
        score += s[i][j]
        down_score(i+1,c,last_d,score)
        
        ans.append(idx)

    for i in range(D):
        print(ans[i]+1)

if __name__ == "__main__":
    main()

Measured memory_bytes: 9868
import java.util.Arrays;
import java.util.Scanner;
public class Main {

	public static void main(String[] args)
	{
		int n,m,na,na2=0,s,cnt=0,flg=0;
		int a[]=new int[31];
		int i,j;
		int b=0;

		Arrays.fill(a,b);

		Scanner sc = new Scanner(System.in);

		n = sc.nextInt();

		m = sc.nextInt();

		for(i=0;i<n;i++) {

			na = sc.nextInt();

			for(j=0;j<na;j++) {
				s = sc.nextInt();
				a[s]++;
			}
		}

		for(i=1;i<=m;i++) {

			if(a[i]==n) {
				cnt++;
			}
		}
		System.out.println(cnt);
	}
}

Measured memory_bytes: 22736
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s, t;
	cin >> s >> t;
	sort(all(s));
	sort(rall(t));
	if (s < t) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <stack>
#include <string>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <map>
#include <set>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef pair<ll, ll> P;

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


int main(void)
{
	ll n;
	cin >> n;
	ll m = (ll)1e13;
	for (ll i = 1; i * i <= n; i++) {
		if (n % i != 0) {
			continue;
		}
		auto p = i - 1;
		auto q = (n / i) - 1;
		m = min(m, p + q);
	}
	cout << m << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main() {
    cin.tie(nullptr); ios::sync_with_stdio(false);
    int N, K; cin >> N >> K;
    vector<int> P(N); for (auto &p : P) cin >> p;
    vector<double> A(N);
    for (int i = 0; i < N; i++) {
        A[i] = (P[i] + 1.0) / 2.0;
    }
    double sum = 0;
    for (int i = 0; i < K; i++) {
        sum += A[i];
    }
    double ans = sum;
    for (int i = K; i < N; i++) {
        sum = sum - A[i - K] + A[i];
        ans = max(ans, sum);
    }
    cout << fixed << setprecision(9) << ans << '\n';
    return 0;
}


Measured memory_bytes: 2560
#include <stdio.h>
#include <stdlib.h>
int main(void){
    int a,b,tmp;
    scanf("%d%d",&a,&b);
    if(a<b) {tmp=a;a=b;b=tmp;}
    if(a-b<1) printf("%d",a+b);
    else printf("%d",a+(a-1));
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define int long long
using namespace std;
const int nmax = 1003;
int N, K;
vector<int> A, B;
deque<int> D[nmax];
void input() {
  int i, j, k, x, y;
  string s;

  cin >> N;
  rep(i, 0, N - 1) {
    rep(j, 0, N - 2) {
      cin >> x;
      D[i].push_back(--x);
    }
  }
}
queue<int> Q;
int ans = 0;
void solve() {
  rep(i, 0, N - 1) { Q.push(i); }

  int M = N * (N - 1) / 2;
  bool update = false;
  set<int> available;
  rep(i, 0, N - 1) { available.insert(i); }  // 前日に戦っていない人

  set<int> av;
  for (int xxx = 1;; ++xxx) {
    av.clear();
    update = false;
    for (auto i : available) {
      bool exsist_i = D[i].size() && av.find(i) == av.end();
      int rival = D[i].front();
      bool exsist_rival = D[rival].size() && av.find(rival) == av.end();
      if (exsist_i && exsist_rival && D[rival].front() == i)

      {
        --M;
        update = true;
        D[i].pop_front();
        D[rival].pop_front();
        av.insert(i);
        av.insert(rival);
      }
    }
    available = av;
    if (M == 0) {
      ans = xxx;
      break;
    }
    if (!update) {
      ans = -1;
      break;
    }
  }
  cout << ans << endl;
}
signed main() {
  input();
  solve();
  return 0;
}

Measured memory_bytes: 8960
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement, groupby
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce, lru_cache  # @lru_cache(None)
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return (int(x) for x in input().split())
def LI(): return list(Is())
def TI(): return tuple(Is())
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(S())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = 10**18
# ----------------------------------------------------------- #

s = S()
A = [(key, sum(1 for _ in group)) for key, group in groupby(s)]
tmp = 0
ans = 0
for key, count in A:
    if key == '<':
        ans += count*(count+1)//2
        tmp = count
    else:
        if tmp < count:
            ans -= tmp
            ans += count*(count+1)//2
        else:
            ans += (count-1)*count//2
        tmp = 0
print(ans)


Measured memory_bytes: 110532
s = input()
t = input()

s_f = [0 for _ in range(26)]
t_f = [0 for _ in range(26)]

for ss, tt in zip(s, t):
    s_f[ord(ss) - ord('a')] += 1
    t_f[ord(tt) - ord('a')] += 1

s_f.sort()
t_f.sort()

for ss, tt in zip(s_f, t_f):
    if ss != tt:
        print('No')
        exit()

print('Yes')


Measured memory_bytes: 3632
from itertools import permutations
N = int(input())
P = list(map(int,input().split()))
Q = list(map(int,input().split()))

fac = 1
for i in range(1,N+1):
    fac *= i

n = [i+1 for i in range(N)]
ptr = sorted(list(permutations(n)))

p = 0
q = 0
for i in range(fac):
    if list(ptr[i]) == P:
        p = i
    if list(ptr[i]) == Q:
        q = i

print(abs(p-q))   

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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;
const ll INF = 1000000000;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    ll n, k; cin >> n >> k;
    ll x[n];
    for(int i=0;i<n;i++) cin >> x[i];
    ll minmv = INF;
    for(int i=0;i<n;i++){
        if(i + k - 1 >= n) break;
        // x[i] ~ x[i + k - 1]
        ll mv = x[i + k - 1] - x[i];
        mv += min(abs(x[i]), abs(x[i + k - 1]));
        minmv = min(minmv, mv);
    }
    cout << minmv << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;
const int INF = 1001001001;
const ll MAXV = 1e18;

int main() {
  string s, t;
  cin >> s >> t;
  int n = s.size();
  int m = t.size();
  vector<vector<int>> ch(26);
  rep(i, n) ch[s[i] - 'a'].push_back(i);
  rep(i, n) ch[s[i] - 'a'].push_back(i + n);

  ll ans = 0;
  int pos = 0;
  rep(i, m) {
    int c = t[i] - 'a';
    auto it = lower_bound(ch[c].begin(), ch[c].end(), pos);
    if (it == ch[c].end()) {
      cout << -1 << endl;
      return 0;
    }
    pos = *it + 1;
    if (pos >= n) {
      pos -= n;
      ans += n;
    }
  }

  ans += pos;
  cout << ans << endl;
}

Measured memory_bytes: 4648
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

vector<ll> f(ll a){
	vector<ll> res;
	ll b = 1;
	while(a >= b){
		b *= 2;
		ll t = 0;
		t += (a / b) * (b / 2);
		t += max(0LL, (a - (a / b) * b + 1) - b / 2); 
		res.emplace_back(t);
	}
	return res;
}

signed main(){
	ll a,b;
	cin >> a >> b;
	vector<ll> va = f(a - 1);
	vector<ll> vb = f(b);
	ll ans = 0;
	rep(i,vb.size()){
		if(i >= va.size()){
			if(vb[i] % 2 == 1) ans += pow(2, i);
			continue;
		}
		if((vb[i] - va[i]) % 2 == 1){
			ans += pow(2, i);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#define maxn 100050
using namespace std;
int a[maxn],num[maxn];
int main(){
	int n;
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	scanf("%d",&a[i]);
	sort(a+1,a+1+n);
	int now=0;
	a[0]=-1;
	for (int i=1;i<=n;i++){
		if (a[i]!=a[i-1]) now++;
		num[now]++;
	}
	if (now>3) printf("No\n");else {
		if (now==1) {
			if (a[1]!=0) printf("No\n");else printf("Yes\n");
		}else
		if (now==2) {
			if ((num[1]==2*num[2]||num[2]==2*num[1])&&a[1]==0) printf("Yes\n");else
				printf("No\n");
		}else {
			if (num[1]==num[2]&&num[2]==num[3]&&((a[1]^a[1+num[1]])==a[1+num[1]+num[2]])) printf("Yes\n");else
				printf("No\n");
		}
	}
	return 0;
}

Measured memory_bytes: 768
#include<iostream>
#include<bits/stdc++.h>
#define pq priority_queue
using namespace std;
int n,m;
long long nums[100005];
long long ans[100005];
long long k;
struct Mat
{
    int num[100005];
}GG,now;
void change (int l)
{
    int temp=GG.num[l-1];
    GG.num[l-1]=GG.num[l];
    GG.num[l]=temp;
}
Mat mul(Mat a,Mat b)
{
    Mat c;
    for(int i=1;i<=n;i++)
        c.num[i]=a.num[b.num[i]];
    return c;
}
int main()
{
    int temp;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        scanf("%lld",nums+i);
    }
    ans[0]=nums[0];
    n--;
    for(int i=n;i>0;i--)
    {
        GG.num[i]=i;
        now.num[i]=i;
        nums[i]-=nums[i-1];
    }
    cin>>m>>k;
    while(m--)
    {
        scanf("%d",&temp);
        change(temp);
    }
    while(k)
    {
        if(k%2)
            now=mul(GG,now);
        GG=mul(GG,GG);
        k/=2;
    }
    for(int i=0;i<=n;i++)
    {
        if(i)
            ans[i]=ans[i-1]+nums[now.num[i]];
        printf("%lld.0\n",ans[i]);
    }
    return 0;
}


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

int n,q;
int p[100010] = {0},r[100010] = {0};
int diff_weight[100010] = {0};

void init(int N){
	for(int i=0;i<=N;++i){
		p[i] = i;
		diff_weight[i] = 0;
		r[i] = 0;
	}
}

int root(int a){
	if(p[a] == a) return a;
	else{
		int r = root(p[a]);
		diff_weight[a] += diff_weight[p[a]];
		return (p[a] = r);
	}
}

bool is_same_set(int a,int b){
	return root(a) == root(b);
}

int weight(int a){
	root(a);
	return diff_weight[a];
}

int diff(int a, int b){
	return weight(b) - weight(a);
}

void unite(int a, int b, int w){
	w += weight(a);
	w -= weight(b);
	a = root(a);
	b = root(b);
	if(a==b) return;
	if(r[a]<r[b]){
		int t = a;
		a = b;
		b = t;
		w = -w;
	}
	//}else{
	if(r[a] == r[b]) r[a]++;
	p[b] = a;
	diff_weight[b] = w;
}

int main(){
	while(cin >> n >> q && n>0){;
		init(n);
		for(int i=0;i<q;i++){
			char c;
			int w,a,b;
			cin >> c;
			if(c=='!'){
				cin >> a >> b >> w;
				unite(a,b,w);
			}else{
				cin >> a >> b;
				if(is_same_set(a,b)) cout << diff(a,b) << endl;
				else cout << "UNKNOWN" << endl;
			}
		}
	}
}


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

int main()
{
  int N;
  string s;
  bool flag = false;
  
  cin >> N;
  rep(i,N)
  {
    cin >> s;
    if(s=="Y")
      flag = true;
  }
  if(flag)
    cout << "Four" << endl;
  else
    cout << "Three" << endl;
}
    

Measured memory_bytes: 256
INF=float('inf')
n,m=map(int,input().split())

#Union Find

#xの根を求める
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
#xとyの属する集合の併合
def unite(x,y):
    x = find(x)
    y = find(y)
    
    if x == y:
        return False
    else:
        #sizeの大きいほうがx
        if par[x] > par[y]:
            x,y = y,x
        par[x] += par[y]
        par[y] = x
        return True

#xとyが同じ集合に属するかの判定
def same(x,y):
    return find(x) == find(y)

#xが属する集合の個数
def size(x):
    return -par[find(x)]

#初期化
#根なら-size,子なら親の頂点
par=[-1]*n

for _ in range(m):
  a,b=map(int,input().split())
  a-=1
  b-=1
  unite(a,b)
ans=-INF
for i in range(n):
  s=size(i)
  ans=max(ans,s)
print(ans)

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

int a[110];
int b[110][110];

int main(){
	int ans = -10000000;
	int n;
	scanf("%d", &n);

	for(int i = 0; i < n; ++i){
		for(int j = 0; j < n; ++j){
			scanf("%d", &a[j]);
		}
		for(int j = 0; j < n; ++j){
			int s = 0;
			for(int k = j; k < n; ++k){
				s += a[k];
				b[j][k] = max(b[j][k], 0) + s;
				ans = max(ans, b[j][k]);
			}
		}
	}
	
	printf("%d\n", ans);
}

Measured memory_bytes: 1076
s=[input() for i in range(3)]
t=0
while 1:
    if not s[t]:
        break
    if s[t][0]=="a":
        s[t],t=s[t][1:],0
    elif s[t][0]=="b":
        s[t],t=s[t][1:],1
    else:
        s[t],t=s[t][1:],2
if t==0:
    print("A")
elif t==1:
    print("B")
else:
    print("C")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define f first
#define s second
#define mp make_pair
#define pi M_PI
#define inf 1<<30
#define eps (1e-11)
#define equals(a,b) (fabs((a)-(b))<eps)
using namespace std;

class Point{
public:
  double x,y;
  Point(double x=0,double y=0):x(x),y(y){}

  Point operator+(Point p){ return Point(x+p.x,y+p.y);}
  Point operator-(Point p){ return Point(x-p.x,y-p.y);}
  Point operator*(double k){ return Point(x*k,y*k);}
  Point operator/(double k){ return Point(x/k,y/k);}
  bool operator<(Point p)const{ return (x!=p.x ? x<p.x : y<p.y);}
  bool operator==(Point p)const{ return fabs(x-p.x)<eps && fabs(y-p.y)<eps;}

  double abs(){ return sqrt(norm());}
  double norm(){ return (x*x+y*y);}
};
typedef Point Vector;
typedef vector<Point> Polygon;

class Circle{
public:
  Point c;
  double r;
  Circle(Point c=Point(),double r=0.0):c(c),r(r){}
};

double norm(Vector a){ return (a.x*a.x+a.y*a.y);}
double abs(Vector a){ return sqrt(norm(a));}
double dot(Vector a,Vector b){ return (a.x*b.x+a.y*b.y);}
double cross(Vector a,Vector b){ return (a.x*b.y-a.y*b.x);}

double arg(Vector p){ return atan2(p.y,p.x);}
Vector polar(double a,double r){ return Point(cos(r)*a,sin(r)*a);}

pair<Point,Point> getCrossPoints(Circle c1,Circle c2){
  double d=abs(c1.c-c2.c);
  double a=acos((c1.r*c1.r+d*d-c2.r*c2.r)/(double)(2*c1.r*d));
  double t=arg(c2.c-c1.c);
  return mp(c1.c+polar(c1.r,t+a),c1.c+polar(c1.r,t-a));
}

// ???????????????????????????
bool isContain(Circle c1,Circle c2){
  if((abs(c1.c-c2.c)+c2.r-c1.r)<eps)return true;
  return false;
}

int n;
vector<pair<Point,double> > vp;
vector<Circle> vc;

bool check(Point p){
  for(int i=0;i<n;i++){
    if(vc[i].r-abs(p-vc[i].c)<-eps)return false;
  }
  return true;
}

bool ok(double mid){
  vc.clear();

  for(int i=0;i<n;i++){
    if(vp[i].s-mid<eps)return false;
    vc.push_back(Circle(vp[i].f,sqrt(vp[i].s*vp[i].s-mid*mid)));
  }

  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(check(vc[i].c))return true;
      if(check(vc[j].c))return true;
    }
  }

  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(i==j)continue;
      if((vc[i].r+vc[j].r)-abs(vc[i].c-vc[j].c)<-eps)return false;
      if(isContain(vc[j],vc[i]))continue;
      if(isContain(vc[i],vc[j]))continue;
      pair<Point,Point> pp=getCrossPoints(vc[i],vc[j]);
      if(check(pp.f))return true;
      if(check(pp.s))return true;
    }
  }
  return vc.size()==1;
}

int main()
{
  int a,b,c;

  while(1){
    cin>>n;
    if(n==0)break;
    vp.clear();
    for(int i=0;i<n;i++){
      cin>>a>>b>>c;
      vp.push_back(mp(Point(a,b),c));
    }

    double l=0,r=1000,mid;
    for(int i=0;i<100;i++){
      mid=(l+r)/2;
      if(ok(mid))l=mid;
      else r=mid;
    }
    printf("%.10f\n",mid);
  }

  return 0;
}

Measured memory_bytes: 1372