akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    vector<int> P(N);
    rep(i, N) { cin >> P[i]; }
    ll sum = 0;
    sort(All(P));
    rep(i, N) { sum += P[i]; }
    sum -= P[N - 1] / 2;
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
matches = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]

n, m = map(int, input().split())
alist = list(map(int, input().split()))
alist.sort(reverse=True)

dp = [-1 for _ in range(n + 1)]
dp[0] = 0
for a in alist:
    match = matches[a]
    for i in range(n - match + 1):
        if dp[i] == -1: continue
        dp[i + match] = max(dp[i + match], dp[i] * 10 + a)

print(dp[-1])

Measured memory_bytes: 16496
//copy from https://atcoder.jp/contests/agc037/submissions/7059910
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define mem(x,v) memset(x,v,sizeof(x))
#define Rep(i,a,b) for(register int i=(a);i<=int(b);++i)
#define rep(i,a,b) for(register int i=(a);i<int(b);++i)
#define Dep(i,a,b) for(register int i=(a);i>=int(b);--i)
#define gc getchar
#define pc putchar
#define fi first
#define se second
inline ll read(){
    ll x=0,f=1;char c=gc();
    for(;!isdigit(c);c=gc())if(c=='-')f=-1;
    for(;isdigit(c);c=gc())x=(x<<1)+(x<<3)+(c^48);
    return x*f;
}
inline void write(ll x){if(x<0)x=-x,pc('-');if(x>=10)write(x/10);putchar(x%10+'0');}
inline void writeln(ll x){write(x);pc('\n');}
inline void wri(ll x){write(x);pc(' ');}
const int maxn = 2e5+233;
int n,l,a[maxn];
pii b[maxn];
vector<pair<pii,pii> > f,g;
ll calc(vector<pii> &v){
	ll res = 0 ,sum = 0;
	for(unsigned i=0,j=l-1;j<v.size();++i,++j)
		sum+=v[i].fi,res+=sum*v[j].se;
	return res;
}
int main(){
	n = read(),l = read();
	Rep(i,1,n){
		a[i] = read();
		b[i] = make_pair(a[i],i);
	}sort(b+1,b+1+n);
	int pos = 0;
	ll res = n,val = 0;
	for(;;){
//		printf("val = %d\n",val);
		if(f.empty()){
			if(pos > n) break;
			val = b[pos].fi;
		} else ++val;
		while(val == b[pos].fi){f.push_back({{b[pos].se,b[pos].se},{1,1}});pos++;}
		g.clear();sort(f.begin(),f.end());
		for(unsigned i=0,j=i;i<f.size();i=++j){
			while(j+1<f.size()&&f[j+1].fi.fi==f[j].fi.se+1)++j;
			int len=j-i+1,cnt=len/l;
			if(cnt){
				vector<pii> tmp,ff,gg;
				Rep(k,i,j) tmp.push_back(f[k].se);
				res += calc(tmp);
				Rep(k,1,cnt){
					ff.push_back({f[i].fi.fi+k-1,(k==cnt)?f[j].fi.se:f[i].fi.fi+k-1});
					gg.push_back({0,0});
				}
				Rep(k,i,j){
					int tl=k-i+1,tr=j-k+1;
					if(tl>=l) gg[tl/l-1].se += f[k].se.se;
					if(tr>=l) gg[cnt-tr/l].fi += f[k].se.fi;
				}
				res -= calc(gg);
				rep(k,0,cnt) g.push_back({ff[k],gg[k]});
			}
		}f = g;
	}
	writeln(res);
	return 0;
}

Measured memory_bytes: 12012
#include<algorithm>
#include<cmath>
#include<climits>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;
const ll MOD = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

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

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

	cout << A * B << endl;

	return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <map>

using ll = long long;

using namespace std;

struct edge{int u, v, w;};

int main() {
    int l;
    cin >> l;
    int d = 1 << 20, i = 1;
    for ( ; (2 * d & l) == 0; d >>= 1);
    vector<edge> ans;
    for (int cur=2 * d; d > 0; (i++, d >>= 1)) {
        ans.push_back(edge{i, i+1, 0});
        ans.push_back(edge{i, i+1, d});
        if (l - cur >= d) {
            ans.push_back(edge{1, i+1, cur});
            cur += d;
        }
    }
    cout << i << ' ' << ans.size() << '\n';
    for (auto &e:ans) cout << e.u << ' ' << e.v << ' ' << e.w << '\n';
    return 0;
}

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { std::cout << #a << " = " << a << "\n"; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T, class V> istream& operator>> (istream& ist, pair<T, V>& p) { return ist >> p.first >> p.second; }
template<class T> ostream& operator<< (ostream& ost, pair<T, T>& p) { return ost << p.first << ", " << p.second; }
template<class T> istream& operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) ist >> e; return ist; }

typedef long long ll;
int const inf = INT_MAX / 2;

