akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <algorithm>

using namespace std;

int h[100016];
int costs[100016];

int main() {
	int N, K;
	scanf("%d%d", &N, &K);
	for(int i=0; i<N; ++i) {
		scanf("%d", &h[i]);
	}
	costs[0] = 0;
	for(int i=1; i<N; ++i) {
		int v = 0x7FFFFFFF;
		for(int j=max(0, i-K); j<i; ++j) {
			v = min(v, costs[j]+abs(h[i]-h[j]));
		}
		costs[i] = v;
	}
	printf("%d\n", costs[N-1]);
	return 0;
}


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

using namespace std;
typedef long long ll;
int n;
const int mod = 1e9 + 7;

void fun(vector<vector<int>> &a, vector<vector<int>> &b){
	vector<vector<int>> c(n, vector<int> (n));
	for (int i = 0; i < n; ++i)
		for(int j = 0; j < n; ++j)
			for(int k = 0; k < n; ++k)
				c[i][k] += (1LL*a[i][j]*b[j][k])%mod,
				c[i][k] %= mod;
	b = c;
}


int main(){
	ll k; cin >> n >> k;
	vector<vector<int>> mat(n, vector<int> (n)), z(n, vector<int>(n));
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < n; ++j)
		{
			cin >> mat[i][j];
		}
		z[i][i] = 1;
	}
	while(k > 0){
		if(k&1) fun(mat, z);
		fun(mat, mat); k >>= 1;
	}
	int ans = 0;
	for(int i = 0; i < n; ++i){
		for(int j = 0; j < n; ++j){
			ans += z[i][j];
			ans %= mod;
		}
	}
	cout << ans;
}

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

using namespace std;

int main() {
  int h, w;
  cin >> h >> w;

  vector<string> g(h);
  int black = 0;
  for (int i = 0; i < h; i++) {
    cin >> g[i];
    for (int j = 0; j < w; j++) {
      black += g[i][j] == '#';
    }
  }

  queue<pair<int, int>> q;
  q.emplace(0, 0);

  vector<vector<int>> dist(h, vector<int>(w, -1));
  dist[0][0] = 0;
  
  const int dy[] = { 0, 1, 0, -1 };
  const int dx[] = { 1, 0, -1, 0 };

  while (!q.empty()) {
    int y = q.front().first;
    int x = q.front().second;
    q.pop();
    for (int k = 0; k < 4; k++) {
      int yy = y + dy[k];
      int xx = x + dx[k];
      if (yy < 0 || xx < 0 || yy >= h || xx >= w) continue;
      if (g[yy][xx] == '#') continue;
      if (dist[yy][xx] != -1) continue;
      dist[yy][xx] = dist[y][x] + 1;
      q.emplace(yy, xx);
    }
  }

  if (dist[h - 1][w - 1] == -1) {
    cout << -1 << endl;
  } else {
    cout << (h * w) - dist[h - 1][w - 1] - black - 1 << endl;
  }
}


Measured memory_bytes: 256
# at ABC 147 e (500)
import sys
X, Y, U = [], [], []
if True:
    H, W, *nums = map(int, sys.stdin.read().split())
    i = 0
    for _ in range(H):
        X.append(nums[i:i + W])
        i += W
        U.append([0] * W)
    for _ in range(H):
        Y.append(nums[i:i + W])
        i += W
else:    
    H, W = map(int, input().split())
    for _ in range(H):
        X.append(list(map(int, input().split())))
        U.append([0 for _ in range(W)])
    for _ in range(H):
        Y.append(list(map(int, input().split())))

mid = 80*80

init = abs(X[0][0] - Y[0][0])
U[0][0] = (1 << (mid - init)) | (1 << (mid + init))

for i in range(W):
    for j in range(H):
        k = abs(X[j][i] - Y[j][i])
        if j > 0:
            U[j][i] |= (U[j - 1][i] << k)
            U[j][i] |= (U[j - 1][i] >> k)
        if i > 0:
            U[j][i] |= (U[j][i - 1] << k)
            U[j][i] |= (U[j][i - 1] >> k)
#        U[j][i] = U[j][i] & ((1 << (2 * mid)) - 1)
    
i = 0
min_ = float("inf")
while True:
     if U[-1][-1] & 1:
         min_ = min(min_, abs(i - mid))
     U[-1][-1] = U[-1][-1] >> 1
     i += 1
     if i >= 2 * mid:
         break
print(min_)


Measured memory_bytes: 55516
n = int(input())
a = list(map(int, input().split()))
MOD = 10 ** 9 + 7

ru = [0] * (n + 1)
for i in range(n):
    ru[i + 1] = ru[i] + 1 * pow(i + 1, MOD - 2, MOD)
    ru[i + 1] %= MOD

fact = 1
for i in range(n):
    fact *= i + 1
    fact %= MOD

ans = 0
for i in range(n):
    l_len, r_len = i + 1, n - i
    coff = ru[i + 1] + ru[n - i]
    ans += fact * a[i] * (coff - 1)
    ans %= MOD

print(ans)

Measured memory_bytes: 62576
using System;

