akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define pdi pair<db,int>
#define mp make_pair
#define pb push_back
#define enter putchar('\n')
#define space putchar(' ')
#define MAXN 100005
#define eps 1e-8
//#define ivorysi
using namespace std;
typedef long long int64;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;char c = getchar();T f = 1;
    while(c < '0' || c > '9') {
    	if(c == '-') f = -1;
    	c = getchar();
    }
    while(c >= '0' && c <= '9') {
    	res = res * 10 + c - '0';
    	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
    	out(x / 10);
    }
    putchar('0' + x % 10);
}
int N;
struct node {
    int to,next,val;
}E[MAXN * 2];
int head[MAXN],sumE;
int C[MAXN],cnt[25],f[(1 << 15) + 5],siz[MAXN];
void add(int u,int v,int c) {
    E[++sumE].to = v;
    E[sumE].next = head[u];
    E[sumE].val = c;
    head[u] = sumE;
}
void dfs(int u,int fa) {
    for(int i = head[u] ; i ; i = E[i].next) {
        int v = E[i].to;
        if(v != fa) {
            C[v] ^= E[i].val;
            dfs(v,u);
            siz[u] ^= siz[v];
        }
    }
    C[u] ^= siz[u];
    siz[u] ^= C[u];
}
void Solve() {
    read(N);
    int x,y,a;
    for(int i = 1 ; i < N ; ++i) {
        read(x);read(y);read(a);
        add(x,y,a);add(y,x,a);
    }
    dfs(0,-1);
    for(int i = 1 ; i < N ; ++i) {
        cnt[C[i]]++;
    }
    int ans = 0,q = 0;
    for(int i = 1 ; i <= 15 ; ++i) {
        ans += cnt[i] / 2;
        cnt[i] %= 2;
        if(cnt[i]) q |= 1 << (i - 1);
    }
    for(int i = 1 ; i < (1 << 15) ; ++i) {
        int a = 0,c = 0;
        for(int j = 1 ; j <= 15 ; ++j) {
            if(i >> (j - 1) & 1) {
                a ^= j;
                ++c;
            }
        }
        if(!a) f[i] = c - 1;
        else f[i] = c;
    }
    for(int S = 1 ; S < (1 << 15) ; ++S) {
        for(int T = (S - 1) & S ; T ; T = (T - 1) & S) {
            f[S] = min(f[S],f[T] + f[S ^ T]);
        }
    }
    ans += f[q];
    out(ans);enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}


Measured memory_bytes: 8320
#include<iostream>
#include <list>
#include<stack>
#include<queue>
#include <vector>
#include <set>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include <functional>
#include<fstream>

#define FOR(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define LL long long
#define CLR(a) memset((a),0,sizeof(a))
#define SZ(x) (int((x).size()))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<<str<<endl
using namespace std;

const LL MOD = 1000000007;// 10^9+7
const int INF = (1 << 30);

struct cell {
	int id; //識別番号
	int left;//残っている数
	int xi;   //xの値
};


//変数
int N;
vector<int> ans;
vector<cell> x, any;



//サブ関数
//入力
void input()
{
	cin >> N;
	FOR(i,1,N+1){
		int tmp;
		cin >> tmp;

		cell tmpc;
		tmpc.id = i;
		tmpc.left = i - 1;
		tmpc.xi = tmp - 1;
		x.push_back(tmpc);
	}

	// 並び替えの方法をラムダ関数で記述
	sort(x.begin(),
		x.end(),
		[](const cell& a, const cell& b) {return a.xi < b.xi; }
	);
}


//計算
void calc()
{
	while (!x.empty()) 
	{
		auto itr = x.begin();
		//x_i の場合
		if (itr->xi == ans.size()) {
			//丁度id個目であることは、既にid-1個使っている場合
			if (itr->left == 0) {
				ans.push_back(itr->id);
				itr->left = N - (itr->id);
				any.push_back(*itr);
				x.erase(itr);
			}
			//使ってない場合は強制終了(生成不可能なので)
			else {
				return;
			}
		}
		//何もなければ、x_iの一番小さいやつを使いましょう
		else {
			while (itr != x.end() && itr->left == 0)itr++;
			if (itr != x.end()) {
				ans.push_back(itr->id);
				itr->left--;
			}
			//全部使われちゃってたら、既に通り越したやつを使いましょう
			else {
				itr = any.begin();
				while (itr != any.end() && itr->left == 0)itr++;
				if (itr != any.end()) {
					ans.push_back(itr->id);
					itr->left--;
				}
				else {
					//ここに来ることある？
					return;
				}
			}
		}
	}

	//anyの残りを使い果たしましょう
	auto itr = any.begin();
	while (itr != any.end()) {
		while (itr->left) {
			ans.push_back(itr->id);
			itr->left--;
		}
		itr++;
	}
}


//出力
void output()
{
	if (ans.size() == N * N) {
		cout << "Yes" << endl;
		for (auto num : ans) {
			cout << num << " ";
		}
		cout << endl;
	}
	else {
		cout << "No" << endl;
	}
}


//デバッグ
void debug()
{
	int N;
	cin>>N;
}


//メイン関数
int main()
{
	input();
	calc();
	output();
	debug();
	
	return 0;
}


