akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define SP fixed << setprecision(10)
#define ER(x) cout << #x << " = " << x << endl;

using namespace std;

typedef long long ll;
typedef pair <int , int> pii;
typedef double DB;

const int N = 100100;
pii a[N];

int main(){

	ios_base::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
	
	int n , t(0);
	cin >> n;

	for(int i = 0 ; i < n ; i++){
		cin >> a[i].F;
		a[i].S = i;
	}
	
	sort(a , a+n);

	for(int i = 0 ; i < n ; i++){
		if(a[i].S%2 != i%2){
			t++;
		}
	}

	cout << t/2 << endl;

	return 0;
}


Measured memory_bytes: 1024
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() (int, []int) {
	n := readInt()
	return n, readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int

// -----------------------------------------------------------------------------

func main() {
	defer stdout.Flush()
	_, a := readLengthAndSlice()

	m := make(map[int]int)
	for _, v := range a {
		m[v-1]++
		m[v]++
		m[v+1]++
	}
	var ans int
	for _, v := range m {
		if ans < v {
			ans = v
		}
	}
	println(ans)

}

// -----------------------------------------------------------------------------


Measured memory_bytes: 7040
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	r := bufio.NewReader(os.Stdin)
	var k, a, b int
	fmt.Fscan(r, &k)
	fmt.Fscan(r, &a)
	fmt.Fscan(r, &b)

	ans := false
	for i := a; i <= b; i++ {
		if i%k == 0 {
			ans = true
			break
		}
	}

	if ans {
		fmt.Println("OK")
	} else {
		fmt.Println("NG")
	}

}

// Union-Find
type unionFind struct {
	d []int
}

func newUnionFind(n int) *unionFind {
	uf := new(unionFind)
	uf.d = make([]int, n)
	for i := 0; i < n; i++ {
		uf.d[i] = -1
	}
	return uf
}

func (uf *unionFind) find(x int) int {
	if uf.d[x] < 0 {
		return x
	}
	uf.d[x] = uf.find(uf.d[x])
	return uf.d[x]
}

func (uf *unionFind) unite(x, y int) bool {
	rootX := uf.find(x)
	rootY := uf.find(y)
	if rootX == rootY {
		return false
	}

	if uf.d[rootX] < uf.d[rootY] {
		uf.d[rootX] += uf.d[rootY]
		uf.d[rootY] = rootX
	} else {
		uf.d[rootY] += uf.d[rootX]
		uf.d[rootX] = rootY
	}

	return true
}

func (uf *unionFind) same(x, y int) bool {
	return uf.find(x) == uf.find(y)
}

func (uf *unionFind) size(x int) int {
	return -uf.d[uf.find(x)]
}

// mod combination
func modpow(a, n, mod int) int {
	res := 1
	for n > 0 {
		if n%2 != 0 {
			res = res * a % mod
		}
		a = a * a % mod
		n = n / 2
	}
	return res
}

func modcomb(n, a, mod int) int {
	x := 1
	y := 1
	for i := 0; i < a; i++ {
		x = x * (n - i)
		x %= mod
		y = y * (i + 1)
		y %= mod
	}
	return x * modpow(y, mod-2, mod) % mod
}

func modfactorial(n, mod int) int {
	result := 1
	for i := 1; i <= n; i++ {
		result = (result * i) % mod
	}
	return result
}

// Utility

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func primeFactor(x int) map[int]int {
	res := make(map[int]int)
	for i := 2; i*i <= x; i++ {
		for x%i == 0 {
			res[i]++
			x = x / i
		}
	}
	if x != 1 {
		res[x] = 1
	}
	return res
}

func divisor(x int) []int {
	res := make([]int, 0)
	for i := 1; i*i <= x; i++ {
		if x%i == 0 {
			res = append(res, i)
			if i != x/i {
				res = append(res, x/i)
			}
		}
	}
	return res
}

func gcd(x, y int) int {
	if y == 0 {
		return x
	}
	return gcd(y, x%y)
}

func lcm(x, y int) int {
	return x / gcd(x, y) * y
}

func reverseString(s string) string {
	r := []rune(s)
	for i, j := 0, len(r)-1; i < len(r)/2; i, j = i+1, j-1 {
		r[i], r[j] = r[j], r[i]
	}
	return string(r)
}

// Queue ...
type Queue []int

// pop ...
func (q *Queue) empty() bool {
	return len(*q) == 0
}

// push ...
func (q *Queue) push(i int) {
	*q = append(*q, i)
}

// pop ...
func (q *Queue) pop() (int, bool) {
	if q.empty() {
		return 0, false
	} else {
		res := (*q)[0]
		*q = (*q)[1:]
		return res, true
	}
}

// Stack ...
type Stack []int

// pop ...
func (s *Stack) empty() bool {
	return len(*s) == 0
}

// push ...
func (s *Stack) push(i int) {
	*s = append(*s, i)
}

// pop ...
func (s *Stack) pop() (int, bool) {
	if s.empty() {
		return 0, false
	} else {
		index := len(*s) - 1
		res := (*s)[index]
		*s = (*s)[:index]
		return res, true
	}
}


Measured memory_bytes: 1828
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <fstream>
#include <cstdlib>
#include <ctime>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <tuple>
#include <climits>
#include <unordered_map>

using namespace std;

//int X[100000], Y[100000];
//
//void solve() {
//    int P, Q, x, y;
//    char d;
//    cin>>P>>Q;
//    memset(X, 0, sizeof(X));
//    memset(Y, 0, sizeof(Y));
//    for (int i=0; i<P; i++) {
//        cin>>x>>y>>d;
//        if (d == 'N') for (int j= y+1; j<=Q; j++) Y[j]++;
//        if (d == 'S') for (int j= 0; j<y; j++) Y[j]++;
//        if (d == 'E') for (int j= x+1; x<=Q; j++) X[j]++;
//        if (d == 'W') for (int j= 0; j<x; j++) X[j]++;
//    }
//    int ans = 0;
//    for (int i=0; i<=Q; i++) {
//        if (X[i])
//    }
//
//}



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

    int r,g,b,n;
    cin>>r>>g>>b>>n;

    int ans = 0;
    for (int i=0; i<=3000; i++) {
        for (int j=0; j<=3000; j++) {
            if (n-i*r-j*g < 0) break;
            if ((n-i*r-j*g)%b == 0) ans++;
        }
    }

    cout<<ans<<endl;