namespace ABC057C
{
    class Program
    {
        static void Main(string[] args)
        {
            long N = long.Parse(Console.ReadLine());
            long Amax = (long)Math.Ceiling(Math.Sqrt(N));
            long Fmin = N;
            for(long i=Amax; i > 0; i--){
                if(N % i == 0){
                    long B = N/i;
                    Fmin = F(i,B);
                    break;
                }
            }
            Console.WriteLine(Fmin);
        }
        public static long F(long a, long b){
            long c = 0; long d = 0;
            while(a > 0){
                c++; a /=10;
            }            
            while(b > 0){
                d++; b /=10;
            }
            if(c < d) return d; else return c;            
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

u64 ans;
void mergeSort(vs32&, int, int);
void merge(vs32&, int, int, int);

void mergeSort(vs32& A, int l, int r)
{
  if (l + 1 < r)
  {
    int m = (l + r) / 2;
    mergeSort(A, l, m);
    mergeSort(A, m, r);
    merge(A, l, m, r);
  }
}

void merge(vs32& A, int l, int m, int r)
{
  int n1 = m - l;
  int n2 = r - m;
  vs32 L(n1 + 1), R(n2 + 1);
  rep (i, n1) L[i] = A[l + i];
  rep (i, n2) R[i] = A[m + i];
  L[n1] = 1e9 + 1; R[n2] = 1e9 + 1;

  int i = 0, j = 0;
  for (int k = l; k < r; ++k)
  {
    ++ans;
    if (L[i] <= R[j])
    {
      A[k] = L[i++];
    }
    else
    {
      A[k] = R[j++];
    }
  }
}

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

    int n;
    cin >> n;

    vs32 A(n);
    rep (i, n) cin >> A[i];

    mergeSort(A, 0, n);

    rep (i, n)
    {
      if (i != 0) cout << ' ';
      cout << A[i];
    }
    cout << '\n';

    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 6768
x, n = map(int,input().split())
p = [int(s) for s in input().split()]
k= 100

for r in range (0,102):
    if (r not in p):
        if (abs(x - int(r)) < k):
            A = int(r)
            k = abs(x - int(r))
if (A > x):
    if (2*x-A not in p):
        A = 2*x-A

print (A)





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

#define MOD 1000000007


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,a,b,i;
    string s;
    cin>>a>>b>>s;
    for(i=0;i<s.size();i++)
      {
      	if(i!=a)
      	  {
      	     if(s[i]<'0' || s[i]>'9')
      	       {  //cout<<s[i];
      	       	cout<<"No";
      	       	return 0;
      	       }
      	  }
      	else
      	  {
      	  	if(s[i]!='-')
      	  	  {	//cout<<s[i];
      	  	  	cout<<"No";
      	  	  	return 0;
      	  	  }
      	  }
      }
    cout<<"Yes"<<'\n';
   return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll n,k;
    cin>>n>>k;
    string s;
    cin>>s;
    ll x =s.length();
    for(ll i=0;i<x;++i)
    {
        if(i+1 == k){
            s[i] += 32;
            break;
        }
    }
    cout<<s<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    int K,N;
    cin>>N>>K;
    unordered_map<int,int> cnt;
    int a;
    rep(i,N)
    {
        cin>>a;
        cnt[a]++;
    }
    priority_queue<int,vint,greater<int>> q;
    for(auto i:cnt)
    {
        q.push(i.second);
    }
    int kind=cnt.size(),ans=0;
    while(kind>K)
    {
        ans+=q.top();
        q.pop();
        kind--;
    }
    cout<<ans;
    return 0;
}

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

def main():
    K = int(input())
    A, B = map(int, input().split())
    for i in range(1001):
        if A <= (i*K) <= B:
            print('OK')
            return
    print('NG')

if __name__ == '__main__':
    main()


Measured memory_bytes: 61712
#ifndef Local
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx")
#endif
#include <bits/stdc++.h>

using namespace std;

#define popCnt(x) (__builtin_popcountll(x))
#define sz(x) ((int)(x.size()))
#define all(v) begin(v), end(v)
#define rall(v) rbegin(v), rend(v)
typedef long long Long;
typedef double Double;

template <class U, class V>
istream& operator>>(istream& is, pair<U, V>& p) {
  is >> p.first >> p.second;
  return is;
}
template <class T>
istream& operator>>(istream& is, vector<T>& v) {
  for (auto& x : v) {
    is >> x;
  }
  return is;
}

template <class T>
ostream& operator<<(ostream& os, vector<T>& v) {
  for (auto& x : v) {
    os << x << " ";
  }
  return os;
}

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifdef Local
  freopen("test.in", "r", stdin);
#else
#define endl '\n'
#endif

  int m, k;
  cin >> m >> k;
  m = 1 << m;
  if (k >= m) {
    cout << -1 << endl;
    return 0;
  }
  if (k == 0) {
    for (int i = 0; i < m; ++i) {
      cout << i << " " << i << " ";
    }
    cout << endl;
    return 0;
  }
  if (m <= 2) {
    cout << -1 << endl;
    return 0;
  }
  for (int i = 0; i < m; ++i) {
    if (i != k) {
      cout << i << " ";
    }
  }
  cout << k << " ";
  for (int i = m - 1; i >= 0; --i) {
    if (i != k) {
      cout << i << " ";
    }
  }
  cout << k << endl;