Measured memory_bytes: 2304
function Main(input) {
	tmp = input.split(" ");
	var n = parseInt(tmp[0]);
	var k = parseInt(tmp[1]);
	var t = 0;
	var rt = 0.0;
	var r = 0.0;
	for (var i = 0 ; i < n ; i++){
		t = i+1;
		rt = 1 / n;
		while(t < k){
			rt = rt * 0.5;
			t = t * 2;
		}
		r += rt;
		rt = 0.0;
	}
	console.log(r);
}

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

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


public class Main {
	public static void main(String[] args) throws Exception {
		MScanner sc = new MScanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		int s=sc.nextInt();
		char[]in=sc.nextLine().toCharArray();
		for(char x:in) {
			int z=((int)(x-'A')+s)%26;
			pw.print((char)('A'+z));
		}
		pw.flush();
	}

	static class MScanner {
		StringTokenizer st;
		BufferedReader br;

		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}

		public MScanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int[] takearr(int n) throws IOException {
			int[] in = new int[n];
			for (int i = 0; i < n; i++)
				in[i] = nextInt();
			return in;
		}

		public long[] takearrl(int n) throws IOException {
			long[] in = new long[n];
			for (int i = 0; i < n; i++)
				in[i] = nextLong();
			return in;
		}

		public Integer[] takearrobj(int n) throws IOException {
			Integer[] in = new Integer[n];
			for (int i = 0; i < n; i++)
				in[i] = nextInt();
			return in;
		}

		public Long[] takearrlobj(int n) throws IOException {
			Long[] in = new Long[n];
			for (int i = 0; i < n; i++)
				in[i] = nextLong();
			return in;
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public char nextChar() throws IOException {
			return next().charAt(0);
		}

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

		public boolean ready() throws IOException {
			return br.ready();
		}

		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}

Measured memory_bytes: 24788
import itertools
N = int(input())
L = list(map(int, input().strip().split()))
#print(L);
t_count = 0;
three_numbers = list(itertools.combinations(L, 3))
#print(three_numbers)

for i in range(len(three_numbers)):
    three_number = three_numbers[i];
    #print(three_number)
    li = three_number[0]
    lj = three_number[1]
    lk = three_number[2]
    #print(li);
    #print(lj);
    #print(lk);

    if li == lj:
        continue;
    elif li == lk:
        continue;
    elif lj == lk:
        continue;

    if li+lj <= lk:
        continue;
    elif li+lk <= lj:
        continue;
    elif lj+lk <= li:
        continue;
    t_count+=1;
            
print(t_count);

Measured memory_bytes: 20456
from collections import deque
S = input()
Q = int(input())
quer = [input().split() for _ in range(Q)]

hanten = 0
t = 0
d = deque(S)
for i in quer:
    quary = i
    if quary[0]=='1':
        #S = S[::-1]
        hanten = hanten ^ 1
    else:
        t = (int(quary[1])-1) ^ hanten
        if t:
            #S = S + quary[2]
            d.append(quary[2])
        else:
            #S = quary[2] + S
            d.appendleft(quary[2])
    #print(S)
if hanten:
    d.reverse()
s = ''.join(list(d))
print(s)

Measured memory_bytes: 44660
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
n, k = M()
s = S()
ans = ''
for i in range(1, n+1):
    c = s[i-1]
    if i == k:
        c = c.lower()
    ans += c
print(ans)

Measured memory_bytes: 38640
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define endl "\n"
#define fastio ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define all(x) x.begin(),x.end()
#define y1 omg
#define INF 1000000010
#define FOR(x, n) for(int x=0; x<n; x++)
#define ini(x, n) memset(x, n, sizeof(x));
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;

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


int n, a, b, value = 0;
vector<vector<int>> Tree(200010);
vi result(200010), point(200010), arr(200010, INF);

void dfs(int x, int d) {
	if (result[x]) return;
	vector<int>::iterator it = lower_bound(arr.begin() + 1, arr.begin() + 1 + d, point[x]);
	int last = *it;
	*it = point[x];
	if (last == INF) value++;
	result[x] = value;
	FOR(i, Tree[x].size()) {
		dfs(Tree[x][i], d + 1);
	}
	*it = last;
	if (last == INF) value--;
}

int main() {
	fastio;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> point[i];
	}
	for (int i = 1; i < n; i++) {
		cin >> a >> b;
		Tree[a].pb(b);
		Tree[b].pb(a);
	}
	dfs(1, 1);
	for (int i = 1; i <= n; i++) {
		cout << result[i] << endl;
	}
}

Measured memory_bytes: 28016
N,M = map(int,input().split())
K = []
for i in range(M):
    S = list(map(int,input().split()))
    k,s = S[0],S[1:]
    K.append(s)
P = list(map(int,input().split()))

ans = 0
for i in range(pow(2,N)):
    Sw = []
    n = i
    for j in range(N):
        Sw.append(n%2)
        n//=2
    A = 0
    for k in range(M):
        n = 0
        for j in K[k]:
            n+=Sw[j-1]
        if n%2==P[k]:
            A+=1
    if A==M:ans += 1
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 2100100100;
// const int MOD = 1e9 + 7;

