akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <iostream>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

int n;
int n_;
P cnt[6];
ll a,b;
vector<P> xy[5];
vector<P> one;
vector<P> two;
vector<ll> Bval;
int dat[1<<22];

void add(int k,int a){
	k+=n_-1;
	dat[k]+=a;
	while(k>0){
		k=(k-1)/2;
		dat[k]=dat[k*2+1]+dat[k*2+2];
	}
}

int query(int a,int b,int k=0,int l=0,int r=n_){
	if(r<=a || b<=l)return 0;
	if(a<=l && r<=b)return dat[k];
	int vl=query(a,b,k*2+1,l,(l+r)/2);
	int vr=query(a,b,k*2+2,(l+r)/2,r);
	return vl+vr;
}

int main(void){
	scanf("%d%lld%lld",&n,&a,&b);
	for(int i=0;i<n;i++){
		ll x,y;
		int t;
		scanf("%d%lld%lld",&t,&x,&y);
		t--;
		xy[t].push_back(P(x,y));
		cnt[t].first++;
	}
	for(int i=0;i<5;i++){
		cnt[i].second=i;
		xy[i].push_back(P(0,0));
	}
	sort(cnt,cnt+5);
	for(int i=0;i<xy[cnt[0].second].size();i++){
		for(int j=0;j<xy[cnt[1].second].size();j++){
			for(int k=0;k<xy[cnt[2].second].size();k++){
				ll xx=xy[cnt[0].second][i].first+xy[cnt[1].second][j].first+xy[cnt[2].second][k].first;
				ll yy=xy[cnt[0].second][i].second+xy[cnt[1].second][j].second+xy[cnt[2].second][k].second;
				one.push_back(P(xx,yy));
				Bval.push_back(yy);
			}
		}
	}
	sort(one.begin(),one.end());
	reverse(one.begin(),one.end());
	sort(Bval.begin(),Bval.end());
	Bval.erase(unique(Bval.begin(),Bval.end()),Bval.end());
	for(int i=0;i<one.size();i++){
		one[i].second=lower_bound(Bval.begin(),Bval.end(),one[i].second)-Bval.begin();
	}
	for(int i=0;i<xy[cnt[3].second].size();i++){
		for(int j=0;j<xy[cnt[4].second].size();j++){
			ll xx=xy[cnt[3].second][i].first+xy[cnt[4].second][j].first;
			ll yy=xy[cnt[3].second][i].second+xy[cnt[4].second][j].second;
			two.push_back(P(xx,yy));
		}
	}
	sort(two.begin(),two.end());
	n_=1;
	while(n_<one.size())n_*=2;
	int l=0,r=0;
	bool flag=false;
	for(int i=0;i<two.size();i++){
		while(l<one.size() && one[l].first+two[i].first>=a){
			add(one[l].second,1);
			l++;
		}
		while(l>r && one[r].first+two[i].first>b){
			add(one[r].second,-1);
			r++;
		}
		int al=lower_bound(Bval.begin(),Bval.end(),a-two[i].second)-Bval.begin();
		int ar=upper_bound(Bval.begin(),Bval.end(),b-two[i].second)-Bval.begin();
		if(query(al,ar)>0)flag=true;
	}
	printf("%s\n",flag?"Yes":"No");
	return 0;
}

Measured memory_bytes: 43348
def main():
    N, K = map(int, input().split())
    S = input()
    class LL:
        def __init__(self, v, p, n):
            self.v = v
            self.p = p
            self.n = n
    T = []
    m = 0
    for s in S:
        if s == '0':
            if m >= 0:
                T.append(m)
                m = 0
            m -= 1
        else:
            if m < 0:
                T.append(-m)
                m = 0
            m += 1
    T.append(abs(m))
    if m < 0:
        T.append(0)
    m = t = sum(T[:K * 2 + 1])
    L = K * 2 + 1
    for i in range(0, len(T) - L, 2):
        t = t + T[L + i] + T[L + i + 1] - T[i] - T[i + 1]
        m = max(m, t)
    print(m)
main()


Measured memory_bytes: 4596
import heapq as h

n,m = map(int,input().split())
l = list(map(lambda x:-int(x),input().split()))
h.heapify(l)
for _ in range(m):
  a = h.heappop(l)
  a *= -1
  a //= 2
  a *= -1
  h.heappush(l,a)
print(-sum(l))

Measured memory_bytes: 14180
#include<iostream>
#include<string>
#include<map>
using namespace std;
int main() {
	for (int i = 0; i < 1000; i++){
		string s; cin >> s;
		bool b = true;
		if (s.size() == 1)b = true;
		else{
			for (int i = 0; i < s.size() - 1; i++) {
				if (s[i] == 'A') {
					if (s[i + 1] != 'B'&&s[i + 1] != 'D') {
						b = false;
					}
				}
				else if (s[i] == 'B') {
					if (s[i + 1] != 'A'&&s[i + 1] != 'C'&&s[i + 1] != 'E') {
						b = false;
					}
				}
				else if (s[i] == 'C') {
					if (s[i + 1] != 'B'&&s[i + 1] != 'F') {
						b = false;
					}
				}
				else if (s[i] == 'F') {
					if (s[i + 1] != 'C'&&s[i + 1] != 'E'&&s[i + 1] != 'I') {
						b = false;
					}
				}
				else if (s[i] == 'I') {
					if (s[i + 1] != 'F'&&s[i + 1] != 'H') {
						b = false;
					}
				}
				else if (s[i] == 'H') {
					if (s[i + 1] != 'I'&&s[i + 1] != 'G'&&s[i + 1] != 'E') {
						b = false;
					}
				}
				else if (s[i] == 'G') {
					if (s[i + 1] != 'H'&&s[i + 1] != 'D') {
						b = false;
					}
				}
				else if (s[i] == 'D') {
					if (s[i + 1] != 'A'&&s[i + 1] != 'G'&&s[i + 1] != 'E') {
						b = false;
					}
				}
				else if (s[i] == 'E') {
					if (s[i + 1] != 'B'&&s[i + 1] != 'D'&&s[i + 1] != 'F'&&s[i + 1] != 'H') {
						b = false;
					}
				}
			}
		}
		if (b)cout << s << endl;
	}
}

