akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
#define mp make_pair
#define MAX 20000
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef vector<long long> vll;
typedef vector<ii> vii;
#define EPS 1e-9
#define LSOne(S) (S & (-S))
#define INF INT_MAX
const int N = 3010;
int table[N][N];
int main(void)
{
    char s[N],t[N];
    scanf("%s %s",&s,&t);
    int n = (int)strlen(s), m = (int)strlen(t);
    for(int i = 0; i <= n; ++i)
    {
        for(int j = 0; j <= m; ++j)
        {
            if(i == 0 || j == 0)
                table[i][j] = 0;
            else if(s[i-1] == t[j-1])
                table[i][j] = table[i-1][j-1]+1;
            else
                table[i][j] = max(table[i-1][j],table[i][j-1]);
        }
    }
    int index = table[n][m];
    char lcs[index+1];
    lcs[index] = '\0';
    int i = n, j = m;
    while(i>0 && j > 0)
    {
        if(s[i-1]==t[j-1])
        {
            lcs[index-1] = s[i-1];
            i--; j--; index--;
        }
        else if(table[i-1][j] > table[i][j-1])
            i--;
        else
            j--;
    }
    printf("%s",lcs);
}


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

using namespace std;

typedef long long int llint;

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

//#define DEBUG

#ifdef DEBUG
#define dump(i) cout << "[*] " #i ": " << i << endl
#define line cout << "[*] --------- [*]" << endl
#else
#define dump(i)
#define line
#endif

int a, b, c, d;

inline void input() {
	cin >> a >> b >> c >> d;
}

inline void solve() {
	cout << max(min(b, d) - max(a, c), 0) << endl;
}

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


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

const int N = 8010;
const int M = 210;
const int mod = 998244353;

typedef long long LL;

inline int Pow(int x, int y) {
    int res = 1;
    for (; y; y >>= 1, x = (LL)x * x % mod) if (y & 1) res = (LL)res * x % mod;
    return res;
}

int frac[N], inv[N];

inline int C(int n, int r) {
    return (LL)frac[n] * inv[r] % mod * inv[n - r] % mod;
}

int dp[M][N];

int r[N << 2], A[N << 2], B[N << 2];

inline void NTT(int a[], int len, int type) {
    for (int i = 1; i < len; i++) if (i < r[i]) swap(a[i], a[r[i]]);
    for (int mid = 2; mid <= len; mid <<= 1) {
        int Wn = Pow(3, type ? (mod - 1) / mid : mod - 1 - (mod - 1) / mid);
        for (int i = 0; i < len; i += mid)
            for (int j = i, w = 1, t; j < i + (mid >> 1); j++, w = (LL)w * Wn % mod)
                t = (LL)a[j + (mid >> 1)] * w % mod, a[j + (mid >> 1)] = (a[j] - t + mod) % mod, a[j] = (a[j] + t) % mod;
    }
    if (!type) for (int i = 0, inv = Pow(len, mod - 2); i < len; i++)
        a[i] = (LL)a[i] * inv % mod;
}

int main() {
    int n, m; cin >> n >> m;
    frac[0] = inv[0] = 1;
    for (int i = 1; i <= n + 2; i++) 
        frac[i] = (LL)frac[i - 1] * i % mod, inv[i] = Pow(frac[i], mod - 2);
    int len = 1, l = 0;
    while (len <= n * 2) len <<= 1, l++;
    for (int i = 1; i < len; i++) r[i] = (r[i >> 1] >> 1) | ((i & 1) << l - 1);
    dp[0][0] = 1;
    for (int i = 1; i <= n; i++) B[i] = inv[i + 2];
    NTT(B, len, 1);
    for (int i = 1; i <= m; i++) {
        for (int j = 0; j < len; j++) A[j] = 0;
        for (int j = 0; j <= n; j++) A[j] = (LL)dp[i - 1][j] * inv[j] % mod;
        NTT(A, len, 1);
        for (int j = 0; j < len; j++) A[j] = (LL)A[j] * B[j] % mod;
        NTT(A, len, 0);
        for (int j = 0; j <= n; j++) 
            dp[i][j] = ((LL)frac[j + 2] * A[j] + (LL)dp[i - 1][j] * (1 + C(j + 1, 2))) % mod;
    }
    int res = 0;
    for (int i = 0; i <= n; i++) res = (res + (LL)dp[m][i] * C(n, i)) % mod;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 6784
#include <iostream>
#include <algorithm>

using namespace std;

const long long mod = 1e9 + 7;
const int inf = 1e5 + 9, maxn = 2e2 + 9;
long long dp[maxn][inf], s[inf];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, x;
    cin >> n >> x;
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    sort(s, s + n);
    for (int i = 0; i < inf; i++) {
        dp[0][i] = i % s[0];
    }
    for (int i = 1; i < n; i++) {
        for (int j = 0; j <= x; j++) {
            dp[i][j] += dp[i - 1][j % s[i]] * 1LL + dp[i - 1][j] * i * 1LL;
            dp[i][j] %= mod * 1LL;
        }
    }
    cout << dp[n - 1][x] << '\n';
    return 0;
}


Measured memory_bytes: 157184
n = int(input())
B = [0]+list(map(int,input().split()))
cases = 0
limits = 0
Ans = []
flag = True
while cases <= 101:
    for b,i in zip(B[:0:-1],range(len(B)-1,0,-1)):    
           if B[i] == i:
               Ans = [b]+Ans
               B.pop(i)
               break
    cases += 1
    if cases >= 100 and len(B) >= 2:
        flag = False

if flag:
    print(*Ans,sep="\n")
else:
    print(-1)

Measured memory_bytes: 3064
package main

import "fmt"

func main() {
	// Code for D - I hate Factorization
	var X int
	fmt.Scan(&X)

	for A := -1000; A <= 1000; A++ {
		for B := -1000; B <= 1000; B++ {
			if (A*A*A*A*A)-(B*B*B*B*B) == X {
				fmt.Println(A, B)
				return
			}
		}
	}
}