  return 0;
}

Measured memory_bytes: 3656
#include <stdio.h>

main(){
  int x,temp;
  int i,j;

  while(1){
    if(scanf("%d", &x)==EOF) break;
    temp=x/39;
    j=x-temp*39;
    printf("3C");
    if(j == 0) printf("39\n");
    else if(j>=1 && j<10) printf("0%d\n", j);
    else printf("%d\n", j);
  }
  return 0;
}

Measured memory_bytes: 0
N, M = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(M)]
left, right = 0, 10**6

for i in range(M):
    if A[i][1] < left:
        print(0)
        exit()
    if A[i][0] > right:
        print(0)
        exit()
    left = max(left, A[i][0])
    right = min(right, A[i][1])

print(right-left+1)


Measured memory_bytes: 27328
N = int(input())
S = str(input())
P1 = set()
cnt = 0
for i in range(N-2):
    if S[i] in P1:
        continue
    else:
        P1.add((S[i]))
        P2 = set()
        for j in range(i+1, N-1):
            if S[j] in P2:
                continue
            else:
                P2.add(S[j])
                P3 = set()
                for k in range(j+1, N):
                    if S[k] in P3:
                        continue
                    else:
                        P3.add(S[k])
                        cnt += 1
print(cnt)


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        Function func = new Function();
        int num1, num2;

        while(true) {
            num1 = Integer.parseInt(scan.next());
            num2 = Integer.parseInt(scan.next());

            if (num1 == 0 && num2 == 0) {
                break;
            }

            func.printRct(num1, num2);
        }
    }
}

class Function {
    public void printRct(int num1, int num2) {
        for (int i = 0; i < num1; i++) {
            for (int j = 0; j < num2; j++) {
                System.out.print("#");
            }
            System.out.print("\n");
        }
        System.out.print("\n");
    }
}


Measured memory_bytes: 37632
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <cctype>
#include <complex>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#define INF 1<<30
#define EPS 1e-15
#define PB push_back
#define fi first
#define se second
#define rep(i,j) for(int  i = 0; i < (j); i++)
#define reps(i,j,k) for(int i = j; i < k; i++)
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef vector < int > vi;
typedef vector < vi > vvi;
bool compare(string a,string b){
	if(b.size() > a.size())return true;
	if(b.size() < a.size())return false;
	rep(i,a.size()){
		if(b[i] > a[i])return true;
		if(b[i] < a[i])return false;
	}
	return false;	
}
string divide(string a){
	int carry = 0;
	string ans = "";
	rep(i,a.size()){
		int tmp = a[i]-'0'+10*carry;
		if(tmp == 1){
			carry = 1;
			if(i != 0)ans += "0";
			continue;
		}
		ans += (tmp/2)+'0';
		if(tmp%2==1){
			carry = 1;
		}
		else{
			carry = 0;
		}
	}
	return ans;
}
string long_calc_p(string a,string b){
	string ans = "";
	reverse(a.begin(),a.end());
	reverse(b.begin(),b.end());
	int sz;
	int mi;
   	if(a.size() > b.size()){
   		sz = a.size();
  		mi = b.size();
	}
   	else{
		sz = b.size();
		mi = a.size();
  	}
	int carry = 0;
	rep(i,sz){
		if(i >= mi){
			if(mi == a.size()){
				int tmp = b[i]-'0'+carry;
				if(tmp > 9){
					carry = 1;
					ans += tmp-10+'0';
				}
				else{
					carry = 0;
					ans += tmp+'0';
				}
			}
			else{
				int tmp = a[i]-'0'+carry;
				if(tmp > 9){
					carry = 1;
					ans += tmp-10+'0';
				}
				else{
					carry = 0;
					ans += tmp+'0';
				}
			}
		}
		else{
			int tmp = a[i]-'0'+b[i]-'0'+carry;
			if(tmp > 9){
				carry = 1;
				ans += tmp-10+'0';
			}
			else{
				carry = 0;
				ans += tmp+'0';
			}
		}
	}
	if(carry)ans+="1";
	reverse(ans.begin(),ans.end());
	return ans;
}
string long_calc_m(string a,string b){
	string ans = "";
	string l="",r="";
	l = "0";
	rep(i,1020)r+="9";	
	while(long_calc_p(l,"1") != r){
		string med = divide(long_calc_p(l,r));
		string tmp = long_calc_p(med,b);
		if(tmp == a){
			ans = med;
			break;
		}
		if(compare(a,tmp)){
			r = med;
		}
		else{
			l = med;
		}
	}
	if(ans == "")ans = "0";
	return ans;
}
int main(){
	string a,b;
	char _a[1024],_b[1024];
	int n;
	scanf("%d",&n);
	while(n--){
		scanf("%s%s",_a,_b);
		a = _a;
		b = _b;
		if(long_calc_p(a,b).size() > 80)puts("overflow");
		else printf("%s\n",long_calc_p(a,b).c_str());
	}
	return 0;
}

Measured memory_bytes: 1220
#include<iostream>
#include<string>
#include<math.h>
using namespace std;

