akhauriyash/Code-Regression huggingface dataset:
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	sc.Scan()
	A, _ := strconv.Atoi(sc.Text())

	sc.Scan()
	B, _ := strconv.Atoi(sc.Text())

	plus := A + B
	minus := A - B
	x := A * B
	if plus >= minus && plus >= x {
		fmt.Println(plus)
	} else if minus >= plus && minus >= x {
		fmt.Println(minus)
	} else if x >= plus && x >= minus {
		fmt.Println(x)
	}
}


Measured memory_bytes: 640
def 解法3優先度付きキュー():
    import heapq
    X,Y,Z,K = [int(_) for _ in input().split()]
    aA = sorted((int(_) for _ in input().split()),reverse=True)
    aB = sorted((int(_) for _ in input().split()),reverse=True)
    aC = sorted((int(_) for _ in input().split()),reverse=True)
    dS=set()
    aAns = [0]*K
    aQ = []
    def fPush(aQ,i,j,k):
        if X <= i :
            i = X-1
        if Y <= j:
            j = Y-1
        if Z <= k:
            k = Z-1
        if (i,j,k) not in dS:
            heapq.heappush(aQ,(-1*(aA[i]+aB[j]+aC[k]),i,j,k))
            dS.add((i,j,k))
    def fPop(aQ):
        iD,i,j,k = heapq.heappop(aQ)
        return (-1*iD,i,j,k)
    fPush(aQ,0,0,0)
    for iU in range(K):
        aAns[iU],i,j,k = fPop(aQ)
        fPush(aQ,i+1,j,k)
        fPush(aQ,i,j+1,k)
        fPush(aQ,i,j,k+1)

    print(*aAns,sep="\n")

解法3優先度付きキュー()


Measured memory_bytes: 5104
import math


def resolve():
    import sys
    input = sys.stdin.readline
    # row = [int(x) for x in input().rstrip().split(" ")]
    ab = int("".join([x for x in input().rstrip().split(" ")]))

    def is_square(n: int):
        return (n ** .5).is_integer()

    if( ab ** .5).is_integer():
        print("Yes")
    else:
        print("No")



if __name__ == "__main__":
    resolve()


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

using namespace std;

#define fast_cin() ios_base::sync_with_stdio(false);cin.tie(NULL)
#define reP(i, x, n) for(int i=x; i<n; i++)
#define aLL(x) x.begin(), x.end()
#define pB push_back
#define eB emplace_back
#define tRav(a, x) for(auto& a: x)
#define fI first
#define sE second
#define lB lower_bound
#define uB upper_bound
#define MOD 1000000007

typedef vector<int> vec;
typedef long long ll;
typedef unsigned long long ull;


int main(){
    fast_cin();
    int n, m;cin>>n>>m;
    int x=((n-1)*n)/2;
    int y=((m-1)*m)/2;
    cout<<x+y<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
vector<P> res;
int dp[2200][2200];
int n;
int dfs(int l,int r){
    //左にl個,右にr個詰めたときの最大値
    if(l == 0 && r == 0)return 0;
    if(l < 0 || r < 0)return -1001001001001001ll;
    if(dp[l][r] != -1)return dp[l][r];
    int ret = 0;
    auto  now = res[l+r-1];
    //trace(now,n-r,l-1);
    //右
    if(r-1 >= 0)ret = max(ret,dfs(l,r-1) + now.first*abs(now.second - (n-r)));
    //左
    if(l-1 >= 0)ret = max(ret,dfs(l-1,r) + now.first*abs(now.second - (l-1)));
    return dp[l][r] =  ret;

}
signed main(){
    cin >> n;
    vector<int> a(n);
    rep(i,2200)rep(j,2200)dp[i][j] = -1;
    rep(i,n){
        cin >> a[i];
        res.emplace_back(a[i],i);
    }
    sort(res.rbegin(),res.rend());
    int ret = 0;
    rep(i,n+1){
        //trace(dfs(i,n-i),i,n-i);
        ret = max(ret,dfs(i,n-i));
    }
    // trace(p);
    // trace(res);
    cout << ret << endl;
    
    return 0;
}

Measured memory_bytes: 41620
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,h=0;
	cin>>n;
	for(int i=0,x,y;i<n;i++)
	{
		cin>>x>>y;
		h=h+1+y-x; 
	} 
	cout<<h<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define REP(i, n) for (int i = (n - 1); i >= 0; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll INF = 100000007;
const int MAX = 1000010;
bool p = true;
bool s = true;
vector<int> t(MAX);

bool is_prime(int n) {
  for (int i = 2; i <= sqrt(n); i++) {
    if (n % i == 0) return false;
  }
  return true;
}

void prime_factorize(int n) {
  for (int p = 2; p * p <= n; ++p) {
    if (n % p != 0) continue;
    while (n % p == 0) {
      n /= p;
    }
    t[p]++;
  }
  if (n != 1) {
    t[n]++;
  }
}

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

  rep(i, n) {
    int a;
    cin >> a;
    if (is_prime(a)) {
      if (a != 1) t[a]++;
    } else {
      prime_factorize(a);
    }
  }
  rep(i, MAX) {
    if (t[i] == n) s = false;
    if (t[i] > 1) p = false;
  }

  if (p) {
    cout << "pairwise coprime" << endl;
  } else if (s) {
    cout << "setwise coprime" << endl;
  } else {
    cout << "not coprime" << endl;
  }
}

Measured memory_bytes: 7048
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define erep(i,a,n) for(int i = a;i<=n;i++)
typedef long long ll;
#define int long long
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define P = pair<int,int>;
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; }