int main() {
  int N; cin >> N;
  vector<int> A(N); cin >> A;
  // A (入力の数列)
  // => P (差の合計が最大になるように A を並び替えた数列)
  // D_i = P_{i + 1} - P_i
  // Σ D1_i = (P_1 - P_0) + (P_2 - P_1) + (P_3 - P_2) + (P_4 - P_3) + ... + (P_{N - 1} - P_{N - 2})
  // Σ D2_i = (P_0 - P_1) + (P_1 - P_2) + (P_2 - P_3) + (P_3 - P_4) + ... + (P_{N - 2} - P_{N - 1})
  // S1 = (P_1 - P_0) + (P_1 - P_2) + (P_3 - P_2) + (P_3 - P_4) + ...
  //    = 2 * (P_1 + P_3 + ...) - 2 * (P_2 + P_4 + ...) - P_0 + P_N

  // 1 2 3 6 8
  // 2 6 1 8 3
  //  4+5+7+5 = 21
  // S = (P_1 - P_0) + (P_1 - P_2) + (P_3 - P_2) + (P_3 - P_4)
  //   = 2 * (P_1 + P_3) - 2 * P_2 - P_0 - P_4
  //   = 2 * (8 + 6) - 2 * 1 - 2 - 3 = 28 - 7 = 21

  // 1 1 3 4 5 9
  // 
  // S = (P_1 - P_0) + (P_1 - P_2) + (P_3 - P_2) + (P_3 - P_4) + (P_5 - P_4)
  //   = 2 * (P_1 + P_3) - 2 * (P_2 + P_4) - P_0 + P_5
  //   = 2 * (5 + 9) - 2 * (1 + 1) - 3 + 4
  //   = 28 - 4 - 3 + 4
  //   = 25

  // 1 5 5
  // 5 1 5
  //  4+4 = 8
  // S1 = (P_1 - P_0) + (P_1 - P_2)
  //    = 2 * P_1 - P_0 - P_2
  //    = 2 * 5 - 5 - 1
  //    = 10 - 6 = 4
  // S2 = (P_0 - P_1) + (P_2 - P_1)
  //    = -2 * P_1 + P_0 + P_2
  //    = -2 * 1 + 5 + 5
  //    = 8

  sort(A.begin(), A.end());
  auto size = (N - 2) / 2;
  auto a1 = [&](){
    ll cand = 0;
    REP(i, (N - size - (N % 2)), N) {
      cand += 2 * A[i];
    }
    rep(i, size) {
      cand -= 2 * A[i];
    }
    cand += -A[size] + (N % 2 ? -1 : 1) * A[size + 1];
    return cand;
  }();
  auto a2 = [&](){
    ll cand = 0;
    REP(i, N - size, N) {
      cand += 2 * A[i];
    }
    rep(i, (size + N % 2)) {
      cand -= 2 * A[i];
    }
    cand += A[size + N % 2] + (N % 2 ? 1 : -1) * A[size + N % 2 + 1];
    return cand;
  }();

  cout << max(a1, a2) << endl;
}


Measured memory_bytes: 768
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String s = sc.next();
        int[] nums = new int[26];

        for (int i=0; i<s.length(); i++) {
            nums[(int) s.charAt(i) - 97] += 1;
        }
        for (int i=0; i<26; i++) {
            if (nums[i] == 0) {
                System.out.println((char)(i+97));
                return;
            }
        }
        System.out.println("None");
    }
}



Measured memory_bytes: 24548
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
 
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
 
int a[200],a2[200];
char mark[200],mark2[200],s[1000];
 
int main(void){
    int n,mini;
    char b;
 
    scanf("%d",&n);
    fgets(s,1000,stdin);
    fgets(s,1000,stdin);
    REP(i,n){
        mark[i] = mark2[i] = s[i * 3];
        a2[i] = a[i] = s[i * 3 + 1] - '0';
    }
 
    REP(i,n){
        RFOR(j,i + 1,n)
            if(a[j] < a[j - 1]){
                swap<int>(a[j],a[j - 1]);
                swap<char>(mark[j],mark[j - 1]);
            }
    }


    REP(i,n){
        mini = i;
        FOR(j,i,n)
            if(a2[j] < a2[mini])
                mini = j;
        if(i != mini){
            swap<int>(a2[i],a2[mini]);
            swap<char>(mark2[i],mark2[mini]);
        }
    }
 
    REP(i,n){
        if(i < n - 1)
            printf("%c%d ",mark[i],a[i]);
        else
            printf("%c%d\n",mark[i],a[i]);
    }
    printf("Stable\n");
    mini = 1;
    REP(i,n)
        if(mark[i] != mark2[i]){
            mini = 0;break;
        }
    REP(i,n){
        if(i < n - 1)
            printf("%c%d ",mark2[i],a2[i]);
        else
            printf("%c%d\n",mark2[i],a2[i]);
    }
    if(mini == 1)
        printf("Stable\n");
    else
        printf("Not stable\n");
    return 0;
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using ii = pair<int, int>;
using vii = vector<ii>;

const int mod = 1000000007;
int add(int a, int b) { return (a += b) < mod? a : a - mod; }
int sub(int a, int b) { return (a -= b) >=  0? a : a + mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }
void adds(int& a, int b) { a = add(a, b); }
void subs(int& a, int b) { a = sub(a, b); }
void muls(int& a, int b) { a = mul(a, b); }
void maxs(int& a, int b) { a = max(a, b); }
void mins(int& a, int b) { a = min(a, b); }
int pwr(int a, ll p) {
    if (p == 0) return 1;
    if (p & 1) return mul(a, pwr(a, p - 1));
    return pwr(mul(a, a), p / 2);
}
int inv(int a) { return pwr(a, mod - 2); }

int n, k, a[100], dp[100002], ndp[100002];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> k;
    for (int i = 0; i < n; ++i)
        cin >> a[i];

    dp[0] = 1;
    for (int i = n - 1; i >= 0; --i)
    {
        for (int q = 1; q <= k; ++q)
            adds(dp[q], dp[q - 1]);

        for (int r = 0; r <= k; ++r)
        {
            int l = r - min(a[i], r);
            int s = (l == 0 ? 0 : dp[l - 1]);
            ndp[r] =  sub(dp[r], s);
        }
        memcpy(dp, ndp, sizeof dp);
    }
    cout << dp[k];
}


