akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
typedef long long ll;

vector<int> S;

bool binarysearch(int key){
	int left = 0;
	int right = S.size()-1;
	while(right - left >= 1){
		int mid = left+(right-left)/2;
		if(S[mid] == key) return true;
		else if (S[mid] > key) right = mid -1;
		else if (S[mid] < key) left = mid + 1;
	}
	return false;
}



int main(){
	int n;
	cin >> n;
	S.resize(n);
	rep(i,n){
		cin >> S[i];
	}
	sort(S.begin(),S.end());
	
	int q;
	cin >> q;
	int ans = 0;
	vector<int> T(q);
	rep(i,q){
		cin >> T[i];
		if(binary_search(S.begin(),S.end(), T[i])) ans++;
	}
	
	cout << ans << endl;
    return 0;
}




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

#define ll long long
#define pb push_back
int n,m,k,dp[100009][3];
struct arr{
int swim,bugs,homework;
};
arr vc[100009];

int DP(int  ind,int prev)
{
    if(ind>n)return 0;
    if(~dp[ind][prev])return dp[ind][prev];
    if(prev==0)return dp[ind][prev]=max(vc[ind].bugs+DP(ind+1,1),vc[ind].homework+DP(ind+1,2));
    if(prev==1)return dp[ind][prev]= max(vc[ind].swim+DP(ind+1,0),vc[ind].homework+DP(ind+1,2));
    return dp[ind][prev]= max(vc[ind].bugs+DP(ind+1,1),vc[ind].swim+DP(ind+1,0));
}

int main()
{
    ios_base::sync_with_stdio(false);  cin.tie(NULL);
    cin>>n;
    memset(dp,-1,sizeof dp);
    for(int i=1;i<=n;i++)cin>>vc[i].swim>>vc[i].bugs>>vc[i].homework;
    cout<<max(DP(2,0)+vc[1].swim,max(DP(2,1)+vc[1].bugs,DP(2,2)+vc[1].homework))<<"\n";
    return 0;
}




