akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.StringTokenizer;
import java.util.Set;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class DigitMultiplication {
        int f(long a) {
            return Long.toString(a).length();
        }

        public void solve(int testNumber, FastReader in, PrintWriter out) {
            long n = in.nextLong();
            Set<Long> divisors = new HashSet<>();
            long ans = 9999999999L;
            for (long i = 1; i * i <= n; i++) {
                if (n % i == 0) {
                    if (i != n / i) {
                        ans = Math.min(Math.max(f(i), f(n / i)), ans);
                    } else {
                        ans = Math.min(Math.max(f(i), f(i)), ans);
                    }
                }
            }
            out.println(ans);
        }

    }

    static class FastReader {
        BufferedReader reader;
        StringTokenizer st;

        public FastReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            st = null;
        }

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

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

    }
}



Measured memory_bytes: 21588
import collections

N = int(input())
s = [input() for i in range(N)]
k = 0
i = 0
ans =[]

c = collections.Counter(s)
c_mc=c.most_common()
for i in range(len(c)):
    if c_mc[i][1] ==c_mc[0][1]:
        ans.append(c_mc[i][0])

ans_A =sorted(ans)
for i in range(len(ans_A)):
    print(ans_A[i])


Measured memory_bytes: 49276
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef complex<double> point; // 2D point only
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldob;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef pair<ii, int> ii_i;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<iii> viii;

#define re real()
#define im imag()
#define fi first
#define se second

// OST
template <typename T>
using ordered_set = __gnu_pbds::tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

// from: https://codeforces.com/blog/entry/62393
// struct custom_hash {
// 	static uint64_t splitmix64(uint64_t x) {
// 		// http://xorshift.di.unimi.it/splitmix64.c
// 		x += 0x9e3779b97f4a7c15;
// 		x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
// 		x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
// 		return x ^ (x >> 31);
// 	}

// 	size_t operator()(uint64_t x) const {
// 		static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
// 		return splitmix64(x + FIXED_RANDOM);
// 	}
// };

const int INF = ~(1<<31);
const ll LINF = (1LL << 60);
const long double EPS = 1e-9;
const long double PI = acos(-1);

const int N = 1005;
const int NN = 1001;
const int MOD = 998244353;
const int IMAX = 1e9+7;
const ll LMAX = 1e15+7;
const int dx[4] = {0,0,-1,1};
const int dy[4] = {-1,1,0,0};

ll X, Y, Z, K;

int main () {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	// cout.precision(10); cout << fixed;

	cin >> X >> Y >> Z >> K;
	vector<ll> A(X), B(Y), C(Z);
	for (int i = 0; i < X; ++i)
		cin >> A[i];
	for (int i = 0; i < Y; ++i)
		cin >> B[i];
	for (int i = 0; i < Z; ++i)
		cin >> C[i];

	sort(A.rbegin(), A.rend());
	sort(B.rbegin(), B.rend());
	sort(C.rbegin(), C.rend());

	vector<ll> ans;
	for (int i = 0; i < X; ++i)
		for (int j = 0; j < Y; ++j)
			for (int k = 0; k < Z; ++k)
				if ((i+1)*(j+1)*(k+1) <= K)
					ans.push_back(A[i]+B[j]+C[k]);
				else
					break;

	sort(ans.rbegin(),ans.rend());

	for (int i = 0; i < K; ++i)
		cout << ans[i] << endl;

	return 0;
}

Measured memory_bytes: 4304
#include<bits/stdc++.h>
using namespace std;
int main(){
string S;
cin >> S;
int a_found = 0;
int z_found = 0;
for(int i = 0; i < S.size(); i++){
  if(S[i] == 'A') {
    a_found= i;
    break;
}
}
for(int i = 0; i < S.size(); i++){
  if(S[i] == 'Z') {
    z_found= i;
  }
}
    
cout << z_found - a_found +1 << endl;
}

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

using namespace std;

#define N 120000

int n,m,ans,a[N],d[N],f[N],q[N];

int main(){
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;++i) scanf("%d",a+i);
	if (a[1]!=1){++ans; a[1]=1;}
	for (int i=2;i<=n;++i) ++d[a[i]];
	int t=0,w=0;
	for (int i=2;i<=n;++i){
		if (!d[i]) q[++w]=i;
		f[i]=m;
	}
	++d[1];
	while (t<w){
		int x=q[++t];
		if (f[x]==1&&a[x]!=1) ++ans;
		else f[a[x]]=min(f[a[x]],f[x]-1);
		--d[a[x]];
		if (!d[a[x]]) q[++w]=a[x];
	}
	printf("%d\n",ans);
	
	return 0;
}
			

Measured memory_bytes: 1792
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n;
    cin>>n;
    map<int,int> m;
    for(int i=1;i<=n;i++)
    {
        m.insert(pair<int,int>(i,0));
    }
    int f;
    for(int i=1;i<n;i++)
    {
        cin>>f;
        auto itr=m.find(f);
        itr->second++;
    }
    
    for(auto it=m.begin();it!=m.end();it++)
    {
        cout<<it->second<<endl;
    }

    return 0;
}


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

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(a) (a).begin(),(a).end()

template<typename T1, typename T2> inline void chkmin(T1 & x, const T2 & y) {if (y < x) x = y;}
template<typename T1, typename T2> inline void chkmax(T1 & x, const T2 & y) {if (x < y) x = y;}

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

void read() {
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
}