Measured memory_bytes: 3192
N = int(input())
A = [int(i) for i in input().split()]
B = list(map(abs,A))
t = 0
for c in A:
    if c < 0:
        t += 1
if t%2 == 0:
    print(sum(B))
else:
    print(sum(B) - 2*min(B))


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

template<class Monoid> struct SegmentTree {
    using Function = function< Monoid(Monoid, Monoid) >;

    int N; vector<Monoid> segment;
    const Function func;
    const Monoid id;

    SegmentTree(int n, const Function func, const Monoid id) : func(func), id(id) {
        N = 1;
        while (N < n) N <<= 1;
        segment.assign(2 * N, id);
    }

    void set(int num, Monoid x) {
        segment[N + num] = x;
    }
    void build() {
        for (int k = N - 1; k > 0; k--) {
            segment[k] = func(segment[2*k], segment[2*k+1]);
        }
    }
    void update(int k, Monoid x) {
        k = k + N; segment[k] = x;
        while(k >>= 1) {
            segment[k] = func(segment[2*k], segment[2*k+1]);
        }
    }

    // query:[a, b)
    Monoid query(int a, int b) {
        Monoid L = id; Monoid R = id; a += N; b += N;
        for (; a < b; a >>= 1, b >>= 1) {
            if (a & 1) L = func(L, segment[a++]);
            if (b & 1) R = func(segment[--b], R);
        }
        return func(L, R);
    }
    // 0-based numbering;
    Monoid operator[](const int k) const {
        return segment[N+k];
    }
};