Measured memory_bytes: 7296
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, a, b) for(int i = a, i##_len = (b); i < i##_len; ++i)

int main()
{
    int c5 = 0,c7 = 0;
    REP(i, 0, 3) {
        int a;
        scanf("%d", &a);
        if(a == 5)++c5;
        if(a == 7)++c7;
    }
    if(c5 == 2 && c7 == 1) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int MOD = 1000000007;
const int INF = 1e9;

const int mod = 1000000007;
const int inf = 1e9;
#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};

map<ll, int> prime_factor(ll n){
	map<ll, int> res;
	for(ll i = 2; i*i<=n; i++){
		while(n%i==0){
			res[i]++;
			n/=i;
		}
	}
	if(n!=1) res[n]++;
	return res;
}

int main(){
    ll n;
    cin >> n;
    auto mp = prime_factor(n);
    int ans = 0;
    for(auto a : mp) {
        int now = a.second;
        int n = 1;
        while( ((n+2)*(n+1))/2 <= a.second) 
            n++;
        ans += n;
    }
    cout << ans <<endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main(){
    char s;
    int n,high=0,max=0,i;
    cin>>n;
    for(i=0;i<n;i++)
    {
    	cin>>s;
    	if(s=='I')high++;
    	else high--;
    	if(high>max) max=high;
    }
    cout<<max<<endl;
    return 0;
}

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

const int MAXN = 200010;
int u, v, n, m, flag, cnt;
int ans[MAXN], head[MAXN];

struct edge {
    int v, next;
} e[MAXN << 1];

void add(int u, int v) {
    e[++cnt].v = v;
    e[cnt].next = head[u];
    head[u] = cnt;
}

void bfs() {
    queue<int> q;
    q.push(1);
    while (!q.empty()) {
        int u = q.front();
        q.pop();
        for (int i = head[u]; i; i = e[i].next) {
            int v = e[i].v;
            if (ans[v]) continue;
            ans[v] = u;
            q.push(v);
        }
    }
}

int main() {
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= m; ++i) {
        scanf("%d%d", &u, &v);
        add(u, v);
        add(v, u);
    }
    bfs();
    for (int i = 2; i <= n; ++i) {
        if (!ans[i]) {
            printf("No");
            return 0;
        }
    }
    printf("Yes\n");
    for (int i = 2; i <= n; ++i) {
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 7672
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9

using vd=vector<double>;
using vvd=vector<vd>;


int main(){
    int h,w;
    cin>>h>>w;
    vvi f(h+2,vi(w+2,1));
    vvi walk(h+2,vi(w+2,0));
    int gy,gx,y=0,x=0,v=0;
    range(i,1,h+1)range(j,1,w+1){
        char c;
        cin>>c;
        switch(c){
            case 'G': gy=i,gx=j,f[i][j]=0; break;
            case '.': f[i][j]=0;break;
            case '#': break;
            case '^': y=i,x=j,v=0,f[i][j]=0; break;
            case '>': y=i,x=j,v=1,f[i][j]=0; break;
            case 'v': y=i,x=j,v=2,f[i][j]=0; break;
            case '<': y=i,x=j,v=3,f[i][j]=0; break;
        }
    }
    walk[y][x]=1;
    rep(loop,1000000){
        vvi vec={{-1,0},{0,1},{1,0},{0,-1}};
        if(f[y+vec[(v+1)%4][0]][x+vec[(v+1)%4][1]]==0){ //右手が道なら右に曲がって前に進む
            //cout<<"hoge";
            v=(v+1)%4;
            y+=vec[v][0], x+=vec[v][1];
            walk[y][x]=1;
        }else if(f[y+vec[v][0]][x+vec[v][1]]==1){ //（右が壁で、）正面が壁なら左に回る
            //cout<<"fuga";
            v=(v+3)%4;
        }else{ //そうでないならまえに進む
            //cout<<"zako";
            y+=vec[v][0],x+=vec[v][1];
            walk[y][x]=1;
        }
        if(y==gy&&x==gx){
            break;
        }
        // cout<<y<<","<<x<<","<<v<<endl;
        // rep(i,h+2){
        //     rep(j,w+2){
        //         if(i==y&&j==x){
        //             cout<<"^>v<"[v];
        //         }else{
        //             cout<<".#"[f[i][j]];
        //         }
        //     }
        //     cout<<endl;
        // }
    }
    if(y==gy&&x==gx){
        int ans=0;
        rep(i,h+2)rep(j,w+2)ans+=walk[i][j];
        cout<<ans<<endl;
    }else cout<<-1<<endl;
	return 0;
}



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


using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)
#define repb(i, ed, st) for(int i=ed; i>=st; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 1010;
const ll INF = 1LL << 60;

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



// Main Code



int main()
{
	string s, t;
	int n;
	cin>>n;
	cin>>s>>t;
	rep(i ,0, s.length())
	{
		cout<<s[i]<<t[i];
	}
	cout<<endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
long long arr[55];
int main()
{
	int n;
	scanf("%d",&n);
	for (int i=0;i<n;i++)
	scanf("%lld",&arr[i]);
	long long ans=0;
	while (1)
	{
		long long tmp=0;
		for (int i=0;i<n;i++)
		tmp+=arr[i]/n;
		if (!tmp)
		{
			printf("%lld",ans);
			return 0;
		}
		ans+=tmp;
		for (int i=0;i<n;i++)
		arr[i]+=tmp-(arr[i]/n)*(n+1);
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ll mod2 = 998244353;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; ll k; cin >> n >> k;
  vector<ll> A(n), F(n);
  rep(i, n) cin >> A[i];
  rep(i, n) cin >> F[i];
  sort(all(A));
  sort(all(F), greater<ll>());
  auto bsearch = [&]() {
    auto test = [&](ll t) {
      ll need = 0;
      rep(i, n) need += max(0LL, A[i]-t/F[i]);
      return need <= k;
    };
    ll ok = longinf, ng = -1;
    while(ok-ng > 1) {
      ll mid = (ok+ng)/2;
      (test(mid) ? ok : ng) = mid;
    }
    return ok;
  };
  cout << bsearch() << endk;
  return 0;
}


Measured memory_bytes: 6368
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll zero = 0;
const ll INF = 10000000000000000; //10^16
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;

bool che(ll a){
    string s = to_string(a);
    bool x,y,z;
    x = false; y = false; z = false;
    int l = s.size();
    for(int i = 0; i < l; i++){
        if(s.at(i) == '3') x=true;
        if(s.at(i) == '5') y=true;
        if(s.at(i) == '7') z=true;
    }
    return x & y & z;
}

int main(void){
    ll N;
    cin >> N;
    
    queue<ll> anstmp;
    queue<ll> ans;
    anstmp.push(3); anstmp.push(5); anstmp.push(7);
    ans.push(3); ans.push(5); ans.push(7);
    ll tmp;
    bool check = true;
    while(check){
        tmp = anstmp.front();
        anstmp.pop();
        ans.push(tmp * 10 + 3);
        ans.push(tmp * 10 + 5);
        ans.push(tmp * 10 + 7);
        anstmp.push(tmp * 10 + 3);
        anstmp.push(tmp * 10 + 5);
        anstmp.push(tmp * 10 + 7);
        if(tmp >= MOD) check = false;
    }
    
    int res = 0;
    while(!ans.empty()){
        tmp = ans.front();
        if(che(tmp)){
            if(tmp <= N){
                res++;
            }
        } 
        ans.pop();
    }
    printf("%d\n",res);
}




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

void fast(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
}

int main(){
	fast();
	ll n;
	cin>>n;
	ll a[n];
	for(ll i=0;i<n;i++)cin>>a[i];
	sort(a,a+n);
	double ans=a[0];
	for(ll i=1;i<n;i++){
		ans=(double)(ans+a[i])/2;
	}
	cout<<fixed<<setprecision(10)<<ans;
}

Measured memory_bytes: 256
#include <vector>
#include <stack>
#include <cstddef>
#include <algorithm>

struct strongly_connected_component {
	using size_type = std::size_t;
private :
	size_type num;
	std::vector<std::vector<size_type>> g, scc;
	std::vector<size_type> low, order, index;
	std::vector<bool> instack;
	std::stack<size_type> sta;

	void chmin (size_type &a, const size_type &b) noexcept {
		if (a > b) a = b;
	}

	void dfs (size_type v) noexcept {
		low[v] = order[v] = ++num;
		sta.push(v); instack[v] = true;
		for (const size_type &u : g[v]) {
			if (order[u] == 0) {
				dfs(u);
				chmin(low[v], low[u]);
			} else if (instack[u]) {
				chmin(low[v], order[u]);
			}
		}
		if (low[v] == order[v]) {
			scc.push_back(std::vector<size_type>());
			while (true) {
				const size_type u = sta.top();
				sta.pop(); instack[u] = false;
				scc.back().push_back(u);
				if (u == v) break;
			}
		}
	}

public :
	explicit strongly_connected_component (size_type n)
	noexcept : num(0), g(n), scc(), low(n, 0), order(n, 0), index(n), instack(n, false), sta() { }

	void add_edge (size_type v, size_type u) noexcept {
		g[v].push_back(u);
	}

	size_type solve () noexcept {
		for (size_type v = 0; v < g.size(); v++) if (not order[v]) dfs(v);
		std::reverse(scc.begin(), scc.end());
		for (size_type i = 0; i < scc.size(); i++) {
			for (const size_type &v : scc[i]) index[v] = i;
		}
		return scc.size();
	}

	const std::vector<std::vector<size_type>> &get_scc () const noexcept {
		return scc;
	}

	size_type size () const noexcept {
		return scc.size();
	}

	const size_type &operator[] (size_type v) const noexcept {
		return index[v];
	}

};


#include <vector>
#include <cstddef>

struct two_sat {
	using size_type = std::size_t;
private :
	strongly_connected_component scc;
	std::vector<bool> answer;

public :
	two_sat (size_type n) noexcept : scc(n << 1), answer(n) { }

	void add_clause (size_type a, bool f, size_type b, bool g) noexcept {
		scc.add_edge(a << 1 | not f, b << 1 | g);
		scc.add_edge(b << 1 | not g, a << 1 | f);
	}

	bool satisfiable () noexcept {
		scc.solve();
		for (size_type i = 0; i < answer.size(); i++) {
			if (scc[i << 1 | 0] == scc[i << 1 | 1]) return false;
			answer[i] = (scc[i << 1 | 0] < scc[i << 1 | 1]);
		}
		return true;
	}

	bool get (const size_type i) const noexcept {
		return answer[i];
	}

};



#include <vector>
#include <cmath>
#include <iostream>

int main() {
	int n, d;
	std::cin >> n >> d;
	std::vector<int> x(n), y(n);
	for (int i = 0; i < n; i++) {
		std::cin >> x[i] >> y[i];
	}
	
	two_sat sat(n);
	
	auto f = [&] (int a, int b) {
		return std::abs(a - b) < d;
	};
	
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			if (f(x[i], x[j])) sat.add_clause(i, 1, j, 1);
			if (f(x[i], y[j])) sat.add_clause(i, 1, j, 0);
			if (f(y[i], x[j])) sat.add_clause(i, 0, j, 1);
			if (f(y[i], y[j])) sat.add_clause(i, 0, j, 0);
		}
	}
	
	if (sat.satisfiable()) {
		std::cout << "Yes" << '\n';
		for (int i = 0; i < n; i++) {
			std::cout << (sat.get(i) ? y[i] : x[i]) << '\n';
		}
	} else {
		std::cout << "No" << '\n';
	}
	
	return 0;
}

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

using namespace std;

int main() {

	int M;
	int i;
	int N = 0;
	int total = 0;
	int ninki = 0;
	
	cin >> N;
	cin >> M;

	int* A;
	A = new int[N];

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

		cin >> A[i];
		total = total + A[i];

	}

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

		if ((float)total / ((float)(4 * M)) <= A[i]) {
			ninki++;
		}

	}
	
	if (ninki >= M) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

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


Measured memory_bytes: 256
# _*_ coding:utf-8 _*_
#  CADDi2018 for Beginners A 1222
#  https://atcoder.jp/contests/caddi2018b/tasks/caddi2018b_a

def  counter2(forSizeInteger):
	forSizeString = str(forSizeInteger)
	counter = 0
	if(forSizeString[0]=='2'):
		counter = counter + 1
	if (forSizeString[1] == '2'):
		counter = counter + 1
	if (forSizeString[2] == '2'):
		counter = counter + 1
	if (forSizeString[3] == '2'):
		counter = counter + 1

	answer=counter

	return answer


if __name__ == '__main__':
	n = int(input())
	solution=counter2(n)
	print(solution)

Measured memory_bytes: 3064
N, K = [int(n) for n in input().split()]
o = {}
for i in range(1, N+1):
    o[i] = False
for j in range(K):
    d = int(input())
    for k in [int(n) for n in input().split()]:
        o[k] = True
print(list(o.values()).count(False))


Measured memory_bytes: 9112
import sys

def solve(N: int, A: "List[int]"):
    result = 0.
    for i in range(N):
        result += 1./A[i]
    print(1./result)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
n,m = map(int,raw_input().split())
a = map(int,raw_input().split())
# m[0],m[1] = m[1],m[0]
# m[0],m[-1] = m[-1],m[0]
# print ' '.join([str(i) for i in m])
res= "Yes"
lt = (float(1)/(4*m))*sum(a)
ctr= 0

for i in a:
    if i >= lt:
        ctr+=1
if ctr>=m:
    print "Yes"
else:
    print 'No'


Measured memory_bytes: 2568
program main
      implicit none
      integer(4) :: n, i
      integer(4), allocatable :: a(:), b(:)

      read *, n
      allocate( a(2:n) )
      read *, a
      allocate( b(1:n) )

      b(:) = 0
      do i = 2, n
        b(a(i)) = b(a(i)) + 1 
      end do
      
      do i = 1, n
        print *, b(i)
      end do

end program main


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

using ll = long long;
#define ALL(c) (c).begin(), (c).end()
const int MOD = 1000000007;

int main() {
    int n, m;
    cin >> n >> m;
    for (int i = m / n; i > 0; i--) {
        if (m % i == 0) {
            cout << i << endl;
            return 0;
        }
    }
}


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

using namespace std;

#include <vector>
#include <list>
#include <cstring>
#include <cmath>
#define scan(x) scanf("%d", &x)
#define scanl(x) scanf("%lld", &x)
#define PI 3.14159265358979323846

void printarray(int* arr, int n){
	for(int i=0;i<n;i++){
		printf("%d ", arr[i]);
	}
	printf("\n");
}

void printvector(vector <int> A){
	for(auto i=A.begin();i!=A.end();i++){
		cout<<*i<<" ";
	}
	cout<<endl;
}

int main(){

	#ifndef ONLINE_JUDGE
    	freopen("D:/Programming/input.txt", "r", stdin);
    	freopen("D:/Programming/output.txt", "w", stdout);
	#endif

	int a,b;
	cin>>a>>b;
	cout<<a*b<<endl;

	return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <queue>
#include <stack>
using namespace std;


int main(){
	int N,W;
	cin>>N>>W;
	vector<int> w(N),v(N);
	for(int i=0;i<N;i++){
		cin>>w[i]>>v[i];
	}
	
	vector<vector<long long>> dp(N+1,vector<long long> (W+1,0));//dp[i][j] i個の品物で重さj以下の時の価値最大値
	
	for(int i=1;i<=N;i++){
		for(int j=1;j<=W;j++){
			if(w[i-1]>j){
				dp[i][j]=dp[i-1][j];
			}
			else{
				dp[i][j]=max(dp[i-1][j],v[i-1]+dp[i-1][j-w[i-1]]);
			}
		}
	}
	
	cout<<dp[N][W]<<endl;
	
	return 0;
}


Measured memory_bytes: 80256
#include <stdio.h>

int main(void){

  int a,b;
  scanf("%d %d", &a, &b);
  int answer = 0;

  for (int i = 0; i < 2; i++) {
    if (a >= b) {
      answer += a;
      a--;
    } else {
      answer += b;
      b--;
    }
  }

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

  return 0;
}

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

#ifdef LOCAL
	#define eprintf(...) printf(__VA_ARGS__)
#else 
	#define eprintf(...) 1
#endif

#define ROUNDUP(a, b) ( (a) + ((b) - 1) ) / b
typedef long long int lli;

using namespace std;


int K, N;
int bs(int b) {
	int left = 1;
	int right = b;

	while ( left <= right ) {
		int mid = left + (right - left) / 2;
		if (mid%b < K) {
			left = mid + 1;
		} else {
			right = mid - 1;
		}
	}
	return left;
}

int main(void) {
	scanf("%d%d", &N, &K);

	lli ans = 0;
	for (int b = K==0?1:K; b <=N; b++) {
		int al = bs(b);
		int au = b-1 - K + al;
		eprintf("b:%d al:%d au:%d\n", b, al, au); 
		int n = (N - au) / b;
		ans += (au - al + 1) * (n + 1);
		if ( al + b * (n+1) <= N)
			ans += N - (al + b * (n+1)) + 1;
		eprintf("b:%d ans:%lld\n", b, ans); 
	}

	printf("%lld\n", ans);
}


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

using namespace std;

int keta(int n) {
    int unko[5];
    for (int i = 0; i < 5; i++) {
        unko[i] = n % 10;
        n /= 10;
    }

    if (unko[0]==unko[4] and unko[1] == unko[3]){
        //printf("%d,%d,%d,%d,%d\n",unko[0],unko[1],unko[2],unko[3],unko[4]);
        return 1;
    }else{
        return 0;
    }
}

int main(){
    int A, B;

    cin >> A >> B;

    int count = 0;

    for (int i = A; i <= B; i++){
        count += keta(i);

        /*int s = i%10;
        int t = i/10000%10;
        int m = i/10%10;
        int n = i/1000%10;
        if(s==t and m==n){
            count++;
        }*/
    }


    cout << count << endl;

    return 0;
}


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

int main(void){
    int n,k; cin >> n >> k;
    int ans = 0;
    for(int i=0;i<n;i++){
        int a; cin >> a;
        int b = k-a;
        if(a < b) ans += a;
        else ans += b;
    }
    cout << ans * 2 << endl;
    return 0;
}

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

const int mod = 1e9 +7;
int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n){
        cin >> a[i];
    }
    ll res = 0;
    rep(d, 60){//d桁目を見る
        ll n0 = 0, n1 = 0;//d桁目の0の個数、１の個数
        rep(i,n){
            if((a[i]>>d)&1){
                n1++;
            }
            else{
                n0++;
            }
        }
        //直ぐにllを超えうるので適宜modで割っている。
        ll tmp = (1ll << d) % mod;//2^dを作る。llは64bitということ
        ll n = n0 * n1 % mod;
        tmp = tmp * n %mod;
        res = (res + tmp) % mod;
    }
    cout << res << endl;
}

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

int main(){
    int x, y, i=0, max=3000;
    do{
        cin >> x >> y;
        if ((x==0) && (y==0)) break;
        if (x<=y) cout << x << " " << y << endl;
        else cout << y << " " << x << endl;
        i++;
    }while(i<max);
}


Measured memory_bytes: 3052
import java.util.Scanner;
import java.util.Arrays;

public class Main {
    public static void main (String... args) {
        Scanner scanner = new Scanner(System.in);
        int N = Integer.parseInt(scanner.nextLine());
        
        String[] sNumbers = scanner.nextLine().split(" ");
        Integer[] nNumbers = Arrays.asList(sNumbers).stream().map(Integer::parseInt).toArray(Integer[]::new);
        
        insertSort(nNumbers, N);
    }
    
    private static void insertSort(Integer[] a, int n) {
        output(a);
        for (int i=1; i <= n-1; i++) {
            int v = a[i];
            int j = i - 1;
            
            while (j >=0 && a[j] > v) {
                a[j+1] = a[j];
                j--;
            }
            a[j+1] = v;
            output(a);
        }
    }
    
    private static void output(Integer[] a) {
        StringBuilder builder = new StringBuilder();
        for (int i=0; i < a.length; i++) {
            if (i < a.length - 1) {
                builder.append(a[i] + " ");
            } else {
                builder.append(a[i] + "");
            }
        }
        System.out.println(builder.toString());
    }
}



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

int mod = 1000000007;

int main()
{
    string A, B, C;
    cin >> A >> B >> C;
    if (A[A.size() - 1] == B[0] && B[B.size() - 1] == C[0])
        cout << "YES";
    else
        cout << "NO";
}

Measured memory_bytes: 256
<?php
  list($s) = explode(" ", trim(fgets(STDIN)));

  $ans=0;
  $n=strlen($s);
  for($i=0;$i<$n;$i++){
    $ans+=$s[$i];
  }
  if($ans % 9 == 0){
    echo "Yes";
  }else{
    echo "No";
  }

Measured memory_bytes: 16408
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;

int main() {
	int n, S[100000], q, A;
	int sum = 0;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &S[i]);
	}
	scanf("%d", &q);
	for (int i = 0; i < q; i++) {
		scanf("%d", &A);
		if (*lower_bound(S, S + n, A)==A) {
			sum += 1;
		}
		
	}
	cout << sum << endl;

}


