akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;

int main(){
    int N;
    int ba=0, xa=0, bx=0;
    int ans = 0;
    cin >> N;
    for(int i=0; i<N; i++){
        string s;
        cin >> s;
        if(s[0] == 'B' && s[s.size()-1] == 'A') ba++;
        else if(s[0] == 'B') bx++;
        else if(s[s.size()-1] == 'A') xa++;
        for(int i=0; i<s.size()-1; i++){
            if(s[i]=='A'&&s[i+1]=='B') ans++;
        }
    }

    if(ba > 0) {
        ans += ba-1;
        if(xa>0){
            ans += 1;
            xa--;
        }
        if(bx>0){
            ans += 1;
            bx--;
        }
    }
    ans += min(xa, bx);

    cout <<  ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
void solve(){
	ll n,m,k;
	cin>>n>>m>>k;
	ll a[n],b[m];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int i=0;i<m;i++){
		cin>>b[i];
		if(i>0) b[i]+=b[i-1];
	}
	int ans=0;
	ll s=0;
	for(int i=0;i<=n;i++){
		int g=upper_bound(b,b+m,k-s)-b;
		ans=max(ans,g+i);
		if(i != n) s+=a[i];
		if(s > k) break;
	}
	cout<<ans<<'\n';
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int tt;
    tt=1;
    while(tt--)
        solve();
    return 0;
}


Measured memory_bytes: 6768
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(10)

using namespace std;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int N;
    cin >> N;

    int ans = 0;
    int maxp = 0;
    REP(i, N) {
        int p;
        cin >> p;
        ans += p;
        maxp = max(maxp, p);
    }
    cout << ans - maxp / 2 << endl;
    return 0;
}


Measured memory_bytes: 888
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int [] in = new int [100000];
        long ans = 0;
        for(int i=0;i<n;i++){int a = sc.nextInt();
                             in[a-1]++;
                             ans+=a;
                            }		
		int q = sc.nextInt();
        for(int i=0;i<q;i++){int b = sc.nextInt();
                             int c = sc.nextInt();
                             ans+=in[b-1]*(c-b);
                             in[c-1]+=in[b-1];
                             in[b-1]=0;
                             System.out.println(ans);
                            }		
	}
}

Measured memory_bytes: 60524
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n;
  vector<string> in(n);
  for (int i = 0; i < n; i++) {
    cin >> in[i];
  }
  int ans = 0;
  for (int d = 0; d < n; d++) {
    bool ok = true;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (in[i][j] != in[j][i]) ok = false;
      }
    }
    ans += ok;
    for (int i = 0; i < n; i++) {
      in[i] = in[i].substr(1) + in[i].substr(0, 1);
    }
  }
  cout << ans * n << endl;
  return 0;
}

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

int n,k;

int main()
{
    cin>>n>>k;
    int res=1;
    while(n--)
    {
        if(res*2<=res+k)
            res*=2;
        else
            res+=k;
    }
    cout<<res;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;

int main()
{
  while (1)
  {
    int n;
    cin >> n;
    if (n == 0)
      break;

    double sum = 0;
    vector<int> ss;

    rep(i, n)
    {
      int s;
      cin >> s;
      sum += s;
      ss.push_back(s);
    }

    double m = sum / n;
    double sigma = 0;
    rep(i, n)
    {
      sigma += pow(ss[i] - m, 2);
    }

    printf("%.8f\n", sqrt(sigma / n));
  }

  return 0;
}


Measured memory_bytes: 3260
#include <bits/stdc++.h>
#include <unordered_map>
typedef long long ll;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(ll i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    if(s[0] == s[1] && s[1] == s[2]){
        print("Yes");
    }else if(s[1] == s[2] && s[2] == s[3]){
        print("Yes");
    }else{
        print("No");
    }
}


Measured memory_bytes: 256
import math

class MergeSort:
    cnt = 0
    def merge(self, a, n, left, mid, right): 
        n1 = mid - left
        n2 = right - mid
        l = a[left:(left+n1)]
        r = a[mid:(mid+n2)]
        l.append(2000000000)
        r.append(2000000000)
        i = 0
        j = 0
        for k in range(left, right):
            self.cnt += 1
            if l[i] <= r[j]:
                a[k] = l[i]
                i += 1
            else:
                a[k] = r[j]
                j += 1
        return a
        
    def mergeSort(self, a, n, left, right):
        if left + 1 < right:
            mid = (left + right) // 2
            self.mergeSort(a, n, left, mid)
            self.mergeSort(a, n, mid, right)
            self.merge(a, n, left, mid, right)
        return a

if __name__ == '__main__':
    n = int(input().rstrip())
    s = [int(i) for i in input().rstrip().split(" ")]
    x = MergeSort()
    print(" ".join(map(str, x.mergeSort(s, n, 0, n))))
    print(x.cnt)

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

#define rep(i, n) for (Int i = 0; i < (Int)n; i++)
#define rep2(i, s, n) for (Int i = s; i < (Int)(n); i++)
#define rep3(i, n, s) for (Int i = n - 1; i >= s; i--)
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).end()
 
double EPS = 1e-10;
Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << endl; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

int main() {
    string s;
    cin >> s;
    vector<Int> a(s.size(), 0);
    rep(i, s.size()) {
        if (s[i] == 'g') {
            a[i]++;
        } else {
            a[i]--;
        }
    }
    rep(i, s.size() - 1) a[i + 1] += a[i];
    Int ma = a[s.size() - 1];
    Int res = 0;
    rep(i, s.size()) {
        if (a[i] > 0 and s[i] == 'g' and ma - 2 >= 0) {
            res++;
            ma -= 2;
        }
    }
    print(res);
    return 0;
}

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