Measured memory_bytes: 1764
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ldb = long double;
using pa = pair < ll, ll >;
using vec = vector < ll >;
#define pb push_back
#define F  first
#define S  second
#define f(i,x,n) for(ll i=x;i<n;i++) 
#define all(c) c.begin(),c.end()
#define edl "\n"
#define str string
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
const int MOD = 1e9 + 7, N = 1e5 + 10;
const ll LINF = LLONG_MAX;
int main() {
    fast();
    // #ifndef ONLINE_JUDGE
    //   freopen("input.txt", "r", stdin);
    //   freopen("output.txt","w",stdout);
    // #endif
    ll n,k;
    cin >> n;
    vector<pa> q(n);
    f(i,0,n){
        cin >> q[i].F;
        q[i].S=i+1;
    }
    sort(all(q));
    f(i,0,n){
        cout<<q[i].S<<" ";
    }
    

    cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
    return 0;
}
 

Measured memory_bytes: 2432
#$from collections 
import bisect,sys

s_ = input()
t = input()

char_s = set(s_)
char_t = set(t)


if not char_s >= char_t:
    print(-1)
    sys.exit()

s = s_+s_

chr_s = {}

l = len(s_)

for i in range(2*l):
    if s[i] in chr_s:
        chr_s[s[i]].append(i)
    else:
        chr_s[s[i]] = [i]
#print(chr_s)
loops = 0
tmp = -1##?

for i in range(len(t)):
    j = bisect.bisect_right(chr_s[t[i]],tmp)###leftと違うの？
    tmp = chr_s[t[i]][j]
    #print(tmp)
    if tmp>=l:
        loops+=l
        tmp-=l
#print(chr_s)
print(loops+tmp+1)#0-indexで+1


Measured memory_bytes: 53232
#include <iostream>
#include <algorithm>

using namespace std;

int main(void)
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, X, Y;
  cin >> N >> X >> Y;
  int distance[N] = {0};
  for (int i = 1; i <= N; i++)
    for (int j = i + 1; j <= N; j++)
      distance[min(abs(j - i), abs(X - i) + 1 + abs(Y - j))]++;
  for (int i = 1; i < N; i++)
    cout << distance[i] << '\n';
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#if __has_include(<local.h>)
#include <local.h>
#endif
using namespace std;

typedef long long int LL;
typedef long long int LLint;

//Faster Program
#define endl "\n"

//Faster Coding
#define ED return
#define GET(a) int a;cin >> a
#define DGET(a) double a;cin >> a
#define SGET(a) string a;cin >> a
#define CGET(a) char a;cin >> a
#define PRINT(a) cout << a << "\n"
#define ANS(a,b) int a;cin >> a;cout << b << "\n"
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define SORT(vec) sort(vec.begin(),vec.end())
#define REV(vec) reverse(vec.begin(),vec.end())
#define ALL(x) (x).begin(),(x).end()

//As Function
#define UP(a,b) ((a+(b-1))/b)
#define IPOW(x,y) LL(pow(x,y))

//Debug
#ifdef LOCAL_H
#define TEST cout << "OK\n"
#define LOG(a) cout << a << "\n"
#else
#define TEST
#define LOG(a)
#endif

#ifdef LOCAL_H
[[maybe_unused]]
#endif
const double PI = M_PI;
#ifdef LOCAL_H
[[maybe_unused]]
#endif
const long long INF = int(999999999);
#ifdef LOCAL_H
[[maybe_unused]]
#endif
const long long MOD = int(1000000007);

//Settings
#ifdef LOCAL_H
const bool DO_BENCHMARK = true;
#endif
const int DOUBLE_ACCURACY = 15;

#ifndef LOCAL_H
    const bool DO_BENCHMARK = false;
#endif
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(DOUBLE_ACCURACY);
    void solve();
    if(DO_BENCHMARK){
        clock_t clock_start = clock();
        solve();
        clock_t clock_end = clock();
        const double time = static_cast<double>(clock_end-clock_start)/CLOCKS_PER_SEC*1000.0;
        cout << "\n" << time << "[ms]\n";
    }
    else solve();
}

