akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;

#define ff              first
#define ss              second
#define ll             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
//mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void sb()
{	
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
vector<vector<double>> dp;
std::vector<double> p;
void solve(){

	dp[0][0] = (double)1 - p[0];
	dp[0][1] = p[0];
	for(int curr=1;curr<p.size();curr++){
		

	for(int i=0;i<=curr+1;i++){
		//dp[curr][i] = (double)0;
		if(i>0){
			dp[curr][i] += dp[curr-1][i-1]*p[curr];
		}
		dp[curr][i]+= dp[curr-1][i]*((double)1 - p[curr]);
	}

}

}
int main()
{
	
	ll n;
	cin>>n;
	dp = vector<vector<double>>(n,vector<double>(n+1,(double)0));
	 p = vector<double>(n);
	for(int i=0;i<n;i++)
		cin>>p[i];
	solve();

	double ans = 0;
	for(int i=0;i<=n;i++){

		if(i>n/2)
			ans+= dp[n-1][i];
	}

	// for(int i=0;i<n;i++){
	// 	for(int j=0;j<=n;j++)
	// 		cout<<dp[i][j]<<" ";
	// 	cout<<endl;
	// }
	cout<<setprecision(10)<<ans<<endl;

	
}

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long  ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){cerr<<"\n";} template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }



int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	ll n, k;
	cin >>n >>k;
	
	
	ll ans = min(n%k, k-n%k);
	cout << ans <<"\n";
	return 0;
}


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

int main() {
    string s;
    cin >> s;
    if (s.at(0) == s.at(1) || s.at(1) == s.at(2) || s.at(2) == s.at(3)) {
        cout << "Bad" << endl;
    }
    else cout << "Good" << endl;
}


Measured memory_bytes: 256
def function(N, a):
    number = 0
    ans = 0
    while number < N:
        if number % 2 == 0:
            if a[number] % 2 == 1:
                ans += 1
        number += 1

    return ans


if __name__ == '__main__':
    N = int(input())
    a = input().split()
    a = [int(i) for i in a]
    print(function(N, a))


Measured memory_bytes: 9040
#include <bits/stdc++.h>
using namespace std;
//using Graph = vector<vector<int>>;
//using P =pair<int,int>;
//int dy[4] = {-1,0,1,0};
//int dx[4] = {0,-1,0,1};

#define MOD 1000000007

long long mod(long long a)
{
    return (a+MOD) % MOD;
}

int main()
{
    long long N,K;
    cin >> N >> K;
    
    
    long long ans = 0;
    
    for(long long i=K;i<N+2;i++)
    {
        ans = mod(ans +  1 + mod((N-i+1) * i)   );
    }
    
    cout << ans << endl;
    return 0;
    
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a, b;
cin >> a >> b;
if (a > 12){
    cout << b;
    return 0;}
else if (a > 5){
    cout << b / 2;
    return 0;
}
else{
    cout << 0;
    return 0;
}
}

Measured memory_bytes: 256
Sx, Sy, Tx, Ty = map(int, input().split())

first_x = Tx - Sx
first_y = Ty - Sy

ans1_list = []

if first_y > 0:
	ans1_list.append('U'*first_y)
	if first_x > 0:
		ans1_list.append('R'*first_x)
	else:
		ans1_list.append('L'*first_x)


else:
	print('D'*first_y)
	if first_x > 0:
		ans1_list.append('R'*first_x)
	else:
		ans1_list.append('L'*first_x)

ans1_list_ = "".join(ans1_list)
#ans2_list_ = "".join(ans2_list)

count1_list = []

#ans_list = ans1_list_ + ans2_list_

for s in ans1_list_:
	if s == 'U':
		count1_list.append('D')
	elif s == 'D':
		count1_list.append('U')
	elif s == 'R':
		count1_list.append('L')
	elif s == 'L':
		count1_list.append('R')

ans1_list = ans1_list_ + "".join(count1_list)

ans2_list = []

if "".join(ans1_list)[0] == 'U':
	ans2_list.append('L')
	ans2_list.append('U')
	ans2_list.append("".join(ans1_list_))
	ans2_list.append('R')
	ans2_list.append('D')

elif "".join(ans1_list)[0] == 'R':
	ans2_list.append('U')
	ans2_list.append('R')
	ans2_list.append("".join(ans1_list_))
	ans2_list.append('D')
	ans2_list.append('L')

elif "".join(ans1_list)[0] == 'D':
	ans2_list.append('R')
	ans2_list.append('D')
	ans2_list.append("".join(ans1_list_))
	ans2_list.append('L')
	ans2_list.append('U')
elif "".join(ans1_list)[0] == 'L':
	ans2_list.append('D')
	ans2_list.append('L')
	ans2_list.append("".join(ans1_list_))
	ans2_list.append('U')
	ans2_list.append('R')

ans2_list_ = "".join(ans2_list)

count_list = []

ans_list = ans1_list + ans2_list_

for s in ans2_list_:
	if s == 'U':
		count_list.append('D')
	elif s == 'D':
		count_list.append('U')
	elif s == 'R':
		count_list.append('L')
	elif s == 'L':
		count_list.append('R')


count_ = "".join(count_list)
ans_list = "".join(ans_list) + count_

ans = ans_list
print(ans)

