akhauriyash/Code-Regression huggingface dataset:
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>
#include <fstream>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
int gcd(int a, int b)
{
	if (a%b == 0)return b;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	int n, k; cin >> n >> k;
	int q; cin >> q;
	vector<int> p(n, k - q);
	while (q--)
	{
		int x; cin >> x;
		--x;
		++p[x];
	}
	for (int x : p)
	{
		if (x <= 0)cout << "No" << endl;
		else cout << "Yes" << endl;
	}
}

Measured memory_bytes: 3740
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
int d[2]={2,8},ans=-1;
vector<ll> v;

void func(int x,ll k){
  if(x) v.push_back(k);
  if(x==18) return ;
  for(int i=0;i<2;i++) func(x+1,k*10+d[i]);
}

void func2(int x,ll k,int sum){
  if(k==1&&sum) ans=max(ans,sum);
  if(v[x]>k) return ;
  if(!(k%v[x])) func2(x,k/v[x],sum+1);
  if(x+1!=v.size()) func2(x+1,k,sum);
}

int main(){
  ll n;
  cin>>n;
  func(0,0);
  sort(v.begin(),v.end());
  func2(0,n,0);
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 7256
import sys
N, K = map(int,input().split())
A = list(map(int,input().split()))

B = 0
K_copy = K
while K_copy > 0:
  B += 1
  K_copy //= 2

C = [0 for d in range(40)] #d桁目に存在する「1」のカウント
for d in range(40):
  for i in range(N):
    if A[i] % 2 == 1:
      C[d] += 1
    A[i] //= 2

ans = 0
for d in range(B, 40):
  ans += 2**d * C[d]
  
bit_K = [0 for _ in range(B)]#Kの各bitの値
for d in range(B):
  if K % 2 == 1:
    bit_K[d] = 1
  K //= 2

if B == 0:
  print(ans)
  sys.exit()
    
#桁DP
DP = [[0 for fill in range(2)] for d in range(B)]

DP[B-1][0] = C[d]
DP[B-1][1] = N - C[d]

for d in range(B-2,-1,-1):
  DP[d][0] = DP[d+1][0] * 2 + max(C[d], N - C[d])
  if bit_K[d] == 1:
    DP[d][0] = max(DP[d][0], DP[d+1][1] * 2 + C[d])
  DP[d][1] = DP[d+1][1] * 2 + C[d] + (N - 2 * C[d])*(bit_K[d])
  #print(d, DP[d][1])
  
ans += max(DP[0])
print(ans)
#print(DP)     
    

Measured memory_bytes: 86488
#include<stdio.h>
#include<queue>
#include<assert.h>
#include<tuple>
#include<string>
#include<algorithm>
#include<iostream>
#include<map>
#include<string.h>
#include<vector>
#include<math.h>
#include<stdlib.h>
#include<set>
#include<ctype.h>
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef tuple<int,int,int> t3;

const int MX = 100005;
const int MM = 1000000007;

int D[MX];

int main()
{
	int N;
	ll tot = 0, unit;
	scanf("%d", &N);
	unit = N * (ll)(N+1) / 2;
	for(int i = 1; i <= N; i++){
		scanf("%d", D+i);
		tot += D[i];
	}
	if( tot % unit ) return !printf("NO\n");
	ll t = tot / unit, cnt = 0;

	D[0] = D[N];
	for(int i = 1; i <= N; i++){
		ll diff = D[i] - D[i-1];
		diff = -diff + t;
		if( diff < 0 || diff % N != 0 ) return !printf("NO\n");
		cnt += diff / N;
	}
	if( cnt != t ) printf("NO\n");
	else printf("YES\n");
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <cstdio>
#include <queue>
#include <tuple>
#include <functional>
using namespace std;
#define rep(i, begin, end) for (decltype(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define si(a) scanf("%d", &a)
#define sii(a, b) scanf("%d%d", &a, &b)
#define siii(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define pi(a) printf("%d\n", a)
#define pii(a, b) printf("%d %d\n", a, b)
#define piii(a, b, c) printf("%d %d %d\n", a, b, c)
#define all(a) a.begin(),a.end()
#define mem(a,v) memset(a,v,sizeof(a))
#define cpy(to, from) memcpy(to, from, sizeof(from))
#define P pair<int, int>
#define t3 tuple<int,int,int>
#define ll long long 
#define pb push_back
//use move emplace..
#define eb emplace_back
//tie(a,ignore,c)=mp(1,2,3) 
#define mp make_pair
#define mt make_tuple
#define what_is(x) cerr << #x << " is " << x << endl
#define read freopen("E:\\in.txt", "r", stdin)

#define maxv 100002
#define maxe 500002
vector<P> G[maxv];
int dis[maxv];
int V, E, r, s, t, d, cur, di;
//fst for dis,snd for v
priority_queue<P,vector<P>,greater<P> >Q;
void dijstra(int src){
	mem(dis, 0x3f);
	dis[src] = 0;
	Q.push({ 0, src });
	while (!Q.empty()){
		tie(di, cur) = Q.top(); Q.pop();
		if (dis[cur] < di)continue;
		for (auto& k : G[cur]){
			if (dis[k.first]>k.second+dis[cur]){
				dis[k.first] = k.second + dis[cur];
				Q.push({ dis[k.first], k.first });
			}
		}
	}
}
int main(){
	//read;
	siii(V, E, r);
	rep(i, 0, E){ siii(s, t, d); G[s].pb({ t, d }); }
	dijstra(r);
	rep(i, 0, V)dis[i] != 0x3f3f3f3f ? pi(dis[i]) : puts("INF");
}

Measured memory_bytes: 11316
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <functional>
#include <unordered_set>
#include <vector>
using namespace std;


int main(void) {
    long long L;
    long long R;
    long long d;

    cin >> L >> R >> d;

    long long sum = 0;
    for(long long i=L; i<=R; ++i)
    {
        if(i%d == 0)
        {
            sum++;
        }
    }
    cout << sum << endl;
}

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

typedef unsigned long ul;
typedef long long ll;
typedef pair<ul, ul> P; //ペア　タイプでふ

int main()
{
    int x = 0;
    int y = 0;
    int z = 0;
    cin >> x >> y >> z;
    if (z >= x && z <= y)
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
    return 0;
}

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

#define REP(i,n) for(int i=0; i<n; i++)
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;
 
#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9

using namespace std;
typedef long long ll;

int main(){
	ll x, input;
	vector<ll> a;
	int n, ans=0;
	
	cin >> n >> x;
	REP(i,n){
		cin >> input;
		a.push_back(input);
	}
	
	sort(a.begin(), a.end() );
	
	REP(i,n){
		if (x<a[i]) break;
		x -= a[i];
		if (x==0 || i<n-1){
			ans++;
		}
	}
	
	cout << ans << endl;
	
	
	return 0;
}


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

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

const ll mod =  1000000007;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INF = 1152921504606846976

int main()
{
    int n; cin >> n;
    map<int,int> mp;
    for(int i = 2; i <= n; i++){
        int div = 2;
        int tmp = i;
        for(int j = 2; j*j <= tmp; j++){
            while(tmp % j == 0){
                mp[j]++;
                tmp /= j;
            }
        }
        if(tmp != 1) mp[tmp]++;
    }
    int ans = 0;
    vector<int> fac;
    for(auto i : mp){
        //cout << i.first << ' ' << i.second << endl;
        fac.push_back(i.second);
    }
    int s = fac.size();
    sort(fac.begin(),fac.end());
    for(int i = 0; i < s; i++){
        if(fac[i] >= 74) ans++;
    }
    for(int i = 0; i < s; i++){
        for(int j = 0; j < s; j++){
            if(i == j) continue;
            if(fac[i] >= 2 && fac[j] >= 24) ans++;
            if(fac[i] >= 4 && fac[j] >= 14) ans++;
            
        }
    }
    int tmp = 0;
    for(int i = 0; i < s; i++){
        for(int j = 0; j < s; j++){
            for(int k = 0; k < s; k++){
                if(i == j || j == k || i == k) continue;
                if(fac[i] >= 2 && fac[j] >= 4 && fac[k] >= 4) tmp++;
            }
        }
    }
    ans += (tmp/2);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    for(int i=0;i<s.size()/2;i++){
    	if(s[i]!=s[s.size()-i-1]){
        cout << "No";
           return 0;
        }
    }
    for(int i=0;i<=(s.size()-1)/4;i++){
        if(s[i]!=s[(s.size()-1)/2-i-1]){
           cout << "No";
           return 0;
        }
        if(s[(s.size()+3)/2+i-1]!=s[s.size()-i-1]){
           cout << "No";
           return 0;
    }
    }
    cout << "Yes";
     
}

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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {
    ll N, K;
    cin >> N >> K;

    // 大きい順に取る
    priority_queue<P> que;
    rep(i, N) {
        ll t, d; cin >> t >> d;
        que.push({d, t});
    }

    map<int, int> mp;
    ll s = 0, x = 0, ans = 0;
    priority_queue<P, vector<P>, greater<P>> que2;
    rep(i, K) {
        P p = que.top(); que.pop();
        if (mp.count(p.second) == 0) x++;
        mp[p.second]++;
        s += p.first;
        que2.push(p);
    }
    ans = s + x*x;

    while (que.size()) {
        P p = que.top(); que.pop();
        if (mp[p.second]>=1) continue;

        ll m = -1;
        while (que2.size()) {
            P p2 = que2.top(); que2.pop();
            if (mp[p2.second] > 1) {
                m = p2.first;
                mp[p2.second]--;
                break;
            }
        }

        if (m == -1) break;

        s += p.first;
        s -= m;
        if (mp[p.second] == 0) x++;
        mp[p.second]++;
        ans = max(ans, s+x*x);
    }

    cout << ans << endl;
}


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

const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll,ll>pll;

ll n;
map<pll, int> dp;

inline void Add(int &x, int a) {
    x += a; while (x >= MOD) x -= MOD;
}

inline int dfs(ll u, ll v) {
    if (v < 0) return 0;
    if (!v) return 1;
    if (dp.count(pll(u, v))) return dp[pll(u, v)];
    int res = 0;
    Add(res, dfs(u >> 1, v >> 1));
    Add(res, dfs((u - 1) >> 1, (v - 1) >> 1));
    if (v >= 2) Add(res, dfs(u >> 1, (v - 2) >> 1));
    return dp[pll(u, v)] = res;
}

int main(void) {
    cin >> n;
    cout << dfs(n, n) << endl;
    return 0;
}


Measured memory_bytes: 3652
h, n = input().split()
h = int(h)
n = int(n)
attack = sorted(list(map(int, input().split())), reverse=True)
while  n > 0:
    m_attack = attack[0]
    if h - m_attack <= 0:
        h = h - m_attack
        print("Yes")
        break
    else:   
        h = h - m_attack
        attack.remove(m_attack)
        n = n-1
if h > 0:
    print("No")

Measured memory_bytes: 13964
using System;
using System.Collections.Generic;

public class CSharp
{
    public static void Main()
    {
        Kyopuro chokudai = new Kyopuro();
        chokudai.AtCoder();
    }
}

public class Kyopuro
{
    public void AtCoder()
    {
        int n = int.Parse(Console.ReadLine());
        int m = n;
        int ans = 0;
        if (n % 2 == 1)
        {
            m--;
            ans = (m - 2) * m / 2 + m;
        } else
        {
            ans = (m - 2) * m / 2;
        }
        Console.WriteLine(ans);

        for (int i = 1; i <= m; i++)
        {
            for (int j = i; j <= m; j++)
            {
                if (i != j && i + j != m + 1)
                {
                    Console.WriteLine(i + " " + j);
                }
            }
        }
        if (n % 2 == 1)
        {
            for(int i = 1; i < n; i++)
            {
                Console.WriteLine(i + " " + n);
            }
        }
    }
    public static void DebugWL(object x) { System.Diagnostics.Debug.WriteLine(x); }
}


Measured memory_bytes: 11220
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include<sstream>
#include<unordered_set>

using namespace std;



int main(){
    string s;
    int N,A,B;
    cin >> N;
    long long res = 0;
    int c = 2;
    int k;
    cin >> k;
    res += k - 1;
    for (int i = 1; i < N; ++i) {
        cin >> k;
        if (k == c) ++c;
        if (k > c) {
            res += (k - 1) / c;
        }
    }
    cout << res;
}



Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <cstring>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>

#define INF 1e9
#define nmax 200010
#define fst first
#define snd second
#define pb push_back
#define SZ(x) ((int)(x.size()))

#define MOD 1000000007

#define MOD1 998244353
#define MOD2 666013
#define P1 255
#define P2 2059

using namespace std;

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

int n, a, b;

int f(int x)
{
    if (x < 0) return x + MOD; else
        return x;
}

int my_pow(int x, int p)
{
    int sol = 1;

    while (p > 0) {

        if (p % 2 == 1) sol = (1LL * sol * x) % MOD;
        
        p /= 2;
        x = (1LL * x * x) % MOD; 
    }

    return sol;
}

int main()
{
    scanf("%d %d %d", &n, &a, &b);

    int ans = my_pow(2, n) - 1;

    int a_fac = 1;
    int b_fac = 1;

    for (int i = 1; i <= a; i++) a_fac = (1LL * a_fac * i) % MOD;
    for (int i = 1; i <= b; i++) b_fac = (1LL * b_fac * i) % MOD;

    int _pa = 1, _pb = 1;

    for (int i = n - a + 1; i <= n; i++) _pa = (1LL * _pa * i) % MOD;

    for (int i = n - b + 1; i <= n; i++) _pb = (1LL * _pb * i) % MOD;

    _pa = (1LL * _pa * my_pow(a_fac, MOD - 2)) % MOD;
    _pb = (1LL * _pb * my_pow(b_fac, MOD - 2)) % MOD;

    ans = f(f(ans - _pa) - _pb);

    printf("%d", ans);

    // IMPORTANT!!!!!
    // Are you missing something????
    // check limits, int or ll

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String a = "";
        for (int x = 0 ; x<s.length();x++){
            a+="x";
        }
        System.out.println(a);
    }
}

Measured memory_bytes: 22996
n=int(input())
s=[]
c=[]
ans=0
for i in range(n):
  s.append(input()[0])
for x in 'MARCH':
  c.append(s.count(x))
for i in range(3):
  for j in range(i+1,4):
    for k in range(j+1,5):
      ans+=c[i]*c[j]*c[k]
print(ans)

Measured memory_bytes: 3864
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
	long long a,b;
	char c;
	scanf("%lld %c %lld",&a,&c,&b);
	if(c=='+')
	    printf("%lld\n",a+b);
	else
	    printf("%lld\n",a-b);
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String s[] = new String[a.length()];
		int n[] = new int[a.length()];
		for(int i = 0; i < a.length(); i++){
			s[i] = a.substring(i, i+1);
		}
		int j;
		int cnt;
		boolean flg;
		for(int k = 0; k < a.length(); k++){
			flg = true;
			j = k;
			cnt = 0;
			if(s[k].equals("R")){
				while(true){
					if(s[j+1].equals("R")){
						j++;
						k++;
						cnt++;
						flg = !flg;
					}
					else{

							n[j] += cnt/2 + 1;
							n[j+1] += (cnt+1)/2;
						break;
					}
				}
			}
			else{
				while(j < s.length -1){
					if(s[j+1].equals("L")){
						j++;
						k++;
						cnt++;
				}
					else{
						break;
					}
				}

				while(true){
					if(s[j-1].equals("L")){
						j--;
						flg = !flg;

					}
					else{
							n[j] += cnt/2 + 1;
							n[j-1]+= (cnt+1)/2;
						break;
					}
				}

			}
		}
		for(int i = 0; i < n.length; i++){
			System.out.print(n[i] + " ");
		}

	}

}