signed main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(b/a < c) cout << b/a << endl;
  else cout << c << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  lint N, M;
  cin >> N >> M;
  vector<lint> A(N);
  REP(i, N) cin >> A[i];
  REP(i, N) A[i]--;
  vector<lint> B(M);
  REP(i, M) cin >> B[i];
  REP(i, M) B[i]--;
  vector<int> rcnt(N*M);
  REP(i, N) {
    rcnt[A[i]]++;
    if(rcnt[A[i]] > 1) {
      cout << 0 << endl;
      return 0;
    }
  }
  vector<int> ccnt(N*M);
  REP(i, M) {
    ccnt[B[i]]++;
    if(ccnt[B[i]] > 1) {
      cout << 0 << endl;
      return 0;
    }
  }
  lint validr = 0;
  lint validc = 0;
  lint num = 0;
  lint ans = 1;
  IREP(i, N*M) {
    if(rcnt[i] > 0 && ccnt[i] > 0) {
      validr++;
      validc++;
      num++;
    } else if(rcnt[i] > 0) {
      ans = ans * validc % MOD;
      validr++;
      num++;
    } else if(ccnt[i] > 0) {
      ans = ans * validr % MOD;
      validc++;
      num++;
    } else {
      ans = ans * (validr * validc - num) % MOD;
      num++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 8064
#include <algorithm>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; ++i) {
    cin >> a[i];
  }
  // 最大公約数-1を割っていくので、あまりは自身-1
  cout << accumulate(a.begin(), a.end(), 0) - N << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
 public static void main(String[] args) {
	Scanner in = new Scanner(System.in);
	int[] preInts = {};
	while (in.hasNextLine()) {
	 String[] strs = in.nextLine().split(",");
	 int[] ints = new int[strs.length];
	 for (int i = 0; i < strs.length; i++) {
		ints[i] = Integer.parseInt(strs[i]);
		int left, right;
		if (preInts.length < ints.length) {
		 left = (i == 0) ? 0 : preInts[i - 1];
		 right = (i == preInts.length) ? 0 : preInts[i];
		} else {
		 left = preInts[i];
		 right = preInts[i + 1];
		}
		ints[i] += Math.max(left, right);
	 }
	 preInts = ints;
	}
	System.out.println(preInts[0]);
 }
}

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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)998244353;

ll N, S;
vll A;

/*
ll search(ll L){
  vll A_sum(S+1, 0);
  A_sum[0] = 1;
  ll ans = 0;
  FOR(l,L,N){
    vll A_copy(S+1, 0);
    for(ll i=0; i+A[l]<=S; ++i){
      A_copy[i+A[l]] += A_sum[i];
    }
    REP(i,S+1) A_sum[i] += A_copy[i];
    ans += A_sum[S];
  }
  return ans;
}
*/

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  IN(N, S);
  A.resize(N);
  REP(i,N) IN(A[i]);

  ll ans = 0;
  /*
  REP(i,N){
    //debug_print(i, search(i));
    ans += search(i);
  }
  */

  vll A_sum(S+1, 0);
  REP(i,N){
    A_sum[0] += 1;
    vll A_copy(S+1, 0);
    for(ll j=0; j+A[i]<=S; ++j) A_copy[j+A[i]] += A_sum[j];
    REP(j,S+1) A_sum[j] = (A_sum[j] + A_copy[j])%MOD;
    ans = (ans + A_sum[S])%MOD;
  }

  /*
  REP(Left,N){
    vll A_sum(S+1, 0);
    A_sum[0] += 1;
    FOR(i,Left,N){
      vll A_copy(S+1, 0);
      for(ll j=0; j+A[i]<=S; ++j){
        A_copy[j+A[i]] += A_sum[j];
      }
      REP(j,S+1) A_sum[j] += A_copy[j];
      ans += A_sum[S];
    }
  }
  */

  OUT(ans);

  return 0;
}

Measured memory_bytes: 384
a, b, n = map(int, input().split())