Measured memory_bytes: 1024
#include <stdio.h>

#define G 9.8
int main(void){
    double v,h;
    int fl;
    
    while (scanf("%lf", &v)!=EOF){
        h=v*v/(2*G);
        for (fl=1; (5*fl-5)<h; fl++) ;
        printf("%d\n", fl);
    }

    return 0;
}

Measured memory_bytes: 1060
n = int(input())
p = list(map(int, input().split()))

# print(n)
# print(p)

p_s = sorted(p)

# print(p_s)

count = 0
for i in range(len(p)):
    if p[i] != p_s[i]:
        count += 1
        
# print(count)

if count == 0 or count == 2:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3060
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() []int {
	n := readInt()
	return readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func minInt(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func minUint(a, b uint) uint {
	if a < b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func minUint64(a, b uint64) uint64 {
	if a < b {
		return a
	}
	return b
}

func maxInt(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func maxUint(a, b uint) uint {
	if a < b {
		return b
	}
	return a
}
func maxInt64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func maxUint64(a, b uint64) uint64 {
	if a < b {
		return b
	}
	return a
}

func absInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int
func main() {
	defer stdout.Flush()

	n := readInt()
	a := make([]int, n)

	for i := 0; i < n; i++ {
		a[i] = readInt()
	}

	var ans int
	i := 0
	j := 1
	for j < len(a) {
		if a[i] != a[j] {
			ans += (j - i) / 2
			i = j
		}
		j++
	}
	ans += (j - i) / 2
	println(ans)
}


Measured memory_bytes: 640
def repeted(S):
    for i in range(1,len(S)):
        if S[i]!=S[0]:
            return False
    return True

def repeted_first(S):
    res=1
    i=1
    while i<len(S) and S[i]==S[0]:
        res+=1
        i+=1
    return res

def repeted_last(S):
    res=1
    i=len(S)-2
    while i>=0 and S[i]==S[-1]:
        res+=1
        i-=1
    return res

def calc_t(S):
    res=0
    temp=1
    for i in range(1,len(S)):
        if S[i]==S[i-1]:
            temp+=1 # 連続する同じ文字の数
        else:
            res+=temp//2
            temp=1
    res+=temp//2
    return res # Sの最後まで見た後

S=input()
K=int(input())

if S[0]!=S[-1]:
    ans=calc_t(S)*K

elif repeted(S):
    ans=(len(S)*K)//2

else:
    rf=repeted_first(S)
    rl=repeted_last(S)
    ans=(calc_t(S)-rf//2-rl//2)*K+rf//2+((rf+rl)//2)*(K-1)+rl//2

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
 
int k;
 
int calc(vector<int> card){
    int ans = 0;
    for(int i = 0 ; i < card.size()-k+1 ; i++){
        int tmp = 1;
        for(int j = 0 ; j < k ; j++){
            tmp *= card[i+j];   
        }
        ans = max(tmp, ans);
    }
    return ans;
}
 
int main(){
    int n;
    while(cin >> n >> k){
      if(n == 0 && k == 0) break;
      vector<int> card(n);
      
      for(int i = 0 ; i < n ; i++) cin >> card[i];
      int ans = 0 , t = calc(card);
      for(int i = 0 ; i < n ; i++)
	for(int j = i+1 ; j < n ; j++){
	  swap(card[i],card[j]),ans=max(ans,calc(card)-t),swap(card[i],card[j]);
	}
      cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 904
import java.util.*

fun main() {

    val (n, m) = readLine()!!.split(" ").map(String::toInt)

    data class Edge(val from: Int, val to: Int, val cost: Int)

    val list = mutableListOf<Edge>()
    repeat(m) {
        val (f, t) = readLine()!!.split(" ").map(String::toInt)
        list.add(Edge(f - 1, t - 1, 1))
        list.add(Edge(t - 1, f - 1, 1))
    }
    val graph = list.groupBy { it.from }

    val d = Array(n) { Pair(Integer.MAX_VALUE, -1) }

    fun dijkstra(s: Int) {
        // first 頂点番号 second 最短距離
        val q = PriorityQueue<Pair<Int, Int>>(n) { p1, p2 ->
            p1.second - p2.second
        }

        d[s] = 0 to 0
        q.add(s to 0)

        while (q.isNotEmpty()) {
            val (from, cost) = q.poll()
//            println(from)
//            println("from:$from cost:$cost")
            // コストが低いのが登録済みであれば処理をスキップする。
            if (d[from].first < cost) {
                continue
            }

            for (edge in graph[from] ?: emptyList()) {
                if (d[edge.to].first > d[edge.from].first + edge.cost) {
                    d[edge.to] = (d[edge.from].first + edge.cost) to edge.from
                    q.add(edge.to to d[edge.to].first)
                }
            }
        }
    }

    dijkstra(0)

    if (d.any { it.first == Integer.MAX_VALUE }) {
        println("No")
    } else {
        println("Yes")
        for (i in 1..d.lastIndex) {
            println(d[i].second+1)
        }
    }

}





Measured memory_bytes: 97644
#include<bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define inf 1000000000

vector<pii> v[200010];

int num[200010],h[110],n,tt;

inline int rd()
{
	int x=0;char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar());
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x;
}

int main()
{
	n=rd();
	for (int i=1;i<=n;i++) num[i]=rd();
	int ans=1;
	for (int i=n-1;i;i--) if (num[i]<num[i+1]) ans++;
	v[1].push_back(pii(0,2));
	v[1].push_back(pii(num[1],1));
	for (int i=2;i<=n;i++)
	{
		tt=0;
		for (pii hh:v[i-1])
		{
			h[++tt]=hh.first;
			h[++tt]=hh.first+num[i]-num[i-1];
		}
		sort(h+1,h+tt+1);
		tt=unique(h+1,h+tt+1)-h-1;
		for (int j=1;j<=tt;j++) if (h[j]>=0&&h[j]<=num[i])
		{
			int res=inf;
			for (pii hh:v[i-1]) res=min(res,hh.second+(h[j]<hh.first)+(num[i]-h[j]>num[i-1]-hh.first));
			if (v[i].empty()||res!=v[i].back().second) v[i].push_back(pii(h[j],res));
		}
	}
	for (int i=0;i<v[n].size();i++)
	{
		int now=v[n][i].second-(i==0);
		ans=min(ans,now);
	}
	printf("%d\n",ans);
	return 0;
}

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

using namespace std;
#define sf(n) scanf("%d", &n)
#define pd(n) printf("%.12lf", n)
#define pf(n) printf("%d", n)
#define p() printf("\n")
#define ps() printf(" ")
#define ll long long
#define ull unsigned long long
#define MAX 1e9
#define mod 1000 * 1000 * 1000 + 7
#define ex 1e18
#define dbl 2e09
#define qu(q) queue<int> q
#define pqu(q) priority_queue<int> q
#define len(s) s.length()
#define sz(x) int(x.size())
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define F first
#define S second
#define clr(x) x.clear()
#define LOG(x) std::cout << x << std::endl;

const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double PI = 3.14159265359;

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

int x[100005];

int main()
{
    ll n,a,b;
    cin>>n>>a>>b;   
    ll ans=0;
    for(int i=0;i<n;++i){
        cin>>x[i];
    }
    for(int i=1;i<n;++i){
        ans+=min(a*1LL*(x[i]-x[i-1]),1LL*b);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;

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 (a>b) { a=b; return 1; } return 0; }
#define _overload3(_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(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()


int main() {
    int k;
    cin >> k;
    string s;
    cin >> s;
    if (k >= s.size()) {
        cout << s << endl;
    } else {
        s = s.substr(0, k) + "...";
        cout << s << endl;
    }
}

Measured memory_bytes: 3608
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;
#include <vector>
#define rep(i,n) for (int i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

ll A;
ll B;
ll C;
ll N;
ll M;
ll K;

int main(){

    cin >> N;
    cin >> K;

    ll ans = 1;
    
    while(N/K>0){
        ans++;
        N = N/K;
    }
    cout << ans << endl;
    

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
  ll n,m;
  cin >> n>> m;
  ll ans=0;
  if(abs(n-m)>1){
    cout << 0;
    return 0;
  }
  ll p=1,q=1,r=1,mod=1e9+7;
  for(int i=1;i<=n;i++){
    p*=i;
    p%=mod;
  }
  for(int i=1;i<=m;i++){
    p*=i;
    p%=mod;
  }
  if((n+m)%2==0){
    p*=2;
    p%=mod;
  }
  cout << p;
  
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define LL long long
#define ULL unsigned long long
#define mem(i, j) memset(i, j, sizeof(i))
#define rep(i, j, k) for(int i = j; i <= k; i++)
#define dep(i, j, k) for(int i = k; i >= j; i--)
#define pb push_back
#define make make_pair
#define INF INT_MAX
#define inf LLONG_MAX
#define PI acos(-1)
using namespace std;

const int N = 1e6 + 5;

const LL mod = 1e9 + 7;

LL ksm(LL a, LL b) { LL ans = 1LL; while(b) { if(b & 1) ans = ans * a % mod; a = a * a % mod; b >>= 1; }  return ans; }

int a[N], b[N];

void solve() {
    int n;
    scanf("%d", &n);
    LL ans = 0LL;
    rep(i, 1, n) {
        scanf("%d", &a[i]);
        ans += b[a[i]];
        b[a[i]]++;
    }
    rep(i, 1, n) {
        ans -= (b[a[i]] - 1);
        printf("%lld\n", ans);
        ans += (b[a[i]] - 1);
    }

}


int main() {
//    int _; scanf("%d", &_);
//    while(_--) solve();

    solve();

    return 0;
}


Measured memory_bytes: 7040
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <ctime>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define RREP(i,x) for(int i=(x)-1;i>=0;i--)
#define RFOR(i,c) for(auto i=(c).rbegin();i!=(c).rend();++i)
#define ALL(container) container.begin(), container.end()
#define SZ(container) ((int)container.size())

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;

main(){
	vector<pii> db;
	for(int w=1;w<=150;w++)
		for(int h=1;h<w;h++)
			db.push_back(pii(w*w+h*h, h));
	sort(db.begin(), db.end());
	int w, h;
	while(cin >> h >> w, h){
		pii tar(w*w+h*h, h);
		tar = *upper_bound(db.begin(), db.end(), tar);
		cout << tar.second << " " << (int)(1e-8+sqrt(tar.first - tar.second*tar.second)) << endl;
	}
	return 0;
}

Measured memory_bytes: 1328
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001
#define fi first
#define se second

int main(void) {
	int n; cin >> n;
	vector<string> s(n); rep(i,n) cin >> s[i];
	map<string,int> mp;
	rep(i,n) mp[s[i]]++;
	int mx = 0;
	for(auto x:mp) mx = max(mx,x.se);
	vector<string> ans;
	for(auto x:mp){
		if(x.se==mx) ans.push_back(x.fi);
	}
	SORT(ans);	
	rep(i,ans.size()) cout << ans[i] << endl;
}




Measured memory_bytes: 28404
#include <bits/stdc++.h>
using namespace std;
int a[100000];
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	char c;
	cin>>c;
	if(c>='a'&&c<='z') cout<<'a';
	else cout<<'A';
}

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


int main() {
    set<int> color;
    int n;
    cin >> n;
    
    int c = 0;
    rep(i, n) {
        int a;
        cin >> a;
        if (a >= 3200) {
            c++;
            continue;
        }
        rep(j, 8) {
            if ((j == 0 ? 1 : 400 * j <= a) && a < 400 * (j + 1)) {
                // cout << j << endl;
                color.insert(j);
                break;
            }
        }
    }
    
    cout << (sz(color) == 0 ? 1 : sz(color)) << " " << c + sz(color) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define vll vector<int>
#define pii pair<int,int>
#define pb push_back
#define sz(v) (int)(v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(int i=a;i<b;++i)
using namespace std;

#define M 100010


int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   	
   	int n;cin>>n;
   	vector<pii> a(n);
   	int b[n],c[n],ans[n];
   	map<int,int>mp;
   	vll id[n+1];
   	rep(i,0,n)cin>>c[i],mp[c[i]]++,id[c[i]].pb(i);
   	set<pii>s;
   	for(auto p:mp)s.insert({p.se,p.fi});
   	int i=n-1;
   	while(i>=0){
   		auto it=s.begin();
   		pii p=*it;
   		s.erase(it);
   		int x=p.se;
   		rep(k,0,p.fi)
   			a[i].fi=x,a[i].se=id[x].back(),id[x].pop_back(),i--;
   	}
   	
   	// rep(i,0,n)cout<<a[i].fi<<" ";cout<<"\n";
   	mp.clear(),s.clear();
   	rep(i,0,n)cin>>b[i],mp[b[i]]++;
   	for(auto p:mp)s.insert({p.se,-p.fi});
   rep(i,0,n)ans[i]=-1;
   bool ok=1;
   	rep(i,0,n){
   		int x=a[i].fi,j=a[i].se;
   		auto it=s.end();it--;
   		pii p=*it;p.se=-p.se;
   		if(p.se!=x){
   			s.erase(it);
   			if(p.fi>1)s.insert({p.fi-1,-p.se});
   			ans[j]=p.se;
   		}
   		else{
   			if(s.size()==1){
   				ok=0;
   				break;
   			}
   			it--,p=*it,s.erase(it),p.se=-p.se;
   			if(p.fi>1)s.insert({p.fi-1,-p.se});
   			ans[j]=p.se;
   		}
   	}
   	if(!ok){
   		rep(i,0,n/2+1)if(i+n/2<n)swap(b[i],b[i+n/2]);
   		rep(i,0,n)if(b[i]==c[i]){
   			cout<<"No";
   			return 0;
   		}
   		cout<<"Yes\n";
   		rep(i,0,n)cout<<b[i]<<" ";
   		return 0;
   	}
   	cout<<"Yes\n";
   	rep(i,0,n)cout<<ans[i]<<" ";
   	
   	
    return 0;
}


Measured memory_bytes: 46960
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
int main(void){
    ll x,k,d;cin>>x>>k>>d;
    x=abs(x);
    ll buf=x/d;
    if(k<=buf){
        ll res=x-k*d;
        cout<<res<<endl;
        return 0;
    }
    k-=buf;
    k%=2;
    buf+=k;
    ll res=x-buf*d;
    res=abs(res);
    cout<<res<<endl;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
using namespace std;

//can use O(1) memory 

int T, n;
const int maxn = 100000+5;

int dpa, dpb, dpc, a, b, c;
int ta, tb, tc;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	cin >> n;
	dpa = dpb = dpc = 0;
	for(int i = 0; i < n; i++)
	{
		cin >> a >> b >> c;
		ta = max(dpb, dpc)+a;
		tb = max(dpa, dpc)+b;
		tc = max(dpb, dpa)+c;
		dpa = ta;
		dpb = tb;
		dpc = tc;
	}
	cout << max(max(dpa, dpb), dpc);
	return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
  
  int a,b,c,d;
  int l,r;

  string result;
  
  cin >> a >> b >> c >> d;

  l = a+b;
  r = c+d;

  if(l > r){
    result = "Left";
  } else if(l == r){
    result = "Balanced";
  } else {
    result = "Right";
  }
  
  cout << result << endl;
  
  return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scn=new Scanner(System.in);
		String str=scn.next();
		int num=10,x=10;
		num*=str.charAt(0)-'0';
		num+=str.charAt(1)-'0';
		num*=10;
		num+=str.charAt(2)-'0';
		num*=10;
		num+=str.charAt(3)-'0';
		x*=str.charAt(5)-'0';
		x+=str.charAt(6)-'0';
		if(num>=2019&&x>4) {
			System.out.println("TBD");
		}else {
			System.out.println("Heisei");
		}
	}

}


Measured memory_bytes: 21844
#include<iostream>
using namespace std;
int main(){
    int N,C;
    cin >> N >> C;
    int sum=0;
    for(int i=0;i<C;i++){
        int a;
        cin >> a;
        sum+=a;
    }
    if(sum%(N+1)!=0){
        cout << sum/(N+1)+1 << endl;
    }else{
        cout << sum/(N+1) << endl;
    }
}


Measured memory_bytes: 3124
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}


ll f(ll b, ll n){
  if(n<b) return n;
  return f(b,n/b)+n%b;
}


signed main(){
  ll n,s; cin>>n>>s;
  if(n<s) return cout<<-1<<endl,0;
  if(n==s) return cout<<n+1<<endl,0;
  ll ans = -1;
  for(ll b=1;b<(ll)pow(n,0.5)+5;b++){
    // if(b==1) continue;
    // if(b>n) break;
    if(b!=1&&b<=n&&f(b,n)==s&&(ans==-1||ans>b)) ans=b;
    if(b<=n-s && (n-s)/b+1<=n&&f((n-s)/b+1,n)==s&&(ans==-1||ans>b)) ans=(n-s)/b+1;
  }
  cout<<ans<<endl;



  return 0;
}


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

int main(){
	int n, k, b, T = 0;
	
	cin>>n;
	
	cin>>k;
	
	for(int i = 0; i < k; i++){
		cin>>b;
		T |= 1<<b;
	}
	
	for(int i = 0; i < (1<<n); i++){
		if((T&i) != T) continue;
		cout<<i<<":";
		for(int j = 0, k = i; k; j++){
			if(k&(1<<j)){
				cout<<" "<<j;
				k &= ~(1<<j);
			}
		}
		cout<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 3088
#include<stdio.h>

int main(void){
  int K;
  int i;
  int count=1;
  int p=7;
  scanf("%d",&K);
  for(;;){
    p=p%K;
    if(p==0){
      printf("%d\n",count);
      return 0;
    }
    if(count>=K){
      printf("-1\n");
      return 0;
    }
    p=10*p+7;
    count++;
  }
}

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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

int main(){
    int n,m,k;
    cin>>n>>m>>k;
    for(int i=0;i<=n;++i){
        for(int j=0;j<=m;++j){
            if((i*j+(n-i)*(m-j))==k){cout<<"Yes";return 0;}
        }
    }
    cout<<"No";
}


Measured memory_bytes: 256
input_date = input()
date_array = input_date.split('/')

year = int(date_array[0])
month = int(date_array[1])
day = int(date_array[2])

if (year <= 2018) or (year == 2019 and month <= 4):
  print('Heisei')
else:
  print('TBD')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  int dx = x2 - x1;
  int dy = y2 - y1;
  dy *= -1;
  swap(dx, dy);
  int x3 = dx + x2, y3 = dy + y2;
  dy *= -1;
  swap(dx, dy);
  int x4 = dx + x3, y4 = dy + y3;
  cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
  return 0;
}

Measured memory_bytes: 3516
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define V vector
#define VI vector<int>
#define VVI vector<vector<int>>

using namespace std;

int main(void){
    int N,W;
    cin>>N>>W;
    vector<pair<int,int>> w(N);
    vector<vector<long>> dp(110,vector<long>(100010));
    rep(i,100010)dp[0][i]=0;
    rep(i,N)cin>>w[i].first>>w[i].second;

    rep(i,N){
        rep(j,W+1){
            if(w[i].first<=j){
                dp[i+1][j]=max(dp[i][j-w[i].first]+w[i].second,dp[i][j]);
            }else{
                dp[i+1][j]=dp[i][j];
            }
        }
    }
    cout<<dp[N][W]<<endl;
}



Measured memory_bytes: 87296
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	As := make([]int, n)
	for i:=0; i<n; i++ {
		fmt.Scan(&As[i])
	}
	max := 0
	for i:=0;i<n-1 ;i++  {
		for j :=i+1; j<n; j++{
			if max < abs(As[i] - As[j]) {
				max = abs(As[i] - As[j])
			}
		}
	}
	fmt.Println(max)
}


func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}


Measured memory_bytes: 512
N = parse(Int, readline())
A = zeros(Int, N)
for i in 1:N
    s = readline()
    A[i] = parse(Int, s)
end

paper = Set{Int}()
cnt = 0

for i in 1:N
    if(in(A[i], paper))
        pop!(paper, A[i])
        global cnt -= 1
    else
        push!(paper, A[i])
        global cnt += 1
    end
end

println(cnt)


Measured memory_bytes: 183572
/*
  ∧,,∧
( 'ω' )つ ＜WA,またお前か！！　
（m9 ＼ 　　
　 ＼　 ＼
　 　 ) ) ＼
　 ／／ ＼ ＼
　 (＿） 　 (＿)
*/

#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(),(x).end()
#define rep(x, y) for (int x = 0; x < y; x++)
#define MOD 1000000007

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

ostringstream oss_global;
string s_global = oss_global.str();

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

    int ans = 3 * r * r;
    cout << ans << endl;
    return 0;
}


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

void showVector(std::vector<int> readVec){
    int size = readVec.size();
    for(int i = 0; i < size; ++i){
        std::cout << readVec.at(i);
        if(size - 1 != i){
            std::cout << " ";
        }else{
            std::cout << std::endl;
        }
    }
}

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

    std::vector<int> a(n);
    for(int i = 0; i < n; ++i){
        std::cin >> a.at(i);
    }

//    showVector(a);

    int count = 0;

    for(int i = 0; i < n; ++i){
        int temp = i;
        for(int j = i; j < n; ++j){
            if(a.at(j) < a.at(temp)){
                temp = j;
            }
        }

        if(temp != i){
            a.at(i) += a.at(temp);
            a.at(temp) = a.at(i) - a.at(temp);
            a.at(i) = a.at(i) - a.at(temp);

            ++count;
        }
    }

    showVector(a);
    std::cout << count << std::endl;

    return 0;
}



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

int main() {
    string s, t, u;
    cin >> s;
    t = s + s;
    u = s + s + s;
    int64_t K, count1 = 0, count2 = 0, N, count3 = 0;
    cin >> K;
    N = s.size();
    if (N == 1) {
        cout << K / 2 << endl;
        return 0;
    }
    for (int i = 0; i < N - 1; i++){
        if (s.at(i) == s.at(i + 1)) {
            count1++;
            i++;
        }
    }
    for (int i = 0; i < 2 * N - 1; i++){
        if (t.at(i) == t.at(i + 1)) {
            count2++;
            i++;
        }
    }
    for (int i = 0; i < 3 * N - 1; i++){
        if (u.at(i) == u.at(i + 1)) {
            count3++;
            i++;
        }
    }
    if (2 * count2 - count1 == count3){
        cout << (count2 - count1) * (K - 1) + count1 << endl;
    }
    else {
        int a = count2 - count1, b = count3 - count2;
        if (K % 2 == 0) {
            cout << count1 + K / 2 * a + (K / 2 - 1) * b << endl;
        }
        else {
            cout << count1 + K / 2 * (a + b) << endl;
        }
    }
}








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

using namespace std;

typedef long long ll;

int main(int argc, char const *argv[])
{
    double n, k;
    double ans=0;

    cin >> n >> k;

    for (int i = 1; i <= n; ++i) {
        if (i<k) {
            ans += pow(0.5, ceil(log2(k/i)));
        }
        else ans++;
    }

    ans /= n;
    
    
    printf("%.16lf\n", (double)(ans));
    return 0;
}

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

#include <climits>
#include <cmath>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
//#define local
#ifdef local
#include "dbg-macro/dbg.h"
#endif
//#define hacks
#ifdef hacks
#include <boost/multiprecision/cpp_int.hpp>
#endif
#define p std::pair
#define ll long long
#define ld long double
#define ull unsigned long long
#define pi std::pair<int, int>
#define all(x) (x).begin(), (x).end()
#define rep(i, n) \
	for (unsigned long long i = 0; i < (unsigned long long)(n); ++i)
#define vec std::vector
#define oreq |=
#define npm next_permutation
using namespace std;
std::vector<unsigned ll> genprimevec(const unsigned ll N);
ll extgcd(ll a, ll b, ll& x, ll& y);
ll nCr(ll n, ll r);
void stat();
template <typename T>
T fact(T num);
constexpr ll mod = 1000000000 + 7;

int main() {
	stat();
	int a,b,k;cin>>a>>b>>k;
	if(b-a+1<2*k){
#ifdef local
		dbg(1212);
#endif
		for(int i=a;i!=b+1;++i){
			cout<<i<<endl;
		}
		return 0;
	}
	for(int i=a;i<a+k;++i){
		cout<<i<<endl;
	}
	for(int i=b-k+1;i!=+b+1;++i){
		cout<<i<<endl;
	}

	return 0;
}

std::vector<unsigned ll> genprimevec(const unsigned ll N) {
	std::vector<bool> is_prime(N + 1);
	for (unsigned ll i = 0; i <= N; i++) {
		is_prime[i] = true;
	}
	std::vector<unsigned ll> P;
	for (unsigned ll i = 2; i <= N; i++) {
		if (is_prime[i]) {
			for (unsigned ll j = 2 * i; j <= N; j += i) {
				is_prime[j] = false;
			}
			P.emplace_back(i);
		}
	}
	return P;
}

void stat(){
#ifdef local
    rep(i, 2){std::cout << "local enable" << std::endl;
}
#endif
#ifdef hacks
rep(i, 2) { std::cout << "boost enable" << std::endl; }
#endif
}

ll nCr(ll n, ll r) {
	ll num = 1;
	for (ll i = 1; i <= r; i++) {
		num = num * (n - i + 1) / i;
	}
	return num;
}

template <typename T>
T fact(T num) {
	if (num == 1) {
		return 1;
	}
	return num * fact(num - 1);
}


Measured memory_bytes: 3624
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		
	Scanner sc = new Scanner(System.in);
	
	double r = sc.nextDouble();
	
	System.out.printf(" %.6f %.6f\n " ,r * r * Math.PI, (r*2) * Math.PI);
	sc.close();
	}
}