using namespace std;

#define G getline
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define LL long long
#define ULL unsigned long long
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>
#define PLI pair<LL,int>
#define PLL pair<LL,LL>
#define MII map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define MLI map<LL,int>
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)





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




LL ans[10000005];

void PreCal()
{
    LL i,j,mx=1e7;
    ans[1]=1;
    for(i=2;i<=mx;i++)
    {
        for(j=i;j<=mx;j+=i)++ans[j];
        ++ans[i],ans[i]*=i,ans[i]+=ans[i-1];
    }
}

int main()
{
    FAST();
    PreCal();
    int n;
    cin >> n;
    cout << ans[n];
    return 0;
}


Measured memory_bytes: 81748
n = gets.to_i
def avg(arr)
  c = 0
  arr.each{|a| c += a}
  return (c.to_f / arr.size.to_f).round
end
x = gets.chomp.split.map{|s| s.to_i}
ans = avg(x)
dist = x.map{|xi| (xi - ans).abs}
a = 0
dist.each{|d| a += d**2}
puts a

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

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

bool isPrime(int x) {
    FOR (i, 2, sqrt(x) + 1) {
        if (x % i == 0) return false;
    }
    return true;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> prime;
    FOR (i, 2, 55556) {
        if (isPrime(i) && i % 5 == 1) prime.push_back(i);
    }
    rep (i, n) {
        if (i != n - 1) cout << prime[i] << " ";
        else cout << prime[i] << endl;
    }
    
    return 0;
}



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

int main(void)
{
    int x, y;
    cin >> x >> y;

    bool possible = (y % 2 == 0) && (y >= 2 * x) && (y <= 4 * x);
    if (possible)
        cout << "Yes\n";
    else
        cout << "No\n";
}


Measured memory_bytes: 3044
from itertools import permutations