Measured memory_bytes: 3316
// ABC171-E
#include <bits/stdc++.h>
#define endl "\n"
#define rep(i,n) for(int i=0;i<int(n);i++)
#define e_b emplace_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> ipair;
typedef pair<ll,ll> lpair;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v) //vectorの中身を見る
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
void map_p(map<int,int>& d){cout<<"map: ";for(auto a : d){cout<<"{"<<a.first<<":"<<a.second<<"}";}cout<<endl;} //mapの中身を見る
void set_p(set<int>& d){cout<<"set: ";for(int a : d){cout<<a<<" ";}cout<<endl;} //setの中身を見る


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);

    int n;
    cin>>n;
    int s=0;
    vector<int> num(n);
    rep(i,n){
        int a;
        cin>>a;
        s=s^a;
        num[i]=a;
    }
    rep(i,n){
        cout<<(s^num[i])<<" ";
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 3992
#include<stdio.h>                                                         
                                                                          
int main(void){                                                           
                                                                          
  int S,h,m,l,s;                                                          
                                                                          
  scanf("%d",&S);                                                         
                                                                          
  h = S / 3600;                                                           
  m = (S % 3600) / 60;                                                    
  s =(S % 3600) % 60;                                                     
                                                                          
  printf("%d:%d:%d\n",h,m,s);                                             
                                                                          
  return 0;                                                               
}

Measured memory_bytes: 2732
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
const int MOD = 1000000007;
const int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;


signed main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  string S, T{}, R{};
  int Q;
  cin >> S >> Q;
  int ok = true;
  int N, M;
  string c;
  rep(i,Q){
    cin >> N;
    if(N == 1){
      if(ok){
        ok = false;
      }
      else{
        ok = true;
      }
    }
    else{
      cin >> M >> c;
      if(M == 1){
        if(ok){
          S.insert(0, c);
        }
        else{
          S += c;
        }
      }
      else{
        if(ok){
          S += c;
        }
        else{
          S.insert(0,c);
        }
      }
    }
  }
  if(ok){
    cout << S << endl;
  }
  else{
    int W = S.size();
    for(int i=W-1;i>=0;i--){
      cout << S[i];
    }
  }
}

Measured memory_bytes: 1040
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,x,y,t=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>x>>y;
		t+=y-x+1;
	}
	cout<<t<<endl;
	return 0;
} 

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

#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define endl "\n"
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define rev(a) (a).rbegin(),(a).rend()
#define pll pair<ll,ll>
#define rep(i,a,b) for(long long i = (a); i <= (b); i++)

const int mod = 1e9+7;
const int N = 1e5+5; 

int main(){
	fast;
	ll t = 1; 
	//cin >> t;
	while(t--){
	    ll n; cin >> n;
	    ll ans = 0;
	    
	    rep(i,1,n){
	        ll x = n - i;
	        if(x > 0){
	            ans += (x + i - 1) / i;
	        }
	    }
	    
	    cout << ans << endl;
	}
}

Measured memory_bytes: 3644
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <ctime>
#include <map>
#include <stack>
#include <sstream>
#include <set>
#include <cmath>
#include <functional>

using namespace std;

int dx[8] = { 0,1,1,1,0,-1,-1,-1 };
int dy[8] = { -1,-1,0,1,1,1,0,-1 };
int main(void)
{
	vector <string> g;
	string s;
	int h, w;

	cin >> h >> w;

	for (int i = 0; i < h; i++)
	{
		cin >> s;
		g.push_back(s);
	}

	for (int i = 0; i < h; i++)
	{
		for (int j = 0; j < w; j++)
		{
			if (g[i][j] == '.')
			{
				int c = 0;
				for (int k = 0; k < 8; k++)
				{
					int x = j + dx[k];
					int y = i + dy[k];
					if (x < 0 || y < 0 || x >= w || y >= h)
					{
						continue;
					}
					if (g[y][x] == '#')
					{
						c++;
					}
				}
				g[i][j] = '0' + c;
			}
		}
	}

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

	return 0;
}

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

int i,j,k,n,c=0,p;
char s[2000005],t[2000005];

int main(){
	scanf("%d",&n);
	while(n!=0){
		scanf("%s",s);
		c=1;
		while(n){
			p=0;
			for(i=0;i<strlen(s);i++){
				if(s[i+1]==s[i])c++;
				else{
					p+=sprintf(t+p,"%d%c",c,s[i]);
					c=1;
				}
			}
			strcpy(s,t);
			strcpy(t,"");
			n--;
		}
		printf("%s\n",s);
		scanf("%d",&n);
	}
	return 0;
}