int main() {
	char S[20];
	string T;
	string p;
	string Q;
	double m;
	int a = 0;
	int A = 0;
	int b = 0;
	int B = 0;
	int c = 0;
	int C = 0;
	int q, w, z;
	int n = 0;
	int x = 0;
	int y = 0;
	int ans = 0;
	int X[100] = { 0 };
	cin >> a >> b;
	cout << a * b - (a + b - 1);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using str = string;

int main(){
  int a, b, c; cin >> a >> b >> c;
  int ans;
  if(a-b >= c){
    int zero = 0;
    cout << zero << endl;
  }else{
    cout << c-a+b << endl;
  }
  return 0;
}

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

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define pb(x) push_back(x)
#define SORT(ls) sort(ls.begin(), ls.end())
#define DESC(ls) sort(ls.rbegin(), ls.rend())
#define mp(x, y) make_pair(x, y)
#define INF 1000000000
#define MOD 1000000007
#define F(i, a, n) for (i = a; i < n; i++)
#define B(i, a, n) for (i = n - 1; i >= 0; i--)
#define SI(x) cin >> x
#define DI(x, y) cin >> x >> y
#define TI(x, y, z) cin >> x >> y >> z
#define FI(w, x, y, z) cin >> w >> x >> y >> z
#define SO(x) cout << x << endl
#define DO(x, y) cout << x << " " << y << endl
#define TO(x, y, z) cout << x << " " << y << " " << z << endl
#define FO(w, x, y, z) cout << w << " " << x << " " << y << " " << z << endl

int main(void) 
{
    int i, j;
    int A, P;
    DI(A, P);
    SO((3*A + P) / 2);
    return 0;

}

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

#ifdef _DEBUG
#define debug(x) cerr << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#else
#define debug(x)
#endif

#define all(s) begin(s), end(s)
#define rall(s) rbegin(s), rend(s)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = ((a)-1); i >= (b); i--)
#define pb push_back
#define sz(a) int((a).size())
#define put(a) ((cout) << (a) << (endl))
#define putf(a, n) ((cout) << (fixed) << (setprecision(n)) << (a) << (endl))
#define deg2rad(x) (((x)*PI) / (180.0))
#define rad2deg(x) (((x) * (180.0)) / PI)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;
template <class T> using vec = vector<T>;

static constexpr ll LL_INF = 1LL << 60;
static constexpr int I_INF = 1 << 28;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class T> static inline T gcd(T a, T b);
template <class T> static inline T lcm(T a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);
template <class T> T mod(T a, T m);

int main(int argc, char* argv[]) {
  ll n, x;
  cin >> n >> x;
  vec<ll> a(n);
  scan(a);

  ll ans = 0;
  rep(i, 1, n) {
    ll sum = a[i - 1] + a[i];
    if (x >= sum) continue;
    ll diff = min(sum - x, a[i]);
    ans += diff;
    a[i] -= diff;
  }

  ll sum = a[0] + a[1];
  if (x < sum) {
    ll diff = min(sum - x, a[0]);
    ans += diff;
    a[0] -= diff;
  }

  put(ans);
  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

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

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

template <class T> inline T gcd(T a, T b) { return __gcd(a, b); }

template <class T> inline T lcm(T a, T b) {
  T c = min(a, b), d = max(a, b);
  return c * (d / gcd(c, d));
}

template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}

template <class T> T mod(T a, T m) { return (a % m + m) % m; }


Measured memory_bytes: 1024
package main

import "fmt"

func main(){
	var A, B int
	var C, D int
	var f = 0

	fmt.Scan(&A, &B);
	fmt.Scan(&C, &D);

	for {
		C -= B 
		if C <= 0 {
			f = 1;
			break;
		}
		A -= D
		if A <= 0 {
			f = 2;
			break;
		}
	}
	if f == 1 {
		fmt.Println("Yes");
	}else{
		fmt.Println("No");
	}
}

Measured memory_bytes: 1752
#include <stdio.h>

int n;
int A[20];
int q;
int m[200];

int search(int key, int i){
    if(key==0){
        return 1;
    }
    if(i==n || key<0){
        return 0;
    }
    return (search(key-A[i], i+1) || search(key, i+1));
}

int main(void){
    // Your code here!
    scanf("%d", &n);
    for(int i=0;i<n;i++){
        scanf("%d", &A[i]);
    }
    scanf("%d", &q);
    for(int i=0;i<q;i++){
        scanf("%d", &m[i]);
    }
    for(int i=0;i<q;i++){
        //printf("%d %d\n", i, search(m[i], 0));
        if(search(m[i], 0)){
            printf("yes\n");
        }else{
            printf("no\n");
        }
    }
}



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


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
 
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    cout << a+b+c+d<<endl;
    
}


Measured memory_bytes: 3132
#include <iostream>
using namespace std;
int main()
{
	char s[19];
	for(int i=0;i<19;i++)
	{
		cin>>s[i];
		if(s[i]==',')
		{
			s[i]=' ';
		}
	}
	for(int j=0;j<19;j++)
	{
		cout<<s[j];
	}
	return 0;
}

Measured memory_bytes: 3584
#include<stdio.h>
int main(){
	int price,order;//単価、販売件数
	int sum_price=0,sum_order=0;
	int count=0;//オーダーのカウント
	while(~scanf("%d,%d",&price,&order)){
		sum_price+=price*order;
		sum_order+=order;
		count++;
		}
		
		sum_order=(double)sum_order/count+0.9;
	
	printf("%d\n%d\n",sum_price,sum_order);
	return 0;
}

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

#define watch(x) cerr << (#x) << ": " << (x) << endl
#define int long long