Measured memory_bytes: 3512
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1<<30;
const int mod = 1e9+7;

int main() {
  int N, M; cin >> N >> M;
  vector<string> A(N), B(M);
  for(int i = 0; i < N; i++) cin >> A[i];
  for(int i = 0; i < M; i++) cin >> B[i];

  for(int i = 0; i < N; i++) {
    for(int j = 0; j < N; j++) {
      if(i+M-1 >= N or j+M-1 >= N) continue;
      bool match = true;
      for(int k = 0; k < M; k++) {
        for(int l = 0; l < M; l++) {
          if(A[i+k][j+l] != B[k][l]) match = false;
        }
      }
      if(match) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;


  return 0;
}



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

#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <stdint.h>
#include <string.h>

#define _USE_MATH_DEFINES
#include <math.h>

#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <string>

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>

#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef long long int i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

const i64 mod = 1'000'000'000ll + 7;
//const i64 smod = 998244353ll;

//const i64 inf = mod;

const long double eps = 1e-8;

int main(int argc, char* argv[]) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed); cerr.precision(15); cerr.setf(ios::fixed);

    i64 n;
    cin >> n;

    vector<i64> p(11, 1);
    for (i64 i = 0; i < n; i++) {
        for (i64 j = 8; j < 11; j++) {
            p[j] *= j;
            p[j] %= mod;
        }
    }

    i64 R = p[10];
    R -= (2 * p[9]) % mod;
    R = (R + mod) % mod;
    R += p[8];
    R %= mod;

    cout << R << endl;



    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
// statics
using namespace std;
using int64 = long long;
using PAIR = pair<int, int>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 1e5 + 1;
constexpr int MAX_M = 60;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout <<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<"\n";
#define debug(x) cerr << #x << ":" << (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=0;--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)

struct Edge {
  int from;
  int to;
  int cost;
};

vector< Edge > e;

signed main() {
  INIT;

  VAR(int, L);
  int N = 1, tmp = L;
  while (tmp >>= 1) N++;

  int cnt = 0, s = 1;
  FOR(i, 1, N) {
    e.push_back(Edge{i, i + 1, 0});
    e.push_back(Edge{i, i + 1, s});
    cnt += s;
    s <<= 1;
  }

  int p = 1;
  tmp = 1;
  while (L > 1) {
    if (L % 2 == 1) {
      e.push_back(Edge{p, N, cnt + 1});
      cnt += tmp;
    }
    L >>= 1;
    p++;
    tmp <<= 1;
  }

  OUT(N)SP OUT(e.size())BR;

  EACH(ei, e) {
    OUT(ei.from)SP OUT(ei.to)SP OUT(ei.cost)BR;
  }
  
  return 0;
}


Measured memory_bytes: 256
import sys
def input():
    return sys.stdin.readline().rstrip()
def main():
    def scoring(ans, d, t, C, S, L, replace = False):
        ans += S[d][t]
        L[t] = d
        ans -= sum([c * (d - l) for (c, l) in zip(C, L)])
        if replace:
            return ans, L
        else:
            return ans
    D = int(input())
    C = list(map(int, input().split()))
    S = [list(map(int, input().split())) for _ in range(D)]
    L = [-1] * 26
    ans = 0
    for d in range(D):
        ANS = [scoring(ans, d, t, C, S, L) for t in range(26)]
        t_max = ANS.index(max(ANS))
        ans, L = scoring(ans, d, t_max, C, S, L, replace = True)
        print(t_max + 1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9516
import java.util.*;
public class Main{
	public static void main(String args[]){
    
    	Scanner sc=new Scanner(System.in);
      	int n=sc.nextInt();
      	int W=sc.nextInt();
      	int w[]=new int[n+1];
      	int v[]=new int[n+1];
      	for(int i=1;i<=n;i++){
        	w[i]=sc.nextInt();
          	v[i]=sc.nextInt();
        }
      	long dp[][]=new long[n+1][W+1];
      	
      	//Logic
      
      for(int i=0;i<=n;i++){
      	for(int j=0;j<=W;j++){
        
        	if(i == 0 || j == 0){
            	dp[i][j] = 0;
              	continue;
            }
        	
          	if(w[i]>j){
            	dp[i][j]=dp[i-1][j];
              	continue;
            }
          
          	dp[i][j] = Math.max(dp[i-1][j],v[i]+dp[i-1][j-w[i]]);
        
        }
      }
      System.out.println(dp[n][W]);  
    
    
    }
}

Measured memory_bytes: 140716
#include<stdio.h>
#define N 2000
int A[N+1];


int main(void){
  int n,l,q,p,sum=0;
  int i,j;

  A[0]=1;
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    scanf("%d",&l);
    sum+=l;
    
    for(j=sum-l;j>=0;j--){
      if(A[j]) A[j+l]=1;
    }
  }


  scanf("%d",&q);
  
  for(i=0;i<q;i++){
    scanf("%d",&p);
    
    if(A[p]) printf("yes\n");
    else printf("no\n");
  }

  return 0;
}



Measured memory_bytes: 2048
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(auto i=0;i<n;++i)
#define REPR(i,n) for(auto i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(auto i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(n,v) {int tmp;for(int i=0;i<n;++i){scanf("%d",&tmp);v.push_back(tmp);}}

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  int n;
  cin >> n;

  vector<int> v(n);
  REP(i,n){
    cin >> v[i];
  }
  
  SORTV(v);

  llong ans = 0;
  if(n == 2){
    cout << abs(v[0] - v[1]) << endl;
    return 0;
  }

  int min_idx = 1, max_idx = n - 1;
  int left = v[0], right = v[0];
  while(true){
    if(min_idx == max_idx){
      int val = v[min_idx];
      ans += max(abs(left - val), abs(right - val));
      break;
    }

    //choice min
    int val = 0;
    int choice = -1; //0:leftmin 1:rightmin 2:leftmax 3:rightmax
    if(abs(left - v[min_idx]) > val){
      val = abs(left - v[min_idx]);
      choice = 0;
    }
    if(abs(right - v[min_idx]) > val){
      val = abs(right - v[min_idx]);
      choice = 1;
    }
    
    //choice max
    if(abs(left - v[max_idx]) > val){
      val = abs(left - v[max_idx]);
      choice = 2;
    }

    if(abs(right - v[max_idx]) > val){
      val = abs(right - v[max_idx]);
      choice = 3;
    }

    if(choice == 0){
      left = v[min_idx];
      min_idx++;
    }else if(choice == 1){
      right = v[min_idx];
      min_idx++;
    }else if(choice == 2){
      left = v[max_idx];
      max_idx--;
    }else{
      right = v[max_idx];
      max_idx--;
    }

    ans += val;

    //cout << choice << " " << ans << endl;
  }

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



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

const ll MAXN = 200000;
const ll INF = 1001001001;

ll N, M, tmp=0;
vector<ll> A, indeg, ans;
vector<vector<ll>> G;

void bfs(ll st) {
    queue<ll> Q;
    Q.push(st);
    while(!Q.empty()) {
        ll u = Q.front();
        Q.pop();
        for(int i=0;i<G[u].size();i++) {
            indeg[G[u][i]]--;
            if(indeg[G[u][i]]==0) {
                Q.push(G[u][i]);
                ans[G[u][i]] = u;
            }
        }
    }
}

signed main() {
    cin >> N >> M;
    indeg.resize(N);
    ans.resize(N);
    G.resize(N);
    for(int i=0;i<N;i++) {
        indeg[i] = 0;
    }
    for(int i=0;i<N+M-1;i++) {
        ll a, b;
        cin >> a >> b;
        G[a-1].push_back(b-1);
        indeg[b-1]++;
    }
    for(int i=0;i<N;i++) {
        if(indeg[i]==0) {
            bfs(i);
            ans[i] = -1;
            break;
        }
    }
    for(int i=0;i<N;i++) {
        cout << ans[i]+1 << endl;
    }
    return 0;
}

Measured memory_bytes: 7808
import itertools
import math
n = int(input())
p  = list(map(int, input().split()))
q  = list(map(int, input().split()))
lst = []
for i in range(1, n+1):
    lst.append(i)
a =  list(itertools.permutations(lst))
p_c = a.index(tuple(p))
q_c = a.index(tuple(q))
print(int(math.fabs(q_c-p_c)))


Measured memory_bytes: 7972
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
int fuck[234567];
int bpow(int x, int y)
{
    int ans = 1;
    while (y)
    {
        if (y & 1)
            ans = 1LL * ans * x % MOD;
        x = 1LL * x * x % MOD;
        y >>= 1;
    }
    return ans;
}
int inv(int x)
{
    return bpow(x, MOD - 2);
}
int c(int n, int r)
{
    if (r > n)
        return 0;
    return 1LL * fuck[n] * inv(fuck[r]) % MOD * inv(fuck[n - r]) % MOD;
}
int f(int i, int s)
{
    return c(s + i - 1, s);
}
int32_t main()
{
    ios::sync_with_stdio(0);
    fuck[0] = 1;
    for (int i = 1; i < 234567; ++i)
        fuck[i] = 1LL * fuck[i - 1] * i % MOD;
    int h, w, a, b;
    cin >> h >> w >> a >> b;
    int ans = f(w, h - 1);
    for (int i = 0; i < b; ++i)
    {
        ans -= 1LL * f(i + 1, h - a - 1) * f(a, w - i - 1) % MOD;
        ans = (ans % MOD + MOD) % MOD;
    }
    cout << ans << '\n';
    return 0;
}

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

#define rep(i, n) for(int (i) = 0; (i) < (int)(n); (i)++)
#define repr(i, n) for(int (i) = (n); (i) >= 0; (i)--)
#define repf(i, m, n) for(int (i) = (m); (i) < (n); (i)++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define inf 1e9

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

using namespace std;

int main(int argc, char const *argv[])
{
    int n, a;
    cin >> n;
    cin >> a;

    if (n % 500 <= a)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();
    Integer[] v = new Integer[N];

    for (int i = 0; i < N; i++) {
      v[i] = sc.nextInt();
    }

    sc.close();

    Arrays.sort(v);

    double answer = v[0];

    for (int i = 1; i < N; i++) {
      answer = (answer + v[i]) / 2;
    }

    System.out.println(answer);

  }

}