int main(){
    int n, m; cin >> n >> m;
    string s; cin >> s;
    SegmentTree<int> stmin(n+1, [](int a, int b){return min(a, b);}, 1e8);
    stmin.update(n, 0);
    for (int i = n-1; i >= 0; i--) {
        if (s[i] == '1') continue;
        stmin.update(i, stmin.query(i+1, min(n+1, i+m+1))+1);
    }
    if (stmin[0] >= 1e8) cout << -1 << endl;
    else {
        vector<int> ans(stmin[0], -1);
        int curr = stmin[0]; int iprev = 0;
        for (int i = 1; i <= n; i++) {
            if (stmin[i] == curr-1) {
                ans[stmin[0]-curr] = i-iprev;
                curr--;
                iprev = i;
            }
        }
        for (int i = 0; i < stmin[0]; i++) {
            if (i) cout << " ";
            cout << ans[i];
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

void Impossible(){
    cout<<0<<endl;
    exit(0);
}

int main(){
    int N; cin>>N;
    vector<int> A(N);
    rep(n,0,N) cin>>A.at(n);

    vector<int> D(N,0);
    for(auto a:A){
        D.at(a)++;
    }

    bool possible=true;
    rep(n,0,N){
        if(n==0){
            if(N%2){
                if(D.at(n)!=1){possible=false; break;}
            }
            else{
                if(D.at(n)!=0){possible=false; break;}
            }
        }else{
            if(N%2){
                if(n%2){
                    if(D.at(n)!=0){possible=false; break;}
                }else{
                    if(D.at(n)!=2){possible=false; break;}
                }
            }else{
                if(n%2==0){
                    if(D.at(n)!=0){possible=false; break;}
                }else{
                    if(D.at(n)!=2){possible=false; break;}
                }
            }
        }
    }
    if(!possible) Impossible();

    int64_t ans=1;
    rep(n,0,N/2){
        ans*=2;
        ans%=MOD;
    }

    cout<<ans<<endl;
}

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

int main() {
  int N;
  cin >> N;
  
    // 小数点以下10桁まで
  cout << fixed << setprecision(10);
  
  if(N%2==0){cout << 0.5<< endl;}
  
  else{cout << (double) ((N+1)/2)/N << endl;}
      
  
}

Measured memory_bytes: 3776
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def main():
    N = int(input())
    a, b = map(int, input().split())
    for _ in range(N - 1):
        T, A = map(int, input().split())
        for i in count(max(a // T, b // A) - 1):
            if T * i >= a and A * i >= b:
                a, b = T * i, A * i
                break
    print(a + b)


if __name__ == '__main__':
    main()


Measured memory_bytes: 4460
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;scanf("%d%d",&a,&b);
    if(a>0)printf("Positive\n");
    else if(b>=0)printf("Zero\n");
    else if((a&1)^(b&1))printf("Positive\n");
    else printf("Negative\n");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string a, b;
	cin >> a >> b;
	int r(string x);
	int t=r(a+b);
	if (int(sqrt(t))==sqrt(t)) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}
int r(string x)
{
    int t=0;
    for (int j=0; j<x.size(); j++) t=t*10+(x[j]-'0');
    return t;
}

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

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

    int n, k;
    cin >> n >> k;

    map<int, int> a;
    REP(i, n) {
        int tmp;
        cin >> tmp;
        a[tmp]++;
    }

    vector<int> tmp(a.size());
    int index = 0;
    for (auto i : a) {
        tmp[index] = i.second;
        index++;
    }
    sort(tmp.begin(), tmp.end());

    int sum = 0;
    if (a.size() > k)
        REP(i, a.size() - k) sum += tmp[i];

    cout << sum << '\n';
    return 0;
}


Measured memory_bytes: 10368
#include<stdio.h>

int main(void){
	char sta[3];
	for(int i=0;i<3;i++){
		scanf("%c",&sta[i]);
	}
	if(sta[0]==sta[1]&&sta[1]==sta[2]){
		printf("No");
		return 0;
	}
	printf("Yes");
}

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

using namespace std;

int main(void)
{
    int n;
    cin >> n;
    vector<int> d(n);
    for (size_t i = 0; i < n; i++)
    {
        cin >> d[i];
    }
    

    int64_t sum = 0;
    for (int i = 0; i < n - 1; i++)
    {
        for (int j = i + 1; j < n; j++)
        {
            sum += d[i] * d[j];
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define dup(x,y) (((x)+(y)-1) / (y)); //整数型のまま切り上げ演算する
#define PI 3.14159265359
#define MOD 1000000007
typedef long long LL;
template<class T> inline void chmax(T & a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> T gcd(T x, T y) { if (y == 0) { return x; } else if (x == 0) { return y; }return gcd(y, x % y); }
template<class T> void print_vector(vector<T> vec) { for (int i = 0; i < vec.size(); i++) { cout << vec[i] << " "; }cout << endl; }
const LL LLINF = 1LL << 60;

int main(void) {
	int N;
	cin >> N;

	//他店の営業時間の情報
	vector<vector<int> > F(N, vector<int>(10));
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < 10; j++) {
			cin >> F[i][j];
		}
	}

	//joisinoお姉ちゃんのお店の情報
	vector<vector<int> > P(N,vector<int>(11));
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < 11; j++) {
			cin >> P[i][j];
		}
	}

	//Nが小さいので普通に全探索する
	LL ans = -LLINF;
	for (int i = 1; i <= 1023; i++) {
		bitset<10> bs(i);
		vector<int> same_time_open(N);
		for (int j = 0; j < N; j++) {
			for (int k = 0; k < 10; k++) {
				if (bs[k] == 1 and F[j][k] == 1) {
					same_time_open[j]++;
				}
			}
		}

		LL tmp = 0;
		for (int i = 0; i < N; i++) {
			tmp += P[i][same_time_open[i]];
		}
		chmax(ans, tmp);
	}
	cout << ans << endl;
	

	return 0;
}

Measured memory_bytes: 256
import Data.List
main=do
 getLine
 a<-sort.map read.words<$>getLine
 let x=0:0:f 0 0 a
 let y=tail x
 let z=tail y
 print$maximum$zipWith(+)x$zipWith(+)y z
f i c[]=[c]
f i c a@(x:as)
 |i==x=f i(c+1)as
 |otherwise=c:f(i+1)0 a


Measured memory_bytes: 29052
#include<bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define REPvec(itr, mp) for(auto itr = mp.begin();itr != mp.end(); itr ++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
using namespace std;
typedef long long ll;
typedef vector<int >    vecint;
typedef vector<vector<int> >  vec2int;
typedef vector<ll >     vecll;
typedef vector<string > vecstr;
typedef vector<bool > vecbool;
typedef vector<bool > vecbool;
////////////////////////////////////////////////
int main()
{
  int n, m; cin >> n >> m;
  int ans;
  for(int i = m/n; i >= 1; i --){
    if(m%i == 0){
		cout << i << endl;
      	return 0;
    }
  }
}


Measured memory_bytes: 256
x,y,a,b,c=(int(i) for i in input().split())
p=sorted([int(i) for i in input().split()])
q=sorted([int(i) for i in input().split()])
r=sorted([int(i) for i in input().split()])
l=sorted(p[a-x:]+q[b-y:]+r)
n=len(l)
print(sum(l[n-x-y:]))

Measured memory_bytes: 22720
#include<stdio.h>

int main(void){
  int W,H,x,y,r;
  scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
  if(r <= x&&W - r >= x){
    if(r <= y&&H - r >= y){
      printf("Yes\n");
    }else{
      printf("No\n");
    }
  }else{
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 1812
#include<cstdio>
#include<cstring>
#include<cmath>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define MEM(a,b) memset(a,b,sizeof(a))

using namespace std;

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

int gcd(int a, int b) {
	if (a < b)swap(a, b);
	int k = a % b;
	if (k == 1)return 1;
	if (k == 0)return b;
	int ans = gcd(b, k);
	return ans;
}

int main() {
	int n;
	cin >> n;
	int ans = 114514;
	for (int i = 1;i <= n / 2 + 1; i++) {
		int sum = 0;
		int a = i, b = n - i;
		while (a) {
			sum += a % 10;
			a = a / 10;			
		}
		while (b) {
			sum += b % 10;
			b = b / 10;
		}
		if (sum < ans)ans = sum;
	}
	cout << ans << endl;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
		String line;
		int out,point,player = 0;
		for (int i = 0; i < n; i++) {
			out = 0;
			point = 0;
			player = 0;
			while (out < 3) {
				line = scn.nextLine();
				switch (line) {
				case "HIT":
					player = player * 10 + 1;
					if(player > 1000) {
						player %= 1000;
						point++;
					}
					break;
				case "HOMERUN":
					point++;
					while(player !=0) {
						point += player%10;
						player /= 10;
					}
					break;
				case "OUT":
					out++;
					break;
				}
			}
			System.out.println(point);
		}
	}
}


Measured memory_bytes: 26108
#include <bits/stdc++.h>
#include<set>
#define ll long long 
#include <string>
#define pb push_back
#define mp make_pair
# define pi 3.14159265358979323846
using namespace std;
int main()
{
	ll int n;
	cin>>n;
	ll int k;
	cin>>k;
	ll int a[n],i;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
	}
	sort(a,a+n);
	ll int s=0;
	for(i=0;i<k;i++)
	{
		s+=a[i];
	}
	cout<<s<<endl;
	
	
}
	
		
	
	
	
	




Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;

long maxDiff(vector<int>);

int main()
{
	int N;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; i++)
		cin >> A[i];
	sort(A.begin(), A.end());
	long ans = maxDiff(A);
	sort(A.begin(), A.end(),greater<int>());
	ans = max(ans, maxDiff(A));
	cout << ans << endl;
	return 0;
}

long maxDiff(vector<int> a)
{
	long sum = 0;
	int n = a.size();
	sum += abs(a[(n - 1) / 2] - a[n - 1]);
	for (int i = 0; i < n / 2 - 1; i++)
	{
		sum += abs(a[n - 1 - i] - a[i]);
		sum += abs(a[i] - a[n - 1 - (i + 1)]);
	}
	if (n % 2 != 0)
	{
		sum += abs(a[n - n / 2] - a[n / 2 - 1]);
	}
	return sum;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
const int maxn =1e6+10;
const int mod=1e9+7;
int mp[maxn];
int a[maxn];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        mp[a[i]]++;
    }
    if(mp[1]==1)
    {
        cout<<1<<'\n';
        return 0;
    }
    if(mp[1]>1)
    {
        cout<<0<<'\n';
        return 0;
    }
    int cnt=0;
    for(int i=1;i<=n;i++)
    {
        if(mp[a[i]]>1)
            continue;
        int flag=0;
        for(ll j=2;j*j<=a[i];j++)
        {
            if(a[i]%j==0&&(mp[j]||mp[a[i]/j]))
            {
                flag=1;
            }
        }
        if(flag)
            continue;
        cnt++;
    }
    cout<<cnt<<'\n';







}


Measured memory_bytes: 8284
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main(){
	
	int n;
	cin >> n;
	vector<vector<int>> to(n);
	rep(i,n-1){
		int x,y;
		cin >> x >> y;
		--x; --y;
		to[x].push_back(y);
		to[y].push_back(x);
	}
	
	vector<vector<ll>> dp(n, vector<ll>(2));
	function<ll(int, bool, int)> dfs;
	dfs = [&](int v, bool isBlack, int parent=-1) -> ll{
			if(dp[v][isBlack] > 0) return dp[v][isBlack];
			ll res = 1;
			for(auto w : to[v]){
				if(w == parent) continue;
				
				ll tmp = 0;
				tmp = ( tmp + dfs(w, false, v) ) % MOD;
				if(!isBlack){
					tmp = ( tmp + dfs(w, true, v) ) % MOD;
				}
		
				res = ( res * tmp ) % MOD;
			}
	
			return dp[v][isBlack] = res;
		};
	
	cout << ( dfs(0, true,-1) + dfs(0, false,-1) ) % MOD << endl;
	return 0;
}

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

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll A,B,C,K;
	cin >> A>>B>>C>>K;
	if(K <= A+B)
		cout << min(K,A)<<endl;
	else
	{
		cout << A-(K-(A+B))<<endl;
	}
	

}