//    int T;
//    cin>>T;
//    for (int t=1; t<=T; t++) {
//        cout<<"Case #"<<t<<": ";
//        solve();
//    }
    return 0;
}

Measured memory_bytes: 256
from collections import deque
k = int(input())
lun = deque([1,2,3,4,5,6,7,8,9])
for i in range(k - 1):
  left = lun.popleft()
  if left % 10 == 0:
    lun.append(left*10)
    lun.append(left*10 + 1)
  elif left % 10 == 9:
    lun.append(left*10 + 9 - 1)
    lun.append(left*10 + 9)
  else:
    x = left % 10
    lun.append(left*10 + x - 1)
    lun.append(left*10 + x)
    lun.append(left*10 + x + 1)
answer = lun.popleft()
print(answer)

Measured memory_bytes: 11860
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main() {
  int a,b,c,d,e,f;
  cin >> a >> b >> c;

  d = a + b;
  e = b + c;
  f = a + c;
  
  if(d <= e && d <= f) {
      cout << d << endl;
  }else if (e <= d && e <= f) {
      cout << e << endl;
  }else {
      cout << f << endl;
  }
  return 0;
}


Measured memory_bytes: 256
n,l = map(int,input().split())
lst = [l+i-1 for i in range(1,n+1)]
if 0 in lst:
    print(sum(lst))
else:
    if l > 0:
        print(sum(lst)-l)
    if l < 0:
        print(sum(lst)-(l+n-1))



Measured memory_bytes: 2940
#include <stdio.h>

int M[100][100];

int main()
{
  int n,i,j;
  scanf("%d",&n);

  for(i=0;i<n;i++)
    {
      for(j=0;j<n;j++)
	{
	  M[i][j]=0;
	}
    }

  int k,u,v;
  
  for(i=0;i<n;i++)
    {
      scanf("%d",&u);
      scanf("%d",&k);
      for(j=0;j<k;j++)
	{
	  scanf("%d",&v);
	  M[u-1][v-1]=1;
	}
    }

   for(int i=0;i<n;i++)
    {
      for(int j=0;j<n;j++)
	{
	  if(j==n-1)
	    printf("%d",M[i][j]);
	  else
	    printf("%d ",M[i][j]);
     
	}
      printf("\n");
    }

   return 0;
}
	  
  



Measured memory_bytes: 2112
#include<bits/stdc++.h>
using namespace std;
#define ioS            ios::sync_with_stdio(false);cin.tie(0);
#define li             long int
#define lli            long li
#define ull            unsigned lli
#define pi             pair<int,int>
#define vi             vector<int>
#define vli            vector<li>
#define vlli           vector<lli>
#define vvi            vector<vector<int>>
#define pb             push_back
#define mp             make_pair
#define forn(i,s,n)    for(auto i=s;i<n;i++)               
#define forr(i,s,n)    for(auto i=s;i>=n;i--) 
const lli MOD = 1e9+7;
const lli mx = 1e7; 

void solve()
{
    int n;
    cin>>n;
    vi a(n); 
    li x=0;
    forn(i,0,n)
    {
        cin>>a[i];
    }
    li totalxor = 0;
    forn(i,0,n)
        totalxor ^= a[i]^a[++i];
    
    forn(i,0,n)
        cout<<(totalxor^a[i])<<" ";
    cout<<endl;
}


int32_t main()
{
    ioS
    // int t;
    // cin>>t;
    // while(t--)
        solve();
}

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

using namespace std;

int main(){

    string s, c, r, str;

    s = "Sunny";
    c = "Cloudy";
    r = "Rainy";

    cin >> str;


    if(str.compare(s) == 0){
        cout << c << endl;
    }
    else if(str.compare(c) == 0){
        cout << r << endl;
    }
    else if(str.compare(r) == 0){
        cout << s << endl;
    }

    return 0;

}





Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
A - Regular Triangle
https://atcoder.jp/contests/exawizards2019/tasks/exawizards2019_a

