akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(void)
{
	int sum[1000001];
	int n, k;

	while (scanf("%d %d", &n, &k), n){
		int maxi, i;
		sum[0] = 0;
		for (i = 1; i <= n; i++){
			int an;
			scanf("%d", &an);
			sum[i] += sum[i - 1] + an;
		}

		maxi = sum[k] - sum[0];
		for (i = 1; i < n - k; i++){
			maxi = fmax(maxi, sum[k + i] - sum[i]);
		}

		printf("%d\n", maxi);
	}

	return (0);
}

Measured memory_bytes: 996
#include <stdio.h>

main()
{	long n;
	long sum;

	while(EOF != scanf("%ld",&n) && n > 0)
	{	sum = 0L;
                do{
			sum += (n /= 5);}
		while(n > 0);
		printf("%ld\n",sum);
	}
return(0);
}



Measured memory_bytes: 1912
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int get_color(set<int> &colors) {
	for (int j = 1; j <= 10000; ++j) {
		if (!colors.count(j)) {
			colors.insert(j);
			return j;
		}
	}

	return 0;
}

int main() {

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

	int n;
	cin >> n;

	vector<int> colors(n);
	set<int> used;
	for (int i = 0; i < n; ++i) {
		cin >> colors[i];
		used.insert(colors[i]);
	}

	int min_spells = 0;
	for (int i = 1; i < n - 1; ++i) {
		if (colors[i] == colors[i - 1] && colors[i] == colors[i + 1]) {
			++min_spells;
			colors[i] = get_color(used);
		}
	}

	for (int i = 1; i < n; ++i) {
		if (colors[i] == colors[i - 1]) {
			++min_spells;
			colors[i] = get_color(used);
		}
	}

	cout << min_spells << "\n";

	return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map> 
#include <map> 
#include <numeric>
#include <limits>
#include <utility>
#include <queue>
#include <random>
#include <bitset>
using namespace std;
typedef long long LL;

int main() {
	int t, i=0, j, k;
	int a, b, c=0 ,d,n,F=0;
	string A,D,E;
	char B,C;
	cin >> a ;
	
	if (a >= 64) {
		c = 64;
	}
	else if(a >= 32) {
		c = 32;

	}
	else if(a >= 16) {
		c = 16;
	}
	else if (a >= 8) {
		c = 8;
	}
	else if (a >=4) {
		c = 4;
	}
	else if (a >= 2) {
		c = 2;
	}
	else {
		c = 1;
	}
	cout << c << endl;
	return 0;
}

Measured memory_bytes: 256
def findSumDigit(num):
    global total
    total = 0
    while num > 0:
        total += num % 10
        num //= 10
    return total

def main():
    n,a,b = map(int, input().split())
    ans = 0
    for i in range(1,n+1):
        tmp = findSumDigit(i)
        if a <= tmp <= b:
            ans += i
    print(ans)
    
if __name__ == '__main__':
    main()

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

const long long mod = 1e9 + 7;

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

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

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

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

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

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

int main(){
    ll n, m;
    cin >> n >> m;
    ll ans = 0;
    for (ll i=1; i*i<=m; ++i) {
        if (m%i==0) {
            if (m >= n * i) ans = max(ans, i);
            if (m >= n * m/i) ans = max(ans, m/i);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>
int main () {
    int n, m, l, data;
    int a[100+1][100+1];
    int b[100+1][100+1];
    long int c[100+1][100+1];
    scanf("%d %d %d", &n, &m, &l);
    
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            scanf("%d", &data);
            a[i][j] = data;
        }
    }
    
    for (int i = 0; i < m; i++) {
        for (int j = 0; j < l; j++) {
            scanf("%d", &data);
            b[i][j] = data;
        }
    }
    
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < l; j++) {
            c[i][j] = 0;
        }
    }
    
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < l; j++) {
            for (int k = 0; k < m; k++) {
                c[i][j] += a[i][k] * b[k][j];
            }
        }
    }
    
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < l-1; j++) {
            printf("%ld ", c[i][j]);
        }
        printf("%ld\n", c[i][l-1]);
    }
    return 0;
}



Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define REP(i, n) for (LL i = 0; i < (LL)(n); i++)
#define FOR(i, m, n) for (LL i = m; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define REVE(x) reverse(x.begin(), x.end())
#define ALL(x) (x).begin(), (x).end()
#define SUM(x) accumulate(x.begin(), x.end(),0)
#define vLL(v,n) vector<LL> v(n); REP(i,n)cin>>v[i];
#define vstr(v,n) vector<string> v(n); REP(i,n)REP(i,n)cin>>v[i];
LL INF = 1e9 + 1;
LL MOD = 1e9+7;
  LL a,b,c,d,e,n,m,l,r,x,y,z,ans=0,ans2=0,count;
string s,S,t;
int main() {
ios_base::sync_with_stdio(false);
cin >> x;
if(x==0){
  cout << 1;
}else{
  cout<< 0;
}
}

Measured memory_bytes: 3608
from collections import deque