if n < b-1:
    x = n
    print(a * x // b - a * (x // b))
    exit()

if n%b != b-1:
    x = n - n%b - 1
else:
    x = n
print(a * x // b - a * (x // b))

Measured memory_bytes: 61848
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cctype>
#include <cmath>
#include <map>
#include <set>
#define rep(i, m, n) for (int i = m; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define ll long long
#define ull unsigned long long
#define push(a) push_back(a)
#define pop(a) pop_back(a)
#define debug(x) cout << #x << ": " << x << endl
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define PI 3.14159265358979
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int main(){
    int n,a,b;
    int ans=0;
    string s1;

    cin>>a>>b;
    for(int i=a; i<=b; i++){
        s1 = to_string(i);
        if(s1[0]==s1[4]&&s1[1]==s1[3]){
            ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
/*
ID: toooooEasy or RafaelSaddatimov
PROG:
*/
#include <bits/stdc++.h>
#define MAX 100005
#define MAXN 100005
#define MOD 1000000007
#define INF 21000000
#define EPS 1e-5
#define ll long long
#define F first
#define S second
#define all(a) a.begin(), a.end()
#define pb push_back
#define io ios_base::sync_with_stdio(false); cin.tie(0)
using namespace std;


int main() {
    io;
    string s, t;
    cin >> s >> t;
    int n = s.size();
    for(int i=0; i<n; ++i) {
        if(s == t)
            return 0 * puts("Yes");
        char c1 = s[0];
        char c2 = s[n - 1];
        s.pop_back();
        s = c2 + s;
    }
    puts("No");
}


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

using ll = long long;

template <typename T>
class node {
public:
	node<T> *l, *r;
	T val, val2;
	node() : val2(0) {}
	node(T val_, node<T>* l_ = nullptr, node<T>* r_ = nullptr) : l(l_), r(r_), val(val_), val2(0) {}
	void init(T val_, node<T>* l_ = nullptr, node<T>* r_ = nullptr) {
		val = val_;
		l = l_;
		r = r_;
	}
};

template <typename T>
class DynamicLazySegmentTree {
	using func_t = function<T(T, T)>;
	const ll n;
	const T id;
	func_t merge;
	node<T> *root;
	vector<node<T>> pool;
	int it;
	ll size(ll n) {
		ll res = 1;
		while (res < n) res <<= 1;
		return res;
	}
	node<T> *new_node() {
		pool[it].init(id);
		return &pool[it++];
	}
	T sub(ll l, ll r, node<T>* n, ll lb, ll ub) {
		if (ub <= l || r <= lb) return id;
		if (l <= lb && ub <= r) return n->val + n->val2 * (ub - lb);
		return n->val2 * (min(r, ub) - max(l, lb)) + merge(n->l != nullptr ? sub(l, r, n->l, lb, (lb + ub) / 2) : id, n->r != nullptr ? sub(l, r, n->r, (lb + ub) / 2, ub) : id);
	}
	void suc(ll l, ll r, node<T>* n, ll lb, ll ub, T val) {
		if (ub <= l || r <= lb) return;
		if (l <= lb && ub <= r) {
			n->val2 += val;
			return;
		}
		n->val += val * (min(r, ub) - max(l, lb));
		if (n->l == nullptr) {
			n->l = new_node();
		}
		if (n->r == nullptr) {
			n->r = new_node();
		}
		suc(l, r, n->l, lb, (lb + ub) / 2, val);
		suc(l, r, n->r, (lb + ub) / 2, ub, val);
	}
public:
	DynamicLazySegmentTree(ll n_, T id_ = 0, func_t merge_ = [](ll a, ll b) { return a + b; }, int max_ = 10000000) :
		n(size(n_)), id(id_), merge(merge_), pool(max_)
	{
		it = 0;
		root = new_node();
	}
	void add(ll l, ll r, T val) {
		suc(l, r + 1, root, 0, n, val);
	}
	T getSum(ll l, ll r) {
		return sub(l, r + 1, root, 0, n);
	}
};

int main()
{
	cin.sync_with_stdio(false);
	ll M, N, Q;
	cin >> N >> M >> Q;
	vector<ll> a(M), b(M), v(M), vs;
	vector<tuple<ll, ll, ll>> vab(M);
	for (int i = 0; i < M; i++) {
		cin >> a[i] >> b[i] >> v[i]; a[i]--; b[i]--;
		vs.push_back(v[i]);
		vab[i] = make_tuple(v[i], a[i], b[i]);
	}
	sort(vs.begin(), vs.end());
	vs.erase(unique(vs.begin(), vs.end()), vs.end());
	sort(vab.begin(), vab.end());
	for (int i = 0; i < M; i++) {
		a[i] = get<1>(vab[i]);
		b[i] = get<2>(vab[i]);
		v[i] = lower_bound(vs.begin(), vs.end(), get<0>(vab[i])) - vs.begin();
	}
	ll vss = vs.size();
	vector<ll> x(Q), y(Q), j(Q);
	vector<ll> l(Q, -1), r(Q, vss - 1);
	for (int i = 0; i < Q; i++) {
		cin >> x[i] >> y[i] >> j[i]; x[i]--; y[i]--;
	}
	for (int cnt = 0; cnt < 18; cnt++) {
		vector<vector<int>> vv(vss);
		for (int i = 0; i < Q; i++) {
			vv[(l[i] + r[i]) / 2].push_back(i);
		}
		DynamicLazySegmentTree<ll> dlst(N);
		ll tmp = 0;
		for (ll i = 0; i < vss; i++) {
			for (; tmp < M && v[tmp] <= i; tmp++) {
				dlst.add(a[tmp], b[tmp], 1);
			}
			for (auto q : vv[i]) {
				if (dlst.getSum(x[q], y[q]) < j[q]) {
					l[q] = i;
				}
				else {
					r[q] = i;
				}
			}
		}
	}
	for (int i = 0; i < Q; i++) {
		printf("%d\n", (int)vs[r[i]]);
	}
	return 0;
}

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

int main()
{
	int n,l;
	cin>>n>>l;
	string a;
	priority_queue<string,vector<string>,greater<string> >q;
	for(int i=0;i<n;i++)
	{
		cin>>a;
		q.push(a);
	}
	
	while(q.size()>0)
	{
		string b=q.top();
		cout<<b;
		q.pop();
	}
	
	return 0;
}

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

#define all(A) begin(A), end(A)
#define sz(A) int(A.size())

using namespace std;

typedef long long ll;

int main () {
  ios::sync_with_stdio(false); cin.tie(0);
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  vector <int> ac(n + 1, 0);
  for (int i = 1; i < n; i++) {
    if (s[i - 1] == 'A' and s[i] == 'C') {
      ac[i + 1] = 1;
    }
  }
  for (int i = 1; i <= n; i++) {
    ac[i] += ac[i - 1];
  }
  while (q--) {
    int l, r;
    cin >> l >> r;
    int x = ac[r] - ac[l - 1];
    if (ac[l] - ac[l - 1] == 1) x--;
    cout << x << '\n';
  }
  return (0);
}

Measured memory_bytes: 1488
// Library
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

// TYPEDEFS
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

// CONSTANTS
#define SZA 0
#define SZB 0

// MACRO
#define MAX(X, Y) (((X) > (Y))? (X) : (Y))
#define MIN(X, Y) (((X) < (Y))? (X) : (Y))
#define ABS(X) (((X) > 0)? (X) : -(X))
#define YN(X) ((X)? "Yes" : "No")
#define SWAP(T, X, Y) {T t; t = X; X = Y; Y = t;}

#define F first
#define S second
#define PB push_back
#define MP make_pair


// Global Tables

//ull gPreProcess[SZA][SZB];

// Functions

void Print2DVector(vector<vector<int>>& v)
{
    ull i, j; 
    for(i = 0; i < v.size(); i++)
    {
        for(j = 0; j < v[i].size(); j++)
        {
            cout << v[i][j];
            if(j == v[i].size()-1)
            {
                cout << endl;
            }
            else
            {
                cout << " ";
            }
        }
    }
}

void PrintVector(vi& v)
{
    ull i;
    for(i = 0; i < v.size(); i++)
    {
        cout << v[i];
        if(i == v.size()-1)
        {
            cout << endl;
        }
        else
        {
            cout << " ";
        }
    }
}

void PrintArr(int* a, ull N)
{
    ull i;
    for(i = 0; i < N; i++)
    {
        cout << a[i];
        if(i == N-1)
        {
            cout << endl;
        }
        else
        {
            cout << " ";
        }
    }
}

void PreProcessTables()
{
    ull i, j;
    for(i = 0; i < SZA; i++)
    {
        for(j = 0; j < SZB; j++)
        {
            break;
        }
        break;
    }
}

int find(int* st, int a)
{
    if(a == st[a])
    {
        return a;
    }
    else
    {
        st[a] = find(st, st[a]);
        return st[a];
    }
}
    
void unite(int* st, int* sz, int a, int b)
{
    int t;
    a = find(st, a);
    b = find(st, b);
    if(a == b)
    {
        return;
    }
    if(sz[a] < sz[b])
    {
        t = a;
        a = b;
        b = t;
    }
    sz[a] += sz[b];
    st[b] = a;
}

void TC(int t)
{
    int N, M, A, B;
    cin >> N >> M;
    int out = 0;
    int st[N], sz[N];
    for(int i = 0; i < N; i++)
    {
        st[i] = i;
        sz[i] = 1;
    }
    for(int i = 0; i < M; i++)
    {
        cin >> A >> B;
        unite(st, sz, A-1, B-1);
    }
    for(int i = 0; i < N; i++)
    {
        out = max(out, sz[i]);
    }
    cout << out << endl;
}   

// Main

int main(void)
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
 
    PreProcessTables();

    int T = 1, t;
    for(t = 1; t <= T; t++)
    {
        TC(t);
    }
    return 0;
}


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

using namespace std;

int main() {

	int n, k;
	cin >> n >> k;
	vector<int> l(n, 0);
	for (int i = 0; i < n; i++) {
		cin >> l[i];
	}
	sort(l.begin(), l.end(),greater<int>());
	int total = 0;
	for (int i = 0; i < k; i++) {
		total += l[i];
	}
	cout << total << endl;
}

Measured memory_bytes: 256
#define ffor(i,a,b) for (int i=(a);i<(b);i++)
#define rfor(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define rep(i,n) for (int i=0;i<(n);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<queue>
#define SIZE 100001
#define MOD 1000000007
#define INF 100000000
using namespace std;



int main(){
    int n;
    cin >> n;
    int a[100001];
    bool b[100001];
    rep(i,n) cin >> a[i];

    rep(i,n) b[i] = false;
    int num = 0;
    int count = 1;
    while(1){
        if(b[num]==true){
            cout << -1 << endl;
            return 0;
        }
        if(a[num]== 2){
            cout << count << endl;
            return 0;
        }
        b[num] = true;
        num = a[num]-1;
        count++;

    }
    


	return 0;
}


Measured memory_bytes: 768
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Map<Integer, Integer> map = new HashMap<Integer, Integer>();
		for (int i = 0; i < n; i++) {
			int a = sc.nextInt();
			if (map.containsKey(a)) {
				map.put(a, map.get(a) + 1);
			} else {
				map.put(a, 1);
			}
		}
		sc.close();

		int ans = 0;
		for (int a : map.keySet()) {
			int cnt = map.get(a);
			if (a < cnt) {
				ans += cnt - a;
			}
			if (cnt < a) {
				ans += cnt;
			}
		}
		System.out.println(ans);
	}
}


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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define all(x) begin(x), end(x)
typedef long long ll;
typedef pair<int, int> pii;
const int inf=1010001000;
const ll  INF=1001000100010001000;
const int mod=(int)1e9+7;

int main(){
    int n,m;
    cin>>n>>m;
    vector<int>x(m);
    rep(i,0,m){
        cin>>x.at(i);
    }
    sort(all(x));
    vector<int>sa(m-1);

    if(m==1 or n>=m){
        cout<<0<<endl;
        return 0;
    }
    rep(i,0,m-1){
        sa.at(i)=abs(x.at(i+1)-x.at(i));
    }
    sort(all(sa),greater<int>());
    int sum=0;
    if(n==1){
        cout<<abs(x.at(m-1)-x.at(0))<<endl;
        return 0;
    }
    rep(i,0,n-1){
        sum+=sa.at(i);
        //cout<<sa.at(i)<<endl;
    }
    cout<<abs(x.at(m-1)-x.at(0))-sum<<endl;
return 0;
}


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

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

using namespace std;
using lint=long long;

int main(){
	int n,W,w[100],v[100];
	scanf("%d%d",&n,&W);
	rep(i,n) scanf("%d%d",&w[i],&v[i]);

	lint dp[100001]={};
	rep(i,n) for(int a=W;a>=w[i];a--) dp[a]=max(dp[a],dp[a-w[i]]+v[i]);

	printf("%lld\n",*max_element(dp,dp+100001));

	return 0;
}


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

deque<int> f(deque<int> d) {
	deque<int> ret = d;
	for(int i = 0; i < 3; i++) {
		d.push_back(d.front());
		d.pop_front();
		ret = min(ret, d);
	}
	return ret;
}

int count_overlap(deque<int> d) {
	int ret = 1;
	deque<int> t = d;
	for(int i = 0; i < 3; i++) {
		d.push_back(d.front());
		d.pop_front();
		if(t == d) ret++;
	}
	return ret;
}

deque<int> C[400];

ll P(int n, int k) {
	ll ret = 1;
	for(int i = n - k + 1; i <= n; i++) {
		ret *= i;
	}
	return ret;
}

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

	int N;
	cin >> N;

	map<deque<int>, int> m;
	map<deque<int>, int> cnt;
	for(int i = 0; i < N; i++) {
		deque<int> d;
		for(int j = 0; j < 4; j++) {
			int c;
			cin >> c;
			d.push_back(c);
		}
		d = f(d);
		C[i] = d;
		m[d]++;
	}

	for(auto p : m) {
		cnt[p.first] = count_overlap(p.first);
	}

	ll ans = 0;
	for(int i = 0; i < N; i++) {
		deque<int> d1 = C[i];
		m[d1]--;
		for(int j = 0; j < N; j++) {
			if(i == j) continue;
			deque<int> d2 = C[j];
			m[d2]--;
			for(int r1 = 0; r1 < 4; r1++) {
				map<deque<int>, int> t;
				deque<int> p1({ d1[1], d1[0], d2[1], d2[0] });
				deque<int> p2({ d1[0], d1[3], d2[2], d2[1] });
				deque<int> p3({ d1[3], d1[2], d2[3], d2[2] });
				deque<int> p4({ d1[2], d1[1], d2[0], d2[3] });
				t[f(p1)]++;
				t[f(p2)]++;
				t[f(p3)]++;
				t[f(p4)]++;
				ll k = 1;
				for(auto p : t) {
					if(!m.count(p.first) || m[p.first] < p.second) {
						k = 0;
						break;
					}
					k *= P(m[p.first], p.second);
					for(int loop = 0; loop < p.second; loop++) {
						k *= cnt[p.first];
					}
				}
				ans += k;
				d1.push_back(d1[0]);
				d1.pop_front();
			}
			m[d2]++;
		}
		m[d1]++;
	}

	cout << ans / 6 << endl;
}

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

using namespace std;

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

int main()
{
    int ans = 0;

    int N;
    scanf("%d", &N);
    string s;
    cin >> s;
    int slen = s.length();
    REP(i, N)
    {
        string str;
        cin >> str;
        
        bool can = false;

        REP(h, str.length())
        {
            if(can) break;

            if(str[h] == s[0])
            {
                int j = 0;
                while(true)
                {
                    if(h + (slen - 1) * (j + 1) >= str.length())
                    {
                        break;
                    }

                    bool c = true;

                    REP(t, slen)
                    {
                        if(s[t] != str[h + t * (j + 1)])
                        {
                            c = false;
                        }
                    }
                    
                    if(c)
                    {
                        can = true;
                        break;
                    }

                    j++;
                }
            }
        }

        if(can) ans++;
    }
    printf("%d\n", ans);
    return 0;
}




Measured memory_bytes: 3308
from heapq import heappush, heappop
from copy import deepcopy


def main():
    n = int(input())
    s = list(map(int, input().split()))

    left = []
    for e in s:
        heappush(left, -e)
    mx = heappop(left)

    made = []
    heappush(made, mx)

    for _ in range(n):
        made_prev = deepcopy(made)
        tmp = []

        while made_prev:
            made_val = heappop(made_prev)
            while left and left[0] <= made_val:
                pp = heappop(left)
                tmp.append(pp)

            if not left:
                print("No")
                exit()

            left_val = heappop(left)
            heappush(made, left_val)

        for e in tmp:
            heappush(left, e)

    print("Yes")


if __name__ == "__main__":
    main()


Measured memory_bytes: 33280
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }
template<typename T> inline T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }







int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    
    
    int n;
    cin >> n;
    while (n--) {
        string s, t;
        cin >> s >> t;
        int dp[1003][1003] = {0};
        rep(i, sz(s) + 1) rep(j, sz(t) + 1) {
            chmax(dp[i + 1][j], dp[i][j]);
            chmax(dp[i][j + 1], dp[i][j]);
            chmax(dp[i + 1][j + 1], dp[i][j] + (s[i] == t[j]));
        }
        cout << dp[sz(s)][sz(t)] << endl;
        // rep(i, sz(s) + 1) { rep(j, sz(t) + 1) cout << dp[i][j] << " "; cout << endl; }
    }
}





Measured memory_bytes: 7144
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define int long long
typedef long long ll;
const int INF = 1001001001001001001ll;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

signed main() {
  int N, K;
  cin >> N >> K;

  N = N % K;
  int ans = min(N, K - N);
  cout << ans << endl;
}

Measured memory_bytes: 256
A,B,N=map(int,input().split())
if A==B:
  if N<A:
    print(N)
  else:
    print(A-1)
elif A<B:
  if N<B:
    print(int(A*N/B)-A*int(N/B))
  else:
    print(int(A*(B-1)/B))
else:
  if N<B:
    print(int(A*N/B)-A*int(N/B))
  else:
    print(int(A*(B-1)/B))