int main() {
    ll N, K;
    cin >> N >> K;
    N %= K;
    cout << min(N, abs(N - K)) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <iomanip>
#include <math.h>
#include <mutex>
#include <algorithm>

//#include "Data.h"


using namespace std;

typedef unsigned long ulong;
typedef unsigned long long ulolong;
typedef long long lolong;


int main()
{
	lolong N, K;
	vector<int> H;

	cin >> N >> K;

	H.reserve(N);

	for (lolong i = 0; i < N; i++)
	{
		int h;
		cin >> h;
		H.push_back(h);
	}

	sort(H.begin(), H.end());

	lolong sum = 0;
	for (lolong i = 0; i < N - K; i++)
	{
		sum += H[i];
	}

	cout << sum << endl;
}

Measured memory_bytes: 1024
import sys
import os
import math
import bisect
import collections
import itertools
import heapq
import re
import queue
import fractions

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

# lcm = lambda x, y: (x * y) // math.gcd(x, y)
lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    A, B = il()
    print(lcm(A, B))


if __name__ == '__main__':
    main()


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

using ll = long long;
using ull = unsigned long long;
using st = string;
using db = double;
using vll = vector<long long>;
using vvll = vector<vll>;
using vchar = vector<char>;
#define rep(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define vrep(vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
ll mod = 1000000007;

int main(){
  ll q;
  st s;
  cin >> s >> q;

  st l = "", r = "";
  ll sw = 0;
  rep(i, 0, q){
    ll t;
    cin >> t;
    if(t == 1) sw++;
    else{
      ll f;
      char c;
      cin >> f >> c;
      if((sw + f) % 2 == 0) r += c;
      else l += c;
    }
  }

  st ans;
  if(sw % 2 == 0){
    reverse(all(l));
    ans = l + s + r; 
  }
  else{
    reverse(all(r));
    reverse(all(s));
    ans = r + s + l;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1348
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define fi first
#define se second

int n, dp[3007][3007], ans = 0;
string s;
const int mod = 1e9 + 7;

void add(int &a, int b){
	a += b;
	if(a >= mod) a -= mod;
}

signed main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> n;
	cin >> s;
	dp[0][0] = 1;
	for(int i = 1; i < n; i++){
		if(s[i - 1] == '<'){
			for(int j = 1; j <= i; j++){
				add(dp[i - 1][j], dp[i - 1][j - 1]);
				dp[i][j] = dp[i - 1][j - 1];
			}
		}
		else{
			for(int j = i - 1; j >= 0; j--){
				add(dp[i - 1][j], dp[i - 1][j + 1]);
				dp[i][j] = dp[i - 1][j];
				//cout << dp[i][j] << endl;
			}
		}
	}
	for(int i = 0; i < n; i++) add(ans, dp[n - 1][i]);
	cout << ans;
}


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

const int N = 510;

int x[N], y[N];
int a[N * N];

int main()
{
    int n;
    cin >> n;
    for (int i = 1; i <= n; i ++) cin >> x[i];
    for (int i = 1; i <= n; i ++) y[i] = i;
    sort(y + 1, y + n + 1, [](int l, int r) {return x[l] < x[r];});
    int p = 1;
    for (int i = 1; i <= n; i ++)
    {
        for (int j = 1; j < y[i]; j ++)
        {
            if (p >= x[y[i]])
            {
                cout << "No" << endl;
                return 0;
            }
            a[p] = y[i];
            while (a[p]) p ++;
        }
        a[x[y[i]]] = y[i];
        while (a[p]) p ++;
    }
    p = n * n;
    while (a[p]) p --;
    for (int i = n; i > 0; i --)
    {
        for (int j = 1; j <= n - y[i]; j ++)
        {
            if (p <= x[y[i]])
            {
                cout << "No" << endl;
                return 0;
            }
            a[p] = y[i];
            while (a[p]) p --;
        }
    }
    cout << "Yes" << endl;
    for (int i = 1; i <= n * n; i ++)
        cout << a[i] << ' ';
}

Measured memory_bytes: 2176
until (m = $<.gets.to_i).zero?
  cards = m.times.map {$<.gets.split.map(&:to_i)}
  memo = Array.new(cards.size + 1) {[]}
  $<.gets.to_i.times do
    count = ->(i, left) {
      return memo[i][left] if memo[i][left]
      if i >= cards.length
        co = left.zero? ? 1 : 0
      else
        co = 0
        a, b = cards[i]
        (b + 1).times do |j|
          nxt = left - a * j
          break if nxt < 0
          co += count.(i + 1, nxt)
        end
      end
      memo[i][left] = co
    }
    puts count.(0, $<.gets.to_i)
  end
end


Measured memory_bytes: 6976
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int N,M;
    cin>>N>>M;
    priority_queue<int> q;
    int sum=0;
    rep(i,N){
        int x;
        cin>>x;
        q.push(x);
        sum+=x;
    }
    rep(i,M){
        int a=q.top();
        q.pop();
        sum-=(a+1)/2;
        a/=2;
        q.push(a);
    }
    cout << sum << endl;
    




}


Measured memory_bytes: 1400
arr=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(arr[int(input())-1])

Measured memory_bytes: 3060
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

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; }
const long long INF = 100100100100;
const long long MOD = 1000000007;
typedef pair<int,long long> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

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

vector<vector<P>> Edge(100005);
vector<int> ans(100005,-1);
vector<long long> dist(100005);