def bfs(i, j):
    dist = [[0] * w for _ in range(h)]
    q = deque()
    q.append((i, j))
    dist[i][j] = 1
    while q:
        nx, ny = q.pop()
        for dx, dy in D:
            X, Y = nx + dx, ny + dy
            if X < 0 or Y < 0 or X >= h or Y >= w:
                continue
            if m[X][Y] == "#":
                continue
            if dist[X][Y] != 0:
                continue

            q.appendleft((X, Y))
            dist[X][Y] = 1 + dist[nx][ny]
    mx = 0
    for i in dist:
        mx = max(mx, max(i))
    return mx


h, w = map(int, input().split())
m = [input() for _ in range(h)]
D = [(-1, 0), (0, -1), (1, 0), (0, 1)]
ans = 0
for i in range(h):
    for j in range(w):
        if m[i][j] == ".":
            ans = max(ans, bfs(i, j))

print(ans - 1)

Measured memory_bytes: 74788
"use strict";
const gcd = function(a,b){
    if(a % b == 0) return b
    return gcd(b, a % b)
}

const helper = function (a, b, c) {
    let one = gcd(a, b)
    let two = gcd(one, c)
    return two
}

const main = arg => {
    const input = arg.trim().split("\n");
    const K = parseInt(input[0]);
    let res = 0
    for (let a = 1; a <= K; a++) {
        for (let b = 1; b <= K; b++) {
            for (let c = 1; c <= K; c++) {
                res = res + helper(a, b, c)
            }
        }
    }
    console.log(res)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));  

Measured memory_bytes: 31548
package main

import (
	"fmt"
	"strconv"
	"strings"
)

func main() {
	var n, x int
	fmt.Scan(&n)

	var s []string
	for i := 0; i < n; i++ {
		fmt.Scan(&x)
		s = append(s, strconv.Itoa(x))
	}
	for i, j := 0, len(s)-1; i < j; i, j = i+1, j-1 {
		s[i], s[j] = s[j], s[i]
	}
	r := strings.Join(s, " ")
	fmt.Println(r)
}

Measured memory_bytes: 1136
import sys
sys.setrecursionlimit(10**6)


class Node():
    def __init__(self, parent=-1, child=-1, sibling=-1, depth=-1):
        self.parent = parent
        self.first_child = child
        self.next_sibling = sibling
        self.depth = depth


class Tree():
    def __init__(self, n):
        self.T = [Node() for _ in range(n)]

    def type_of(self, i):
        node = self.T[i]
        if node.parent == -1:
            return 'root'
        if node.first_child == -1:
            return 'leaf'
        return 'internal node'

    def children_of(self, i):
        node = self.T[i]
        if node.first_child == -1:
            return []

        children = [node.first_child]
        node = self.T[node.first_child]
        while node.next_sibling != -1:
            children.append(node.next_sibling)
            node = self.T[node.next_sibling]

        return children

    def depth_of(self, i):
        return self.T[i].depth

    def get_root(self, ):
        for i, node in enumerate(self.T):
            if node.parent == -1:
                return i

    def set_children(self, i, c):

        if len(c) == 0:
            return False

        self.T[i].first_child = c[0]

        num_c = len(c)
        for j in range(num_c-1):
            self.T[c[j]].parent = i
            self.T[c[j]].next_sibling = c[j+1]
        self.T[c[num_c-1]].parent = i

        return True

    def set_depth(self, ):
        root = self.get_root()
        self.depth(root, 0)

    def depth(self, i, d):
        self.T[i].depth = d
        if self.T[i].next_sibling != -1:
            self.depth(self.T[i].next_sibling, d)
        if self.T[i].first_child != -1:
            self.depth(self.T[i].first_child, d+1)

    def parent_of(self, i):
        return self.T[i].parent


N = int(input())
A = [list(map(int, input().split())) for _ in range(N)]
T = Tree(N)

for i, *c in A:
    c = c[1:]
    T.set_children(i, c)
T.set_depth()

for i in range(N):
    p = T.parent_of(i)
    d = T.depth_of(i)
    t = T.type_of(i)
    c = T.children_of(i)
    print(f'node {i}: parent = {p}, depth = {d}, {t}, {c}')



Measured memory_bytes: 140988
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll n, m;std::cin >> n >> m;
  vvl s = vv(n, 2, 0, ll);
  re(i, n) std::cin >> s[i][0] >> s[i][1];
  sort(s.begin(), s.end());
  vvl left = vv(n, 2, 0, ll), right = vv(n, 2, 0, ll);
  re(i, n) left[i] = vll{s[i][0], (i==0?0:left[i-1][1])+s[i][1]};
  re(i, n) right[i] = vll{m-s[n-1-i][0], (i==0?0:right[i-1][1])+s[n-1-i][1]};

  std::vector<ll> left_max(n, 0), right_max(n, 0);
  re(i, n) left_max[i] = max((i==0?-10000000000000000:left_max[i-1]), left[i][1] - left[i][0]);
  re(i, n) right_max[i] = max((i==0?-10000000000000000:right_max[i-1]), right[i][1] - right[i][0]);
  ll ans = max({(ll)0, right_max[n-1], left_max[n-1]});

  re(i, n-1) ans = max(ans, left[i][1]-2*left[i][0]+right_max[n-2-i]);
  re(i, n-1) ans = max(ans, right[i][1]-2*right[i][0]+left_max[n-2-i]);
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 18176
import java.util.Scanner;

public class Main {