Measured memory_bytes: 28216
#include<bits/stdc++.h>
#define F first
#define S second
using namespace std;

int main(){

  int H, W;
  char mas[55][55];
  int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
  int d[55][55];
  typedef pair < int, int > P;
  queue < P > que;
  int cnt = 0;

  cin >> H >> W;
  for(int i=1;i<=H;i++){
    for(int j=1;j<=W;j++){
      cin >> mas[i][j];
      if(mas[i][j] == '.') cnt++;
    }
  }


  memset(d, -1, sizeof(d));

  que.push(P(1,1)); //x, y
  d[1][1] = 0;

  while(que.size() != 0){
    int x = que.front().F, y = que.front().S; que.pop();

    for(int i=0;i<4;i++){
      int nx = x + dx[i], ny = y + dy[i];

      if(nx < 1 || ny < 1 || nx > W || ny > H) continue;
      if(mas[ny][nx] == '#') continue;
      if(d[ny][nx] != -1 && d[ny][nx] <= d[y][x]+1) continue;

      d[ny][nx] = d[y][x] + 1;
      que.push(P(nx, ny));
    }
  }

  if(d[H][W] != -1) cout << cnt - d[H][W] -1 << endl;
  else cout << -1 << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#define ALL(x) (x).begin(), (x).end()
#define rt return
#define dll(x) scanf("%I64d",&x)
#define xll(x) printf("%I64d\n",x)
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define gg(x) getInt(&x)
#define db(x) cout<<"== [ "<<x<<" ] =="<<endl;
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll powmod(ll a,ll b,ll MOD){ll ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}
inline void getInt(int* p);
const int maxn=1000010;
const int inf=0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/

int main()
{
    //freopen("D:\\common_text\\code_stream\\in.txt","r",stdin);
    //freopen("D:\\common_text\\code_stream\\out.txt","w",stdout);
    string s;
    gbtb;
    cin>>s;
    int len=s.length();
    if(s[0]==s[len-1])
    {
        if(len&1)
        {
            cout<<"Second"<<endl;
        }else
        {
            cout<<"First"<<endl;   
        }
    }else
    {
        if(len&1)
        {
            cout<<"First"<<endl;
        }else
        {
            cout<<"Second"<<endl;
        }
    }
    
    
    
    return 0;
}

inline void getInt(int* p) {
    char ch;
    do {
        ch = getchar();
    } while (ch == ' ' || ch == '\n');
    if (ch == '-') {
        *p = -(getchar() - '0');
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 - ch + '0';
        }
    }
    else {
        *p = ch - '0';
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 + ch - '0';
        }
    }
}