void solve(){
    vector<int> vec (3);
    cin >> vec[0] >> vec[1] >> vec[2];
    SORT(vec);
    REP(i,3)LOG(vec[i]);
    if(vec[0] == 5 && vec[1] == 5 && vec[2] == 7){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
using namespace std;
typedef long long LL;
LL bigger(LL H, LL W) {
	if (H*W % 2 == 0) return H*W / 2;
	return (H*W + min(H, W)) / 2;
}
LL smaller(LL H, LL W) {
	if (H*W % 2 == 0) return H*W / 2;
	return (H*W - min(H, W)) / 2;
}
int main()
{
	LL H, W;
	cin >> H >> W;
	if (H*W % 3 == 0) {
		cout << 0 << endl;
		return 0;
	}
	LL ans = 1LL << 60;
	ans = min(ans, bigger(H, W - W / 3) - H*(W / 3));
	ans = min(ans, H*(W / 3 + 1) - smaller(H, W - (W / 3 + 1)));
	ans = min(ans, bigger(H - H / 3, W) - (H / 3)*W);
	ans = min(ans, (H / 3 + 1)*W - smaller(H - (H / 3 + 1), W));
	cout << ans << endl;
}

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

int main() {
  int N, D, X;
  cin >> N >> D >> X;
  
  vector<int> num(N);
  
  for (int i = 0; i < N; i++) cin >> num.at(i);
  
  int answer = 0;
  for (int i = 0; i < N; i++){
    int count = 0;
    for (int j = 0; j*num.at(i)+1 <= D;j++) count = j+1;
    answer += count;
 }
  answer += X;
  cout << answer << endl;
} 

Measured memory_bytes: 256
//check violation of constraints

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Comparator;
import java.util.NoSuchElementException;

public class Main {

	void run(int N, int T, long[] A, long[] B) {
		long[][] x = new long[N][2];
		for (int i = 0; i < N; ++i) {
			x[i][0] = A[i];
			x[i][1] = B[i];
		}
		Arrays.sort(x, new Comparator<long[]>() {
			@Override
			public int compare(long[] o1, long[] o2) {
				return Long.compare(o1[0], o2[0]);
			}
		});
		for (int i = 0; i < N; ++i) {
			A[i] = x[i][0];
			B[i] = x[i][1];
		}

		long[] dp = new long[T + 1];
		for (int i = 0; i < N; ++i) {
			for (int t = T - 1; t >= 0; --t) {
				int nt = Math.min(T, t + (int) A[i]);
				dp[nt] = Math.max(dp[nt], dp[t] + B[i]);
			}
		}
		long ans = 0;
		for (long v : dp)
			ans = Math.max(ans, v);
		System.out.println(ans);
	}

	public static void main(String[] args) throws FileNotFoundException {
		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		int T = sc.nextInt();
		long[] A = new long[N];
		long[] B = new long[N];
		for (int i = 0; i < N; ++i) {
			A[i] = sc.nextLong();
			B[i] = sc.nextLong();
		}
		new Main().run(N, T, A, B);
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

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

Measured memory_bytes: 22740
inf = 10 ** 9
nmax = 40
abmax = 10

n,ma,mb = gets.split.map(&:to_i)
a = Array.new(nmax)
b = Array.new(nmax)
c = Array.new(nmax)

dp = Array.new(nmax+1) { Array.new(nmax*abmax+1)  { Array.new(nmax*abmax+1) {inf} } }

n.times do |i|
  ai,bi,ci = gets.split.map(&:to_i)
  a[i] = ai
  b[i] = bi
  c[i] = ci
end

dp[0][0][0] = 0

0.upto(n-1) do |i|
  0.upto(nmax*abmax) do |ca|
    0.upto(nmax*abmax) do |cb|
      next if dp[i][ca][cb] == inf
      dp[i+1][ca][cb] = [ dp[i+1][ca][cb],dp[i][ca][cb] ].min
	  dp[i+1][ca+a[i]][cb+b[i]] = [ dp[i+1][ca+a[i]][cb+b[i]],dp[i][ca][cb]+c[i] ].min
    end
  end
end

ans = inf

1.upto(nmax*abmax) do |ca|
  1.upto(nmax*abmax) do |cb|
    ans = [ans, dp[n][ca][cb]].min if ca*mb == cb*ma
  end
end

puts ans == inf ? -1 : ans

Measured memory_bytes: 54780
n,m=map(int,input().split())
s=list(map(int,input().split()))
t=list(map(int,input().split()))
dp=[[0]*m for _ in range(n)]
sum=[[0]*m for _ in range(n)]
mod=10**9+7
ans=0
for i in range(n):
  if s[i]==t[0]:
    dp[i][0]=1
  else:
    dp[i][0]=0
  ans+=dp[i][0]  
  sum[i][0]=sum[i-1][0]+dp[i][0]
for i in range(m):
  if t[i]==s[0]:
    dp[0][i]=1
  else:
    dp[0][i]=0
  ans+=dp[0][i]
  sum[0][i]=sum[0][i-1]+dp[0][i]
for i in range(1,n):
  for j in range(1,m):
    if s[i]==t[j]:
      dp[i][j]=(sum[i-1][j-1]+1)%mod
    else:
      dp[i][j]=0
    sum[i][j]=(sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1]+dp[i][j])%mod
    ans+=dp[i][j]
    ans%=mod
print((ans-dp[0][0]+1)%mod)

Measured memory_bytes: 105180
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define mp make_pair
#define fs first
#define se second
#define pi 2*acos(0)
#define PI 3.14159265358979323846264338

typedef long long ll;
typedef unsigned long long ull;
typedef pair < int , int > pii;
typedef pair < ll , ll > pll;

const int N = 100010;
const int MX = 123456;
const int mod = (int)1e9 + 7;
const int base = 97;
const ull BS1 = 10000019ULL;
const int INF = (1 << 29);

template < class T > inline void fastScan(T &x){
    register char c = getchar();
    int neg = 0; x = 0;
    for(   ; (c < 48 || c > 57) && (c != '-'); c = getchar());
    if(c == '-') { neg = 1; c = getchar(); }
    for(   ; c > 47 && c < 58; c = getchar()){
        x = (x << 1) + (x << 3) + c - 48;
    }
    if(neg) x = -x;
}

// OrderedSet
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// template < typename T > using ordered_set = tree < T, null_type, greater < T >, rb_tree_tag, tree_order_statistics_node_update >;

//typedef uint64_t hash_t;
//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
//const int HASH_COUNT = 2;
//const hash_t HASH_P = (uint32_t)-13337;
//uniform_int_distribution<hash_t> MULT_DIST(0.25 * HASH_P, 0.75 * HASH_P);
//const hash_t HASH_MULT[HASH_COUNT] = {MULT_DIST(rng), MULT_DIST(rng)};

int n;

ll inp[N];
ll dp[105];

ll f(ll hand, ll x, ll y){
  ll how = hand / x;
  return (hand % x) + how * y;
}

ll Solve(){
  dp[1] = 1000;
  for(int i = 2; i <= n; i++){
    dp[i] = dp[i - 1];
    for(int j = 1; j < i; j++){
      if(inp[j] < inp[i]){
        dp[i] = max(dp[i], f(dp[j], inp[j], inp[i]));
      }
    }
  }
  return dp[n];
}

int main(){
  fastScan(n);
  for(int i = 1; i <= n; i++){
    fastScan(inp[i]);
  }
  printf("%lld\n", Solve());
}


Measured memory_bytes: 3732
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace ConsoleApp11
{
    class Class76
    {
        static void Main()
        {
            ulong[] abcd = Console.ReadLine().Split().Select(ulong.Parse).ToArray();
            ulong count = abcd[1] - abcd[0] + 1;

            ulong divC = (abcd[1] / abcd[2]) - (abcd[0]-1) / abcd[2];
            ulong divD = (abcd[1] / abcd[3]) - (abcd[0]-1) / abcd[3];
            ulong divCD = abcd[1] / LCM(abcd[2],abcd[3]) - (abcd[0]-1) / LCM(abcd[2],abcd[3]);
            Console.WriteLine(count - divC - divD + divCD);
        }
        static ulong GCD(ulong a,ulong b)
        {
            return b == 0 ? a : GCD(b, a % b);
        }
        static ulong LCM(ulong a,ulong b)
        {
            return a*b / GCD(a, b);
        }
    }
}


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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

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

    unordered_set<string> s;
    for (auto i : irange(0L, n)) {
        string ss;
        cin >> ss;
        s.insert(ss);
    }

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

Measured memory_bytes: 17732
h,w = map(int,input().split())

if  w == 1 or h == 1:
    print("1")
elif h % 2 == 0:
    print(h//2 * w)
elif w % 2 == 0:
    print(int((h/2 * w)))
else:
    print((w*h)//2 + 1)

Measured memory_bytes: 2940
from operator import mul
from functools import reduce

N, K = map(int, input().split())
MOD = 10 ** 9 + 7


def comb(N, R):
    R = min(N-R, R)
    if R == 0: return 1
    over = reduce(mul, range(N, N - R, -1))
    under = reduce(mul, range(1,R + 1))
    return over // under % MOD


def f2(N, K):
    return comb(N+K-1, K-1)

def f(N, K):
    if (N < K): return 0
    if N == 0 and K == 0: return 1
    if (K < 1): return 0
    return f2(N-K, K)


for i in range(1,K+1):
    blue = f(K, i)
    red = 0
    red += f(N-K, i-1)
    red += f(N-K, i) * 2 % MOD
    red += f(N-K, i+1) % MOD
    
    print(red * blue % MOD)

Measured memory_bytes: 3944
#include <bits/stdc++.h>
using namespace std;
#define ri register int
typedef long long ll;
#define rll register ll 
namespace io {
	const int SIZE = (1 << 21) + 1;
	char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c, qu[55]; int f, qr;
	// getchar
	#define gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	// print the remaining part
	inline void flush () {
		fwrite (obuf, 1, oS - obuf, stdout);
		oS = obuf;
	}
	// putchar
	inline void putc (char x) {
		*oS ++ = x;
		if (oS == oT) flush ();
	}
	// input a signed integer
	template <class I>
	inline void gi (I &x) {
		for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c <= '9' && c >= '0'; c = gc()) x = (x << 1) + (x << 3) + (c & 15); x *= f;
	}
	// input a letter
	template <class I>
	inline void get (I &x) {
		for (c = gc(); c < 'A' || c > 'Z'; c = gc()) ;
		x = c;
	}
	// input a string
	inline void read (char *s){
		for(c = gc(); c < 'A' || c > 'Z'; c = gc()) ;
		for(; c >= 'A' && c <= 'Z'; c = gc()) *++s = c;
		*++s = '\0';
	}
	// print a signed integer
	template <class I>
	inline void print (I x) {
		if (!x) putc ('0'); if (x < 0) putc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10;
		while (qr) putc (qu[qr --]);
	}
	//no need to call flush at the end manually!
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
}
using io :: gi;
using io :: get;
using io :: read;
using io :: putc;
using io :: print;
const int N=1e5+5;
int tot,head[N],nxt[N<<1],adj[N<<1],col[N],cnt[3],res,flag,size;
inline void addedge(ri x,ri y){
	nxt[++tot]=head[x];
	adj[head[x]=tot]=y;
}
inline void dfs(ri x){
	++size;
	++cnt[col[x]];
	for(ri y,i=head[x];i;i=nxt[i])
		if(i&1){
			++res;
			if(col[y=adj[i]]==-1)
				col[y]=(col[x]+1)%3,
				dfs(y);
			else if(col[y]!=(col[x]+1)%3)
				flag=0;
		}
		else{
			if(col[y=adj[i]]==-1)
				col[y]=(col[x]+2)%3, // -1 + 3 
				dfs(y);
			else if(col[y]!=(col[x]+2)%3)
				flag=0;
		}
}
int main(){
	ri n,m,x,y,i;
	rll ans;
	gi(n);gi(m);
	while(m--) gi(x),gi(y),addedge(x,y),addedge(y,x);
	for(i=1;i<=n;++i) col[i]=-1;
	ans=0;
	for(i=1;i<=n;++i)
		if(col[i]==-1){
			memset(cnt,0,sizeof(cnt));
			col[i]=0;
			res=0;
			flag=1;
			size=0;
			dfs(i);
			if(flag)
				if(cnt[1]&&cnt[2])
					ans+=(ll)cnt[0]*cnt[1]+(ll)cnt[1]*cnt[2]+(ll)cnt[2]*cnt[0];
				else
					ans+=res;
			else
				ans+=(ll)size*size;
		}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 9472
#include <iostream>

using namespace std;

long long gcd(long long a, long long b) {
    return b == 0 ? a : gcd(b, a % b);
}

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

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n, m; cin >> n >> m;
    int a[n]; for (int i = 0; i < n; i++) {
        cin >> a[i];
        a[i] /= 2;
    }
    long long res = 1;
    for (int i = 0; i < n; i++) res = lcm(res, a[i]);
    bool good = 1;
    for (int i = 0; i < n && good; i++) {
        if (res / a[i] % 2 == 0) good = 0;
    }
    int ans = m / res;
    ans = (ans + 1) / 2;
    if (!good) ans = 0;
    cout << ans;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using P = pair<int,int>;
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;}
const ll INF = 1LL<<60;
#define M_PI 3.14159265358979



int main()
{
    double a,b,h,m;
    cin >> a >> b >> h >> m;

    double bang = (m/60.0)*360.0;
    double aang = (h*60.0+m)*0.5;
    double ang = 0.0;
    if(fabs(bang - aang) > 180) ang = 360.0 - fabs(bang - aang);
    else ang = fabs(bang - aang);

    double ans = sqrt(a*a + b*b - 2.0*a*b*cos((ang)/360.0 * 2.0*M_PI));

   cout << fixed << setprecision(11) <<  ans << endl;

    return 0;
}
//Ctrl+Shift+Bでコンパイルと実行を行ってデバッグすること

Measured memory_bytes: 4224
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main(void){
    double x1, x2, y1, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    cout << fixed << setprecision(5);
    cout << sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)) << endl;
}


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

int dp[10001];
int N,W;
int main() {
    scanf("%d%d",&N,&W);

    for(int i = 0;i < N;i++) {
        int v,w;
        scanf("%d%d",&v,&w);
        for(int j = W;j >= w;j--) {
            dp[j] = max(dp[j],dp[j - w] + v);
        }
    }
    printf("%d\n",dp[W]);
    return 0;
}


Measured memory_bytes: 2792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<ll>>;
using P = pair<int,int>;
#define MOD 1000000007
#define INF 1000000
#define MAX_N 100010



int main()
{
  int N;cin>>N;
  vector<int> a(N+1);
  vector<int> b(N+1);
  vector<int> c(N+1);
  
  for (int i=1;i<=N;i++)
    cin>>a[i]>>b[i]>>c[i]; 
  
  vector<vector<int>> dp(N+1,vector<int>(3));
  //dp[i][j]=i日まででj=0,1,2はa,b,cを選ぶ
  
  dp[0][0]=0;
  dp[0][1]=0;
  dp[0][2]=0;
  
  for (int i=1;i<=N;i++)
  {
    dp[i][0]=max(dp[i-1][1]+a[i],dp[i-1][2]+a[i]);
    dp[i][1]=max(dp[i-1][0]+b[i],dp[i-1][2]+b[i]);
    dp[i][2]=max(dp[i-1][0]+c[i],dp[i-1][1]+c[i]);
  }
  
  cout<<max(dp[N][0],max(dp[N][1],dp[N][2]))<<endl;
  
}

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

int main() {
  string text="aiueo";
  char c,d;

  cin >> c;

  for(int i=0;i<5;i++){
      d=text.at(i);
      if(c==d){
          cout << "vowel" << endl;
        break;
      }
      else if(i==4){
          cout << "consonant" << endl;
      }
    }
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define ll long long
#define mx 100002
#define int long long
#define endl "\n"
#define IO ios :: sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define fi first
#define se second
#define fr(i,a,b) for(int i=a;i<=b;i++  )
#define pii pair<int,int>
using namespace std;
int f(int x)
{
    if(x==-1)return 0;
    if(x%4==0)return x;
    if(x%4==1)return 1;
    if(x%4==2)return x+1;
    return 0;
}
signed main()
{
    IO;
    int a,b;
    cin>>a>>b;
    int ans=f(b)^f(a-1);
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (ll i=0;i<N;i++)
#define loop(i,N,M) for(ll i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)

ll debugFlag = false;
template<typename T> void debug(T&);
template<typename T> void debug(T&, bool);
template<typename T> void debug(vector<T>&);
template<typename T> void debug(vector<T>&, bool);
template<typename T, typename U> void debug(pair<T, U>&);
template<typename T, typename U> void debug(pair<T, U>&, bool);

template<typename T>
void debug(T& obj) {
	debug(obj, true);
}

template<typename T>
void debug(T& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << obj;
	if (lnFlag) cout << endl;
}

template<typename T>
void debug(vector<T>& obj) {
	debug(obj, true);
}

template<typename T>
void debug(vector<T>& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << "[";
	rep(i, obj.size()) {
		if (i != 0) cout << ",";
		debug(obj[i], false);
	}
	cout << "]";
	if (lnFlag) cout << endl;
}

template<typename T, typename U>
void debug(pair<T, U>& obj) {
	debug(obj, true);
}

template<typename T, typename U>
void debug(pair<T, U>& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << "(";
	debug(obj.first, false);
	cout << ",";
	debug(obj.second, false);
	cout << ")";
	if (lnFlag) cout << endl;
}

ll N;

void solve() {
	cin >> N;
	vector<int> vecA(N+1);
	vector<int> vecB(N);

	rep(i, N + 1) cin >> vecA[i];
	rep(i, N) cin >> vecB[i];

	ll ans = 0;

	rep(i, N) {
		ll tmp = min(vecA[i], vecB[i]);
		vecA[i] -= tmp;
		vecB[i] -= tmp;
		ans += tmp;

		tmp = min(vecA[i + 1], vecB[i]);
		vecA[i + 1] -= tmp;
		vecB[i] -= tmp;
		ans += tmp;

	}

	cout << ans;

}

int main(int argc, char* argv[]) {
	if (argc == 2 && string(argv[1]) == "debug") debugFlag = true;
	solve();
	cout << endl;
	return 0;
}


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

using Z = long long;
Z tmod(Z a, Z b) {
  if (b < 0) return -tmod(-a, -b);
  return (a %= b) < 0 ? a + b : a;
}
Z tdiv(Z a, Z b) { return (a - tmod(a, b)) / b; }

constexpr long long inf = 0x3f3f3f3fLL << 32;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  long long n, k;
  cin >> n >> k;
  --k;
  vector<long long> a(n);
  for (auto&& e : a) {
    cin >> e;
  }
  sort(begin(a), end(a));
  auto cnt = [&](long long x) -> long long {
    long long res = 0;
    for (auto e : a) {
      if (e > 0) {
        res += upper_bound(begin(a), end(a), tdiv(x, e)) - begin(a);
      } else if (e < 0) {
        res += end(a) - lower_bound(begin(a), end(a), tdiv(-x + -e - 1, -e));
      } else {
        if (x >= 0) {
          res += n;
        }
      }
    }
    for (auto e : a) {
      res -= e * e <= x;
    }
    res /= 2;
    return res;
  };
  long long ng = -inf, ok = inf;
  while (ok - ng > 1) {
    long long mid = (ng + ok) / 2;
    (cnt(mid) > k ? ok : ng) = mid;
  }
  cout << ok << '\n';
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define maxn 100050
#define inf 0x3f3f3f3f
#define LL long long
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define mm(a,b) memset(a,b,sizeof(a))
#define mp(a,b) make_pair(a,b)
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
const double eps = 1e-6;
const LL mod=1e9+7;
const LL INF=(LL)1e18;
using namespace std;
LL gcd(LL a,LL b){return b==0?a:gcd(b,a%b);}
LL qpow(LL x,LL y){LL re=1,base=x%mod;while(y){if(y&1)re=(re*base)%mod;base=(base*base)%mod;y>>=1;}return re;}
int vis[maxn],dis1[maxn],dis2[maxn];
struct node{
	int to,w;
	node(int to,int w):to(to),w(w){}
};
vector<node>e[maxn];
void dfs(int id,int dis[]){
	for(int i=0;i<e[id].size();i++){
		int next=e[id][i].to,ww=e[id][i].w;
		if(vis[next]) continue;
		dis[next]=dis[id]+ww;
		vis[next]=1;
		dfs(next,dis);
	}
} 
int main(){
//	freopen("input.txt","r",stdin);
//	freopen("ouput.txt","w",sdout);
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	mm(vis,0),mm(dis1,0),mm(dis2,0);
	int n;
	cin>>n;
	for(int i=1;i<n;i++){
		int x,y;
		cin>>x>>y;
		e[x].pb(node(y,1));
		e[y].pb(node(x,1));
	}
	vis[1]=1;
	dfs(1,dis1);
	mm(vis,0),vis[n]=1;
	dfs(n,dis2);
	int ans=0;
	for(int i=2;i<n;i++){
		if(dis1[i]<=dis2[i]) ans++;
		else ans--;
	}
	if(ans>0) cout<<"Fennec"<<endl;
	else cout<<"Snuke"<<endl;
	return 0;
}

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

int main() {
  int n; cin >> n;
  int sum = 0, mx = 0;
  for (int i = 0; i < n; i++) {
    int l; cin >> l;
    sum += l;
    mx = max(mx, l);
  }
  cout << (sum - mx > mx ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
a,b,k = map(int, input().split())

if min(a,k) == a:
    taka = 0
    if min(b, k-a) == b:
        aoki = 0
        print(taka, aoki)
    else:
        aoki = b - (k-a)
        print(taka, aoki)
else:
    taka = a - k
    aoki = b
    print(taka, aoki)

Measured memory_bytes: 3060
N,x=(int(i) for i in input().split())
lst=[int(i) for i in input().split()]
lst.sort()
ans=0
for i in range(N):
  if x==0:
    break
  if lst[i]<=x:
    x-=lst[i]
    ans+=1
  if lst[i]>x:
    break
  if ans==N-1:
    if lst[N-1]==x:
      x=0
      ans+=1
    else:
      break
print(ans)

Measured memory_bytes: 3064
<?php
// Your code here!
for ($i = 0; $i < 5; $i++) {
    $input[] = trim(fgets(STDIN));
}
$q = trim(fgets(STDIN));
$bool = false;
$n = 1;
for ($i = 0; $i < 4; $i++) {
    for ($j = $n; $j < 5; $j++) {
        $dis = $input[$j] - $input[$i];
        if ($dis > $q) {
            $bool = true;
        }
    }
    $n++;
}

if ($bool) echo ":(";
    else echo "Yay!";
?>


Measured memory_bytes: 3828
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace B_Resale
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] str1 = Console.ReadLine().Split(' ');
            string[] str2 = Console.ReadLine().Split(' ');
            int[] V = new int[N];
            int[] C = new int[N];
            for(int i = 0; i < N; i++)
            {
                V[i] = int.Parse(str1[i]);
                C[i] = int.Parse(str2[i]);
            }
            int score = 0;
            for(int i = 0; i < N; i++)
            {
                if (V[i] > C[i])
                {
                    score += V[i] - C[i];
                }
            }
            Console.Write(score);
        }
    }
}


Measured memory_bytes: 11220
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
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, W; cin >> N >> W;
    vector<int> w(N), v(N);
    for (int i = 0; i < N; i++) cin >> w[i] >> v[i];

    vector<vector<long long>> dp(N + 1, vector<long long>(W * 2, 0));
    for (int i = 0; i < N; i++) for (int sum_w = 0; sum_w <= W; sum_w++) {
        chmax(dp[i + 1][sum_w], dp[i][sum_w]);
        if (sum_w - w[i] >= 0) chmax(dp[i + 1][sum_w], dp[i][sum_w - w[i]] + v[i]);
    }
    cout << dp[N][W] << endl;
    return 0;
}

Measured memory_bytes: 159744
#include<stdio.h>
int main()
{

	int n = 0, i, j, k;
	char ans[100005] = { 0 };
	// スペース区切りの整数の入力
	scanf("%d", &n);
	char s[100005];
	scanf("%s", s);
	for (j = 0; j < 4; j++)
	{

		switch (j) {
		case 0:
			ans[0] = 'S';
			ans[1] = 'S';
			break;
		case 1:
			ans[0] = 'S';
			ans[1] = 'W';
			break;
		case 2:
			ans[0] = 'W';
			ans[1] = 'S';
			break;
		case 3:
			ans[0] = 'W';
			ans[1] = 'W';
			break;

		}
		for (i = 0; i < n; i++)
		{
			if (ans[i+1] == 'S')
			{
				if (s[(i+1)%n] == 'o')
				{
					ans[i+2] = ans[i+0];
				}
				else
				{
					if (ans[i+0] == 'S')
					{
						ans[i+2] = 'W';
					}
					else
					{
						ans[i+2] = 'S';
					}
				}
			}
			else
			{
				if (s[(i+1)%n] == 'x')
				{
					ans[i+2] = ans[i+0];
				}
				else
				{
					if (ans[i+0] == 'S')
					{
						ans[i+2] = 'W';
					}
					else
					{
						ans[i+2] = 'S';
					}
				}

			}
			/*
			if (ans[i] == 'S'&&s[i + 1] == 'o')
			{

			}
			if (s[i + 1] == 'o')
			{

			}
			*/
		}
		if ((ans[0] == ans[n])&&(ans[1]==ans[n+1]))
		{
			for (i = 0; i < n; i++)
			{
				printf("%c", ans[i]);
			}
			return 0;
		}
		if (j == 3)
		{
			printf("-1");
			return 0;
		}
		//printf("%s\n", ans);
	}

	// 出力
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
const int maxn = 4e5 + 7;
const double pi = acos(-1);

int main(){
	ll n,a,b;
	cin >> n >> a >> b;
	ll sum = a + b;
	ll k = n / sum;
	ll ans = k * a;
	ll x = n % sum;
	if(x > a) ans += a;
	else ans += x;
	cout << ans << endl; 
	return 0;
}

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


using namespace std;







int main(){
	int h,w;
	int ret[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

	cin >> h;

	cout << ret[h-1] << endl;
	return 0;

	
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
#define rep(a,n,b) for(int i=a;i<n;i+=b)
#define rrep(a,n,b) for(ll i=n;i>=a;i-=b)
#define iter(obj) for(auto x : obj) 
#define pb(i) push_back(i)
#define ff first
#define ss second
#define pchr(flag) cout<<(flag ? "YES" : "NO")
#define ot(x) cout<<x
#define nl cout<<endl;
#define sc cout<<" "
#define ll long long int
#define input freopen("input.txt","r",stdin)
#define op freopen("output.txt","w",stdout);
#define fastio std::ios::sync_with_stdio(false)
using namespace std;
const int N = 2e5+7;
const int MOD  = 1000000007;
const float PI = 3.1415926535;
//33333333333;
int prime[N];
void SieveOfEratosthenes(int n) 
{ 
     for (int p=2; p*p<=n; p++) {
        if (prime[p] == 0)  {
            for (int i=p*p; i<=n; i += p) 
                prime[i] = 1; 
        } 
    } 
} 
int main() 
{ 
	fastio;
	int h,a;
	cin>>h>>a;
	if(h%a) cout<<(h/a)+1;
	else cout<<h/a;
}


Measured memory_bytes: 256
import math
A, B = map(int,input().split())

# aとbの最大公約数
def gcd(a,b):
    if b == 0:
        return a
    return gcd(b,a%b)

# aとbの最小公倍数
# a*b = lcm(a,b)*gcd(a,b) より
def lcm(a,b):
    return a*b//gcd(a,b)

print(lcm(A,B))


Measured memory_bytes: 38448
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] a = new int[N];
        int sum = 0;
        for(int i = 0; i<N; i++) {
            a[i] = sc.nextInt();
            sum += a[i];
        }
        if(sum%10 != 0) {
            System.out.println(sum);
            return;
        }
        Arrays.sort(a);
        int sumc = sum;
        for(int i = 0; i<N; i++) {
            if(a[i] %10==0) continue;
            sumc = sum-a[i];
            if(sumc%10 !=0) break;
        }
        if(sumc == sum) {
            System.out.println(0);
            return;
        }
        System.out.println(sumc);
    }
}

Measured memory_bytes: 21844
using System;
using System.Linq;
using System.Collections.Generic;

class Program {

    const int MAX = 101;
    const int wht = 0;
    const int gry = 1;
    const int blk = 2;
    static int[] d = new int[MAX];
    static int[] stt = new int[MAX];
    static int[] nm = new int[MAX];

    static List<List<int>> g = new List<List<int>>();

    static void Main(string[] args) {

        int ln = int.Parse(Console.ReadLine());
        for (int i = 0; i < MAX; i++) {
            g.Add(new List<int>());
            d[i] = 999;
        }

        for (int i = 0; i < ln; i++) {
            int[] ip = Console.ReadLine().Split(' ').Select(z => int.Parse(z)).ToArray();
            nm[ip[0]] = 1;

            for (int j = 2; j < ip.Length; j++) {
                g[ip[0]].Add(ip[j]);
            }
        }

        bfs(1);

        for (int i = 0; i < MAX; i++) {
            if (nm[i] > 0) {
                Console.WriteLine(i.ToString() + " " + (d[i] == 999 ? -1 : d[i]).ToString());
            }
        }

    }


    static void bfs(int v) {

        var q = new Queue<int>();
        q.Enqueue(v);
        d[v] = 0;

        while (q.Count > 0) {
            
            var u = q.Dequeue();
            for (int i = 0; i < g[u].Count; i++) {
                if (stt[g[u][i]] != blk) {
                    q.Enqueue(g[u][i]);
                    stt[g[u][i]] = gry;
                    d[g[u][i]] = Math.Min(d[g[u][i]], d[u] + 1);
                }
            }

            stt[u] = blk;
        }
    }
}



Measured memory_bytes: 20748
import sys
import numpy as np
import numba
from numba import njit, b1, i4, i8, f8

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

MASK30 = (1 << 30) - 1
MASK31 = (1 << 31) - 1
MASK61 = (1 << 61) - 1

@njit((i8, ), cache=True)
def rh_modulo(x):
    xu, xd = x >> 61, x & MASK61
    x = xu + xd
    if x >= MASK61:
        x -= MASK61
    return x


@njit((i8, i8), cache=True)
def rh_multiply(a, b):
    au, ad = a >> 31, a & MASK31
    bu, bd = b >> 31, b & MASK31
    x = ad * bu + au * bd
    xu, xd = x >> 30, x & MASK30
    return rh_modulo(au * bu * 2 + xu + (xd << 31) + ad * bd)


@njit((i8, i8), cache=True)
def rh_pows(base, max_len):
    pows = np.empty(max_len, np.int64)
    pows[0] = 1
    for n in range(1, max_len):
        pows[n] = rh_multiply(pows[n - 1], base)
    return pows


@njit((i8[:], i8, i8[:]), cache=True)
def compute_rh(pows, base, S):
    N = len(S)
    RH = np.empty(N, np.int64)
    RH[0] = S[0] + 10
    for n in range(1, N):
        x = rh_multiply(RH[n - 1], base) + S[n] + 10
        if x >= MASK61:
            x -= MASK61
        RH[n] = x
    return RH


@njit((i8[:], i8, i8[:], i8, i8), cache=True)
def rh_substr(pows, base, RH, l, r):
    h = RH[r]
    if l > 0:
        h -= rh_multiply(RH[l], pows[r - l])
    if h < 0:
        h += MASK61
    return h

@njit((i8[:], ), cache=True)
def main(S):
    S = S.copy()
    l_ind = np.where(S == -1)[0][:-1] + 1
    r_ind = np.where(S == -1)[0][1:]
    N = len(l_ind)
    # 逆順にしておく
    for i in range(N):
        S[l_ind[i]:r_ind[i]] = S[l_ind[i]:r_ind[i]][::-1]

    # rolling hashの計算
    max_len = len(S) + 10
    base = np.random.randint(0, 1 << 31)
    pows = rh_pows(base, max_len)
    RH = np.zeros_like(S)
    for i in range(N):
        RH[l_ind[i]:r_ind[i]] = compute_rh(pows, base, S[l_ind[i]:r_ind[i]])

    # 後ろ（自身も含む）に置ける文字集合の計算
    sets = np.zeros_like(S)
    for i in range(N):
        for j in range(r_ind[i] - 1, l_ind[i] - 1, -1):
            sets[j] = sets[j + 1] | 1 << S[j]

    # 作れる組 (prefix, 右からの1文字)をすべて計算する
    ptr = 0
    nums = np.empty(len(S) * 26 + 10, np.int64)
    for i in range(N):
        for j in range(l_ind[i], r_ind[i]):
            for k in range(26):
                if sets[j] & 1 << k:
                    h = rh_multiply(RH[j - 1], base) + k
                    nums[ptr] = h
                    ptr += 1
    nums = nums[:ptr]
    nums.sort()
    # 各文字列とマッチングする対象を数える
    ans = 0
    for i in range(N):
        h = rh_multiply(RH[r_ind[i] - 2], base) + S[r_ind[i] - 1]
        cnt = np.searchsorted(nums, h, 'right')
        cnt -= np.searchsorted(nums, h, 'left')
        ans += cnt - 1  # 自分を除外
    print(ans)

N = int(readline())
S = np.array(list(read().rstrip()), np.int64)

S[S == ord('\n')] = -1
S[S > 0] -= ord('a')
S = np.insert(S, 0, -1)
S = np.append(S, -1)

main(S)


Measured memory_bytes: 346972
#include<iostream>

using namespace std;

int main(){
	long long int n,temp;
	int i,j=0;
	cin >> n;
	temp=n;
	int a[17];

	for(i=0;temp!=0;i++){
		a[i]=(temp%10);temp /= 10;
		if(a[i]==9){j++;}
	}

	if(i==j){
		cout << i*9 <<endl;
		return 0;
	}
	if(a[i-1]==9){
		cout << 8+9*(i-1)<<endl;
		return 0;
	}
	if(i==j+1){
		cout << a[i-1]+9*(i-1)<<endl;
		return 0;
	}
	if(a[i-1]==1){
		cout << 9*(i-1);
		return 0;
	}
	cout << (a[i-1]-1)+9*(i-1)<<endl;

	return 0;


}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mxn 1000010
#define LL long long
#define pb push_back
#define ppb pop_back
#define pf push_front
#define pii pair<int,int> 
#define mp make_pair
#define fr first
#define sc second
using namespace std;
int n,sl,fh,ans,a[mxn];
int rd()
{
	sl=0;fh=1;
	char ch=getchar();
	while(ch<'0'||'9'<ch) {if(ch=='-') fh=-1; ch=getchar();}
	while('0'<=ch&&ch<='9') sl=sl*10+ch-'0',ch=getchar();
	return sl*fh;
}
int main()
{
	n=rd();
	for(int i=1;i<=n;++i) a[i]=rd();
	sort(a+1,a+n+1);
	printf("%d\n",a[n/2+1]-a[n/2]);
	return 0;
}

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

using namespace std;

int main(){
string S,T; cin >> S >> T;
  
  int alphabet1[26];
    for(int i = 0;i < 26; i++){ alphabet1[i] = -1;}
  int alphabet2[26];
    for(int j = 0;j < 26; j++){ alphabet2[j] = -1;}
  
  
  bool flag = true;
  
  // Sの同じ文字が、Tの異なる文字に対応しない,Tの同じ文字がSの異なる文字に対応しない
  
  for(int i = 0; i < S.size(); i++){
    int s = S[i] - 'a'; int t = T[i] - 'a';
    if(alphabet1[s] != -1){if(alphabet1[s] != t){ flag = false; break;}}
    //埋まっていて、かつTの異なる文字と対応しているならばfalse;
    if(alphabet2[t] != -1){if(alphabet2[t] != s){ flag = false; break;}}
    
    alphabet1[s] = t; alphabet2[t] = s;}
  
  if(flag){ cout << "Yes" << endl; }
else{ cout << "No"<< endl;} return 0;}
    
    

Measured memory_bytes: 776
/*
Dont BLUNDER
*/

// #pragma GCC optimize("O3")
// //#pragma comment(linker, "/stack:200000000")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimization ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;


 */
//#define d long double
#define int long long
#define pii pair<int,int>
#define pb push_back
#define endl '\n'
#define pi acos(-1)

#define init(x,a) memset(x,a,sizeof(x))
#define all(c) c.begin(),c.end()
int const mod1 = 998244353;
int const mod = 1000000007;
#define bitcount(x)       __builtin_popcountll(x)
#define l first
#define r second
const int inf = LLONG_MAX;
int toint(const string &s) {stringstream ss; ss << s; int x; ss >> x; return x;}
string tostring ( int number ) {stringstream ss; ss << number; return ss.str();}
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define haha ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
// * Using PBDS *
/*typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
               os; */



int modexp(int x, int n) {
	if (n == 0) {
		return 1;
	}
	else if (n & 1) {
		return (modexp((x * x) % mod, n / 2) % mod * x % mod) % mod;
	}
	else {
		return (modexp((x * x) % mod, n / 2) % mod);
	}
}

int modinv(int n)
{
	return modexp(n, mod - 2);
}

int gcd(int a, int b) {
	if (b == 0) {
		return a;
	}
	return gcd(b, a % b);
}
bool comp(pair<int, pii> a, pair<int, pii> b) {
	if (a.first == b.first) {
		return a.second.first < b.second.first;
	}
	return a.first < b.first;

}
vector<int> adj[200005];
int vis[200005];
int ans = 0;
int n, m;
int c = 0;

void dfs(int x) {
	vis[x] = 1;
	c++;
	for (auto i : adj[x]) {
		if (vis[i] == 0)
		{
			vis[i] = 1;
			dfs(i);
		}
	}
}



signed main()
{
	haha
// #ifndef ONLINE_JUDGE

// 	freopen("inp.txt", "r", stdin);

// 	freopen("out1.txt", "w", stdout);
// #endif
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		adj[a].pb(b);
		adj[b].pb(a);

	}
	for (int i = 1; i <= n; i++) {
		if (vis[i] == 0) {
			c = 0;
			dfs(i);
			ans = max(ans, c);
		}
	}
	cout << ans;















}