N, M = map(int, input().split())
G = [[0] * N for _ in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    G[a - 1][b - 1] = 1
    G[b - 1][a - 1] = 1

count = 0
for p in permutations(range(1, N)):
    s = 0
    for i in p:
        if G[s][i] == 0:
            break
        else:
            s = i
    else:
        count += 1

print(count)

Measured memory_bytes: 3064
#include <iostream>
#include <map>
#include <queue>
using namespace std;

int main()
{
    int n;
    cin >> n;
    map<string, priority_queue<pair<int,int>>> m;
    for(int i=0; i<n; i++){
        string s;
        int score = 0;
        cin >> s >> score;
        m[s].push({score, i});
    }
    for(auto e: m){
        auto q = e.second;
        while(!q.empty()){
            cout << q.top().second + 1<< endl;
            q.pop();
        }
    }
    return 0;
}


Measured memory_bytes: 256
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_4_A
# Linear Search
# Result:
import sys


### main
ary_s_len = int(sys.stdin.readline().rstrip())
ary_s = [int(x) for x in sys.stdin.readline().rstrip().split(' ')]
ary_t_len = int(sys.stdin.readline().rstrip())
ary_t = [int(x) for x in sys.stdin.readline().rstrip().split(' ')]
assert len(ary_s) == ary_s_len
assert len(ary_t) == ary_t_len

count = 0
for e in ary_t:
    for se in ary_s:
        if e == se:
            count += 1
            break

print count

Measured memory_bytes: 4720
#include<iostream>
#include<fstream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<deque>
#include<set>
#include<map>
#include<bitset>
#include<ctime>
#include<queue>
using namespace std;
#define int long long
#define pii pair <int, int>
#define XX first
#define YY second

// constants:
const int mn = 200005;
const int mod = 1000000007;
const long long inf = 4444444444444444444;
const int sminf = 1111111111;
const bool is_multitest = 0;
const bool is_interactive = 0;

// i/o methods:
const bool input_from_file = 0;
const bool output_to_file = 0;
#define filename ""
#define in_extension "inp"
#define out_extension "out"

// data preprocessing: (e.g.: divisor generating, prime sieve)
void preprocess()
{
    
}

// global variables:
string s;
deque <char> S;
int Q;
int T[mn], F[mn];
char C[mn];
// main solution goes here:
void execute(int test_number)
{
    cin >> s >> Q;
    for (char t: s) S.push_back(t);
    for (int i=1; i<= Q; i++) {
        cin>>T[i];
        if (T[i] == 2) cin>>F[i]>>C[i];
    }

    bool flipped = 0;
    for (int i=1; i <= Q; i++) {
        if (T[i] == 1) flipped = !flipped;
        else {
            if (flipped) {
                if (F[i] == 1) S.push_back(C[i]);
                else S.push_front(C[i]);
            } else {
                if (F[i] == 1) S.push_front(C[i]);
                else S.push_back(C[i]);
            }
        }
    }

    if (flipped) {
        reverse(S.begin(), S.end());
    }
    for (char c: S) {
        cout<<c;
    }
}
// REMEMBER TO CHOOSE TEST METHODS
// PLEASE REMOVE cout AND cerr DEBUG LINES BEFORE SUBMITTING PROBLEMS
// Solution by low_



















signed main()
{
#ifdef lowie
    if (!is_interactive)
    {
        freopen("test.inp", "r", stdin);
        freopen("test.out", "w", stdout);
    }
#else
    if (input_from_file) freopen(filename"."in_extension, "r", stdin);
    if (output_to_file) freopen(filename"."out_extension, "w", stdout);
#endif
    if (!is_interactive)
    {
        ios_base::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
    }

    preprocess();
    int ntest;
    if (is_multitest) cin >> ntest;
    else ntest = 1;

    for (int testno = 1; testno <= ntest; testno++)
    // use for instead of while to serve facebook hacker cup test format
    {
        execute(testno); // only start coding in this function, not in main
    }
}
// Template by low_
// Contact me via mail: ttuandung1803@gmail.com
// ...or codeforces: www.codeforces.com/profiles/low_
// ...or if you're interested in food: www.instagram.com/lowie.exe/

Measured memory_bytes: 7332
#include<map>
#include<set>
#include<bitset>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<chrono>
#include<stack>
#include<fstream>
#include<list>
#define REP(i,x,y) for(ll i=x;i<=y;i++)
#define SIZE(a) ll(a.size())
#define vll vector<ll> 
#define MEMSET(a, n, m) for(ll i=0;i<=n;i++) a[i] = m
#define BIT(n) (ll(1)<<n)
#define UNIQUE(v) v.erase(unique(v.begin(),v.end()),v.end()) 
#define UNIQUE_ARRAY(a,x) unique(a + 1, a + x + 1) - a - 1
#define SORT(a,n) sort(a+1,a+n+1)
#define SORT_O(a,n,order) sort(a+1,a+n+1,order)
#define PER(i,y,x) for(ll i=y;i>=x;i--)
typedef long long ll;
using namespace std;


struct edge
{
	long long to; long long len;
	bool operator<(const edge& rhs) const {
		return len > rhs.len;
	}
};

ll const MAX = 700;
ll color[MAX][MAX][2];
ll cnt[2][2] = {};
vll vi[2],vj[2];

bool oor(ll n,ll i,ll j) {
	return !(0 <= i && i < n * 2 && 0 <= j && j < n * 2);
}

void drw(ll n, ll k, ll si, ll sj) {
	stack<ll> sti, stj, col;
	sti.push(si);
	stj.push(sj);
	color[si][sj][k] = 0;
	while (!sti.empty()) {
		ll curi = sti.top();
		ll curj = stj.top();
		ll nexcol = (color[curi][curj][k] + 1) % 2;
		sti.pop(); stj.pop(); 
		REP(iii, 0, SIZE(vi[k])-1) {
			ll nexi = curi + vi[k][iii];
			ll nexj = curj + vj[k][iii];
			if (oor(n, nexi, nexj)) { continue; }
			if (color[nexi][nexj][k] == -1) {
				color[nexi][nexj][k] = nexcol;
				sti.push(nexi);
				stj.push(nexj);
			}
		}
	}
}

void f(ll n, ll d, ll k) {
	REP(i, -n * 2, n * 2) {
		REP(j, -n * 2, n * 2) {
			if (i*i + j * j == d) {
				vi[k].push_back(i);
				vj[k].push_back(j);
			}
		}
	}
	REP(i, 0, 2 * n - 1) {
		REP(j, 0, 2 * n - 1) {
			color[i][j][k] = -1;
		}
	}

	REP(i, 0, 2 * n - 1) {
		REP(j, 0, 2 * n - 1) {
			if (color[i][j][k] == -1) {
				drw(n, k, i, j);
			}
		}
	}
}

void prnt(ll n,ll ii,ll jj) {
	ll cnt = 0;
	REP(i, 0, 2 * n - 1) {
		REP(j, 0, 2 * n - 1) {
			if (color[i][j][0] == ii && color[i][j][1] == jj) {
				cout << i << " " << j << endl;
				cnt++;
				if (cnt == n * n) {
					return;
				}
			}
		}
	}
}

int main() {
	ll n, d, e;
	cin >> n >> d >> e;
	f(n, d, 0);
	f(n, e, 1);
	REP(i, 0, 2 * n - 1) {
		REP(j, 0, 2 * n - 1) {
			ll c0 = color[i][j][0];
			ll c1 = color[i][j][1];
			cnt[c0][c1]++;
		}
	}
	ll ii, jj;
	REP(i, 0, 1) {
		REP(j, 0, 1) {
			if (cnt[i][j] >= n * n) {
				ii = i;
				jj = j;
				break;
			}
		}
	}
	ll cnt = 0;
	prnt(n,ii,jj);
	/*
	REP(i, 0, 2*n-1) {
		REP(j, 0, 2 * n - 1) {
			cout << color[i][j][0] << color[i][j][1] << " ";
			cnt++;
			if (cnt == n * n) { break; }
		}
		cout << endl;
	}
*/	
}

Measured memory_bytes: 11392
from __future__ import division
from collections import defaultdict

class UnionFindSet:
	def __init__(self, nodes):
		self.fa = {}
		for n in nodes:
			self.fa[n] = n

	def find(self, x):
		if self.fa[x] == x:
			return x
		else:
			self.fa[x] = self.find(self.fa[x])
			return self.fa[x]

	def union(self, x, y):
		fx = self.find(x)
		fy = self.find(y)
		if fx == fy:
			return fx
		else:
			self.fa[fx] = fy
			return fy


"""
graph is a hash
graph["nodes"] is a list of all nodes in the graph
graph["edges"] is a list of all edges in the graph in (x, y, w) form
  - x is the first nodes
  - y is the second nodes
  - w is the weight of the edges
graph["relation"] is the graph relation of the graph
"""

def kruscal(graph):
	"kruscal minimum spanning tree algorithm"
	ufset = UnionFindSet(graph["nodes"])

	ret = 0

	for (x, y, w) in sorted(graph["edges"], key = lambda x: x[-1]):
		fx = ufset.find(x)
		fy = ufset.find(y)
		if fx != fy:
			ret += w
			ufset.union(fx, fy)
		else:
			pass
	return ret



if __name__ == '__main__':
	V, E = map(int, raw_input().strip().split())
	graph = {}
	graph["nodes"] = [i for i in range(V)]
	graph["edges"] = []
	graph["adj"] = defaultdict(list)
	for _ in range(E):
		x, y, w = map(int, raw_input().strip().split())
		graph["edges"].append((x, y, w))
		graph["adj"][x].append((y, w))
		graph["adj"][y].append((x, w))

	print kruscal(graph)

Measured memory_bytes: 46940
#include <stdio.h>



int  n1,n2,a[10000],b[500];

int linear(int);


int main(){
  int i,sum=0;
  scanf("%d",&n1);
 
  for(i=0;i<n1;i++) scanf("%d",&a[i]);
scanf("%d",&n2);
 
  for(i=0;i<n2;i++) scanf("%d",&b[i]);
  for(i=0;i<n2;i++){
    sum+=linear(b[i]);




}
  printf("%d\n",sum);

return 0;
}
int linear(int key){
  int i;
  for(i=0;i<n1;i++){
    if(key==a[i])return 1;

}
  return 0;

}

Measured memory_bytes: 640
#include<stdio.h>
int main(void){
   long a, b, r, A, B;
   while(scanf("%ld %ld", &a, &b) != EOF){
      A = a;
      B = b;
      if(b > a){
         a = B;
         b = A;
      }
      r = a % b;
      while(r != 0){
         a = b;
         b = r;
         r = a % b;
      }
      printf("%ld %ld\n", b, A * B / b);
   }
   return 0;
}

Measured memory_bytes: 1780
S = input()
N = len(S)
ans = [0] * (N + 1)
for i in range(N):
    if S[i] == "<":
        ans[i + 1] = ans[i] + 1
for i in range(N - 1, -1, -1):
    if S[i] == ">":
        if ans[i] <= ans[i + 1]:
            ans[i] = ans[i + 1] + 1
print(sum(ans))

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

    int a,b,s,m,g;
    scanf("%d%d",&a,&b);
    s=a+b;
    m=a-b;
    g=a*b;
    if(s>=m&&s>=g){
        printf("%d\n",s);
    }
    else if(m>=s&&m>=g){
        printf("%d\n",m);
    }
    else{
        printf("%d\n",g);
    }
    return 0;
}

