akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 32000

int main(){
	int limit;
	int* table = new int[NUM];
	int* work = new int[NUM];

	for(int i=0; i < NUM;i++)table[i] = 1;
	table[0] = 0;
	table[1] = 0;

	limit = NUM;

	for(int i=2;i<limit;i++){
		if(table[i] == 1){
			for(int k=2*i;k < NUM; k += i){
				table[k] = 0;
			}
		}
	}

	int index = 0;
	vector<int> PRIME;

	for(int i = 2; i < NUM; i++){
		if(table[i] == 1){
			PRIME.push_back(i);
		}
	}

	int left,right;
	scanf("%d %d",&left,&right);

	int* num_table = new int[right-left+1];
	int* count_table = new int[right-left+1];

	for(int num = left; num <= right; num++){
		num_table[num-left] = num;
		count_table[num-left] = 0;
	}

	limit = sqrt(right);
	int start;

	for(int i = 0; i < PRIME.size(); i++){
		if(PRIME[i] > limit)break;

		for(start = 0;start < right-left+1 && num_table[start]%PRIME[i] != 0; start++);

		for(int k = start; k < right-left+1;k += PRIME[i]){
			while(num_table[k] > 1 && num_table[k]%PRIME[i] == 0){
				num_table[k] /= PRIME[i];
				count_table[k]++;
			}
		}
	}

	int ans = 0;
	for(int num = left; num <= right; num++){
		if(num_table[num-left] != 1)count_table[num-left]++;
		if(table[count_table[num-left]] == 1)ans++;
	}

	printf("%d\n",ans);

	return 0;
}


Measured memory_bytes: 11240
// She is Pretty pretty!
#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ff first
#define ss second
#define mp make_pair
#define pb push_back

const int N = 1100;
ll n, a[N],f[N][N], sum[N];
int main()
{
    ios::sync_with_stdio(false),cin.tie(0);
    cin >> n;
    memset(f, 0x3f, sizeof f);
    for(int i = 1; i <= n; i++){
        f[i][i] = 0;
        cin >> a[i];
        sum[i] = sum[i-1]+a[i];
    }
    for(int len = 1; len < n; len++){
        for(int l = 1; l + len <= n; l++){
            int r = l + len;
            for(int k = l; k < r; k++){
                f[l][r] = min(f[l][r] , f[l][k]+f[k+1][r]);
            }
            f[l][r] += sum[r] - sum[l-1];
        }
    }
    cout <<f[1][n] <<endl;
    return 0;
}


Measured memory_bytes: 9728
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

a,b = m()

data = []

ans = ""

for i in range(a):
    data.append(input()[:-1])
data.sort()

for i in range(a):
    ans += data[i]
print(ans)

Measured memory_bytes: 66092
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

vector<int> a[3];
int dp[3][2];

int main() {
	int n; cin >> n; a[0].resize(n + 1, 0);
	a[1].resize(n + 1, 0); a[2].resize(n + 1, 0);
	for (int i = 1; i <= n; i++)
		cin >> a[0][i] >> a[1][i] >> a[2][i];

	fill(dp[0], dp[0] + 6, 0);
	for (int i = 1; i <= n; i++)
		for (int j = 0; j < 3; j++) {
			dp[j][i & 1] = 0; for (int k = 0; k < 3; k++) if (k != j)
				dp[j][i & 1] = max(dp[j][i & 1], dp[k][(i ^ 1) & 1] + a[k][i]);
		}

	cout << max({ dp[0][n & 1], dp[1][n & 1], dp[2][n & 1] }) << '\n';
	cin.ignore(2); return 0;
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int divide_2(int n)
{
    if (n % 2)
        return 0;
    return divide_2(n / 2) + 1;
    // int res = 0;
    // while (n % 2 == 0 && n)
    // {
    //     res++;
    //     n /= 2;
    // }
    // return res;
}

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    int cnt = 0;
    rep(i, n) if (a[i] % 2 == 0) cnt += divide_2(a[i]);

    cout << cnt << '\n';
    return (0);
}


Measured memory_bytes: 3628
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template <class T> bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }

char f(int i) {
	if (i == 0)return 'S';
	if (i == 1)return 'E';
	if (i == 2)return 'N';
	return 'W';
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, m, l;
	while (cin >> n >> m >> l, n) {
		vector<string> v(n);
		REP(i, n)cin >> v[i];
		int x, y, d;
		REP(i, n)REP(j, m) {
			if (isalpha(v[i][j])) {
				x = i;
				y = j;
				if (v[i][j] == 'S')d = 0;
				else if (v[i][j] == 'E')d = 1;
				else if (v[i][j] == 'N')d = 2;
				else d = 3;
			}
		}
		ll a, b, cnt = 0;
		map<pair<pii, int>, int> mp;
		while (1) {
			if (mp.count({ {x, y}, d })) {
				a = mp[{ {x, y}, d}];
				b = cnt - mp[{ {x, y}, d}];
				if (l < a) {
					for (auto c : mp) {
						if (c.second == l) {
							cout << c.first.first.first + 1 << " " << c.first.first.second + 1 << " " << f(c.first.second) << endl;
						}
					}
				}
				else {
					ll num = (l - a) % b + a;
					for (auto c : mp) {
						if (c.second == num) {
							cout << c.first.first.first + 1 << " " << c.first.first.second + 1 << " " << f(c.first.second) << endl;
						}
					}
				}
				break;
			}
			mp[{ {x, y}, d}] = cnt;
			cnt++;
			while (1) {
				int nx = x + dx[d * 2], ny = y + dy[d * 2];
				if (nx < 0 || ny < 0 || nx >= n || ny >= m || v[nx][ny] == '#') {
					d = (d + 3) % 4;
				}
				else break;
			}
			x += dx[d * 2], y += dy[d * 2];
		}

	}
}


