akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#pragma warning(disable:4996)
using namespace std;

struct Node {
	int key;
	int left;
	int right;
};

int n;
char command[7];
Node tree[500000];
int tree_num;
int root = -1;

inline int create_node(int key) {
	Node& node = tree[tree_num];
	node.key = key;
	node.left = -1;
	node.right = -1;
	return tree_num++;
}

inline void insert(int key) {
	if (root == -1) {
		root = create_node(key);
		return;
	}
	int node = root, parent = 0;
	while (node != -1) {
		parent = node;
		if (key < tree[node].key) {
			node = tree[node].left;
		}
		else {
			node = tree[node].right;
		}
	}
	int newnode = create_node(key);
	if (key < tree[parent].key) {
		tree[parent].left = newnode;
	}
	else {
		tree[parent].right = newnode;
	}
}

inline int find(int key) {
	int node = root;
	while (node != -1) {
		if (tree[node].key == key) {
			return node;
		}
		else if (tree[node].key > key) {
			node = tree[node].left;
		}
		else {
			node = tree[node].right;
		}
	}
	return -1;
}

void pre_order(int root) {
	Node& node = tree[root];
	printf(" %d", node.key);
	if (node.left != -1) {
		pre_order(node.left);
	}
	if (node.right != -1) {
		pre_order(node.right);
	}
}

void in_order(int root) {
	Node& node = tree[root];
	if (node.left != -1) {
		in_order(node.left);
	}
	printf(" %d", node.key);
	if (node.right != -1) {
		in_order(node.right);
	}
}

int main(void) {
	scanf("%d", &n);
	for (int i = 0, key; i < n; ++i) {
		scanf("%s", command);
		if (command[0] == 'i') {
			scanf("%d", &key);
			insert(key);
		}
		else if (command[0] == 'f') {
			scanf("%d", &key);
			int found = find(key);
			printf("%s\n", found != -1 ? "yes" : "no");
		}
		else {
			if (root == -1) { continue; }
			in_order(0);
			printf("\n");
			pre_order(0);
			printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 7724
import sys
import re

a = sys.stdin.readline().strip();
pattern = 'RL'

pairs = []
# (left, length)

p1 = []
p2 = [-1]

for m in re.finditer(r'RL', a, re.MULTILINE):
	p1.append(m.start(0))

# 
for m in re.finditer(r'LR', a, re.MULTILINE):
	p2.append(m.start(0))
p2.append(len(a)-1)


# print(p1)
# print(p2)

result = [0 for x in range(len(a))]


# 10^10は偶数なので、最初と配置の偶奇は同じ。
# 開始と終了の偶奇が違うなら公平配分
# 開始奇数終了奇数→奇数が1つ多い→奇数の方
# 開始偶数終了偶数→偶数が1つ多い→偶数の方

for lft in (range(len(p1))):
	tx = p1[lft]
	t0 = p2[lft] + 1
	t1 = p2[lft + 1]
	w = t1 - t0 + 1

	sx = 0
	sy = 0
	if((t1 - t0) % 2 == 1):
		sx = w // 2
		sy = w // 2
	else:
		kg = t0 % 2
		if((kg == 0 and tx % 2 == 0) or (kg == 1 and tx % 2 == 1)):
			sx = (w + 1) // 2
			sy = w // 2
		else:
			sx = w // 2
			sy = (w + 1) // 2
	sx = int(sx)
	sy = int(sy)
	result[tx] = sx
	result[tx+1] = sy


print(' '.join(map(str, result)))


Measured memory_bytes: 14708
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
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; }


int main() {
    int n, k; cin >> n >> k;
    ll ans = 0;
    for (int b = k+1; b <= n; b++) {
        ans += n/b * max(0, b-k) + max(0, n%b - k + 1);
    }
    if (k == 0) ans -= n;
    cout << ans << endl;
}


Measured memory_bytes: 256
def examD():
    H, W, N = LI()
    ab = set()
    for _ in range(N):
        a, b = list(map(int,input().split()))
        ab.add((a-1,b-1))
    check = set()
    for c in ab:
        for i in range(-1,2):
            for j in range(-1,2):
                if 1<=c[0]+i<H-1 and 1<=c[1]+j<W-1:
                    check.add((c[0]+i,c[1]+j))
#    print(check)
#    print(ab)
    ansC = [0]*10
    for c in check:
        cur = int(0)
        for i in range(-1,2):
            for j in range(-1,2):
                if (c[0]+i,c[1]+j) in ab:
                    cur += 1
        ansC[cur] +=1
    ansC[0] = (H-2)*(W-2)-sum(ansC)
    for v in ansC:
        print(v)


import sys
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examD()


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

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

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

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

int main(){
	ll N;
	cin >> N;
	vector<ll> A(N);
	REP(i, N) cin >> A[i];

	ll tmp = 0;
	REP(i, N) if(A[i]%2==1) tmp++;
	cout << (tmp%2==1?"NO":"YES") << endl;
    return 0;
}

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

int main(){
    int n; cin>>n;
    int a[n]; rep(i,n) cin>>a[i];
    int ans=0;
    rep(i,n)rep(j,n){
        ans=max(ans,abs(a[i]-a[j]));
    }
    cout<<ans<<endl;
    return 0;
}


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


def II():
    return int(sys.stdin.readline())


def main():
    n = II()
    if n % 2 == 1:
        print(0)
        return

    n_int = n // 2
    ans_int = 0

    k = 5
    while k <= n_int:
        ans_int += n_int//k
        k *= 5

    print(ans_int)


main()


Measured memory_bytes: 64836
/* Simplicity and Goodness */

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

// using namespace __gnu_pbds;
using namespace std;
// typedef tree<int, null_type, less<int>, rb_tree_tag,
//             tree_order_statistics_node_update> indexed_set;

void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B)
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...)  cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)