Measured memory_bytes: 22312
import java.io.*;
import java.util.Scanner;


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int n = sc.nextInt();

		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}

		double tmp = 0;
		for (int e : a) {
			tmp += (double)1 / e;
		}
		
		pr.printf("%.6f%n", 1 / tmp);
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);
			
		solve();
			
		pr.close();
		sc.close();
	}

	static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 23888
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int N,M; cin>>N>>M;
  vector<vector<pii>> A(N);
  int memo=0;
  rep(i,0,M){
    int L,R,D; cin>>L>>R>>D;
    A[L-1].pb(mp(R-1,D));
    A[R-1].pb(mp(L-1,-D));
    memo=L-1;
  }
  vi F(N,-INF);
  string ans="Yes";
  rep(j,0,N){
    if(F[j]==-INF){
  F[j]=0;
  queue<pii> Q;
  Q.push(mp(j,0));
  while(Q.size()>0){
    int X=Q.front().first,Y=Q.front().second;
    Q.pop();
    rep(i,0,A[X].size()){
      int B=A[X][i].first,C=Y+A[X][i].second;
      if(F[B]==-INF){
        Q.push(mp(B,C));
        F[B]=C;
      }
      else if(F[B]!=C){
        ans="No";
        goto XYZ;
      }
    }
  }
    }
  }
  sort(ALL(F));
  if(F[N-1]-F[0]>1000000000)
    ans="No";
  XYZ:
  cout<<ans<<endl;
  }



Measured memory_bytes: 14448
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, sum = 0;
    cin >> n;
    int b[n - 1];
    for (int i = 0; i < n - 1; i++) {
        cin >> b[i];
    }
    sum += b[0];
    sum += b[n - 2];
    for (int i = 0; i < n - 2; i++) {
        sum += min(b[i], b[i + 1]);
    }
    cout << sum;
}



Measured memory_bytes: 3632