int32_t main() {

    int n, q; cin >> n >> q;
    string s; cin >> s;

    vector<int> acs(n, 0);
    for(int i = 1; i < n; ++i) {
        acs[i] = acs[i-1];
        if(s[i-1] == 'A' && s[i] == 'C') {
            acs[i]++;
        }
    }

    for(int i = 0; i < n; ++i) cerr << acs[i];
    cerr << endl;

    for(int i = 0; i < q; ++i) {
        int l, r; cin >> l >> r;
        int ans = acs[r-1] - acs[l-1];
        cout << ans << endl;
    }
    
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i < n; ++i)
#define repe(i, n) for(int i=0; i <= n; ++i)
#define repr(i, n) for(int i=n-1; i > 0; --i)
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
#define eb(x,y) emplace_back(x,y)
#define PI 3.14159265359
using namespace std;
template <class T> bool chmax(T &a, const T &b) {if (a<b) {a = b; return 1;} return 0;}
template <class T> bool chmin(T &a, const T &b) {if (b<a) {a = b; return 1;} return 0;}
template <class T> using V=vector<T>;
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1000000007;
const ll MAX = 510000;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
vector<int> Eratosthenes(const int N)
{
    vector<bool> is_prime(N+1, true);
    vector<int> P;
    for(int i=2; i<=N; i++) {
        if (is_prime[i]) {
            for(int j=2*i; j<=N; j+=i) {
                is_prime[j] = false;
            }
            P.emplace_back(i);
        }
    }
    return P;
}
 
int main() {
    ll n;
    cin >> n;
    vector<ll> A(n);
    vector<ll> B(n);
    rep (i,n) {
        cin >> A[i];
        B[i] = A[i];
    }

    sort(all(A), greater<ll>());
    rep(i,n) {
        if (B[i]==A[0]) {
            cout << A[1] << "\n";
        } else {
            cout << A[0] << "\n";
        }
    }

}

Measured memory_bytes: 4736
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include<map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
using namespace std;
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define LONGINF 1000000000000000000
int main() {
	int a, b;
	cin >> a >> b;
	vector<int> wow;
	REP(i, b) {
		int tmp;
		cin >> tmp;
		wow.push_back(tmp);
	}
	sort(wow.begin(), wow.end(),greater<int>());
	if (b == 1) {
		cout << wow[0] - 1 << endl;
		return 0;
	}
	cout << max(0, wow[0] * 2 - a-1) << endl;
	return 0;
}

Measured memory_bytes: 256
def main():
  N,P = map(int,input().split())
  S = list(map(int,list(input())))
  S=S[::-1]
  ans = 0
  if P==2:
    l = [0,2,4,6,8]
    for i,s in enumerate(S):
      if s in l:
        ans+=N-i
  elif P==5:
    l=[0,5]
    for i,s in enumerate(S):
      if s in l:
        ans+=N-i

  else:
    l = [0]*P
    a=0
    for i in range(N):
      b = pow(10,i,P)
      b *= S[i]
      b %= P
      a+=b
      a%=P
      l[a]+=1
    ans+=l[0]
    for i in l:
      ans+=i*(i-1)//2

  print(ans)
  
main()

Measured memory_bytes: 61680
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

ll H;

ll solve(ll val){
  if(val==1) return 1;
  ll res=solve(val/2)*2+1;
  return res;
}

int main(){
  cin>>H;

  cout<<solve(H)<<endl;


  return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
s = input()
if s.count("1") == n or s.count("0") == n:
    print(n)
    exit()
zero = 0
flag = 0
for i in s:
    if i == "0":
        flag = 1
    else:
        if flag:
            zero += 1
        flag = 0
if flag:
    zero += 1
k = min(zero, k)
renzoku = []
count = 0
flag = 0
for i in range(n):
    if s[i] == "1":
        if flag:
            count += 1
        else:
            renzoku.append(count)
            count = 1
        flag = 1
    else:
        if flag:
            renzoku.append(count)
            count = 1
        else:
            count += 1
        flag = 0
renzoku.append(count)
renzoku_t = [0]
for i in range(len(renzoku)):
    renzoku_t.append(renzoku[i] + renzoku_t[i])
ans = 0
if k == zero:
    print(n)
    exit()
if s[0] == "0":
    ans = renzoku_t[0 + k + k] - renzoku_t[0]
for i in range(1, len(renzoku) - k - k + 1, 2):
    if i == 0 or i == len(renzoku) - k - k:
        ans = max(ans, renzoku_t[i + k + k] - renzoku_t[i])
    else:
        ans = max(ans, renzoku_t[i + k + k + 1] - renzoku_t[i])
print(ans)

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

ll cmp3(ll P1, ll P2, ll Q1, ll Q2) {
  ll s1 = P1 * (Q1 + Q2);
  ll s2 = P2 * Q1;
  ll s3 = P2 * Q2;
  ll smax = max(s1, max(s2, s3));
  ll smin = min(s1, min(s2, s3));
  return smax - smin;
}

ll chk(ll c, ll P, ll Q) {
  c = min(c, cmp3(P/3, P - P/3, Q/2, Q - Q/2));
  c = min(c, cmp3(P/3 + 1, P - P/3 - 1, Q/2, Q - Q/2));
  return c;
}

ll solve() {
  ll H, W; cin >> H >> W;
  if (H % 3 == 0) return 0;
  if (W % 3 == 0) return 0;
  ll c = min(H, W);
  c = chk(c, H, W);
  c = chk(c, W, H);
  return c;
}


int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);
  cout << solve() << endl;

  return 0;
}



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

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    string s1 , s2;
    cin >> s1 >> s2;
    int ans = 0;
    int n = s1.size();
    for(int i = 0 ; i < n ; i++)
        if(s1[i] != s2[i])
        ans++;
    cout<<ans;
}