Measured memory_bytes: 21332
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	public static void main(String[] args)throws IOException{
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader reader = new BufferedReader(isr);
		
		String str;
		int e, m, hoge;
		while(!(str = reader.readLine()).equals("0")){
			e = Integer.valueOf(str);
			m = Integer.MAX_VALUE;
			for(int i = 0; Math.pow(i, 3) <= e; i++){
				hoge = (int)Math.sqrt(e - Math.pow(i, 3));
				m = (int)Math.min(e - Math.pow(i, 3) - Math.pow(hoge, 2) + hoge + i, m);
			}
			System.out.println(m);
		}
		reader.close();
	}
}

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

int main() {
  int H, W, A, B;
  int y=0;
  int x=0;
  string S;
  cin >> A >> B;

  x=A-2*B;
  if (x<0) {
    cout << 0 << endl;
    return 0;
  }
  else {
    cout << x << endl;
    return 0;
    
    
  }
    
}


Measured memory_bytes: 256
str1 = gets.split
N,M = str1[0].to_i, str1[1].to_i

str1 = gets.chomp.split
a = []
i = 0
while i < N 
  a[i] = str1[i].to_i
  i += 1
end
a.sort!

b = []
i = 0
while i < M
  str1 = gets.split
  b[i] = str1[0].to_i, str1[1].to_i
  i += 1