Measured memory_bytes: 3652
import bisect
N = int(input())

ans = N
sixs = [1]
i = 6
while i <= N:
    sixs.append(i)
    i *= 6
nines = [1]
i = 9
while i <= N:
    nines.append(i)
    i *= 9

for i in range(N+1):
    #iの分だけ6**xで構成
    cnt = 0
    a = i
    b = N-i
    while a > 0:
        idx = bisect.bisect_right(sixs, a)
        cnt += a // sixs[idx-1]
        a -= (a // sixs[idx-1]) * sixs[idx-1]

    while b > 0:
        idx = bisect.bisect_right(nines, b)
        cnt += b // nines[idx-1]
        b -= (b // nines[idx-1]) * nines[idx-1]

    ans = min(ans, cnt)

print(ans)

Measured memory_bytes: 3188
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define int ll
using pint = pair<int,int>;
using Graph = vector<vector<int>>;
void YN(bool flg) {cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg) {cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg) {cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) cout << n << '\n'
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 1e10; //10^10
const double PI = acos(-1.0L);
/*mod逆元*/long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}
template< typename T >T mod_pow(T x, T n, T p=MOD) {T ret = 1;while(n > 0) {if(n & 1) (ret *= x) %= p;(x *= x) %= p;n >>= 1;}return ret;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n >>= 1; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}

//----------------ライブラリとか----------------

int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

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

    int n,a,b; cin >> n >> a >> b;
    int ans = 0;
    FOR(i,1,n+1) if(a<=findSumOfDigits(i)&&findSumOfDigits(i)<=b) ans+=i;
    out(ans);

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
const int mod = (int)(1e9 + 7);
typedef long long ll;
int main(){
  long long H,W,K;
  cin >> H >> W >> K;
  K--;
  long long dp[H+2][W];
  rep(i,H+2)rep(j,W) dp[i][j] = 0;
  dp[0][0] = 1;
  rep(i,H){
    rep(j,W){
      rep(mask,1 << (W-1)){
        //生成できるあみだくじのパターンかどうか
        bool invalid = false;
        rep(k,(W-1)-1){
          if((mask & (1 << k)) > 0 && (mask & (1 << (k+1))) > 0) invalid = true;
        }
        if(invalid) continue;

        if(j < W-1 && (mask & (1 << j)) > 0)                            dp[i+1][j+1] = (dp[i+1][j+1] + dp[i][j]) % mod;
        else if(j - 1 >= 0 && (mask & (1 << (j-1))) > 0)     dp[i+1][j-1] = (dp[i+1][j-1] + dp[i][j]) % mod;
        else                                                 dp[i+1][j]   = (dp[i+1][j]   + dp[i][j]) % mod;
      }
    }
  }
  cout << dp[H][K] << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define Max 100005
const LL mod=1e9+7;
const LL LL_MAX=9223372036854775807;
using namespace std;
struct node{
    LL len;
    LL en;
}a[2*Max];
bool cmp(node a,node b){
    return a.en<b.en;
}
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
        scanf("%lld%lld",&a[i].len,&a[i].en);
    sort(a,a+n,cmp);
    LL now=a[0].len,en=a[0].en;
    for(int i=1;i<n;i++){
        if(now>en){
            printf("No\n");
            return 0;
        }
        now+=a[i].len;
        en=a[i].en;
    }
    if(now>en){
        printf("No\n");
        return 0;
    }
    printf("Yes\n");
    return 0;
}


Measured memory_bytes: 3456
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>

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

#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define REV(v) reverse(v.begin(),v.end())
#define SRTV(v) sort(v.begin(),v.end())
#define SRTAG(a,n) sort(a,a+n,greater<>())
#define MOD 1000000007

typedef long long ll;
typedef tuple<int,int,bool> Tb;

int atcoder(){
    //入力
    int h,w;
    cin >> h >> w;
  	string s[h];
  	REP(i,0,h) cin >> s[i];
    //処理
    //出力
    REP(i,0,w+2) cout << "#";
  	cout << ENT;
    REP(i,0,h) cout << "#" << s[i] << "#" << ENT;
    REP(i,0,w+2) cout << "#";
	cout << ENT;
    return 0;
}

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


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define REP(i,a,n) for(ll i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvl vector<vector<ll>>
#define print(n) cout<<n<<endl
const int M=100010;
const int inf=1000000007;
const long long INF=1000000000000000007;
using ll=long long;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int main(){
	ll n,m;
	cin>>n>>m;
	ll s=0;
	map<ll,ll> mp;
	REP(i,1,n+1){
		ll x;
		cin>>x;
		s+=x;
		mp[s%m]+=1;
	}
	ll ans=0;
	for(auto v:mp) {
		if(v.first==0)ans+=v.second;
		ans+=(v.second)*(v.second-1)/2;
	}
	print(ans);
}

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

int main() {
	int n;
	cin>>n;
	int a[n][3];
	for(int i=0;i<n;i++){
		cin>>a[i][0]>>a[i][1]>>a[i][2];
		if(i){
			a[i][0]+=max(a[i-1][1],a[i-1][2]);
			a[i][1]+=max(a[i-1][2],a[i-1][0]);
			a[i][2]+=max(a[i-1][1],a[i-1][0]);
		}
	}
	cout<<max(a[n-1][0],max(a[n-1][1],a[n-1][2]));
	
	return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <iomanip>
#include <unordered_set>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<pair<ll,ll> > vpll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vc> vvc;
typedef vector<vs> vvs;
typedef vector<vll> vvll;
typedef map<int,int> mii;
typedef set<int> si;
#define rep(i,n) for(ll i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define arep(i,v) for(auto i : v)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define fi first
#define se second
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
template <class T> inline void dump(T &v){irep(i, v){cout<<*i<<((i==--v.end())?'\n':' ');}}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
constexpr ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-11;



int main() {
    
    ll n;
    cin>>n;
    vi v(n);
    rep(i,n)cin>>v[i];
    ll xo=0;
    rep(i,n)xo^=v[i];
    rep(i,n)v[i]^=xo;
    dump(v);
}


Measured memory_bytes: 3972
#include <stdio.h>

int main() {
	static char s[4], t[4];
	int i, yes;

	scanf("%s%s", s, t);
	yes = 1;
	for (i = 0; i < 3; i++)
		if (s[i] != t[2 - i])
			yes = 0;
	printf(yes ? "YES\n" : "NO\n");
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string.h>

using namespace std;

int main()
{
  char a[1001] ={0};
  int b,c;
  while(1)
  {
    cin >> a;
    if(a[0] == '0')break;
    b = 0;
    c = 0;
    while(a[b] != 0)
    {
      c += a[b] - '0';
      b++;
    }
    cout << c << endl;
  }
  return 0;
}



Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
int main()
{
	int n;
	scanf("%d", &n);
	string s, t;
	cin >> s >> t;
	rep(i, n) {
		cout << s[i] << t[i];
	}
	cout << endl;
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << endl;

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

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"

ll fac(int n) {
  ll ret = 1ll;
  for (int i = 1; i <= n; i++) { ret = ret * i % 1000000007ll; }
  return ret;
}

void solve() {
  ll n, m;
  cin >> n >> m;
  if (abs(n - m) > 1) {
    cout << 0 << endl;
    return;
  }
  if (n == m) {
    cout << (fac(n) * fac(m) * 2ll) % 1000000007ll << endl;
  } else {
    assert(abs(n - m) == 1);
    cout << (fac(n) * fac(m)) % 1000000007ll << endl;
  }
  return;
}

signed main() {
  fastio();
  solve();
  // int t; cin >> t; while(t--)solve();
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll> 
#define P pair<ll,ll>
#define ALL(a) (a).begin(),(a).end()
#define YESNO(i) if((i)) puts("YES");else puts("NO");
#define YesNo(i) if((i)) puts("Yes");else puts("No");
#define yesno(i) if((i)) puts("yes");else puts("no");
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,a;cin>>n;
  set<ll> st;
  rep(i,n) {cin>>a;st.insert(a);}
  YESNO(st.size()==n);
  return 0;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
#define fo(i,a) for(i = 0;i < a;i++)
using namespace std;
int main(void)
{
	int n,o[9]={0},t=0,i;
	
	cin >> n ;
	while(n != 0){
		fo(i,9) cin >> o[i] ;
		t = accumulate(o,o + 9,0) ;
		cout << n - t << endl ;
		cin >> n ;
	}
	
	return 0 ;
}



Measured memory_bytes: 3016
#include<iostream>
#include<iomanip>
#include<limits>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

#define big ((ll)(1e9)+7)

int main()
{
  double n,m;
  cin >> n >> m;
  vector<double> a(n);
  double sum = 0.0;
  for(int i = 0;i < n;i++)
  {
    cin >> a[i];
    sum += a[i];
  }

  int cnt = 0;
  sum /= 4*m;
  // if(sum % 4*m != 0)
  // {
  //   sum++;
  // }
  // cout << sum << endl;
  for(int i = 0;i < n;i++)
  {
    if(a[i] >= sum)
    {
      cnt++;
    }
  }
  if(cnt >= m)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}


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

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

	string s[h];

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

	char res[h][w];

	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(s[i][j]=='#') {
				res[i][j] = '#';
				continue;
			}
			int cnt = 0; 
			if(i-1>=0 && s[i-1][j]=='#') cnt++;
			if(i+1<h && s[i+1][j]=='#') cnt++;
			if(j-1>=0 && s[i][j-1]=='#') cnt++;
			if(j+1<w && s[i][j+1]=='#') cnt++;
			if(i-1>=0 && j-1>=0 && s[i-1][j-1]=='#') cnt++;
			if(i+1<h && j+1<w && s[i+1][j+1]=='#') cnt++;
			if(i-1>=0 && j+1<w && s[i-1][j+1]=='#') cnt++;
			if(i+1<h && j-1>=0 && s[i+1][j-1]=='#') cnt++; 
			res[i][j] = cnt+'0';
		}
	}


for(int i=0;i<h;i++){
	for(int j=0;j<w;j++) cout<<res[i][j];
	cout<<endl;
}



}



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

using namespace std;

typedef long long ll;
typedef long double ld;

#define int ll
#define loop(i, n) for (int i = 0; i < n; ++i)
#define loop1(i, n) for (int i = 1; i < n; ++i)

void solve() {
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    if (k <= a)
        cout << k;
    else if (k <= a + b)
        cout << a;
    else
        cout << a - (k - a - b);
}

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

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

int n;
string x, y;
bool mat[1000][1000];
int a[1000][1000];

int max(int i, int j) {
	int r = (!mat[i - 1][j] ? a[i - 1][j] : 0);
	r = ((!mat[i][j - 1] && a[i][j - 1] > r) ? a[i][j - 1] : r);
	return r > a[i - 1][j - 1] ? r : a[i - 1][j - 1];
}

int main(){
	cin >> n;
	for (int ia = 0; ia < n; ia++) {
		int ans = 0, p = 0;
		cin >> x >> y;
		for (int i = 0; i < x.length(); i++) {
			mat[i][0] = x[i] == y[0] ? true : false;
			a[i][0] = mat[i][0] ? 1 : 0;
		}
		for (int i = 1; i < y.length(); i++) {
			mat[0][i] = x[0] == y[i] ? true : false;
			a[0][i] = mat[0][i] ? 1 : 0;
		}
		for (int i = 1; i < x.length(); i++) {
			for (int j = 1; j < y.length(); j++) {
				mat[i][j] = x[i] == y[j] ? true : false;
				a[i][j] = max(i, j) + (mat[i][j] ? 1 : 0);
				if (a[i][j] > p) p = a[i][j];
			}
		}
		if (a[x.length() - 1][0] > p) p = a[x.length() - 1][0];
		if (a[0][y.length() - 1] > p) p = a[0][y.length() - 1];
		cout << p << endl;
	}


	return 0;
}

Measured memory_bytes: 7928
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array;


void main() {
    int r, g;
    scan(r);
    scan(g);
    auto ans = r + (g - r) * 2;
    writeln(ans);
}



void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


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

int main(void){
	int input[3];
	cin >> input[0] >> input[1] >> input[2];
	for(int index = 0; index < 3; index++){
		for(int cnt = index + 1; cnt < 3; cnt++){
			if(input[cnt - 1] > input[cnt]){
				int temp = input[cnt- 1];
				input[cnt- 1] = input[cnt];
				input[cnt] = temp;
			}
		}

	}
	cout << input[2] * 10 + input[1] + input[0] << endl;
	return 0;
}


Measured memory_bytes: 256
MAX = int(input())
MAX+=1
factor = [0]*(MAX + 1); 
def generatePrimeFactors(): 
	factor[1] = 1;
	for i in range(2,MAX): 
		factor[i] = i; 
	for i in range(4,MAX,2): 
		factor[i] = 2; 

	i = 3; 
	while(i * i < MAX): 
		if (factor[i] == i): 
			j = i * i; 
			while(j < MAX): 
				if (factor[j] == j): 
					factor[j] = i; 
				j += i; 
		i+=1; 

def ca(n): 
	if (n == 1): 
		return 1; 
	ans = 1; 
	dup = factor[n]; 
	c = 1; 
	j = int(n / factor[n]); 
	while (j > 1): 
		if (factor[j] == dup): 
			c += 1; 
		else: 
			dup = factor[j]; 
			ans = ans * (c + 1); 
			c = 1; 
		j = int(j / factor[j]); 

	ans = ans * (c + 1); 
	return ans; 
generatePrimeFactors() 
r=1
for i in range(2,MAX):
    r+=i*ca(i)
print(r)


Measured memory_bytes: 146492
import java.util.*;
public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int d[]=new int[N];
    int total=0;
    for(int i = 0 ; i<N ; i++){
      d[i] = sc.nextInt();
    }

    for(int i = 0 ; i<N ; i++){
      for(int j = 1 ; j<N-i ; j++){
        int n=d[i]*d[i+j];
        total=total+n;
      }
    }
    System.out.println(total);


  }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
int main(){
	int A,B,C,K;
  cin >> A >> B >> C >> K;
  if(K <= A){
    cout << K << endl;
  }else if(K <= A+B){
    cout << A << endl;
  }else{
    cout << A-(K-A-B) << endl;
  }
}

Measured memory_bytes: 3492
#include <bits/stdc++.h>
using namespace std;
vector<char> v1;
vector<char> v2;
int contagem[200][200];
int contador[200];
int main()
{
	int n;
	cin>>n;
	char s[100];
	for (int i = 0; i < n; ++i)
	{
		cin>> s[i];
	}
	
	char aux[100];
	char aux2[100];
	int k=1;
	while(k<n)
	{
		for (int i = 0; i <k ; ++i)
			v1.push_back(s[i]);
		for (int i = k; i < n; ++i)
			v2.push_back(s[i]);
		for (int i = 0; i <k ; ++i)
		{
	
			for (int j = 0; j < n-k; ++j)
			{
				if(v1[i]==v2[j] and contagem[k-1][v1[i]]==0)
				{
					contagem[k-1][v1[i]]=1;
					contador[k-1]++;
					break;

				}
			}
		}
		v1.clear();
		v2.clear();


		k++;
	}
	int max=0;
	for (int i = 0; i < n; ++i)
	{
		
		if(contador[i]>max)
		{
			max=contador[i];
		}
	}
	cout<<max<<"\n";
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
int X,Y,S;
int tax(int a,int b)
{
	return b*(100+a)/100;
}
int max(int a,int b)
{
	if(a>b)return a;
	else return b;
}
int solve()
{
	int maximum=0;
	for(int i=1;i<S;++i)
	for(int j=i;j<S;++j)
	if(tax(X,i)+tax(X,j)==S)
	 maximum=max(maximum,tax(Y,i)+tax(Y,j));
	 return maximum;
}
int main()
{
	while(cin >>X>>Y>>S&&X>0)
	{
		cout<<solve()<<endl;
	}
}


Measured memory_bytes: 3108
package main

import (
	"fmt"
)

func main() {
	var a, b string
	fmt.Scan(&a, &b)

	if len(a) > len(b) {
		fmt.Println("GREATER")
		return
	} else if len(a) < len(b) {
		fmt.Println("LESS")
		return
	}

	if a > b {
		fmt.Println("GREATER")
	} else if a == b {
		fmt.Println("EQUAL")
	} else {
		fmt.Println("LESS")
	}
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b;

  cin >> a >> b;

  if(a != 2 && b != 2){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

    


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

int main() {
  int X;
  cin >> X;
  
  for (int i = 120; i > -121; i--) {
    for (int j = -120; j < 121; j++) {
      int C = i-j;
      int D = i*i*i*i + i*i*i*j + i*i*j*j + i*j*j*j + j*j*j*j;
      if (C * D == X){
        cout << i << ' ' << j << endl;
        return 0;
      }
    }
  }
}
  
 

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
typedef int64_t llong;
#define INF 1000000000
#define n_max 100
#define t_max 100000

int main(){
    int n,c;
    cin >>n >> c;
    int reco[30][t_max+5]={};
    int s,t,ch;
    REP(i,n){
        scanf("%d%d%d",&s,&t,&ch);
        reco[ch-1][s]+=1;
        reco[ch-1][t+1]-=1;
    }
    REP(i,c){
        REP(j,t_max){
            reco[i][j+1]+=reco[i][j];
        }
    }
    int ans=0;
    int tmp;
    FOR(i,0,t_max+1){
        tmp=0;
        REP(j,c) if(reco[j][i]>0) tmp+=1;
        if(tmp > ans) ans = tmp;
    }
    cout << ans << endl;
}

Measured memory_bytes: 11904
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

const int MOD = 1000000007, INF = 1111111111;
using namespace std;
using lint = long long;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (int i = 0; i < (int)vec.size(); i++) {
		os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	}
	return os;
}

#ifdef _DEBUG
template <class Head>
void dump(const char* str, Head &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + 1, t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

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

	int N, K;
	cin >> N >> K;

	vector<int> l(N);
	for (int i = 0; i < N; i++) cin >> l[i];

	sort(l.begin(), l.end(), greater<int>());

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

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
line = input().split(" ")
n = int(line[0])
k = int(line[1])

l = []
for _ in range(n):
    line = input().split(" ")
    a = int(line[0])
    b = int(line[1])
    l.append([a,b])

l.sort()

while k>0:
    x = l.pop(0)
    k = k-x[1]

print(x[0])


Measured memory_bytes: 20092
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <queue>
# define MOD 1000000000+7
# define INF 1000000000
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;
using namespace std;
unsigned long long int a = 0, b = 0, c = 0, d = 0, e = 0, ans = 0, x = 0, y = 0, z = 0, N = 0, m = 0, maxy = 0, mini = 9999, counter = 0, endp = 0, checker = 0;

std::vector <char> vec{}, vecsec{}, vecth{};
long long int iremono[100010], koware[100001];
long long  int iremono2[100001], check[100001], xpo[10000001], ypo[10000001], hei[1000001];
std::vector<std::string>kinds{}, kaku{};
char maze[1000];
int sx, sy;
int gx, gy;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
bool okada = false, okada2 = false;
long long int dp[4][100003] ,ire[4][100003];
std::string input[103],one,two,three;
char re;

int H, W;//はんい
bool qw = false, er = false, ty = false, ui = false;
std::string code;
int main() {
	cin >> a;
	rep(i, a) {
		cin >> iremono[i];
	}
	rep(i, a - 2) {
		if (iremono[i + 1] > iremono[i] && iremono[i + 1] < iremono[i + 2]) {
			counter++;
		}
		else if (iremono[i + 1] < iremono[i] && iremono[i + 1] > iremono[i + 2]) {
			counter++;
		}
	}
	cout << counter << endl;
}



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

class disjoinset {
	public:
		vector<int> rank,p;
	disjoinset (){}
	disjoinset(int size){
	rank.resize(size,0);
	p.resize(size,0);
	for(int i=0; i<size;i++)makeSet(i);
	}
	void makeSet(int x){
	p[x] = x;
	rank[x] =0;
	}
	bool same(int x,int y){
	return findSet(x) == findSet(y);
	}
	void unite(int x,int y){
		link(findSet(x),findSet(y));
	}
	void link(int x,int y){
		if(rank[x] > rank[y]){
		 p[y] = x;
		}else{
		 p[x] = y;
		 if(rank[x]==rank[y] )rank[y]++;
		}
	}
	int findSet(int x){
		if(x!=p[x])p[x] = findSet(p[x]);
		return p[x];
	}

};
 
int main(){
	int n,a,b,q;
	int t;
	cin>>n>>q;
	disjoinset ds  = disjoinset(n);
	for(int i=0;i<q;i++){
		cin>>t>>a>>b;
		if(t==0) ds.unite(a,b);
		else if(t==1){
		if(ds.same(a,b) ) cout<<1<<endl;
		else cout<<0<<endl;
		}
	}

	return 0;
}



Measured memory_bytes: 3172
#include<bits/stdc++.h>
#include <queue>
using namespace std;
using ll = long long;
using P = pair<int,int>;

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

	priority_queue<P> PQ;
	sort(a.rbegin(),a.rend());

	PQ.emplace(a[0],a[0]);

	ll ans = 0;
	for(int i = 1;i<n;i++)
	{
		ans += PQ.top().first;
		PQ.emplace(a[i],PQ.top().first);
		PQ.emplace(a[i],PQ.top().second);
		PQ.pop();
	}

	cout << ans << endl;
	
}


Measured memory_bytes: 6920
#include <stdio.h>
typedef long long int ll;
const int N=4e3+10;
const int MOD=998244353;
ll f[N];
ll mul(ll a,ll b){return (a*b)%MOD;}
ll add(ll a,ll b){return (a+b)%MOD;}
ll pow(ll a,ll b){
    ll ans=1;
    while(b){
        if(b&1)ans=mul(ans,a);
        b>>=1;
        a=mul(a,a);
    }
    return ans;
}
ll rev(ll n){return pow(n,MOD-2);}
ll C(ll a,ll b){return a>=b&&b>=0?mul(f[a],mul(rev(f[b]),rev(f[a-b]))):0;}
int main(){
    f[0]=f[1]=1;
    for(int i=2;i<N;i++)f[i]=mul(f[i-1],i);
    int n,k,a;
    ll ans;
    scanf("%d%d",&k,&n);
    for(int i=2;i<=(k<<1);i++){
        ans=0;
        if(i&1){
            if(i>k)a=((k<<1)+1-i)>>1;
            else a=i>>1;
            for(int j=0;j<=a;j++)ans=add(ans,mul(C(a,j),mul(C(n+k-(a<<1)-1,n-j),pow(2,j))));
            printf("%lld\n",ans);
        }
        else{
            if(i>k)a=((k<<1)-i+2)>>1;
            else a=(i+1)>>1;
            for(int j=0;j<=a;j++)ans=add(ans,mul(C(a,j),mul(C(n+k-(a<<1)-1,n-j),pow(2,j))));
            //for(int j=0;j<=a;j++)ans=add(ans,mul(C(a,j),mul(C(n+k-(a<<1)-2,n-j-1),pow(2,j))));
            printf("%lld\n",ans);
        }
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	void ab(){
		int a,b,d,r;
		double f;
		Scanner s = new Scanner(System.in);
		a = s.nextInt();
		b = s.nextInt();
		d = a/b;
		r = a%b;
		f = (double)a/b;
		System.out.println(d + " " + r + " " + String.format("%.9f", f));
	}
	public static void main(String args[]){
		Main m = new Main();
		m.ab();
	}
}

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

#define mod 1000000007;

using namespace std;

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

    map<char,int> counter;
    for(auto i = t.begin(); i != t.end(); i++){
        counter[*i]++;

    }

    
    for(auto pair : counter){
        if(pair.second % 2  == 0){
        }
        else{
            cout << "No";
            return 0;
        }
    }


    cout << "Yes";
    
}


Measured memory_bytes: 256
N=int(input())
h=[0]+list(map(int,input().split()))+[9000000001]

if N==1:
    print("Yes")
else:
    isOK=True
    for i in range(len(h)-1):
        left=h[i]
        right=h[i+1]
        if left==right:
            continue
        elif left+1<=right:
            h[i+1]-=1
        elif left>right:
            isOK=False
            break
    if isOK:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 14396