Measured memory_bytes: 3828
import java.util.*;

public class Main{

    void solve(){
        Scanner sc = new Scanner(System.in);

        while(sc.hasNext()){
            char[] s1 = sc.next().toCharArray();
            char[] s2 = sc.next().toCharArray();

            int n = s1.length;
            int m = s2.length;

            int[][] dp = new int[2][m+1];
            
            int idx = 0;
            int max = 0;
            for(int i=0; i<n; i++){
                Arrays.fill(dp[idx],0);
                for(int j=0; j<m; j++){
                    if(s1[i]==s2[j]){
                        dp[idx][j+1] = dp[(idx+1)%2][j]+1;
                        max = Math.max(max, dp[idx][j+1]);
                    }
                }
                idx = (idx+1)%2;
            }
            
            System.out.println(max);
        }
    }

    public static void main(String[] args){
        new Main().solve();
    }
}

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

using i32 = int_fast32_t;
using i64 = int_fast64_t;

int main() {
    i32 n, a, b;
    cin >> n >> a >> b;
    i32 ans = n / (a + b) * a;
    n %= (a + b);
    ans += min(a, n);
    cout << ans << endl;
}


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

int main() {
	stack<int> S1;
	stack<pair<int, int> > S2;
	char ch;
	int sum = 0;
	for (int i = 0; cin >> ch; i++)
	{
		if (ch == '\\') S1.push(i);
		else if (ch == '/' && S1.size() > 0)
		{
			int j = S1.top(); S1.pop();
			sum += i - j;
			int a = i - j;
			while (S2.size() > 0 && S2.top().first > j)
			{
				a += S2.top().second; S2.pop();
			}
			S2.push(make_pair(j, a));
		}
	}
	vector<int> ans;
	while (S2.size() > 0)
	{
		ans.push_back(S2.top().second); S2.pop();
	}
	reverse(ans.begin(), ans.end());
	cout << sum << endl;
	cout << ans.size();
	for (int i = 0; i < ans.size(); i++)
	{
		cout << " ";
		cout << ans[i];
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 3188
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;



namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var n = cin.ReadLong;

            var x = (cin.ReadLongArray(5).Min());

            var ans = 4 + n / x;

            if (n % x != 0) ans++;

            WriteLine(ans);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        public double[] ReadDoubleArray(long N) { var ret = new double[N]; for (long i = 0; i < N; ++i) ret[i] = ReadDouble; return ret; }
    }
}



Measured memory_bytes: 13396
#include <cstdio>
#include <cstring>
#define N 1000000
int n;
bool prime[N];
int num[N];
int main() {
    memset(prime, 1, sizeof prime);
    //for (int i=0;i<N;++i)prime[i]=true;
    prime[1] = prime[0] = num[0] = false;
    for (int i = 2; i < N; ++i)
        if (prime[i]){
            for (int j = 2 * i; j < N; j += i) prime[j] = false;
        //if (i%1000==0)
        //printf("%d %d\n",i,prime[i]);
    }
    for (int i = 1; i < N; ++i) num[i] = prime[i] + num[i-1];
    while (~scanf("%d", &n)) printf("%d\n", num[n]);
    return 0;
}



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

int main() {
  int N;
  cin >> N;
  int64_t sum = 0;
  for (int i=1; i<=N; i++){
  	if (i%3!=0 && i%5!=0){
      sum += i;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 3616
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true) {
            int H = sc.nextInt();
            int W = sc.nextInt();
            if(H==0 && W==0) break;
            for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    System.out.printf("#");
                }
                System.out.printf("\n");
            }
            System.out.println();
        }
    }
}



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

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

using namespace std;
typedef long long ll;
typedef long double ld;

const int max_n = 100111, inf = 1000111222;

int main()
{
    //freopen("input.txt", "r", stdin);
    int x, a;
    cin >> x >> a;
    if (x < a) {
        cout << 0 << endl;
    } else {
        cout << 10 << endl;
    }


    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>

#define DIV 1000000007
#define TE 2e5
using namespace std;
using ll = long long;
using ldb = long double;

int main() {
	int N; string S; int K;
	cin >> N >> S >> K;
	char c=S[K-1];
	for (int i = 0; i < N; i++) {
		cout << (S[i] == c ? c : '*');
	}

}


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

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

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

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

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

int main(){
    ll a, b; cin >> a >> b;
    if(a <= 0 && b >= 0){
        cout << "Zero" << endl;
    }else if(a < 0 && abs(b-a)%2==0){
        cout << "Negative" << endl;
    }else{
        cout << "Positive" << endl;
    }
}

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

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
	string S;
	cin >> S;

	ll N = S.size();
	ll MOD = 2019;

	ll ans = 0;
	map<int, int> m;
	ll base = 1;
	ll sum = 0;
	for (int ii = N-1; ii >= 0; --ii){
		ll v = ((S[ii] - '0') * base) % MOD;
		sum = (sum + v) % MOD;
		m[sum]++;
		ans += m[sum] - 1;
		if (sum == 0) ans++;
		base = (base * 10) % MOD;
	}

	cout << ans << "\n";

	return 0;
}


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

