akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

typedef pair<int,int> pint;
struct edge{
    int dst,weight;
};
vector<edge> road[3001];
int inf=1000000000;

int main(){
    priority_queue<pint,vector<pint>,greater<pint> > pq;
    int n,m,k;
    cin>>n>>m>>k;
    int a,b,l;
    edge ed;
    for(int i=0;i<m;++i){
        cin>>a>>b>>l;
        ed.dst=b-1;ed.weight=l;road[a-1].push_back(ed);
        ed.dst=a-1;ed.weight=l;road[b-1].push_back(ed);
    }
    int d[3001];
    for(int i=0;i<n;++i) d[i]=inf;
    for(int i=0;i<k;++i){
        cin>>a;d[a-1]=0;
        pq.push(make_pair(0,a-1));
    }
    while(!pq.empty()){
        pint pi=pq.top();pq.pop();
        int t=pi.second;
        for(vector<edge>::iterator it=road[t].begin();it!=road[t].end();++it){
            if(d[it->dst]>d[t]+it->weight){
                d[it->dst]=d[t]+it->weight;
                pq.push(make_pair(d[it->dst],it->dst));
            }
        }
    }
    int ans=0;
    for(int i=0;i<n;++i){
        for(int j=0;j<road[i].size();++j){
            if(j!=i&&d[i]!=inf&&d[road[i][j].dst]!=inf){
                ans=max(ans,(d[i]+d[road[i][j].dst]+road[i][j].weight+1)/2);
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 5956
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll a[114514];
ll cnt[50],be[50];
bool f[50];
int main(){
	ll n,k;
	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>a[i];
		ll x=1;
		for(int j=0;j<40;j++){
			if(j)x=x<<1;
			be[j]=x;
			if(a[i]&x)cnt[j]++;
		}
	}
	for(int i=0;i<40;i++)if(cnt[i]>n/2)f[i]=1;
	ll ans=0,num=k+1;
	for(int i=0;i<40;i++){
		ll sum=0,x=be[i];
		if(i){
			if(f[i-1]&&(num&be[i-1]))num-=be[i-1];
			if(!f[i-1]&&!(num&be[i-1]))num+=be[i-1];
		}
		if(!(num&x))continue;
		num-=x;
		for(int j=0;j<n;j++)sum+=(a[j]^num);
		ans=max(sum,ans);
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 4408
import sys, math
from collections import defaultdict
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 1000000007
sys.setrecursionlimit(1000000)

A, B = rl()

if (A+B) % 2 == 1:
	print('IMPOSSIBLE')
else:
	print((A+B)//2)


Measured memory_bytes: 65244
#include<bits/stdc++.h>
    #define ll long long
    #define rep(i,a,b) for(i=a;i<b;i++)
    #define pb push_back
    #define all(v) v.begin(),v.end()
    #define F first
    #define S second
    #define vi vector < ll  int >
    #define CLR(a) memset((a),0,sizeof(a))
    #define mp make_pair
    #define hell 1000000007
    using namespace std;

    #define MAXN 1000005
    int spf[MAXN];
    void sieve()
    {
        spf[1] = 1;
        for (int i=2; i<MAXN; i++)
            spf[i] = i;
        for (int i=4; i<MAXN; i+=2)
            spf[i] = 2;

        for (int i=3; i*i<MAXN; i++)
        {
            if (spf[i] == i)
            {
                for (int j=i*i; j<MAXN; j+=i)

                    if (spf[j]==j)
                        spf[j] = i;
            }
        }
    }


    vector<int> gf(int x)
    {
        vector<int> ret;
        while (x != 1)
        {
            ret.push_back(spf[x]);
            x = x / spf[x];
        }
        return ret;
    }
    int BIT[100050];
    void upd(int x) { ++x;  while(x<=MAXN)  {  BIT[x]++;  x+=(x&-x);  } }
    int cal(int x) {  ++x;  int res=0;  while(x>0)  {  res+=BIT[x];  x-=(x&-x);  } return res; }

    ll mod=hell;
    ll pr( ll x , ll y)
    {
        ll ans=1;
        if(y==0) return ans;
        while(y>1)
        {
            if(y&1) ans*=x;
            x*=x;
            y/=2;
            x%=mod;
            ans%=mod;
        }
        ans*=x;
        ans%=mod;
        return ans;
    }
    ll inv(ll n)
    {
        return pr(n,mod-2);
    }
    ll stoi(string s)
    {
        int n=s.size();
        ll k=0; int i;
        rep(i,0,n)
        {
            k+=s[i]-'0';
            k*=10;
        }
        return k/10;
    }
    string to_string(ll n)
    {  if(!n) return "0";
        string s=""; int a,b;
        while(n>0)
        {
            b=n%10;
            s+=(b+'0');
            n/=10;
        }
        reverse(all(s));
        return s;
    }
  ll invvf[1000500],fact[1000500];
  void pre()
  {
      ll i,j,n=1000050;
      fact[0]=1; fact[1]=1;
      rep(i,2,n) {fact[i]=fact[i-1]*i; fact[i]%=hell;}
      invvf[1]=1; invvf[0]=1;
      rep(i,2,n)
      {
          invvf[i]=inv(fact[i]);
      }

  }
 ll ncr(ll n , ll r)
 {
     ll y=fact[n];
     y*=invvf[r];
     y%=hell;
     y*=invvf[n-r];
     y%=hell;
     return y;
 }


int phi(int n) {
    int result = n;
    for (int i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            while (n % i == 0)
                n /= i;
            result -= result / i;
        }
    }
    if (n > 1)
        result -= result / n;
    return result;
}
    void solve()
    {
    long long  i,j=0,r=200,p,q,k=0,d,y=0,n,h=100000000000000,flag=0,m=0,a=hell,b=hell,id,h1,h2,a1,b1,a2,w,x,u,f,l,c=0,e,ans=0;
    cin>>a>>b>>n;
    if(n>b-1)
    {
        cout<<(a*(b-1))/b;
    }
    else cout<<n*a/b;
    }
    signed main()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        int t=1;
        //sieve();
        //pre();
         // cin>>t;
        solve();
    }


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

int main(){
	long long a, b, c, d;
	long long N;
	cin >> a >> b >> c >> d >> N;
	long long min1 = min(min(a*4,b*2),c);
	long long min2 = min(min(a*8,b*4),min(c*2,d));
	long long ans = (N%2 == 0 ? N*min2/2 : (N-1)*min2/2+min1);
	cout << ans << endl;
	return 0;
} 

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    // Your code here!
  int i,n,j,k;
  int b,f,r,v;
  int count[4][3][10]={0};
  
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
      scanf("%d %d %d %d",&b, &f, &r, &v);
      count[b-1][f-1][r-1]+=v;
  }
  
  for(k=0;k<4;k++){
      for(j=0;j<3;j++){
          for(i=0;i<10;i++){
              printf(" %d",count[k][j][i]);
          }
          printf("\n");
      }
      if(k==3) break;
      printf("####################\n");
  }
  return 0;
}



Measured memory_bytes: 2104
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, h, w;
    cin >> n >> h >> w;
    int x[n + 1];
    for(int i = 0; i < n; i++) cin >> x[i];
    int e = 0;
    for(int i = 0; i < n; i += 2)
    {
        int tmp = x[i] + x[i + 1];
        if(tmp > w) tmp = 2 * w - tmp;
        e += tmp;
    }
    cout << e * h << endl;
    return 0;
}


Measured memory_bytes: 3208
/*	
*  Sachin Mittal
*/
#include<bits/stdc++.h>
#define int long long
#define M 998244353
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define mem0(dp) memset(dp,0,sizeof(dp))
#define mem1(dp) memset(dp,-1,sizeof(dp))
#define pb push_back
#define fr(i,j,n) for(int i=j;i<n;i++)
#define sz(s) (int)(s.size())
using namespace std;
int32_t main(){
ios
int t=1;
//cin>>t;
while(t--)
{
	int k,n;cin>>k>>n;
	vector<int> a(n);
	for(int i=0;i<n;i++)cin>>a[i];
	for(int i=0;i<n;i++)a.pb(k+a[i]);
	int ans=1e18;
	for(int i=0;i<n;i++)
	{
		ans=min(ans,a[i+n-1]-a[i]);
	}
	cout<<ans;
}
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long H,N;
  cin >> H >>N;
  long long P = 0;
  vector<int>A(N);
    for (int i=0; i<N; i++) {
      cin >> A[i];
      P += A[i];
    }
  if (P >= H) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 640
#!/usr/bin/env python3

import math

alpha = 'abcdefghijklmnopqrstuvwxyz'

s = input()
t = input()

if s in t and s != t:
    print('Yes')
    exit()
if s == t:
    print('No')
    exit()
if t in s and s != t:
    print('No')

s = sorted(s)
t = sorted(t,reverse = True)
#print(s,t)

for i in range(min(len(s),len(t))):
    for k in range(26):
        if s[i] == alpha[k]:
            x = k
        if t[i] == alpha[k]:
            y = k
    #print(x,y)
    if x < y:
        print('Yes')
        exit()
    if y < x:
        print('No')
        exit()

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

using namespace std;

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

	int r = 0;
	if (a == 1)
	{
		r = b == 3 ? 2 : 3;
	}
	else if (a == 2)
	{
		r = b == 1 ? 3 : 1;
	}
	else
		r = b == 1 ? 2 : 1;
	printf("%d", r);

	return 0;
}

Measured memory_bytes: 888
N, M, K = gets.split.map(&:to_i)
a = []
b = []
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)
sa = []
sa[0] = 0
sb = []
sb[0] = 0
N.times do |i|
  sa[i+1] = sa[i] + a[i]