end

b.sort_by! {|k, v| v }
b.flatten!

i = 0
j = N-1
k = M*2-1
x = 0
y = 0
answer = 0
while i < N
  if a[j] <= b[k]
    x = b.pop
    y = b.pop
    k -= 2
    if i+y < N
      answer += x*y
      i += y
    else
      y = N-i
      answer += x*y
      i += y
    end
    if k == -1
      k = 0
      b[0] = 0
    end
  else
    answer += a.pop
    i += 1
    j -= 1
  end
end

puts answer

Measured memory_bytes: 21920
#include <stdio.h>

int main(){
  int n, soma = 0, x;
  int a[21], b[21], c[21];

  scanf("%d", &n);

  for(int i = 0; i < n; ++i){
    scanf("%d", &a[i]);
  }
  for(int i = 0; i < n; ++i){
    scanf("%d", &b[i]);
  }
  for(int i = 0; i < n-1; ++i){
    scanf("%d", &c[i]);
  }

  soma = b[a[0]-1];


  for(int i = 1; i < n; ++i){
    if(a[i] == a[i-1]+1){
      soma = soma+b[a[i]-1]+c[a[i-1]-1];
    }
    else{
      soma = soma + b[a[i]-1];
    }
  }

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


Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include<iostream>
#include<fstream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<climits>
#include<set>
#include<map>
#include<cmath>
#include<iomanip>
#include<iterator>
#include<queue>
#include<stack>
#include<cctype>
#include<deque>
#include<time.h>
#include<bitset>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<sstream>
#include<random>

//by Skeef79

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

#pragma warning(disable : 4996)
#pragma comment(linker, "/STACK:16777216")
#define pb push_back
#define en '\n'
#define for0(i,n) for(int i = 0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define vec vector
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

const int INF = 2000000000;
const ll LINF = 2000000000000000000;

template<typename T> void print(vector<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}

template<typename T> void print(deque<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}

template<typename T> void print(vector<vector<T>>& a)
{
	for (int i = 0; i < a.size(); i++)
	{
		for (int j = 0; j < a[i].size(); j++)
			cout << a[i][j] << ' ';
		cout << en;
	}
}

template <typename T> void input(vector<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cin >> a[i];
}

template<typename T> void input(deque<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cin >> a[i];
}

template<typename T> void input(vector<vector<T>>& a)
{
	for (int i = 0; i < a.size(); i++)
		for (int j = 0; j < a[i].size(); j++)
			cin >> a[i][j];
}

void solve()
{
	int h, a;
	cin >> h >> a;
	cout << (h + a - 1) / a;

	

}

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

#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
#endif

	int tst = 1;
	//cin >> tst;
	while (tst--)
		solve();

}

