akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;

int main() {
    int N, M;
    cin >> N >> M;
    int A[N], sum = 0;
    for(int i = 0; i < N; i++) {
        cin >> A[i];
        sum += A[i];
    }
    int count = 0;
    for(int i = 0; i < N; i++) {
        if(A[i] * 4 * M >= sum) count++;
    }
    if(M <= count)
        cout << "Yes";
    else
        cout << "No";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF=1e9,MOD=1e9+7;
const long long LINF=1e18;
using namespace std;
#define int long long
//template
int pw(int n,int k){
  int res=1;
  while(k){
    if(k&1)res*=n;//res%=MOD;
    n*=n;//n%=MOD;
    k>>=1;
  }
  return res;
}
//main
signed main(){
  int N;string s;cin>>N>>s;
  string t=s.substr(0,N);
  string u=s.substr(N,N);reverse(u.begin(),u.end());
  typedef pair<string,string> P;
  map<P,int> m;
  int ans=0;
  for(int i=0;i<pw(2,N);i++){
    string tmp1,tmp2;
    int j=i;
    for(int k=0;k<N;k++){
      if(j&1)tmp1+=t[k];
      else tmp2+=t[k];
      j/=2;
    }
    m[P(tmp1,tmp2)]++;
  }
  for(int i=0;i<pw(2,N);i++){
    string tmp1,tmp2;
    int j=i;
    for(int k=0;k<N;k++){
      if(j&1)tmp1+=u[k];
      else tmp2+=u[k];
      j/=2;
    }
    ans+=m[P(tmp1,tmp2)];
  }
  cout<<ans<<endl;
}


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


typedef long long ll;

const int maxn=2e5+10;
int n, k;
int sum[maxn],c[maxn],p[maxn];
bool vis[maxn];

int main() 
{
    scanf("%d%d", &n, &k);
    for (int i = 1; i <= n; i++) scanf("%d", &p[i]);
    for (int i = 1; i <= n; i++) scanf("%d", &c[i]);
    ll ans = -1e18;
    for (int i = 1; i <= n; i++) 
	{
        int t = i;
        vector<int> v;
        ll sum = 0;
        while ( true ) 
		{
            v.push_back(c[p[t]]), sum += c[p[t]], t = p[t];
            if(t == i) break;
        }
        int tn = v.size();
        if( k <= tn || sum <= 0 ) 
		{
            ll tmp = 0;
            for ( int j = 0, z = 1; z <= k && j < tn; z++, j++ ) tmp += v[j], ans = max(tmp, ans);    
        }
        else 
		{
            ll tmp = 0;
            for ( int j = 0; j < tn; j++ ) 
			{
                tmp += v[j];
                ll r = (k - (j + 1)) / tn;
                ans = max(ans, tmp + r * sum);
            }
        }

    }
    printf("%lld\n", ans);
}


Measured memory_bytes: 3888
class LazySegTree: # Non Recursion, RmQ, RUQ
    def __init__(self, N):
        self.N = N
        self._N = 1<<((N-1).bit_length())
        self.INF = (1<<31) - 1
        self.node = [self.INF]*2*self._N
        self.lazy = [None]*2*self._N

    def build(self, lis):
        for i in range(self.N):
            self.node[i+self._N-1] = lis[i]
        for i in range(self._N-2,-1,-1):
            self.node[i] = self.node[i*2+1] + self.node[i*2+2]

    def _gindex(self, l, r):
        left = l + self._N; right = r + self._N
        lm = (left // (left & -left)) >> 1
        rm = (right // (right & -right)) >> 1
        while left < right:
            if right <= rm: yield right
            if left <= lm: yield left
            left >>= 1; right >>= 1
        while left:
            yield left
            left >>= 1

    def propagates(self, *ids): # ids: 1-indexded
        for i in reversed(ids):
            v = self.lazy[i-1]
            if v is None: continue
            self.lazy[2*i-1] = self.node[2*i-1] = v
            self.lazy[2*i] = self.node[2*i] = v
            self.lazy[i-1] = None
        return

    def update(self, l, r, x): # change all[left, right) to x
        *ids, = self._gindex(l, r)
        self.propagates(*ids)
        left = l + self._N; right = r + self._N
        while left < right:
            if left & 1:
                self.lazy[left-1] = self.node[left-1] = x
                left += 1
            if right & 1:
                right -= 1
                self.lazy[right-1] = self.node[right-1] = x
            left >>= 1; right >>= 1
        for i in ids:
            self.node[i-1] = min(self.node[2*i-1], self.node[2*i])

    def query(self, l, r):
        self.propagates(*self._gindex(l, r))
        left = l + self._N; right = r + self._N
        ret = self.INF
        while left < right:
            if right & 1:
                right -= 1
                ret = min(ret, self.node[right-1])
            if left & 1:
                ret = min(ret, self.node[left-1])
                left += 1
            left >>= 1; right >>= 1
        return ret

nm = lambda: map(int, input().split())
n,q = nm()
S = LazySegTree(n)
for _ in range(q):
  v = list(nm())
  if v[0]:
    # print(S.node)
    # print(S.lazy)
    print(S.query(v[1], v[2]+1))
  else:
  	S.update(v[1], v[2]+1, v[3])


Measured memory_bytes: 12024
S = input()
s1 = S[0]
out = 'No'
s1_list = list(filter(lambda x: x == s1, S))
if len(s1_list) == 2:
    s2_list = list(filter(lambda x: x != s1, S))
    if s2_list[0] == s2_list[1]:
        out = 'Yes'
print(out)

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

void input(int &n, vector<int> &a) {
    cin >> n;
    a.resize(n);
    rep(i,n) {
        cin >> a[i];
    }
}

int div(int n) { // 整数が2で割り切れる回数
    int count = 0;
    while (n % 2 == 0) {
        n /= 2;
        count++;
    }
    return count;
}

int main() {
    int n; vector<int> a;
    input(n, a);

    int sum = 0;
    rep(i,n) { //各要素の2で割り切れる回数の総和
        sum += div(a[i]);
    }
    cout << sum << endl;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#include <unistd.h>
#include <sys/time.h>
#include <stdlib.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P, ll> T;
 
long long int INF = 2e18;
const ll fact_table = 1200008;
double Pi = 3.1415926535897932384626;

priority_queue <ll> pql;
priority_queue <P> pqp;
priority_queue <P> bag;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop
 
ll dx[8]={1,0,-1,0,1,1,-1,-1};
ll dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//↓,→,↑,←

#define endl "\n"
#ifdef ENJAPMA
    #undef endl
#endif
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)(); 
#define pc(x) cout << x << ",";
 
const ll mod = 998244353ll;
// const ll mod = 1000000007ll;
  
ll mypow(ll number1,ll number2, ll mod){
    if(number2 == 0){
        return 1ll;
    }else{
        ll number3 = mypow(number1,number2 / 2, mod);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
void YES(bool condition){
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}
 
/*
ll fact[fact_table + 5],rfact[fact_table + 5]; 
 
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=fact_table; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[fact_table] = mypow(fact[fact_table],mod - 2, mod);
    for(ll i=fact_table; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod ) * rfact[n-r]) % mod;}
*/

bool multicase = false;

ll n,m,num,a,b,c,d,e,h,q;
ll w, k;

void solve(){
    cin >> n;
    vector<string> s;
    for(ll i=0;i<n;i++){
        string t;
        cin >> t;
        s.pb(t);
    }
    sort(s.begin(), s.end());
    ll ans = 0;
    for(ll i=0;i<s.size();i++){
        if(i == 0 || s[i] != s[i-1]){
            ans ++;
        }

    }
    p(ans);
    return;
}


int main(){
    // init();
    
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll q, testcase = 1;
    if(multicase){
        cin >> q;
    }else{
        q = 1; 
    }
    while(q--){
        // pu("Case ");pu("#");pu(testcase);pu(": ");
        solve();
        testcase++;
    }
    
    // solve();
    return 0;
}
















Measured memory_bytes: 11624
#include<bits/stdc++.h>
using namespace std;
int h,w,c,dx[4]={0,0,1,-1},dy[4]={1,-1,0,0};
vector<int> p(64);

int nu(int x,int y,int cl,int t){
  int res=1;
  p[y*w+x]=cl;
  for(int i=0;i<4;i++){
    int nx=x+dx[i],ny=y+dy[i];
    if(nx<0||w<=nx||ny<0||h<=ny||p[ny*w+nx]!=t||p[ny*w+nx]==cl)continue;
    res+=nu(nx,ny,cl,t);
  }
  return res;
}

int dfs(int d){
  if(d==4){
    nu(0,0,c,p[0]);
    return nu(0,0,7,p[0]);
  }
  vector<int> tp=p;
  int res=0;
  for(int j=1;j<7;j++){
    nu(0,0,j,p[0]);
    res=max(res,dfs(d+1)),p=tp;
  }
  return res;
}

int main(){
  while(cin>>h>>w>>c,h){
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++)cin>>p[i*w+j];
    cout<<dfs(0)<<endl;
  }
  return 0;
}

Measured memory_bytes: 3072
import sys, os, math, bisect, itertools, collections, heapq, queue, copy, array

# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
# from decimal import Decimal
# from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def get_depth(parent, node):
    depth = 0
    n = node
    while True:
        if parent[n] == -1: break
        n = parent[n]
        depth += 1

    return depth


def get_sibling(parent, tree, node):
    p = parent[node]
    if p == -1:
        return -1
    else:
        return tree[p][0] if tree[p][0] != node else tree[p][1]


def get_degree(tree, node):
    l, r = tree[node]
    ret = 0
    if l != -1: ret += 1
    if r != -1: ret += 1
    return ret


def get_height(tree, node):
    h1, h2 = 0, 0
    if tree[node][0] != -1:
        h1 = get_height(tree, tree[node][0]) + 1
    if tree[node][1] != -1:
        h2 = get_height(tree, tree[node][1]) + 1
    return max(h1, h2)


def get_type(parent, tree, node):
    type = ''
    if parent[node] == -1:
        type = 'root'
    elif tree[node][0] == -1 and tree[node][1] == -1:
        type = 'leaf'
    else:
        type = 'internal node'
    return type


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    parent = [-1] * N
    tree = collections.defaultdict(list)

    for n in range(N):
        id, l, r = il()
        tree[id] = [l, r]
        if l != -1:
            parent[l] = id
        if r != -1:
            parent[r] = id

    for node in range(N):
        print('node {0}: parent = {1}, sibling = {2}, degree = {3}, depth = {4}, height = {5}, {6}'.format(
            node, parent[node], get_sibling(parent, tree, node), get_degree(tree, node), get_depth(parent, node),
            get_height(tree, node), get_type(parent, tree, node)
        ))


if __name__ == '__main__':
    main()



Measured memory_bytes: 7124
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
typedef long long ll;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    vector<vector<int>> A(N, vector<int>(N));
    rep(i, N) rep(j, N) cin >> A[i][j];
    vector<vector<int>> d(N, vector<int>(N));
    d = A;
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < N; j++) {
            for(int k = 0; k < N; k++) {
                d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
            }
        }
    }
    ll res = 0;
    for(int i = 0; i < N; i++) {
        for(int j = i + 1; j < N; j++) {
            int dist = INF;
            for(int k = 0; k < N; k++) {
                if(k == i || k == j)
                    continue;
                dist = min(dist, d[i][k] + d[k][j]);
            }
            if(A[i][j] < dist) {
                res += A[i][j];
            } else if(A[i][j] == dist) {
            } else {
                cout << -1 << endl;
                return 0;
            }
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	static long count(int AB){
		int ret = 0;
		for(int a = 1 ; a * a <= AB ; ++a){
			if(AB % a == 0){
				int b = AB / a;
				if(a == b){
					++ret;
				}else{
					ret += 2;
				}
			}
		}
		return ret;
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long ret = 0;
		int AB[] = new int[N + 1];
		for(int A = 1 ; A <= N ; ++A){
			for(int ab = A ; ab <= N ; ab += A){
				AB[ab]++;
			}
		}
//		long ts = System.currentTimeMillis();
		for(int C = 1 ; C <= N ; ++C){
			int ab = N - C;
			ret += AB[ab];
		}
//		long te = System.currentTimeMillis();
//		System.out.println(te - ts);
		System.out.println(ret);
	}
}


Measured memory_bytes: 39520
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <math.h>
#include <map>
#include<cmath>
#include<queue>

typedef long long ll;
using namespace std;
#define mod 10007
#define rep(i,n) for(ll i=0;i<n;i++)

int main(void){
  int n;
  cin >> n;
  int ans;
  ans = n*n*n;

  cout << ans << endl;
  return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>

using namespace std;
typedef long long ll;
const int MAXN = 6005;
int n,mod;
ll f[MAXN][MAXN*2];

int main()
{
	cin >> n >> mod;
	f[0][MAXN] = 1;
	for(int i = 0; i<3*n; i++)
	    for(int j = MAXN-i; j<=MAXN+i; j++)
	    {
	    	f[i+1][j+1] = (f[i+1][j+1]+f[i][j])%mod;
	    	f[i+2][j-1] = (f[i+2][j-1]+f[i][j]*(i+1))%mod; 
		    f[i+3][j] = (f[i+3][j]+f[i][j]*(i+1)%mod*(i+2))%mod; 
		}
	ll ans = 0;
	for(int j = MAXN; j<MAXN*2; j++)
	    ans = (ans+f[3*n][j])%mod;
	cout << ans << endl;
	return 0;
}


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

int main()
{
    int h, w;
    cin >> h >> w;
    char s[h][w] = {};
    int dx[8] = {-1,-1,-1,0 ,0,1 ,1,1};
    int dy[8] = {-1,0 ,1 ,-1,1,-1,0,1};
    for(int i=0; i<h; i++)
        for(int j=0; j<w; j++) cin >> s[i][j];
        
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            if(s[i][j] == '#'){
                cout << '#';
                continue;
            }
            int tmp = 0;
            for(int di=0; di<8; di++){
                int x = i+dx[di];
                int y = j+dy[di];
                if(x>=0 && x<h && y>=0 && y<w && s[x][y] == '#') tmp++;
            }
            cout << tmp;
        }
        cout << endl;
    }
    return 0;
}


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


void solve(long long N, std::vector<long long> s){
  sort(s.begin(), s.end());
  long long acc = accumulate(s.begin(), s.end(), 0);

  if((acc % 10) != 0) {
    cout << acc << endl;
    return;
  }

  for(long long i = 0; i < N; i++){
    if((acc - s[i]) % 10 != 0) {
      cout << acc - s[i] << endl;
      return;
    }
  }

  cout << 0 << endl;
  return;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
  scanf("%lld",&N);
  std::vector<long long> s(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&s[i]);
  }
    solve(N, std::move(s));
    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    n,m,L=map(int,input().split())
    E=[[] for _ in range(n)]
    for _ in range(m):
        u,v,w=map(int,input().split())
        if(w>L): continue
        u-=1; v-=1
        E[u].append((v,w))
        E[v].append((u,w))

    # 各始点からの Dijkstra
    # dist は (補給回数、補給してからの使用料)
    A=[None]*n
    for s in range(n):
        dist=[(INF,INF)]*n
        dist[s]=(0,0)
        used=[0]*n
        for _ in range(n-1):
            v=min((dist[v],v) for v in range(n) if(not used[v]))[1]
            used[v]=1
            c,l=dist[v]
            for nv,w in E[v]:
                if(l+w>L):
                    nd=(c+1,w)
                else:
                    nd=(c,l+w)
                dist[nv]=min(dist[nv],nd)
        A[s]=dist

    for _ in range(int(input())):
        s,t=map(int,input().split())
        s-=1; t-=1
        res=A[s][t][0]
        print(res if(res!=INF) else -1)
resolve()

Measured memory_bytes: 82652
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const int INF=1e7;

map<LL,LL> mp;

int main(){
    int N,M;
    cin >> N;
    for(int i=0;i<N;i++){
        LL D;
        cin >> D;
        mp[D]++;
    }
    cin >> M;
    for(int i=0;i<M;i++){
        LL T;
        cin >> T;
        mp[T]--;
        if(mp[T]<0){
            puts("NO");
            return 0;
        }
    }
    puts("YES");
    return 0;
}


Measured memory_bytes: 12800
#include "bits/stdc++.h"
#define ll long long int
#define ld long double
#define fastIO ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define pb push_back

using namespace std;
typedef pair<int, int> pii;

vector<bool> vis;
vector<vector<int>> g;

int dfs(int node) {
    vis[node] = true;
    int children = 0;

    for (int i : g[node]) {
        if (!vis[i]) {
            children += 1 + dfs(i);
        }
    }
    return children;
}

int main() {
    fastIO;
    int n, m;
    cin >> n >> m;

    g = vector<vector<int>>(n);
    vis = vector<bool>(n, false);

    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        g[a].pb(b);
        g[b].pb(a);
    }

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


Measured memory_bytes: 23512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,x;
    cin>>n>>x;
    int arr[n],dp[n+1];
    dp[0]=0;
    for(int i=0;i<n;i++)cin>>arr[i];
    int i;
    for(i=1;i<=n;i++){
        dp[i]=dp[i-1]+arr[i-1];
        if(dp[i]>=x)break;
    }
    if(dp[i]>x||i==n+1)cout<<i;
    else
    cout<<i+1;
        
    
    return 0;
}

Measured memory_bytes: 256
r, g, b, n = map(int, input().split())

l = sorted([r, g, b])
x = l[0]
y = l[1]
z = l[2]

ans = 0

mz = n // z
for i in range(mz + 1):
    my = (n - z * i) // y
    for j in range(my + 1):
        if (n - z * i - y * j) % x == 0:
            ans += 1

print(ans)


Measured memory_bytes: 9048
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll/*, vl, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, n) for(ll i = 1; i <= ll(n); i++)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); i++)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); i++)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

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

  ll n, p=26, cnt=1;
  cin >> n;
  while(n>p) {n-=p; p*=26; cnt++;}
  n--;
  
  string s(cnt, 'a');
  rep(i, cnt) {s[i]+=n%26; n/=26;}
  reverse(all(s));
  cout << s << newl;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define rep(i,a) for(int i=0;i<a;i++)
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    if(n%2!=0){
        cout<<"No"<<endl;
        return 0;
    }
    else{
        n/=2;
        if(s.substr(0,n)==s.substr(n,n)){
            cout<<"Yes"<<endl;
            return 0;
        }
        else{
            cout<<"No"<<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
#define rep(i, n) for (int i = 1; i <= (int)(n); i++)

int main() {
  int n;
  cin >> n;
  int cnt = 0;
  rep(i, n) {
    string si = to_string(i);
    if (si.size() % 2 == 1) cnt++;
  }
  cout << cnt << endl;

}

Measured memory_bytes: 256
// -*- coding:utf-8-unix -*-

use proconio::input;

// ABC086C - Traveling
// https://atcoder.jp/contests/abs/fasks/arc089_a

fn main() {
    input! {
        n: usize,
    }
    let result = (1..n+1).filter(|x| x % 3 != 0 && x % 5 != 0 ).fold(0, |acc,x|acc + x );
    println!("{}",result);
}


Measured memory_bytes: 2156
#include <stdio.h>
int main(void){
  int N;
  int i,x,y,z;
  if(scanf("%d",&N)==1);
  int a[100000];
  for(x=1;x<=100;x++){
    for(y=1;y<=100;y++){
     for(z=1;z<=100;z++){
       int s;
       s=x*x+y*y+z*z+x*y+y*z+z*x;
       if(s>N){
         break;
       }
       a[s]++;
     }
    }
  }
  for(i=1;i<=N;i++){
    printf("%d\n",a[i]);
  }
  return 0;
}

  

Measured memory_bytes: 1672
#include <bits/stdc++.h>
using namespace std;
const long long int INF = 1000000000000000ll;
long long int f(long long int n, long long int b)
{
	if(n < b)
		return n;
	return f(n/b, b) + (n%b);
}
int main()
{
	long long int n,s;
	cin>>n>>s;
	long long int ans = INF;
	for (long long int b = 2; b*b - 1 < n; ++b)
	{
		if(f(n,b) == s)
			ans = min(ans, b);
	}
	for (long long int a1 = 1; a1*a1 <= n; ++a1)
	{
		long long int a0 = s - a1;
		if(a0 < 0)
			break;
		long long int b = (n - a0)/a1;
		if(a1 < b && a0 < b && a1*b + a0 == n)
			ans = min(ans, b);
	}
	if(n == s)
		ans = min(ans, n+1);
	if(ans == INF)
		ans = -1;
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(A) (A).begin(),(A).end()
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)

const ll mod = 1e9+7;
const ll INF = 2*1e18;
const int inf = 1e9+7;

using namespace std;

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	string s;
	cin >> s;
	for(int i=0;i<s.size();i++){
		int now = s[i] - 'A';
		now = (now + N) % 26;
		now = now + 'A';
		cout << (char)now;
	}
	cout << endl;
}

Measured memory_bytes: 256
dic = {'2':1, '3':2, '4':3, '5':4, '6':5, '7':6, '8':7, '9':8, '10':9, '11':10, '12':11, '13':12, '1':14}
a,b = map(str,input().split())

if dic[a] > dic[b]:
    print('Alice')
elif dic[a] == dic[b]:
    print('Draw')
else:
    print('Bob')

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <utility>

int main() {
  const uint32_t max = 100'000;
  std::pair<std::string, uint32_t> tasks[max];

  uint32_t n = 0, q = 0;
  std::cin >> n >> q;
  for (uint32_t i = 0; i < n; i++)
    std::cin >> tasks[i].first >> tasks[i].second;

  uint32_t tail = n, count = 0;
  for (size_t i = 0; i < tail; i++) {
    uint32_t roop_i = i % max;
    if (tasks[roop_i].second > q) {
      tasks[roop_i].second -= q;
      if (roop_i != tail % max) tasks[tail % max] = tasks[roop_i];
      tail++;
      count += q;
    } else {
      count += tasks[roop_i].second;
      std::cout << tasks[roop_i].first << " " << count << std::endl;
    }
  }

  return 0;
}


Measured memory_bytes: 7064
x,y = gets.chomp.split.map(&:to_i)
cards_force = [2,3,4,5,6,7,8,9,10,11,12,13,1]
a = cards_force.index(x)
b = cards_force.index(y)

if a < b
  puts "Bob"
elsif a == b
  puts "Draw"
else
  puts "Alice"
end

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

#if DEBUG && !ONLINE_JUDGE
    #include "header.h"
#else
    #define debug(args...)
#endif

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long lli;
typedef long double ld;

#define pb push_back
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x).size()
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b) for(auto i=(a);i<b;i++)

#define INF (int)1e9
#define EPS 1e-9
#define MOD 1000000007
void preprocess(void) {
    return;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.precision(20);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    preprocess();
    int n; cin>>n;
    vi dp(n+3,0);
    vi h(n+1);
    rep(i,1,n+1) cin>>h[i];
    dp[1] = 0;
    rep(i,2,n+1) {
        if(i==2) {
            dp[i] = dp[i-1] + abs(h[i] - h[i-1]);
            continue;
        }
        dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]));
    }
    debug(dp);
    cout<<dp[n]<<endl;
}



Measured memory_bytes: 1024
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n,a[3000],x,am[3000];
long long ans=0;
int main()
{
	scanf("%d%d",&n,&x);
	for (int i=1;i<=n;i++) scanf("%d",a+i),am[i]=a[i];
	for (int i=1;i<=n;i++) ans+=a[i];
	for (int i=1;i<n;i++)
	{
		long long tmp=0;
		for (int j=1;j<=n;j++) am[j]=min(am[j],a[(j+i-1)%n+1]),tmp+=am[j];
		tmp+=1ll*x*i;
		ans=min(ans,tmp);
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
const int N = 50 + 10;
int a[N];
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	sort(a, a + n);
	double ans = a[0];
	for (int i = 1; i < n; ++i)
		(ans += a[i]) /= 2.;
	cout << fixed << setprecision(10) << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define fi first
#define se second
using namespace std;
typedef pair<int,int> P;
const int M=1e5+10;
int n;
P m[2],s[2];
map<int,int> a[2];
void fm(int x)
{
    for(auto item: a[x])
    {
        if(item.se>m[x].se)
        {
            s[x]=m[x];
            m[x]=item;
        }
        else if(item.se>s[x].se)
            s[x]=item;
    }
}
int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        int x;
        scanf("%d",&x);
        a[i&1][x]++;
    }
    fm(0),fm(1);
    if(m[0].fi==m[1].fi)
        printf("%d\n",n-max(m[0].se+s[1].se,m[1].se+s[0].se));
    else
        printf("%d\n",n-m[0].se-m[1].se);
    return 0;
}



Measured memory_bytes: 4992
abc = list(map(int, input().split()))
abc.sort()
count = 0
count += int((abc[2]-abc[1])/2)
abc[1] += 2*int((abc[2]-abc[1])/2)

count += int((abc[2]-abc[0])/2)
abc[0] += 2*int((abc[2]-abc[0])/2)

if abc[2]*3-sum(abc) == 1:
	count += 2
elif abc[2]*3-sum(abc) == 2:
	count += 1

print(count)

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

int main(void){
  long long a, b, now = 0, old = 0;
  scanf("%lld",&a);
  scanf("%lld",&b);

  for (long long i = 1; i < 1001; i++) {
    if (now - b == old - a) {
      printf("%lld", old - a);
      return 0;
    }
    old = now;
    now += i;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()
#define let auto const

template<typename... Types>
struct dynarr: std::vector<Types...> {
  using std::vector<Types...>::vector;
  using size_type = typename std::vector<Types...>::size_type;
  auto&& operator[](size_type i) { return this->at(i); }
  auto&& operator[](size_type i) const { return this->at(i); }
};

int main() {
  i64 N;
  cin >> N;
  vector<i64> A(N + 1);
  vector<i64> B(N);
  rep(i,0,N + 1) cin >> A[i];
  rep(i,0,N) cin >> B[i];
  i64 ans = 0;
  rep(i,0,N) {
    i64 b = min(B[i], A[i]);
    B[i] -= b;
    A[i] -= b;
    ans += b;
    b = min(B[i], A[i + 1]);
    B[i] -= b;
    A[i + 1] -= b;
    ans += b;
  }
  cout << ans << endl;
}


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

#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define sortA(a) sort(a.begin(),a.end())
#define sortD(a) sort(a.begin(),a.end(),greater<int>())
typedef long long ll;
#define len(s) s.length()

void solve() {
    string s,t;
    cin>>s>>t;
    int sl = len(s);
    int st = len(t);
    if(st == sl+1)
    {
      rep(i,sl)
      {  if(s[i]==t[i])
          continue;
          cout<<"No";
          return;
      }
      cout<<"Yes";
    }
    else
      cout<<"No";
}


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin>>t;
    while(t--)
      solve();

	  return 0;
}


Measured memory_bytes: 3652
import java.util.*;
public class Main {
    
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        int N = 100000;
        Sieve sieve = new Sieve(N);
        int[] likes = new int[N+1];
        for (int i = 0; i < likes.length; i++) {
            if(i%2==1 && sieve.isPrime(i) && sieve.isPrime((i+1)/2)){
                likes[i] = 1;
            }
        } 
        int[] sump = new int[N+1];
        for (int i = 1; i < sump.length; i++) {
            sump[i] = sump[i-1] + likes[i];
        }
        // for (int i = 0; i < 15; i++) {
        //     System.out.print(prime.get(i));
        // }
        int Q = scanner.nextInt();
        int[] ls = new int[Q];
        int[] rs = new int[Q];
        for (int i = 0; i < Q; i++) {
            ls[i] = scanner.nextInt();
            rs[i] = scanner.nextInt();
        }
        for (int i = 0; i < Q; i++) {
            int left = ls[i]-1;
            int right = rs[i];
            System.out.println(sump[right] - sump[left]);
        }
    }
    public static class Sieve {
        private int n;
        private int[] f;
        public ArrayList<Integer> primes = new ArrayList<>();
        public Sieve(int N){
            n = N;
            f = new int[n+1];
            f[0] = -1; // 0 is not prime
            f[1] = -1; // 1 is not prime
            for(int i = 2; i <= N; i++){
                if(f[i]!=0) continue;
                primes.add(i);
                f[i] = i;
                for(int j = i+i; j<=n; j+=i){
                    if(f[j]==0) f[j] = i;
                }
            }
        }
        public boolean isPrime(int i){
            return (f[i]==i);
        } 
        public ArrayList<Integer> factorList(int i){
            ArrayList<Integer> res = new ArrayList<>();
            while(i != 1){
                res.add(f[i]);
                i /= f[i];
            }
            return res;
        }
        public HashMap<Integer, Integer> factorCount(int i){
            HashMap<Integer, Integer> res = new HashMap<>();
            while(i != 1){
                res.putIfAbsent(f[i], 0);
                res.put(f[i], res.get(f[i]) + 1);
                i /= f[i];
            }
            return res;
        }
    }
}



Measured memory_bytes: 88340
#include <cstdio>
#include <cstdlib>
#include <algorithm>

using namespace std;

int main(){
	long long a[100000];
	long n;

	long long s[100000];
	long long s2[100000];
	long long ans = 0;
	long long ans2 = 0;

	scanf("%ld",&n);
	for(long i=0;i<n;i++){
		scanf("%lld",&a[i]);
	}

	if(a[0]!=0){
		s[0] = a[0];
	}else{
		s[0] = 1;
		ans++;
	}
	for(long i=1;i<n;i++){
		s[i] = s[i-1]+a[i];
		if((s[i-1]>0&&s[i]<0)||(s[i-1]<0&&s[i]>0)){
			continue;
		}else{
			ans += abs( (-s[i-1]/abs(s[i-1])) -s[i] );
			s[i] = -s[i-1]/abs(s[i-1]);
		}
	}
//
	if(a[0]!=0){
		s2[0] = -a[0]/abs(a[0]);
		ans2 += abs(a[0]-s2[0]);
	}else{
		s2[0] = -1;
		ans2++;
	}
	for(long i=1;i<n;i++){
		s2[i] = s2[i-1]+a[i];
		if((s2[i-1]>0&&s2[i]<0)||(s2[i-1]<0&&s2[i]>0)){
			continue;
		}else{
			ans2 += abs( (-s2[i-1]/abs(s2[i-1])) -s2[i] );
			s2[i] = -s2[i-1]/abs(s2[i-1]);
		}
	}

	if(ans2<ans) ans = ans2;
//
	printf("%lld\n",ans);

	return 0;
}


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

int main(){
    int a, b, c;
    int num_div = 0;
    cin >> a >> b >> c;

    for(int i=a; i<=b; i++){
        if( (c%i)==0 ) num_div++;
    }
    cout << num_div << endl;
    return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;
using namespace __gnu_pbds;

typedef tree<pair<long long int,long long int> ,null_type,less<pair<long long int,long long int> >,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

bool check(long long int a)
{
    for(int i=2;i<=sqrt(a);i++)
    {
        if(a%i == 0)
            return 0;
    }
    return 1;
}
void go()
{
    long double a,b;
    cin>>a>>b;
    cout<<(long long int)(a*b);
}
int main()
{
    //FIO;
    //int t;
    //cin>>t;
    //while(t--)
        go();
    return 0;
}


Measured memory_bytes: 3748
#include<bits/stdc++.h>
using namespace std;
int n,x,dp[3][101];

int main(){
	cin>>n;
	memset(dp,0,sizeof(dp));
	for(int i=1;i<=2;i++)
		for(int j=1;j<=n;j++){
			cin>>x;
			dp[i][j]=max(dp[i-1][j],dp[i][j-1])+x;
		}
	cout<<dp[2][n]<<endl;
}

Measured memory_bytes: 256
#高速化heapqダイクストラ
from collections import *
from heapq import*
import sys
input=lambda:sys.stdin.readline()


def BFS(point,d):
    cost=[1e7]*(n+1)
    cost[point]=0
    Q=[]
    heappush(Q,(0,point))
    
    while Q:
        c,p=heappop(Q)
        for np in d[p]:
            if cost[np]==1e7:
                cost[np]=c+1
                heappush(Q,(c+1,np))
    return cost

n=int(input())
d={}
for i in range(n-1):
    a,b=map(int,input().split())
    if a in d:
        d[a].append(b)
    else:
        d[a]=[b]
    if b in d:
        d[b].append(a)
    else:
        d[b]=[a]
        
x=BFS(1,d)[1:]
y=BFS(n,d)[1:]

#print(x,y)

F=0
S=0

for s,t in zip(x,y):
    if s<=t:
        F+=1
    else:
        S+=1

if F<=S:
    print("Snuke")
else:
    print("Fennec")


Measured memory_bytes: 35484
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <set>
#include <utility>
using namespace std;

int main() {
  int cash(int N, int c6, int c9);
  int N; cin >> N;
  int c6a = 1; int c9a = 1;
  while (c6a*6 <= N) {
    c6a *= 6;
  }
  while (c9a*9 <= N) {
    c9a *= 9;
  }
  cout << cash(N, c6a, c9a) << endl;
}


int cash(int N, int c6, int c9) {
  int c9a = c9; int c6a = c6;
  if (N == 0)
    return 0;
  else {
    while (c6 > N) {
      c6 /= 6;
    }
    while (c9 > N) {
      c9 /= 9;
    }
    return min(cash(N-c6, c6a, c9a), cash(N-c9, c6a, c9a)) + 1;
  }
}


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

int main(){



  int i,n,p,max;
  int kouho[60];

  while(1){

    scanf("%d %d",&n,&p);
    if(n==0 && p==0)
      break;
    max = p;

    for(i=0;i<n;i++){
      kouho[i] = 0;
    }
    i=0;
    while(1){
      if(p>0){
	if(i<n){
	  kouho[i]++;
	  p--;
	}
	if(kouho[i] == max){
	  break;
	}
      }
      else if(p == 0){
	p = kouho[i];
	kouho[i]=0;
      }
      i++;
      if(i==n){
	i=0;
      }
    }
    printf("%d\n",i);
  

  }
  return 0;
}

Measured memory_bytes: 600
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x = sc.nextInt();
		int t = sc.nextInt();

		int minTime = 0;
		if (n % x == 0) {
			minTime = (n / x) * t;
		} else {
			minTime = (n / x + 1) * t;
		}
		System.out.println(minTime);

		sc.close();

	}

}


Measured memory_bytes: 35764
#include <stdio.h>

int main(){
    int n;
    int a;
    int b;

    scanf("%d %d %d", &n, &a, &b);

    if (n == 1){
        printf("Hello World\n");
    }
    else{
        printf("%d\n", a + b);
    }
    return 0;
}

Measured memory_bytes: 128
import java.util.*;
public class Main{
    public static void main(String[] args){
	new Main().run();
    }
    Scanner sc = new Scanner(System.in);

    int n, a, b, c, x;
    int f;
    int[] real;

    void run(){
	while(sc.hasNext()){
	    n = sc.nextInt();
	    a = sc.nextInt();
	    b = sc.nextInt();
	    c = sc.nextInt();
	    x = sc.nextInt();
	    if(n==0 && a==0 && b==0 && c==0 && x==0) break;

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

	    f = 0;
	    int i=0;
	    while(true){
		if(f>10000) break;
		if(x==real[i]) i++;
		if(i==real.length) break;
		x = (a*x+b)%c;
		f++;
	    }

	    System.out.println(f>10000 ? "-1" : f);
	}
    }
}

Measured memory_bytes: 31792
// ConsoleApplication1.cpp : Defines the entry point for the console application.
//

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

#define MAXCHAR 255

using namespace std;

vector<bool> ListOfPPLWithSnacks;

int main()
{
	int N = 0;
	int K = 0;
	cin >> N >> K;

	// init list
	for (int i = 0; i < N; i++)
	{
		ListOfPPLWithSnacks.push_back(false);
	}

	for (int i = 0; i < K; i++)
	{
		int d = 0;
		cin >> d;
		for (int j = 0; j < d; j++)
		{
			int index = 0;
			cin >> index;
			ListOfPPLWithSnacks[index - 1] = true;
		}
	}

	// Check who doesnt have snacks
	int output = 0;
	for (int i = 0; i < ListOfPPLWithSnacks.size(); i++)
	{
		if (!ListOfPPLWithSnacks.at(i))
			output++;
	}

	cout << output << endl;
}

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

using namespace std;

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

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

// コスト，大きさ
ll dp[2][404][404];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	ll a[404];
	cin>>n;
	REP(i, n){
		cin>>a[i];
		dp[1][i][i]=a[i];
	}
	REP(i, n){
		REP(j, n){
			if(i!=j){
				dp[0][i][j]=1e15;
			}
		}
	}
	FOR(d, 1, n){
		REP(l, n-d){
			int r=l+d;
			FOR(i, l, r){
				if(dp[0][l][r]>dp[0][l][i]+dp[0][i+1][r]+dp[1][l][i]+dp[1][i+1][r]){
					dp[0][l][r]=dp[0][l][i]+dp[0][i+1][r]+dp[1][l][i]+dp[1][i+1][r];
					dp[1][l][r]=dp[1][l][i]+dp[1][i+1][r];
				}
			}
			// DEBUG(l);
			// DEBUG(r);
			// DEBUG(dp[0][l][r]);
		}
	}
	cout<<dp[0][0][n-1]<<'\n';
	return 0;
}


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

using ll=long long;
int main(){
    int n;
    cin>>n;
    vector<ll> a(3*n);
    for(int i=0;i<3*n;i++) cin>>a[i];

    vector<ll> scf(3*n);
    vector<ll> scb(3*n);
    
    priority_queue<ll,vector<ll>,greater<>> bigq;
    ll sum=0;
    for(int i=0;i<n;i++){
        sum+=a[i];
        bigq.push(a[i]);
    }
    scf[n-1]=sum;    
    for(int i=n;i<=2*n;i++){
        sum+=a[i];
        bigq.push(a[i]);
        sum-=bigq.top();
        bigq.pop();
        scf[i]=sum;
    }

    priority_queue<ll> smlq;
    sum=0;
    for(int i=3*n-1;i>=2*n;i--){
        sum+=a[i];
        smlq.push(a[i]);
    }
    scb[2*n]=sum;
    
    for(int i=2*n-1;i>=n;i--){
        sum+=a[i];
        smlq.push(a[i]);
        sum-=smlq.top();
        smlq.pop();
        scb[i]=sum;
    }

    ll res=-1e15;
    for(int i=n-1;i<2*n;i++){
        res=max(res,scf[i]-scb[i+1]);
    }
    cout<<res<<endl;
    return 0;
}

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

using namespace std;

//#define int long long

const int big = 1e9;

void solve() {
    int r, c;
    cin >> r >> c;
    char p[r][c];
    for (int i = 0; i < r; ++i) for (int j = 0; j < c; ++j) cin >> p[i][j];
    vector <vector <int> > dp(r, vector <int> (c, big));
    dp[0][0] = 0;
    if (p[0][0] == '#') dp[0][0] = 1;
    for (int i = 0; i < r; ++i) {
        for (int j = 0; j < c; ++j) {
            int x = i, y = j;
            queue <pair <int, int> > q;
            q.push({i, j});
            /*while (!q.empty()) {
                int x = q.front().first, y = q.front().second;
                q.pop();*/
                if (x + 1 < r && p[x + 1][y] == '.') {
                    dp[x + 1][y] = min(dp[x + 1][y], dp[i][j]);
                    q.push({x + 1, y});
                }
                if (y + 1 < c && p[x][y + 1] == '.') {
                    dp[x][y + 1] = min(dp[x][y + 1], dp[i][j]);
                    q.push({x, y + 1});
                }
            //}
            q.push({i, j});
            int val = 0;
            if (p[i][j] == '.') val = 1;
/*            while (!q.empty()) {
                int x = q.front().first, y = q.front().second;
                q.pop();*/
                if (x + 1 < r && p[x + 1][y] == '#') {
                    dp[x + 1][y] = min(dp[x + 1][y], dp[i][j] + val);
                    q.push({x + 1, y});
                }
                if (y + 1 < c && p[x][y + 1] == '#') {
                    dp[x][y + 1] = min(dp[x][y + 1], dp[i][j] + val);
                    q.push({x, y + 1});
                }
            //}
        }
    }
    cout << dp[r - 1][c - 1];
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <cstdlib>
#include <utility>
#include <cmath>
#include <queue>
#include <stack>
#include <cstring>