Measured memory_bytes: 9080
#include <stdio.h>
a[100],b[100];main(i,n){
	for(;scanf("%d",&n),n;){
		//if(n>90)exit(1);
		for(i=0;i<=n;i++)scanf("%d",a+i);
		for(i=1;i<=n;i++)b[i]=a[i]-a[i-1];
		if(b[1]==b[2]&&b[2]==b[3]&&b[3]==b[4]){
			for(i=5;i<=n;i++)if(b[i]!=b[1])break;
			printf("%d\n",a[i]);
		}
		else if(b[2]==b[3]&&b[3]==b[4])printf("%d\n",a[0]);
		else if(b[1]==b[2]&&b[2]==b[3])printf("%d\n",a[4]);
		else if(a[2]-a[0]==b[3]&&b[3]==b[4])printf("%d\n",a[1]);
		else if(b[1]==b[2]&&b[2]==a[4]-a[2])printf("%d\n",a[3]);
		else if(b[1]==a[3]-a[1]&&a[3]-a[1]==b[4])printf("%d\n",a[2]);
		else exit(1);
	}
exit(0);}

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

int main(){
	int r,c;
	cin >> r >> c;
	int sum[103][103] = {0};
	int x[103][103] = {0};
	for (int i = 0; i < r; ++i)
	{
		for (int j = 0; j < c; ++j)
		{
			cin >> x[i][j];
		}
	}
	for (int i = 0; i < r; ++i)
	{
		for (int j = 0; j < c; ++j)
		{
			cout << x[i][j] << " ";
			sum[i+1][0] += x[i][j];
			sum[0][j+1] += x[i][j];
		}
		cout << sum[i+1][0] << endl;
	}
	for (int i = 0; i < c; ++i)
	{
		cout << sum[0][i+1] << " ";
		sum[r+1][c+1] += sum[0][i+1];
	}
	cout << sum[r+1][c+1] << endl;
}