class UnionFind {
private:
	// 各ノードの親と、属する連結成分の大きさ（ただしsizeは根のみ正しいことが保証されている）
	std::vector<int> parent_, size_;
public:
	// sizeに要素数
	UnionFind(const int size);
	// indexの属する木の根を計算する
	int calcRoot(const int index);
	// index1とindex2が同じ連結成分に属しているかを判定する
	bool areConnected(const int index1, const int index2);
	// index1とindex2を連結する,
	void unite(const int index1, const int index2);
	// indexの属する連結成分の大きさを計算
	int calcSize(const int index);
};

UnionFind::UnionFind(const int size)
	:parent_(size),
	size_(size, 1)
{
	for (int i{}; i < size; i++) parent_[i] = i;
};

int UnionFind::calcRoot(const int index)
{
	if (parent_[index] == index) return index;
	const int p{calcRoot(parent_[index])};
	parent_[index] = p;
	return p;
}

bool UnionFind::areConnected(const int index1, const int index2)
{
	return calcRoot(index1) == calcRoot(index2);
}

void UnionFind::unite(const int index1, const int index2)
{
	const int root1{calcRoot(index1)}, root2{calcRoot(index2)};
	if (root1 == root2) return;
	if (size_[root1] <= size_[root2])
	{
		size_[root2] += size_[root1];
		parent_[root1] = root2;
	}
	else
	{
		size_[root1] += size_[root2];
		parent_[root2] = root1;
	}
	return;
}

int UnionFind::calcSize(const int index)
{
	return size_[calcRoot(index)];
}