int main() {
    int N;cin >> N;
    for(int i = 0;i<N-1;i++){
        int a,b,c;cin >> a >> b >> c;
        a--;b--;
        Edge.at(a).push_back(make_pair(b,c));
        Edge.at(b).push_back(make_pair(a,c));
    }
    //first:from second:dist
    queue<P> Q;
    Q.push(make_pair(0,0));
    while(!Q.empty()){
        P p = Q.front();Q.pop();
        int from = p.first;long long D = p.second;
        if(D % 2 == 0) ans.at(from) = 0;
        else ans.at(from) = 1;
        for(P V : Edge.at(from)){
            if(ans.at(V.first) != -1) continue;
            Q.push(make_pair(V.first,V.second+D));
        }
    }
    for(int i = 0;i<N;i++)cout << ans.at(i) << endl;
}


Measured memory_bytes: 9088
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define RSORT(x) sort((x).rbegin(), (x).rend())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
#define SP << " " <<
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) { a = b; return 1;} return 0;}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) { a = b; return 1;} return 0;}
#define dame {cout<< "-1" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------
struct edge{ll to;};
struct graph{
    ll N;
    vector<vector<edge> > G;
    vector<bool> used;
    vector<ll> A;

    graph(ll n): N(n), G(N), used(N,false), A(N,0) {}

    void ade(ll s, ll t){
        G[s].emplace_back((edge){t});
        G[t].emplace_back((edge){s}); //無向ならON
    }

    void dfs(ll v=0, ll p=0){
        used[v]=true;
        ll ct=0;
        for(auto E : G[v]){
            if(!used[E.to]){
                dfs(E.to,p+1);
                ++ct;
            }
        }
        maxi(A[p+1],ct);
    }

    P gon(ll v){
        rep(i,N) used[i]=false;
        rep(i,N) A[i]=0;
        dfs(v);
        ll huka=1,ha=1;
        reps(i,1,N){
            if(A[i]==0) break;
            ++huka;
            ha*=A[i];
        }
        return {huka,ha};
    }

    P goe(ll v, ll v2){
        rep(i,N) used[i]=false;
        rep(i,N) A[i]=0;
        used[v]=true;
        used[v2]=true;
        dfs(v);
        dfs(v2);
        ll huka=1,ha=2;
        reps(i,1,N){
            if(A[i]==0) break;
            ++huka;
            ha*=A[i];
        }
        return {huka,ha};
    }
};
//--MAIN-----------------------------------
void Main() {
    ll N;
    cin>>N;
    graph g(N);
    vector<P> kore;
    rep(i,N-1){
        ll a,b; cin>>a>>b; --a,--b;
        kore.emplace_back(a,b);
        g.ade(a,b);
    }
    ll ans0=INF2,ans1=INF2;
    rep(i,N){
        P pa=g.gon(i);
        if(mini(ans0,pa.first)) ans1=pa.second;
        else if(ans0==pa.first) mini(ans1,pa.second);
    }
    rep(i,N-1){
        P pa=g.goe(kore[i].first, kore[i].second);
        if(mini(ans0,pa.first)) ans1=pa.second;
        else if(ans0==pa.first) mini(ans1,pa.second);
    }
    cout<< ans0 SP ans1 <<"\n";
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    char c[a+b+2];
    for(int i=1;i<=a+b+1;i++)
    {
          cin>>c[i];
        if(i!=a+1&&(c[i]<'0'||c[i]>'9')){cout<<"No";return 0;}
        else if(c[a+1]!='-'&&i==a+1){cout<<"No";return 0;}
    }
    cout<<"Yes";
    return 0;
}

Measured memory_bytes: 256
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)

def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]

n = input()
print('Yes' if '7' in n else 'No')


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const int MOD = 1000000007;

vector<int> idx[26];

int main() {
  string s, t;
  cin >> s;
  cin >> t;
  rep(i, s.size()) { idx[(int)(s[i] - 'a')].eb(i); }
  rep(i, t.size()) {
    if (idx[(int)(t[i] - 'a')].size() == 0) {
      cout << "-1" << endl;
      return 0;
    }
  }

  ll ans = 0;
  int pos = -1;
  int len = s.size();
  rep(i, t.size()) {
    int key = (int)(t[i] - 'a');

    auto it = upper_bound(all(idx[key]), pos);
    int next = -1;

    if (it == idx[key].end()) {
      ans += len;
      pos = -1;
      next = *upper_bound(all(idx[key]), pos);
    } else {
      next = *it;
    }
    pos = next;
  }
  ans += pos + 1;

  cout << ans << endl;
}