"""
import sys


def solve(A, B, C):
    if A == B and B == C:
        return 'Yes'
    return 'No'


def main(args):
    A, B, C = map(int, input().split())
    ans = solve(A, B, C)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 3060
// be name khoda
#include<bits/stdc++.h>

using namespace std;

#define F first
#define S second
#define int long long
#define mpr make_pair 
typedef long long ll;
#pragma GCC optimize("Ofast")

const int maxn = 3e5+10;
const int N = 1e6+5;
const int mod = 998244353;
const int inf = 1e9+10;

int A, B, n, k;
int fac[maxn];

ll pw(ll a, ll b)
{
    if(b == 0) return 1;
    ll x = pw(a,b/2); x = (x*x) % mod;
    if(b&1) x = (x*a) % mod;
    return x;
}

ll C(ll n, ll k)
{
    return (fac[n] * pw((fac[k] * fac[n-k]) % mod, mod-2)) % mod;
}

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

    cin>> n >> A >> B >> k;
    fac[0] = 1;
    for(int i = 1; i <= n; i++) fac[i] = (fac[i-1] * i) % mod;

    ll ans = 0;
    for(int x = 0; x <= n; x++)
        if((k-A*x) % B == 0)
        {
            int y = (k-A*x)/B;
            if(y < 0 || y > n) continue;
            (ans += (C(n,x) * C(n,y)) % mod) %= mod;
        }
    cout<< ans;
}





Measured memory_bytes: 2560
#include <stdio.h>

#define MAX 10000
#define NIL -1

typedef struct { int parent, left, right;} Node;

Node T[MAX];
int n, D[MAX], H[MAX];

void setDepth(int u,int d) {
	if(u == NIL) return;
	D[u] = d;
	setDepth(T[u].left, d+1);
	setDepth(T[u].right,d+1);
}

int setHeight(int u) {
	int h1 = 0, h2 = 0;
	if(T[u].left != NIL)
		h1 = setHeight(T[u].left)  + 1;
	if(T[u].right != NIL)
		h2 = setHeight(T[u].right) + 1;
	return H[u] = (h1 > h2 ? h1 : h2);
}

// 接点 u の兄弟を返す
int getSibling(int u) {
	if(T[u].parent == NIL) return NIL;
	if(T[T[u].parent].left != u && T[T[u].parent].left != NIL )
		return T[T[u].parent].left;
	if(T[T[u].parent].right != u && T[T[u].parent].right != NIL )
		return T[T[u].parent].right;
	return NIL;
}

void print(int u) {
	int deg = 0;
	printf("node %d: ",u);
	printf("parent = %d, ",T[u].parent);
	printf("sibling = %d, ",getSibling(u));
	if(T[u].left  != NIL) deg++;
	if(T[u].right != NIL) deg++;
	printf("degree = %d, ",deg);
	printf("depth = %d, ",D[u]);
	printf("height = %d, ",H[u]);
	
	if(T[u].parent == NIL) {
		printf("root\n");
	} else if(T[u].left == NIL && T[u].right == NIL) {
		printf("leaf\n");
	} else {
		printf("internal node\n");
	}
}

int main(void) {
	int i, v, l, r, root = 0;
	scanf("%d",&n);
	for(i=0;i<n;i++) T[i].parent = NIL;
	for(i=0;i<n;i++) {
		scanf("%d %d %d",&v,&l,&r);
		T[v].left  = l;
		T[v].right = r;
		if(l != NIL) T[l].parent = v;
		if(r != NIL) T[r].parent = v;
	}
	
	for(i=0; i<n; i++)
	if(T[i].parent == NIL) root = i;
	
	setDepth(root,0);
	setHeight(root);
	
	for(i=0;i<n;i++) print(i);
	
	return 0;
}



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

int main(){
    long long ans=0,sum=0,n,a,b;
    
    cin >>n>>a>>b;

    if(n==1 && a!=b){
        
        ans=0;

    }else if(a > b){
        ans=0;

    }else ans = abs((b*(n-1) + a) - (a*(n-1) + b)) + 1;

    //cout <<fixed<<setprecision(16)<< << endl;
    cout << ans << endl;

    //if(flag==1)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(N: int):
    print((N-1)*N//2)
    
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  int n;
  cin>>n;
  vector<ll> vec(n);
  for(int i=0;i<n;i++){
	cin>>vec[i];
  }
  sort(vec.rbegin(),vec.rend());
  ll ans=0;
  priority_queue<ll> que;
  for(int i=0;i<n;i++){
    if(i){
      	ans+=que.top();que.pop();
      	que.push(vec[i]);
    	que.push(vec[i]);
    }else{
      	que.push(vec[i]);
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 6912
#include<stdio.h>

int main(){
  int i,j,k;
  int N,X;
  scanf("%d %d",&N,&X);
  int A[N];
  for(i=0;i<N;i++)
    scanf("%d ",&A[i]);
  k=0,i=0,j=1;
  while(1){
    k+=A[i];
    i++;
    if(k<=X)
    j++;
    if(i==N)
      break;
  }
  
  printf("%d\n",j);
  return 0;
}





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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

    ll N;
    cin >> N;
    vector<ll> L(N);
    REP(i, N) cin >> L[i];
    sort(L.begin(), L.end());

    ll res = 0;
    for(int i=0;i<N;i++){
    	for(int j=i+1;j<N;j++){
    		for(int k=j+1;k<N;k++){
    			if(L[i] < L[j] + L[k] && L[j] < L[k] + L[i] && L[k] < L[i] + L[j]) res++;
    		}
    	}
    }
    cout << res << endl;
    return 0;
}

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

#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long hoge = 0; (hoge) < (n); ++ (hoge)) cerr << #x << "[" << hoge << "]: " << x[hoge] << '\n'
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef tuple<ll,ll> Pll;
typedef vector<ll> vll;
const ll INF = LLONG_MAX/10;
const ll MOD = 1e9+7;

//mod p(p:prime)上での行列

ll extgcd(ll a, ll b, ll &x, ll &y) {
    ll g = a; x = 1; y = 0;
    if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
    return g;
}

ll invMod(ll a, ll m) {
    ll x, y;
    if (extgcd(a, m, x, y) == 1) return (x + m) % m;
    else                         return 0; // unsolvable
}

template<int mod> struct Matrix {
    vector<vector<long long> > val;
    Matrix(int n, int m, long long x = 0) : val(n, vector<long long>(m, x)) {}
    void init(int n, int m, long long x = 0) {val.assign(n, vector<long long>(m, x));}
    size_t size() const {return val.size();}
    inline vector<long long>& operator [] (int i) {return val[i];}
};

//===================================================
// O( n )
template<int mod> Matrix<mod> identity(int n) {
    Matrix<mod> A(n, n);
    for (int i = 0; i < n; ++i) A[i][i] = 1;
    return A;
}

// O( n^3 )
template<int mod> Matrix<mod> mul(Matrix<mod> A, Matrix<mod> B) {
    Matrix<mod> C(A.size(), B[0].size());
    for (int i = 0; i < (ll)C.size(); ++i)
        for (int j = 0; j < (ll)C[i].size(); ++j)
            for (int k = 0; k < (ll)A[i].size(); ++k)
                C[i][j] = (C[i][j] + A[i][k] * B[k][j]%mod)%mod;
    return C;
}
// O( n^3 log e )
template<int mod> Matrix<mod> pow(Matrix<mod> A, ll e) {
    return e == 0 ? identity<mod>(A.size())  :
    e % 2 == 0 ? pow(mul(A, A), e/2) : mul(A, pow(A, e-1));
}


template<int mod>
ostream &operator<<(ostream &os, Matrix<mod> &v) {
    os << "[";
    for (int i = 0; i < (ll)v.size(); i++){
        if (i > 0) os << endl << " ";
        os << "[";
        for (int j = 0; j < (ll)v[i].size(); os << v[i][j++])
            if (j > 0) os << " ";
        os << "]";
    }
    os << "]";
    return os;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N,K;cin>>N>>K;
  Matrix<MOD> A(N,N);
  for(ll i=0;i<N;i++){
    for(ll j=0;j<N;j++){
      cin>>A[i][j];
    }
  }
  //cerr<<"!!"<<endl;
  Matrix<MOD> D=pow(A,K);
  //cerr<<D<<endl;
  ll ans = 0;
  for(ll i=0;i<N;i++){
    for(ll j=0;j<N;j++){
      ans = (ans+D[i][j])%MOD;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 5376
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
## dp ##
def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]
## math ##
def to_bin(x: int) -> str: return format(x, 'b') # rev => int(res, 2)
def to_oct(x: int) -> str: return format(x, 'o') # rev => int(res, 8)
def to_hex(x: int) -> str: return format(x, 'x') # rev => int(res, 16)
MOD=10**9+7
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(MAX_NUM+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(MAX_NUM**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, MAX_NUM+1, i):
            is_prime[j] = False
    return [i for i in range(MAX_NUM+1) if is_prime[i]]
## libs ##
from itertools import accumulate as acc
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left
#======================================================#

def main():
    q,h,s,d = MII()
    n = II()
    pay = [q*4,h*2,s,d/2]
    pay_sorted = sorted(pay)
    min1 = pay_sorted[0]
    min1_index = pay.index(min1)
    min2 = pay_sorted[1]
    min2_index = pay.index(min2)

    if min1_index == 0:
        print(int((n//0.25)*q))
    elif min1_index == 1:
        print(int((n//0.5)*h))
    elif min1_index == 2:
        print(int(n)*s)
    else:
        res = int(n//2)*d
        if n%2 == 1:
            res += pay[min2_index]
        print(res)

if __name__ == '__main__':
    main()

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

int h, w, ar[15];
bool used[15], ev;
char s[12][12];

inline bool isRev(char a[], char b[]) {
	for (int i = 0; i < h; i++) if (a[i] != b[h - 1 - i]) return false;
	return true;
}

bool dfs(int p, int n, int e) {
	if (e) {
		for (int i = 0; i < h; i++) {
			used[i] = true; ar[h / 2] = i;
			if (dfs(0, 0, 0)) return true;
			used[i] = false;
		}
		return false;
	}
	else if (n != h / 2) {
		while (used[p]) p++;
		for (int i = p + 1; i < h; i++) if (!used[i]) {
			used[i] = true;
			ar[n] = p; ar[h - 1 - n] = i;
			if (dfs(p + 1, n + 1, 0)) return true;
			used[i] = false;
		}
		return false;
	}
	else {
		char temp[15][15];
		bool u[15] = {}, ev = !(w % 2);
		for (int i = 0; i < w; i++) for (int j = 0; j < h; j++) temp[i][j] = s[ar[j]][i];
		for (int i = 0; i < w; i++) {
			for (int j = i + 1; j < w && !u[i]; j++) if (!u[j])
				u[i] = u[j] = isRev(temp[i], temp[j]);
			if (!u[i] && !ev) u[i] = ev = isRev(temp[i], temp[i]);
			if (!u[i]) return false;
		}
		return true;
	}
}

int main() {
	scanf("%d%d", &h, &w);
	for (int i = 0; i < h; i++) scanf("%s", s[i]);
	puts(dfs(0, 0, h % 2) ? "YES" : "NO");

	return 0;
}

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

int main()
{
    long long a, v, b, w, t;
    cin >> a >> v >> b >> w >> t;
    if(v <= w){
        cout << "NO" << endl;
        return 0;
    }else if(a > b){
        for(long long i = 0; i < t; i++){
            b -= w;
            a -= v;
            if(a <= b){
                cout << "YES" << endl;
                return 0;
            }
        }
        cout << "NO" << endl;
        return 0;
    }else{
        for(long long i = 0; i < t; i++){
            a += v;
            b += w;
            if(a >= b){
                cout << "YES" << endl;
                return 0;
            }
        }
        cout << "NO" << endl;
        return 0;
    }
}

Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

template<int Modulo = MOD> struct Mint {
	Int val;
	constexpr Mint(Int v = 0) noexcept : val(v% Modulo) {
		if (val < 0) v += Modulo;
	}
	constexpr int getmod() { return Modulo; }
	constexpr Mint operator - () const noexcept { return val ? Modulo - val : 0; }
	constexpr Mint operator + (const Mint& r) const noexcept { return Mint(*this) += r; }
	constexpr Mint operator - (const Mint& r) const noexcept { return Mint(*this) -= r; }
	constexpr Mint operator * (const Mint& r) const noexcept { return Mint(*this) *= r; }
	constexpr Mint operator / (const Mint& r) const noexcept { return Mint(*this) /= r; }
	constexpr Mint& operator += (const Mint& r) noexcept {
		val += r.val;
		if (val >= Modulo) val -= Modulo;
		return *this;
	}
	constexpr Mint& operator -= (const Mint& r) noexcept {
		val -= r.val;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr Mint& operator *= (const Mint& r) noexcept {
		val = val * r.val % Modulo;
		return *this;
	}
	constexpr Mint& operator /= (const Mint& r) noexcept {
		Int a = r.val, b = Modulo, u = 1, v = 0;
		while (b) {
			Int t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		val = val * u % Modulo;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr bool operator == (const Mint& r) const noexcept {
		return this->val == r.val;
	}
	constexpr bool operator != (const Mint& r) const noexcept {
		return this->val != r.val;
	}
	friend ostream& operator << (ostream& os, const Mint<Modulo>& x) noexcept {
		return os << x.val;
	}
	friend istream& operator >> (istream& is, Mint<Modulo>& x) noexcept {
		Int tmp; is >> tmp;
		x = Mint<Modulo>(tmp);
		return is;
	}
	friend constexpr Mint<Modulo> modpow(const Mint<Modulo>& a, Int n) noexcept {
		Mint res(1), tmp = a;
		while (n > 0) {
			if (n & 1) res *= tmp;
			tmp *= tmp;
			n >>= 1;
		}
		return res;
	}
};

using mint = Mint<>;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int d;
	cin >> d;

	if (d == 25)printf("Christmas\n");
	else if(d==24)printf("Christmas Eve\n");
	else if (d == 23)printf("Christmas Eve Eve\n");
	else if (d == 22)printf("Christmas Eve Eve Eve\n");


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

int main()
{
	ios;
	int n,i;
	ll ans=0,s=0, mod= (int)1e9+7;
	cin>>n;
	vector<ll> a(200005);
	for(i=0;i<n;i++) 
	{
		cin>>a[i];
		s=(s+a[i])%mod;
	}
//	cout<<s<<" ";
	for(i=0;i<n-1;i++)
	{
		s=(s-a[i]+mod)%mod;
		ans= (ans +  (a[i]*s)%mod)%mod;
//		cout<<s<<" "<<ans<<"\n";
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 4776
#include <bits/stdc++.h>
typedef long long ll;
#define INF 1000000000
#define MOD 1000000007
int dx[4]={1,0,-1,0},dy[4]={0,-1,0,1};
using namespace std;
int main(void){
    int n,m;
    cin>>n>>m;
    vector<pair<int,pair<int,int>>>data(m);
    for(int i=0;i<m;i++){
        cin>>data[i].first>>data[i].second.first;
        data[i].second.second=i;
    }
    sort(data.begin(),data.end());
    int now=data[0].first;
    int i=0;
    int h,l=1;
    vector<string>ans(m);
    while(i<m){
        string s,t;
        if(now==data[i].first){
            h=now;
            s=to_string(h);
            t=to_string(l);
            while(s.size()<6){
                s='0'+s;
            }
            while(t.size()<6){
                t='0'+t;
            }
            ans[data[i].second.second]=s+t;
            l++;
        }else{
            now=data[i].first;
            h=now;
            l=1;
             s=to_string(h);
            t=to_string(l);
            while(s.size()<6){
                s='0'+s;
            }
            while(t.size()<6){
                t='0'+t;
            }
            ans[data[i].second.second]=s+t;
            l++;
        }
        i++;
    }
    for(int i=0;i<m;i++){
        cout<<ans[i]<<endl;
    }
 return 0;   
}

Measured memory_bytes: 8192
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> P;
static const double EPS = 1e-5;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
int toint(char s){
  if(s=='I') return 1;
  if(s=='V') return 5;
  if(s=='X') return 10;
  if(s=='L') return 50;
  if(s=='C') return 100;
  if(s=='D') return 500;
  if(s=='M') return 1000;
}
int main(void){
  string line;
  while(cin>>line){
    int ret=0;
    REP(i,line.size()-1){
      if(toint(line[i+1])-toint(line[i])>0){
        ret -= toint(line[i]);
      }else{
        ret += toint(line[i]);
      }
    }
    ret += toint(line[line.size()-1]);
    cout<<ret<<endl;
  }    
  return 0;
}

Measured memory_bytes: 0
# include <cstdio>
# include <cmath>
# include <cstring>
# include <string>
# include <vector>
# include <queue>
# include <map>
# include <algorithm>
# include <iostream>

using namespace std;

const int MAX_N = 256;

int n;
int a[MAX_N];

int main ()
{
	int i;
	cin >> n;
	for (i = 0; i < 2 * n; i ++)
		cin >> a[i];
	sort (a, a + 2 * n);
	int ans = 0;
	for (i = 0; i < 2 * n; i += 2)
		ans += a[i];
	printf ("%d\n", ans);

	return 0;
}


Measured memory_bytes: 256
//srinivas
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/assoc_container.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
// using namespace __gnu_pbds;
using namespace std;

#define all(c) (c).begin(),(c).end()
#define endl "\n"
#define ff first
#define ss second
#define allr(c) (c).rbegin(),(c).rend()
#define fr(x,in,n,r) for(x=in;x<n;x+=r)
#define ifr(x,n) for(x=0;x<n;x++)
#define dfr(x,n) for(x=n-1;x>=0;x--)
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define pof(a) pop_front(a)
#define pob(a) pop_back(a)
#define eb(a) emplace_back(a)
#define ef(a) emplace_front(a)
typedef int ll;
typedef map<ll,ll> mll;
typedef map<string,ll> msll;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef long double ld;
#define mod 1000000007

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string a,b;
    ll i,j,n,m;
    cin>>a>>b;
    n=a.length();
    m=b.length();
    ll dp[n+1][m+1];
    ifr(i,n+1)dp[i][0]=0;
    ifr(i,m+1)dp[0][i]=0;
    fr(i,1,n+1,1){
  		fr(j,1,m+1,1){
  			dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
  			if(a[i-1]==b[j-1])
  				dp[i][j]=max(dp[i][j],dp[i-1][j-1]+1);
  		}
    }
    // cout<<dp[n][m]<<endl;
    string ans="";
    i=n;
    j=m;
    // ifr(i,n+1){
    // 	ifr(j,m+1)
    // 	cout<<dp[i][j]<<" ";
    // 	cout<<endl;
    // }
    while(i>0 && j>0){
    	if(dp[i][j]==dp[i-1][j])
    		i--;
    	else{
    		if(dp[i][j]==dp[i][j-1])
    			j--;
    		else{
    			if(a[i-1]==b[j-1]){
    				// cout<<b[j-1];
    				ans+=b[j-1];
    			}
    			i--;
    			j--;
    		}
    	}
    }
    reverse(all(ans));
    cout<<ans<<endl;
    return 0;
}

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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)

using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;

constexpr int MOD = 1000000007;

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

    int n, W;
    cin >> n >> W;

    vi v(n), w(n);
    rep(i, 0, n) { cin >> v[i] >> w[i]; }

    vi dp(W + 1, 0);
    rep(i, 0, n) {
        rrep(j, 1, W + 1) {
            if (j - w[i] >= 0) { dp[j] = max(dp[j], dp[j - w[i]] + v[i]);}
        }
    }
    cout << dp[W] << endl;
    return 0;
}


Measured memory_bytes: 3228
#include <bits/stdc++.h>
#define MAX 1000010
#define MOD 998244353
using namespace std;

vector<int> primes;
int temp[1234];
vector<int> factors[MAX];
int coeff[MAX];
int cur[MAX];

inline int add(int a, int b)
{
	return (a + b) % MOD;
}

inline int sub(int a, int b)
{
	return (MOD + a - b) % MOD;
}

inline int prod(int a, int b)
{
	return (long long)a * b % MOD;
}

void factor(int idx, int x)
{
	vector<int> curList;
	curList.push_back(1);
	int t = x;
	for (int i : primes)
	{
		if (t % i == 0)
		{
			vector<int> nxtList;
			int cnt = 0;
			while (t % i == 0)
			{
				t /= i;
				cnt++;
			}
			int coeff = 1;
			for (int j = 0; j <= cnt; j++)
			{
				for (int k : curList) nxtList.push_back(k * coeff);
				coeff *= i;
			}
			curList = nxtList;
		}
	}
	if (t > 1)
	{
		vector<int> nxtList;
		for (int i : curList) nxtList.push_back(i * t);
		for (int i : nxtList) curList.push_back(i);
	}
	for (int i : curList) factors[i].push_back(x / i);
}

int main(void)
{
	for (int i = 2; i < 1234; i++)
	{
		if (temp[i]) continue;
		primes.push_back(i);
		for (int j = 2 * i; j < 1234; j += i) temp[j] = 1;
	}

	for (int i = 1; i < MAX; i++)
	{
		coeff[i] = sub(i, cur[i]);
		for (int j = 2; i * j < MAX; j++) cur[i * j] = add(cur[i * j], prod(prod(j, j), coeff[i]));
	}

	int N;
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		int t;
		cin >> t;
		factor(i, t);
	}
	int ans = 0;
	for (int i = 1; i < MAX; i++)
	{
		int sum = 0;
		int sqSum = 0;
		for (int j : factors[i])
		{
			sum = add(sum, j);
			sqSum = add(sqSum, prod(j, j));
		}
		sum = prod(sum, sum);
		sum = sub(sum, sqSum);
		ans = add(ans, prod(sum, coeff[i]));
	}
	ans = prod(ans, (MOD + 1) / 2);
	cout << ans << endl;
	return 0;
}


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

using namespace std;

char str[10];

int main(){
    scanf("%s",str);
    for(int i=1;i<strlen(str);i++){
        if(str[i]=='C' && str[i-1]=='A'){
            puts("Yes");
            return 0;
        }
    }
    puts("No");
    return 0;
}


Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * b.cc: B: Maximum Difference
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100;

/* typedef */

/* global variables */

int as[MAX_N];

/* subroutines */

/* main */

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &as[i]);

  int maxd = 0;
  for (int i = 0; i < n; i++)
    for (int j = i + 1; j < n; j++) {
      int d = abs(as[i] - as[j]);
      if (maxd < d) maxd = d;
    }

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


Measured memory_bytes: 256
O = list(str(input()))
E = list(str(input()))

list = []

if len(O)==len(E):
    for i in range(len(O)):
        list.append(O[i])
        list.append(E[i])

else:
    for i in range(len(E)):
        list.append(O[i])
        list.append(E[i])
    list.append(O[-1])

L="".join(list)
print(L)


Measured memory_bytes: 9064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn=3e5+100;
ll par[maxn];
ll find(ll v)
{
    if(v==par[v])
    return v;
    return par[v]=find(par[v]);
}
void merge(ll x,ll y)
{
    x=find(x);
    y=find(y);
    if(x==y)
    return;
    par[x]=y;
}
int main()
{
    map<ll,ll> h;
    ll n,m;
    cin>>n>>m;
    for(ll i=1;i<=n;i++)
    par[i]=i;
    for(int i=0;i<m;i++)
    {
        ll x,y;
        cin>>x>>y;
        merge(x,y);
    }
    for(int i=1;i<=n;i++)
    {
        ll x=par[find(i)];
        h[x]++;
    }
    ll res=0;
    for(auto it:h)
    res=max(res,it.second);
    cout<<res;
    return 0;
}


Measured memory_bytes: 17516
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <string>
#include <map>

typedef long long ll;

using namespace std;
int main() {
    ll n, x;
    cin >> n >> x;
    vector<ll> a(n+1);
    for (int i = 0; i<n; ++i) cin >> a[i];
    a[n] = x;
    sort(a.begin(), a.end());
    for(auto it = a.begin(); it!=a.end()-1; ++it){
        *it = *(it+1)-*it;
    }
    ll p = a[0];
    ll q, d;
    for(auto it = a.begin()+1; it!=a.end()-1; ++it){
        q = min(p,*it);
        p = max(p,*it);
        while(true){
            d = p%q;
            p = q;
            q = d;
            if(d==0) break;
        }
    }
    cout << p << endl;
    
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>

using namespace std;

const int size = 31;

char map[size][size];
char map2[size][size];

struct Peep {
  int dir;
  int x;
  int y;
  Peep(int dir, int x, int y) : dir(dir), x(x), y(y) {}
};

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

int getDir(char c) {
  return c == 'N' ? 1
      : c == 'E' ? 0
      : c == 'W' ? 2
      : c == 'S' ? 3
      : -1;
}
char dirs[] = {'E', 'N', 'W', 'S'};

int main()
{
  int w, h;
  while(cin >> w >> h, w || h) {
    vector<Peep> peeps;
    int numPeeps = 0;
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        char c;
        cin >> c;
        int dir = getDir(c);
        if(dir != -1) {
          peeps.push_back(Peep(dir, j, i));
          numPeeps++;
        }
        map[i][j] = c;
      }
    }
    int t;
    for (t = 0; t <= 180 && numPeeps > 0; t++) {
      for (int i = 1; i < h-1; i++) {
        for (int j = 1; j < w-1; j++) {
          int dir = getDir(map[i][j]);
          if (dir != -1) {
            for (int k = 0; k < 4; k++) {
              int nextX = j + dx[(dir+k+3)%4];
              int nextY = i + dy[(dir+k+3)%4];
              char nextC = map[nextY][nextX];
              if(nextC == '.' || nextC == 'X') {
                map[i][j] = dirs[(dir+k+3)%4];
//                cout << "acc:" << nextX << ", "<< nextY << ", " << map[i][j]<<endl;
                break;
              }
              else {
//                cout << "neg:" << nextX << ", "<< nextY << ", " << dirs[(dir+k+3)%4]<<endl;
              }
            }
          }
        }
      }
      for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
          map2[i][j] = map[i][j];
        }
      }

      for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
          if (map[i][j] != '.' && map[i][j] != 'X') continue;
          for (int k = 0; k < 4; k++) {
            int neibX = j + dx[k];
            int neibY = i + dy[k];
            if (neibX < 0 || w <= neibX || neibY < 0 || h <= neibY) continue;
            char neibC = map[neibY][neibX];
            int dir = getDir(neibC);
            if (dir == (k+2)%4) {
              if (map[i][j] == 'X') {
                map2[neibY][neibX] = '.';
                numPeeps--;
              }
              else {
                map2[i][j] = dirs[dir];
                map2[neibY][neibX] = '.';
              }
              break;
            }
          }
        }
      }
/*      for (int i = 0; i < h; i++) {
        cout << "bf:" << map[i] << endl;
      }
*/      for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
          map[i][j] = map2[i][j];
        }
//        cout << "af:" << map[i] << endl;
      }
//      cout << endl;
    }
    if (t <= 180) cout << t << endl;
    else cout << "NA" << endl;

  }
  return 0;
}

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

#define ll long long

using namespace std;

int n;
int main() {
    cin >> n;
    int last, x;
    for (int i = 0; i < n; ++i) {
        cin >> x;
        if (!i) {
            last = x - 1;
            continue;
        } else {
            if (x < last) {
                cout << "No";
                return 0;
            }
            last = x > last ? x - 1 : x;
        }
    }

    cout << "Yes";
    return 0;
}


Measured memory_bytes: 256
#include <cstdlib>
#include <iostream>
#include <string>
#include <time.h>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
using namespace std;

#define huge 1000000007

int main(void) {

	long long N = 0, M = 0;
	cin >> N >> M;
	long res = 0;

	if (2 * N > M) {
		res += M/2;
	}
	else {
		res += N;
		M -= 2 * N;
		res += M / 4;
	}

	cout << res << endl;

	return 0;




}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using ll = long long int;

int main(){
    ll N; cin >> N;
    vll A(N); 
    for(int i=0; i<N; i++){
        cin >> A[i];
    }
    sort(A.begin(),A.end());
    vll m(100001, 0);
    for(int i=0; i<N; i++){
        m[A[i]]++;
    }
    sort(m.begin(),m.end(),greater<ll>());
    ll even = 0, odd = 0;
    for(int i=0; i<100001; i++){
        if(m[i] == 0){break;}
        else{
            if(m[i]%2==0){even++;}else{odd++;}
        }
    }
    if(even%2==0){cout << odd + even;}
    else{cout << odd + even - 1;}
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main(void) {
  int N, A, B, C;
  cin >> N >> A >> B >> C;
  vector <string> s(N);
  for (int i = 0; i < N; i++) cin >> s[i];

  if ((A+B+C)==0) {
    cout << "No" << endl;
    return 0;
  }
  if ((A+B+C)==1) {
    if ((s[0]=="AB") && ((A+B)==0)) {
      cout << "No" << endl;
      return 0;
    }
    if ((s[0]=="BC") && ((B+C)==0)) {
      cout << "No" << endl;
      return 0;
    }
    if ((s[0]=="AC") && ((A+C)==0)) {
      cout << "No" << endl;
      return 0;
    }
  }

  vector <string> ans(N);
  for (int i = 0; i < N; i++) {

    if ((s[i]=="AB") && ((A+B)==0)) {
      cout << "No" << endl;
      return 0;
    }
    if ((s[i]=="BC") && ((B+C)==0)) {
      cout << "No" << endl;
      return 0;
    }
    if ((s[i]=="AC") && ((A+C)==0)) {
      cout << "No" << endl;
      return 0;
    }

    // どちらかが0
    else if ((s[i]=="AB") && (A==0)) {
      A++;
      B--;
      ans[i] = "A";
    }
    else if ((s[i]=="AB") && (B==0)) {
      A--;
      B++;
      ans[i] = "B";
    }
    else if ((s[i]=="AC") && (A==0)) {
      C--;
      A++;
      ans[i] = "A";
    }
    else if ((s[i]=="AC") && (C==0)) {
      A--;
      C++;
      ans[i] = "C";
    }
    else if ((s[i]=="BC") && (C==0)) {
      B--;
      C++;
      ans[i] = "C";
    }
    else if ((s[i]=="BC") && (B==0)) {
      C--;
      B++;
      ans[i] = "B";
    }

    // 両方1
    else if ((s[i]=="AB") && (A==1) && (B==1)) {
      if (i < (N-1)) {
        if ((s[i+1]=="AB") || (s[i+1]=="AC")) {
          A++;
          B--;
          ans[i] = "A";
        } else {
          A--;
          B++;
          ans[i] = "B";
        }
      } else { // last
        A++;
        B--;
        ans[i] = "A";
      }
    }
    else if ((s[i]=="BC") && (B==1) && (C==1)) {
      if (i < (N-1)) {
        if ((s[i+1]=="AB") || (s[i+1]=="BC")) {
          B++;
          C--;
          ans[i] = "B";
        } else {
          B--;
          C++;
          ans[i] = "C";
        }
      } else { // last
        B++;
        C--;
        ans[i] = "B";
      }
    }
    else if ((s[i]=="AC") && (A==1) && (C==1)) {
      if (i < (N-1)) {
        if ((s[i+1]=="AB") || (s[i+1]=="AC")) {
          A++;
          C--;
          ans[i] = "A";
        } else {
          A--;
          C++;
          ans[i] = "C";
        }
      } else { // last
        A++;
        C--;
        ans[i] = "A";
      }
    }

    // 上記以外
    else if (s[i]=="AB") {
      if (A>B) {
        A--;
        B++;
        ans[i] = "B";
      } else {
        A++;
        B--;
        ans[i] = "A";
      }
    }
    else if (s[i]=="BC") {
      if (B>C) {
        B--;
        C++;
        ans[i] = "C";
      } else {
        B++;
        C--;
       ans[i] = "B";
      }
    }
    else if (s[i]=="AC") {
      if (A>C) {
        A--;
        C++;
        ans[i] = "C";
      } else {
        A++;
        C--;
        ans[i] = "A";
      }
    }
  }
  
  // output
  cout << "Yes" << endl;
  for (int i = 0; i < N; i++) {
    cout << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 9604
#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++)


int main() {
  int n;
  cin >>n;
  vector<int> a(n);
  rep(i,n) {
    cin>>a.at(i);
  }
  sort(a.begin(),a.end());
  double ans=a.at(0);
  rep2(i,1,n){
    ans=(ans+a.at(i))/2;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		sc.close();
		BigDecimal L0 = new BigDecimal(2);
		BigDecimal L1 = new BigDecimal(1);
		BigDecimal result = new BigDecimal(0);
		if (N == 1) {
			result = new BigDecimal(1);
		} else {
			for (int i = 2; i <= N; i++) {
				result = L0.add(L1);
				L0 = L1;
				L1 = result;
			}
		}
		System.out.println(result);
	}
}

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

class Program
{
	static void Main()
	{
        long N = long.Parse(Console.ReadLine());

        long ans = long.MaxValue;
        for (long i = 1; i*i <= N; i++)
        {
            if (N % i != 0) continue;
            long now = (N / i) + i - 2;
            ans = Math.Min(ans, now);
        }
        Console.WriteLine(ans);
	}

	static string[] InStrs()
	{
		return Console.ReadLine().Split(' ');
	}
	static IEnumerable<int> InInts()
	{
		return Console.ReadLine().Split(' ').Select(x => int.Parse(x));
	}
	static IEnumerable<long> InLongs()
	{
		return Console.ReadLine().Split(' ').Select(x => long.Parse(x));
	}
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std ;
using namespace atcoder ;
using ll = long long ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
using pll = pair<ll,ll> ;
const int INF = 1e9 ;
void chmin(int &a,int b){if(a>b) a = b ;}
void chmax(ll &a,ll b){if(a<b) a = b ;}
void YorN(bool a){cout << (a?"YES":"NO") << "\n" ;}

int main(){
	int n,q ;
	cin >> n >> q ;
	fenwick_tree<ll> ft(n) ;
	for(int i=0;i<n;i++){
		ll a ; cin >> a ;
		ft.add(i,a) ;
	}
	while(q--){
		ll t,u,v ;
		cin >> t >> u >> v ;
		if(t) cout << ft.sum(u,v) << endl ;
		else ft.add(u,v) ;
	}
}

Measured memory_bytes: 8216
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(ll i = (begin); i < (end); i++)
#define rep(i, n) FOR(i, 0, n)
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using pii = pair<int, int>; using pll = pair<ll, ll>; using vi = vector<int>; using vl = vector<ll>;
template<typename T, typename U> static void chmin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> static void chmax(T &x, U y) { if (x < y) x = y; }

signed main() {
    int n;
    cin>>n;
    if (n % 1000 == 0) {
        cout << 0;
        return 0;
    }
    cout<<(1000 - (n % 1000));
    return 0;
}

Measured memory_bytes: 3576
N, M, C = map(int, input().split())
B, *A = [list(map(int, input().split())) for i in range(N+1)]
cnt = 0

for i in range(N):
    sum = 0
    for j in range(M):
        sum += A[i][j]*B[j]
    if sum+C > 0:
        cnt += 1

print(cnt)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
void main_sub(void);
int main(int argc, char* argv[]) {
    main_sub();
    return 0;
}
// int を int64_t にする
// g++ に -DUSE_STRICT_INT をつけるか、
// 下のコメントアウトを外すと無効化
#define USE_STRICT_INT
using i64 = int64_t;
#ifndef USE_STRICT_INT
#define int i64
#endif
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF = (1 << 30);
constexpr i64 INFL = (1LL << 62);
constexpr i64 MOD = 1000000007;

vector<vector<vector<int>>> dp(110, vector<vector<int>>(4, vector<int>(2, 0)));

void main_sub(void) {
    string s;
    cin >> s;
    int m;
    cin >> m;
    int n = s.size();
    dp[0][0][0] = 1;
    rep(i, n) rep(j, 4) rep(k, 2) {
        int x = s[i] - '0';
        rep(d, 10) {
            int ni = i + 1, nj = j, nk = k;
            if (d != 0) nj++;
            if (nj > m) continue;
            if (k == 0) {
                if (d > x) continue;
                if (d < x) nk = 1;
            }
            dp[ni][nj][nk] += dp[i][j][k];
        }
    }
    cout << dp[n][m][0] + dp[n][m][1] << endl;
    return;
}

Measured memory_bytes: 256
n, m = map(int,input().split())
A = [list(map(int,input().split()))for i in range(n)]
b = [list(map(int,input().split()))for i in range(m)]
C = []

for i in range(n):
    c = 0
    for j in range(m):
        c += A[i][j]*b[j][0]
    C.append(c)
        
for i in range(len(C)):
    print(C[i])


Measured memory_bytes: 6032
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main() {
	int a,b,c;
	cin>>a>>b>>c;
	if(a==b||b==c||a==c){
		if(a==b&&a==c){
			cout<<"No"<<endl;
		}
		else cout<<"Yes"<<endl;
	}
	else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256