end
M.times do |i|
  sb[i+1] = sb[i] + b[i]
end
ans = 0
j = M
(N+1).times do |i|
  break if sa[i] > K
  while sb[j] > K - sa[i]
    j -= 1
  end
  ans = [ans, i+j].max
end
puts ans

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

int main() {
	string o, e;
	cin >> o >> e;

	int n = o.size(), m = e.size();

	for (int i = 0; i < m; i++) {
		cout << o[i] << e[i];
	}
	if (n - m == 1) cout << o[n - 1];
	cout << endl;

	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);
  ll N;
  cin >> N;
  ll ans = 1;
  for(ll i=1;i<N+1;i++)
  {
    ans *= i;
    ans = ans%1000000007;
  }
  cout << ans%1000000007 << endl;
  return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split(" "))

sum_ita = 0
have = [0 for i in range(N)]

for i in range(K):
    d = int(input())
    nyu = list(map(int, input().split(" ")))
    for row in nyu:
        have[row - 1] += 1

print(have.count(0))

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

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

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

using namespace std;

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

int nextInt() {int a; cin >> a; return a;}
char nextChar() {char a; cin >> a; return a;}
double nextDouble() {double a; cin >> a; return a;}
string nextString() {string a; cin >> a; return a;}

void inputVector(vector<int> &v, int &n) {rep(i,n){v.push_back(nextInt());}}
void inputVector(vector<double> &v, int &n) {rep(i,n){v.push_back(nextDouble());}}
void inputVector(vector<string> &v, int &n) {rep(i,n){v.push_back(nextString());}}

class Graph {
private:
	class Edge {
	public:
		int to;
		int cap;
		int rev;
		Edge(int to, int cap, int rev) {
			this->to = to;
			this->cap = cap;
			this->rev = rev;
		}
	};

	int calcFlow(int s, int t, int left) {
		if (s == t) return left;

		visited[s] = true;

		rep(i, nextEdges[s].size()) {
			Edge &edge = nextEdges[s][i];
			if (edge.cap == 0) continue;
			if (visited[edge.to]) continue;
			int flow = calcFlow(edge.to, t, min(left, edge.cap));
			if (flow > 0) {
				edge.cap -= flow;
				nextEdges[edge.to][edge.rev].cap += flow;
				return flow;
			}
		}

		return 0;
	}

	vector<bool> visited;
	vector<vector<Edge>> nextEdges, backUpNextEdges;
public:
	Graph() {}
	Graph(int n) {
		nextEdges.resize(n);
		visited.resize(n);
	}

	void addEdge(int node, int to, int cap) {
		nextEdges[node].push_back(Edge(to, cap, nextEdges[to].size()));
		nextEdges[to].push_back(Edge(node, 0, nextEdges[node].size() - 1));
	}

	int calcMaxFlow(int s, int t) {
		backUpNextEdges = nextEdges;

		int ret = 0;
		while (true) {
			rep(i, nextEdges.size()) visited[i] = false;
			int flow = calcFlow(s, t, INT_MAX);
			if (flow == 0) break;
			ret += flow;
		}

		nextEdges = backUpNextEdges;

		return ret;
	}
};