Measured memory_bytes: 512
class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0]*(n+1)

    def __iter__(self):
        psum = 0
        for i in range(self.size):
            csum = self.sum(i+1)
            yield csum - psum
            psum = csum
        raise StopIteration()

    def __str__(self):  # O(nlogn)
        return str(list(self))

    def sum(self, i):
        # [0, i) の要素の総和を返す
        if not (0 <= i <= self.size): raise ValueError("error!")
        s = 0
        while i>0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        if not (0 <= i < self.size): raise ValueError("error!")
        i += 1
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

    def __getitem__(self, key):
        if not (0 <= key < self.size): raise IndexError("error!")
        return self.sum(key+1) - self.sum(key)

    def __setitem__(self, key, value):
        # 足し算と引き算にはaddを使うべき
        if not (0 <= key < self.size): raise IndexError("error!")
        self.add(key, value - self[key])

from operator import itemgetter
import sys
input = sys.stdin.readline
mod = 998244353
N = int(input())
XY = [list(map(int, input().split())) for _ in range(N)]
XY.sort(key=itemgetter(1))
for i in range(N):
    XY[i][1] = i
XY.sort(key=itemgetter(0))
bitL = Bit(N)
bitR = Bit(N)
L = []  # 左下
R = [0]*N  # 右下
for _, y in XY:
    L.append(bitL.sum(y))
    bitL.add(y, 1)