Measured memory_bytes: 256
// ███▓▓▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓╬╬╬╬╬╬▓█
// ███▓███████▓▓╬╬╬╬╬╬╬╬╬╬╬╬▓███▓▓▓▓█▓╬╬╬▓█
// ███████▓█████▓▓╬╬╬╬╬╬╬╬▓███▓╬╬╬╬╬╬╬▓╬╬▓█
// ████▓▓▓▓╬╬▓█████╬╬╬╬╬╬███▓╬╬╬╬╬╬╬╬╬╬╬╬╬█
// ███▓▓▓▓╬╬╬╬╬╬▓██╬╬╬╬╬╬▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓█
// ████▓▓▓╬╬╬╬╬╬╬▓█▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓█
// ███▓█▓███████▓▓███▓╬╬╬╬╬╬▓███████▓╬╬╬╬▓█
// ████████████████▓█▓╬╬╬╬╬▓▓▓▓▓▓▓▓╬╬╬╬╬╬╬█
// ███▓▓▓▓▓▓▓╬╬▓▓▓▓▓█▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓█
// ████▓▓▓╬╬╬╬▓▓▓▓▓▓█▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓█
// ███▓█▓▓▓▓▓▓▓▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓█
// █████▓▓▓▓▓▓▓▓█▓▓▓█▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓█
// █████▓▓▓▓▓▓▓██▓▓▓█▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
// █████▓▓▓▓▓████▓▓▓█▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
// ████▓█▓▓▓▓██▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
// ████▓▓███▓▓▓▓▓▓▓██▓╬╬╬╬╬╬╬╬╬╬╬╬█▓╬▓╬╬▓██
// █████▓███▓▓▓▓▓▓▓▓████▓▓╬╬╬╬╬╬╬█▓╬╬╬╬╬▓██
// █████▓▓█▓███▓▓▓████╬▓█▓▓╬╬╬▓▓█▓╬╬╬╬╬╬███
// ██████▓██▓███████▓╬╬╬▓▓╬▓▓██▓╬╬╬╬╬╬╬▓███
// ███████▓██▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬████
// ███████▓▓██▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓████
// ████████▓▓▓█████▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓█████
// █████████▓▓▓█▓▓▓▓▓███▓╬╬╬╬╬╬╬╬╬╬╬▓██████
// ██████████▓▓▓█▓▓▓╬▓██╬╬╬╬╬╬╬╬╬╬╬▓███████
// ███████████▓▓█▓▓▓▓███▓╬╬╬╬╬╬╬╬╬▓████████
// ██████████████▓▓▓███▓▓╬╬╬╬╬╬╬╬██████████
// ███████████████▓▓▓██▓▓╬╬╬╬╬╬▓███████████
//#include "grader.h"
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <deque>
#include <cassert>
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define read(FILENAME) assert(freopen((FILENAME + ".in").c_str(), "r", stdin))
#define write(FILENAME) assert(freopen((FILENAME + ".out").c_str(), "w", stdout))
#define files(FILENAME) read(FILENAME), write(FILENAME)
using namespace std;
template <typename A, typename B> void chkmin(A &x, B y) {if (x > y) x = y;}
template <typename A, typename B> void chkmax(A &x, B y) {if (x < y) x = y;}
     