int gcd(int a, int b) {
	if (a < b) swap(a, b);

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

signed main() {
	int m, n;
	cin >> m >> n;

	while (m > 0) {
		vector<int> b, r;
		inputVector(b, m);
		inputVector(r, n);

		Graph g = Graph(m + n + 2);

		rep(i, m) {
			g.addEdge(0, i + 1, 1);

			rep(j, n) {
				if (gcd(b[i], r[j]) > 1) {
					g.addEdge(i + 1, m + j + 1, 1);
				}
			}
		}
		rep(i, n) {
			g.addEdge(m + i + 1, m + n + 1, 1);
		}

		cout << g.calcMaxFlow(0, m + n + 1) << endl;;

		cin >> m >> n;
	}

    return 0;
}

Measured memory_bytes: 16312
#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define isNum(a) (a>='0'&&a<='9')
#define SP putchar (' ')
#define EL putchar ('\n')
#define inf 2147483647
#define File(a) freopen(a".in", "r", stdin), freopen(a".out", "w", stdout)
template<class T1>inline void read(T1&);
template<class T1>inline void write(T1);
int main () {
    int a, b;
    read(a);
    read(b);
    write(a+b/2);
    EL;
    return 0;
}
template<class T1>void read(T1 &r_e_a_d) {
    T1 k=0;
    char ch=getchar();
    int flag=1;
    while (!isNum(ch)) {
        if (ch=='-') {
            flag=-1;
        }
        ch=getchar();
    }
    while (isNum(ch)) {
        k=(k<<1)+(k<<3)+ch-'0';
        ch=getchar();
    }
    r_e_a_d = flag*k;
}
template<class T1>void write(T1 w_r_i_t_e) {
    if (w_r_i_t_e<0) {
        putchar('-');
        write(-w_r_i_t_e);
    }else {
        if (w_r_i_t_e<10) {
            putchar(w_r_i_t_e+'0');
        }else {
            write(w_r_i_t_e/10);
            putchar((w_r_i_t_e%10)+'0');
        }
    }
}


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

 int main() {
 int n;
 cin >> n;
 vector<int> p(n);
 rep(i, n) cin >> p[i];
 int k = 0;
 rep(i, n) if(p[i] != i + 1) k++;
 if(k <= 2) cout << "YES" << endl;
 else cout << "NO" << endl;
 return 0;
}


Measured memory_bytes: 3588
# import bisect
# from collections import Counter, deque
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
# from operator import attrgetter, itemgetter
# import math

import sys

# import numpy as np

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    l = float(input())
    ll = l/3

    print(pow(ll,3))


if __name__ == '__main__':
    main()


Measured memory_bytes: 39832
var i,n:longint;
    l:array[0..2]of qword;
begin
  readln(n);
  l[0]:=2;
  l[1]:=1;
  for i:=2 to n do
    l[i mod 3]:=l[(i+1)mod 3]+l[(i+2)mod 3];
  writeln(l[n mod 3]);
end.

Measured memory_bytes: 128
#include <stdio.h>          // printf(), scanf()
#include <math.h>           // round()
#include <stdbool.h>

#define N 10

int
main(int argc, char** argv)
{
	int i;

	while (true)
	{
		int d[N];
		int v1;
		int v2;
		int a;

		int t = 0;
		for (i = 0; i < N; ++i)
		{
			if (scanf("%d,", &a) == EOF)
				break;

			t += a;
			d[i] = t;
		}

		if (i < N)
			break;

		scanf("%d,%d", &v1, &v2);
		int v = round(v1 * 100000.0 / (v1 + v2));

		for (i = 0; i < N; ++i)
		{
			d[i] = round(d[i] * 100000.0 / t);
			if (v <= d[i])
			{
				printf("%d\n", i + 1);
				break;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 608
#include<iostream>
#include<complex>

typedef std::complex<double> P;

const double EPS = 1e-10;

double dot( const P& a, const P& b )
{
	return std::real( std::conj( a ) * b );
}

double cross( const P& a, const P& b )
{
	return std::imag( std::conj( a ) * b );
}

// 線分abと点cの距離
double dist( const P& a, const P& b, const P& c )
{
	if( dot( b - a, c - a ) < EPS )
		return abs( c - a );
	if( dot( a - b, c - b ) < EPS )
		return abs( c - b );

	return abs( cross( b - a, c - a ) ) / abs( b - a );
}

int n;
P wpt[100];
double r[100];

std::istream& operator>> ( std::istream& in, P& p )
{
	if( in )
	{
		double x, y;
		in >> x >> y;
		p = P( x, y );
	}

	return in;
}

int main()
{
	while( std::cin >> n, n )
	{
		for( int i = 0; i != n; ++i )
			std::cin >> wpt[i] >> r[i];

		int m;
		std::cin >> m;
		for( int i = 0; i != m; ++i )
		{
			P s, t;
			std::cin >> s >> t;

			for( int j = 0; j != n; ++j )
			{
				if( !( abs( s - wpt[j] ) < r[j] && abs( t - wpt[j] ) < r[j] ) && dist( s, t, wpt[j] ) <= r[j] )
				{
					std::cout << "Safe" << std::endl;
					break;
				}
				else if( j == n - 1 )
					std::cout << "Danger" << std::endl;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 1252
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;

int main()
{
	int N, M;

	cin >> N >> M;
	vector<pair<long long int, long long int> > n(N);
	vector<pair<long long int, long long int> > m(M);

    for (int i = 0; i < N; i++) {
        cin >> n[i].first >> n[i].second;
    }
    for (int i = 0; i < M; i++) {
        cin >> m[i].first >> m[i].second;
    }

    for (int i = 0; i < N; i++) {
        int mini = mod, num, len;
        for (int j = 0; j < M; j++) {
            len = abs(n[i].first-m[j].first)+abs(n[i].second-m[j].second);
            if (len < mini) {
                num = j;
                mini = len;
            }
        }
        cout << num+1 << endl;
    }

	return 0;
}


Measured memory_bytes: 256
import re
import sys
s = re.findall('[a-z]', sys.stdin.read().lower())
letters = 'abcdefghijklmnopqrstuvwxyz'
cnt = [0]*26
for i in s:
    point = 0
    for j in letters:
        if i == j:
            cnt[point] += 1
            break
        point += 1
for i in range(26):
    print('%s : %d'%(letters[i], cnt[i]))


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

def dfs(v, N, visited):
  for i in range(1,N+1):
    if not visited[i]: break
    # すでに全て到達済みだったら
    if i == N: return 1

  ret = 0
  for i in range(1, N+1):
    if not graph[v][i]: continue
    if visited[i]: continue

    visited[i] = 1
    ret += dfs(i, N, visited)
    visited[i] = 0

  return ret

N,M = map(int, input().split())

graph = [[0]*(N+1) for i in range(N+1)]

for _ in range(0,M):
  a,b = map(int, input().split())
  graph[a][b] = 1
  graph[b][a] = 1

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

visited[1] = 1
print(dfs(1, N, visited))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define int long long
int32_t main()
{
	int n, ai;
	cin>>n;
	int cnt[5]={};
	for (int i = 0; i < n; ++i)
	{
		cin>>ai;
		cnt[ai]++;
	}
	double dp[305][305][305]={};
	for(int k=0; k<=n; ++k)
	{
	    for(int j=0; j<=n; ++j)
	    {
	        for(int i=0; i<=n; ++i)
	        {
	            if(i+j+k)
	                dp[i][j][k]+=n;
	            if(k)
	                dp[i][j][k]+=k*dp[i][j+1][k-1];
	            if(j)
	                dp[i][j][k]+=j*dp[i+1][j-1][k];
	            if(i)
	                dp[i][j][k]+=i*dp[i-1][j][k];
	            if(i+j+k)
	                dp[i][j][k]=(double)dp[i][j][k]/(i+j+k);
	           // dp[i][j][k]=k*(1+dp[i][j+1][k-1]) + j*(1+dp[i+1][j-1][k]) + i*(1+dp[i-1][j][k]);
	        }
	    }
	}
	printf("%.9f",dp[cnt[1]][cnt[2]][cnt[3]]);
}

Measured memory_bytes: 221952
#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(a) ((a).begin(), (a).end())
typedef long long ll;
const long long INF = 1LL << 60;
// const int INF=1010101010;
// using Graph = vector<vector<int>>;

vector<long long> P(55);  //パティの枚数
vector<long long> N(55);  //レベル

ll rec(int i, ll x) {
  if (i == 0)
    return x;
  else if (x == 0 || x == 1)
    return 0;
  else if (x == N[i])
    return P[i];
  else if (x <= N[i - 1] + 1)
    return rec(i - 1, x - 1);
  else if (x <= N[i] - 1)
    return 1 + P[i - 1] + rec(i - 1, x - 2 - N[i - 1]);
  else
    return 0;
}

int main() {
  int n;
  long long x;
  cin >> n >> x;
  N[0] = 1;
  P[0] = 1;
  for (int i = 0; i < n; i++) {
    N[i + 1] = 3 + 2 * N[i];
    P[i + 1] = 1 + 2 * P[i];
  }
  cout << rec(n, x) << endl;
}

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

typedef long long 		ll;
typedef vector<ll> 		vll;
typedef pair<ll,ll> 	pll;
typedef vector<pll> 	vpll;
typedef vector<int> 	vi;
typedef pair<int,int> 	pii;
typedef vector<pii> 	vpii;

#define fi				first
#define se 				second
#define pb 				push_back
#define mp 				make_pair
#define all(v)			v.begin(),v.end()
#define sz(v)			s.size()
#define rep(i,a,b) 		for(int i=a;i<=b;i++)
#define per(i,a,b) 		for(int i=a;i>=b;i--)
#define fill(a,v)		memset(a,v,sizeof(a))
#define tc				int T;cin>>T;while(T--)
#define nl				printf("\n")
#define aya				cerr<<"yaha aya"<<"\n"
#define debug(x,y)		printf("%d %d\n",x,y)
#define fast_io			ios_base::sync_with_stdio(false);cin.tie(NULL);
#define grt				greater<int>()

const int mod = 1e9+7;
const int mod2= 1e9+9;

inline int pow_(ll a, int n, int p=mod){
	int r=1;while(n){if(n&1)r=r*a%p;n>>=1;a=a*a%p;}return r;
}

const int MAX = 1e5+1;
const int LG = 30+1;

int main(void)
{
	int n;cin>>n;
	ll ans = 0;
	ll tot = 0;
	ll d[n];
	rep(i,0,n-1) cin>>d[i];
	rep(i,0,n-1) tot += d[i];
	rep(i,0,n-1)
	{
		tot -= d[i];
		ans += d[i]*tot;
	}
	cout<<ans<<"\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector<int> fail(string s)
{
    vector<int> f(s.size());
    f[0] = 0;
    for(int i=1; i<(int)s.size(); ++i)
    {
        int t = f[i-1];
        while(s[t] != s[i])
        {
            if(t==0) break;
            t = f[t-1];
        }
        if(s[t] == s[i]) f[i] = t+1;
        else f[i] = 0;
    }
    return f;
}
int main()
{
    string s; cin >> s;
    bool flag = true;
    for(int i=0; i<(int)s.size(); ++i)
        if(s[0] != s[i])
        {
            flag = false; 
            break;
        }
    if(flag)
    {
        printf("%d\n%d\n", (int)s.size(), 1);
        return 0;
    }
    else
    {
        vector<int> x = fail(s);
        if(x[s.size()-1] == 0 || (int)s.size()%((int)s.size() - x[s.size()-1]) != 0)
        {
            printf("%d\n%d\n", 1, 1);
            return 0;
        }
        reverse(s.begin(), s.end());
        vector<int> y = fail(s);
        int cnt = 0;
        for(int i=1; i<s.size(); ++i)
        {
            int j = s.size() - i;
            bool xpos = x[i-1] == 0 || i%(i-x[i-1]) != 0;
            bool ypos = y[j-1] == 0 || j%(j-y[j-1]) != 0;
            if(xpos && ypos) ++cnt;
        }
        printf("%d\n%d\n", 2, cnt);
    }
}




Measured memory_bytes: 5144
//_nebula_
#include<bits/stdc++.h>
using namespace std;
#define int long  long
#define double long double
int t;
const int M=1e9+7;
const int inf=INT64_MAX;
int factt(int n){
    int ans=1;
    for(int i=1;i<=n;i++){
        ans*=i;
        ans=ans%M;
    }
    return ans;
}
int max(int a,int b,int c){
    return max(a,max(b,c));
}
int min(int a,int b,int c){
    return min(a,min(b,c));
}
int fspow(int x,int y){
    int ans;
    if(y==0) return 1;
    ans=fspow(x, y/2);
    if(y%2==0) return (ans*ans);
    return x*ans*ans;
}
int gcd(int x,int y){
    if(x<y) swap(x,y);
    if(y==0) return x;
    return gcd(x%y,y);
}
int p2(int x){
    int ans=0;
    while(x>=1){
        ans++;
        x/=2;
    }
    return ans;
}
signed main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    t=1;
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
   //  cin>>t;
    //int tmp=t;
    while(t--){
        int a,b,c,d;
        cin>>a>>b>>c>>d;
        int ans=-inf;
        ans=max(ans,a*c);
        ans=max(ans,a*d);
        ans=max(ans,b*c);
        ans=max(ans,b*d);
        cout<<ans<<"\n";
    }
}


Measured memory_bytes: 3644
#include <stdio.h>
#include <string.h>
#define mod 1000000007

typedef long long ll;

int main(void) {
  int n, i, j, k, m;
  char t[1200], b[1200];
  scanf("%s", t);
  scanf("%s", b);
  n = strlen(t), m = strlen(b);
  ll dp[m][n], sum[n];
  for(i = 0; i < m; ++i) for(j = 0; j < n; ++j) dp[i][j] = 0;
  for(i = 0; i < n; ++i) if(t[i] == b[0]) dp[0][i] = 1;
  sum[0] = dp[0][0];
  for(i = 1; i < n; ++i) sum[i] = sum[i - 1] + dp[0][i];
  for(i = 1; i < m; ++i) {
    for(j = 0; j < n; ++j) {
      if(b[i] == t[j]) {
        if(j)dp[i][j] = sum[j - 1];
        else dp[i][j] = 0;
      }
    }
    sum[0] = dp[i][0];
    for(j = 1; j < n; ++j) {
      sum[j] = sum[j - 1] + dp[i][j];
      sum[j] %= mod;
    }
  }
  ll ans = 0;
  for(i = 0; i < n; ++i) {
     ans += dp[m - 1][i];
     ans %= mod;
  }
  /*for(i = 0; i < m; ++i) {
    for(j = 0; j < n;++j) printf("%d ", dp[i][j]);
    printf("\n");
  }*/
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 10496
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define inf 1e9
#define mod 1000000007
#define endl "\n"


void solve()
{
	int a,b;
    cin>>a>>b;
    cout<<a*b;

}

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


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

int main() {
  int N,K;
  cin>>N>>K;
  std::vector<int> v(N+1,0);
  int k;
  int a=0;
  for(int i=0;i<N;i++){
    cin>>k;
    if(v[k]==0)a++;
    v[k]++;
  }
  int ans=0;
  sort(v.begin(),v.end());
  int l=0;
  for(int i=0;K<a-l;i++){
    if(v[i]!=0){
      ans+=v[i];
      l++;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
int main() {
	string s, p; cin >> s >> p;
	s += s;
	rep(i, s.size() - p.size() + 1) {
		if (s.substr(i, p.size()) == p) {
			puts("Yes");return 0;
		}
	}
	puts("No");
}


Measured memory_bytes: 3176
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;

int main() {
  int n, d, x;
  cin >> n >> d >> x;
  vector<vector<int>> p(d, vector<int>(n));
  for (int i = 0; i < d; i++) {
    for (int j = 0; j < n; j++) {
      cin >> p[i][j];
    }
  }
  for (int i = 0; i < d - 1; i++) {
    vector<int> dp(x + 1);
    for (int j = 0; j < x + 1; j++) dp[j] = j;
    for (int j = 0; j < n; j++) {
      for (int k = 0; k < x + 1; k++) {
        if (k < p[i][j]) continue;
        dp[k] = max(dp[k], dp[k - p[i][j]] + p[i + 1][j]);
      }
    }
    int m = 0;
    for (int j = 0; j < x + 1; j++) m = max(m, dp[j]);
    x = m;
  }
  cout << x << endl;
}



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

int main() {
  int n, k, x, y;
  cin >> n >> k >> x >> y;
  
  if(k>n){
    cout << x*n << endl;
  }
  
  else{
    cout << x*k+y*(n-k) << endl;
  }
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<cassert>
#include<ctime>
#define cmin(a,b) (a>(b)?a=(b),1:0)
#define cmax(a,b) (a<(b)?a=(b),1:0)
#define dmin(a,b) ((a)<(b)?(a):(b))
#define dmax(a,b) ((a)>(b)?(a):(b))
namespace io
{
	int F()
	{
		int n=0,F=1;
		char ch;
		while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		ch=='-'?F=0:n=ch-'0';
		while((ch=getchar())>='0'&&ch<='9')n=n*10+ch-'0';
		return F?n:-n;
	}
}
const int M=1000000007;
int li[22];
int fr[22];
int f[133333];
int r0[133333];
int pc[266666];
int b3[133333];
int v[133333],pv;
int g[44444444];
int h[133333];
int ex2[333];
int lg[133333];
int fu[133333];
int main()
{
	int n=io::F(),m=io::F();
	for(register int i=1;i<=m;++i)
	{
		int x=n-io::F(),y=n-io::F();
		li[x]|=1<<y;
		fr[y]|=1<<x;
	}
	for(register int i=2;i<1<<n;++i)lg[i]=lg[i>>1]+1;
	ex2[0]=1l;
	for(register int i=1;i<=300;++i)ex2[i]=(ex2[i-1]<<1)%M;
	for(register int i=0;i<1<<n-1;++i)
		if(!(i&1))r0[i]=1;
			else r0[i]=r0[i>>1]<<1;
	for(register int i=1;i<1<<n;++i)pc[i]=pc[i^i&-i]+1;
	for(register int i=1;i<1<<n-1;++i)b3[i]=i&1?b3[i-1]+1:b3[i>>1]*3;
	for(register int i=1;i<1<<n-1;++i)fu[i]=i&1<<n-2?i|1<<n-1:i;
	f[0]=1;
	for(register int i=0;i<1<<n-1;++i)
		if(f[i])
		{
			pv=0;
			for(register int j=(1<<n-1)-1&~i;j;j=(j-1)&~i)if(j&r0[i])v[++pv]=j;
			for(register int* j=v+pv;j!=v;--j)
			{
				int now=*j^r0[i];
				now=now&-now;
				if(*j==r0[i])h[*j]=pc[fr[lg[r0[i]]]&fu[i]];
					else h[*j]=h[*j^now]+pc[fr[lg[now]]&fu[i]];
				int tmp=ex2[h[*j]];
				for(register int k=n-1;k>lg[r0[i]];--k)
					if(~fu[i|*j]&1<<k)tmp=(long long)tmp*(ex2[pc[li[k]&(fu[*j])]]-1)%M;
				f[i|*j]=(f[i|*j]+(long long)f[i]*tmp)%M;
			}
		}
	printf("%d\n",(ex2[m]+M-f[(1<<n-1)-1])%M);
	return 0;
}

Measured memory_bytes: 4480
N, Q = map(int, input().split())
S = input()
LR = [[int(i) for i in input().split()] for i in range(Q)]
pre = [0]*(N+1)
for i in range(N):
  pre[i+1] = pre[i] + (1 if S[i:i+2] == 'AC' else 0)
for a in LR:
  print(pre[a[1]-1] - pre[a[0]-1])

Measured memory_bytes: 26068
#include <bits/stdc++.h>
using namespace std;
vector <int> V;
int main(){
	int n; cin>>n;
	for(int i = 0; i < n; i ++){
		int x; cin>>x;
		V.push_back(x);
	}
	sort(V.begin(), V.end());
	for(int i = 0; i < n-1; i ++){
		if(V[i] == V[i+1]){
			cout << "NO\n";
			return 0;
		}
	}
	cout << "YES\n";
}

Measured memory_bytes: 1400
import sys
S = input()

if not (S[0] == "A" and "C" in S[2:len(S)-1]):
    print("WA")
    sys.exit()

S = sorted(S)

if not S[1] == "C":
    print("WA")
    sys.exit()

if not "a" <= S[2] <= "z":
    print("WA")
    sys.exit()

print("AC")

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

string to_string(string s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

template <uint32_t mod>
class Modular {
private:
  uint32_t n;

public:
  Modular(int64_t _n = 0) : n((_n >= 0 ? _n : mod - (-_n) % mod) % mod) {}

  uint32_t get() const {
    return n;
  }

  bool operator ==(const Modular& o) const {
    return n == o.n;
  }

  bool operator !=(const Modular& o) const {
    return n != o.n;
  }

  Modular& operator +=(const Modular& o) {
    n += o.n;
    n = (n < mod ? n : n - mod);
    return *this; 
  }

  Modular& operator -=(const Modular& o) {
    n += mod - o.n;
    n = (n < mod ? n : n - mod);
    return *this;
  }

  Modular& operator *=(const Modular& o) {
    n = uint64_t(n) * o.n % mod;
    return *this;
  }

  Modular& operator /=(const Modular& o) {
    return (*this) *= o.inv();
  }

  Modular operator +(const Modular& o) const {
    return Modular(*this) += o;
  }

  Modular operator -(const Modular& o) const {
    return Modular(*this) -= o;
  }

  Modular operator *(const Modular& o) const {
    return Modular(*this) *= o;
  }

  Modular operator /(const Modular& o) const {
    return Modular(*this) /= o;
  }

  Modular pow(uint64_t b) const {
    Modular ans(1), m = Modular(*this);
    while (b) {
      if (b & 1) {
        ans *= m;
      }
      m *= m;
      b >>= 1;
    }
    return ans;
  }

  Modular inv() const {
    int32_t a = n, b = mod, u = 0, v = 1;
    while (a) {
      int32_t t = b / a;
      b -= t * a;
      swap(a, b);
      u -= t * v;
      swap(u, v);
    }
    assert(b == 1);
    return Modular(u);
  }
};

using Mint = Modular<int(1e9 + 7)>;

void test_case() {
  int n, k;
  cin >> n >> k;
  vector<vector<int>> G(n + 1);
  for (int i = 1; i < n; ++i) {
    int u, v;
    cin >> u >> v;
    G[u].emplace_back(v);
    G[v].emplace_back(u);
  }
  vector<Mint> ways(n + 1);
  function<void(int, int)> dfs = [&](int u, int p) {
    int st = k - 1 - (p != 0);
    for (auto v : G[u]) {
      if (v != p) {
        ways[v] = st--;
        dfs(v, u);
      }
    }
  };
  ways[1] = k;
  dfs(1, 0);
  Mint res = 1;
  for (int i = 1; i <= n; ++i) {
    res *= ways[i];
    if ((int) G[i].size() + 1 > k) {
      res *= 0;
    }
  }
  cout << res.get() << "\n";
}

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


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

using namespace std;
typedef pair<int,int> pii;
typedef long long int ll;

#define INF 1 << 29
#define REP(i,n) for(ll i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(ll i=(k);i<(int)(n);i++)



vector<bool> gen_sosuu(vector<bool> sosuu){
  int size = sosuu.size();
  REP(i,size){
    sosuu[i] = true;
  }
  sosuu[0] = false;
  sosuu[1] = false;
  sosuu[2] = true;
  FOR(i,2,sqrt(size)+1){
    if(sosuu[i] == false) continue;
    for(int j = 2; i*j<size;j++){
      sosuu[i*j] =false;
    }
  }
  return sosuu;
}

int l;
string n;
bool num[10] = {false};

bool ok(string s){
  REP(i,s.size()){
    int a = s[i]-'0';
    if(num[a]==false) return false;
  }
  return true;
}

int main(){
  cin >> n >> l;
  REP(i,10){
    num[i] = true;
  }
  REP(i,l){
    int a;
    cin >> a;
    num[a] = false;
  }
  FOR(i,stoi(n),100000){
    if(ok(to_string(i))){
      cout << i << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		new Main().run();
	}
	public void run(){
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			int n = scan.nextInt();
			int k = scan.nextInt();
			if(n == 0 && k == 0){
				break;
			}
			boolean[] card = new boolean[n];
			boolean zero = false;
			int t = 0;
			for(int i = 0;i < k;i++){
				t = scan.nextInt();
				if(t == 0){
					zero = true;
					continue;
				}
				card[t-1] = true;
			}
			int max = 0;
			int flag = 0;
			for(int i = 0;i < n;i++){
				if(!card[i]){
					continue;
				}
				t = 1;
				flag = 0;
				for(int j = 1;i+j < n && ((!zero && flag < 1) || (zero && flag < 2));j++){
					t++;
					if(!card[i+j]){
						flag++;
					}
				}
				if(zero && flag > 0){
					flag -= 1;
				}
				max = Math.max(max,t-flag);
			}
			max = Math.max(max,t);
			System.out.println(max);
		}
	}
}

Measured memory_bytes: 62212
using System;
using System.Collections.Generic;
using System.Linq;
class Program
    {
        static void Main(string[] args)
        {   
            int n = int.Parse(Console.ReadLine());
            string[] s1 = Console.ReadLine().Split(' ');
            int ga = int.Parse(s1[0]), sa = int.Parse(s1[1]), ba = int.Parse(s1[2]);
            string[] s2 = Console.ReadLine().Split(' ');
            int gb = int.Parse(s2[0]), sb = int.Parse(s2[1]), bb = int.Parse(s2[2]);

            long donguri = 0;
            for (int i=0; i*ga<=n; i++)
            {
                if (ga >= gb && i > 0) break;
                for (int j=0; i*ga + j*sa <= n; j++)
                {
                    if (sa >= sb && j > 0) break;
                    int k = 0;
                    if (ba < bb) k = (n - ga * i - sa * j) / ba; 
                    donguri = Math.Max (donguri, (gb - ga) * i + (sb - sa) * j + (bb - ba) * k);
                }
            }
            n += (int)donguri;
            Console.Error.WriteLine(n);
            donguri = 0;
            for (long i=0; i*gb<=n; i++)
            {
                if (gb >= ga && i > 0) break;
                if (1.0 * ga / gb <= 1.0 * sa / sb && i > sb) break;

                for (long j=0; i*gb + j*sb <= n; j++)
                {
                    if (sb >= sa && j > 0) break;
                    if (1.0 * ga / gb >= 1.0 * sa / sb && j > gb) break;
                    //Console.Error.WriteLine(i + " " + j);
                    long k = 0;
                    if (bb < ba) k = (n - gb * i - sb * j) / bb; 
                    donguri = Math.Max (donguri, (ga - gb) * i + (sa - sb) * j + (ba - bb) * k);
                }
            }
            Console.WriteLine((long)n + donguri);
            
            
        }
    }
    //mcs Main.cs
    //mono Main.exe

Measured memory_bytes: 13140
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		while(in.hasNext()){
			int n = in.nextInt();
			int ans = 0;
			for(int a=0; a<10; a++){
				for(int b=0; b<10; b++){
					for(int c=0; c<10; c++){
						if(n-a-b-c>=0 && n-a-b-c<10) ans++;
					}
				}
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 12000
N, Q = map(int, input().split())
S = list(input())
lr = []
for i in range(Q):
    l, r = map(int, input().split())
    lr.append([l-1, r-1])
AC = []
pre = None
cnt = 0
for c in S:
    if c == "A":
        pre = "A"
    elif pre == "A" and c == "C":
        cnt += 1
        pre = None
    elif pre == "A":
        pre = None
    AC.append(cnt)
for l, r in lr:
    print(AC[r] - AC[l])




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

class Work():
    """ 仕事クラス """
    def __init__(self, a, b):
        self.need_time = a  # 仕事を終わらせるのに必要な時間
        self.deadline = b   # 締切時刻


def solve():
    N = int(input())

    works = []  # 仕事をリストにぶちこむ
    for _ in range(N):
        a, b = list(map(int, input().split()))
        works.append(Work(a, b))
    works.sort(key=lambda x: x.deadline)  # 締切が早い順にソート

    # 締切が早いやつから先に仕事を終らせる貪欲法
    now_time = 0  # 現在時刻
    for i in range(N):
        now_time += works[i].need_time
        if now_time > works[i].deadline:
            print("No")
            return
    print("Yes")



if __name__ == "__main__":
    solve()

Measured memory_bytes: 64820
#!/usr/bin/python
# -*- coding: utf-8 -*-

# def
def int_mtx(N):
    x = []
    for _ in range(N):
        x.append(list(map(int,input().split())))
    return x

def str_mtx(N):
    x = []
    for _ in range(N):
        x.append(list(input()))
    return x

def int_map():
    return map(int,input().split())

def int_list():
    return list(map(int,input().split()))

def print_space(l):
    return print(" ".join([str(x) for x in l]))

# import
import numpy as np



# main code
N = int(input())
A = int_list()

ans = 0

if N == 1:
    print(0)
    exit()

now = A[0]

for i in range(1,N):
    if now > A[i]:
        ans += now-A[i]
    else:
        now = A[i]

print(ans)





Measured memory_bytes: 50864
public class Main {
	public static void main(String[] args){
		java.util.Scanner scan = new java.util.Scanner(System.in);
		int x = scan.nextInt();
		for(int i = 1;i <= x; i++){
			if(i % 3 == 0){
				System.out.print(" " + i);
			}else if(i % 10 == 3){
				System.out.print(" " + i);
			}else if(String.valueOf(i).contains("3")){
				System.out.print(" " + i);
			}
		}
		System.out.println();
	}

}

Measured memory_bytes: 29252
#pragma region kyomukyomupurin

/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-04-21 16:00:36
 **/

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

using int64 = long long;

template <class T>
using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int flag = 0;
  for (auto e : vec) os << (flag++ ? ", " : "{") << e;
  return os << '}';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int flag = 0;
  for (auto e : st) os << (flag++ ? ", " : "{") << e;
  return os << '}';
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int flag = 0;
  for (auto e : mp) os << (flag++ ? ", " : "{") << e;
  return os << '}';
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

#pragma endregion kyomukyomupurin

template<class _Tp>
std::map<_Tp, int> prime_fact(_Tp n){
  std::map<_Tp, int> result;
  for (_Tp i = 2; i * i <= n; ++i){
    if (n % i != 0) continue;
    int cnt = 0;
    while (n % i == 0){
      n /= i; ++cnt;
    }
    result[i] = cnt;
  }
  if (n != 1) result[n] = 1;
  return result;
}

template<class _Tp>
_Tp Totient(_Tp n) {
  _Tp res = n;
  for (_Tp i = 2; i * i <= n; ++i) {
    if (n % i != 0) continue;
    (res /= i) *= (i - 1);
    while (n % i == 0) n /= i;
  }
  if (n != 1) (res /= n) *= (n - 1);
  return res;
}

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

  int64 n; cin >> n;
  // euler's phi function
  // phi(n) = n * (1 - 1 / p1) * (1 - 1 / p2) * ... * (1 - 1 / pk)

  cout << Totient(n) << endl;

  return 0;
}


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i < n + 1; i++)
#define repr(i, n) for (int i = n - 1; i >= 0; i--)
#define repr1(i, n) for (int i = n; i > 0; i--)
#define FOR(i, j, n) for (int i = j; i < n; i++)

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

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

    int64_t sumf=0,sumb=0,sum=0;

    rep(i,n+1){
        sumf += i;
        sumb += n-i;

        if(i >= k-1){
            sum += sumb-sumf+1;
        }

    }

    cout << sum % 1000000007 << endl;

}

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

// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
  
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

#define ll long long
#define fill fill_n
#define pf push_front
#define pb push_back
#define FOR(i,l,r) for(int i=l;i<r;i++)
#define ROF(i,r,l) for(int i=r;i>=l;i--)
#define comp(v) (v).begin(),(v).end()
#define ff first
#define ss second
#define infile freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
typedef vector<int> vi;
typedef vector<ll> vli;
typedef vector<pair<int,int>> vpi;

const int M = 1e9+7;
const int N = 2e5;
ll po(int,int);


void solve(){
    string s,t;
    cin>>s>>t;
    int ns=s.length();
    int nt=t.length();
    int ans=nt;
    FOR(i,0,ns-nt+1){
        int c=0;
        FOR(j,i,i+nt){
            if(s[j]!=t[j-i]) c++;
        }
        ans=min(ans,c);
    }
    cout<<ans<<"\n";
    
    
}





int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    int t=1;
    //cin>>t;
    FOR(i,1,t+1){
        //cout<<"Case #"<<i<<": "; 
        solve();
    }
    
	return 0;
	
	
}


ll po(int a,int b){
    if(b==0) return 1;
    ll ans=1;
    if(b%2==0){
        ans = po(a,b/2)%M;
        ans=(ans%M * ans%M)%M;
    }
    else{
        ans = po(a,(b-1)/2)%M;
        ans = (ans%M * ans%M * a)%M;
    }
    return ans%M;
}


Measured memory_bytes: 3648
#include<iostream>
#include<string>

using namespace std;

string s;

bool is_ok()
{
    if (s[0] == 'Y' && s[1] == 'A' && s[2] == 'K' && s[3] == 'I') return true;
    return false;
}

int main()
{
    cin >> s;
    if (is_ok()) cout << "Yes" << endl;
    else cout << "No\n";
    return 0;
}

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

string s;

LL nc2(LL n) {
  return n * (n - 1) / 2;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin >> s;
  vector<LL> cnt(26, 0);
  for(int i = 0; i < s.size(); i++) {
    cnt[s[i] - 'a']++;
  }
  LL res = 1 + nc2(s.size());
  for(LL x: cnt) {
    res -= nc2(x);
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 720
#include<utility>
#include<algorithm>
#include<vector>
#include<queue>
#include<iostream>
#include<functional>

using namespace std;
typedef long long ll;

struct edge {
	int to, cost;
	edge(const int &_to, const int &_cost) :to(_to), cost(_cost) {}
	edge(const edge &e) :to(e.to), cost(e.cost) {}
};
bool operator< (const edge& l, const edge &r) { return (l.cost < r.cost); }
bool operator> (const edge& l, const edge &r) { return (l.cost > r.cost); }

int V;
vector<vector<edge>> G(10000);
vector<bool> used(10000);
priority_queue <edge, vector<edge>, greater<vector<edge>::value_type>> que;

double prim(int s) {
	double res = 0;
	used[s] = true;
	for (int i = 0; i < G[s].size(); ++i)que.emplace(G[s][i]);
	while (!que.empty()) {
		edge e = que.top(); que.pop();
		if (used[e.to])continue;
		res += e.cost;
		used[e.to] = true;
		for (int i = 0; i < G[e.to].size(); ++i) {
			if (!used[G[e.to][i].to])
				que.emplace(G[e.to][i]);
		}
	}
	return res;
}

int main()
{
	cin.tie(0);
	ios::ios_base::sync_with_stdio(false);
	int E;
	cin >> V >> E;
	int s, t, w;
	for (int i = 0; i < E; ++i) {
		cin >> s >> t >> w;
		G[s].emplace_back(edge(t, w));
		G[t].emplace_back(edge(s, w));
	}
	int ans = prim(0);
	cout << ans << endl;
}

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

int N,m,n,a,b,c,pi,result[30];
string A,B;
int S[1510][1510];

int main(){
//	cin >> N;
    N =1;
	for(int i=0;i<N;i++){
		cin >> A >> B;
		m = A.length();
		n = B.length();
		
		for(int j=0;j<=n;j++)
			S[0][j] = j;
		for(int j=0;j<=m;j++)
			S[j][0] = j;
			
		for(int j=1;j<=m;j++)
			for(int k=1;k<=n;k++) {
				if(A[j-1]==B[k-1])
					pi = 0;
				else 
					pi = 1;
					
				a = S[j-1][k]+1;
				b = S[j][k-1]+1;
				c = S[j-1][k-1]+pi;	
				S[j][k] = min(min(a,b),c);
			}
		result[i] = S[m][n];
	}
	
	for(int i=0;i<N;i++)
		cout << result[i] << endl;
	
	return 0;
}


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

int main() {
  int h,w;
  for (int i = 0;; i++) {
    cin>>h>>w;
    if (h==0 && w==0) break;
    else {
      for (int s = 0; s < h; s++) {
        for (int t = 0; t < w; t++) {
          cout<<"#";
        }
        cout<<endl;
      }
      cout<<endl;
    }
  }
}



Measured memory_bytes: 3060
(defun main ()
  (defparameter s_list (loop :for a :from 1 :upto (read) collect(read-line)))
  (if (equal s_list (remove-duplicates s_list :test #'equal))
      (if (loop :for k :from 1 :upto (1- (length s_list)) always(equal (car (last (concatenate 'list (nth (1- k) s_list)))) (char (nth k s_list) 0)))
          "Yes"
          "No")
      "No")
  )
(format t "~A" (main))

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

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> A(n);
    int t = 0;
    for(int i = 0; i < n;i++){
        cin >> A.at(i);
        t += A.at(i);
    }
    int ans = 0;
    double c = (double)t / (4*m);
    for(auto x : A){
        if(x >= c) ans++;
    }
    if(ans >= m) cout << "Yes" << endl;
    else cout << "No" << endl;
    
}

Measured memory_bytes: 3624
N,D=map(int,input().split())
List = []
for i in range (N):
  List.append(list(map(int, input().split())))
dist = D*D
res = 0
tryDist = 0
for i in range(N):
  tryDist = List[i][0]*List[i][0] + List[i][1]*List[i][1] 
  if tryDist <= dist:
    res += 1
print(res)

Measured memory_bytes: 45384