void run() {
	for (int i = k; i < n; i++) {
		if (a[i] > a[i - k]) {
			cout << "Yes\n";
		} else {
			cout << "No\n";
		}
	}
}

void write() {

}

signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0), cout.precision(20), cout.setf(ios::fixed);
	read();
	run();
	write();
	return 0;
}

Measured memory_bytes: 4392
#include <stdio.h>

int n, c[510], s[510], f[510];
long long st = 0, time = 0;
int main(){
    scanf("%d", &n);
    for(int i=0; i<n-1; i++){
        scanf("%d %d %d", &c[i], &s[i], &f[i]);
    }

    for(int i=0; i<n-1; i++){
        time = 0;
        for( int j=i; j<n-1; j++){
            if(time < s[j]){
                time = s[j];
            } else {
                if(time%f[j] != 0){
                    int num = f[j];
                    while(num < time){
                        num+=f[j];
                    }
                    //printf("...%d...", num);
                    time += (num-time);
                }
            }

            time += c[j];

        }
        printf("%d\n", time);
    }
    printf("0\n");
}


Measured memory_bytes: 128
import java.util.*;
public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		long X = sc.nextLong();
		long count = 0;
		long fifhund = X / 500;
		long fif = (X - 500 * fifhund) / 5;
		count = fifhund * 1000 + fif * 5;
		System.out.println(count); 
	}	
}

Measured memory_bytes: 22356
S = input()
con = "KIHBR"
cnt1 = 0
cnt2 = 0
flag = True
for i in S:
    if cnt1 < 5 and i==con[cnt1]:
        cnt1+=1
        cnt2=0
    elif i=="A":
        if cnt1==1 or cnt1==2:
            flag = False
            break
        cnt2+=1
        if cnt2==2:
            flag = False
            break
    else:
        flag = False
        break
print("YES") if flag and cnt1==5 else print("NO")

Measured memory_bytes: 3064
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
using namespace std;

#define re_ return
#define in_ inline
#define op_ operator
#define inc(l, i, r) for(i=l; i<r; ++i)
#define st_ static
typedef long long ll;

const int mxn=1<<9;

int n, m, a[mxn], b[mxn<<1], cnt[2], h[mxn<<1];
struct edge{int v, o;} e[1<<20];

in_ ll dP(ll a, ll b, ll p)
{
    st_ ll r;
    for(r=1; b; a=a*a%p, b>>=1)
        b&1? r=r*a%p: 0;
    re_ r;
}

in_ char chk(ll a, ll p)
{
    st_ ll s, r, i;
    for(r=p-1, s=0; ~r&1; ++s, r/=2);
    if(i=dP(a, r, p), i==1 || i==p-1) re_ 1;
    for(;s--;)
        if((i=i*i%p)==p-1) re_ 1;
    re_ 0;
}

in_ char isP(int p)
{
    if(p==2) re_ 1;
    if(p==1 || ~p&1) re_ 0;
    st_  int i;
    inc(0, i, 48)
        if(!chk(rand()%(p-2)+1, p))
            re_ 0;

//    for(i=2; i*i<=p; ++i)
//        if(p%i==0)
//            re_ 0;
    re_ 1;
}

in_ void aE(int u, int v)
{
    st_ int tot;
    e[++tot]=(edge){v, h[u]}, u[h]=tot;
}

char vis[mxn<<1];
char Hun(int u)
{
    st_ int f[mxn<<1];
    int i, v;
    for(i=u[h]; v=i[e].v; i=i[e].o)
        if(!vis[v])
            if(vis[v]=1, !f[v] || Hun(f[v]))
            re_ f[v]=u, 1;
    re_ 0;
}