Measured memory_bytes: 1344
#include<iostream>
#include<vector>
#include<algorithm>
#define ll long long
using namespace std;
vector <ll> vec;
ll n, s;
bool cmp(ll x, ll y)
{
	return x > y;
}
bool check(ll x)
{
	ll a0, a1;
	a1 = n / x;
	a0 = n % x;
	if (a1 < x && x >= 2 && a0 + a1 == s)
		return true;
	return false;
}
int main()
{
	cin >> n >> s;
	if (n < s)
	{
		cout << -1 << endl;
		return 0;
	}
	if (n == s)
	{
		cout << n + 1 << endl;
		return 0;
	}
	ll i;
	for (i = 2; i * i <= n; i++)
	{
		ll x = n;
		ll sum = 0;
		while (x >= i)
		{
			sum += x % i;
			x /= i;
		}
		sum += x;
		if (sum == s)
		{
			cout << i << endl;
			return 0;
		}
	}
	ll y = n - s;
	for (ll j = 1; j * j <= y; j++)
		if (y % j == 0)
			vec.push_back(j), vec.push_back(y / j);
	sort(vec.begin(), vec.end(), cmp);
	for (ll j = 0; j < vec.size(); j++)
	{
		ll b = y / vec[j] + 1;
		if (check(b))
		{
			cout << b << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

#define REP(k, n) for (ll k = 0; k < (ll)(n); ++k)
#define REPREV(k, n) for (ll k = (ll)(n)-1; k >= 0; --k)
#define FOR(k, a, b) for (ll k = (ll)(a); k < (ll)(b); ++k)
#define FORREV(k, a, b) for (ll k = (ll)(b)-1; k >= (ll)(a); --k)
#define FOREACH(e, v) for (auto e : v)

#define TGET(t, i) get<i>(t)
#define TSET(t, i, a) get<i>(t) = a
// MinHeap - priority_queue<ll, vll, greater<ll>> pq;

#define EVEN(n) ((n)&1) == 0
#define ODD(n) ((n)&1) == 1
#define MOD(x, m) ((x) % (m) + (m)) % (m)

#define SORT(v) sort(v.begin(), v.end())
#define SORTREV(v) sort(v.rbegin(), v.rend())
#define SHUFFLE(v) random_shuffle(v.begin(), v.end())
//srand(unsigned(time(0)));

#define REMOVEAT(v, i) v.erase(v.begin() + i)
#define REVERSE(v) reverse(v.begin(), v.end())

template <typename T>
void join(vector<T>& arr, string sep) {
    bool first = true;
    for (auto t : arr) {
        if (first) {
            first = false;
            cout << t;
        } else {
            cout << sep << t;
        }
    }
    cout << "\n";
}

#define POS "POSSIBLE"
#define IMPOS "IMPOSSIBLE"

// #define INF LLONG_MAX
// #define MINF LLONG_MIN
#define INF 9e18
#define MINF -INF

void solve() {
    ll h1,m1,h2,m2,k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    ll up_duration = 60*(h2-h1) + (m2 - m1);
    ll study_duration = up_duration - k;
    if(study_duration > 0){
        cout << study_duration << endl;
    }
    else{
        cout << 0 << endl;
    }
}

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

    return 0;
}


Measured memory_bytes: 3164
N = int(input())
 
N_1 = N - 1
counts = 0
i = 1
j = 1
while i <= N_1:
    while j <= N_1:
        if i * j <=  N_1:
            counts = counts + 1
        else:
            j = N_1
        j = j + 1
    j = 1
    i = i + 1
 
print(counts)

Measured memory_bytes: 67112
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = s, i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = s, i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = s; i < (n); ++i)
#define VFORS(i, s, n) for(int i = s; i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = s, i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = s, i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;
using VD = vector<double>;
using VLL = vector<ll>;
using VS = vector<string>;
using VC = vector<char>;
using VB = vector<bool>;

const int MOD = 1000000007;
const int INF = 1000000000;

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


int dx[4] = {-1, 0, 0, 1};
int dy[4] = {0, -1, 1, 0};
int h, w;
int cnt = 0; //白のマスの数
VS s;

struct Point{
    int x, y;
    Point(int X, int Y) : x(X), y(Y){};
    //x:縦 y:横
};

void bfs(){
    queue<pair<Point, int>> que;//point, distance
    vector<VB> visited(h, VB(w, false));
    visited[0][0] = true;
    que.push(MP(Point(0, 0), 1));
    while(!que.empty()){
        pair<Point, int> pi = que.front(); que.pop();
        Point p = pi.first;
        int d = pi.second;

        REP(i, 4){
            int nx = p.x + dx[i], ny = p.y + dy[i];
            if(0 <= nx && nx < h && 0 <= ny && ny < w &&
               !visited[nx][ny] && s[nx][ny] == '.'){
                if(nx == h-1 && ny == w-1){
                    cout << cnt - d - 1 << "\n"; return;
                }
                que.push(MP(Point(nx, ny), d+1));
                visited[nx][ny] = true;
            }
        }
    }
    cout << -1 << "\n";
    return;
}

int main(){
    cin >> h >> w;
    
    s.resize(h);
    REP(i, h){
        cin >> s[i];
        REP(j, w){if(s[i][j] == '.') ++cnt;
        }
    }
    bfs();
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	int W, H, x, y, r;
	scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);

	if ((x + r <= W) && (y + r <= H) && (x > 0) && (y > 0))
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 2108
N, K = map(int, input().split())
p = list(map(int, input().split()))
def expect(i):
    return (i+1) / 2


S=[0]

for i, x in enumerate(p, start=1):
    S.append(S[i-1] + expect(x))
    
ans = 0    

for i in range(N - K + 1):
    r = S[i+K] - S[i]
    if r > ans:
        ans = r
print(ans)

Measured memory_bytes: 24804
// Ver19.03
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF (1 << 29) * 2
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

ll a[100005];
int main()
{
  ll n, k, ans = LLINF, lrdiff;
  scanf("%lld%lld", &n, &k);
  for (int i = 0; i < n; i++)
  {
    scanf("%lld", a + i);
  }
  for (int i = 0; i < n - k + 1; i++)
  {
    lrdiff = llabs(a[i] - a[i + k - 1]);
    ans = MIN(ans, MIN(llabs(a[i]) + lrdiff, llabs(a[i + k - 1]) + lrdiff));
  }
  printf("%lld\n", ans);
  return 0;
}

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

void solve() {
    int N, T;
    cin >> N >> T;
    using P = pair<int, int>;
    vector<P> D(N);
    rep(i, N) {
        int a, b;
        cin >> a >> b;
        D[i] = make_pair(a, b);
    }
    sort(D.begin(), D.end());
    int ans = 0;
    vector<int> dp(3030);
    rep(i, N) {
        int cost = D[i].first;
        int point = D[i].second;
        for(int j = T; j >= 0; --j) {
            if(j + cost < T) chmax(dp[j + cost], dp[j] + point);
            else chmax(ans, dp[j] + point);
        }
    }
    rep(i, T) chmax(ans, dp[i]);
    cout << ans << '\n';
}

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


Measured memory_bytes: 256
def main(M, T, P, R):
    team = [[0, 0, i + 1] for i in range(T)]
    teamprob = [[0] * P for i in range(T)]
    for _ in range(R):
        m, t, p, r = map(int, input().split())
        if r == 0:
            team[t - 1][0] += 1
            team[t - 1][1] -= m
            team[t - 1][1] -= teamprob[t - 1][p - 1]
        else:
            teamprob[t - 1][p - 1] += 20
    team.sort(reverse=True)
    ans = "{0}".format(team[0][2])
    for i in range(1,T):
        if team[i - 1][0] == team[i][0]:
            if team[i - 1][1] == team[i][1]:
                ans += "="
            else:
                ans += ","
        else:
            ans += ","
        ans += "{0}".format(team[i][2])
    print(ans)

while 1:
    m, t, p, r = map(int, input().split())
    if m == t == p == r == 0:
        break
    main(m, t, p, r)


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



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)