using namespace std;

#define ll long long

#ifndef ONLINE_JUDGE
#define debug(format, ...) fprintf(stderr, \
    "%s:%d: " format "\n", __func__, __LINE__,##__VA_ARGS__)
#else
#define debug(format, ...)
#define NDEBUG
#endif

int a[200005];
//int f[1005][1005];
int f0[200005];
int bound[200005][3];

int n;

int get_f(int x, int y)
{
    if (y < bound[x][1]) return f0[x];
    if (y < bound[x][2]) return f0[x] - 1;
    return f0[x] - 2;
}

int calc_f(int i, int j)
{
    if (a[i-1] > a[i]) {
        return min(get_f(i-1, j), min(
            get_f(i-1, a[i-1] - a[i] + j) + 1, get_f(i-1, a[i-1]) + 2));
    } else {
        return min((a[i-1] - a[i] + j < 0 ? 100000000 : get_f(i-1, a[i-1] - a[i] + j)), min(
            get_f(i-1, min(j, a[i-1])) + 1, get_f(i-1, a[i-1]) + 2));
    }
}

int binary_search(int i, int j)
{
    int l = 0; int r = a[i];
    if (calc_f(i, a[i]) > j) return a[i] + 1;
    while (l < r) {
        int mid = (l + r) / 2;
        if (calc_f(i, mid) <= j) {
            r = mid;
        } else {
            l = mid + 1;
        }
    }
    return l;
}