Measured memory_bytes: 1252
#include <bits/stdc++.h>
/*#ifndef LOCAL_RUN
    #pragma GCC optimize("Ofast")
    #pragma GCC optimize("unroll-loops")
    #pragma GCC optimize("fast-math")
    #pragma GCC target("avx2,tune=native")
#endif*/
#define X first
#define Y second
using namespace std;

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

const int N = 1e6+228;

int par[N], cnt[N];

int main()
{
    #ifdef LOCAL_RUN
        freopen("input.txt", "r", stdin);
    //#else
        //freopen("cowcode.in", "r", stdin);
        //freopen("cowcode.out", "w", stdout);
    #endif
	ios::sync_with_stdio(false);
    cin.tie(0);

    for (int i = 2; i < N; i++) {
        if (par[i] != 0) continue;
        for (int j = i << 1; j < N; j += i)
            par[j] = i;
    }

    int n, g = 0;
    cin >> n;
    for (int i = 0, t; i < n; i++) {
        cin >> t;
        g = __gcd(g, t);
        int last = -1;
        while (par[t] != 0) {
            int x = par[t];
            t = t / par[t];
            if (last != x) {
                last = x;
                cnt[x]++;
            }
        }
        if (last != t && t != 1)
            cnt[t]++;
    }
    if (g != 1) {
        cout << "not coprime";
        return 0;
    }
    for (int i = 0; i < N; i++) {
        if (cnt[i] > 1) {
            cout << "setwise coprime";
            return 0;
        }
    }
    cout << "pairwise coprime";

    return 0;
}

// 272472LF


Measured memory_bytes: 11472
n = int(input())
s = input()
alphaList = "qwertyuiopasdfghjklzxcvbnm"
sMax = 0
for i in range(1, n):
    sSum = 0
    for j in range(26):
        if s[0:i].count(alphaList[j]) > 0 and s[i:n].count(alphaList[j]) > 0:
            sSum += 1
    sMax = max(sMax, sSum)
print(sMax)


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

int main() {
  int num = 1;

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

  for (int i = 0; i < N; i++) {
    if (num * 2 < num + K) {
      num *= 2;
    } else {
      num += K;
    }
  }

  cout << num << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define REP(i,n) for(int i = 0; i < int(n); i++)
#define REREP(i,n) for(int i = int(n - 1); i >= 0; i--)
#define FOR(i, m, n) for(int i = int(m);i < int(n);i++)
#define REFOR(i, m, n) for(int i = int(n - 1);i >= int(m);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define fi first 
#define se second

#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VD vector<double>
#define VVD vector<vector<double>>
#define VVVD vector<vector<vector<double>>>
#define VL vector<ll>
#define VVL vector<vector<ll>>
#define VVVL vector<vector<vector<ll>>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define VVVB vector<vector<vector<bool>>>
#define VS vector<string>
#define VVS vector<vector<string>>
#define VVVS vector<vector<vector<string>>>

#define PII pair<int,int>
#define PDD pair<double,double>
#define PLL pair<ll,ll>
#define VPII vector<pair<int,int>>
#define VVPII vector<vector<pair<int,int>>>
#define VVVPII vector<vector<vector<pair<int,int>>>>
#define VPLL vector<pair<ll,ll>>
#define VVPLL vector<vector<pair<ll,ll>>>
#define VVVPLL vector<vector<vector<pair<ll,ll>>>>

const ll MOD = (ll)1e9 + 7;
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;


void YN(bool flag) {
	cout << ((flag) ? "YES" : "NO") << endl;
}

void Yn(bool flag) {
	cout << ((flag) ? "Yes" : "No") << endl;
}

void yn(bool flag) {
	cout << ((flag) ? "yes" : "no") << endl;
}

int main() {
	int N, i; cin >> N >> i;
	cout << N - i + 1 << endl;

	
	return 0;
}


Measured memory_bytes: 256
using System;

class Solution
{
  static void Main()
  {
    var S = Console.ReadLine();
    int ans = 0, n = 0;
    for (int i = 0; i < 3; i++)
    {
      if (S[i] == 'R')
      {
        n++;
      }
      else
      {
        n = 0;
      }
      ans = Math.Max(ans, n);
    }
    Console.WriteLine(ans);
  }
}

Measured memory_bytes: 25952
S = list(map(int,input().split()))

if (3*max(S)-S[0]-S[1]-S[2])%2 == 0:
    print(int((3*max(S)-S[0]-S[1]-S[2])/2))
else:
    print(int((3+3*max(S)-S[0]-S[1]-S[2])/2))


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

using namespace std;

int N;
vector<int> A;


int main()
{
	cin >> N;

	A = vector<int>(N);

	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}


	int tgt = 1;
	for (int i = 0; i < N; i++) {
		if (A[i] == tgt) {
			tgt++;
		}
	}


	int ans = 0;

	if (tgt == 1) {
		ans = -1;
	}
	else {
		ans = N - tgt + 1;
	}



	cout << ans << endl;

	return 0;
}



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