int main(void){

	int N, M; cin >> N >> M;
	vector<bool> from_1(N, false);
	vector<bool> to_N(N, false);

	REP(i,M){
		int a, b; cin >> a >> b; a--; b--;
		int sum = a + b; a = min(a, b); b = sum - a;
		if(a == 0) from_1[b] = true;
		if(b == N-1) to_N[a] = true;
	}

	REP(i,N){
		if(from_1[i] == true and to_N[i] == true){
			cout << "POSSIBLE" << endl;
			return 0;
		}

	}

	cout << "IMPOSSIBLE" << endl;
	return 0;

}


Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    
    int a = sc.nextInt();
    int b = sc.nextInt();
    
    int result = a*b;
    
    if(result%2 == 0){
      System.out.println("Even");
    }else{
      System.out.println("Odd");
    }
  }
}

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

int main(){
  int N;
  cin >> N;
  map<string, int> cnt;
  int max = 0;
  string s;
  rep(i, N){
    cin >> s;
    cnt[s]++;
    if(cnt[s] > max)
      max = cnt[s];
  }
  for(auto itr : cnt){
    auto value = itr.second;
    if(value == max)
      cout << itr.first << endl;
  }
}

Measured memory_bytes: 25216
#include<iostream>
 
using namespace std;
 
int main(){
  int A,B;
  cin >> A >> B;
  
  int sum=0;
  
  for(int i = 0; i < 2; i++){
    if( A >= B ){
      sum += A;
      A--;
    }else{
      sum += B;
      B--;
    }
  }
  
  cout << sum << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct compare{
    bool operator()(pair<int,int>&p1,pair<int,int>&p2){
        
        return p1.first>p2.first;
        
    }
};



int main()
{
   string str;
   
   cin>>str;
   
   int n=str.length();
   
   int sum=0;
   
   for(int i=0;i<n;i++){
       char c=str[i];
       
       sum+=(c-'0');
       
   }
   
   if(sum%9==0){
       cout<<"Yes";
   }
   else cout<<"No";
}


Measured memory_bytes: 3716
from collections import deque

N = int(input())

neighbor = [[] for _ in range(N)]

for _ in range(N-1):
    a, b = map(int, input().split())
    neighbor[a-1].append(b-1)
    neighbor[b-1].append(a-1)

# 黒を0、白を1、未着色を-1で表す
black_white = [0] + [-1]*(N-2) + [1]

# 点iを与えると、点iからの最短距離のリストを返す
def shortest_distance(home_point):
    shortest_distance_list = [-1]*N
    shortest_distance_list[home_point] = 0
    next_points = deque([home_point])

    while len(next_points) > 0:
        p = next_points.popleft()
        for idx in neighbor[p]:
            if shortest_distance_list[idx] == -1:
                shortest_distance_list[idx] = shortest_distance_list[p]+1
                next_points.append(idx)

    return shortest_distance_list

shortest_distance_from_Fennec = shortest_distance(0)
shortest_distance_from_Snuke = shortest_distance(N-1)

for idx in range(1,N-1):
    if shortest_distance_from_Fennec[idx] <= shortest_distance_from_Snuke[idx]:
        black_white[idx] = 0
    else:
        black_white[idx] = 1

print("Fennec" if black_white.count(0) > black_white.count(1) else "Snuke")


Measured memory_bytes: 32116
N,M = map(int,input().split())
dist = [0]
MOD = 10**5
for _ in range(N-1):
  d = int(input())
  dist.append(d)

for i in range(N-1):
  dist[i+1] += dist[i]

res = 0
cur = 0
for _ in range(M):
  a = int(input())
  res += abs(dist[cur+a] - dist[cur]) % MOD
  cur = cur+a

print(res%MOD)


Measured memory_bytes: 9636
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  string s;
  cin>>s;
  int n = s.size();
  int ok = n/2;
  int ng = n + 1;
  while(abs(ok-ng)>1){
    int mid = (ok + ng)/2;
    bool c = true;
    loop(i,n-mid,mid-1)
      if(s[i]!=s[i+1])c=false;
    if(c) ok = mid;
    else ng = mid;
  }
  cout << ok << endl;
  
}