	private static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int w = sc.nextInt(), a = sc.nextInt(), b = sc.nextInt();
		System.out.println(Math.max(Math.max(b - (a + w), a - (b + w)), 0));
	}
}

Measured memory_bytes: 23252
s = list(input())
flagR = True
Rcnt = 1
Lcnt = 0
ans = []
for c in s[1:]:
	if flagR:
		if c == "R":
			Rcnt += 1
			ans.append(0)
		else:
			flagR = False
			Lcnt = 1
	else:
		if c == "L":
			Lcnt += 1
		else:
			flagR = True
			ans.append(Rcnt//2 + Rcnt%2 + Lcnt//2         )
			ans.append(Rcnt//2          + Lcnt//2 + Lcnt%2)
			for _ in range(Lcnt-1):
				ans.append(0)
			Rcnt = 1
ans.append(Rcnt//2 + Rcnt%2 + Lcnt//2         )
ans.append(Rcnt//2          + Lcnt//2 + Lcnt%2)
for _ in range(Lcnt-1):
	ans.append(0)

print(' '.join(map(str, ans)))


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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using Graph = vector<vector<int>>;

int main(){
    ll N; cin>>N;
    if(N==1){
        cout<<0<<endl;
        return 0;
    }
    map<ll,ll> M;
    ll cp = N;
    int flag = 0;
    for(ll i = 2; i <= sqrt(N);i++){
        while(cp%i==0){
            //cout<<cp<<endl;
            M[i]++;
            cp/=i;
            flag++;
        }
        if(cp<i)break;
    }
    if(cp!=1)M[cp]=1;
    if(flag==0){
        //素数
        cout<<1<<endl;
        return 0;
    }
    ll res = 0;
    for(auto p:M){
        //cout<<p.first<<" "<<p.second<<endl;
        ll cnt = p.second;
        // ll tmp = 1;
        // while(cnt){
        //     if(cnt<tmp)break;
        //     res++;
        //     cnt -= tmp;
        //     tmp++;
        // }
        ll tmp = 0, cur = 1;
        while(cnt >= cur) cnt -= cur++, tmp++;
        res += tmp;
    }
    cout<<res<<endl;
}



Measured memory_bytes: 3696
#include<stdio.h>
int solve(int, int);
int n,A[50];
int main(){
  int q,m,i;
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&A[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&m);
    if(solve(0,m)) printf("yes\n");
    else printf("no\n");
  }
  return 0;
}

int solve(int i,int m){
  int r;
  if(m==0) return 1;
  if(i>=n) return 0;
  r=solve(i+1,m) || solve(i+1,m-A[i]);
  return r;
}









Measured memory_bytes: 2108
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdlib>

using namespace std;

#define ALL(c) c.begin(),c.end()
#define RALL(c) c.rbegin(),c.rend()
#define SORT(x) sort((x).begin(),(x).end())
#define REP(i,x,y) for(int i=(x);i<(y);++i)
#define MP(a,b) make_pair((a),(b))
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;

const int INF=1<<30;
const long long int INF_=1LL<<58;
const double EPS=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
	os << "[";
	for (const auto &v : vec) {
		os << v << ",";
	}
	os << "]";
	return os;
}

string Reverse(string &str){
	reverse(str.begin(),str.end());
	string res=str;
	reverse(str.begin(),str.end());
	return res;
}

void Solve(){
	int m;
	cin >> m;
	REP(i,0,m){
		string str;
		cin >> str;
		
		unordered_set<string> x;
		REP(i,0,str.size()-1){
			string a=str.substr(0,i+1),b=str.substr(i+1);
			x.insert(a+b);
			x.insert(b+a);
			x.insert(Reverse(a)+b);
			x.insert(b+Reverse(a));
			x.insert(a+Reverse(b));
			x.insert(Reverse(b)+a);
			x.insert(Reverse(a)+Reverse(b));
			x.insert(Reverse(b)+Reverse(a));
		}

		cout << x.size() << endl;
	}
}

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

Measured memory_bytes: 1308
#include<bits/stdc++.h>
using namespace std;
int main(){
   int N,count;
   cin>>N;
   count=0;
   vector<int> p(N);
   for(int i=0;i<N;i++)
      cin>>p.at(i);

   for(int i=0;i<N;i++){
      if(p.at(i)!=i+1)
         count++;
   }

   if(count<=2)
      cout<<"YES"<<endl;
   else
      cout<<"NO"<<endl;
}

Measured memory_bytes: 256
N, M ,C = map(int,input().split())
B = list(map(int,input().split()))
A = [list(map(int,input().split())) for i in range(N)]
count = 0

for A1 in A:
    sum = 0
    for i in range(M):
        sum += A1[i] * B[i]
    if sum + C > 0:
        count = count + 1
print(count)

Measured memory_bytes: 3060
mod=1000000007
n=int(input())

def pow_by_iter(a, x, p):
    acc = a
    for i in range(1, x):
        acc = (acc * a) % p
    return acc

print((pow_by_iter(10, n, mod)+pow_by_iter(8, n, mod)-pow_by_iter(9, n, mod)-pow_by_iter(9, n, mod))%mod)

Measured memory_bytes: 62440
#include<iostream>
#include<algorithm>
#include<string>
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
using namespace std;
int a, b, c, d;
int ar[10000];
int f(string s) {
	if (s.size() == 1) {
		if (s[0] == 'a')return a;
		if (s[0] == 'b')return b;
		if (s[0] == 'c')return c;
		if (s[0] == 'd')return d;
	}
	char ch = s[1]; int p, q;
	int e = 2;
	string s1;
	if (s[e] == '[') {
		int cnt = 1;
		s1 = "[";
		while (cnt) {
			e++;
			s1 += s[e];
			if (s[e] == '[')cnt++;
			if (s[e] == ']')cnt--;
		}
	}
	else s1 += s[e];
	p = f(s1);
	e++;
	//
	s1 = "";
	if (s[e] == '[') {
		int cnt = 1;
		s1 = "[";
		while (cnt) {
			e++;
			s1 += s[e];
			if (s[e] == '[')cnt++;
			if (s[e] == ']')cnt--;
		}
	}
	else s1 += s[e];
	q = f(s1);
	
	if (ch == '+')return p | q;
	if (ch == '*')return p & q;
	if (ch == '^')return p ^ q;
}
signed main() {
	string s;
	while (cin >> s, s != ".") {
		for (a = 0; a <= 9; a++)
			for (b = 0; b <= 9; b++)
				for (c = 0; c <= 9; c++)
					for (d = 0; d <= 9; d++)
						ar[1000 * a + 100 * b + 10 * c + d] = f(s);
		int p; cin >> p; cout << ar[p] << ' ';
		int cnt = 0; for0(i, 10000)if (ar[i] == ar[p])cnt++; cout << cnt << endl;
	}
}


Measured memory_bytes: 3216
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define INF 1001001001

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

/*
1≤k≤n≤10^7
p は素数 (上の実装ではさらに p>n を仮定している)
*/

const int MAX = 2005;//階乗の配列数
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};


int main(){
  COMinit();
  int n, k;
  cin >> n >> k;
  repo(i, k){
    mint red=COM(n-k+1, i);
    mint blue=COM(k-1, i-1);
    mint ans=red*blue;
    cout << ans.x << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <ctype.h>
#include <string.h>
int main(void)
{
    char W[10],T[1000];
    char eof[12]="END_OF_TEXT";
    int cnt=0,i;
    
    scanf("%s",W);
    
    while(1)
    {
        scanf("%s",T);
        if(strcmp(T,eof)==0) break;
        else
        {
            for(i=0;T[i]!='\0';i++)
            {
                T[i]=tolower(T[i]);
            }
            if(strcmp(W,T)==0) cnt++;
        }
    }
    
    printf("%d\n",cnt);
    
    return 0;
}


Measured memory_bytes: 2104
// Author -- Frame

#include<bits/stdc++.h>

#define lowbit(x) ((x)&(-(x)))
#define Finline __inline__ __attribute__ ((always_inline))
#define DEBUG fprintf(stderr,"Running on Line %d in Function %s\n",__LINE__,__FUNCTION__)
#define SZ(x) ((int)x.size())
#define mkpr std::make_pair
#define pb push_back

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef std::pair<int,int> pi;
typedef std::pair<ll,ll> pl;
using std::min;
using std::max;

const int inf=0x3f3f3f3f,Inf=0x7fffffff;
const ll INF=0x3f3f3f3f3f3f3f3f;

Finline uint rnd(){static uint seed=416;return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;}
template <typename _Tp>_Tp gcd(const _Tp &a,const _Tp &b){return (!b)?a:gcd(b,a%b);}
template <typename _Tp>Finline _Tp abs(const _Tp &a){return a>=0?a:-a;}
template <typename _Tp>Finline void chmax(_Tp &a,const _Tp &b){(a<b)&&(a=b);}
template <typename _Tp>Finline void chmin(_Tp &a,const _Tp &b){(b<a)&&(a=b);}
template <typename _Tp>Finline void read(_Tp &x)
{
	char ch(getchar());bool f(false);while(!isdigit(ch)) f|=ch==45,ch=getchar();
	x=ch&15,ch=getchar();while(isdigit(ch)) x=(((x<<2)+x)<<1)+(ch&15),ch=getchar();
	f&&(x=-x);
}
template <typename _Tp,typename... Args>Finline void read(_Tp &t,Args &...args){read(t);read(args...);}
template <typename _Tp,typename... Args>Finline _Tp min(const _Tp &a,const _Tp &b,const Args &...args){return a<b?min(a,args...):min(b,args...);}
template <typename _Tp,typename... Args>Finline _Tp max(const _Tp &a,const _Tp &b,const Args &...args){return a<b?max(b,args...):max(a,args...);}
Finline int read_str(char *s)
{
	char ch(getchar());while(ch==' '||ch=='\r'||ch=='\n') ch=getchar();
	char *tar=s;*tar=ch,ch=getchar();while(ch!=' '&&ch!='\r'&&ch!='\n'&&ch!=EOF) *(++tar)=ch,ch=getchar();
	return tar-s+1;
}

const int N=1000005;
int a[N];
const int MAXN=1000005;
bool pr[MAXN];
int p[MAXN],pos,md[MAXN];
void sieve()
{
	for(int i=2;i<MAXN;++i)
	{
		if(!pr[i]) p[++pos]=i,md[i]=i;
		for(int j=1;j<=pos&&i*p[j]<MAXN;++j)
		{
			pr[i*p[j]]=true;
			md[i*p[j]]=p[j];
			if(!(i%p[j])) break;
		}
	}
}
int cnt[MAXN];
int main()
{
	sieve();
	int n;read(n);
	int g=0;
	for(int i=1;i<=n;++i)
	{
		read(a[i]);
		g=gcd(g,a[i]);
		int x=a[i];
		int last=0;
		while(x>1)
		{
			if(md[x]!=last) ++cnt[md[x]];
			last=md[x];
			x/=md[x];
		}
	}
	for(int i=1;i<MAXN;++i)
	{
		if(cnt[i]>1)
		{
			if(g==1)
			{
				printf("setwise coprime\n");
				return 0;
			}
			else
			{
				printf("not coprime\n");
				return 0;
			}
		}
	}
	printf("pairwise coprime\n");
	return 0;
}


Measured memory_bytes: 16436
n = int(input())
a = input()
b = input()
c = input()

t = n * 2;

for i in range(n):
    if a[i] == b[i] : t -= 1
    if b[i] == c[i] : t -= 1
    if c[i] == a[i] : t -= 1
    
    if a[i] == b[i] and b[i] == c[i] and c[i] == a[i] : t += 1
    
print(t)

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

#ifdef DEBUG
#define ifd if(true)
#else
#define ifd if(false)
#endif

#define dout ifd cerr

#define uint unsigned long long
#define int long long

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int N, M;
  cin >> N >> M;
  vector<pair<int, int>> q(M);
  for (int i = 0; i < M; i++) {
    cin >> q[i].first >> q[i].second;
    if (q[i].second < q[i].first) {
      int tmp = q[i].second;
      q[i].second = q[i].first;
      q[i].first = tmp;
    }
  }
  sort(q.begin(), q.end());
  int tot = 0;
  int rls = -1;
  for (pair<int, int> p : q) {
    if (p.first >= rls) {
      tot++;
      rls = p.second;
    } else {
      rls = min(rls, p.second);
    }
  }
  cout << tot << endl;
}


Measured memory_bytes: 1792
import java.util.*;

class Main {
  public static final long MOD = 1000000007;
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    int a;
    double tmp;
    double ans = 0;
    double Z = N;
    for(int i=N; i>0; i--){
      tmp = 1;
      a = i;
      while(a < K){
        tmp /= 2;
        a *= 2;
      }
      ans += 1/Z * tmp; 
    }
    System.out.println(ans);
  }

  public static int gcd(int a, int b){
    if(b == 0) return a;
    return gcd(b, a%b);
  }
}

Measured memory_bytes: 24148
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
#define pb push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
const int maxn=1e5+10;
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
ll gcd(ll a,ll b)
{
	return !b?a:gcd(b,a%b);
}
int main()
{
	ios::sync_with_stdio(false);cin.tie(0);
	ll a,b;
	cin>>a>>b;
	cout<<a/gcd(a,b)*b;
    return 0;
}



Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin 
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();

    token.parse().ok().expect("failed to parse token")
}
fn main() {
    let n : u8 = read();
    let m : u8 = read();
    if n == m {
        println!("Yes");
    } else {
        println!("No");
    }
}


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