Measured memory_bytes: 500
#include <bits/stdc++.h>
using namespace std;
int main() {
  int h, w;
  cin >> h >> w;
  char a[110][110];
  for(int i=1; i<=h; i++){
    for(int j=1; j<=w; j++){
    cin >> a[i][j];
    }
  }
  for(int i=0; i<=h+1; i++){
    a[i][0] = '#';
    a[i][w+1] = '#';
  }
  for(int i=1; i<=w; i++){
    a[0][i] = '#';
    a[h+1][i] = '#';
  }
  for(int i=0; i<=h+1; i++){
    for(int j=0; j<=w+1; j++){
      cout << a[i][j];
      if(j==w+1) cout << endl;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int X[2000],Y[200];
signed main(){
	int n,m,x,y;cin>>n>>m>>x>>y;
	rep(i,n)cin>>X[i];
	rep(i,m)cin>>Y[i];
	sort(X,X+n);
	sort(Y,Y+m);
	for(int z=-1000;z<=1000;z++){
		if(x<z&&z<=y&&X[n-1]<z&&z<=Y[0]){
			puts("No War");
			return 0;
		}
	}
	puts("War");
}

Measured memory_bytes: 256
def binomial_p(n, k, p):
    '''
    Input: integers n, k such that n >= k >= 0, prime number p
    Output: n choose k mod p
    '''

    k = min(k, n-k)
    fct_n = 1  # factorial of n mod p = 1 * 2 * ... * n mod p
    inv = [0, 1] # inv[i] : inverse of i mod p
    invfct_k = 1 # factorial of inverse of k mod p = 1^(-1) * 2^(-1) * ... * k^(-1) mod p
    invfct_n_k = 1  # factorial of inverse of (n-k) mod p

    # Calculate inverse, factorial, factorial of inverse of i
    # all at the same time
    for i in range(2, n - k + 1):
        fct_n = (fct_n * i) % p
        inv.append(( inv[p % i] * (p - p//i) ) % p )
        invfct_n_k = invfct_n_k * inv[-1] % p
        if i == k:
            invfct_k = invfct_n_k

    for i in range(n - k + 1, n + 1):
        fct_n = (fct_n * i) % p

    return ((fct_n * invfct_k % p) * invfct_n_k) % p



x, y = [int(a) for a in input().split()]

n, rn = divmod(2 * x - y, 3)
m, rm = divmod(2 * y - x, 3)
p = 10**9 + 7

if rn != 0 or rm != 0 or n < 0 or m < 0:
    ans = 0
else:
    a = (2 * x - y) // 3
    b = (2 * y - x) // 3
    ans = binomial_p(a + b, b, p)

print(ans)


Measured memory_bytes: 68336
#include <stdio.h>
int main(void) {
	long long int a,b,x,y,i,z;
	scanf("%lld",&a);
	for(i=0;i<a;i++){
		scanf("%lld",&b);
		if(i==0){
			x=b;
			y=b;
			z=b;
		}else{
			z=z+b;
		//	printf("[%lld,%lld]\n", i, z);
			if(x>b){
				x=b;
			}
			if(y<b){
				y=b;
			}
		}
	}
	printf("%lld %lld %lld\n",x,y,z);
	return 0;
}

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

using namespace std;

int main() {
  int N, B[2]{0,100000}, ans{};
  cin >> N;
  for (int i = 0; i < N - 1; i++) {
    cin >> B[i%2];
    ans += min(B[0],B[1]);
  }
  ans += B[N%2];
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int N,K;

int ans;

void dfs(int d,int v){
	if(d==N){
		if(ans>v){ans=v;}
		return;
	}

	dfs(d+1,v*2);
	dfs(d+1,v+K);
}

int main(){

	scanf("%d",&N);
	scanf("%d",&K);

	ans=1<<30;

	dfs(0,1);

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

	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define int long long
using namespace std;
struct edge {
	int u,v,nxt;
} e[233333*2];
int n,tot,h[233333],p[233333],incir[233333],cir[233333],f[233333],vis[233333];
void add(int u,int v) {
	e[++tot].u=u;
	e[tot].v=v;
	e[tot].nxt=h[u];
	h[u]=tot;
}
void dfs_sub_tree(int u){
	for(int i=h[u];i;i=e[i].nxt){
		int v=e[i].v;
		if(incir[v]) continue;
		dfs_sub_tree(v);
	}
	for(int i=h[u];i;i=e[i].nxt){
		int v=e[i].v;
		if(incir[v])continue;
		vis[f[v]]=1;
	}
	while(vis[f[u]])f[u]++;
	for(int i=h[u];i;i=e[i].nxt){
		int v=e[i].v;
		if(incir[v])continue;
		vis[f[v]]=0;
	}
}
signed main() {
	scanf("%lld",&n);
	for(int i=1; i<=n; ++i) {
		scanf("%lld",&p[i]);
		add(p[i],i);
	}
	int now=1;
	while(!incir[now]) {
		incir[now]=1;
		now=p[now];
	}
	memset(incir,0,sizeof(incir));
	while(!incir[now]) {
		incir[now]=1;
		cir[++cir[0]]=now;
		now=p[now];
	}
	if(cir[0]%2==0){
		cout<<"POSSIBLE";
		return 0;
	}
	int maxn=0,minm=n*2;
	for(int i=1;i<=cir[0];++i){
		dfs_sub_tree(cir[i]);
		maxn=max(maxn,f[cir[i]]);
		minm=min(minm,f[cir[i]]);
	}
	if(maxn!=minm){
		cout<<"POSSIBLE";
	}
	else cout<<"IMPOSSIBLE";
}

Measured memory_bytes: 14848
#include <iostream>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <map>
using namespace std;

typedef double D;
const double EPS = 1e-8;

struct P {
  D x, y;
  P() { }
  P(D x_, D y_) : x(x_), y(y_) { }
};

struct C {
  P p;
  D r;
  C() { }
  C(P p_, D r_) : p(p_), r(r_) { }
  C(D x_, D y_, D r_) : p(x_, y_), r(r_) { }
};

int sig(double a, double b) {
  if(a < b - EPS) return -1;
  if(a > b + EPS) return +1;
  return 0;
}

bool iCC(C a, C b) {
  D dx = a.p.x - b.p.x;
  D dy = a.p.y - b.p.y;
  D d2 = dx*dx + dy*dy;
  return sig(d2, (a.r + b.r)*(a.r + b.r)) < 0;
}

int N;
C circle[24];
int color[24];
bool overlap[24][24];

map<int, int> memo;
int solve(int S) {
  if(memo.count(S)) return memo[S];
  int top = 0;
  for(int i = 0; i < N; ++i) {
    if(((S >> i) & 1) == 0) continue;
    bool ok = true;
    for(int j = 0; j < i; ++j) {
      if(((S >> j) & 1) == 0) continue;
      if(overlap[i][j]) {
        ok = false;
        break;
      }
    }
    if(ok) {
      top |= (1 << i);
    }
  }
  int res = 0;
  for(int i = 0; i < N; ++i) {
    for(int j = i + 1; j < N; ++j) {
      if(((top >> i) & 1) && ((top >> j) & 1) && color[i] == color[j]) {
        int B = S;
        B &= ~(1 << i);
        B &= ~(1 << j);
        res = max(res, 2 + solve(B));
      }
    }
  }
  return memo[S] = res;
}

int main() {
  while(true) {
    memo.clear();
    cin >> N;
    if(N == 0) break;
    for(int i = 0; i < 24; ++i)
      for(int j = 0; j < 24; ++j)
        overlap[i][j] = false;
    for(int i = 0; i < N; ++i) {
      cin >> circle[i].p.x >> circle[i].p.y >> circle[i].r >> color[i];
      color[i]--;
    }
    for(int i = 0; i < N; ++i) {
      for(int j = 0; j < i; ++j) {
        if(iCC(circle[i], circle[j])) {
          overlap[i][j] = true;
        }
      }
    }
    cout << solve((1 << N) - 1 ) << endl;
  }
}

Measured memory_bytes: 50384
#include <stdio.h>
 
int main()
{
    int n, a[10000], i, max, min;
    long sum;

    scanf("%d", &n);
    for (i = 0; i < n; i++)
        scanf("%d", &a[i]);

    max = a[0];
    min = a[0];
    sum = 0;

    for (i = 0; i < n; i++) {
        if (a[i] > max)
            max = a[i];
        if (a[i] < min)
            min = a[i];
        sum += a[i];
    }

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

Measured memory_bytes: 636
//IOI 2021

#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define ff first
#define ss second

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

int n, q, L, R;
string s;
vector<pcc> qu;

int bs1() {
	int t = 0;
	bool f = false;
	for (auto i : qu) {
		if (i.ff == s[t]) {
			if (i.ss == 'L')
				t--;
			else
				t++;
		}
		if (t == -1) {
			f = true;
			break;
		}
		if (t == n)
			break;
	}
	if (!f)
		return 0;

	int l = 0, r = n;
	while (l + 1 < r) {
		int mid = (l + r) / 2;
		int tmp = mid;
		bool flag = false;
		for (auto i : qu) {
			if (i.ff == s[tmp]) {
				if (i.ss == 'L')
					tmp--;
				else
					tmp++;
			}
			if (tmp == -1) {
				flag = true;
				break;
			}
			if (tmp == n)
				break;
		}
		if (flag)
			l = mid;
		else
			r = mid;
	}
	return r;
}

int bs2() {
	int t = n - 1;
	bool f = false;
	for (auto i : qu) {
		if (i.ff == s[t]) {
			if (i.ss == 'L')
				t--;
			else
				t++;
		}
		if (t == -1)
			break;
		if (t == n) {
			f = true;
			break;
		}
	}
	if (!f)
		return n - 1;

	int l = -1, r = n - 1;
	while (l + 1 < r) {
		//cerr << "# " << l << " " << r << endl;
		int mid = (l + r) / 2;
		int tmp = mid;
		bool flag = false;
		for (auto i : qu) {
			if (i.ff == s[tmp]) {
				if (i.ss == 'L')
					tmp--;
				else
					tmp++;
			}
			if (tmp == -1)
				break;
			if (tmp == n) {
				flag = true;
				break;
			}
		}
		cerr << "! " << flag << endl;
		if (flag)
			r = mid;
		else
			l = mid;
	}
	return l;
}
int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> q >> s;
	while (q--) {
		char t1, t2;
		cin >> t1 >> t2;
		qu.pb({t1, t2});
	}

	L = bs1();
	R = bs2();
	cerr << L << " " << R << endl;
	cout << R - L + 1 << endl;
	return 0;
}


Measured memory_bytes: 1100
#include <cstdio>
#include <vector>

int main()
{
    int input_size;
    scanf("%d", &input_size);
    std::vector<std::vector<bool> > neighbor_exists(input_size, std::vector<bool>(input_size, false));
    for(int i = 0; i < neighbor_exists.size(); i++) {
        int id, num_neighbors;
        scanf("%d %d", &id, &num_neighbors);
        for(int j = 0; j < num_neighbors; j++) {
            int neighbor_id;
            scanf("%d", &neighbor_id);
            neighbor_exists[id-1][neighbor_id-1] = true;
        }
    }

    for(int i = 0; i < neighbor_exists.size(); i++) {
        if(neighbor_exists[i][0]) {
            putchar('1');
        } else {
            putchar('0');
        }
        for(int j = 1; j < neighbor_exists[i].size(); j++) {
            putchar(' ');
            if(neighbor_exists[i][j]) {
                putchar('1');
            } else {
                putchar('0');
            }
        }
        putchar('\n');
    }
    return 0;
}

Measured memory_bytes: 2696
let N = readLine()!.characters.split(" ").map{Int(String($0))!}[0]
let D = readLine()!.characters.split(" ").map{String($0)}
for i in N..<100000 {
    var flag = false
    for c in D {
        if String(i).characters.contains(Character(c)) {
            flag = false
            break
        } else {
            flag = true
        }
    }
    if flag {
        print(i)
        break
    }
}

Measured memory_bytes: 4208
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll ans=-1;
ll n,m,x;
void dfs(ll h,vector<ll>k,ll sum,vector<vector<ll> >b)
{
    bool f=0;
    for (ll i=0;i<m;i++)
        if (k[i]<x)
    {
        f=1;
        break;
    }
    if (!f)
    {
        if (ans==-1)
            ans=sum;
        ans=min(ans,sum);
        return;
    }
    for (ll i=h;i<n;i++)
    {
        vector<ll>l;
        l=k;
        for (ll j=1;j<=m;j++)
            l[j-1]+=b[i][j];
        dfs(i+1,l,sum+b[i][0],b);
    }
}
int main()
{
 cin>>n>>m>>x;
 vector<vector<ll> >b(n,vector<ll>(m+1));
 for (ll i=0;i<n;i++)
 {
     for (ll j=0;j<m+1;j++)
        cin>>b[i][j];
 }
 vector<ll>k(m);
 dfs(0,k,0,b);
 cout<<ans;
    return 0;
}


Measured memory_bytes: 3656
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;

const int maxn = 100000 + 5;
const int maxm = 300000 + 5;

int n, m, delta[maxm];
int xs[maxm], nx;

int main(void) {
	scanf("%d%d", &n, &m);
	
	for(int i = 0; i < n; ++i) {
		int l, r;
		scanf("%d%d", &l, &r);
		
		nx = 0;
		/*
		xs[nx++] = 0;
		xs[nx++] = l - 1;
		for(int x = 1, y; x <= l - 1; x = y + 1) {
			xs[nx++] = x;
			y = (l - 1) / ((l - 1) / x);
		}
		*/
		int y = sqrt(l - 1 + 0.1);
		for(int x = 0; x <= y; ++x) {
			xs[nx++] = x;
			if(x) xs[nx++] = (l - 1) / x;
		}
		sort(xs, xs + nx);
		nx = unique(xs, xs + nx) - xs;
		
		for(int j = 0; j < nx; ++j) {
			int L, R, x = xs[j];
			L = (l - 1) / (x + 1) + 1;
			R = r / (x + 1);
			if(x) R = min(R, (l - 1) / x);
			++delta[L], --delta[R + 1];
			//printf("x = %d; L = %d; R = %d\n", x, L, R);
		}
	}
	
	for(int i = 1; i <= m; ++i) {
		delta[i] += delta[i - 1];
		printf("%d\n", delta[i]);
	}
}

Measured memory_bytes: 1280
// -----------------------------------
// Author     : MatsuTaku
// Affiliation: Tokushima University
// Country    : Japan
// Date       : 04/08/2020
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  ll n; cin>>n;
  cout << n*(n-1)/2 << endl;

  return 0;
}


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

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

    int k = (n%10);

    if(k == 2|| k == 4 || k == 5 || k == 7 || k == 9){
        cout << "hon" << endl;
    }
    else if (k == 0 || k == 1 || k == 6 || k == 8 )
    {
        cout << "pon" << endl;
    }
    else if (k == 3)
    {
        cout << "bon" << endl;
    }
    
    
    return 0;
}

Measured memory_bytes: 3624
//itp1_8-c
#include <iostream>
#include <vector>
#include <cstdio>
#include <cctype>
using namespace std;

int main(){
 vector<int> cnt(26,0); 
 char ch;
 while(scanf("%c",&ch)!=EOF){
  if(islower(ch)) cnt[int(ch-'a')]+=1;
  else if(isupper(ch)) cnt[int(ch-'A')]+=1;
 }

 for(int i=0;i<26;i++)
  printf("%c : %d\n",i+97,cnt[i]);
 
 return 0;
}

Measured memory_bytes: 1168
import java.util.*;

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


Measured memory_bytes: 23764
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  auto x = readln.chomp.split.to!(int[]);
  auto y = readln.chomp.split.to!(int[]);
  int a, b;
  
  foreach (i; 0..y.length) {
    if (y[i] < x[2]) {
      a++;
    } else {
      b++;
    }
  }
  min(a,b).writeln;
}


Measured memory_bytes: 256
import fractions
import collections

def fact(n):
    c = []
    while n % 2 == 0:
        c.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            c.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        c.append(n)
    return c

a, b = map(int, input().split())
g = fractions.gcd(a, b)
c = collections.Counter(fact(g))

print(len(c)+1)

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

int main(){
    int n, ans1=0, ans2=0, ans3=0, ans4=0;
    string s, ac="AC", wa="WA", tle="TLE", re="RE";
    cin >> n;
    rep(i, n){
        cin >> s;
        if(s==ac)ans1++;
        if(s==wa)ans2++;
        if(s==tle)ans3++;
        if(s==re)ans4++;
    }
    cout << ac << " x " << ans1 << endl;
    cout << wa << " x " << ans2 << endl;
    cout << tle << " x " << ans3 << endl;
    cout << re << " x " << ans4 << endl;
    return 0;
}

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

void dfs(int node, vector<int> adj[], int dp[], bool vis[]) 
{ 
	vis[node] = true; 

	for (int i = 0; i < adj[node].size(); i++) { 

		if (!vis[adj[node][i]]) 
			dfs(adj[node][i], adj, dp, vis); 

		dp[node] = max(dp[node], 1 + dp[adj[node][i]]); 
	} 
} 

void addEdge(vector<int> adj[], int u, int v) 
{ 
	adj[u].push_back(v); 
} 

int findLongestPath(vector<int> adj[], int n) 
{ 
	int dp[n + 1]; 
	memset(dp, 0, sizeof dp); 


	bool vis[n + 1]; 
	memset(vis, false, sizeof vis); 

	for (int i = 1; i <= n; i++) { 
		if (!vis[i]) 
			dfs(i, adj, dp, vis); 
	} 

	int ans = 0; 

	for (int i = 1; i <= n; i++) { 
		ans = max(ans, dp[i]); 
	} 
	return ans; 
} 

int main() 
{ 
	int n,m; 
	cin>>n>>m;
	vector<int> adj[n + 1]; 

	
	while(m--)
	{
		int u,v;
		cin>>u>>v;
	addEdge(adj, u, v); 
	}

	cout << findLongestPath(adj, n); 
	return 0; 
} 


Measured memory_bytes: 9600
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define hi cerr<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1
#define sysp system("pause")
#define PI acos(-1)
#define pf push_front
#define ins insert
#define fh(x,v) for(auto x:v)

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
unsigned XorShift(void){static unsigned x = 123456789;static unsigned y = 362436069;static unsigned z = 521288629;static unsigned w = 88675123;unsigned t;t = x ^ (x << 11);x = y; y = z; z = w;return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

//}

main(){
	int n;cin>>n;
	int x[n],y[n],h[n];
	rep(i,n)cin>>x[i]>>y[i]>>h[i];
	rep(i,101)rep(j,101){
		int tyo;
		rep(k,n)if(h[k])tyo=h[k]+abs(x[k]-i)+abs(y[k]-j);
		int f=1;
		rep(k,n)if(max(tyo-abs(x[k]-i)-abs(y[k]-j),0ll)!=h[k])f=0;
		if(f){
			dump(i,j,tyo);
			return 0;
		}
	}
}





Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s_1, s_2, s_3; cin >> s_1 >> s_2 >> s_3;
    cout << char(toupper(s_1[0])) << char(toupper(s_2[0])) << char(toupper(s_3[0]));
    cout << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long int
#define sci(n) scanf("%lld",&n)
#define pri(n) printf("%lld",n)
#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fl2(i,a,b) for(int i=(a);i<(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)
#define ff first
#define ss second
#define pb push_back
#define mkp make_pair
#define sz size()
#define all(a)  a.begin(), a.end()
#define mem(a, b)     memset(a, b, sizeof(a))
#define nl printf("\n")
#define spc printf(" ")
#define pii pair<int,int>
#define piii pair<pii,int>
#define mii map<int,int>
#define msi map<string,int>
#define mci map<char,int>
#define mss map<string,string>
using namespace std;


int32_t main()
{

//#ifdef ONPC
//    freopen("in.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);
//#endif
    int a,b;
    sci(a);
    sci(b);
    if(a==1 and b==2 || a==2 and b==1)
        printf("3\n");
   else if(a==1 and b==3 || a==3 and b==1)
        printf("2\n");
    else
        printf("1\n");



    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void){
    int n,AC=0,WA=0,TLE=0,RE=0;
    string s;
    cin>>n;
    for(int i=0; i<n; i++){
    cin>>s;
    if(s=="AC"){
        AC++;
    }
    if(s=="WA"){
        WA++;
    }
    if(s=="TLE"){
        TLE++;
    }
    if(s=="RE"){
        RE++;
    }
}
    cout<<"AC x "<<AC<<endl;
    cout<<"WA x "<<WA<<endl;
    cout<<"TLE x "<<TLE<<endl;
    cout<<"RE x "<<RE<<endl;
}

Measured memory_bytes: 3560
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
#include<cstring>

using namespace std;

#ifdef LDEBUG
#define debug(x) cout << #x << ":" << x << endl
#else
#define debug(...)
#endif

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

typedef unsigned long long u64;
typedef long long i64;

int n;
struct e {
        int to;
        int d;
        e(int t, int _d){ to = t; d = _d;}
};
vector<e> g[100005];
int c[100005];

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

        cin >> n;

        REP(i,n) {
                c[i] = -1;
        }

        REP(i,n-1) {
                int a,b,w;
                cin >> a >> b >> w;
                a--;b--;

                g[a].push_back(e(b,w));
                g[b].push_back(e(a,w));
        }

        c[0] = 0;
        queue<int> q;
        q.push(0);
        while (!q.empty()) {
                int p = q.front(); q.pop();

                REP(j, g[p].size()){
                        int to = g[p][j].to;
                        int d = g[p][j].d;

                        if (c[to] != -1)
                                continue;

                        c[to] = (d%2 == 0 ? c[p] : 1-c[p]);
                        q.push(to);
                }
        }

        REP(i,n){
                cout << (char)('0' + c[i]) << endl;
        }


        return 0;
}


Measured memory_bytes: 6784
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i = 0; i < N; i++){
    cin >> a[i];
  }
  int k = a[0],j = 1;
  if(k == 2){
    cout << 1 << endl;
    return 0;
  }
  bool flag = false;
  while(j < N){
    k = a[k - 1];
    j++;
    if(k == 2){
      flag = true;
      break;
    }
  }
  
  if(flag){
    cout << j << endl;
  }else{
    cout << -1 << endl;
  }
  return 0;
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ANS(ans) cout << ans << endl


int main() {
    string s,L,R;
    L = "LUD";
    R = "RUD";
    cin >> s;
    bool flg = true;
    int l = s.length();
    REP(i,l) {
        if(i % 2 == 0) {
            if(s[i] != R[0] && s[i] != L[1] && s[i] != L[2]) flg = false;
        }
        else {
            if(s[i] != L[0] && s[i] != R[1] && s[i] != R[2]) flg = false;
        }
    }
    if(flg) cout << "Yes" << endl;
    else cout << "No" << endl;
}


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

int main() {

    long long a,b,x;
    cin >> a >> b >> x;

    long int div_a = a / x;
    long int div_b = b / x;
    long int sub_ab = div_b - div_a;

    if(a % x == 0 ) sub_ab++;

    
    cout << sub_ab << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdio>
#include<set>
#include<map>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repn(i, n) for(int i = 1; i <= n; i++) 
#define lint long long
#define all(x) (x).begin(), (x).end()

int main(){
    int A,B,C; cin>>A>>B>>C;
    cout<<min(B/A, C)<<endl;
}

Measured memory_bytes: 888
N = int(input())  # 数値入力


def dfs(s):
    # 潜りすぎ防止
    if int(s) > N:
        return 0

    # 7,5,33がすべて含まれていたらret=1
    ret = 1 if all(s.count(c) > 0 for c in "753") else 0

    for c in "753":
        ret += dfs(s + c)  # 潜る

    return ret


print(dfs("0"))


Measured memory_bytes: 2940
import sys
input=sys.stdin.readline

a,b,k=map(int,input().split())

ans=set()
for i in range(k):
	if a+i<=b:
		ans.add(a+i)

for i in range(k):
	if b-i>=a:
		ans.add(b-i)

lists=list(ans)
lists.sort()
for i in lists:
	print(i)

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

#define INF 100000000


int main() {
    
    int n,k,q; cin >> n >> k >> q;
    int sc[n]; 
    for(int i = 0; i < n; i++) sc[i] = k - q;
    for(int i = 0; i < q; i++) {
        int x; cin >> x;
        sc[x-1]++;
    }
    for(int i  = 0; i < n; i++) {
        if(sc[i] > 0) {
            cout << "Yes\n";
        }else {
            cout << "No\n";
        }
    }

    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;
#define N_MAX 100005
typedef long long ll;

int main()
{
	int N,M;
  	cin >> N >> M;
  	pair<ll, int> T[N_MAX];
  	for(int i = 0; i < N; i++){
      	ll A;
      	int B;
    	cin >> A >> B;
      	T[i].first = A;
      	T[i].second = B;
    }
  	sort(T, T+N);
  	ll money = 0;
  	for(int i = 0; i < N; i++){
    	if(M >= T[i].second){
        	M -= T[i].second;
          	money += T[i].first*T[i].second;
        } else {
        	money += T[i].first*M;
			break;
        }
    }
  	cout << money << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];
    rep(i,N){
        if (A[i]%2==0){
            if (A[i]%3!=0&&A[i]%5!=0){
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }
    cout << "APPROVED" << endl;
}

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


def solve(S: str):
    a = {'Sunny': 'Cloudy', 'Cloudy': 'Rainy', 'Rainy': 'Sunny'}
    print(a[S])


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    String s = sc.next();
    int r = 0;
    int b = 0;
    for (int i = 0; i < N; i++) {
      if (s.charAt(i) == 'R') {
        r++;
      } else {
        b++;
      }
    }
    System.out.println(r > b ? "Yes" : "No");
  }
}


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

int main(void) {
  int n, ans = 0;
  long long a[10101];
  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> a[i];
  for (int i = 0; i < n; i++) {
    int cnt = 0;
    while (true) {
      if (!(a[i] & 1)) {
        a[i] /= 2;
        cnt++;
      }
      else
        break;
    }
    ans += cnt;
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
#[macro_use]
mod input {

use std;
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[macro_export]
#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
pub fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
pub fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}
}


use input::*;

use std::cmp;

fn vec_range_sum(v: &Vec<usize>, n: usize) -> usize {
    let to;
    let mut sum = 0;
    if n > v.len() {
        to = v.len();
    } else {
        to = n
    }
    for i in 0..to {
        sum += v[i];
    }
    sum
}

fn main() {
    let (n, w): (usize, usize);
    input!(n, w);
    let mut ans = 0;
    let mut vc = vec![Vec::new(); 4];
    let mut offset = 0;
    for _ in 0..n {
        let (w, v): (usize, usize);
        input!(w, v);
        if offset == 0 {
            offset = w;
        }
        vc[w - offset].push(v);
    }

    for z in &mut vc {
        z.sort();
        z.reverse();
    }

    for i in 0..w + 1 {
        if i * offset > w {
            break;
        }
        for j in 0..w + 1 {
            if i * offset + j * (offset + 1) > w {
                break;
            }
            for k in 0..w + 1 {
                if i * offset + j * (offset + 1) + k * (offset + 2) > w {
                    break;
                }
                for l in 0..w + 1 {
                    if i * offset + j * (offset + 1) + k * (offset + 2) + l * (offset + 3) > w {
                        break;
                    }
                    let mut ans_buf = 0;
                    ans_buf += vec_range_sum(&vc[0], i);
                    ans_buf += vec_range_sum(&vc[1], j);
                    ans_buf += vec_range_sum(&vc[2], k);
                    ans_buf += vec_range_sum(&vc[3], l);
                    ans = cmp::max(ans_buf, ans);
                }
            }
        }
    }
    p(ans);
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

pair<ll,ll> rational(ll cur){
	string cs = to_string(cur);
	const ll cnum = cur;
	ll cden = 0LL;
	for(auto &elem:cs) cden += (elem - '0');
	return make_pair(cnum,cden);
}

void update(auto &ret,auto cur){
	if(cur.first * ret.second < ret.first * cur.second){
		ret = cur;
	}

	if(ret.first * cur.second == cur.first * ret.second and cur.first < ret.first){
		ret = cur;
	}
}

ll f(ll cur){
	auto ret = rational(cur);
	string cs = to_string(cur);

	const int n = cs.size();
	rep(i,n){
		for(char c = cs[i]; c <= '9'; ++c){
			string nxt = cs;
			nxt[i] = c;
			rep(j,i+1,n) nxt[j] = '9';
			auto tar = rational(stoll(nxt));
			//cerr << "Cand: " << nxt << endl;
			update(ret,tar);
		}
	}	
	update(ret,rational(cur));
	return ret.first;
}

int main(void){
	
	int k;
	cin >> k;
	ll cur = 1LL;
	rep(i,k){
		cout << cur << endl;
		cur = f(cur + 1);
	}

	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<bool> db;
template<class T> using vv=vector<vector< T > >;

int n;

int calc(vi lis) {
  int ret = 0;
  int l = lis.size();
  if (lis.empty()) {
    return n;
  }
  ret = max(ret, lis[0]);
  rep (i, l-1) {
    ret = max(ret, lis[i+1] - lis[i] - 1);
  }
  ret = max(ret, n-1 - lis[l-1]);
  return ret;
}

int main() {
  string s;
  cin >> s;
  n = s.length();
  vector<bool> checked(26, false);
  int ans = 1000;
  rep (i, n) {
    char c = s[i];
    if (checked[s[i] - 'a']) {
      continue;
    }
    checked[s[i] - 'a'] = true;
    vi lis = {i};
    FOR (j, i+1, n) {
      if (s[j] == c) {
        lis.push_back(j);
      }
    }
    ans = min(ans, calc(lis));
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 760
#include <cstdio>
#include <vector>

using namespace std;

struct node{
    int key;
    int parent, left, right;
    node(){ parent=-1; left=-1; right=-1; }
};

vector<node> tree;
int root=-1;

void print_pre(int id)
{
    if(id==-1){ return; }
    printf(" %d", tree[id].key);
    print_pre(tree[id].left);
    print_pre(tree[id].right);
}

void print_in(int id)
{
    if(id==-1){ return; }
    print_in(tree[id].left);
    printf(" %d", tree[id].key);
    print_in(tree[id].right);
}

void insert(int z)
{
    int y=-1;
    int x=root;
    while(x!=-1){
        y=x;
        if(tree[z].key<tree[x].key){
            x=tree[x].left;
        } else{
            x=tree[x].right;
        }
    }
    tree[z].parent=y;
    if(y==-1){
        root=z;
    } else if(tree[z].key<tree[y].key){
        tree[y].left=z;
    } else{
        tree[y].right=z;
    }
}

bool find(int key)
{
    int x=root;
    while(x!=-1){
        int k=tree[x].key;
        if(key==k){
            return true;
        } else if(key<k){
            x=tree[x].left;
        } else{
            x=tree[x].right;
        }
    }
    return false;
}

int main()
{
    int m;
    scanf("%d", &m);
    tree=vector<node>(m);
    int n=0;
    for(int i=0; i<m; i++){
        char buf[8]; scanf("%s", buf);
        if(*buf=='i'){
            int k; scanf("%d", &k);
            tree[n].key=k;
            insert(n);
            n++;
        } else if(*buf=='f'){
            int k; scanf("%d", &k);
            printf("%s\n", find(k) ? "yes" : "no");
        } else{
            print_in(root);
            printf("\n");
            print_pre(root);
            printf("\n");
        }
    }
    return 0;
}

Measured memory_bytes: 9948
use std::collections::VecDeque;
fn main() {
    proconio::input! {
        k: usize,
    }
    let mut q:VecDeque<u64> = [1,2,3,4,5,6,7,8,9].iter().map(|&x| x).collect();
    for _ in 0..(k-1) {
        let x = q.remove(0).unwrap();
        if x % 10 != 0 { q.push_back(10*x + (x%10)-1); }
        q.push_back(10*x + (x%10));
        if x % 10 != 9 { q.push_back(10*x + (x%10)+1); }
    }
    println!("{}", q.get(0).unwrap());
}

Measured memory_bytes: 3996
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int d = sc.nextInt();
        int x = sc.nextInt();
        int[] a = new int[n+1];
        a[0] = 0;
        int sum = x;
        for(int i=1;i<=n;i++){
            a[i] = sc.nextInt();
        }
        for(int i=1;i<=n;i++){
            sum += 1+(d-1)/a[i];
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 21844