Measured memory_bytes: 512
#include <iostream>
using namespace std;
#define ll long long int
ll fib[1000];
ll fibonacci(ll n)
{
    if(fib[n])
        return fib[n];
    if (n<=1)
        return n;
    return fib[n] = fibonacci(n-2) + fibonacci(n-1);
}
int main ()
{
    int a;
    cin>>a;
    cout<<fibonacci(a+1)<<endl;

}



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

using ll = long long;
using P = pair<ll, ll>;

const ll MOD = 1e9+7;
// const ll MOD = 998244353;
const ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define DEBUG(x) std::cerr << #x << " : " << (x) << std::endl;
//#define DEBUG(x) ;

ll N, u, v; 
vector<vector<ll>> G;
vector<ll> du, dv;

int main(int argc, char **argv)
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> N >> u >> v;
	--u, --v;

	G.resize(N);
	du.assign(N, -1);
	dv.assign(N, -1);

	REP(i, N-1)
	{
		ll a, b; cin >> a >> b;
		--a, --b;
		G[a].push_back(b);
		G[b].push_back(a);
	}

	queue<ll> que;
	que.push(v);
	dv[v] = 0;

	while (que.size())
	{
		ll now = que.front();
		que.pop();

		for (auto &nv : G[now])
		{
			if (dv[nv] != -1) continue;
			dv[nv] = dv[now] + 1;
			que.push(nv);
		}
	}

	que.push(u);
	du[u] = 0;

	while (que.size())
	{
		ll now = que.front();
		que.pop();

		for (auto &nv : G[now])
		{
			if (du[nv] != -1) continue;
			du[nv] = du[now] + 1;
			que.push(nv);
		}
	}

	if (du[v] == 1)
	{
		std::cout << 0 << std::endl;
		return 0;
	}

	ll res{0};
	REP(n, N)
	{
		if (du[n] < dv[n])
		{
			res = max(res, dv[n] - 1);
		}
	}

	std::cout << res<< std::endl;	
	return 0;
}


Measured memory_bytes: 11092
N = int(input())

S, ans = {}, 0
for i in range(N):
    s = input()
    s = ''.join(sorted(list(s)))
    if s in S:
        S[s] += 1
    else:
        S[s] = 1

for c in S.values():
    ans += c * (c - 1) // 2

print(ans)


Measured memory_bytes: 17888
import java.util.*

fun main(args: Array<String>) {
    val (n, k) = getInts()
    val input = getInts()
    val sum = LongArray(1001)
    sum[0] = 0
    (1..1000).forEach { sum[it] = it + sum[it - 1] }

    var current = 0.0

    (0 until k).forEach {
        current += (sum[input[it]] / input[it].toDouble())
    }

    var maxi = current

    var i = 0
    (k until n).forEach {
        current += (sum[input[it]] / input[it].toDouble())
        current -= (sum[input[i]] / input[i].toDouble())
        i++
        maxi = Math.max(maxi, current)
    }
    println(maxi)
}

fun getInt() = readLine()!!.toInt()
fun getInts() = readLine()!!.split(" ").map { it.toInt() }
fun getLong() = readLine()!!.toLong()
fun getLongs() = readLine()!!.split(" ").map { it.toLong() }


Measured memory_bytes: 62012
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define int long long
using namespace std;
signed main() {
    int X;
    cin >> X;

    if (X >= 400 && 599 >= X) {
        cout << 8 << endl;
    }
    else if (X >= 600 && 799 >= X) {
        cout << 7 << endl;
    }
    else if (X >= 800 && 999 >= X) {
        cout << 6 << endl;
    }
    else if (X >= 1000 && 1199 >= X) {
        cout << 5 << endl;
    }
    else if (X >= 1200 && 1399 >= X) {
        cout << 4 << endl;
    }
    else if (X >= 1400 && 1599 >= X) {
        cout << 3 << endl;
    }
    else if (X >= 1600 && 1799 >= X) {
        cout << 2 << endl;
    }
    else {
        cout << 1 << endl;
    }
}

Measured memory_bytes: 3632
#include <iostream>

#include <string.h>

using namespace std;

int main(){

    //数组a代表余数是否出现过，如果一个余数重复出现表示无解

    int n, t=0, count=0, a[1000001] ;

    bool flag=true;

    cin >>n;

    memset( a, 0, sizeof( a));

    //模拟正常的除法运算

    do

    {

        t= t * 10 + 7;

        t = t % n;

        count++;

        if( a[t] == 1)

        {

            flag = false;

            break;

        }

        else

        {

            a[t] = 1;

        }

    }while( t !=0);

    if( flag)

    {

        cout<< count <<endl;  

    }

    else

    {

        cout<< -1 << endl;

    }

    return 0;

}

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