for i, (_, y) in zip(range(N-1,-1,-1), XY[::-1]):
    R[i] = bitR.sum(y)
    bitR.add(y, 1)
ans = N * pow(2, N-1, mod) % mod
#print(ans)
for i, (ld, rd) in enumerate(zip(L, R)):
    lu = i - ld
    ru = N - 1 - i - rd
    #print(lu, ld, ru, rd)
    p_lu, p_ld, p_ru, p_rd = pow(2,lu,mod), pow(2,ld,mod), pow(2,ru,mod), pow(2,rd,mod)
    d = p_ru*p_ld*(p_lu-1)*(p_rd-1)\
           + p_lu*p_rd*(p_ru-1)*(p_ld-1)\
           - (p_lu-1)*(p_rd-1)*(p_ru-1)*(p_ld-1)
    #print(d)
    ans = (ans + d) % mod
#print(L)
#print(R)

print(ans)


Measured memory_bytes: 113116
import java.util.*;
import static java.lang.Integer.*;
import static java.lang.Long.*;
//import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		long[] a = new long[n];
		for(i=0;i<n;i++) {
			a[i] = parseLong(sc.next());
		}
		sc.close();
		long cnt=0;
		for(i=0;i<n;i++) {
			while((a[i]&1)==0) {
				cnt++;
				a[i] = a[i] >> 1;
			}
		}
		out.println(cnt);
	}
}