int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d", a + i);
    bound[0][1] = 1;
    bound[0][2] = 1;
    for (int i = 1; i <= n + 1; i++) {
        f0[i] = calc_f(i, 0);
        bound[i][1] = binary_search(i, f0[i] - 1);
        bound[i][2] = binary_search(i, f0[i] - 2);
        //printf("%d %d %d\n", f0[i], bound[i][1], bound[i][2]);
    }
    printf("%d", get_f(n + 1, 0));
    return 0;
}


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

using namespace std;

#define llong long long int
#define ldouble long double
#define rep(i, n) for (int i = 0; i < n; ++i)
#define repr(i, n) for (int i = n; i >= 0; --i) 
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

const static int MOD = 1000000000 + 7;
const static int INT_INF = 999999999;
const static llong INF = 1LL << 60;
const static double eps = 1e-6;
const static int dx[] = {1, 0, -1, 0};
const static int dy[] = {0, 1, 0, -1};

llong cul(llong x) {
    int tmp = x % 4;
    if (tmp == 0) return x;
    if (tmp == 1) return 1;
    if (tmp == 2) return x + 1;
    else return 0;
}

signed main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    llong a, b;
    cin >> a >> b;
    if (a != 0) --a;
    llong ans = cul(a) ^ cul(b);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