typedef pair <int, int> point;
     
const string FILENAME = "input";
const int MAXN = 1e5, p = 1e9 + 7;

int n;
long long A, B;
long long h[MAXN];

bool check(int M) {
	long long cnt = 0;
	for (int i = 0; i < n; ++i) {
		if ((h[i] - M * B) <= 0) continue;
		cnt += ((h[i] - M * B) - 1) / (A - B) + 1;
	}
	return cnt <= M;
}

int main() {
	//read(FILENAME);
	ios::sync_with_stdio(0);
	cin >> n >> A >> B;
	for (int i = 0; i < n; ++i) {
		cin >> h[i];
	}
	int L = -1, R = 1e9;
	while (R - L > 1) {
		int M = (L + R) >> 1;
		if (check(M)) {
			R = M;
		} else {
			L = M;
		}
	}
	cout << R << endl;
}








Measured memory_bytes: 1024
use std::collections::{BTreeSet, HashSet};
use std::error::Error;
use std::io;

pub fn main() {
    if let Err(_e) = run() {
        panic!("failed.");
    }
}

fn run() -> Result<(), Box<dyn Error>> {
    let mut input = String::new();
    io::stdin().read_line(&mut input)?;
    input.clear();
    io::stdin().read_line(&mut input)?;
    let mut nums: Vec<i64> = input
        .trim()
        .split_whitespace()
        .map(|s| s.parse::<i64>().unwrap())
        .collect();
    input.clear();

    nums.sort();

    let mut dp = vec![0; 1_000_001];
    for &x in &nums {
        let index = x as usize;
        if dp[index] != 0 {
            dp[index] = 2;
            continue;
        }
        let mut from = index;
        while from < 1_000_001 {
            dp[from] += 1;
            from = from + x as usize;
        }
    }
    // println!("{:?}", dp);

    let mut count = 0;
    for &x in &nums {
        if dp[x as usize] == 1 {
            count += 1;
        }
    }
    println!("{}", count);

    Ok(())
}