using namespace std;

const int maxn = 200000 + 5;

int n;
char a[maxn];
int pre[maxn];

void inline Init()
{
	scanf("%d %s", &n, a + 1);
	for(int i = 1; i <= n; ++i) pre[i] = pre[i - 1] + (a[i] == '#');
}

int ans = 0x7fffffff;
void inline Solve()
{
	for(int i = 0; i <= n; ++i) {
		int x = pre[i];
		int y = (n - i) - (pre[n] - pre[i]);
//		cerr << x << ' ' << y << endl;
		ans = min(ans, x + y);
	}
	printf("%d\n", ans);
}

int main()
{
	Init();
	Solve();
	return 0;
}

Measured memory_bytes: 1280
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int main(){
  int n,area[4];
  ll h;
  
  cin >> n;
  vector<ll> hs;
  ull ans = 0;
  area[0] = area[1] = area[2] = area[3] = 0;
  for(int i=0;i<n;i++){
    cin >> h;
    hs.push_back(h);
  }
  sort(hs.begin(),hs.end(),greater<ll>() );
  for(int i=0;i<n;i++){
    int pos = i%4;
    ans += hs[i]-area[pos]>=0?hs[i]-area[pos]:0;
    area[pos]++;
  }
  cout << ans+1 << endl;

return 0;
}

Measured memory_bytes: 1232
x = int(input())

flg = 'n'
for a in range(-120, 121, 1):
    for b in range(-120, 121, 1):
        if a ** 5 - b ** 5 == x:
            flg = 'y'
            break
    if flg == 'y':
        break
print(a, b)


Measured memory_bytes: 9016
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string.h>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <memory.h>
#include <set>
#include <cmath>
#define fio ios::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
/*
int func(int x) {
	int i = 0;
	for (; x >> i; i++);
	int comp = 1 << (i-1);
	if (comp == x) return x;
	return comp << 1;
}
*/
int n, k, dp[100'005] = { 1, };
double ans = 0;
int func(int x) {
	int left = 0, right = 30;
	int res = 0;
	while (left <= right) {
		int mid = left + right >> 1;
		if (k <= dp[mid] * x) {
			res = dp[mid];
			right = mid - 1;
		}
		else {
			left = mid + 1;
		}
	}
	return res;
}

int main(void) {
	for (int i = 1; i <= 10000; i++) {
		dp[i] = dp[i - 1] * 2;
	}
	scanf("%d %d", &n, &k);
	for (int i = 1; i <= n; i++) {
		if (k <= i) ans += 1.0 / n;
		else ans += 1.0 / (n * func(i));
	}
	printf("%.12lf\n", ans);
	/*
	k = 10;
	int x; scanf("%d", &x);
	printf("%d\n", func(x));
	*/
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cstring>
using namespace std;

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

long long paper[10][10];
const int dx[] = {0,0,1,-1};
const int dy[] = {1,-1,0,0};
const int diax[] = {1,1,-1,-1};
const int diay[] = {-1,1,1,-1};


void filldd(int x, int y){
	rep(k,4){
		int tx = x+dx[k] , ty = y+dy[k];
		if( tx<0 || ty<0 || tx>=10 || ty>=10 )continue;
		paper[ty][tx]++;
	}
}
void filldia(int x, int y){
	rep(k,4){
		int tx = x+diax[k] , ty = y+diay[k];
		if( tx<0 || ty<0 || tx>=10 || ty>=10 )continue;
		paper[ty][tx]++;
	}
}

void dai(int x, int y){
	REP(z,1,3)rep(k,4){
		int tx = x+dx[k]*z , ty = y+dy[k]*z;
		if( tx<0 || ty<0 || tx>=10 || ty>=10 )continue;
		paper[ty][tx]++;
	}
	filldia(x,y);
}
void chuu(int x, int y){
	filldd(x,y);
	filldia(x,y);
}

int main(){
	int x,y,sz;
	memset(paper,0,sizeof(paper));
	while(~scanf("%d,%d,%d",&x,&y,&sz)){
		paper[y][x]++;
		if( sz==3 )      dai(x,y);
		else if( sz==2 ) chuu(x,y);
		else             filldd(x,y);
	}
	long long nasi = 0, ari = 0;
	rep(i,10)rep(j,10){
		if( paper[i][j]==0 )nasi++;
		else{
			ari = max(ari,paper[i][j]);
		}
	}
	printf("%lld\n%lld\n",nasi,ari);
	return 0;
}

Measured memory_bytes: 0
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tl3;



const int BIG_NUM = 1e9;
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;

const int MAX = 1e5+5;



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



	cout << 0 << endl << flush;
	
	string s0;
	cin >> s0;
	if (s0[0] == 'V') {
		
		return 0;
	}

	cout << n - 1 << endl << flush;
	
	string sl;
	cin >> sl;
	if (sl[0] == 'V') {
		
		return 0;
	}

	int l = 0;
	int r = n - 1;


	for (int i = 0; i < 18; i++) {
		int m = (l + r) / 2;
		

		cout << m << endl << flush;
		string s;
		cin >> s;
		if (s[0] == 'V') {
			//cout << m << endl <<  flush;
			return 0;
		}

		if ((s[0] == s0[0]) ^(m %2 == 1)) {
			l = m;
		}
		else {
			r = m;
		}



	}
	
	return 0;

}

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

using namespace std;
typedef long long ll;

// #define DEBUG

const int maxint = 1e9;
struct timestamp;
vector<int> shortest, indeg;
vector<vector<int>> connective;

void dag(int n)
{
    vector<int> search;
    vector<int> new_search;

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

        if (indeg[i] == 0)
        {
            search.push_back(i);
            cout << i << endl;
        }
    }
    while (!search.empty())
    {
        for (auto itr = search.begin(); itr != search.end(); itr++)
        {
            for (auto itr2 = connective[*itr].begin(); itr2 != connective[*itr].end(); itr2++)
            {
                indeg[*itr2] -= 1;
                if (indeg[*itr2] == 0)
                {
                    new_search.push_back(*itr2);
                    indeg[*itr2] = -1;
                    cout << *itr2 << endl;
                }
            }
        }
        search.clear();
        search = new_search;
        new_search.clear();
    }
}