num = int(input()) - 1
list = list(map(int,input().split()))
len = len(list) 
total = 0
i = 0

while i < num:
    if list[i] > list[i+1]:
        total= total + (list[i+1] -list[i])
        list[i+1] = list[i]
        i = i + 1
    else:
        i = i + 1
        
print(abs(total))

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

typedef long long ll;
typedef pair<int,int> P;

const int INF = 1e9;
const int mod = 1e9+7;

int main()
{
    int n;
    cin >> n;
    ll ans = 0;
    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        ans += a - 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
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; }

using ll = long long;
using P = pair<int,int>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

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

int main() {
    int N;
    cin>>N;
    vector<ll> ans(10005,0LL);
    for(int x = 1; x < 105; x++){
        for(int y = 1; y < 105; y++){
            for(int z = 1; z < 105; z++){
                int t = x*x+y*y+z*z+x*y+y*z+z*x;
                if(t<=10000) ans[t]++;
            }
        }
    }
    rep(i,N){
        cout<<ans[i+1]<<endl;
    }
}

Measured memory_bytes: 3696
import math
import collections


def main():
    N = int(input())
    if N == 1:
        print(0)
        exit()
    limit = math.sqrt(N)
    vals = []
    i = 2
    while True:
        if i > limit:
            break
        if N % i == 0:
            vals.append(i)
            N //= i
        else:
            i += 1
    if N != 1:
        vals.append(N)
    c = collections.Counter(vals)
    ans = 0
    for v, freq in c.items():
        i = 0
        while True:
            i += 1
            freq -= i
            if freq < 0:
                break
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 67920
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner sc = new Scanner(System.in);
		
		String s = sc.nextLine();
		int[] i = ArrconvAtoi(s);
		
		System.out.println(Math.abs(i[0] - i[1]));

	}
	
    private static int[] ArrconvAtoi(String s) {
        String[] strs = s.split(" ");
        int[] ints = new int[strs.length];
        int i = 0;
 
        for (String st : strs) {
            ints[i] = Integer.parseInt(st);
            i++;
        }
 
        return ints;
    }

}


Measured memory_bytes: 26180