Measured memory_bytes: 43884
#include<stdio.h>
#include<algorithm>
using namespace std;
char in[10][10];
int pl[10];
int u[10][10];
int t3[10];
int q[10];
int used[10];
int L;
int dfs(int a){
	if(a==3){
		return 1;
	}
	if(u[a][0]==0)return dfs(a+1);
	for(int i=0;i<L;i++){
		if(used[i])continue;
		bool ok=true;
		for(int j=0;j<L;j++){
			int cnt=0;
			for(int k=0;k<L;k++){
				if(!used[k]&&q[k]==q[i]+j)cnt++;
			}
			if(cnt<u[a][j])ok=false;
		}
		if(ok){
			for(int j=0;j<L;j++){
				int cnt=0;
				for(int k=0;k<L;k++){
					if(cnt==u[a][j])break;
					if(!used[k]&&q[k]==q[i]+j){
						cnt++;
						used[k]=1;
					}
				}
			}
			if(dfs(a+1))return 1;
			for(int j=0;j<L;j++){
				int cnt=0;
				for(int k=0;k<L;k++){
					if(cnt==u[a][j])break;
					if(used[k]&&q[k]==q[i]+j){
						cnt++;
						used[k]=0;
					}
				}
			}
		}
	}
	return 0;
}
long long C[10][10];
int main(){
	int a,b,c;
	t3[0]=1;
	C[0][0]=1;
	for(int i=0;i<9;i++){
		for(int j=0;j<=i;j++){
			C[i+1][j]+=C[i][j];
			C[i+1][j+1]+=C[i][j];
		}
	}
	for(int i=1;i<10;i++)t3[i]=t3[i-1]*3;
	while(scanf("%d%d%d",&a,&b,&c),a){
		L=c;
		for(int i=0;i<10;i++)for(int j=0;j<10;j++)u[i][j]=0;
		for(int i=0;i<c;i++){
			scanf("%s",in[i]);
			pl[i]=0;
			for(int j=1;in[i][j];j++)pl[i]++;
			if(in[i][0]!='*')u[in[i][0]-'a'][pl[i]]++;
		}
	/*	for(int i=0;i<3;i++){
			for(int j=0;j<7;j++)printf("%d ",u[i][j]);
			printf("\n");
		}*/
		long long ret=0;
		for(int i=0;i<t3[c-1];i++){
			q[0]=0;
			for(int j=0;j<c;j++)used[j]=0;
			for(int j=1;j<c;j++){
				q[j]=q[j-1]+i%t3[j]/t3[j-1];
			}
			if(!dfs(0))continue;
			long long tmp=1;
			int now=0;
			int div=1;
			int num=1;
			for(int j=0;j<c;j++){
				if(j&&q[j]!=q[j-1]){
					tmp*=C[a][now];
					now=1;
					num++;
					if(q[j-1]+1<q[j])div++;
				}else now++;
			}
			tmp*=C[a][now];
			int un=b-num;
			if(un<div-1)continue;
			un-=div-1;
			for(int j=0;j<div;j++){
				tmp*=(un+div-j);
				tmp/=(j+1);
			}
		//	for(int j=0;j<c;j++)printf("%d ",q[j]);
		//	printf(": %lld\n",tmp);
			ret+=tmp;
		}
		long long total=1;
		for(int i=0;i<c;i++){
			total*=(a*b-i);
			total/=(i+1);
		}
		printf("%.12f\n",(double)ret/total);
	}
}

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