#define scn(n) scanf("%d", &n)
#define lscn(n) scanf("%lld", &n)
#define pri(n) printf("%d ", (int)(n))
#define prin(n) printf("%d\n", (int)(n))
#define lpri(n) printf("%lld ", n)
#define lprin(n) printf("%lld\n", n)
#define rep(i,a,b) for(int i=(int)(a); i<(int)(b); i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;

const int inf = INT_MAX;
const int ninf = INT_MIN;
const int mod = 1e9+7;
const int maxN = 2e5+2;


void solve()
{
    int n;
    scn(n);

    puts(n >= 30? "Yes": "No");
}

int main()
{
    int t = 1;
    // scn(t);
    while(t --) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3760
#include<stdio.h>
int main()
{
	int a,b;
	scanf("%d %d",&a,&b);
	if(a==b)
	{
		printf("unsafe");
	}
	if(a<b)
	{
		printf("unsafe");
	}
	if(a>b)
	{
		printf("safe");
	}
	return 0;
}

Measured memory_bytes: 1732
#include <iostream>
#include <algorithm>
#include <map>
#include <cstdio>
#define mod 1000000007
using namespace std;
inline long long gcd(long long x,long long y)
{
	if(x>y) swap(x,y);
	while(x) y%=x,swap(x,y);
	return y;
}
map <pair<long long,long long>,long long> mp;
pair <long long,long long> a[200005];
long long ksm[200005];
signed main(int argc, char** argv) {
	long long n;
	cin >> n;
	for(long long i=1;i<=n;i++)
	{
		long long x,y;
		scanf("%lld%lld",&x,&y);
		if(x<0) x=-x,y=-y;
		if(x==0&&y<0) y=-y;
		long long G=gcd(max(x,-x),max(y,-y));
		if(G) x/=G,y/=G;
		else
		{
			if(x!=0) a[i]={1,0};
			else if(y!=0) a[i]={0,1};
			else a[i]={0,0};
		}
		a[i]={x,y};
		++mp[a[i]];
	}
	ksm[0]=1;
	for(long long i=1;i<=n;i++) ksm[i]=(ksm[i-1]*2%mod);
	long long ans=1,s=0;
	for(long long i=1;i<=n;i++)
	{
		if(a[i].first==0&&a[i].second==0)
		{
			++s;
			continue;
		}
		long long x=mp[a[i]],y=max(mp[{a[i].second,-a[i].first}],mp[{-a[i].second,a[i].first}]);
		mp[a[i]]=mp[{a[i].second,-a[i].first}]=mp[{-a[i].second,a[i].first}]=0;
		ans*=ksm[x]+ksm[y]-1,ans%=mod;
	}
	cout << (ans+mod-1+s)%mod;
	return 0;
}

Measured memory_bytes: 45416
def solve(n,a):
    ct = [0 for _ in range(n)]
    for v in a:
        ct[v] += 1

    if n%2 == 1:
        if ct[0] != 1:
            return 0

        for i in range(1,n):
            if i%2 == 1:
                if ct[i] != 0:
                    return 0
            else:
                if ct[i] != 2:
                    return 0
    else:
        if ct[0] != 0:
            return 0

        for i in range(1,n):
            if i%2 == 1:
                if ct[i] != 2:
                    return 0
            else:
                if ct[i] != 0:
                    return 0

    return 2**(n//2)%(10**9+7)

def main():
    n = int(input())
    a = list(map(int,input().split()))
    print(solve(n,a))

if __name__ == '__main__':
    main()


Measured memory_bytes: 14008
d,g=map(int,input().split())
l=[list(map(int,input().split())) for i in range(d)]

a=[]
for j in range(d):
  a.append([(j+1)*100*l[j][0]+l[j][1],l[j][0]])

b=[]
for k in range(2**d):
  b.append(format(k,'0'+str(d)+'b'))

c=[]
for m in range(len(b)):
  e=0;f=0;z=-1
  for n in range(d):
    if b[m][n]=='1':
      e+=a[n][0];f+=a[n][1]
    else:
      z=n+1
  c.append([e,f,z])

p=[]
for x in range(len(c)):
  q=c[x][0];r=c[x][1];s=c[x][2]
  if q>=g:
    p.append(r)
  else:
    for y in range(a[s-1][1]+1):
      q+=s*100;r+=1
      if q>=g:
        p.append(r)
        break

print(min(p))

Measured memory_bytes: 3188
#include<algorithm>
#include<cmath>
#include<iostream>
#include<vector>
#include<string>
using namespace std;
typedef long long ll;

#define REP(i, n) for(ll i=0;i<ll(n); i++)

int main(){
    int hp_1, at_1, hp_2, at_2;
    cin >> hp_1 >> at_1 >> hp_2 >> at_2;
    while(hp_1 > 0 || hp_2 > 0){

        hp_2 -= at_1;
        if(hp_2 <= 0){cout << "Yes" << endl;return 0;}

        hp_1 -= at_2;
        if(hp_1 <= 0){cout << "No"  << endl;return 0;}
    }

    return 0;
}


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

void InsertionSort(std::vector<int>& arr)
{
	int j;
	for (auto i = 0; i < arr.size();++i)
	{
		std::cout << arr[i];
		if (i != arr.size() - 1)
			std::cout << " ";
		else
			std::cout << "\n";
	}

	for (auto i = 1; i < arr.size(); ++i)
	{
		int v = arr[i];
		j = i - 1;
		while (j>=0&&arr[j]>v)
		{
			arr[j + 1] = arr[j];
			--j;
		}
		arr[j + 1] = v;
		for (auto i = 0; i < arr.size(); ++i)
		{
			std::cout << arr[i];
			if (i != arr.size() - 1)
				std::cout << " ";
			else
				std::cout << "\n";
		}
	}
}

template<typename T>
T Input()
{
	T value;
	std::cin >> value;
	return value;
}

int main()
{
	std::vector<int> vec;
	int num;
	std::cin >> num;
	for (auto i = 0; i < num; ++i)
		vec.push_back(Input<int>());

	InsertionSort(vec);

	return 0;
}

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

int main() {
	int n;
	cin >> n;
	vector<int> a(100001, 0);
	vector<int> b(100001, 0);
	rep(i, n) {
		int v;
		scanf("%d", &v); '\n';
		if (i % 2 == 0) a[v]++;
		else b[v]++;
	}
	int ma = 0;
	int na = 0;
	int mb = 0;
	int nb = 0;
	rep2(i, 1, 100001) {
		if (a[i] > a[ma]) {
			na = ma;
			ma = i;
		}
		else if (a[i] > a[na]) {
			na = i;
		}
		if (b[i] > b[mb]) {
			nb = mb;
			mb = i;
		}
		else if (b[i] > b[nb]) {
			nb = i;
		}
	}
	if (ma != mb) {
		cout << n - a[ma] - b[mb] << endl;
	}
	else {
		cout << n - max(a[ma] + b[nb], a[na] + b[mb]) << endl;
	}
}
	

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

const long long INF = (1 << 30);

int main(){
  int n;
  cin >> n;
  
  int a[100000][3];
  rep(i,n){
    rep(j,3){
      cin >> a[i][j];
    }
  }
  
  long long dp[100100][3] = {}; //幸福度を0で初期化
  rep(i,3){
    dp[0][i] = a[0][i];
  }
  
  rep(i,n){
    rep(j,3){
      rep(k,3){
        if(j == k) continue;
        dp[i+1][j] = max(dp[i][k] + a[i+1][j], dp[i+1][j]);
      }
    }
  }
  
  long long ans = 0;
  rep(i,3){
    ans = max(ans, dp[n-1][i]);
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int x[100500];
void solve() {
	int n, k;
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> x[i];
	}

	ll res = LONG_MAX;
	map<ll, ll> mp1, mp2, m1, m2;
	ll k1 = 0, k2 = 0;
	for (int i = 0; i < n; i++) {
		if (x[i] > 0) {
			k1++;
			mp1[x[i]] = k1;
			m1[k1] = x[i];
		}
		if (x[n - i - 1] <= 0) {
			k2++;
			mp2[x[n - i - 1]] = k2;
			m2[k2] = x[n - i - 1];
		}
	}
	for (int i = 0; i < n; i++) {
		if (x[i] <= 0)  {
			ll need = k - mp2[x[i]];
			ll t = -x[i];
			if (need > 0 && mp1[m1[need]] > 0) {
				t = min((2 * (-x[i]) + m1[need]), (-x[i]) + 2 * m1[need]);
				need = 0;
			}
			if (need == 0)
				res = min(t, res);
		}
		else {
			ll need = k - mp1[x[i]];
			ll t = x[i];
			if (need > 0 && mp2[m2[need]] > 0) {
				t = min((2 * x[i] - m2[need]), x[i] - 2 * m2[need]);
				need = 0;
			}
			if (need == 0)
				res = min(t, res);
		}
	}
	cout << res;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int t = 1;
	//cin >> t;
	for (int i = 1; i <= t; i++) {
		solve();
	}
}

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


def solve(S: str):
    if S == 'Sunny':
        print('Cloudy')
    elif S == 'Cloudy':
        print('Rainy')
    else:
        print('Sunny')
    return S


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
from sys import exit

N = int(input())
S = input()

stack = []

black = 0
white = 0

for i in range(len(S)):
    if S[i] == '.':
        white += 1

ans = len(S)
for i in range(len(S) + 1):
    if ans > black + white:
        ans = black + white

    if i == len(S):
        continue
    if S[i] == '.':
        white -= 1
    else:
        black += 1

print(ans)


Measured memory_bytes: 3500
n,k=map(int,input().split())
import math
p=0
for i in range(1,n+1):
  if i>=k:
    p+=1/n
  else:
    if int(math.log2(k/i))==math.log2(k/i):
      p+=(1/n)*((1/2)**(int(math.log2(k/i))))
    else:
      p+=(1/n)*((1/2)**(int(math.log2(k/i))+1))
print(p)

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


int main() {
  int n;
  
  string s,t;
  
  string sum;
  
  cin >> n;
  
  cin >> s >> t;
  
  for(int i=0; i<n; i++){
    sum+=s.at(i);
    sum+=t.at(i);
  }
  
  cout << sum;
  
}


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

int main() {
    string s, t;
    cin >> s >> t;

    int a[26], b[26];

    for (int i = 0; i < 26; i++) {
        a[i] = -1;
        b[i] = -1;
    }

    for (int i = 0; i < s.size(); i++) {
        int x = s[i] - 'a';
        int y = t[i] - 'a';

        if (a[x] == -1) {
            a[x] = y;
        }

        if (b[y] == -1) {
            b[y] = x;
        }

        if (a[x] != y || b[y] != x) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}


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

#define int long long
const int sqrtN = 512;
struct SqrtDecomposition {
  int N, K;
  vector<int> data;
  vector<int> bucketSum;
  vector<int> bucketAdd;
  SqrtDecomposition(int n) : N(n) {
    K = (N + sqrtN - 1) / sqrtN;
    data.assign(K * sqrtN, 0);
    bucketSum.assign(K, 0);
    bucketAdd.assign(K, 0);
  }
  // [s, t)
  void add(int s, int t, int x) {
    for (int k = 0; k < K; ++k) {
      int l = k * sqrtN, r = (k + 1) * sqrtN;
      if (r <= s || t <= l)
        continue;
      if (s <= l && r <= t) {
        bucketAdd[k] += x;
      } else {
        for (int i = max(s, l); i < min(t, r); ++i) {
          data[i] += x;
          bucketSum[k] += x;
        }
      }
    }
  }
  // [s, t)
  int getSum(int s, int t) {
    int sum = 0;
    for (int k = 0; k < K; ++k) {
      int l = k * sqrtN, r = (k + 1) * sqrtN;
      if (r <= s || t <= l)
        continue;
      if (s <= l && r <= t) {
        sum += bucketSum[k] + bucketAdd[k] * sqrtN;
      } else {
        for (int i = max(s, l); i < min(t, r); ++i) {
          sum += data[i] + bucketAdd[k];
        }
      }
    }
    return sum;
  }
};

signed main() {
  ios::sync_with_stdio(false);
  int N, Q;
  cin >> N >> Q;
  SqrtDecomposition decomp(N);
  while (Q--) {
    int c;
    cin >> c;
    if (c == 0) {
      int s, t, x;
      cin >> s >> t >> x;
      decomp.add(s, t + 1, x);
    } else {
      int s, t;
      cin >> s >> t;
      cout << decomp.getSum(s, t + 1) << endl;
    }
  }
}

Measured memory_bytes: 3616
#include <stdio.h>

int main(void){
  int a, b, c, d;
  scanf("%d%d%d%d", &a, &b, &c, &d);
  if(a*b<=c*d)
    printf("%d\n", c*d);
  else
    printf("%d\n", a*b);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long
using namespace std;
const ll INF = 1e18L + 10;
int main(){
    fast;
    int n, w;
    cin >> n >> w;
    ll wt[n], val[n];
    for(int i = 0; i < n; i++)
        cin >> wt[i] >> val[i];
    int sum_val = 0;
    for(int x: val)
        sum_val += x;
    vector <ll> dp(sum_val + 1, INF);
    dp[0] = 0;
    for(int i = 0; i < n; i++)
        for(int j = sum_val - val[i]; j >= 0; j--)
            dp[j + val[i]] = min(dp[j + val[i]], dp[j] + wt[i]);
            //cout << dp[j + val[i] << "acaa\n";
    ll ans = 0;
    for(int i = 0; i <= sum_val; i++)
        if(dp[i] <= w)
            ans = max(ans, (ll)i);
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3956
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)
	bc := 0
	ans := 0
	mae := false
	for i := len(s) - 2; i >= 0; i-- {
		if s[i] == 'B' {
			if s[i+1] == 'C' {
				bc++
				mae = true
			} else {
				bc = 0
				mae = false
			}
			continue
		}
		if s[i] == 'A' {
			if mae {
				ans += bc
				mae = true
			} else {
				bc = 0
			}
			continue
		}
		if mae {
			mae = false
		} else {
			bc = 0
		}
	}
	fmt.Println(ans)
}


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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

ll dp[2][102];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	string s;
  cin>>s;
  string ans="AKIHABARA";
  
  ll cur1=0;
  ll n=ans.size();
  bool flag=true;
  REP(cur,n){
    if(cur1!= s.size() && s[cur1]==ans[cur]){
      cur1++;
      continue;
    }
    else{
      if(ans[cur]=='A')
        continue;
      else{
        flag=false;
        break;
      }
    }
  }
  
  if(cur1!=s.size())
    flag=false;
         
  if(flag)
    cout<<"YES"<<endl;
  else
    cout<<"NO"<<endl;


}




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

using namespace std;

using i64 = int64_t;

const i64 MOD = 1e9+7;

const i64 INF = 1e18+7;

using value_type = i64;


signed main(){
    vector<int> x(3), y(3);
    for(int i = 0; i < 3; ++i)
        cin >> x[i] >> y[i];
    double a = sqrt((x[0] - x[1]) * (x[0] - x[1]) + (y[0] - y[1]) * (y[0] - y[1]));
    double b = sqrt((x[2] - x[1]) * (x[2] - x[1]) + (y[2] - y[1]) * (y[2] - y[1]));
    double c = sqrt((x[2] - x[0]) * (x[2] - x[0]) + (y[2] - y[0]) * (y[2] - y[0]));
    double t = (a + b + c) / 2;
    double s = sqrt(t * (t - a) * (t - b) * (t - c));
    double r = 2 * s / (a + b + c);
    double st = 0;
    double en = MOD;
    for(int i = 0; i < 60; ++i){
        double mid = (st + en) / 2;
        (((1 - mid / r) * max({a, b, c}) > 2 * mid) ? st : en) = mid;
    }
    printf("%.20lf\n", st);
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main( )
{
	
	int i,p,count=0;
	char x[200001];
	char y[200001];
	gets(x);
	gets(y);
	
	p = strlen(x); 

	for (i=0; i<p; i++)
	{
		if (x[i] != y[i])
		{  
		    count++;
		}
	}
	printf ("%d\n",count);
	
	return 0;
}

Measured memory_bytes: 2036
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int main(){
    char a[10000],b[10000];
    cin>>a>>b;
    int x=strlen (a);
    int y=strlen (b);
    if (x!=y){
	
     if(x>y) 
	       cout<<"GREATER";
	 else 
	      cout<<"LESS";
    
	}else{
		
		for(int i=0 ;i<x ;i++){
			if(a[i]!=b[i]){
			
			     if(a[i]>b[i])
			        cout<<"GREATER";
			    else 
			        cout<<"LESS";
		    break;
		}
		        if(i+1==x)
                 cout<<"EQUAL";
			continue;	 
				 	}}
				return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
signed main(){
  ll n,v;
  cin >> n;
  ll a[n];
  set<ll> st;
  for(int i=0;i<n;i++){
    cin >> a[i];
    st.insert(a[i]);
  }
  v = st.size();
  if(v%2==0) v--;
  cout <<v <<endl;
}


Measured memory_bytes: 5760
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>

using namespace std;

int main(){
  int n = 0;
  char t[1001] = {0};
  gets(t);
  for(n = 0; n < 1001; n++){
    if(t[n] == 0)
      break;
    t[n] -= 3;
    if(t[n] < 'A')
      t[n] += 'Z' - 'A' + 1;
    printf("%c", t[n]);
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 1080
#include<bits/stdc++.h>
using namespace std;
const int N=1005;
int n,Max,pos,tot,ans[N],a[N];
vector<int> vec;
typedef long long ll;
ll sum1,sum2;
int main()
{
   scanf("%d",&n);Max=-1e9-1;//注意max要赋值成负的！
   for (int i=1;i<=n;i++) 
   {
      scanf("%d",&a[i]);if (a[i]>Max) Max=a[i],pos=i;
      if (i&1) sum1+=(a[i]>0)?a[i]:0;
      else sum2+=(a[i]>0)?a[i]:0;
   }
   if (Max<0) 
   {
     printf("%d\n%d\n",Max,n-1);
     for (int i=n;i>pos;i--) printf("%d\n",i);
     for (int i=1;i<pos;i++) puts("1");
     return 0;
   }
   for (int i=(sum1>sum2?1:2);i<=n;i+=2) if (a[i]>0) vec.push_back(i);
   printf("%lld\n",max(sum1,sum2));
   for (int i=n;i>vec[vec.size()-1];i--) ans[++tot]=i;
   for (int i=vec.size()-1;i>=1;i--)
   {
     int t=(vec[i]-vec[i-1])/2-1;
     while (t--) ans[++tot]=vec[i-1]+2;
     ans[++tot]=vec[i-1]+1;
   }
   for (int i=1;i<vec[0];i++) ans[++tot]=1;
   printf("%d\n",tot);
   for (int i=1;i<=tot;i++) printf("%d\n",ans[i]);
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N=3e3+5,MOD=998244353;
int n,m,ans;
int a[N],f[N]; 
signed main(){
	scanf("%lld%lld",&n,&m);
	for (register int i=1; i<=n; ++i) scanf("%lld",&a[i]); 
	for (register int i=1; i<=n; ++i)
	{
		for (register int j=m; j>a[i]; --j) f[j]=(f[j]+f[j-a[i]])%MOD;
		f[a[i]]=(f[a[i]]+i)%MOD;
		ans=(ans+f[m]*(n-i+1)%MOD)%MOD;
		f[m]=0;
	}
	printf("%lld\n",ans);
return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>

int main(){
	int a,b,c,checkTable[11],rest,count;
	while(scanf("%d %d %d",&a,&b,&c)!=EOF){
		for(int i=0; i < 11; i++)checkTable[i] = 0;
		count = 0;
		checkTable[a] = 1;
		checkTable[b] = 1;
		checkTable[c] = 1;
		if(a+b >= 20){
			printf("NO\n");
		}else{
			rest = 20 -(a+b);
			for(int i=1; i <= rest; i++){
				if(checkTable[i] == 0)count++;
			}
			if(count >= 4)printf("YES\n");
			else{
				printf("NO\n");
			}
		}

	}

	return 0;
}

Measured memory_bytes: 2596
import math
def plot(x,y):
    print(f'{x:.8f} {y:.8f}')

def Koch(n,x1,y1,x2,y2): #3点を求めるプログラム
    if n==0:
        plot(x1,y1) 
        return
    sx=(2*x1+x2)/3
    sy=(2*y1+y2)/3
    tx=(x1+2*x2)/3
    ty=(y1+2*y2)/3      
    
    ux=(tx-sx)*(1/2)-(ty-sy)*(math.sqrt(3)/2)+sx
    uy=(tx-sx)*(math.sqrt(3)/2)+(ty-sy)*(1/2)+sy  
    
    Koch(n-1,x1,y1,sx,sy) #分割された座標から求める、n-1で無限ループにならないようにする
    Koch(n-1,sx,sy,ux,uy)
    Koch(n-1,ux,uy,tx,ty)
    Koch(n-1,tx,ty,x2,y2)
    
    
n=int(input())    
Koch(n,0,0,100,0)
plot(100,0)
    


Measured memory_bytes: 5756
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin >> n;
vector<char> s(n);
bool flag=false;
for(int i=0;i<n;i++) {
	cin >> s[i];
    if(s[i]=='Y') flag=true;
}
if(flag) cout << "Four" << endl;
else cout << "Three" << endl;
return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int X = int.Parse(input[0]);
            int Y = int.Parse(input[1]);
            int A = int.Parse(input[2]);
            int B = int.Parse(input[3]);
            int C = int.Parse(input[4]);

            List<long> dataA = new List<long>();
            List<long> dataB = new List<long>();
            List<long> dataC = new List<long>();
            List<long> selected = new List<long>();

            string[] inputdataA = Console.ReadLine().Split(' ');
            for (int i = 0; i < A; i++)
                dataA.Add(long.Parse(inputdataA[i]));

            string[] inputdataB = Console.ReadLine().Split(' ');
            for (int i = 0; i < B; i++)
                dataB.Add(long.Parse(inputdataB[i]));

            string[] inputdataC = Console.ReadLine().Split(' ');
            for (int i = 0; i < C; i++)
                dataC.Add(long.Parse(inputdataC[i]));

            dataA.Sort((a, b) => b.CompareTo(a));
            dataB.Sort((a, b) => b.CompareTo(a));
            dataC.Sort((a, b) => b.CompareTo(a));

            for (int i = 0; i < X; i++)
                selected.Add(dataA[i]);

            for (int i = 0; i < Y; i++)
                selected.Add(dataB[i]);

            selected.Sort();

            int idx = 0;
            int idxC = 0;

            while (idxC < dataC.Count && idxC < selected.Count)
            {
                if (dataC[idxC] > selected[idx])
                {
                    selected[idx] = dataC[idxC];
                    idx++;
                    idxC++;
                }
                else
                    break;
            }

            long res = selected.Sum();

            Console.WriteLine(res);
        }

    }
}


Measured memory_bytes: 44004
#include <bits/stdc++.h>
using namespace std;
#define fix(f,n) std::fixed<<std::setprecision(n)<<f
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long int ll;
typedef unsigned long long int ull;
#define vi vector<int>
#define pii pair<int,int>
#define vii vector<pii>
#define max(a,b) ((a>b)?a:b)
#define min(a,b) ((a>b)?b:a)
#define max3(a,b,c) ((a>b)?(a>c)?a:c:(b>c)?b:c)
#define min3(a,b,c) ((a<b)?(a<c)?a:c:(b<c)?b:c)
#define REP(i,a,n) for(ll i=a;i<n;i++)
#define pb push_back
#define mp make_pair

string s,t;
int dp[3001][3001]={};

int solve(int x,int y){
    if(dp[x][y]!=-1){
        return dp[x][y];
    }
    if(x==0 || y==0){
        return dp[x][y]=0;
    }else{
        if(s[x-1]==t[y-1]){
            return dp[x][y]=1+solve(x-1,y-1);
        }else{
            return dp[x][y]=max(solve(x-1,y),solve(x,y-1));
        }
    }
}

int main(){
	fast;
	int test=1;
	//cin >> test;
	while(test--){
	    cin >> s >> t;
	    memset(dp,-1,sizeof dp);
	    int len=solve(s.length(),t.length());
	    int temp=len;
	    vector<char> ans;
	    int j=t.length();
	    for(int i=s.length() ; i>0 && temp>0 ; i--){
	        if(dp[i-1][j]==temp){
	            continue;
	        }
	        while(j>-1 && dp[i][j]==temp){
	            j--;
	        }
	        temp--;
	        ans.pb(t[j]);
	    }
	    for(int i=len-1 ; i>=0 ; i--){
	        cout << ans[i];
	    }
	    cout << endl;
	}
	return 0;
}

Measured memory_bytes: 39280
import sys
readline = sys.stdin.readline
MOD = 998244353

N, M, K = map(int, readline().rstrip().split())
fact = [1] * (N+1)
finv = [1] * (N+1)
inv = [1] * (N+1)
inv[0] = 0
for i in range(2, N+1):
    fact[i] = (fact[i-1] * i % MOD)
    inv[i] = (-inv[MOD%i] * (MOD // i)) % MOD
    finv[i] = (finv[i-1] * inv[i]) % MOD

def comb(n, r, mod=MOD):
    if r < 0 or n < r:
        return 0
    return fact[n] * finv[r] * finv[n-r] % mod

def main():
    res = 0
    for k in range(K+1):
        res += comb(N-1, k, MOD) * pow(M-1, N-k-1, MOD) * M
        res %= MOD
    
    print(res)


if __name__ == '__main__':
    main()

Measured memory_bytes: 32508
from collections import deque
n,m=map(int,input().split())
graph=[[] for i in range(n+m)]
for i in range(n):
    l=list(map(int,input().split()))
    for j in range(1,l[0]+1):
        graph[n-1+l[j]].append(i)
        graph[i].append(n-1+l[j])
visited=[False]*(n+m)
Q=deque([0])
while Q:
    v=Q.popleft()
    for i in graph[v]:
        if visited[i]:continue
        Q.append(i)
        visited[i]=True
if False in visited[:n]:print("NO")
else:print("YES")

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

int main() {
    long n,k;
    cin >> n>>k;
    long t=n%k;
    cout << min(t,k-t);
    return 0;
}

Measured memory_bytes: 384
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)

#define rep(i,n) for(int i = 0; i < n; i++)
#define ENDL "\n"
#define print(i) std::cout << (i) << "\n"

#define int long long // at least int64 > 9*10^18
#define all(v) v.begin(), v.end()

signed main() {
	std::string s;
	std::cin >> s;
	int n = s.length();
	if(n&1) {
		print("No");
		return 0;
	}
	std::map<char,char> map;
	map['b'] = 'd';
	map['d'] = 'b';
	map['p'] = 'q';
	map['q'] = 'p';
	for(int i=0;i<n/2;i++) {
		if(map[s[i]]!=s[n-1-i]) {print("No");return 0;}
	}
	print("Yes");
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define leading zero str.erase(0, min(str.find_first_not_of('0'), str.size()-1));
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
string text="abcdefghijklmnopqrstuvwxyz";
const int maxn=1e6+7;
//        .--------------.
//        | Try First One|
//        '--------------'
//                |     .--------------.
//                |     |              |
//                V     V              |
//              .--------------.       |
//              |      AC.     |<---.  |
//              '--------------'    |  |
//              (True)|  |(False)   |  |
//           .--------'  |          |  |
//           |           V          |  |
//           |  .--------------.    |  |
//           |  |   Try Again  |----'  |
//           |  '--------------'       |
//           |                         |
//           |  .--------------.       |
//           '->| Try Next One |-------'
//              '--------------'
ll bin_pow(ll a,ll b,ll m)
{
    ll res=1;
    a%=m;
    while(b>0)
    {
        if(b&1)
            res=res*a%m;
        b>>=1;
        a=a*a%m;
    }
    return res;
}
bool miller_rabin(ll d,ll n)
{
    ll a=2+rand()%(n-4);
    ll x=bin_pow(a,d,n);
    if(x==1 || x==n-1)
        return true;
    while(d!=n-1)
    {
        x=(x*x)%n;
        d*=2;
        if(x==1)
            return false;
        if(x==n-1)
            return true;
    }
    return false;
}
bool prime(ll n,ll k)
{
    if(n==1 || n==4)
        return false;
    if(n<=3)
        return true;
    ll d=n-1;
    while(d%2==0)
        d/=2;
    for(int i=0; i<k; i++)
    {
        if(!miller_rabin(d,n))
            return false;
    }
    return true;
}
int n;
string s;
ll ans = 0;

void solve(ll x,ll y)
{
    if(x==n+1)
    {
        ans += y;
        return;
    }
    ll cur = 0;
    for(ll i=x; i<=n; i++)
    {
        cur = (10*cur) + (s[i]-'0');
        solve(i+1,y+cur);
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    char s[100005];
    scanf("%s",s+1);
    int n=strlen(s+1);
    int cnt1=n;
    int cnt2=n;
    for(int i=1;i<=n;i++){
        if(s[i]=='0')cnt1=min(cnt1,max(n-i,i-1));
        if(s[i]=='1')cnt2=min(cnt2,max(n-i,i-1));
    }
    cout<<max(cnt1,cnt2)<<endl;
}


Measured memory_bytes: 3872
# -*- coding: utf-8 -*-
import sys
N,M,K=map(int, sys.stdin.readline().split())

par=[ i for i in range(N+1) ]
size=[ 1 for i in range(N+1) ]

def root(x):
    while par[x]!=x:
        x=par[x]
    return x

def same(x,y):
	return root(x)==root(y)

def unite(x,y):
    x=root(x)
    y=root(y)
    if x==y: return
    if size[y]<size[x]: x,y=y,x  #yの要素数を大きくする
    size[y]+=size[x]
    par[x]=y #yが親ノード

def getsize(x):
	return size[root(x)]

IN=[ 0 for _ in range(N+1) ]

for _ in range(M):
    a,b=map(int, sys.stdin.readline().split())
    unite(a,b)
    IN[a]+=1
    IN[b]+=1

for _ in range(K):
    c,d=map(int, sys.stdin.readline().split())
    if same(c,d):
        IN[c]+=1
        IN[d]+=1

for i in range(1,N+1):
    print getsize(i)-1-IN[i],

Measured memory_bytes: 40220
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
#define int long long 
const int N=2e5+5;
int d,n,a;
vector<int> temp;
vector<pair<int , int> >p;
int32_t main(){
	IOS;
	
	//code

	cin>>n>>d>>a;
	temp.resize(n);
	p.resize(n);
	int bomb=0;
	for(int i=0;i<n;i++){
		int x=0,h=0;
		cin>>x>>h;
		p[i]= {x,h};
	}
	int sum=0;
	vector<pair<int, int>>::iterator it ;
	sort(p.begin(), p.end());
	for(int i=0;i<n;i++){
		bomb-=temp[i];
		pair<int, int> effect= {p[i].first + 2*d, 1e18};
		if((bomb*a)<p[i].second){
			int h= p[i].second- (bomb*a);
			int k=0;
			if(h%a==0)
				k=(h/a);
			else
				k=(h/a+1);
			bomb+=k;
			sum+=k;
			it= upper_bound(p.begin(), p.end(), effect);
			int ind=it-p.begin();
			if(ind<n)	temp[ind]+=k;
		}
	}
	cout<<sum<<endl;	
	//code
	
	return 0;

}

Measured memory_bytes: 4992
#include <stdio.h>

int main(void)
{
    int n;
    int a;
    int min = 1000000;
    int max = -1000000;
    long sum = 0;

    scanf("%d", &n);

    for ( int i = 0; i < n; i++ ) {
        scanf("%d", &a);
        if ( a < min ) {
            min = a;
        }
        if ( a > max ) {
            max = a;
        }
        sum += a;
    }

    printf("%d %d %ld\n", min, max, sum);

    return 0;
}


Measured memory_bytes: 2120
#include <stdio.h>  /*入出力*/
#include <stdlib.h> /*標準ライブラリ*/
#include <string.h> /*文字列*/
#include <math.h>   /*計算*/

/*ABC */

int main(void)
{
  int X, A;
  scanf("%d%d", &X, &A);
  if (X < A) {
    printf("0\n");
    return 0;
  }else printf("10\n");
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
 
#define ulli unsigned long long int
 
#define Pi 3.14159265358979323846264338327950288419716939937510
 
int main(){
 
	ios :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
	
	int k;
	
	string s;
	
	cin>>k>>s;
	
	for(auto &i : s){
		
		int j = (int)(i-'A');
		
		j += k;
		
		j %= 26;
		
		i = (char)(j+'A');
	}
	
	cout<<s;
}

Measured memory_bytes: 256
#pragma target("avx")
#pragma optimize("O3")
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using PP = std::pair<ll,P>;
using V = std::vector<ll>;
template<typename T> using pq = std::priority_queue<T>;
template<typename T> using rpq = std::priority_queue<T, std::vector<T>, std::greater<T>>;

#define REP(i,b,e) for(ll i=b; i<e; i++)
#define ALL(vec) vec.begin(),vec.end()
#define PRINT(vec) printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");
#define SCAN(vec) for(auto &i:vec)scanf("%ld",&i)
#define fi first
#define se second

const int MOD = 1e9+7;
const ll INF = 1e18;
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

int main(){
        ll n;
        scanf("%ld", &n);

        V spf(n+1, 0);
        REP(i, 0, n+1) spf[i] = i;
        for(ll i=2; i*i<=n; i++) if(spf[i]==i) {
                for(ll j=i+i; j<=n; j+=i) if(spf[j]==j) {
                        spf[j] = i;
                }
        }

        ll ans = 0;
        REP(i, 1, n+1){
                ll x = i, prev = 0, tmp = 0, cnt = 1;
                while(x!=1){
                        if(prev==spf[x]) tmp++;
                        else {
                                cnt *= tmp + 1;
                                tmp = 1;
                        }
                        prev = spf[x];
                        x /= spf[x];
                }
                cnt *= tmp + 1;
                ans += i * cnt;
        }
        printf("%ld\n", ans);
        return 0;
}

Measured memory_bytes: 81416
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <numeric>
#include <iomanip>
#define fi first
#define se second
#define fcout(n) cout<<fixed<<setprecision((n))
#define cinl(str) getline(cin,(str))
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int INF=10000009;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };

int main() {
	string s,t;
	while(true){
		cin>>s;
		if (cin.eof())break;
		t="";
		for(int i=0;i<s.size();i++){
			if(s[i]!='@'){
				t+=s[i];
			}
			else{
				for(int j=0;j<s[i+1]-'0';j++){
					t+=s[i+2];
				}
				i+=2;
			}
		}
		cout<<t<<endl;
	}
}

Measured memory_bytes: 3124
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define M 1000000007

ll n, x, ans, a[1005];

int main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    
    cin >> n >> x;
    for (int i = 1; i <= n; i++) cin >> a[i];
    sort(a + 1, a + n + 1);
    for (int i = 1; i < n; i++){
        if (x < a[i]) break;
        ans++;
        x -= a[i];
    }
    if (a[n] == x) ans++;
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<utility>
#include<cmath>
#include<algorithm>
 
using namespace std;
 
long double fact(int x){
  long double r=1;
  while(x){
    r*=x--;
  }
  return r;
}
 
int main(){
  int n,m,l;
  cin>>n>>m>>l;
  double ap[100][51],acp[100][52]={{}};
  double at[100][51];
  for(int i=0;i<n;i++){
    double p,t,v;
    cin>>p>>t>>v;
    for(int j=0;j<=m;j++){
      at[i][j]=l/v+t*j;
      ap[i][j]=pow(p/100,j)*pow(1-p/100,m-j)*fact(m)/fact(j)/fact(m-j);
      acp[i][j+1]=acp[i][j]+ap[i][j];
    }
  }
  for(int i=0;i<n;i++){
    double a=0;
    for(int j=0;j<=m;j++){
      double c=ap[i][j];
      for(int k=0;k<n;k++){
    if(i!=k){
      int x=upper_bound(at[k],at[k]+m+1,at[i][j]+1e-9)-at[k];
      c*=1-acp[k][x];
    }
      }
      a+=c;
    }
    cout<<fixed<<a<<endl;   
  }
  return 0;
}

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

//#define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* cpp template {{{ */

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define rep(i, n) REPS(i, 0, n)
#define REP0(i,n) for (ll i = 0; i <= (ll)(n); ++i)
#define REP1(i,n) for (ll i = 1; i <= (ll)(n); ++i)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << '\n';}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {rep(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) is >> x;
  //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいいです。
  return is;
}
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : " " );
  }
  return os;
}
/* }}} */
signed main() 
{
  string a,b;
  cin>>a>>b;
  if(a.size()>b.size()) print("GREATER");
  else if(a.size()<b.size()) print("LESS");
  else if(a>b) print("GREATER");
  else if(a<b) print("LESS");
  else print("EQUAL");

  return 0;
}

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

namespace DW20A {
    class Program {
        static void Main(string[] args) {
            var n = int.Parse(Console.ReadLine());
            var playlist = new Dictionary<string, int>();
            for (var i = 0; i < n; i++) {
                var l = Console.ReadLine().Split(' ');
                playlist.Add(l[0], int.Parse(l[1]));
            }

            var x = Console.ReadLine();

            var b = false;
            Console.WriteLine(playlist.Where(kv => {
                if (b) return true;
                if (kv.Key == x) b = true;
                return false;
            }).Sum(kv => kv.Value));
        }
    }
}

Measured memory_bytes: 13396
fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let mut iter = s.split_whitespace();
    let a: i32 = iter.next().unwrap().parse().unwrap();
    let b: i32 = iter.next().unwrap().parse().unwrap();
    println!("{} {}", a*b, 2*(a+b));
}



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

const int mod = 1000000007;
typedef long long LL;
void reduce(int & x) { x += x >> 31 & mod; }
int mul(int a, int b) { return (LL) a * b % mod; }
int pow(int a, int b, int res = 1) {
	for (; b; b >>= 1, a = mul(a, a)) if (b & 1) res = mul(res, a);
	return res;
}
const int MAXN = 110;
int A[MAXN], n, li[MAXN], bak;
int dp[MAXN][MAXN];
int main() {
	std::ios_base::sync_with_stdio(false), std::cin.tie(0);
	std::cin >> n;
	for (int i = 1; i <= n; ++i) std::cin >> A[i], li[++bak] = A[i];
	li[++bak] = 1; std::sort(li + 1, li + 1 + bak);
	bak = std::unique(li + 1, li + 1 + bak) - li - 1;
	li[bak + 1] = 0x3f3f3f3f;
	for (int i = 1; i <= n; ++i)
		A[i] = std::lower_bound(li + 1, li + 1 + bak, A[i]) - li;
	dp[0][0] = 1;
	const int inv2 = mod + 1 >> 1;
	auto calc = [] (int l, int r, int H) {
		r = std::min(r, H - 1);
		return pow(2, H, (pow(inv2, l) - pow(inv2, r + 1) + mod) % mod);
	} ;
	for (int i = 1; i < A[1]; ++i) {
		dp[1][i] = pow(2, li[A[1]] - li[i]) - pow(2, li[A[1]] - li[i + 1]);
		reduce(dp[1][i]);
		dp[1][i] = mul(dp[1][i], 2);
	}
	dp[1][A[1]] = 2;
	for (int i = 2; i <= n; ++i) {
		if (A[i] >= A[i - 1]) {
			int delta = li[A[i]] - li[A[i - 1]];
			for (int j = 1; j < A[i - 1]; ++j) {
				reduce(dp[i][j] += pow(2, delta, dp[i - 1][j]) - mod);
			}
			for (int j = A[i - 1]; j <= A[i]; ++j) {
				int t = calc(li[j], li[j + 1] - 1, li[A[i]]) + (j == A[i]);
				t = mul(t, 2);
				reduce(dp[i][j] += mul(t, dp[i - 1][A[i - 1]]) - mod);
			}
		} else {
			for (int j = 1; j <= A[i - 1]; ++j)
				reduce(dp[i][std::min(j, A[i])] += mul(dp[i - 1][j], 1 + (j >= A[i])) - mod);
		}
	}
	std::cout << std::accumulate(dp[n], dp[n + 1], 0ll) % mod << std::endl;
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> a(105);
  for(int i=0;i<N;i++){
     int b;
     cin >> b ;
     a[b]++; 
  }  
  int res =0;
  for(int j=0;j<105;j++){
    if (a.at(j)!=0)res++;
  }  
  cout << res<< endl;
  
}


Measured memory_bytes: 256