Measured memory_bytes: 128
def main():
    N = int(input())
    B = list(map(int, input().split()))
    ans = [0] * N
    for i in range(N):
        idx = 0
        for j in range(N-i):
            if B[j] == j+1:
                idx = j+1
        if idx == 0:
            print(-1)
            return
        ans[i] = idx
        B = B[:idx-1] + B[idx:]
    for a in ans[::-1]:
        print(a)


if __name__ == "__main__":
    main()


Measured memory_bytes: 38512
#include<iostream>
using namespace std;
int main()
{
    int i,a,b;
    cin>>a>>b;
    if(a>b)
    {
        for(i=0; i<a; i++)
            cout<<b;
    }
    else if (b>=a)
    {
        for(i=0; i<b; i++)
            cout<<a;
    }
    cout<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef pair<int, int> P;

const long double EPS = 1e-10;
const long long INF = 1e18;
const int MOD = (int)1e9 + 7;
const long double PI = acos(-1.0L);

ll d, g;
vector<int> p, c;
int ans = 1e9;

int main() {  // TODO
  cin >> d >> g;
  p = vector<int>(d);
  c = vector<int>(d);
  rep(i, d) cin >> p[i] >> c[i];

  int ans = 1e9;
  rep(i, 1 << d) {
    int step = 0;
    int score = 0;
    for (int j = d - 1; j >= 0; j--) {
      if (i >> j & 1) {
        int base = (j + 1) * 100;
        rep(s, p[j]) {
          score += base;
          step++;
          if (s == p[j] - 1) {
            score += c[j];
          }
          if (score >= g) {
            ans = min(ans, step);
          }
        }
      }
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define ll long long
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define repm(i, a, b) for (ll i = (ll)(a); i > (ll)(b); i--)
#define all(v) v.begin(), v.end()
#define rall(x) (x).rbegin(), (x).rend()
#define pll pair<long long, long long>
#define pb emplace_back
#define mp make_pair
#define mt make_tuple
#define vc vector<char>
#define vvc vector<vc>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<long long>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vvb = vector<vb>;
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;}
//snippets:tmp,cl,cvl,cs,co,coy,con,cov,setp



int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll d,t,s;
    cin>>d>>t>>s;
    if(t*s<d){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
}


Measured memory_bytes: 3648
from bisect import bisect

n = int(input())

A = sorted(map(int,input().split()))

a = A[-1]

i = bisect(A,a/2)
j = max(i-1,0)

k = min((A[i]-a/2, i),(a/2-A[j],j))[1]

print(a,A[k])


Measured memory_bytes: 14644
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
#define int long
#define ll long long
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define mk make_pair
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int N; cin >> N;
    cout << N*N << endl;
}


Measured memory_bytes: 256
def solve():
    l = list(map(int, input().split(" ")))
    count_dict = {}

    for element in l:
        if element not in count_dict:
            count_dict[element] = 1
        else:
            count_dict[element] += 1

    for key, val in count_dict.items():
        if val == 1:
            print(key)
            break
            

solve()

Measured memory_bytes: 3064
//Daniel Grzegorzewski
#include <bits/stdc++.h>

#define MP make_pair
#define PB push_back
#define ST first
#define ND second

using namespace std;

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;

void init_ios()
{
     ios_base::sync_with_stdio(0);
     cin.tie(0);
}

int main()
{
    init_ios();
    int a, b;
    cin >> a >> b;
    if (a <= 0 && b >= 0) {
    	cout<<"Zero\n";
    	return 0;
    }
    if (a > 0) {
    	cout<<"Positive\n";
    	return 0;
    }
    if (a == 0) {
    	cout<<"Zero\n";
    	return 0;
    }
    int ile = abs(a)-abs(b+1);
    if (ile%2 == 0)
    	cout<<"Positive\n";
    else
    	cout<<"Negative\n";
}

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

int main() {
    int N, L;
    std::cin >> N >> L;

    std::vector<std::string> S(N);
    for (int i = 0; i < N; ++i) {
        std::cin >> S[i];
    }
    
    std::sort(S.begin(), S.end());

    std::string ret;
    ret.reserve(N * L);
    for (int i = 0; i < N; ++i) {
        ret += S[i];
    }

    std::cout << ret << std::endl;
}


Measured memory_bytes: 256
#include<stdio.h>
 
int main(){
  int n, m, a;
 
  scanf("%d %d",&n,&m);
  for(int i=0;i<m;i++){
    scanf("%d", &a);
    n-=a;
  }
  if(n<0) n=-1;
  printf("%d",n);
  return 0;
}

Measured memory_bytes: 2152
#include <string>

#include <iostream>
#include <vector>
int main()
{
	int n;
	std::cin >> n;
	std::vector<double> x(n);
	std::vector<std::string> u(n);
	for (int i = 0; i < n; i++) {
		std::cin >> x.at(i);
		std::cin >> u.at(i);
	}

	double sum = 0;
	for (int i = 0; i < n; i++) {
		if (u.at(i).at(0) == 'B') {
			sum += 380000.0*x.at(i);
		}
		else {
			sum += x.at(i);
		}
	}
	std::cout<<sum;

	return 0;

}



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

#define int long long
#define endl '\n'
#define ll long long
#define ld long double
#define fi first
#define se second
#define pii pair<int, int>
#define pll pair<long long, long long>
#define mod (ll) (1e9 + 7)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define all(v) v.begin(), v.end()
#define dvec(v) for(auto i: v) cout<< i<< " "; cout<< '\n';
#define gcd(a,b) __gcd(a, b)
#define lcm(a,b) ((a)*((b)/gcd(a,b)))
#define darr(a,n) for(int i=0; i<n;i++) cout<< a[i]<< " "; cout<< '\n';
#define what_is(x) cerr<< #x<< " : "<< x<< '\n';


int32_t main() {
    fast;
    int n, W;
    cin >> n >> W;
    int val[n], wt[n];
    int total_sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> wt[i] >> val[i];
        total_sum += val[i];
    }

    int dp[2][total_sum + 1];
    for (int i = 0; i <= total_sum; i++) {
        dp[0][i] = (dp[1][i] = INT_MAX);
        dp[0][0] = dp[1][0] = 0;
    }

    int curr = 1;
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= total_sum; j++) {
            dp[curr][j] = min(dp[curr][j], dp[!curr][j]);
            if (j >= val[i-1]) {
                dp[curr][j] = min(dp[curr][j], wt[i-1] + dp[!curr][j - val[i-1]]);
            }
        }
        curr = !curr;
    }

    for (int sum = total_sum; sum >= 0; sum--) {
        if (dp[!curr][sum] <= W) {
            cout << sum << endl;
            return 0;
        } else {
            // cout << "j : " << sum << ", wt : " << dp[!curr][sum] << endl;
        }
    }

    return 0;
}


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