int main()
{
    srand(998244353);
    int i, j;
    scanf("%d", &n);
    inc(0, i, n)
        scanf("%d", a+i);
    sort(a, a+n);
    inc(0, i, n)
    {
        if(!i || a[i]>a[i-1]+1)
            b[++m]=a[i], ++cnt[a[i]&1];
        if(i>n-2 || a[i]<a[i+1]-1)
            b[++m]=a[i]+1, ++cnt[a[i]+1&1];
    }
    inc(1, i, m+1)
        if(b[i]&1)
            inc(1, j, m+1)
                if(~b[j]&1 && isP(abs(b[i]-b[j])))
                    aE(i, j);

    j=0;
    inc(1, i, m+1)
        if(b[i]&1)
            memset(vis, 0, sizeof(vis)),
                j+=Hun(i);

    printf("%d\n", cnt[0]+cnt[1]-j+(cnt[0]-j&1));
//    printf("%d\n", m);
//    for(;;) scanf("%d", &i), printf("%d\n", isP(i));
    0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int
cmp_int(const void *a, const void *b)
{
	if (*(int *)a > *(int *)b) return 1;
	if (*(int *)a < *(int *)b) return -1;
	return 0;
}

int
main()
{
	int a[3];	
	scanf("%d %d %d", &a[0], &a[1], &a[2]);

	qsort(a, 3, sizeof(int), cmp_int);
	printf("%d %d %d\n", a[0], a[1], a[2]);

	return 0;
}

Measured memory_bytes: 600
#pragma once

#include <bits/stdc++.h>

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;

#define rep(a,n) for(int a = 0;a < n;a++)
#define repi(a,b,n) for(int a = b;a < n;a++)

const ull mod = 1000000007;

int main(void)
{
	ll n;
	cin >> n;
	if (n % 2 == 1) {
		cout << 0 << endl;
		return 0;
	}
	n = n / 2;
	ll sum = 0;
	ll div = 5;
	while (div <= n) {
		sum += n / div;
		div *= 5;
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 384
from itertools import accumulate
N,K = map(int,input().split())
S = input()

memo = [0]
run = 0
turn = '1'

for s in S:

    if s == turn:
        run += 1
    else:
        turn = s
        memo.append(run)
        run = 1

memo.append(run)
if turn == '0':
    memo.append(0)


if len(memo) > K*2+1:
    memo = list(accumulate(memo))
    res = max(x-y for x,y in zip(memo[K*2+1::2], memo[:-(K*2+1):2]))
else:
    res = N
print(res)

Measured memory_bytes: 7924
import sys
n,m=map(int,input().split())
number=[0]*n
for i in range(m):
    s,c=map(int,input().split())
    if s==1 and c==0 and n!=1:
        print(-1)
        sys.exit()
    if number[s-1]==0:
        number[s-1]=c
    elif number[s-1]==c:
        continue
    else:
        print(-1)
        sys.exit()
if number[0]==0 and n!=1:
    number[0]=1
answer=''
for i in range(len(number)):
    answer+=str(number[i])
print(int(answer))

Measured memory_bytes: 3064
#include<stdio.h>
int main(){
	int N,a[100],i,j;
	int Alice=0,Bob=0,tmp;
	scanf("%d",&N);
	for(i=0;i<N;i++){
		scanf("%d",&a[i]);
	}
	for(i=0;i<N;i++){
		tmp=0;
		for(j=0;j<N;j++){
			if(a[j]>a[tmp]){
				tmp=j;
			}
		}
		Alice+=a[tmp];
		i++;
		a[tmp]=0;
			tmp=0;
		for(j=0;j<N;j++){
			if(a[j]>a[tmp]){
				tmp=j;
			}
		}
		Bob+=a[tmp];
		a[tmp]=0;
	}
	printf("%d",Alice-Bob);
	return 0;
}

Measured memory_bytes: 128
#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <set>
#include <numeric>
#include <bitset>
#include <map>
#include <limits.h>
#include <iomanip>
using namespace std;
typedef unsigned long ul;
typedef pair<ul, ul> P;
const int INF = 1e9;
 
long long gcd(long long x, long long y){
			if (x==0)return y;
      if(y==0)return x;
      if(x<y){
				long long temp = x;
			x = y;
				y = temp;
			}
			long long r = x % y;
				while(r!=0){
					x = y;
					y = r;
				r = x % y;
	    		}
			return y;
	    }


int main(){
	int N,P;
	cin >> N >> P;
	cout << ((3*N)+P)/2 << endl;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define forx(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;

int main()
{
    ll x, y, ans = 0;
    cin >> x >> y;

    if (x * y < 0)
        ans = 1 + abs(x + y);
    else if (y >= x)
        ans = y - x;
    else if (x * y == 0)
        ans = 1 + x - y;
    else
        ans = x - y + 2;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <numeric>
#include <iomanip>

using namespace std;
long long A[400];
long long B[400];
const long long MOD = 1000000007;
long long dp[400][401];
long long powers[401][401];
long long power_cum_sum[401][401];
int main(){
    int N;
    int C;
    cin >> N >> C;
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    for(int i = 0; i < N; i++){
        cin >> B[i];
    }
    
    for(int i = 0; i <= 400; i++){
        powers[i][0] = 1;
        for(int j = 1; j <= 400; j++){
            powers[i][j] = (i * powers[i][j - 1]) % MOD;
            //x_power[i][j] = (x_power[i][j - 1] * A[i]) % MOD;
        }
    }
    
    for(int i = 0; i <= 400; i++){
        power_cum_sum[i][0] = powers[0][i];
        for(int j = 1; j <= 400; j++){
            power_cum_sum[i][j] = (power_cum_sum[i][j - 1] + powers[j][i]) % MOD;
        }
    }
    dp[0][0] = B[0] - A[0] + 1;
    for(int i = 1; i <= C; i++){
        dp[0][i] = ((((power_cum_sum[i][B[0]] - power_cum_sum[i][A[0] - 1]) % MOD) + MOD) % MOD);
    }
    for(int i = 1; i < N; i++){
        for(int j = 0; j <= C; j++){
            for(int k = 0; k <= j; k++){
                //cout << k << endl;
                //cout << k << " "  << A[i] << " " << power_cum_sum[k][B[i]] << " " << power_cum_sum[k][A[i] - 1] << endl;
                dp[i][j] = (dp[i][j] + (dp[i - 1][j - k] * (((power_cum_sum[k][B[i]] - power_cum_sum[k][A[i] - 1]) % MOD + MOD) % MOD)) % MOD) % MOD;
            }
        }
    }
    cout << dp[N - 1][C] << endl;
    /*
    for(int j = 0; j < N; j++){
        for(int i = 0; i <= C; i++){
            cout << dp[j][i] << " ";
        }
        cout << endl;

    }
    */
    return 0;
}


Measured memory_bytes: 3968
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>

#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define repf(i, a, b) for (int i = (int)a; i < (int)b; i++)
#define repv(x, arr) for (auto &x : arr)
#define all(v) (v).begin(), (v).end()
#define vec(name, num) vector<ll> name((num), 0);
#define mp(a, b) make_pair(a, b)
#define op(i) cout << (i) << endl;
#define F first
#define S second

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;

const ll mod = 1e9 + 7;
const ll infl = 1e17;

typedef unsigned long long ull;




int main()
{
    ll n, k;
    cin >> n >> k;
    ll root = 1;
    while (root*root<=n){
        root++;
    }
    root--;
    //cout << 2*root+1 << endl;
    vector<vector<ll>> dp(k + 1, vector<ll>(2*root+1, 0));
    vector<ll> num(2 * root + 1, 0);
    repf(i, 1, root + 1) num[i] = 1;
    ll bef = root;
    repf(i,root+1,2*root+1){
        num[i] = n / (2*root+1-i) - bef;
        bef = n / (2*root+1-i);
    }

    //repf(i, 1, 2 * root + 1) cout << num[i] << " ";
    //cout << endl;
    dp[0][1] = 1;
    repf(j,1,1+k){
        ll s = 0;
        repf(i,1,2*root+1){
            s = (s + dp[j - 1][i])%mod;
            dp[j][2 * root + 1 - i] = s*num[2*root+1-i]%mod;
        }
    }
    ll ans = 0;
    /*repf(j,1,1+k){
        repf(i, 1, 2 * root + 1) cout << dp[j][i] << " ";
        cout << endl;
    } */
    repf(i, 1, 2 * root + 1) ans = (ans+dp[k][i])%mod;
    cout << ans << endl;
}


Measured memory_bytes: 50832
from sys import exit

N,M=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
A.sort()
B.sort()
A.append(M*N+1)
B.append(M*N+1)
for i in range(N):
    if A[i]==A[i+1]:
        print(0)
        exit()
for i in range(M):
    if B[i]==B[i+1]:
        print(0)
        exit()

t=10**9+7

def P(n,r):
    s=1
    for i in range(n-r+1,n+1):
        s*=i
    return s
def CP(n,r):
    return r*P(n-1,r-1)

c=0
r=0
n=0
f=False
ans=1
while True:
    if n>=M*N:
        print(ans%t)
        break
    if A[r]==B[c]:
        if N-r>B[c]-n:
            print(0)
            break
        ans = (ans*P(B[c]-n-1,N-r-1))%t
        c+=1
        n+=(N-r)
        f=True
    elif A[r]>B[c]:
        if N-r>B[c]-n:
            print(0)
            break
        if f:
            ans= (ans*P(B[c]-n,N-r))%t
            f=False
        else:
            ans = (ans*CP(B[c]-n,N-r))%t
        c+=1
        n+=(N-r)
    else:
        if M-c>A[r]-n:
            print(0)
            break
        if f:
            ans = (ans*P(A[r]-n,M-c))%t
            f=False
        else:
            ans = (ans*CP(A[r]-n,M-c))%t
        r+=1
        n+=(M-c)
        


Measured memory_bytes: 3188
#include <iostream>
#include <stack>
#include <string>
using namespace std;

int main() {
	string s;
	while(getline(cin,s), s != ".") {
		stack<char> sk;
		bool flg = true;
		for(int i = 0; i < s.size(); i++) {
			if(s[i] == '(' || s[i] == '[') {
				sk.push(s[i]);
			}
			else if(s[i] == ')') {
				if(!(sk.size() && sk.top() == '(')) {
					flg = false;
					break;
				}
				sk.pop();
			}
			else if (s[i] == ']') {
				if(!(sk.size() && sk.top() == '[')) {
					flg = false;
					break;
				}
				sk.pop();
			}
		}
		if(sk.size()) flg = false;

		cout << (flg ? "yes" : "no" ) << endl;
	}
}

Measured memory_bytes: 3164
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

// (i - j + 1) * 2 > (a[i] - arr[j] + 1)
// (2i - a[i]) + 1 > (2j - a[j])
// (2j - a[j]) < (2i - a[i] + 1)
int main() {
    string s;
    cin >> s;
    unordered_map<char, vector<int>> cnt;
    for(int i = 0; i < s.size(); i++) {
        cnt[s[i]].push_back(i+1);
    }
    for(auto p: cnt) {
        auto& vec = p.second;
        map<int, int> pos;
        for(int i = 0; i < vec.size(); i++) {
            int key = i*2 - vec[i];
            auto it = pos.lower_bound(key+1);
            if (it != pos.begin()) {
                cout << prev(it)->second << " " << vec[i];
                return 0;
            }
            pos[key] = vec[i];
        }
    }
    cout << "-1 -1" << endl;
    return 0;
}




Measured memory_bytes: 2508
N = int(input())
if N == 1:
    print("0")
    exit()
def f(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

temp = f(N)
ans = 0
for x in temp:
    i = 0
    temp2 = x[1]
    while(temp2 > 0):
        i += 1
        temp2 -= i
        if temp2 >= 0:
            ans += 1

print(ans)

Measured memory_bytes: 9496
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX
#define INFL LLONG_MAX
typedef long long ll;
using namespace std;

int main(){
  ll n; cin >> n;
  vector<ll> name(5,0);

  rep(i,n){
    string s; cin >> s;
    switch(s.at(0)){
      case 'M':
        name.at(0)++;
        break;
      case 'A':
        name.at(1)++;
        break;
      case 'R':
        name.at(2)++;
        break;
      case 'C':
        name.at(3)++;
        break;
      case 'H':
        name.at(4)++;
        break;
    }
  }

  ll ans = 0;
  for(int i=0;i<3;i++){
    for(int j=i+1;j<4;j++){
      for(int k=j+1;k<5;k++){
        ans += name.at(i)*name.at(j)*name.at(k);
      }
    }
  }

  cout << ans << endl;

}


Measured memory_bytes: 3588
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <math.h>
#include <numeric>
#include <iomanip>
#include <climits>
using namespace std;
int main(){
  long long int n,d;
  cin >> n >> d;
  int count=0;
  long long int x=0,y=0;
  long long int dd=d*d;
  for(int i=0;i<n;i++){
    cin >> x >> y;
    long long int delta = x*x+y*y;
    if(dd-delta>=0)count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 3624
#include <stdio.h>
#include <iostream>
#include <vector>
using namespace std;


int main()
{
    int N, num;
    int sum = 0;
    vector<int> L;

    // input
    cin >> N;

    for (int i = 0 ; i < 2*N ; i++)
    {
        cin >> num;
        L.push_back(num);
    }

    sort(L.begin(), L.end());
    for (int i = 0 ; i < N ; i++)
    {
        sum += L[2*i];
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
sum_otoshidama = 0
for _ in range(N):
    x, u = input().split()
    if u == 'JPY':
        sum_otoshidama += float(x)
    elif u == 'BTC':
        sum_otoshidama += (float(x) * 380000)
print(sum_otoshidama)


Measured memory_bytes: 2940
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';

int main() {
    ll n,x;
    cin>>n;
    string s="second";
    rep(i,n){
        cin>>x;
        if(x%2!=0)s="first";
    }
    cout<<s<<endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvl = vector<vector<long>>;
using pii = pair<int, int>;
using pil = pair<int, long>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,s,t) for(int i=s; i<t; i++)
#define RNG(i,s,t,u) for(int i=s; i<t; i+=u)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()

int main(){
  int n,k;
  cin >> n >> k;
  vl h(n);
  rep(i,n) cin >> h[i];
  vl dp(n+1,1e16);
  dp[0] = 0;
  rep(i,n-1){
    for(int j=1;j<=k;j++){
      if(i+j >= n) break;
      dp[i+j] = min(dp[i+j], dp[i] + abs(h[i]- h[i+j]));
    }
  }
  cout << dp[n-1] << endl;
}

Measured memory_bytes: 4772
#include <bits/stdc++.h>
using namespace std;
#define MAX_N 100000
#define MAX_M 100000
#define vec vector<int>
#define vecst vector<string>
#define vecch vector<char>
#define vecf vector<float>
#define vecvec vector<vector<int>>
using ll=int long long;
const int INF = 1e9;
#define PI 3.141592653589793
// cout << setprecision(15) << std::fixed;

int main(){
  int sec=0;
  for(int i=0;i<4;i++){
    int a;
    cin>>a;
    sec+=a;
  }
  cout<<sec/60<<endl;
  cout<<sec%60<<endl;
}




Measured memory_bytes: 3084
<?php
fscanf(STDIN, "%s", $string);
$result = '';
for($i = 0; $i < strlen($string); $i++) {
    $result = $result . $string[$i];
    if ($string[$i] == 'B') {
        $result = substr($result, 0, strlen($result) - 2);
    }
}
echo $result;
?>

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

int main() {
  int a, b; cin >> a >> b;
  if (a + b == 15) {
    cout << '+' << endl;
  }
  else if (a * b == 15) {
    cout << '*' << endl;
  }
  else {
    cout << 'x' << endl;
  }
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)

int L[10];
int N, A, B, C;
ll ans;

void dfs(string s, int n){
    if(n == N) {
        ll num = 0;
        ll X,Y,Z;
        X = Y = Z = 0;
        int mx, my, mz;
        mx = my = mz = -1;
        for(int i = 0; i < N; i++){
            int c = s[i] - '0';
            if(c == 1){
                X += L[i];
                mx++;
            }
            else if(c == 2){
                Y += L[i];
                my++;
            }
            else if(c == 3){
                Z += L[i];
                mz++;
            }
        }
        if(mx == -1 || my == -1 || mz == -1)
            return;

        num += 10*(mx+my+mz);
        int arr[3] = {C, B, A};
        ll tmp = num;
        do{
            num = tmp;
            num += abs(arr[0]-X);
            num += abs(arr[1]-Y);
            num += abs(arr[2]-Z);
            ans = min(ans, num);
        }while(next_permutation(arr, arr+3));
    }
    else{
        dfs(s+"0", n+1);
        dfs(s+"1", n+1);
        dfs(s+"2", n+1);
        dfs(s+"3", n+1);
    }

}

int main(){
    cin >> N >> A >> B >> C;
    REP(i,N){
        int l;
        cin >> l;
        L[i] = l;
    }

    ans = LLONG_MAX;
    dfs("", 0);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
from math import factorial
import numpy as np

stdin = sys.stdin

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split())) # applies to numbers only
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

def cumprod(arr, MOD):
    L = len(arr); Lsq = int(L**.5+1)
    arr = np.resize(arr, Lsq**2).reshape(Lsq, Lsq)
    for n in range(1, Lsq):
        arr[:, n] *= arr[:, n-1]; arr[:, n] %= MOD
    for n in range(1, Lsq):
        arr[n] *= arr[n-1, -1]; arr[n] %= MOD
    return arr.ravel()[:L]

def make_fact(U, MOD):
    x = np.arange(U, dtype=np.int64); x[0] = 1
    fact = cumprod(x, MOD)
    x = np.arange(U, 0, -1, dtype=np.int64); x[0] = pow(int(fact[-1]), MOD-2, MOD)
    fact_inv = cumprod(x, MOD)[::-1]
    return fact, fact_inv

U = 10**6
MOD = 10 ** 9 + 7
fact, fact_inv = make_fact(U, MOD)
N, K = rl()
A = rl()
A.sort()
min = A[0]
A = [(x - min)%MOD for x in A]
#最大値として何回登場するか
count = 0

for i in range(K-1, N):
    # A[i] * iC(k-1)
    count += A[i] * fact[i] % MOD * fact_inv[K-1] % MOD * fact_inv[i-(K-1)] % MOD
    count %= MOD
for i in range(N-K+1):
    # A[i] * (N-(i+1)) C (k-1)
    count -= A[i] * fact[N-(i+1)] % MOD * fact_inv[K-1] % MOD * fact_inv[N-(i+1)-(K-1)] % MOD
    count %= MOD

print(count)


Measured memory_bytes: 54748
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {

	vector<int> a(3);

	for (int i = 0; i < 3; i++) {
		cin >> a[i];
	}

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

	cout << a[0] * a[1] / 2 << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#define ll long long int
#define ld long double
#define INF 1000000000
#define EPS 0.0000000001
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;
typedef pair<int, int> pii;

int main()
{
  int n,m,p,x;
  int num[105]={};
  int i;

  while(1){
    cin>>n>>m>>p;
    if(n==0 && m==0 && p==0)break;
    ll sum=0LL;
    rep(i,n){
      cin>>x;
      num[i+1]=x;
      sum+=x;
    }
    sum=sum*(100-p);
    if(num[m])
      cout<<sum/num[m]<<endl;
    else 
      cout<<"0"<<endl;
  }

}

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

template<class T>
void chmin (T &a, T b) {
    if (a > b) a = b;
}

long long a, b, c, d;
map<long long, long long> mp;
const long long INF = (1LL << 60);

long long dfs (long long n) {
    if (n == 0) return 0;
    if (n == 1) return d;
    if (mp.count(n)) return mp[n];
    long long ret = INF;
    if (n < INF / d) chmin(ret, n * d);
    for (int i = 0; i < 3; i++) {
        long long t = vector{2LL, 3LL, 5LL}[i];
        long long cost = vector{a, b, c}[i];
        if (n % t == 0) {
            chmin(ret, cost + dfs(n / t));
        } else {
            long long l = n / t * t, r = l + t;
            chmin(ret, cost + d * (n - l) + dfs(n / t));
            chmin(ret, cost + d * (r - n) + dfs(n / t + 1));
        }
    }
    return mp[n] = ret;
}

int main() {
    int t;
    cin >> t;
    while (t--) {
        long long n;
        cin >> n >> a >> b >> c >> d;
        cout << dfs(n) << '\n';
        mp.clear();
    }
    return 0;
}

Measured memory_bytes: 4392
#include<iostream>
using namespace std;
int h[101]={};
bool isfin(){
  for(int i=0;i<101;++i)
	if(h[i])return true;
  return false;
}
int main(){
  int n;cin>>n;;
  for(int i=0;i<n;++i)cin>>h[i];
  int ans=0;
  int i=-1;
  while(isfin()){
	++i;
	if(i>n)i=0;
	if(h[i]==0)continue;
	while(i<n&&h[i]>0){
	  h[i]--;
	  ++i;
	}
	ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include <set>
long long A,B,K;
using namespace std;
int main(){
	cin>>A>>B>>K;
	//分为三种情况
	set<int> s;
	if(B-A+1<K){
		for(int i=A;i<=B;i++){
			cout<<i<<endl;
		}
	}else{
		
	for(int i=A;i<A+K;i++){
		s.insert(i);
	}
	for(int i=B-K+1;i<=B;i++){
		s.insert(i);
	}
	for(set<int>::iterator it = s.begin(); it!= s.end(); it++){
		cout<<*it<<endl;
	}
	}
	return 0;
} 

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
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
 *
 * @author HossamDoma
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        public void solve(int testNumber, InputReader in, PrintWriter out) {

            int n = in.nextInt();

            int[][] a = new int[n + 1][n + 1];
            for (int i = 1; i <= n; ++i) {
                for (int j = 1; j <= n; ++j) {
                    a[i][j] = in.nextInt();
                }
            }

            boolean[][] bad = new boolean[n + 1][n + 1];

            for (int i = 1; i <= n; ++i) {
                for (int j = 1; j <= n; ++j) {
                    for (int k = 1; k <= n; ++k) {
                        if (i == k || j == k) continue;
                        if (a[i][j] > a[i][k] + a[k][j]) {
                            out.println(-1);
                            return;
                        } else if (a[i][j] == a[i][k] + a[k][j])
                            bad[i][j] = true;
                    }
                }
            }


            long ans = 0;
            for (int i = 1; i <= n; ++i) {
                for (int j = i + 1; j <= n; ++j) {
                    if (bad[i][j]) continue;
                    else ans += a[i][j];
                }
            }

            out.println(ans);


        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;
        public String test_string;

        public InputReader(InputStream test_stringeam) {
            reader = new BufferedReader(new InputStreamReader(test_stringeam), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    String line = null;
                    if (test_string != null) {
                        line = test_string;
                        test_string = null;
                    } else
                        line = reader.readLine();

                    tokenizer = new StringTokenizer(line);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}



Measured memory_bytes: 32900
#Coding:Utf-8

N,Q=input().split()
S=input()
S= S.replace("AC","Ac")


def judge(x):
  if x=="c":
    return 1
  else:
    return 0


t=[]
t.append(0)

for i in range(1,int(N)):
  t.append(t[i-1]+judge(S[i]))

for j in range(int(Q)):
  a,b=list(map(int, input().split()))
  print(t[b-1]-t[a-1])

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

int main(){
  int n;cin >> n;
  int h[n];rep(i,n)cin >> h[i];
  int dp[n];//dp[i] iにたどり着く最小コスト
  dp[0] = 0;dp[1] = abs(h[1]-h[0]);
  for(int i=2;i<n;++i){
    dp[i] = min(dp[i-2]+abs(h[i]-h[i-2]),dp[i-1]+abs(h[i]-h[i-1]));
  }
  cout << dp[n-1] << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
using namespace std;

int main() {

    long long int n;
    cin >> n;

    for ( long long int i = 1; i < 10; i++ ) {
        long long int k = n / i;
        if ( k * i == n && k < 10 ) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
    return 0;

    return 0;

}


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

using namespace std;

typedef long long I64;

const int NMAX = 10;

int d[NMAX+2], N,K;

int main() {
    cin >> N >> K;
    d[0] = 1;
    for( int i = 1;  i <= N;  ++i ) {
        d[i] = min( d[i - 1] + d[i - 1], d[i - 1] + K );
    }
    cout << d[N] << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <vector>
#include <map>
#include <utility>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <string>
#include <limits.h>
#include <algorithm>

using namespace std;


int main(){
    
    int n;
    cin >> n;
    int ct[26];
    for (int i = 0; i < 26; i++) {
        ct[i] = 1 << 30;
    }
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        int count[26] ={0};
        for (int a = 0; a < s.size(); a++) {
            count[s[a]-'a']++;
        }
        for (int a = 0; a < 26; a++) {
            ct[a] = min(ct[a],count[a]);
        }
    }
    for (int i = 0; i < 26 ; i++) {
        for (int j = 0; j < ct[i]; j++) {
            cout << (char)('a' + i);
        }
    }
    cout << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define mrep(i,from,n) for(int i = from; i < n; i++)
#define mreps(i,from,n) for(int i = from; i <= n; i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())
typedef long long ll;
typedef pair<ll, ll> P;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
ll mod = 1000000007;

void solve()
{
	ll n,c,k; cin >> n>>c>>k;
	vector<ll> t(n);
	rep(i, n) cin >> t[i];
	sort(all(t));
	int ans = 0;
	rep(i ,n)
	{
		int last = i;
		ll end = t[i] + k;
		while (i+1 < n && t[i+1] <= end && i+1 - last < c)i++;
		ans++;
	}
	cout << ans << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 1024
import sys
input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''
N = int(input())
a, b, c = [0] * N, [0] * N, [0] * N
dp = [[0] * 3 for _ in range(N)]

for i in range(N):
    a[i], b[i], c[i] = map(int, input().split())

dp[0][0] = a[0]
dp[0][1] = b[0]
dp[0][2] = c[0]

for i in range(1, N):
    dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a[i]
    dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + b[i]
    dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c[i]

ans = max(dp[-1][0], dp[-1][1], dp[-1][2])
print(ans)


Measured memory_bytes: 57324
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int x = sc.nextInt();
		int[] array = new int[n];
		Arrays.fill(array, 0);
		for(int i = 0; i < m; i++) array[sc.nextInt()] = 1;
		int[] cost = {0,0};
		for(int i = 0; i <= x;i++) cost[0] += array[i];
		for(int i = x; i < n;i++) cost[1] += array[i];
		System.out.println(Math.min(cost[0], cost[1]));
	}

}


Measured memory_bytes: 24276
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
typedef long long ll;


int main(){
    string s;cin>>s;
    ll n=s.size();
    map<char,ll> m;
    rep(i,0,n)m[s[i]]++;
    ll an=0;
    for(auto i:m){
        ll num=i.second;
        an+=(num-1)*num/2;
    }
    cout<<n*(n-1)/2-an+1<<endl;
}
    









Measured memory_bytes: 640
def main():
    N, K = map(int, input().split())
    R, S, P = map(int, input().split())
    T = input()

    score = 0
    scores = {
        'r': P,
        's': R,
        'p': S
    }

    for i in range(K):
        prev = ''
        for j in range(N//K+1):
            idx = j*K+i
            if idx >= N:
                break
            current = T[idx]
            if current != prev:
                score += scores[current]
                prev = current
            else:
                prev = ''
    print(score)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int test[200001];
int main() {
	long long n, a, sum = 0, num = 0; cin >> n;
	for (int h = 0; h < n; h++) {
		cin >> a;
		if (h == 0) { sum = a; }
		else if (h == 1) { num = a; }
		else if (sum >= num) {
			if (a > sum) {
				sum = a;
			}
			else if (a <= sum && a > num) {
				num = a;
			}
		}
		else if (sum < num) {
			if (a > num) {
				num = a;
			}
			else if (a <= num && a > sum) {
				sum = a;
			}
		}
		test[h] = a;
	}
	if (sum >= num) {
		for (int h = 0; h < n; h++) {
			if (test[h] == sum) {
				cout << num << endl;
			}
			else {
				cout << sum << endl;
			}
		}
	}
	if (sum < num) {
		for (int h = 0; h < n; h++) {
			if (test[h] == num) {
				cout << sum << endl;
			}
			else {
				cout << num << endl;
			}
		}
	}
	cin >> n;
}

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

int findSumOfDigits(int n) {
  int sum = 0;
  while(n > 0) {
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main() {
  int N;
  cin >> N;
  int min = 1000000;
  for(int i = 1; i < N; ++ i) {
    int A = i;
    int B = N - i;

    int sum = findSumOfDigits(A) + findSumOfDigits(B);
    if(sum < min) {
      min = sum;
    }
  }
  cout << min << endl;
}

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

const int maxn=100005;
using ll = long long;

int w[maxn],num[maxn];
int W,n;
ll dp[maxn], v[maxn];

void ZOP(int weight, int value) {
	for(int i = W; i >= weight; i--) {
		dp[i]=std::max(dp[i],dp[i-weight]+value);
	}
}

int main(int argc, char *argv[]) {  
	std::cin >> n >> W;
	for (int i = 0; i < n; i++) {
		std::cin >> w[i] >> v[i];
	}
	for (int i = 0; i < n; i++) {
		ZOP(w[i], v[i]);
	}
	ll ans = 0;
	for (int i = 0; i <= W; i++) {
		ans = std::max(dp[i], ans);
	}
	std::cout << ans << '\n';
}

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

signed main()
{
    int N,Q; cin>>N>>Q;
    string s; cin>>s;

    vint cnt(N+1);
    for(int i=1;i<N;i++){
        if(s[i-1]=='A' and s[i]=='C') cnt[i]=cnt[i-1]+1;
        else cnt[i]=cnt[i-1];
    }

//  REP(i,N) cout<<cnt[i]<<' '; cout<<endl;

    while(Q--){
        int l,r; cin>>l>>r; l--,r--;
        if(l==0) cout<<cnt[r]<<endl;
        else{
            if(s[l-1]=='A' and s[l]=='C') cout<<cnt[r]-cnt[l-1]-1<<endl;
            else cout<<cnt[r]-cnt[l-1]<<endl;
        }
    }
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define pb push_back
#define pf push_front

namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;

typedef pair<int, int> P;

bool ps1(const P &forall_a_in_P, const P &forall_b_in_P)
{ //first昇順
	return forall_a_in_P.first < forall_b_in_P.first;
}
bool ps2(const P &forall_a_in_P, const P &forall_b_in_P)
{ //first降順
	return forall_a_in_P.first > forall_b_in_P.first;
}
bool ps3(const P &forall_a_in_P, const P &forall_b_in_P)
{ //second昇順
	return forall_a_in_P.second < forall_b_in_P.second;
}
bool ps4(const P &forall_a_in_P, const P &forall_b_in_P)
{ //second降順
	return forall_a_in_P.second > forall_b_in_P.second;
}
int main(){
	int n;
	cin>>n;
	vector<int>a(n);
	rep(i,n)cin>>a[i];
	deque<int>mi,pl;
	ll mis=0,pus=0;
	rep(i,n){
		if(a[i]<0){
			mi.pb(a[i]);
		}else{
			pl.pb(a[i]);
		}
	}
	deque<pair<int,int>>menu;	
	if(mi.size()>0&&pl.size()>0){

	}else if(mi.size()==0){
		sort(all(pl));
		mi.push_back(pl[0]);
		pl.pop_front();

	}else{
		sort(all(mi),greater<int>());
		pl.push_back(mi[0]);
		mi.pop_front();
	}
	while(pl.size()!=1){
		menu.push_back(make_pair(mi[0],pl.front()));
		mi[0]=mi[0]-pl.front();
		pl.pop_front();
	}
	while(mi.size()!=0){
		menu.push_back(make_pair(pl.front(),mi.front()));
		pl.front()=pl.front()-mi.front();
		mi.pop_front();
	}
	cout<<pl.front()<<endl;
	rep(i,n-1){
		cout<<menu[i].F<<" "<<menu[i].S<<endl;
	}
	
}


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

#define debug(s) cout << s << endl
#define debug1(s, t) cout << s << " " << t << endl
#define debug2(s, t, u) cout << s << " " << t << " " << u << endl
#define printvec(v)       \
    for (auto &&i : v)    \
        cout << i << " "; \
    cout << endl

using namespace std;
using i64 = long long;

int main()
{
    int n;
    cin >> n;
    vector<double> a(n);
    for (auto &&item : a)
    {
        cin >> item;
    }
    double d;
    for (auto &&ai : a)
    {
        d += 1.0/ai;
    }
    printf("%lf", 1.0/d);

    return 0;
}

Measured memory_bytes: 256
N = int(input())
x = []
y = []
h = []
for _ in range(N):
    xx,yy,hh = map(int,input().split())
    x.append(xx)
    y.append(yy)
    h.append(hh)
cm = 100
def dist(cx,cy,x,y):
    return(abs(cx-x)+abs(cy-y))
for cx in range(cm+1):
    for cy in range(cm+1):
        H = -1
        Hm = 10000000000
        contra = False
        for i in range(N):
            Hi = h[i] + dist(cx,cy,x[i],y[i])
            if h[i] == 0:
                Hm = min(Hi,Hm)
            else:
                if H == -1:
                    H = Hi
                else:
                    if H!=Hi:
                        contra = True
                        break
            if H > Hm:
                contra = True
                break
        if contra == False:
            print(cx,cy,H)                
            exit()    
                   

Measured memory_bytes: 3064