int main()
{
    int N, Q;
    string str;
    int l[100005], r[100005];
    int ac[100005];
    cin >> N >> Q;
    cin >> str;
    REP(i, Q)
        cin >> l[i] >> r[i];
    ac[0] = 0;
    ac[1] = 0;
    REP(i, N-1){
        if(str[i] == 'A' && str[i+1] == 'C')
            ac[i+2] = ac[i+1] + 1;
        else
            ac[i+2] = ac[i+1];
    }
    REP(i, Q)
        cout << ac[r[i]] - ac[l[i]] << endl;
    return 0;
}



Measured memory_bytes: 2176
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        mut s: chars
    }
    if s[1] == 'B' {
        s[1] = 'R';
    } else {
        s[1] = 'B';
    }
    println!("{}", s.iter().collect::<String>());
}


Measured memory_bytes: 2048
n, k = map(int, input().split())

sunukes = [0 for i in range(n)]

for i in range(k):
    d = int(input())
    aa = list(map(int, input().split()))

    for j in range(d):
        sunukes[aa[j] - 1] += 1

count = sum(1 for sunuke in sunukes if sunuke == 0)

print(count)


Measured memory_bytes: 9092
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int n,a[105],ans=0,sum=0;
int main()
{
	ans=1000000000;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	for(int i=-100;i<=100;i++)
	{
		sum=0;
		for(int j=1;j<=n;j++)sum+=(a[j]-i)*(a[j]-i);
		ans=min(ans,sum);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1736
#include <stdio.h>
int main (void){
    long long int N, A, B, counter = 0;
    scanf("%lld %lld %lld",&N,&A,&B);
    char s[N+1];
    scanf("%s",s);
    long long int pass = 0;
    for(long long int i = 0; i < N; i++){
        if(s[i] == 'a' && pass < A+B){
            pass++;
            printf("Yes\n");
        } else if(s[i] == 'b' && pass < A+B && ++counter <= B){
            pass++;
            printf("Yes\n");
        } else {
            printf("No\n");
        }
    }
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)
#define bg begin()
#define ed end()
#define all(x) x.bg, x.ed
#define vi vector<int>
template <class t, class u>
bool chmax(t &a, u b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class t, class u>
bool chmin(t &a, u b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}

signed main()
{
    int n, m;
    cin >> n >> m;
    if (n >= m)
    {
        cout << 0 << endl;
        return 0;
    }
    vector<int> x(m);
    rep(i, m)
    {
        cin >> x[i];
    }
    sort(all(x));
    vector<int> diff;
    rep(i, m - 1)
    {
        diff.push_back(-x[i + 1] + x[i]);
    }
    sort(all(diff));
    int sum = 0;
    rep(i, n - 1)
    {
        sum -= diff[i];
    }
    cout << x[m - 1] - x[0] - sum << endl;

    return 0;
}

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

using namespace std;

int main(int argc, char* argv[])
{
    int x, y; cin >> x >> y; x--; y--;

    vector<int> u = {1, 2, 1, 4, 1, 4, 1, 1, 4, 1, 4, 1};

    cout << ((u[x] == u[y]) ? "Yes" : "No") << endl;
    return 0;
}


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

int a, b;

void Main() {
  cin >> a >> b;

  if (a > 9 || b > 9) {
    cout << -1 << endl;
  } else {
    cout << a * b << endl;
  }
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<string>
#include<sstream>
#include<iomanip>
#include<utility>
#include<cmath>
#include<set>
#include<list>
#include<queue>
#include<stack>
#include<map>
#include<set>
using namespace std;
typedef long long int ll;
const int MAX=100000;

vector<int> G[MAX];
list<int> out;
bool V[MAX];
int n;

void dfs(int u)
{
	V[u]=true;
	for(int i=0;i<G[u].size();i++)
	{
		if(!V[G[u][i]])dfs(G[u][i]);
	}
	out.push_front(u);
	return;
}

void topologicalsort()
{
	for(int i=0;i<n;i++)V[i]=false;
	for(int i=0;i<n;i++)if(!V[i])dfs(i);
	for(auto it:out)cout<<it<<endl;
	return;
}

int main()
{
	int m;cin>>n>>m;
	int s,t;
	for(int i=0;i<m;i++)
	{
		cin>>s>>t;
		G[s].push_back(t);
	}
	topologicalsort();
	return 0;
}

Measured memory_bytes: 6068
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;

int main()
{
    int N, A;
    cin >> N >> A;
    cout << N * N - A << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include<iostream>

using namespace std;

int main()
{
    int n;
    int ans = 0;

    cin >> n;


    for (int i = 1; i <= n; i++) {

        int t = (n + i - 1) / i;

        ans += t - 1;

    }


    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 3672
#include<stdio.h>

#define MAX 1024

int main(void)
{
  
  char moji;
  char count[MAX + 1];
  char output[MAX + 1][76];
  
  int i = 0;
  int j = 0;
  int testcase;
  int test = 0;  
  
  scanf("%d",&testcase);
  
  while(test < testcase){

    scanf("%s",count);
    
    while(count[i] != '\0'){
      switch(count[i]){
      case '1': if((moji != '.' && moji != ',' && moji != '!' && moji != '?') || moji == ' ')
	  moji = '.';
	else if(moji == '.')
	  moji = ',';
	else if(moji == ',')
	  moji = '!';
	else if(moji == '!')
	  moji = '?';
	else if(moji == '?')
	  moji = ' ';
	break;
	
      case '2': if((moji != 'a' && moji != 'b') || moji == 'c')
	  moji = 'a';
	else if(moji == 'a')
	  moji = 'b';
	else if(moji == 'b')
	  moji = 'c';
	break;
	
      case '3': if((moji != 'd' && moji != 'e') || moji == 'f')
	  moji = 'd';
	else if(moji == 'd')
	  moji = 'e';
	else if(moji == 'e')
	  moji = 'f';
	break;
	
      case '4': if((moji != 'g' && moji != 'h') || moji == 'i')
	  moji = 'g';
	else if(moji == 'g')
	  moji = 'h';
	else if(moji == 'h')
	  moji = 'i';
	break;
	
      case '5': if((moji != 'j' && moji != 'k') || moji == 'l')
	  moji = 'j';
	else if(moji == 'j')
	  moji = 'k';
	else if(moji == 'k')
	  moji = 'l';
	break;
	
      case '6': if((moji != 'm' && moji != 'n') || moji == 'o')
	  moji = 'm';
	else if(moji == 'm')
	  moji = 'n';
	else if(moji == 'n')
	  moji = 'o';
	break;
	
      case '7': if((moji != 'p' && moji != 'q' && moji != 'r') || moji == 's')
	  moji = 'p';
	else if(moji == 'p')
	  moji = 'q';
	else if(moji == 'q')
	  moji = 'r';
	else if(moji == 'r')
	  moji = 's';
	break;
	
      case '8': if((moji != 't' && moji != 'u') || moji == 'v')
	  moji = 't';
	else if(moji == 't')
	  moji = 'u';
	else if(moji == 'u')
	  moji = 'v';
	break;
	
      case '9': if((moji != 'w' && moji != 'x' && moji != 'y') || moji == 'z')
	  moji = 'w';
	else if(moji == 'w')
	  moji = 'x';
	else if(moji == 'x')
	  moji = 'y';
	else if(moji == 'y')
	  moji = 'z';
	break;
	
      case '0': if(moji!='\0'){
	  output[test][j] = moji;
	  j ++ ;
	  moji = '\0';
	}
	break;

      default : break;
	
      }
      i++;
      
    }
    
    for(i=0;count[i]!='\0';i++)
      count[i] = '\0';
    
    output[test][j] = '\0';

    test++;
    i = 0;
    j = 0;
    
  }

  for(i=0;i<testcase;i++){
    for(j=0;output[i][j]!='\0';j++)
    printf("%c",output[i][j]);

    printf("\n");
  }
  return 0;
  
}

Measured memory_bytes: 584
#![allow(non_snake_case)]
#![allow(unused_imports)]
#![allow(unused_variables)]
#![allow(dead_code)]

use std::collections::BinaryHeap;
use std::io::Read;

const U32_LARGE: u32 = 1 << 30;

fn read<T: std::str::FromStr>() -> T {
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let m: u32 = read();
    let a: Vec<u64> = (0..n).map(|_| read()).collect();

    let mut heap = BinaryHeap::new();
    for &v in a.iter() {
        heap.push(v);
    }

    for _ in 0..m {
        let v = heap.pop().unwrap();
        heap.push(v / 2);
    }

    let res = heap.iter().sum::<u64>();

    println!("{}", res);
}


Measured memory_bytes: 6396
/***********************************************************
	When you are inspired by passion 
	and you want to live for the current moment

	When your every thought and action
	has the power to become the story of your future

	When difficulties stand to demolish your Glory
	Just remember that Life is a 'Golden adverse Story'

	Withstand it to acheive your passion and dreams
	more amazingly more easily.

	Why then? When writing the story of your Life
	You want to Let someone else hold your pen

					huzaifa242©

***********************************************************/
#include "bits/stdc++.h"
using namespace std;
#define int int32_t
#define MAX 100005
#define x first 
#define y second

int seed;
mt19937 rng(seed=chrono::steady_clock::now().time_since_epoch().count());
inline int rnd(int l = 0, int r = numeric_limits <int>::max())
{return uniform_int_distribution<int> (l, r)(rng);}

template <typename T, typename G>
ostream& operator << (ostream& out, const pair <T, G> &a) 
{return out << "( " << a.x << ", " << a.y << ")";}

template <typename T>
ostream& operator << (ostream& out, const vector <T> &a) 
{out << "[ "; for(const auto &i: a) out << i << ", "; return out << "]" << endl;}

template <typename T>
ostream& operator << (ostream& out, const set <T> &a) 
{out << "{ "; for(const auto &i: a) out << i << ", "; return out << "}" << endl;}

template <typename T, typename G>
ostream& operator << (ostream& out, const map <T, G> &a) 
{out << "< "; for(const auto &i: a) out << i << ", "; return out << ">" << endl;}

template <typename T, size_t N>
typename enable_if<!is_same <typename remove_cv <T>::type, char>::value,
ostream&>::type operator << (ostream& out, T (&a)[N])
{out << "[ "; for(const auto &i: a) out << i << ", "; return out << "]" << endl;}

void debug_out(){cerr << endl;} 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{cerr << (H) << ' '; debug_out(T...);}
 
#ifdef LOCAL
#define debug(...) cerr << '#' << #__VA_ARGS__ << ":\n", debug_out(__VA_ARGS__)
#else
#define debug(...) 24
#endif

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	vector <int> rate = {600, 800, 1000, 1200, 1400, 1600, 1800, 2000};
	reverse(rate.begin(), rate.end());
	int n, ans = 9;
	cin >> n;
	for (int i = 0; i < rate.size(); ++i) {
		if (rate[i] > n) 
			ans = i + 1;
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 3644
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc099b
{
    class Program
    {
        static void Main(string[] args)
        {
            var buf = Console.ReadLine().Split();
            var a = int.Parse(buf[0]);
            var b = int.Parse(buf[1]);
            var dif = b - a;
            var n = dif - 1;
            var height_a = n * (2 * 1 + (n - 1)) / 2;
            var snowStack = height_a-a;
            Console.WriteLine(snowStack);
        }
    }
}


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

using namespace std;

int n,a,b,c,d;
char s[300000];

void movea(){
	if (s[a+1]=='.'){++a; return;}
	if (s[a+2]=='.'){a+=2; return;}
	puts("No"); exit(0);
}

int main(){
	scanf("%d%d%d%d%d",&n,&a,&b,&c,&d);
	scanf("%s",s+1);
	if (c>d){swap(c,d); swap(a,b);}
	while (b<d){
		if (b+1!=a&&s[b+1]=='.'){++b; continue;}
		if (b+1==d){
			movea();
			++b; continue;
		}
		if (b+2!=a&&s[b+2]=='.'){b+=2; continue;}
		movea();
	}
	if (a>c){puts("No"); return 0;}
	while (a<c){
		movea();
	}
	if (a!=c){puts("No"); return 0;}
	puts("Yes");
	
	return 0;
}
			

Measured memory_bytes: 384
class Ant
	def initialize(*args)
		@index, @dx, @x = args
	end
	attr_accessor :index, :dx, :x, :time
end

loop {
	n, l = gets.split.map &:to_i
	break if n == 0
	ants = (1..n).map {|i|
		dir, x = gets.chomp.split 
		Ant.new(i, {?R=>1, ?L=>-1}[dir], x.to_i)
	}

	events = []
	ants.combination(2){|a1, a2|
		next if a1.dx == a2.dx
		next if (a1.x + a2.x).odd?
		if a1.dx == 1
			next if a1.x > a2.x
			events << [a1.index, a2.index, (a2.x - a1.x) / 2]
		else
			next if a1.x < a2.x
			events << [a1.index, a2.index, (a1.x - a2.x) / 2]
		end
	}
	ants.each{|a|
		a.time = (a.dx > 0 ? l - a.x : a.x)
	}

	events.sort_by!(&:last)
	
	events.each{|i, j, _|
		a1 = ants[i-1]
		a2 = ants[j-1]
		a1.index, a2.index = a2.index, a1.index
	}

	max_t = ants.map(&:time).max
	last = ants.select{|a| a.time == max_t}
	if last.size == 1
		last = last[0].index
	else
		last = last.find{|a| a.dx == -1}.index
	end
	puts "#{max_t} #{last}"
}

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

int main(){
  string s,a;
  cin>>s>>a;
  vector<string> ans;
  for(int i=0;i<s.size()-a.size()+1;i++){
    for(int j=0;j<a.size();j++){
      if(s.at(i+j)=='?'||a.at(j)==s.at(i+j)){
        if(j==a.size()-1){
          string b=s.substr(0,i) + a +s.substr(i+j+1);
          ans.push_back(b);
        }
      }else break;
    }
  }if(ans.empty()){
    cout<<"UNRESTORABLE"<<endl;
    return 0;
  }else{
    int n=ans.size()-1;
    for(int i=0;i<s.size();i++){
      if(ans[n].at(i)=='?') cout<<'a';
      else cout<<ans[n].at(i);
    }
    cout<<endl;
    return 0;
  }
}

Measured memory_bytes: 256
#include <bitset>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <stdio.h>
#include <math.h>

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<ll> vll;

typedef pair<int, int> pii;

typedef queue<int> qi;
typedef queue<string> qs;


#define rep(i, n) for(int i=0; i<(n); ++i)
#define repp(i, a, b) for(int i = (a); i <= (b); i++)
#define repm(i, a, b) for(int i = (a); i >= (b); i--)

#define all(v) v.begin(), v.end()
//sort( all(v) )　などと使える

int main(){
    ll x; cin >> x;

    ll chokin = 100;
    ll ans = 0;
    while(chokin < x){
        chokin *= 1.01;
        ans++;
    }

    cout << ans  << endl;
}

Measured memory_bytes: 3620
n, m = map(int, input().split())
sc = []
for i in range(m):
    sc.append(list(map(int, input().split())))

if n == 1:
    x = 0
elif n == 2:
    x = 10
else:
    x = 100

for i in range(x,1000):
    flag = True
    i_str = str(i)
    for j in range(m):
        a = int(i_str[sc[j][0] - 1])
        b = sc[j][1]
        if a != b:
            flag = False
    if flag:
        print(i)
        exit()
print("-1")


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define MAXN 200005
#define trace(x) cout<<#x<<" = "<<x<<'\n'
#define trace2(x, y) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<'\n'
#define trace3(x, y, z) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<" "<<#z<<" = "<<z<<'\n'
#define sz(x) (int)(x).size()
using namespace std;
struct ii {
	int a, b;
	bool operator < (ii o) const { return tie(a, b) < tie(o.a, o.b); }
};
struct iii {
	int a, b, c;
	bool operator < (iii o) const { return tie(a, b, c) < tie(o.a, o.b, o.c); }
};
long long TC, N, M, K, Q, x, y, z;

long long arr[MAXN], ans;

int main() {
	#ifdef FAIRUZI10
	freopen("/home/fairuzi/Documents/CP/input.in", "r", stdin);
	#endif
	
	scanf("%lld%lld", &N, &K);
	for (int i = 0; i < N; i++) {
		scanf("%lld", &arr[i]);
	}
	long long dari = 0;
	long long sampai = 0;
	ans = 0;
	for (int i = 0; i < N; i++) {
		if (arr[i] <= sampai) {
			sampai = arr[i]+K;
		} else {
			ans += sampai-dari;
			dari = arr[i];
			sampai = arr[i]+K;
		}
	}
	ans += sampai-dari;
	printf("%lld\n", ans);
	
	return 0;
}



Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD (int) 1e9+7
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define vi vector<int>
int main()
{

#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif
	fio;
	int k;
	cin >> k;
	int a, b;
	cin >> a >> b;
	for (int i = a; i <= b; i++)
	{
		if (i % k == 0)
		{
			cout << "OK" << endl;
			return 0;
		}
	}
	cout << "NG";
	return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <iomanip>
using namespace std;

#define pi 3.141592653589


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

	for (int i = 1; i <= n; i++)
	{
		int x = i;
		if (x % 3 == 0)
		{
			cout << " " << i;
		}
		else
		{
			while (x)
			{
				if (x % 10 == 3)
				{
					cout << " " << i;
					break;
				}
				x /= 10;
			}
		}
	}
	cout << endl;
	return 0;
}

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

typedef long long int ll;

int main(){
    ll n,r=0,b=0,g=0,tc=0,c=0;
    string s;
    cin >> n;
    cin >> s;

    for (int i = 0; i < n; ++i){
        if(s[i] == 'R') r++;
        if(s[i] == 'G') g++;
        if(s[i] == 'B') b++;
    }
    tc = r*b*g;
    for (int i = 0; i < n; ++i){
        for (int j = i+1; j < n; ++j){
            if(j+(j-i) < n && j > i ){
                if (s[i] != s[j] && s[i] != s[j+(j-i)] && s[j] != s[j+(j-i)])
                    c++;
            }
        }
    }
    cout << tc-c << endl;
    return 0;
}


Measured memory_bytes: 3584
import sys

nums = [int(num) for num in input().split(" ")]

if nums[0] == nums[1]:
    print(nums[0])
    exit()
elif nums[0] > nums[1]:
    big_num = nums[0]
    small_num = nums[1]
else:
    big_num = nums[1]
    small_num = nums[0]

while (big_num % small_num) != 0:
    tmp = big_num
    big_num = small_num
    small_num = tmp % small_num

print(small_num)


Measured memory_bytes: 5608
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long int ll;
int main(){
	int N, M;
	bool memo[100000];
	int num[100000];
	cin >> N >> M;
	fill(memo, memo + N, false);
	fill(num, num + N, 1);
	memo[0] = true;
	for(int i = 1; i <= M; i++){
		int x, y;
		cin >> x >> y;
		x--; y--;
		if(memo[x] == true) memo[y] = true;
		if(num[x] == 1) memo[x] = false;
		num[x]--; num[y]++;
	}
	int ans = 0;
	for(int i = 0; i < N; i++){
		if(memo[i] == true) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 768
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<deque>
#include<queue>
using namespace std;

using ll = long long;
const int INF = 1001001001;
const ll LLINF = 1001001001001001001;
const int MOD = 1000000007;

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

int main()
{
  ll n, m, k;
  cin >> n >> m >> k;
  vector<ll> a(n+1, 0);
  vector<ll> b(m+1, 0);

  for (ll i = 1; i <= n; i++) {
    ll tmp;
    cin >> tmp;
    a[i] = tmp + a[i-1];
  }

  for (ll i = 1; i <= m; i++) {
    ll tmp;
    cin >> tmp;
    b[i] = tmp + b[i-1];
  }

  ll res = 0;
  for (ll i = 0; i <= n; i++) {
    ll tmp = a[i];
    ll nokori = k - tmp;
    if (nokori < 0) break;
    if (nokori == 0) {
      res = max(res, i);
      continue;
    }

    auto it = lower_bound(b.begin(), b.end(), nokori);
    ll index;
    if (*it == nokori) {
      index = distance(b.begin(), it);
    } else {
      index = distance(b.begin(), --it);
    }

    res = max(res, index + i);
  }

  cout << res << endl;
}


Measured memory_bytes: 6420
n = gets.to_i
ans = Array.new(10**4 + 1, 0)

## x <= y <= zとする。

max_x = Math.sqrt(n/6).to_i
max_y = Math.sqrt(n/3).to_i
max_z = Math.sqrt(n).to_i


(1..max_x).each do |x|
  (x..max_y).each do |y|
    (y..max_z).each do |z|
      result = x**2 + y**2 + z**2 + x*y + y*z + z*x
	  break if result > n
      if x != y && y != z
	      plus_cnt = 6
      elsif x != z && (x == y || y == z) 
          plus_cnt = 3
      else x == z
          plus_cnt = 1
      end
	      ans[result] += plus_cnt if result <= n
    end
  end
end

(1..n).each do |i|
  puts ans[i]
end


Measured memory_bytes: 14224
#include<stdio.h>
#define N 8
#define FREE -1
#define NOT_FREE 1
 
int row[N],col[N],dpos[2*N-1],dneg[2*N-1];
 
int x[N][N];
void initialize(void);
void printBoard(void);
void recursive(int);
 
int main(){
  int i,j;
   
  initialize();
 
  for( i = 0 ; i < N ; i++ ){
    for(j = 0 ; j < N ; j++ ){
      x[i][j] = 0;
 
    }
  }
 
  int k;
  int r,c;
   
  scanf("%d",&k);
 
  for( i = 0 ; i < k ; i++ ){
    scanf("%d%d",&r,&c);
    x[r][c] = 1;
  }
 
  recursive(0);
 
  return 0;
}
 
void initialize(){
  int i,j;
  for( i = 0 ; i < N ; i++ ) {
    row[i] = FREE;
    col[i] = FREE;
  }
 
  for( i = 0 ; i < 2*N-1 ; i++ ){
    dpos[i] = FREE;
    dneg[i] = FREE;
  }
 
}
 
 
void printBoard(){
  int i,j;
   
  for( i = 0 ; i < N ; i++ ){
    for( j = 0 ; j < N ; j++ ){
      if(x[i][j]){
    if(row[i] != j) return;
      }
    }
  }
 
  for( i = 0 ; i < N ; i++ ){
    for( j = 0 ; j < N ; j++ ){
      if(row[i] == j ) printf("Q");
      else printf(".");
    }
    printf("\n");
  }
}
 
void recursive(int i){
  if( i == N ){
    printBoard();
    return;
  }
 
  int j;
 
  for( j = 0 ; j < N ; j++ ){
    if( NOT_FREE == col[j] || NOT_FREE == dpos[i+j] || NOT_FREE == dneg[i-j+N-1]) continue;
 
    row[i] = j;
    col[j] = dpos[i+j] = dneg[i-j+N-1] = NOT_FREE;
 
    recursive(i+1);
 
    row[i] = col[j] = dpos[i+j] = dneg[i-j+N-1] = FREE;
  }
}

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

  int i,n,in,min,max;
  long sum;

  min = 1000000;
  max = -1000000;
  sum = 0;

  scanf("%d", &n);

  for ( i = 0; i < n; i++){

    scanf("%d", &in);

    if ( min > in ) min = in;
    if ( max < in ) max = in;
    sum = sum + in;

  }

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

  return 0;

}

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

using namespace std;

#define FOR(i,s,e) for(int (i)=(s);(i)<(int)(e);(i)++)
#define REP(i,e) FOR(i,0,e)

#define all(o) (o).begin(), (o).end()
#define psb(x) push_back(x)
#define UNIQUE(o) (o).erase(unique(sort(all((o)))))

typedef long long ll;
typedef pair<int, int> PII;

const int H = 30;
const int W = 30;
int h, w;
int ph[H][W], pv[H][W], usd[H][W];

int main() {
  while(scanf("%d%d ", &w, &h), w) {
    REP(i,h*2-1) {
      if (i&1) {
        REP(j,w) scanf("%d ", &(pv[i/2][j]));
      } else {
        REP(j,w-1) scanf("%d ", &(ph[i/2][j]));
      }
    }
    memset(usd, 0, sizeof(usd));
    queue<PII> q;
    q.push(make_pair(0, 0));
    usd[0][0] = 1;
    while (q.size()) {
      int i = q.front().first;
      int j = q.front().second;
      q.pop();

      if (j+1<w && !ph[i][j] && !usd[i][j+1]) {
        usd[i][j+1] = usd[i][j] + 1;
        q.push(make_pair(i,j+1));
      }
      if (j-1>=0 && !ph[i][j-1] && !usd[i][j-1]) {
        usd[i][j-1] = usd[i][j] + 1;
        q.push(make_pair(i,j-1));
      }
      if (i+1<h && !pv[i][j] && !usd[i+1][j]) {
        usd[i+1][j] = usd[i][j] + 1;
        q.push(make_pair(i+1,j));
      }
      if (i-1>=0 && !pv[i-1][j] && !usd[i-1][j]) {
        usd[i-1][j] = usd[i][j] + 1;
        q.push(make_pair(i-1,j));
      }
    }
    printf("%d\n", usd[h-1][w-1]);
  }
  return 0;
}


Measured memory_bytes: 3224
#include<stdio.h>
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n,M[N][N];
int color[N],d[N],f[N],tt = 0;

void dfs_visit(int u){
  int v;
  color[u] = GRAY;
  d[u] = ++tt;
  for(v = 0 ; v < n ; v++){
    if(M[u][v] == 0)continue;
    if(color[v] == WHITE){
      dfs_visit(v);
    }
  }
  color[u] = BLACK;
  f[u] = ++tt;
}

void dfs(){
  int u;
  for(u = 0 ; u < n ; u++){
    color[u] = WHITE;
  }
  tt = 0;
  for(u = 0 ; u < n ; u++){
    if(color[u] == WHITE)dfs_visit(u);
  }
  for(u = 0 ; u < n ; u++){
    printf("%d %d %d\n",u + 1,d[u],f[u]);
  }
}

int main(){
  int u,v,k,i,j;

  scanf("%d",&n);
  for(i = 0 ; i < n ; i++){
    for(j = 0 ; j < n ; j++){
      M[i][j] = 0;
    }
  }

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

  return 0;
}



Measured memory_bytes: 2112
n = int(input())
cn= 1
an= [1]
i = 1

while cn < n / 4: 
    an.append(cn*3+1)
    cn=cn*3+1
an.sort(reverse=True)

def insertionSort(a,n,g):
    cnt=0
    for i in range(g,n):
        v = a[i]
        j = i - g
        while j>= 0 and a[j]>v:
            a[j + g]= a[j]
            j = j-g
            cnt+=1
        a[j + g]=v
    return cnt

def shellSort(a,n,an):
    cnt=0
    m = len(an)
    g = an
    for i in an:
        cnt += insertionSort(a,n,i)
    return cnt


x=[]
for i in range(n):
    x.append(int(input()))

print(len(an))
print(" ".join([str(i) for i in an]))
y= shellSort(x,n,an)
print(y)

for i in range(n):
    print(x[i])

Measured memory_bytes: 47512
#-*-coding:utf-8-*-

def main():
    H, W = list(map(int, input().split()))
    grid = [[0 for i in range(W+2)] for j in range(H+2)]

    for i in range(H):
        s = input()
        for j in range(W):
            grid[i+1][j+1] = s[j]
    
    for i in range(1, H+1):
        for j in range(2, W+1):
            if grid[i][j-1] == '.' and grid[i][j] == '#' and grid[i][j+1] == '.' and grid[i-1][j] == '.' and grid[i+1][j] == '.':
                print('No')
                exit()
   
    print('Yes')

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
N = int(input())
A = list()
E = list()
for i in range(N):
    A.append(int(input()))
    evid = list()
    for j in range(A[-1]):
        target, label = input().split()
        evid.append([int(target) - 1, int(label)])
    E.append(evid)

max_honesty = 0
for i in range(2**N):
    state = [(i >> j) & 1 for j in range(N)]
    is_contrad = False
    for j in range(N):
        if state[j] == 1:
            evids = E[j]
            for e in  evids:
                target, label = e
                if label != state[target]:
                    is_contrad = True
                    break
        if is_contrad:
            break
    if not is_contrad and max_honesty < sum(state):
        max_honesty = sum(state)

print(max_honesty)


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <array>
#include <cmath>
#include <climits>
#include <cstdint>
using namespace std;

inline namespace atcoder {
    template <typename T, size_t Depth>
    struct vector_helper { using type = vector<typename vector_helper<T, Depth - 1>::type>; };
    template <typename T>
    struct vector_helper<T, 0> { using type = T; };
    template <typename T, size_t Depth>
    using vector_t = typename vector_helper<T, Depth>::type;

    template <typename T> using vec = vector_t<T, 1>;
    template <typename T> using vvec = vector_t<T, 2>;
    template <typename T> using vvvec = vector_t<T, 3>;
}

double solver(vec<int> &visited, vec<array<int, 2>> &coord, int depth = 0) {
    double sum = 0;

    if (depth == visited.size()) {
        for (int i = 1; i < visited.size(); ++i) {
            int p1 = visited[i - 1], p2 = visited[i];
            sum += sqrt(pow(coord[p1][0] - coord[p2][0], 2) + pow(coord[p1][1] - coord[p2][1], 2));
        }
        return sum;
    }

    for (int i = 0; i < visited.size(); ++i) {
        if (visited[i] != -1) continue;
        visited[i] = depth;
        sum += solver(visited, coord, depth + 1);
        visited[i] = -1;
    }
    return sum;
}

int main() {
    cout << fixed;

    int n; cin >> n;
    vec<array<int, 2>> coord(n);
    for (auto &e : coord) cin >> e[0] >> e[1];

    int fact = 1;
    for (int i = 2; i <= n; ++i) fact *= i;

    vec<int> visited(n, -1);
    cout << solver(visited, coord) / fact << endl;
}



Measured memory_bytes: 3848