long long A, B, Q, s[100005], t[100005];


inline long long calc(long long t1, long long t2, long long x) {
    if (t1 > A || t2 > B || t1 < 1 || t2 < 1) return 0x7f7f7f7f7f7f7f7f;
    long long S = s[t1], T = t[t2];
    if (S >= x && T >= x)
        return max(S, T) - x;
    if ((S <= x && T >= x) || (T <= x && S >= x))
        return abs(S - T) + min(abs(T - x), abs(S - x));
    if (S <= x && T <= x)
        return x - min(S, T);
    return 0x7f7f7f7f7f7f7f7f;
}
int main() {
    cin >> A >> B >> Q;
    for (int i = 1; i <= A; ++i)
        scanf("%lld", s + i);
    for (int i = 1;  i <= B; ++i)
        scanf("%lld", t + i);
    sort(s + 1, s + A + 1);
    sort(t + 1, t + B + 1);
    while (Q--) {
        long long x;
        scanf("%lld", &x);
        long long t1 = lower_bound(s + 1, s + A + 1, x) - s;
        long long t2 = lower_bound(t + 1, t + B + 1, x) - t;
        long long res = 0x7f7f7f7f7f7f7f7f;
        res = min(res, calc(t1 - 1, t2, x));
        res = min(res, calc(t1, t2, x));
        res = min(res, calc(t1 - 1, t2 - 1, x));
        res = min(res, calc(t1, t2 - 1, x));
        printf("%lld\n", res);
    }
    return 0;
}


Measured memory_bytes: 2816
using System.Linq;
using System;