Measured memory_bytes: 30372
use std::io;
use std::collections::HashMap;

fn read_line() -> String {
    let mut line = String::new();

    io::stdin().read_line(&mut line)
        .expect("Failed to read line");
    return line;
}
fn to_i(s: &str) -> i64 {
    return s.trim().parse()
        .expect("Please type a number!");
}
fn read_nums() -> Vec<i64>
{
    let line = read_line();
    let items: Vec<&str> = line.split(' ').collect();

    let mut nums: Vec<i64> = Vec::new();

    for item in items {
        nums.push(to_i(item));
    }
    return nums;
}


fn main() {
    //println!("start");
    let nn = read_nums();
    let n = nn[0];
    let mut aa = Vec::new();

    
    for i in 0..n {
        let line = read_line();
        aa.push(to_i(&line));
    }

    let mut aa2 = aa.clone();
    aa2.sort();
    // println!("aa {:?} {:?}", aa, aa2);

    let  max = aa2[(n-1) as usize];
    let  max2 = aa2[(n-2) as usize];

    // println!("{} {} {}", n, max, max2);

    //print!("{}", ret);
    for i in 0..n {
        let a = aa[i as usize];
        if a==max {
            println!("{}", max2);
        }else {
            println!("{}", max);
        }
    }
    
}   

Measured memory_bytes: 9724