int main()
{
  long long N; cin >> N;
  int sqrtN = sqrt(N);
  long long ans = 0;

  for (int i = 1; i <= sqrtN; i++)
  {
    if (N % i == 0 and N / i - 1 > i) ans += N / i - 1;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>

using namespace std;

using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define Rep(i, n) for (long long i = 0; i< (long long)(n); i++)
#define RRep(i,n) for (long long i = ((long long)(n)-1); i>=0; i--)
#define all(v) (v).begin(),(v).end()

struct Edge{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w){ }
};

using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;

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

template <class T>
T gcd(T a, T b){
    if( b==0 ) return a;
    return gcd(b, a%b);
}

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

const int INF = 1e9+7;

vector<int> dx = {-1,0,1,0};
vector<int> dy = {0,-1,0,1};

int main(){
    int n;
    cin >> n;
    vector<int> s(n);
    rep(i,n) cin >> s[i];
    int q;
    cin >> q;
    int ans = 0;
    rep(_,q){
        int t;
        cin >> t;
        if(binary_search(all(s),t)) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3160
k,n = map(int,input().split())
a = list(map(int,input().split()))
dis = [0]*n
for i in range(n):
    if i == 0:
        dis[i] = a[-1] - a[0]
    else:
        dis[i] = k - a[i] + a[i-1]
print(min(dis))

Measured memory_bytes: 26444
def main():
    n, k, q = map(int, input().split())
    score_list = [k - q for _ in range(n)]

    for _ in range(q):
        a = int(input())
        score_list[a - 1] += 1

    for score in score_list:
        if score > 0:
            print("Yes")
        else:
            print("No")


if __name__ == "__main__":
    main()


Measured memory_bytes: 80044
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<climits>
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(){
  int h,w,n; cin >> h >> w >> n;
  int mx = max(h,w);
  if(n%mx==0) cout << n / mx << endl;
  else cout << n / mx + 1 << endl;
  return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define _overload(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(...) _overload(__VA_ARGS__, repi, _rep)(__VA_ARGS__)
double res, PI = acos(-1);
int n;
main(){
	cin >> n;
    int x[n], y[n];
	rep(i, n){
        cin>>x[i]>>y[i];
    }
	rep(i, n){
        vector<double> d;
        rep(j, n){
            if(i != j){
                d.push_back(atan2(y[j] - y[i], x[j] - x[i]));
            }
        }
		sort(all(d));
		res = d[0] - d[d.size() - 1] + PI;
		rep(j, 1, d.size()){
            res=max(res,d[j] - d[j - 1] - PI);
        }
        cout<<max(0.0, res / 2.0 / PI)<<'\n';
	}
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws java.io.IOException {
        Scanner scan = new Scanner(System.in);
        while (true) {
            int n = scan.nextInt();
            if (n == 0)
                break;
            int ans = 0;
            for (int i = 1; i <= n / 2; i++) {
                int sum = i;
                for (int j = i + 1; j < n; j++) {
                    sum += j;
                    if (sum == n) {
                        ans++;
                        break;
                    }
                }
            }
            System.out.println(ans);
        }
    }
}

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

int main(){
  string s[7] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
  string str;
  cin >> str;
  for(int i=0;i<7;i++){
    if(str==s[i]) cout << 7-i << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define VI vector<int>
#define VVI vector<vector<int>>
#define UM unordered_map
#define MP map
#define ST set
#define US unordered_set
#define V vector
#define S string
#define D deque
#define L list
#define Q queue
#define PQ priority_queue
#define D deque
#define PII pair<int, int>
#define P pair
#define DB double
#define LDB long double
#define FOR(i, n) for (int i = 0; i < (n); ++i)
#define FFOR(i, n) for (int i = 0; i <= (n); ++i)
#define RFOR(i, n) for (int i = (n)-1; i >= 0; --i)
#define all(grid) (grid).begin(), (grid).end()
#define rall(grid) (grid).rbegin(), (grid).rend()

const int dr[] = {0, 1, 0, -1};
const int dc[] = {1, 0, -1, 0};

template <typename T>
void read(T& a) {
  a = 0;
  char c;
  while ((c = cin.peek()) < 48 or c > 57) cin.get();
  while ((c = cin.get()) > 47 and c < 58) a = (a << 3) + (a << 1) + c - 48;
}

template <typename T, typename... Args>
void read(T& a, Args&&... args) {
  read(a);
  read(forward<Args>(args...)...);
}

template <typename T>
void write(const S& sep, const S& end, T n) {
  char c[128] = {0};
  int i = 0;
  for (; n; ++i, n /= 10) c[i] = n % 10;

  for (--i; i >= 0; --i) cout.put(c[i] + 48);

  cout.write(end.c_str(), end.size() * sizeof(char));
}

template <typename T, typename... Args>
void write(const S& sep, const S& end, T n, Args&&... args) {
  char c[128] = {0};
  int i = 0;
  for (; n; ++i, n /= 10) c[i] = n % 10;

  for (--i; i >= 0; --i) cout.put(c[i] + 48);

  cout.write(sep.c_str(), sep.size() * sizeof(char));
  write(sep, end, forward<Args>(args...)...);
}
const int mxN = 1e5 + 5;
struct DSU {
  int parent[mxN], sz[mxN];

  DSU(int n) {
    iota(parent, parent + n, 0);
    fill_n(sz, n, 1);
  }

  int find(int i) {
    if (parent[i] == i) return i;
    return parent[i] = find(parent[i]);
  }

  void unite(int a, int b) {
    a = find(a), b = find(b);
    if (a != b) {
      if (sz[a] < sz[b]) {
        parent[b] = a;
        sz[a] += sz[b];
      } else {
        parent[a] = b;
        sz[b] += sz[a];
      }
    }
  }

  int size(int i) { return sz[find(i)]; }

  bool same(int a, int b) { return find(a) == find(b); }
};

void solve() {
  int n;
  cin >> n;
  ST<int> st[26];
  string s;
  cin >> s;
  for (char c : s) {
    static int i = 0;
    st[c - 'a'].insert(i++);
  }
  int q;
  cin >> q;
  FOR(i, q) {
    int n;
    cin >> n;
    if (n == 1) {
      int j;
      char c;
      cin >> j >> c;
      --j;
      if (c != s[j]) {
        st[s[j] - 'a'].erase(j);
        st[c - 'a'].insert(j);
        s[j] = c;
      }
    } else {
      int ans = 0;
      int l, r;
      cin >> l >> r;
      --l, --r;
      FOR(j, 26) {
        auto left = st[j].lower_bound(l);
        auto right = st[j].upper_bound(r);
        ans += left != right;
      }
      cout << ans << "\n";
    }
  }
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  solve();
}


Measured memory_bytes: 27236
/*
[nikkei2019-qual] A - Subscribers
*/

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

int N, A, B;

void solve() { cout << min(A, B) << " " << max(0, A + B - N) << endl; }

int main() {
    cin >> N >> A >> B;

    solve();

    return 0;
}


Measured memory_bytes: 256
n = int(input())
X = ['']
for i in range(1, 6):
    for j in range(10**i):
        X.append(str(j).zfill(i))
cnt = 0
for a in range(1, n+1):
    x = str(a)[0]
    y = str(a)[-1]
    if x == y:
        cnt += 1
    if y == '0':
        continue
    l, r = -1, len(X)-1
    while r-l > 1:
        c = (l+r)//2
        if int(y+X[c]+x) <= n:
            l = c
        else:
            r = c
    cnt += r
print(cnt)


Measured memory_bytes: 49628
#include <iostream>

using namespace std;

int N;
char S[5 * 100000];
int num_west = 0;
int cnt_west = 0;
int ans = 5 * 100000;

int main() {
    cin >> N >> S;
    for (int i = 0; i < N; i++) {
        if (S[i] == 'W') {
            num_west += 1;
        }
    }
    for (int i = 1; i < N + 1; i++) {
        int west = S[i-1] == 'W' ? cnt_west + 1 : cnt_west;
        int numt = N - i - (num_west - west) + cnt_west;
        if (numt < ans) {
            ans = numt;
        }
        cnt_west = west;
    }
    cout << ans << endl;
}

Measured memory_bytes: 888
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
  if n==1
    return Array.new(size){init}
  else
    return Array.new(n).map{Array.new(size){init}}
  end
end


def min(a,b)
  return a>b ? b : a
end
V,E=get_i
d=Array.new(V).map{Array.new(V){Float::INFINITY}}
V.times do|i|
  d[i][i]=0
end
E.times do|i|
  s,t,d_=get_i
  d[s][t]=d_
end

V.times do|k|
  V.times do|i|
    V.times do|j|
      d[i][j]=min(d[i][j],d[i][k]+d[k][j])
    end
  end
end
flag=false
V.times do|i|
  if d[i][i]<0
    flag=true
    break
  end
end
if flag
  puts "NEGATIVE CYCLE"
else
  V.times do|i|
    V.times do|j|
      if d[i][j]==Float::INFINITY
        print "INF"
      else
        print d[i][j]
      end
      print " " unless j==V-1
    end
    print "\n"
  end
end


Measured memory_bytes: 8936
#include<bits/stdc++.h>
using namespace std;
const long double PI = 3.14159265358979323846;  /* pi */

int main() {
    long long n;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i] >> b[i];
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());

    double m1, m2;
    long ans = 0;
    if (n & 1)
    {
        m1 = a[n/2];
        m2 = b[n/2];
        ans = m2 - m1 + 1;
    }
    else
    {
        m1 = (a[(n-1)/2] + (double)a[n/2])/2.0;
        m2 = (b[(n-1)/2] + (double)b[n/2])/2.0;
        double dif = (m2 - m1);
        ans = dif * 2 + 1;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 4744
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>; 
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1001001001001001001;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main(){
    int n; cin >> n;
    vector<ll> A(n); rep(i, n) cin >> A[i];

    ll res = 0;
    rept(i, 1, n){
        if(A[i] < A[i-1]){
            res += A[i-1] - A[i];
            A[i] = A[i-1];
        }
    }
    cout << res << ln;
}
    


Measured memory_bytes: 4844
//↓見なくていいよ！ここから--------------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error("\n");
  var start = Date.now();
  Main();
  var end = Date.now() - start;
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function makeClone(obj){return JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//↑見なくていいよ！ここまで--------------------------------------------------
function Main(){
	var one = nextIntArray();
	var N = one[0];
	var K = one[1];
	var output = 0;
	for(var i = 1; i <= N; i++){
		var tmp = (1 / N);
		if(i < K){
			//何回連続でコインを表にしてK点以上になる？
			var point = i;
			var count = 0;
			while(point < K){
				point *= 2;
				count++;
			}
			output += tmp * Math.pow(1 / 2, count);
		}else{
			output += tmp;
		}
	}
	myout(output);
}


Measured memory_bytes: 33912
#include <bits/stdc++.h>
 
using namespace std;
 
vector<pair<long long, long long>> d;
 
int main(int, char**)
{
	unsigned int n;
	long long t = 0, s = 0;
	cin >> n;
	d.resize(n);
 
	for (unsigned int i = 0; i < n; i++) {
		long long a, b;
		cin >> a >> b;
		d[i].first = a + b;
		d[i].second = a;
	}
 
	sort(d.begin(), d.end(), greater<>());
 
	for (unsigned int i = 0; i < n; i++) {
		if (i % 2 == 0) t += d[i].second;
		else s += d[i].first - d[i].second;
	}
 
    cout << t - s << endl;
	return 0;
}

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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> d(n);
    for (int i = 0; i < n; i++)cin >> d[i];

    int ret = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            ret += d[i] * d[j];
        }
    }

    cout << ret << endl;
    return 0;
}

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

//宣言
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

//数値
#define MOD 1000000007
#define INF (1<<20)
const double EPS = 1e-10;
const double PI = acos(-1.0);

//操作
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define REP(i,n) FOR(i,0,n)
#define REPB(i,n) for(int i=n;i>=0;--i)
#define SORT(A) sort(A,A+sizeof(A)/sizeof(A[0]))
#define VSORT(A) sort(A.begin(),A.end())
#define EXIST(s,e) (s.find(e)!=s.end())
#define PB push_back
#define MP make_pair
#define Int(x) int x; scanf("%lld", &x);
#define int2(x, y) int x, y; scanf("%lld %lld", &x, &y);

//DEBUG
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main() {
	bool E1[200000] = { 0 }, EN[200000] = { 0 };
	int n, m;
	cin >> n >> m;
	int a, b;
	REP(i, m) {
		cin >> a >> b;
		if (a == 1) E1[b - 1] = 1;
		if (b == 1) E1[a - 1] = 1;
		if (a == n) EN[b - 1] = 1;
		if (b == n) EN[a - 1] = 1;
	}
	FOR(i, 1, n - 1) {
		if (E1[i] == 1 && EN[i] == 1) {
			cout << "POSSIBLE" << endl;
			return 0;
		}
	}
	cout << "IMPOSSIBLE" << endl;

}

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

int w, h, n;
int x[10001], y[10001];

int getDist( int x1, int y1, int x2, int y2 )
{
	if( (x2 - x1) * (y2 - y1) >= 0 )
		return max(abs(x2 - x1), abs(y2 - y1));
	return abs(x2 - x1) + abs(y2 - y1);
}

int main()
{
	cin >> w >> h >> n;
	cin >> x[0] >> y[0];
	int ans = 0;
	for( int i = 1; i < n; i++ ){
		cin >> x[i] >> y[i];
		ans += getDist(x[i-1], y[i-1], x[i], y[i]);
	}
	cout << ans << endl;
	return 0;
}

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

int i,j,k,n,tab[100010];

int main()
{
	cin>>n;
	for (i=1;i<=n;i++)
	{
		cin>>k;
		tab[k]++;
	}
	int maxi=0;
	for (i=1;i<=100000;i++)
	{
		int sum=tab[i-1]+tab[i]+tab[i+1];
		maxi=max(sum,maxi);
	}
	cout<<maxi<<'\n';
}


Measured memory_bytes: 640
#include <cmath>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <sstream>

using namespace std;

typedef long long ll;

mt19937 rnd(228);

int main()
{
#ifdef ONPC
    freopen("a.in", "r", stdin);
#endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, l;
    cin >> n >> l;
    vector <int> a(n);
    for (int i = 0; i < n; i++)
    {
        int x;
        cin >> x;
        a[i] = x;
    }
    int x = -1;
    for (int i = 0; i < n - 1; i++)
    {
        if (a[i] + a[i + 1] >= l)
        {
            x = i;
        }
    }
    if (x == -1)
    {
        cout << "Impossible\n";
    }
    else
    {
        cout << "Possible\n";
        for (int j = n - 2; j >= x + 1; j--)
        {
            cout << j + 1 << '\n';
        }
        for (int j = 0; j < x; j++)
        {
            cout << j + 1 << '\n';
        }
        cout << x + 1 << '\n';
    }
}


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

int main(void)
{
  int n,v,r,f,b,i,j,k;
  int m[11][4][5]={};

  cin >> n;
  for(i=1;i<=n;i++){
    cin >> b >> f >> r >> v;
    m[r][f][b]=m[r][f][b]+v;
  }
  for(i=1;i<=4;i++) {
    for(j=1;j<=3;j++) {
      for(k=1;k<=10;k++) cout << " " << m[k][j][i];
      cout << endl;
    }
    if(i != 4)
      cout << "####################" << endl;
  }

  return 0;
}

Measured memory_bytes: 3084
using System;
public class Hello{
    public static void Main(){
        // Your code here!
        string[] line = Console.ReadLine().Split(' ');
        
        int a = int.Parse(line[0]);
        int b = int.Parse(line[1]);
        
        if(1<=a && a<=9 && 1<=b && b<=9) Console.WriteLine(a*b);
        else Console.WriteLine("-1");
    }
}


Measured memory_bytes: 13140
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import numpy as np

def main():
	N, K = map(int, input().split(" "))
	
	if K > N:
		print(1)
		sys.exit()
		
	if N % K == 0:
		print(0)
	else:
		print(1)
	
	
	
if __name__ == "__main__":
	main()


Measured memory_bytes: 12072
s = input()
k = int(input())
di = []
cnt = 1
ans = 0
if len(s) > 1:
    for i in range(1,len(s)):
        if s[i] == s[i-1]:
            cnt += 1
        else:
            di.append(cnt)
            cnt = 1
    di.append(cnt)
    if di[0] != len(s):
        for j in di:
            ans += j//2
        ans *= k
        if s[0] == s[-1] and di[-1] % 2 == 1 and di[0] % 2 == 1:
            ans += k - 1
    else:
        ans = k*len(s)//2
else:
    ans = k//2
print(ans)

Measured memory_bytes: 9252
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        char POSSIBLE = '1';
        char IMPOSSIBLE = '0';

        int over100 = n / 100;
        int under100 = n % 100;

        int[] rimit = new int[20];

        for (int i = 1; i <= 20; i++) {
            rimit[i - 1] = i * 5;
        }

        if (n >= 2000) {
            System.out.println(POSSIBLE);
            return;
        }

        if (over100 == 0) {
            System.out.println(IMPOSSIBLE);
            return;
        }
        if (under100 <= rimit[over100 - 1]) {
            System.out.println(POSSIBLE);
            return;
        }
        System.out.println(IMPOSSIBLE);
    }
}


Measured memory_bytes: 23508