public class Hello
{
    public static void Main()
    {
        while (true)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var a = Array.ConvertAll(line, int.Parse);
            if (a.Sum() == 0) break;
            var x = getTimes(a[0], a[1]);
            var y = getTimes(a[2], a[3]);
            var z = getTimes(a[4], a[5]);
            Console.WriteLine(Lcm(Lcm(x, y), z));
        }
    }
    public static int getTimes (int a, int m)
    {
        var rtime = 0; var x = 1;
        while (true)
        {
            var nx = (a * x) % m;
            rtime++;
            if (nx == 1) return rtime;
            else x = nx;
        }
    }
    public static long Lcm (long a , long b)
    {
        if (a < b)  return Lcm(b, a);
        var ab = a * b;
        while (b != 0)
        {
            var wk = a % b;
            a = b;
            b = wk;
        }
        return ab / a;
    }
}

Measured memory_bytes: 9556
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i = 0;i<((ll)(n));i++)
#define reg(i,a,b) for(ll i = ((ll)(a));i<=((ll)(b));i++)
#define irep(i,n) for(ll i = ((ll)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(ll i = ((ll)(b));i>=((ll)(a));i--)
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

/*
*/

ll n,a[300010],s[20]={};
set<pair<ll,ll>> p;
bool ok=true;

void init(){
	cin>>n;
	rep(i,1<<n)cin>>a[i];
	sort(a,a+(1<<n));
	ll b=-1,c=0;
	rep(i,1<<n){
		if(b==-1){
			c=1;
		}else if(b==a[i]){
			c++;
		}else{
			p.insert({-b,c});
			c=1;
		}
		b=a[i];
	}
	p.insert({-b,c});
	// for(auto itr=p.begin();itr!=p.end();itr++)cerr<<itr->first<<" "<<itr->second<<endl;
}

int main(void){
	init();
	s[n]=1;
	for(auto itr=p.begin();itr!=p.end();itr++){
		ll num=itr->second;
		ll c[20]={};
		ireg(i,0,n){
			if(num>=s[i]){
				c[i]+=s[i];
				num-=s[i];
				s[i]=0;
			}else{
				c[i]+=num;
				s[i]-=num;
				num=0;
			}
		}
		if(num>0)ok=false;
		ireg(i,0,n){
			rep(j,i)s[j]+=c[i];  // 例：16が8,4,2,1になる
		}
		// reg(i,0,n)cerr<<s[i]<<" ";
		// cerr<<endl;
		// reg(i,0,n)cerr<<c[i]<<" ";
		// cerr<<endl;
		// cerr<<"--"<<endl;
	}
	cout<<(ok?"Yes":"No")<<endl;
	return 0;
}