Measured memory_bytes: 3476
n,m=map(int,input().split())
ablist=[]
for i in range(n):
  ab=list(map(int,input().split()))
  ablist.append(ab)
ablistsort=sorted(ablist)
ans=0
ko=0
for i in range(n):
  ans+=ablistsort[i][0]*ablistsort[i][1]
  ko+=ablistsort[i][1]
  if ko>m:
      ans-=(ablistsort[i][0]*ablistsort[i][1])
      ko-=ablistsort[i][1]
      while ko<m:
        ans+=ablistsort[i][0]
        ko+=1
print(ans)

Measured memory_bytes: 28332
#include <iostream>
#include <bitset>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <regex>
#include <iomanip>
#include <climits>
#include <utility>
#include <queue>
using namespace std;
using ll = long long int;
using dd = long double;
const ll MOD = 1e9 + 7;

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

ll fact(ll n)
{
    if (n == 0)
    {
        return 1;
    }
    if (n == 1)
    {
        return 1;
    }
    return n * fact(n - 1) % MOD;
}

int main()
{
    ll N;
    cin >> N;
    map<ll, ll> mp;

    for (ll i = 0; i <= 100; i++)
    {
        auto f = [](int n) {
            ll ans = 0;
            bitset<10> b(n);
            for (ll i = 0; i < 10; i++)
            {
                if (b[i] == 1)
                {
                    ans = i;
                    break;
                }
            }
            return ans;
        };

        mp[i] = f(i);
    }
    
    ll ans = -1;
    ll prev = -1;
    for (ll i = 1; i <= N; i++)
    {
        if (mp[i] > prev) {
            ans = i;
            prev = mp[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define PI (acos(-1))

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e15;
const int INF=1e9;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    int n,a,b;
    cin>>n>>a>>b;
    int cnt=(b-a)%2;
    if(cnt%2==0){
        cout<<"Alice"<<endl;
    }else{
        cout<<"Borys"<<endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;


public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A,B,C,X,ans=0;
		A = sc.nextInt();
		B = sc.nextInt();
		C = sc.nextInt();
		X = sc.nextInt();
		A++;
		B++;
		C++;
		for(int i = 0; i < A; ++i) {
			for (int j = 0; j < B; j++) {
				for (int k = 0; k < C; k++){
					if(500*i+100*j+50*k == X) {

						++ans;
//						System.out.println(ans);
					}

				}

			}
		}

		System.out.println(ans);
	}
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define MOD 1000000007
#define PI 3.1415926535

int main(void)
{
    int n, m,x;
    cin >> n >> m >> x;

    vector<vector<int>>a(n,vector<int>(m+1,0));

    for (int i = 0; i < n;i++){
        for (int j = 0; j < m+1;j++){
            cin >> a[i][j];
        }
    }
    vector<pair<int, int>> cost(n);
    for (int i = 0; i < n;i++){
        cost[i].first = a[i][0];
        cost[i].second = i;
    }
    sort(cost.begin(), cost.end());

    int ans = 874563210;

    for (int bit = 0; bit < (1 << n);bit++){
        vector<int> sum(m, 0);
        int temp_ans = 0;
        for (int i = 0; i < n; i++)
        {
            if(bit & (1<<i)){
                for (int j = 0; j < m;j++){
                    sum.at(j) += a.at(i).at(j + 1);
                }
                temp_ans += a.at(i).at(0);
            }
        }
        bool OK = true;
        rep(i, m){
            if(sum.at(i)<x)
                OK = false;
        }
        if(!OK)
            continue;
        ans = min(ans, temp_ans);
    }
    
    if (ans == 874563210)
        cout << -1 << endl;
    else
        cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <stdio.h>
#include <stdbool.h>

int main(){
    int i, j, n;
    char mark;
    char marks[4]={'S', 'H', 'C', 'D'};
    int num;
    bool cards[4][13]={false};

    scanf("%d ", &n);
    for(i=0;i<n;i++){
        scanf("%c %d ", &mark, &num);
        for(j=0;j<4;j++){
            if(mark==marks[j]){
                cards[j][num-1]=true;
                break;
            }
        }
    }
    for(i=0;i<4;i++){
        for(j=0;j<13;j++){
            if(!cards[i][j]){
                printf("%c %d\n", marks[i], j+1);
            }
        }
    }
    return 0;
}


Measured memory_bytes: 2644
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<string>
#include<map>
#include<vector>
#include<queue>
#include<set>
#include<stack>
#include<sstream>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=1000+10;
int n;
map<int,bool>mmp;
map<int,string>md;
int main(){
    md[3]="Three";
    md[4]="Four";
    while(~scanf("%d",&n)){
        mmp.clear();
        char c;
        for(int i=0;i<n;i++){
            cin>>c;
            mmp[c-'A']=1;
        }
        cout<<md[mmp.size()]<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
n = int(input())
tensai = []
for i in range(n):
    a,b = map(int,input().split())
    tensai.append(b * 10000000000 + a)
tensai.sort()
time = 0
ans = "Yes"
for i in range(n):
    time += tensai[i] % 10000000000
    deadline = tensai[i] // 10000000000
    if time > deadline:
        ans = "No"
        break
    else:
        continue
print(ans)

Measured memory_bytes: 13392
#include <bits/stdc++.h>
#define N 200010
using namespace std;
long long dp[N],n,Q,num[N]={};
vector<long long> ft[N];
bool book[N];
queue<long long> q;
int main(){
	long long i,x,y;
	cin>>n>>Q;
	for(i=1;i<n;i++)
	{
		cin>>x>>y;
		x--;
		y--;
		ft[x].push_back(y);
		ft[y].push_back(x);
	}
	for(i=0;i<Q;i++)
	{
		cin>>x>>y;
		x--;
		num[x]+=y;
	}
	book[0]=true;
	q.push(0);
	dp[0]=num[0];
	while(q.size())
	{
		x=q.front();
		q.pop();
		for(i=0;i<ft[x].size();i++)
		{
			y=ft[x][i];
			if(!book[y])
			{
				dp[y]=dp[x]+num[y];
				q.push(y);
				book[y]=true;
			}
		}
	}
	for(i=0;i<n;i++)
	{
		cout<<dp[i]<<" ";
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 19312
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
const ll inf = 1LL << 50;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
///////////////////////////////////////

//一つの黒く塗られたマスが影響を与える範囲は周辺にあるいくつかの3*3領域しかない
//これらの周辺の少しのマスにのみ何かの処理をするだけで計算できれば高速に答えが求められる
//(i,j)を上からi行目で左からj行目のマスを左上とする3*3の正方形を表すことにする
//例えば上からp行目で左からq行目のマスを黒く塗ると(p-k,q-l)(k=0,1,2)(l=0,1,2)に含まれる黒いマスが一つ増える
//だから入力で与えられる点に対してこれらの正方形の左上のマスを全部列挙しておき
//最大で9N個列挙される。その列挙されたものの中でそれぞれの正方形で何回出現するかがカウントできれば良い
//これはpairやmapなどで処理する
//最後に黒いマス0個の個数は全体(H-2)*(W-2)個から一回以上黒いマスが出現した3*3領域を引けば求められる

int main() {
	ll H, W, N; cin >> H >> W >> N;
	vector<pair<ll,ll>>V;
	ll ans[10];
	REP(i, 10)ans[i] = 0;
	for (int i = 0; i < N; ++i) {
		int a, b; cin >> a >> b;
		a--, b--;
		for (int j = 0; j < 3; ++j) {
			for (int k = 0; k < 3; ++k) {
				if (a - j < 0 || a -j+2 >= H || b - k < 0|| b -k+ 2 >= W) {
					continue;
				}
				V.push_back({ a - j,b - k });
			}
		}
	}
	if (N == 0) {
		ans[0] = (H - 2)*(W - 2);
		for (int i = 1; i <= 9; ++i)ans[i] = 0;
	}
	else {
		sort(V.begin(), V.end());

		int cnt = 1;
		for (int i = 0; i < V.size() - 1; ++i) {
			if (V[i].first == V[i + 1].first&&V[i].second == V[i + 1].second) {
				cnt++;
			}
			else {
				ans[cnt]++;
				cnt = 1;
			}
		}
		ans[cnt]++;
		ll sum = 0;
		for (int i = 1; i <= 9; ++i) {
			sum += ans[i];
		}
		ans[0] = (H - 2)*(W - 2) - sum;
	}
	for (int i = 0; i <= 9; ++i) {
		cout << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 18408
def binarySearch(A, key):
    left = 0
    right = len(A)
    while left < right:
        mid = (left + right) // 2
        if A[mid] == key:
            return mid
        elif key < A[mid]:
            right = mid
        else:
            left = mid + 1
    return None


input()
S = [int(i) for i in input().split()]
input()
T = [int(i) for i in input().split()]
count = 0

for k in T:
    if binarySearch(S, k) is not None:
        count += 1

print(count)




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

int main() {
  int n,k;
  cin >> n >> k;
  std::vector<int> vec(n);
  rep(i,n) cin >> vec.at(i);
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  ll total = 0;
  rep(i,n) {
    if (i < k) continue;
    total += vec.at(i);
  }
  cout << total << endl;
}


Measured memory_bytes: 3988
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_DEPRECATE

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>
#include <fstream>
#include <iterator>
#include <bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

#define FOR(i,n) for(int i = 0; i < (n); i++)
#define sz(c) ((int)(c).size())
#define ten(x) ((int)1e##x)
#define tenll(x) ((ll)1e##x)

const int INF = ten(9);
int d;
int x[ten(5)];

struct Seg{
	int n;
	vector<vector<int> > dat;
	Seg(int* a, int size){
		n = 1;
		while (n < size) n *= 2;
		dat.resize(2 * n - 1);
		for (int i = n - 1; i < 2 * n - 1; i++) {
			if (i - n + 1<size) dat[i].push_back(a[i - n + 1]);
			else dat[i].push_back(INF);
		}
		for (int i = n - 2; i >= 0; i--) {
			prop(i);
		}

	}

	void prop(int k){
		merge(dat[2 * k + 1].begin(), dat[2 * k + 1].end(),
			  dat[2 * k + 2].begin(), dat[2 * k + 2].end(),
			  back_inserter(dat[k]));
	}

	Pii minmax(int a, int b, int l, int r, int k){
		if (b <= l || r <= a) return Pii(INF, -INF);
		if (a <= l && r <= b) {
			return Pii(dat[k][0], dat[k].back());
		}

		Pii f = minmax(a, b, l, (l + r) / 2, 2 * k + 1);
		Pii g = minmax(a, b, (l + r) / 2, r, 2 * k + 2);
		return Pii(min(f.first, g.first), max(f.second, g.second));
	}

	int count(int a, int b, int LOW, int UP, int l, int r, int k){
		if (b <= l || r <= a) return 0;
		if (a <= l && r <= b) {
			auto it1 = lower_bound(dat[k].begin(), dat[k].end(), LOW);
			auto it2 = upper_bound(dat[k].begin(), dat[k].end(), UP);
			int ret = it2 - it1;
			return ret;
		}
		int f = count(a, b,LOW,UP, l, (l + r) / 2, 2 * k + 1);
		int g = count(a, b, LOW, UP, (l + r) / 2, r, 2 * k + 2);
		return f + g;
	}
};

int main(){
	int d;
	scanf("%d", &d);
	FOR(i, d) scanf("%d", x + i);

	Seg seg(x, d);

	int q;
	scanf("%d", &q);
	FOR(i, q){
		int l, r, e; scanf("%d%d%d", &l, &r, &e);
		l--;
		int cnt = seg.count(l, r,min(x[l],x[r-1]) - e,max(x[l],x[r-1])+e, 0, seg.n, 0);
		int ans = r - l - cnt;
		printf("%d\n", ans);
	}
}

Measured memory_bytes: 23264
import java.util.Scanner;
 
public class Main{
		
	public static void main(String args[]){
		  
		Scanner sc = new Scanner(System.in);
		
		int r = sc.nextInt();
		int D = sc.nextInt();
		int x = sc.nextInt();
		int next = r*x - D;
		
		for(int i = 1; i <= 10; i++) {
			System.out.println(next);
			next = r*next - D;
		}
	}
}


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

int main()
{
	int a, b;
	cin >> a >> b;

	string aa = string( b, (char)(a + '0') );
	string bb = string( a, (char)(b + '0') );
	string ans = aa;
	if( bb < ans ) ans = bb;

	cout << ans << endl;
}


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

int main() {
  string S, T;
  cin >> S >> T;
  int x;
  x = S.size();
    
  int TF = 0;
    for (int i = 0; i<x; i++) {
      if (S.at(i) != T.at(i)) {
        TF++;
        break;
      }
    }
  
  if (TF == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  
}

Measured memory_bytes: 3600
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include<numeric>
#include<cmath>
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using pll = pair<ll,ll>;
using vvii = vector<vector<int> >;
using vvll =  vector<vector<ll> >;

const ll inf = 1LL << 60;

int main(){
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	//cout << fixed << setprecision(15);
    int c = 0;
    int N; cin>>N;
    while(c < N){
        c += 1000;
    }
    cout << c - N << endl;
}


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

#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

int main() {
  int n;
  cin >> n;

  int max_count = 0;
  int ret = 1;

  for (int i = 1; i <= n; i++) {
    int count = 0;
    int val = i;
    while (true) {
      if (val % 2 == 1) {
        break;
      }
      val /= 2;
      count++;
    }

    if (count > max_count) {
      max_count = count;
      ret = i;
    }
  }

  cout << ret << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long mod=1000000007;
long long c[3000][3000]; 
long long com(int a,int b){
  if(c[a][b]>=0){
    return c[a][b];
  }
  if(a==b||b==0){
    return 1;
  }
  if(a<b||a<0){
    return 0;
  }
  return c[a][b]=(com(a-1,b-1)+com(a-1,b))%mod;
}
int main(){
  int n, k;
  cin >> n >> k;
  memset(c,-1,sizeof(c));
  for(int i=1;i<=k;i++){
    cout << com(n-k+1,i)%mod*com(k-1,i-1)%mod << endl;
  }
}

Measured memory_bytes: 70784
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1000000007, INF = 1e9;
ll f(ll n, ll x)
{
    if(n == -1){
        return 0;
    }
    return (n/x)+1;
}
int main()
{
    ll a, b, x;
    cin >> a >> b >> x;
    cout << f(b, x) - f(a-1, x) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

#define SIZE 1000000
#define NUM1 1000000007
#define NUM2 99999883

struct Info{
	ull hash_1,hash_2;
};

int T_length;
char T[SIZE+1];
ull HASH[SIZE+1][2],P[SIZE+1][2];

Info calcHash(int left,int right){

	Info ret;

	int length = right-left+1;

	ret.hash_1 = HASH[right+1][0]-HASH[left][0]*P[length][0];
	ret.hash_2 = HASH[right+1][1]-HASH[left][1]*P[length][1];

	return ret;
}

bool IS_SAME(Info left,Info right){
	if(left.hash_1 == right.hash_1 && left.hash_2 == right.hash_2)return true;
	else{
		return false;
	}
}


int main(){

	scanf("%s",T);
	for(T_length = 0; T[T_length] != '\0'; T_length++);

	HASH[0][0] = 0;
	HASH[0][1] = 0;
	P[0][0] = 1;
	P[0][1] = 1;

	//Tのハッシュ値を求める
	for(int i = 1; i <= T_length; i++){
		HASH[i][0] = T[i-1] + HASH[i-1][0]*NUM1;
		HASH[i][1] = T[i-1] + HASH[i-1][1]*NUM2;

		P[i][0] = P[i-1][0]*NUM1;
		P[i][1] = P[i-1][1]*NUM2;
	}

	int start_length = BIG_NUM;
	for(int length = T_length/3;length >= 0; length--){
		if(length*3+2 > T_length)continue;
		if((T_length-(3*length))%2 == 1)continue;
		start_length = length;
		break;
	}

	if(start_length == BIG_NUM){
		printf("mitomerarenaiWA\n");
		return 0;
	}

	Info H_1,H_2,H_3,H_4,H_5;

	int B_length;

	for(int A_length = start_length; A_length >= 1; A_length--){
		if((T_length-(3*A_length))%2 == 1)continue;
		B_length = (T_length-(3*A_length))/2;

		H_1 = calcHash(0,A_length-1);
		H_2 = calcHash(A_length,T_length-2*A_length-B_length-1);
		H_3 = calcHash(T_length-2*A_length-B_length,T_length-A_length-B_length-1);
		H_4 = calcHash(T_length-A_length-B_length,T_length-A_length-1);
		H_5 = calcHash(T_length-A_length,T_length-1);


		if(IS_SAME(H_1,H_3) == true && IS_SAME(H_1,H_5) == true && IS_SAME(H_2,H_4) == true){
			printf("Love ");
			for(int i = 0; i < T_length-2*A_length-B_length; i++){
				printf("%c",T[i]);
			}
			printf("!\n");
			return 0;
		}
	}

	printf("mitomerarenaiWA\n");

	return 0;
}



Measured memory_bytes: 35448
#include<bits/stdc++.h>
using namespace std;
#define int        long long
#define nn         100005

int n,k;
int s[nn];
int solve(){
    int dp[n+1]={0};
    dp[1] = 0;

    for(int i=2;i<=k+1;i++){
        dp[i] = INT_MAX;
        for(int j=1;(i-j)>0 && j<=k;j++){
            dp[i] = min(dp[i],abs(s[i]-s[i-j])+dp[i-j]);
        }
    }

    for(int i=k+2;i<=n;i++){
        dp[i] = INT_MAX;
        for(int j=1;(i-j)>0 && j<=k;j++){
            dp[i] = min(dp[i],abs(s[i]-s[i-j])+dp[i-j]);
        }
    }
    /*for(int i=1;i<=n;i++){
        cout<<dp[i]<<" ";
    }
    cout<<"\n";*/
    return dp[n];
}

int32_t main() {
    cin>>n>>k;
    if(k>n)
        k = n;
    for(int i=1;i<=n;i++){
        cin>>s[i];
    }

    cout<<solve();
}


Measured memory_bytes: 1792
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
    int n,m; cin>>n>>m;
    int sum=0;
    rep(i,m){
        int a; cin>>a;
        sum+=a;
    }
    cout<<(sum<=n ? n-sum : -1)<<endl;
}


Measured memory_bytes: 3640
N = int(input())
X = []
for _ in range(N):
    a = int(input())
    X.append([[int(a) for a in input().split()] for __ in range(a)])

def chk(m):
    L = [m >> i & 1 for i in range(N)]
    for i in range(N):
        for x, y in X[i]:
            x -= 1
            if L[i] and L[x] != y: return 0
    return 1

ma = 0
for i in range(1<<N):
    if chk(i):
        ma = max(ma, bin(i).count("1"))
print(ma)

Measured memory_bytes: 45404
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>
 
using namespace std;

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

    vector<int> P;

    for(int i = 0; i < N; i++){
        int p;
        cin >> p;

        P.push_back(p);
    }

    int sum = 0;

    for(int i = 1; i < N - 1; i++){
        if((P[i] < P[i-1] && P[i] > P[i+1]) || (P[i] > P[i-1] && P[i] < P[i+1])){
            sum++;
        }
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
using namespace std;

int main(){
    int p=pow(10,9)+7;
    string S;cin>>S;
    int N=S.size();

    long long dp_ABC[100010],dp_BC[100010],dp_C[100010];
    int mpow=1; //分岐数

    //初期化
      dp_ABC[0]=dp_BC[0]=dp_C[0]=0;
    //漸化式
    for(int i=1;i<=N;i++){
        if(S[N-i]=='A'){
            dp_ABC[i]=(dp_ABC[i-1]+dp_BC[i-1])%p;
            dp_BC[i]=dp_BC[i-1];
            dp_C[i]=dp_C[i-1];
        }
        if(S[N-i]=='B'){
            dp_ABC[i]=dp_ABC[i-1];
            dp_BC[i]=(dp_BC[i-1]+dp_C[i-1])%p;
            dp_C[i]=dp_C[i-1];
        }
        if(S[N-i]=='C'){
            dp_ABC[i]=dp_ABC[i-1];
            dp_BC[i]=dp_BC[i-1];
            dp_C[i]=(dp_C[i-1]+mpow)%p;
        }
        if(S[N-i]=='?'){
            dp_ABC[i]=(((dp_ABC[i-1]+dp_BC[i-1])%p+dp_ABC[i-1])%p+dp_ABC[i-1])%p;
            dp_BC[i]=(((dp_BC[i-1]+dp_C[i-1])%p+dp_BC[i-1])%p+dp_BC[i-1])%p;
            dp_C[i]=(((dp_C[i-1]+dp_C[i-1])%p+dp_C[i-1]%p)+mpow)%p;
            mpow=((mpow+mpow)%p+mpow)%p;
        }
    }

    cout<<dp_ABC[N]<<endl;
    return 0;
}

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

#define int long long

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)

#define INF (3e9)

using namespace std;

int N;
int P[100003];

signed main()
{
    cin >> N;


    int ans = 0;
    int num = 0;
    REPS(i, N)
    {
        int p;
        cin >> p;

        if (i == p)
        {
            ++num;
        }

        if (i != p || i == N)
        {
            if (num > 0)
            {
                ans += num/2;
                if (num&1) ++ans;
            }
            num = 0;
        }
    }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin >> a >> b >>c;
  if(a == b){
    cout << c << endl;
  } else if(b == c){
    cout << a << endl;
  } else if(a == c){
    cout << b << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<set>
#include<climits>
#define ll long long
using namespace std;
int main() {
	ll n, d;
	cin >> d >> n;
	if (n == 100) {
		cout <<(ll) (pow(100, d)*(n + 1)) << endl;
	}
	else {
		cout << (ll) (pow(100, d)*n) << endl;
	}
}


Measured memory_bytes: 256
import re
S=input()
ans = [0]*len(S)
for m in re.finditer(r'(R+)(L+)', S):
    rs, ls = m.groups()
    nr, nl = len(rs), len(ls)
    n = nr+nl
    pos = m.start()
    if nr%2 == 1:
        ans[pos+nr-1] = (n+1)//2
        ans[pos+nr] = (n)//2
    else:
        ans[pos+nr-1] = (n)//2
        ans[pos+nr] = (n+1)//2
print(" ".join([str(a) for a in ans]))


Measured memory_bytes: 49500
#include <iostream>
#include <vector>
#include <numeric>
#include <tuple>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <limits>
#include <unordered_map>
#include <type_traits>
#include <map>

using namespace std;
using str = string;

#define rep(a,l,r) for(int a=(l);a<(r);a++)
#define get cin>>
#define put cout<<

int gcd_euclid(int u, int v) {
  int r;
  while (0 != v) {
    r = u % v; u = v; v = r; /* swap */
  }
  return u;
}

// 最大公約数算出
int calc_gcd(const vector<int> vec){
	int gcd = *min_element(vec.begin(), vec.end());
	for (const int ele: vec){
		gcd = gcd_euclid(gcd,ele);
	}
	return gcd;
}

// 最小公倍数
int calc_lcm(const vector<int> vec) {
	int tmp = 1;
	for (const int ele: vec){
		tmp *= ele;
	}
	int gcd = calc_gcd(vec);
	return tmp/gcd;
}

string def(string& prev) {
	return "A" + prev + "B" + prev + "C";
}

void run() {
    int n; get n;
    if (n == 1) {
    	put "Hello World";
    	return;
    }

    int a,b; get a; get b;

    put a + b;
}

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


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define IREP(v, i) for(auto i = (v).begin(); i != (v).end(); ++i)
#define IRREP(v, i) for(auto i = (v).rbegin(); i != (v).rend(); ++i)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define REV(x) reverse(ALL(x))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ld = long double;
using ll = long long;
using ui = unsigned int;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using Pll_ll = pair<ll, ll>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;
const double EPS = 1E-10;

template<class T, class S>
bool chmax(T &a, const S &b){
    if(a < b){
        a = b; return true;
    }
    return false;
}
template<class T, class S>
bool chmin(T &a, const S &b){
    if(b < a){
        a = b; return true;
    }
    return false;
}


int main(){
    int N; cin >> N;
    VI A(N);
    REP(i, N) cin >> A[i];
    VI pos;
    ll negSum(0), posSum(0);
    int cnt(0);
    REP(i, N){
        int B; cin >> B;
        if(B > A[i]){
            negSum += B - A[i];
            ++cnt;
        }
        else if(B < A[i]){
            posSum += A[i] - B;
            pos.PB(A[i] - B);
        }
    }
    if(negSum > posSum){
        cout << -1 << endl;
        return 0;
    }

    RSORT(pos);
    for(int i = 0; i < pos.size() && negSum > 0; ++i){
        negSum -= pos[i]; ++cnt;
    }
    cout << cnt << endl;
    return 0;
}


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

int main(void) {
	int h,w;
	cin >> h >> w;
	char bomb[55][55];
	for(int i=1; i<=h; i++){
		for(int j=1; j<=w; j++){
			cin >> bomb[i][j];
		}
	}
	int area[55][55];
	for(int i=1; i<=h; i++){
		for(int j=1; j<=w; j++){
			area[i][j]=0;
			if(bomb[i][j]=='#')cout << '#';
			else {
				for(int k=-1; k<=1; k++){
					for(int l=-1; l<=1; l++){
						if(bomb[i+k][j+l]=='#')area[i][j]++;
					}
				}
				cout << area[i][j];
			}
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
/*alurquiza*/
//https://matcomgrader.com/problem/9623/dictionary-search/
//Segment Tree + binary search
#include <bits/stdc++.h>

using namespace::std;

typedef long long LL;
const int MOD = 1e9 + 7;

LL pot(int base,int exp){
	if(exp == 1)
		return base;
	if(exp % 2 == 0){
		LL aux = pot(base,exp / 2);
		return aux * aux % MOD;
	}
	return pot(base,exp - 1) * base % MOD;
}

// long long fact(int ini,int fin){
// 	LL r = 1;
// 	while(ini <= fin)
// 		r = r * ini++ % MOD;
// 	return r;
// }

LL C(int N,int K,std::vector<LL> &F){
	return F[N] * pot(F[K],MOD - 2) % MOD * pot(F[N - K],MOD - 2) % MOD;
}

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

	// freopen("milkvisits.in","r",stdin);
	// freopen("milkvisits.out","w",stdout);

	int k,q;
	cin >> k >> q;

	std::vector<int> V(k + 1);
	for(int i = 1;i <= k;i++){
		cin >> V[i];
	}

	while(q--){
		int n,x,m;
		cin >> n >> x >> m;

		std::vector<LL> TA(k + 1);
		int cant_0 = 0;
		for(int i = 1;i <= k;i++){
			cant_0 += (V[i] % m == 0);
			TA[i] = TA[i - 1] + (V[i] % m);
		}

		n--;

		// cerr << cant_0 << '\n';

		int tmp = n / k;
		int rsol = cant_0 * tmp;
		long long sum = 1LL * tmp * TA[k] + (x % m);

		// cerr << rsol << '\n';

		for(int i = 0;i < n % k;i++){
			i++;
			rsol += (V[i] % m == 0);
			sum += (V[i] % m);
			i--;
		}

		rsol += sum / m;

		// cerr << rsol << ' ' << sum << '\n';

		cout << n - rsol << '\n';
	}

	return 0;
}

//g++ -std=c++11 -Wall DS.cpp -o main

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <ctype.h>
using namespace std;

int main(int argc, char** argv) {
  string s;
  cin >> s;

  if (s[0] != 'A') {
    cout << "WA";
    return 0;
  }

  int c_count = 0;
  int c_pos = 2;
  for (int i = 2; i < s.size() - 1; i++) {
    if (s[i] == 'C') {
      c_count++;
      c_pos = i;
    }
  }

  if (c_count != 1) {
    cout << "WA";
    return 0;
  }

  for (int i = 0; i < s.size(); i++) {
    if (i == c_pos || i == 0) {
      continue;
    }
    if (isupper(s[i]) != 0) {
      cout << "WA";
      return 0;
    }
  }
  cout << "AC";
  return 0;
}


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

int main(){
  int x, y; cin >> x >> y;
  if(y&1){
    cout << "No\n";
  }else{
    int b = y/2 - x;
    if(b<0) cout << "No\n";
    else{
      int a = x - b;
      if(a < 0) cout << "No\n";
      else cout << "Yes\n";
    }
  }
  return 0;
}


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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

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

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

template <class T> T Sq(const T &t) { return t * t; }

const int mod = 1e9 + 7;

signed main() {
  int n = read();
  vector<double> val;
  REP(i, n) val.PB(read());
  sort(ALL(val));
  double ans = val[0];
  FOR(i, 1, n) { ans = (ans + val[i]) / 2.0; }
  std::cout << ans << std::endl;
}


Measured memory_bytes: 256
S=input()

pos={"AKIHABARA","KIHABARA","AKIHBARA","KIHBARA","AKIHABRA","KIHABRA","AKIHBRA","KIHBRA","AKIHABAR","KIHABAR","AKIHBAR","KIHBAR","AKIHABR","KIHABR","AKIHBR","KIHBR"}
     
if S in pos:
  print("YES")
else:
  print("NO")


Measured memory_bytes: 8968
#include <bits/stdc++.h>
 #define f first
 #define s second
 #define endl '\n'
 #define LL long long
 #define pb push_back
 #define sz(a) (int)a.size()
 #define all(a) a.begin(),a.end()
 #define rall(a) a.rbegin(),a.rend()
 #define debug(x) cerr << #x << " is " << x << endl;
 using namespace std;
 int const MAXN = 2e6 + 9;
 int main(){
    ios_base::sync_with_stdio (0),cin.tie(0);
    LL r,g,b,n;
    LL ans  = 0;
    cin >> r >> g >> b >> n;
    for (int i = 0; i <= n; i++){
        for (int j = 0; j <= n; j++){
            LL x = r*i +j*g;
            if ( x >  n) continue;
            LL y = n - x;
            if (y % b == 0) ans++;
        }
    }
    cout << ans;
 }


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<functional>
#include<vector>
#include<stack>
#include<queue>
#include<iostream>
using namespace std;
int main(void)
{
	int i,j,k;
	double n,w,nn;
	int rin;
	int suu[8]={128,64,32,16,8,4,2,1};
	int suu2[4]={8,4,2,1};
	int sei[8],syo[4];
	char sei2[9],syo2[4];
	while(1) {
		cin >>n;
		if(n<0) break;
		for(i=0;i<8;i++) {
			if(n-suu[i]>=0) {
				sei2[i]='1';
				n=n-suu[i];
			}
			else {
				sei2[i]='0';
			}
		}
		sei2[i]='.';
		sei2[i+1]='\0';
		n=n*16;
		for(i=0;i<4;i++) {
			if(n-suu2[i]>=0) {
				syo2[i]='1';
				n=n-suu2[i];
			}
			else {
				syo2[i]='0';
			}
		}
		if(n==0){
			syo2[i]='\0';
			strcat(sei2,syo2);
			cout << sei2 <<endl;
		}
		else cout << "NA" <<endl;
	}
	exit(0);
}
			
		

Measured memory_bytes: 1220
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
using namespace std;
int main(){
    int x,y;
    cin >> x >> y;
    string ans = "No";
    if((x==1||x==3||y==5||y==7||y==8||y==10)&&(y==3||y==5||y==7||y==8||y==10||y==12)){
        ans ="Yes";
    }else if((x==4||x==6||x==9)&&(y==6||y==9||y==11)){
        ans ="Yes";
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;
int main(){
  vector<int> A(3);
  cin >> A[0] >> A[1] >> A[2];
  sort(A.begin(),A.end());
  cout << A[2]*10+A[1]+A[0] << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int H, N; cin >> H >> N;
    vector<int> A(N);

    for(auto &it : A){
        cin >> it;
    }

    for(auto it : A){
        H -= it;
    }

    if(H > 0){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
}

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

int main(){
    int n;
    cin >> n;
    unordered_map <string, int> s;
    string temp;
    long long ans = 0;

    for (int tsumugi = 0; tsumugi < n; tsumugi++){
        cin >> temp;
        sort(temp.begin(), temp.end());
        ans += s[temp];
        s[temp]++;
    }

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

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

void extgcd(int a,int b,int &x,int &y){
  x = 1; y = 0;

  if(b != 0) extgcd(b, a% b, y, x), y -= (a / b) * x; 
}

int main(){
  int a,b,x,y;

  cin >> a >> b;
  extgcd(a,b,x,y);
  cout << x << " " << y << endl;

  return 0;
}

Measured memory_bytes: 1168
import java.util.Scanner;
//import java.io.*;
//import java.util.Arrays;
public class Main {
	public static void main(String[] args) throws java.io.IOException {
		Scanner scan = new Scanner(System.in);
		//InputStreamReader is = new InputStreamReader(System.in);
		//BufferedReader br = new BufferedReader(is);
		int n  = scan.nextInt();
		while(n != 0){
			int num[] = new int[n];
			int cun = 0;
			for(int i = 0 ; i < n ; i++){
				num[i] = scan.nextInt();
			}
			for(int i = n-1 ; i > 0 ; i--){
				for(int j = 0 ; j < i ; j++){
					if(num[j] > num[j+1]){
						int cen = num[j];
						num[j] = num[j+1];
						num[j+1] = cen;
						cun++;
					}
				}
			}
			System.out.println(cun);
			n = scan.nextInt();
		}
	}
}

Measured memory_bytes: 28384
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <list>
#include <ctime>
#include <sstream>
#include <queue>
#include <stack>
#include <random>
#include <bitset>
#include <numeric>
#include <cassert>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;
#define rep(x, b, e) for(int x=(b); x<(e); ++x)
#define ford(x, b, e) for(int x=((int)(b))-1; x>=(e); --x)
#define all(c) c.begin(),c.end()
#define sz(x) ((int)((x).size()))
#define pb push_back
#define st first
#define nd second
#define mp(x,y) make_pair(x,y)
typedef short int sint;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it) {
	*this << ((it != d.b) ? ", " : "") << *it;
  }
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const int nax = 1e5 + 10;
const int inf = 1e9;
string inp;
int n, m;
int d[nax];
int p[nax];
int najmn[nax];

int main() {
	ios_base::sync_with_stdio(false);
	cin >> n >> m;
	cin >> inp;
	rep(i,0,n) d[i] = inf;
	d[n] = 0;
	int s = 0;
	p[0] = n;
	int q = 1;
	ford(i, n, 0) {
		if (i + m < p[s]) {
			++s;
		}
		if (inp[i] == '1') {
			continue;
		}
		// puste pole
		if (s == q) {
			cout << -1 << endl;
			return 0;
		}
		d[i] = 1 + d[p[s]];
		// printf("d[%d] = %d\n", i, d[i]);
		p[q++] = i;
	}
	int wsk = 0;
	while (wsk < n) {
		int p2 = wsk;
		while (d[p2] == inf || d[p2] == d[wsk]) ++p2;
		cout << p2 - wsk << ' ';
		wsk = p2;
	}
	cout << endl;
}

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

class rolling_hash{
    constexpr static uint64_t mod = (1ULL << 61) - 1;
    constexpr static uint64_t mask31 = (1ULL << 31) - 1;
    constexpr static uint64_t mask30 = (1ULL << 30) - 1;
    static uint64_t base[2];
    std::vector<uint64_t> hash[2], bpow[2];

    uint64_t mul(uint64_t a, uint64_t b) const noexcept{
        uint64_t ah = a >> 31, al = a & mask31;
        uint64_t bh = b >> 31, bl = b & mask31;
        uint64_t mid = ah * bl + al * bh;
        uint64_t mh = mid >> 30, ml = mid & mask30;
        return 2 * ah * bh + mh + (ml << 31) + al * bl;
    }
    uint64_t rem(uint64_t x) const noexcept{
        x = (x & mod) + (x >> 61);
        return x < mod ? x : x - mod;
    }
public:
    rolling_hash(): bpow{{1}, {1}} {
        if(base[0] == 0){
            std::mt19937_64 mt(rand());
            std::uniform_int_distribution<uint64_t> dist(3, mod-1);
            base[0] = dist(mt);
            base[1] = dist(mt);
        }
    }
    void push_back(char c){
        if(hash[0].size() == 0){
            hash[0].push_back(c);
            hash[1].push_back(c);
        }else{
            hash[0].push_back(rem(mul(hash[0].back(), base[0]) + c));
            hash[1].push_back(rem(mul(hash[1].back(), base[1]) + c));
        }
        bpow[0].push_back(rem(mul(bpow[0].back(), base[0])));
        bpow[1].push_back(rem(mul(bpow[1].back(), base[1])));
    }
    void push_back(std::string s){
        size_t n = hash[0].size() + s.size();
        hash[0].reserve(n);
        hash[1].reserve(n);
        bpow[0].reserve(n + 1);
        bpow[1].reserve(n + 1);
        for(char c: s) push_back(c);
    }
    std::pair<uint64_t, uint64_t> operator[](size_t i) const noexcept{
        return {hash[0][i], hash[1][i]};
    }
    std::pair<uint64_t, uint64_t> operator[](std::pair<size_t, size_t> r) const noexcept{
        if(r.first == 0) return operator[](r.second - 1);
        uint64_t h0 = rem(hash[0][r.second-1] + 3 * mod - mul(hash[0][r.first-1], bpow[0][r.second - r.first]));
        uint64_t h1 = rem(hash[1][r.second-1] + 3 * mod - mul(hash[1][r.first-1], bpow[1][r.second - r.first]));
        return {h0, h1};
    }
};
uint64_t rolling_hash::base[2];

using namespace std;
int main(){
    string t, p;
    size_t nt, np;
    rolling_hash ht, hp;

    cin >> t >> p;
    nt = t.size();
    np = p.size();
    ht.push_back(t);
    hp.push_back(p);
    for(size_t i=0;i+np<=nt;++i){
        if(ht[{i, i+np}] == hp[{0, 0+np}]) cout << i << endl;
    }
    return 0;
}


Measured memory_bytes: 36200