Measured memory_bytes: 8804
#include <bits/stdc++.h>
using namespace std;
#define fol(i,n) for(int i=0;i<n;++i)
#define pb push_back
typedef long long ll;
typedef pair<int,int> P;
typedef vector<P> vip;

int main(){
 int n;cin>>n;
 bool flag = false;
  for(int i=0;i<26;i++){
    for(int j=0;j<15;j++){
      if(i*4+j*7==n) flag = true;
    }
  }
  if(flag)cout <<"Yes"<<endl;
  else cout << "No"<<endl;
  return 0;
}


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

int main() {
  ll A, B, C, X, Y;
  cin >> A >> B >> C >> X >> Y;
  
  ll ans = 1000000000000;
  // ABピザの数ごとで最小金額を計算する
  for (ll i=0; i <= 3000000; i+= 2ll) {
    ll cost = i * C;
    cost += A * max(0ll, X - i / 2ll);  // 0以下にならないようにAも買う
    cost += B * max(0ll, Y - i / 2ll);  // 0以下にならないようにBも買う
    ans = min(ans, cost);  // 前のiterationより小さかったら採用
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <queue>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define MP make_pair
#define ll long long
#define fi first
#define se second
using namespace std;

template <typename T>
void read(T &x) {
    x = 0; bool f = 0;
    char c = getchar();
    for (;!isdigit(c);c=getchar()) if (c=='-') f=1;
    for (;isdigit(c);c=getchar()) x=x*10+(c^48);
    if (f) x=-x;
}

template<typename F>
inline void write(F x)
{
	static short st[30];short tp=0;
	if(x<0) putchar('-'),x=-x;
	do st[++tp]=x%10,x/=10; while(x);
	while(tp) putchar('0'|st[tp--]);
	putchar('\n');
}

template <typename T>
inline void Mx(T &x, T y) { x < y && (x = y); }

template <typename T>
inline void Mn(T &x, T y) { x > y && (x = y); }

const int N = 100;
ll a[N], n;

ll dfs(int l, int r, int xl, int xr) {
	if (r <= l + 1) return 0;
	ll ans = 1e18;
	for (int x = l + 1; x < r; x++)
		Mn(ans, dfs(l, x, xl, xl + xr) + dfs(x, r, xl + xr, xr) + a[x] * (xl + xr));
	return ans;
}

int main() {
	read(n); 
	for (int i = 1;i <= n; i++) read(a[i]);
	printf ("%lld\n", a[1] + a[n] + dfs(1, n, 1, 1));
	return 0;
}

Measured memory_bytes: 3236
res = 'z'*100
s = input()
t = input()
l = len(t)
for i in range(len(s)-l+1):
    string = s[i:i+l]
    flag = False
    for (j,k) in zip(string,t):
        if j!=k and j!='?':
            flag = True
            break
    if flag:
        continue
    tmp = s[:i] + t + s[i+l:]
    res = min(res, tmp.replace('?','a'))
if res=='z'*100:
    print('UNRESTORABLE')
else:
    print(res)

Measured memory_bytes: 3064
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_m
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // fixed, setprecision 
#include <math.h> // double sqrt
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;

int main(){
    long long h,count=0,ans=0;
    cin>>h;
    while(h>0){
        count++;
        h/=2;
        ans+=pow(2,count-1);
    }

cout<<ans;
return 0;
}

Measured memory_bytes: 3312
import java.util.*;
public class Main {
	static Scanner sc = new Scanner(System.in);
	static int[] handout = new int[31];
	static int[] source = new int[29];
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO ツ篠ゥツ督ョツ青カツ青ャツつウツづェツつスツδソツッツドツ・ツスツタツブ
		read();
		slove();
	}
	static boolean read(){
		for(int i = 1; i <= 28; i++){
			source[i] = sc.nextInt();
		}
		return true;
	}
	static void slove(){
		for(int i = 1; i<=30; i++){
			handout[i] = i;
		}
		for(int i = 1; i <= 30 ;i++){
			for(int j = 1; j <=28 ; j++){
				if(handout[i] == source[j])
					handout[i] = 0;
				
			}
			if(handout[i] != 0)
				System.out.println(handout[i]);
		}
		
	}
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a=0,b=0,c=0,d=0;
  string s;
  cin>>n;
  while(n--)
  {
      cin>>s;
      if(s=="AC")
        a++;
      else if(s=="WA")
      b++;
      else if(s=="TLE")
        c++;
      else
        d++;
  }
  cout<<"AC x "<<a<<endl;
  cout<<"WA x "<<b<<endl;
  cout<<"TLE x "<<c<<endl;
  cout<<"RE x "<<d;
   return 0;
}


Measured memory_bytes: 3624
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int n;
char tex[1050];
char *fin;

int main(void){
	scanf("%d",&n);
	fgets(tex,1042,stdin);
	for(;n>0;n--){
		fgets(tex,1042,stdin);
		while(strstr(tex,"Hoshino")!=NULL){
			fin=strstr(tex,"Hoshino");
			fin[6]='a';
		}
		printf("%s",tex);
	}
	return 0;
}

Measured memory_bytes: 608