int main()
{
	long long n, m;
	scanf("%lld%lld", &n, &m);
	std::vector<std::pair<int, int>> bridge;
	bridge.resize(m);
	for (auto& e: bridge)
	{
		scanf("%d%d", &e.first, &e.second);
		e.first--;
		e.second--;
	}
	UnionFind uf(n);
	std::vector<long long> ans(m);
	ans.back() = n * (n - 1) / 2;
	for (long long i{m - 2}; i >= 0; i--)
	{
		auto& b{bridge[i + 1]};
		if (uf.areConnected(b.first, b.second))
			ans[i] = ans[i + 1];
		else
		{
			ans[i] = ans[i + 1] - (long long)uf.calcSize(b.first) * uf.calcSize(b.second);
			uf.unite(b.first, b.second);
		}
	}
	for (int i{}; i < m; i++)
		printf("%lld\n", ans[i]);
 
	return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
     
using namespace std;
     
typedef long long ll;
     
double getTime() { 
  return clock() / (double) CLOCKS_PER_SEC;
}
     
void read() {};
     
template<typename T, typename... Args>
void read(T& a, Args&... args) {
  cin >> a;
  read(args...);
}
     
void print() {};
     
template <typename T, typename... Args>
void print(T a, Args... args) {
  cout << a << " \n"[sizeof...(args) == 0];
  print(args...);
}

int main() {
  int h, n; read(h, n);
  int sum = 0;
  for(int i = 0; i < n; i++) {
    int x; read(x);
    sum += x;
  }
  if(sum >= h) {
    print("Yes");
  }
  else {
    print("No");
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ll long long
#define M 1000000007LL
typedef pair<int,int> ii;
typedef vector<int> vi;
#define MAXN 100010
ll a[MAXN];
int main() {
	int n;cin >> n;
	int a[n];
	for (int i=1; i<=n; i++) {
		cin >> a[i];
	}
	ll res = 0;
	sort(a+1, a+n+1);
	if (n & 1) {
		for (int i=1; i<n/2; i++) {
			res += 2LL*a[n-i+1] - 2LL*a[i];
		}
		int m = (n+1)/2,h = (n+3)/2, l = (n-1)/2;
		res = res + max(2LL*a[h] - a[m] - a[l], a[h] + a[m] - 2LL*a[l]);
		printf("%lld\n", res);
	}
	else {
		for (int i=1; i<n/2; i++) {
			res += 2LL*a[n-i+1] - 2LL*a[i];
		}
		res += a[n/2+1] - a[n/2];
		printf("%lld\n", res);
	}
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define x first
#define y second
typedef pair<int,int> pii;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
template <typename T> void chkmax(T &x,T y){x<y?x=y:T();}
template <typename T> void chkmin(T &x,T y){x>y?x=y:T();}
template <typename T> void readint(T &x)
{
	x=0;int f=1;char c;
	for(c=getchar();!isdigit(c);c=getchar())if(c=='-')f=-1;
	for(;isdigit(c);c=getchar())x=x*10+c-'0';
	x*=f;
}
const int MAXN=1000005;

int n,ch[MAXN][26],stot;
char str[MAXN];
int f[MAXN][26],g[MAXN][26];
int cnt[26];
void insert(const char *s)
{
	int m=strlen(s),p=0;
	for(int i=0;i<m;++i)++cnt[s[i]-'a'];
	for(int i=m-1;i>=0;--i)
	{
		if(!i)++g[p][s[i]-'a'];
		for(int j=0;j<26;++j)if(cnt[j])++f[p][j];
		if(!ch[p][s[i]-'a'])ch[p][s[i]-'a']=++stot;
		p=ch[p][s[i]-'a'];
		--cnt[s[i]-'a'];
	}
}

int main()
{
	#ifdef LOCAL
	freopen("code.in","r",stdin);
//	freopen("code.out","w",stdout);
	#endif
	readint(n);
	for(int i=1;i<=n;++i)
	{
		scanf("%s",str);
		insert(str);
	}
	ll ans=0;
	for(int i=0;i<=stot;++i)
		for(int j=0;j<26;++j)
			ans+=1ll*g[i][j]*f[i][j];
	printf("%lld\n",ans-n);
	return 0;
}

Measured memory_bytes: 253124
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int c[3][3];
    REP(i,3) REP(j,3) cin>>c[i][j];

    REP(i,2){
        set<int> st;
        REP(j,3){
            st.insert(c[i][j]-c[i+1][j]);
        }
        if(st.size()>1){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
 
}


Measured memory_bytes: 256
//============================================================================
// Name        : e.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include<vector>
using namespace std;
typedef long long ll;
int main() {
	int n;cin>>n;
	vector<ll> a(n);
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	ll def=1;
	for(int i=0;i<18;i++)def*=10;
	vector<ll> v(n),v1(n),v2(n),u(n),u1(n),u2(n);
	v[0]=a[0];
	v1[0]=-def;
	v2[0]=-def;
	u[0]=-def;;
	u1[0]=0;
	u2[0]=-def;
	for(int i=1;i<n;i++){
		v[i]=u[i-1]+a[i];
		v1[i]=u1[i-1]+a[i];
		v2[i]=u2[i-1]+a[i];
		u[i]=v[i-1];
		u1[i]=max(v1[i-1],u[i-1]);
		u2[i]=max(v2[i-1],u1[i-1]);
	}
	if(n%2){
		cout<<max(v2[n-1],u1[n-1])<<endl;
	}else{
		cout<<max(v1[n-1],u[n-1])<<endl;
	}
//	for(int i=0;i<n;i++){
//		cout<<v[i]<<' ';
//	}cout<<endl;
//	for(int i=0;i<n;i++){
//			cout<<v[i]<<' ';
//		}cout<<endl;
//		for(int i=0;i<n;i++){
//				cout<<v1[i]<<' ';
//			}cout<<endl;
//			for(int i=0;i<n;i++){
//					cout<<v2[i]<<' ';
//				}cout<<endl;
//				for(int i=0;i<n;i++){
//						cout<<u[i]<<' ';
//					}cout<<endl;
//					for(int i=0;i<n;i++){
//							cout<<u1[i]<<' ';
//						}cout<<endl;
//						for(int i=0;i<n;i++){
//								cout<<u2[i]<<' ';
//							}cout<<endl;
	return 0;
}

Measured memory_bytes: 14348
#include <iostream>

using namespace std;

int main() {
	int a[4],b[4];
	while (cin>>a[0]>>a[1]>>a[2]>>a[3]) {
		cin>>b[0]>>b[1]>>b[2]>>b[3];
		int hit=0, blow=0;
		for (int i=0; i<4; i++) {
			for (int j=0; j<4; j++) {
				if (i==j&&a[i]==b[j]) hit++;
				else if (a[i]==b[j]) blow++;
			}
		}
		cout << hit << " " << blow << endl;
	}
}

Measured memory_bytes: 0
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>

int main() {
  uint32_t L = 0, R = 0, d = 0;
  std::cin >> L >> R >> d;

  std::cout << R/d - L/d + (L%d == 0) << std::endl;

  return 0;
}

Measured memory_bytes: 3624
def resolve():
    '''
    code here
    '''
    import math
    A, B, H, M = [int(item) for item in input().split()]

    h_ = 2*math.pi*(H*5 + M/60*5)/60
    m_ = 2*math.pi*(M/60)

    h_pos = [A*math.sin(h_), A*math.cos(h_)]
    m_pos = [B*math.sin(m_), B*math.cos(m_)]
    # print(h_pos)
    # print(m_pos)
    res = math.sqrt((h_pos[0]-m_pos[0])**2 + (h_pos[1]-m_pos[1])**2)
    print(res)
if __name__ == "__main__":
    resolve()


Measured memory_bytes: 9528
A,B,M = map(int,input().split())
a =[int(i)for i in input().split()]
b =[int(i) for i in input().split()] 
xyc = [input().split() for k in range(M)]
ans = []


for i in range(M):
  ans.append(a[int(xyc[i][0])-1] + b[int(xyc[i][1])-1]-int(xyc[i][2]))
  
ans.sort()
a.sort()
b.sort()
nomin=a[0]+b[0]

print(min(ans[0],nomin))

Measured memory_bytes: 50172
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int N = in.nextInt();
            int[] h = in.nextIntArray(N);

            long[] cost = new long[N];
            Arrays.fill(cost, Long.MAX_VALUE);
            cost[0] = 0;
            for (int i = 0; i < N - 1; i++) {
                cost[i + 1] = Math.min(cost[i + 1], cost[i] + Math.abs(h[i] - h[i + 1]));
                if (i + 2 < N)
                    cost[i + 2] = Math.min(cost[i + 2], cost[i] + Math.abs(h[i] - h[i + 2]));
            }
            out.println(cost[N - 1]);
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

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

        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = nextInt();
            }
            return a;
        }

    }
}



Measured memory_bytes: 31844