Measured memory_bytes: 18688
import java.util.Scanner;
public class Main
{
	public static void main(String[] args) 
	{
		int cost[][]=
			{
				{0,300,500,600,700,1350,1650},
				{300,0,350,450,600,1150,1500},
				{500,350,0,250,400,1000,1350},
				{600,450,250,0,250,850,1300},
				{700,600,400,250,0,600,1150},
				{1350,1150,1000,850,600,0,500},
				{1650,1500,1350,1300,1150,500,0}
			};
		int km[][]=
			{
				{0,6,13,18,23,43,58},
				{6,0,7,12,17,37,52},
				{13,7,0,5,10,30,45},
				{18,12,5,0,5,25,40},
				{23,17,10,5,0,20,35},
				{43,37,30,25,20,0,15},
				{58,52,45,40,35,15,0}
			};
		Scanner in=new Scanner(System.in);
		for(;;)
		{
			int s=in.nextInt();
			if(s==0)
				return;
			int sh=in.nextInt(),sm=in.nextInt();
			int t=in.nextInt();
			int th=in.nextInt(),tm=in.nextInt();
			int ans=cost[s-1][t-1];
			int t1=sh*60+sm;
			int t2=th*60+tm;
			if(km[s-1][t-1]<=40&&(17*60+30<=t1&&t1<=19*60+30||17*60+30<=t2&&t2<=19*60+30))
				ans=ans/2+ans/2%50;
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 12000
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;

int n;
double ans, a[102];

int main(){
	
	cin >> n;
	rep(i, n)cin >> a[i];
	sort(a, a + n);
	ans = a[0];
	REP(i, 1, n){
		ans += a[i];
		ans /= 2;
	}
	cout << ans << endl;
}


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

#define ALL(c) (c).begin(), (c).end()
#define CALL(c) (c).cbegin(), (c).cend()
#define RALL(c) (c).rbegin(), (c).rend()
#define CRALL(c) (c).crbegin(), (c).crend()
#define REP(i, n) for (int i = 0; i < static_cast<int>(n); i++)
#define FOR(i, s, n) for (int i = s; i < static_cast<int>(n); i++)
#define PSORT(s,p,e) partial_sort((s), next((s), (p)), (e))
#define VIEW(v,t) for_each((v).begin(), (v).end(), [](t& a) { cout << a << " "; }); cout << endl;

const int INF = INT_MAX;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};

using PII = pair<int, int>;
using LL = long long;
using ULL = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using V2 = vector<vector<T>>;
template<class T, int W=255> using A = array<T, W>;
template<class T, int W=255, int H=255> using A2 = array<array<T, W>, W>;

int n;
V<int> h;

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

    REP(i, n) {
        int a;
        cin >> a;
        h.push_back(a);
    }

    int ans = 1;
    int m = h[0];
    FOR(i, 1, h.size()) {
        if(m <= h[i]) ans++;
        m = max(m, h[i]);
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <tuple>
#include <set>

class union_find {
  std::vector<intmax_t> tree;

public:
  union_find(size_t n): tree(n, -1) {}

  size_t find(size_t v) {
    if (tree[v] < 0)
      return v;

    return (tree[v] = find(tree[v]));
  }

  bool unite(size_t u, size_t v) {
    u = find(u);
    v = find(v);
    if (u == v)
      return false;

    if (-tree[u] >= -tree[v])
      std::swap(u, v);

    tree[v] += tree[u];
    tree[u] = v;
    return true;
  }

  bool connected(size_t u, size_t v) {
    return (find(u) == find(v));
  }

  size_t size(size_t v) {
    return -tree[find(v)];
  }
};

constexpr int INF = 1e9;

int slim(size_t n, int w, std::vector<std::tuple<int, size_t, size_t>>& es) {
  union_find uf(n);
  size_t m = 1;
  for (size_t i=0; i<es.size(); ++i) {
    int wi = std::get<0>(es[i]);
    if (wi < w) continue;

    size_t a = std::get<1>(es[i]);
    size_t b = std::get<2>(es[i]);
    if (uf.unite(a, b) && ++m == n)
      return wi - w;
  }
  return INF;
}

int testcase_ends() {
  size_t n, m;
  scanf("%zu %zu", &n, &m);

  if (n == 0 && m == 0) return 1;

  std::vector<std::tuple<int, size_t, size_t>> es;
  std::set<int> ws;
  for (size_t i=0; i<m; ++i) {
    size_t a, b;
    int w;
    scanf("%zu %zu %d", &a, &b, &w);
    --a;
    --b;
    es.emplace_back(w, a, b);
    ws.insert(w);
  }

  std::sort(es.begin(), es.end());
  int res = INF;
  for (int w: ws)
    res = std::min(res, slim(n, w, es));

  if (res == INF)
    return puts("-1"), 0;

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

int main() {
  while (!testcase_ends()) {}
}



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

#define ll long long int

ll gcd(ll a, ll b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
}

bool ispal(string s){
    int start=0;
    int n=s.length();
    int end =n-1;
    while(start<end){
        if(s[start]!=s[end])
        return false;
        start++;
        end--;
    }
    
    return true;
}





int main() {
  
 

    
    int x;
    cin>>x;
    int n;
    cin>>n;
    
    set<int>s;
    for(int i=0;i<n;i++){
        int y;
        cin>>y;
        s.insert(y);
    }
    int diff =INT_MAX;
    int val=-1;
 
 for(int j=x;j>=0;j--){
     if(s.find(j)==s.end()){
         diff = x-j;
         val =j;
         break;
     }
 }
 for(int j=x+1;j<=101;j++){
      if(s.find(j)==s.end()){
         int diff1 = j-x;
         if(diff1<diff){
         val =j;
         
         }
         break;
     }
 }
 
 cout << val << endl;
 
 

 


	

}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
using namespace std;
typedef long long ll;
const int INF = 1001001001;

int main() {
    int k, s;
    cin >> k >> s;
    int ans = 0;
    rep(x, k+1)rep(y, k+1){
        int z = s-x-y;
        if(z>=0 and z<=k){
            ans++;
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
/*
@author: sharrad99
*/
#include<bits/stdc++.h>
using namespace std;
int main(){


	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	string s;
	cin >> s;

	int n = s.length();

	if(n % 2 == 0) {
		cout << "No\n";
		return 0;
	}

	for(int i = 0, j = n - 1; i <= j; i++, j--) {
		if(s[i] != s[j]) {
			cout << "No\n";
			return 0;
		}
	}
	for(int i = 0, j = (n / 2) - 1; i <= j; i++, j--) {
		if(s[i] != s[j]) {
			cout << "No\n";
			return 0;
		}
	}

	for(int i = (n / 2) + 1, j = n - 1; i <= j; i++, j--) {
		if(s[i] != s[j]) {
			cout << "No\n";
			return 0;
		}
	}

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

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//s[i]-'0'でchar文字→int数に;
//string s = to_string(int数);
//int n = stoi(string文字列)
//実行時間制約2秒では２×10^8回くらいまで計算できる


int main() {
  int n;
  cin >> n;
  
  vector<int> p(n);
  rep(i,n){
  cin>>p[i];
  }
  
  auto copy = p;
  
  sort(all(p));
  reverse(all(p));
  int dai = p[0];
  
  if(p[1]!=dai) {
    rep(i,n){
      if(copy[i]!=dai)cout << dai << endl;
      else cout << p[1] << endl;;
    }
  }
  else {
    rep(i,n) {
    cout << dai << endl;
    }
  }
  
}

Measured memory_bytes: 3200
s = list(map(int,input()))
n = len(s)
count1 = 0
count2 = 0
if n == 1:
    print(0) 
else:
    for i in range(n):
        if i%2 == 0 and s[i] != 0:
            count1 += 1
        elif i%2 != 0 and s[i] != 1:
            count1 += 1
    for i in range(n):
        if i%2 == 0 and s[i] != 1:
            count2 += 1
        elif i%2 !=0 and s[i] != 0:
            count2 += 1
    print(min(count1,count2))

Measured memory_bytes: 3956
import fractions

N = int(input())
A = list(map(int, input().split()))

left = [0]*(N+1)
for i in range(1,N+1):
    left[i] = fractions.gcd(left[i-1],A[i-1])

right = [0]*(N+1)
right[N-1] = A[N-1]
for i in range(N-2,-1,-1):
    right[i] = fractions.gcd(right[i+1],A[i])

ans = 0
for i in range(N):
    ans = max(ans,fractions.gcd(left[i],right[i+1]))
print(ans)

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

typedef unsigned long long ull;

int comp(const void *p1,const void *p2);

int main(void){
	ull *creature,*sum,n,i;
	int ans=1;
	scanf("%d",&n);
	creature=(ull *)calloc(n,sizeof(ull));
	sum=(ull *)calloc(n,sizeof(ull));
	for(i=0;i<n;i++) scanf("%llu",&creature[i]);
	
	qsort(creature,n,sizeof(ull),comp);
	for(i=0;i<n;i++) sum[i]=(i==0)?creature[i]:(creature[i]+sum[i-1]);
	for(i=n-1;i>0;i--){
		if(creature[i]<=sum[i-1]*2) ans++;
		else break;
	}
	
	printf("%llu\n",ans);
	
	free(sum);
	free(creature);
	return 0;
}

int comp(const void *p1,const void *p2){
	int n1,n2;
	n1=*((const int *)p1);
	n2=*((const int *)p2);
	return n1-n2;
}

Measured memory_bytes: 1788
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
int digit(int num){
    int cnt=0;
    while(num>0){
        cnt+=num%10;
        num/=10;
    }
    return cnt;
}
int main() {
    int N;
    cin>>N;
    int min_dig=INF;;
    for(int i=1;i<=N-1;i++){
        min_dig=min(digit(i)+digit(N-i),min_dig);
    }
    cout<<min_dig<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    int N; cin >> N;
    vector<int> A(N);
    bool T = true;
    for (int i = 0; i < N; ++i) {
        int a = 0;
        cin >> a;
        if (a % 2 == 0) {
            if (a % 3 == 0 || a % 5 == 0) {
                continue;
            }
            else {
                T = false;
                break;
            }
        }
    }
    if (T) printf("%s\n", "APPROVED");
    else printf("%s\n", "DENIED");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define INF 1000000007
#define mod 1005
#define ll long long int

void solve()
{
	ll n;
	cin>>n;
	ll temp = n;
	ll ans = 0;
	for(ll i=2; i*i<=n;i++)
	{
		if(n%i==0)
		{
			ll pwr = 0;
            while(n%i == 0){
                pwr++;
                n/=i;
            }
            ans += (ll)((sqrt(1+8*pwr)-1)/2.0);
		}
	}
	if (n > 1) 
		ans++;
    cout << ans;
}
int main()
{
	int t = 1;
//	cin>>t;
	
	while(t--)
	{
		solve();
	}
}

Measured memory_bytes: 3680
from bisect import bisect_left, bisect_right

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A.sort()
C.sort()

ans = 0
for b in B:
    a = bisect_left(A, b)
    c = N - bisect_right(C, b)
    ans += a * c

print(ans)

Measured memory_bytes: 23328
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
using namespace std;
#define ll long long 
#define ld double 
#define  pb push_back
#define  ff(n) for(i=0; i<n; i++)
#define mo 10000
ll max(ll a,ll b){return (a>b)?a:b;}
int main()
{
    ll n,m=0,i,x,y,k=0,j;
    cin>>n;
    int128_t k1=1,k2=1000000000000000000;
    vector<ll>a(n);
    for(i=0; i<n; i++)
     cin>>a[i];
     sort(a.begin(),a.end());
     for(i=0; i<n; i++)
      {
          k1*=a[i];
          if(k1>k2)
           {
               cout<<-1<<endl;
               return 0;
           }
      }
     cout<<k1<<endl;    
}


Measured memory_bytes: 4008
N=int(input())
print(0)
s=input()
if s=='Vacant':
  exit()
x=s
print(N-1)
s=input()
if s=='Vacant':
  exit()
left=0
right=N
while True:
  n=(left+right)//2
  print(n)
  s=input()
  if s=='Vacant':
    exit()
  if n%2!=0:
    if s==x:
      right=n
    else:
      left=n
  else:
    if s!=x:
      right=n
    else:
      left=n


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std; inline void fileio(const char* in, const char* out) { freopen(in, "r", stdin); freopen(out, "w", stdout); } 
#define TD typedef
#define forx(i,n) for(int i = 0; i < (n); ++i)
TD long long ll; TD long double ld; TD pair<int,int> pii; TD pair<ll, ll> pll; TD vector<int> VI; TD vector<bool> VB; TD vector<ll> VL;
const char nl = '\n'; const int INF = 0x3f3f3f3f; const ll LINF = 0x3f3f3f3f3f3f3f3fll; const ld EPS = 1e-9, PI = acos(-1);
#define ff first
#define ss second

TD pair<char,char> pcc;

int main() {
  atexit([](){ cerr << "Time: " << (ld)clock() / CLOCKS_PER_SEC << nl; });
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  // Emily <3
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  vector<pcc> queries(q);
  forx(i, q) { cin >> queries[i].ff >> queries[i].ss; }
  int l = 0, r = n-1;
  // [l, r] is good range
  reverse(queries.begin(), queries.end());
  for(pcc que : queries) {
    if (que.ss == 'L') {
      //shrink left if possible
      if (que.ff == s[l]) {
        l++;
      }
      if (r < n-1 && que.ff == s[r+1])
        r++;
    } else {
      if (que.ff == s[r]) {
        r--;
      }
      if (l > 0 && que.ff == s[l-1])
        l--;
    }
    if (l > r) break;
  }
  if (l > r) {
    cout << 0 << nl;
  } else {
    cout << r - l + 1 << nl;
  }

  return 0;
}



Measured memory_bytes: 976