int main()
{

#ifdef DEBUG
    cout << "DEBUG MODE" << endl;
    ifstream in("input.txt"); //for debug
    cin.rdbuf(in.rdbuf());    //for debug
#endif

    int n, s, t, m, maxindex;
    cin >> n >> m;
    connective.resize(n);
    indeg.resize(n);
    for (int i = 0; i < n; i++)
    {
        shortest.push_back(maxint);
        indeg.push_back(0);
    }
    for (int i = 0; i < m; i++)
    {
        cin >> s >> t;
        connective[s].push_back(t);
        indeg[t]++;
    }

    dag(n);

    return 0;
}

// getline(cin,s);
// a = strtok(s, ",");  ","で分解
// for (int i = 0; i < n; i++)
// for (int j = 0; j < m; j++)


Measured memory_bytes: 3784
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define forever for (;;)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
template<typename A> using V = std::vector<A>;
template<typename A> using F = std::function<A>;
template<typename A, typename B> using P = std::pair<A, B>;
using pii = P<int, int>;
using vi = V<int>;
using vd = V<double>;
using vs = V<std::string>;
using vpii = V<pii>;
using vvi = V<vi>;
using vvpii = V<vpii>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int n) { return n & 1; }
constexpr bool even(const int n) { return ~n & 1; }
template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> std::istream &operator>>(std::istream &is, std::pair<A, B> &p) { is >> p.first; is >> p.second; return is; }
using namespace std;
// clang-format on

main {
  int d;
  cin >> d;
  while (d--) {
    int n;
    cin >> n;
    vs v(n, string(n, ' '));
    vi di = {-1, 0, 1, 0}, dj = {0, 1, 0, -1};
    auto canPut = [&](int i, int j) {
      if (i < 0 || j < 0 || i >= n || j >= n) return false;
      int c = 0;
      c += i - 1 >= 0 && v[i - 1][j] == '#';
      c += j - 1 >= 0 && v[i][j - 1] == '#';
      c += i + 1 < n && v[i + 1][j] == '#';
      c += j + 1 < n && v[i][j + 1] == '#';
      return c <= 1;
    };
    int i = n, j = 0, t = 0;
    forever {
      int ni = i + di[t], nj = j + dj[t];
      if (canPut(ni, nj)) {
        i = ni;
        j = nj;
        v[i][j] = '#';
        continue;
      }
      t = (t + 1) % 4;
      ni = i + di[t], nj = j + dj[t];
      if (canPut(ni, nj)) {
        i = ni;
        j = nj;
        v[i][j] = '#';
        continue;
      }
      break;
    }
    for (auto &x : v) cout << x << endl;
    if (d) cout << endl;
  }
}

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

int main(){
  ll n,k;
  cin >> n >> k;
  vector<ll> a(n);
  for(ll i=0;i<n;i++){
    cin >> a.at(i);
  }
  
  for(ll i=k;i<n;i++){
    if(a.at(i-k) < a.at(i)) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  
  return 0;
}


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

int cnt[1<<26];

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
    
    string s;
    cin>>s;
    int n = s.size();
    int INF = 1e9;
    for(int i=0;i<(1<<26);i++) cnt[i] = INF;
    cnt[0] = 0;
    int now = 0;
    int ans;
    for(int i=0;i<n;i++){
        now ^= (1<<(s[i]-'a'));
        int ret = 1e9;
        for(int j=0;j<26;j++){
            ret = min(ret,cnt[now^(1<<j)]+1);
        }
        cnt[now] = min(cnt[now],ret);
        ans = cnt[now];
        //cerr << i << " " << ans << endl;
    }
    ans = max(ans,1);
    cout << ans << endl;
}

Measured memory_bytes: 262804
#include<stdio.h>

int main(void)
{
	int a, b, c;
	int i, count=0;

	scanf("%d %d %d", &a, &b, &c);

	for(i=a; i<=b; i++)
		if( 0 == c % i)
			count++;

	printf("%d\n", count);

	return 0;
}


Measured memory_bytes: 2104
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<stdio.h>
#include<locale.h>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;

int main()
{
 string s,t;
 cin>>s; cin>>t;
 int inx=0;
 for(int i=0;i<s.size();i++)
 {
	int flg=1;
	for(int j=0;j<t.size();j++)
	{
		if(i+j>=s.size()){flg=0; break;}
		if(s[i+j]!=t[j]){flg=0;}
	}
	if(flg==1){inx=1; break;}
 }
 if(inx==1){for(int i=0;i<s.size();i++){if(s[i]=='?'){s[i]='a';}} }
 if(inx==0){
 	int st=-1;
	for(int i=0;i<s.size();i++)
	{
		int flg=1;
		for(int j=0;j<t.size();j++)
		{
			if(i+j>=s.size()){flg=0; break;}
			if(s[i+j]!=t[j]&&s[i+j]!='?'){flg=0;}
		}
		if(flg==1){st=i;}
	}
	if(st==-1){s="UNRESTORABLE";}
	else{
		for(int i=0;i<s.size();i++)
		{
			if(s[i]=='?'){s[i]='a';}
		}
		for(int i=st;i<st+t.size();i++)
		{
			s[i]=t[i-st];
		}
	}
 }

 cout<<s;
 
}

Measured memory_bytes: 3588