int main(){
    int n;
    cin >> n;
    set<string> sset;
    int j;
    int count=0;

    rep(i,n){
        string s;
        cin >> s;
        if (!(sset.count(s))){
            sset.insert(s);
            count++;
        }
    }

    cout << count;

    return 0;
}

Measured memory_bytes: 19248
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
    int n,x;
    cin >> n >> x;
    int m_min = 1001001001,m_sum = 0;
    rep(i,n) {
        int m;
        cin >> m;
        m_min = min(m_min,m);
        m_sum += m;
    }
    int ans = n;
    x -= m_sum;
    ans += x/m_min;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define rep(i,l,r) for(int i=(l);i<(r);++i)
#define dd(x) cout << #x << " = " << x << ", "
#define de(x) cout << #x << " = " << x << endl
//-------
const int N = 107;
int h, w, n, a[N * N], c[N][N];
void solve() {
	int x = 1, y = 1;
	rep(i, 1, n + 1) {
		rep(j, 0, a[i]) {
			c[x][y] = i;
			(x & 1) ? ++y : --y;
			if (y > w) {
				++x, y = w;
			} else if (y < 1) {
				++x, y = 1;
			}
		}
	}
	rep(i, 1, h + 1) {
		rep(j, 1, w + 1)
			printf("%d%c", c[i][j], " \n"[j == w]);
	}
}
int main() {
	scanf("%d%d%d", &h, &w, &n);
	rep(i, 1, n + 1) scanf("%d", a + i);
	solve();
	return 0;
}

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

using ll = long long;

#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (int)(a.size())
#define clr(a, b) memset(a, b, sizeof(a))
#define REP(i, a, b) for(int i=(int)(a); i<(int)(b); ++i)
#define REPD(i, a, b) for(int i=(int)(a)-1; i>=(int)(b); --i)

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 2e5 + 5;
int n, k, a[N];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> k;
    REP(i, 0, n) {
    	cin >> a[i];
    }   
    REP(i, k, n) {
    	if(a[i-k] < a[i]) {
    		cout << "Yes\n";
    	} else {
    		cout << "No\n";
    	}
    }
    return 0;
}


Measured memory_bytes: 4380
#include<bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp> 
//using namespace boost::multiprecision; 
using namespace std;
#define ll long long int
#define ld long long double
#define vi vector<int>
#define vl vector<ll>
#define pi pair<int, int>
#define pl pair<ll, ll>
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define nl '\n'
#define mp make_pair
#define debug1(x) cout <<#x<<" "<<x<<'\n';
#define debug2(x,y) cout <<#x<<" "<<x <<" "<<#y<<" "<<y <<'\n';
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<'\n';
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define inf 1e18
const int mod = (int)1e9+7;
pair<ll,ll>s4[4]={{-1,0},{1,0},{0,-1},{0,1}};
pair<ll,ll>s8[8]={{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,1},{1,0},{1,-1}};

void solve() {
    ll a,b,c,k;
    cin >> a>>b >> c>>k;
    if(a>=k) {
        cout << k << nl;
    }
    
    else if(k<=a+b) {
        cout << a << nl;
    }
    else if(k<=a+b+c) {
        cout << 2*a+b-k << nl;
    }
}

signed main() {
    boost;
    solve();
}

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

const int nmax = 8;
bool graph[nmax][nmax];

int dfs(int v, int N, bool visited[nmax]) {

	bool all_visited = true;

	for (int i = 0; i < N; ++i) {
		if (visited[i] == false)
			all_visited = false;
	}

	if (all_visited) {
		return 1;
	}

	int ret = 0;

	for (int i = 0; i < N; i++) {
		if (graph[v][i] == false) continue;
		if (visited[i]) continue;

		visited[i] = true;
		ret += dfs(i, N, visited);
		visited[i] = false;
	}

	return ret;
}
int main(void) {
	int N, M;
	cin >> N >> M;

	for (int i = 0; i < M; ++i) {
		int A, B;
		cin >> A >> B;
		graph[A - 1][B - 1] = graph[B - 1][A - 1] = true;

	}

	bool visited[nmax];

	for (int i = 0; i < N; ++i) {
		visited[i] = false;
	}

	visited[0] = true;
	cout << dfs(0, N, visited) << endl;
	return 0;

}

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

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


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	public static void main(String[] args) throws IOException{
		String buf;
		String[] regex = {
				".*that.*",
				".*this.*",
				".*the.*",
		};
		BufferedReader br = new BufferedReader (new InputStreamReader(System.in));
		while((buf = br.readLine())!=null){
				char[] data = buf.toCharArray();
				while(true){
					boolean bool= false;
					buf = String.valueOf(data);
					for(int i = 0 ;i < regex.length;i++){
						if(buf.matches(regex[i])) bool = true;
					}
					if(bool)break;
					for(int i = 0; i <data.length;i++){
						if(Character.isLowerCase(data[i])){
							if(data[i] == 'z'){
								data[i] = 'a';
							}else data[i] ++;
						}
					}
				}
			System.out.println(buf);
		}
			br.close();
		}
}

Measured memory_bytes: 19296