akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner stdIn = new Scanner(System.in);
        int k = stdIn.nextInt();
        String s = stdIn.next();
        if(k > 0 && k < 101){
            if(s.length() > 0 && s.length() < 101){
                if(s.length() > k){
                    char[] x = new char[s.length()];
                    for(int i = 0 ; i < k ; i++){
                        x[i] = s.charAt(i);
                        System.out.print(x[i]);
                    }
                    System.out.println("...");
                }else{
                    System.out.println(s);
                }
            }
        }
    }
}


Measured memory_bytes: 35764
#include<bits/stdc++.h>
#define MOD 1000000007
#define mp make_pair
#define ll long long
#define pb push_back
#define faster ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define debug cout<<"Debugging.."<<endl
using namespace std;
map<pair<int,int>,bool> m;
bool animal(int n,int x)
{
	if(m.find({n,x})!=m.end())
	return m[{n,x}];
	if(x<0)return false;
	if(n==0 && x==0)return true;
	if(n==0 && x>0)return false;
	
	if(n>0 && x==0)return false;
	
	
	return m[{n,x}]=animal(n-1,x-2) || animal(n-1,x-4);	
}
int main()
{
	faster;

		ll int n,x;
		cin>>n>>x;
		if(animal(n,x))cout<<"Yes"<<endl;
		else
		cout<<"No"<<endl;

	
}




Measured memory_bytes: 3676
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

import static java.lang.System.in;

public class Main {
    static long[] dp;
    static long[] pre;

    public static void main(String[] args) {
        Scanner scanner = new Scanner(in);
        int n = scanner.nextInt();
        int[][] can = new int[n][n];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                can[i][j] = scanner.nextInt();
            }
        }
        pre = new long[(1 << n)];
        for (int mask = 0; mask < (1 << n); mask++) {
            for (int i = 0; i < n; i++) {
                if ((mask & (1 << i)) != 0) {
                    for (int j = i + 1; j < n; j++) {
                        if ((mask & (1 << j)) != 0)
                            pre[mask] += can[i][j];
                    }
                }
            }
        }
        dp = new long[1 << n];
        Arrays.fill(dp, Long.MIN_VALUE);
        dp[0]=0;
        for (int mask = 0; mask < (1 << n); mask++) {
            ArrayList<Integer> notTaken = new ArrayList<>();
            for (int i = 0; i < n; i++) {
                if ((mask & (1 << i)) == 0)
                    notTaken.add(i);
            }
            rec(0, dp[mask], notTaken, mask, 0);
        }
        System.out.println(dp[(1<<n)-1]);

    }

    private static void rec(int i, long score, ArrayList<Integer> notTaken, int mask, int group) {
        if (i == notTaken.size()) {
            dp[mask] = Math.max(dp[mask], score + pre[group]);
            return;
        }
        rec(i+1, score,notTaken,mask | (1<<notTaken.get(i)),group | (1<<notTaken.get(i)));
        rec(i+1, score,notTaken,mask ,group );
    }
}


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

#define ll long long 
#define pb push_back
#define mp make_pair
#define F first
#define S second 
#define pl pair<long ,long >
#define pi pair<int ,int >
#define lb(v,x) lower_bound(v.begin(),v.end(),x)-v.begin();
#define ub(v,x) upper_bound(v.begin(),v.end(),x)-v.begin();
#define ct(i) cout<< i << "\n";
#define sv(v) sort(v.begin(),v.end());
#define mod 1000000007
#define M 100005
vector<int> ans;
int a,b,c,m;

void answer(){
    ll n;
    cin>>n;
    if(n>=400 && n<=599) cout<<8;
    if(n>=600 && n<=799) cout<<7;
    if(n>=800 && n<=999) cout<<6;
    if(n>=1000 && n<=1199) cout<<5;
    if(n>=1200 && n<=1399) cout<<4;
    if(n>=1400 && n<=1599) cout<<3;
    if(n>=1600 && n<=1799) cout<<2;
    if(n>=1800 && n<=1999) cout<<1;

}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL); 
    int q;
    //cin>>q; while(q--)
        answer();

    return 0;
}


Measured memory_bytes: 3640
//nani?
#include<bits/stdc++.h>
#define pi acos(-1);
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define f(i,a,b) for( int i = a; i < b ; i++ )
#define sor(a) sort( a.begin(), a.end() )
#define rsor(a) sort( a.rbegin(), a.rend() )
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
//#define inf 1LL<<62
typedef long long ll;
typedef double ld;
using namespace std;
const ll inf=1e10+6;
const ll MOD=1e9+7;
const ll mod=998244353;
// ac cmtr;
const int MAX_N = 4*1e5+5;
const int LG = 25;

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cout << name << " : " << arg1 << endl;}
 
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cout.write(names, comma - names) << " : " << arg1<<" | ";
  __f(comma+1, args...);}
#else
#define trace(...)
#endif
//---------------------------

ll a[MAX_N];
ll p[MAX_N];

int main(){
    fastio;
    ll n,k,q;
    cin>>n>>k>>q;
    f(i,0,q) cin>>a[i];
    f(i,1,n+1) p[i] = 0;
    f(i,0,q){
        p[a[i]]++;
    }
  	ll sum = 0;
  	f(i,1,n+1){
    	sum+= p[i];
    }
    f(i,1,n+1){
        if(k-(sum-p[i])  <= 0) cout<<"No"<<endl;
        else cout<<"Yes"<<endl;
    }

}

Measured memory_bytes: 5192
#include        "algorithm"
#include        "iostream"
#include        "numeric"
#include        "iomanip"
#include        "cstring"
#include        "math.h"
#include        "bitset"
#include        "string"
#include        "vector"
#include        "ctime"
#include        "queue"
#include        "stack"
#include        "map"
#include        "set"

#include        "ext/pb_ds/assoc_container.hpp" // Common file
#include        "ext/pb_ds/tree_policy.hpp" // Including tree_order_statistics_node_update
#include        "ext/pb_ds/detail/standard_policies.hpp"

using namespace std;
using namespace __gnu_pbds;


#define          f first
#define          lgn 25
#define          endl '\n'
#define          sc second
#define          N (int)2e5+5
#define          pb push_back
#define          mod 1000000007
#define          ld long double
#define          vi vector<int>
#define          eb emplace_back
#define          vpii vector<pii>
#define          mii map<int,int>
#define          int long long 
#define          pii pair<int,int>
#define          pq priority_queue
#define          BLOCK (int)sqrt(N)
#define          test(x) while(x--)
#define          all(x) begin(x),end(x)
#define          allr(x) rbegin(x),rend(x)
#define          fo(i,a,n) for(int i=a;i<n;i++)
#define          rfo(i,n,a) for(int i=n;i>=a;i--)
#define          FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define          time() cerr << "Time : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n"
#define          PI acos(-1.0)
#define 		 bug(...)       __f (#__VA_ARGS__, __VA_ARGS__)

typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update > 
OS ;

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

inline void INP()
{
	#ifndef ONLINE_JUDGE
	    freopen("input.txt","r",stdin);   
	    freopen("output.txt","w",stdout);
	#endif 
}

const int inf = 0x3f3f3f3f;
const int INF = 0x3f3f3f3f3f3f3f3f;

int n,m,k,q,x,y;
string s;
vi adj[N];
vi dis;
mii ans;

void dijkstra(int sr)
{
	dis.assign(n+1 , inf);

	set<pii> st;
	st.insert({ dis[sr] = 0 , sr});

	while( !st.empty() )
	{
		auto now = st.begin();
		st.erase(now);
		int v = now->sc;
		int d = now->f;

		for( auto j : adj[v])
		{
			if( dis[j] > d + 1 )
			{
				st.erase( { dis[j] , j});
				dis[j] = d + 1;
				st.insert({ dis[j] , j});
			}
		}
	}

	// bug( sr );
	fo(i,1,n+1)
	{
		if( i > sr  )
		{
			int d = dis[i];
			// bug(  i , d );
			ans[dis[i]]++;
		}
	}


}
void go()
{
	cin >> n >> x >> y;

	fo(i,1,n)
	{
		adj[i].pb(i+1);
		adj[i+1].pb(i);
	}
	adj[x].pb(y);
	adj[y].pb(x);

	// dijkstra(2);
	fo(i,1,n+1)
	{
		dijkstra(i);
	}

	fo(i,1,n) cout << ans[i] << ' ';
	cout << endl;
}

int32_t main()
{
	//INP(); 
	FAST;     
	int t=1; 
	// cin>>t;
	test(t) go();
}

 

Measured memory_bytes: 5120
#include <stdio.h>
int main(void)
{
	int H;
	int W;
	int i,j = 0;
	while(1){
		scanf("%d %d",&H,&W);
		if ((H==0)||(W==0))break;
		
		for(i=0;i<H;i++){
			for(j=0;j<W;j++){
				if((i==0)||(i==H-1)||(j==0)||(j==W-1)){
					printf("#");
				}else{
					printf(".");
				}
			}
			printf("\n");
		}
		printf("\n");
		i++;
	}
	
	return 0;
}



Measured memory_bytes: 2100
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

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

	vector<int> w(n, 0);
	int sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> w[i];
		sum += w[i];
	}

	int ans = sum;
	int sum1 = 0;
	for (auto x: w) {
		sum1 += x;
		ans = min(ans, abs(sum1 - (sum - sum1)));
	}
	cout << ans << endl;
	return 0;
}


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

int sumaDigitos(int digito)
{
    int suma = 0;
    while(digito > 0)
    {
        suma += digito % 10;
        digito /= 10;
    }
    return suma;
}

int main(void)
{
    int A, N, B, minSuma = 1e9;
    cin >> N;
    for(int i = 1 ; i <= N / 2 ; i++)
    {
        A = sumaDigitos(i);
        B = sumaDigitos(N - i);
        minSuma = min(minSuma, A + B);
    }
    cout << minSuma << "\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
long long int mod = (long long int)1000000007;
using namespace std;

void solve()
{
    ll i,j,k,n;
    std::cout.precision(10);
    int yes=0;
  	cin>>n;
  int freq[n+1]={0};
  j=n;
  n--;
  while(n--)
  {
    cin>>i;
    freq[i]++;
  }
  for(i=1;i<=j;i++)
    cout<<freq[i]<<"\n";
}

int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
    int i,j,k;
    int t;
    std::cout.precision(10);
    t=1;
    while(t--)
    {
        solve();
        cout<<"\n";
    }
}


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

namespace ConsoleApp1 {
    class Program {
        static void Main(string[] args) {
            string[] str = Console.ReadLine().Split(' ');//2つ以上のスペース区切り入力の取得
            int a = int.Parse(str[0]);  //数値で受け取りたい場合は変換する
            int b = int.Parse(str[1]);
            if ((a + b) % 2 == 0) {
                Console.WriteLine((a + b) / 2);
            } else {
                Console.WriteLine("IMPOSSIBLE");
            }            
        }
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;
const int loose = 0;
const int tight = 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;
}

//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

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

	ll n, t;
	cin >> n >> t;

	vector<P> ab(n);
	REP(i, n) cin >> ab[i].first >> ab[i].second;

	sort(all(ab));

	Matrix dp(n + 1, Array(t + 1, 0));

	REP(i, n) {
		REP(j, t) {
			ll a = ab[i].first;
			ll b = ab[i].second;
			chmax(dp[i + 1][min(j + a, t)], dp[i][j] + b);
			chmax(dp[i + 1][j], dp[i][j]);
		}
		chmax(dp[i + 1][t] , dp[i][t]);
	}

	ll ans = 0;

	REP(i, t+1) {
		chmax(ans, dp[n][i]);
	}

	cout << ans << en;

	return 0;
}


Measured memory_bytes: 70784
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;
typedef long long ll;

vector<ll> make_divitors(ll n){
  vector<ll> res;
  for(ll i=1; i<=int(sqrt(n)); i++){
    if( n%i == 0 ){
      res.push_back(i);
      res.push_back(n/i);
    }
  }
  return res;
}

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

  vector<ll> divitors = make_divitors(n);
  ll ans = divitors[divitors.size()-1] + divitors[divitors.size()-2] - 2;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>
#include<map>
#define For(i,a,b) for(int i=(a);i<(b);i++)
#define Rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;


int main() {
	int N;
	string S;
	cin >> N >> S;
	vector<vector<int>> a(2, vector<int>(N, 0));
	Rep(i, N) {
		if (S[i] == 'W') a[0][i] += 1;
		else a[1][i] += 1;
	}
	vector<vector<int>> sum(2, vector<int>(N + 1, 0));
	Rep(i, N) {
		sum[0][i + 1] += sum[0][i] + a[0][i];
		sum[1][i + 1] += sum[1][i] + a[1][i];
	}
	int res = N;
	Rep(i, N) {
		int cn = sum[0][i] + sum[1][N] - sum[1][i + 1];
		if (res > cn) res = cn;
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 6392
x = int(input())

a = -1000
b = -1000

for _ in range(2000):
    for _ in range(2000):
        if (a ** 5) - (b ** 5) == x:
            print('{0} {1}'.format(a,b))
            exit()
        b += 1
    b = -2000
    a += 1

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

int main()
{
  int N, j, count;
  int max_n = 1;
  int max_count = 0;

  cin >> N;
  for (int i = 1; i <= N; i++)
  {
    j = i;
    count = 0;
    while (j % 2 == 0)
    {
      j /= 2;
      count++;
    }
    if (max_count < count)
    {
      max_count = count;
      max_n = i;
    }
  }
  cout << max_n << endl;
}

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

template <class T>
inline void read(T &res)
{
	res = 0; bool bo = 0; char c;
	while (((c = getchar()) < '0' || c > '9') && c != '-');
	if (c == '-') bo = 1; else res = c - 48;
	while ((c = getchar()) >= '0' && c <= '9')
		res = (res << 3) + (res << 1) + (c - 48);
	if (bo) res = ~res + 1;
}

typedef long long ll;

const int N = 1e5 + 5, M = N << 1;

int n, m, ecnt, nxt[M], adj[N], go[M], dep[N], fa[N], cnt1, sze[2][N], tot, a[N],
val[M], pos[M], cnt[M][2], s[M], tmp[M];
bool vis[N], isc[N];
ll ans;

void add_edge(int u, int v)
{
	nxt[++ecnt] = adj[u]; adj[u] = ecnt; go[ecnt] = v;
	nxt[++ecnt] = adj[v]; adj[v] = ecnt; go[ecnt] = u;
}

void dfs(int u, int fu)
{
	dep[u] = dep[fu] + 1; if (dep[u] & 1) cnt1++;
	sze[dep[u] & 1][u] = 1;
	for (int e = adj[u], v; e; e = nxt[e])
		if ((v = go[e]) != fu) dfs(v, u),
			sze[0][u] += sze[0][v], sze[1][u] += sze[1][v];
	ans += sze[0][u] > sze[1][u] ? sze[0][u] - sze[1][u]
		: sze[1][u] - sze[0][u];
}

void fcir(int u, int fu)
{
	vis[u] = 1; dep[u] = dep[fu] + 1; fa[u] = fu;
	for (int e = adj[u], v; e; e = nxt[e])
		if ((v = go[e]) != fu && !vis[v]) fcir(v, u);
		else if (v != fu && dep[v] < dep[u])
			for (int x = u; x != fa[v]; x = fa[x])
				isc[a[++tot] = x] = 1;
}

void sfd(int u, int fu)
{
	dep[u] = dep[fu] + 1; sze[dep[u] & 1][u] = 1;
	for (int e = adj[u], v; e; e = nxt[e])
		if ((v = go[e]) != fu && !isc[v]) sfd(v, u),
			sze[0][u] += sze[0][v], sze[1][u] += sze[1][v];
	if (fu) ans += sze[0][u] > sze[1][u] ? sze[0][u] - sze[1][u]
		: sze[1][u] - sze[0][u];
}

int main()
{
	int x, y;
	read(n); read(m);
	for (int i = 1; i <= m; i++) read(x), read(y), add_edge(x, y);
	if (m == n - 1)
	{
		dfs(1, 0);
		if (cnt1 * 2 != n) return puts("-1"), 0;
		return std::cout << ans << std::endl, 0;
	}
	fcir(1, 0); m = 0;
	for (int i = 1; i <= tot; i++)
	{
		sfd(a[i], 0); if (i & 1) std::swap(sze[0][a[i]], sze[1][a[i]]);
		if (sze[0][a[i]] > sze[1][a[i]])
			for (int j = 1; j <= sze[0][a[i]] - sze[1][a[i]]; j++)
				val[++m] = 0, pos[m] = i;
		else for (int j = 1; j <= sze[1][a[i]] - sze[0][a[i]]; j++)
			val[++m] = 1, pos[m] = i;
	}
	for (int i = 1; i <= m; i++) val[i + m] = tot & 1 ? val[i] ^ 1 : val[i],
		pos[i + m] = pos[i] + tot;
	for (int i = 1; i <= (m << 1); i++)
		cnt[i][0] = cnt[i - 1][0] + (val[i] == 0),
			cnt[i][1] = cnt[i - 1][1] + (val[i] == 1);
	if (tot & 1)
	{
		for (int i = 1; i <= m; i++) if (cnt[i + m][0] - cnt[i][0]
			== cnt[i + m][1] - cnt[i][1])
			{
				int c0 = 0, c1 = 0;
				for (int j = i + 1; j <= i + m; j++)
					(val[j] ? c1 : c0)++, ans += 1ll * (pos[j + 1] - pos[j])
						* (c0 > c1 ? c0 - c1 : c1 - c0);
				return std::cout << ans << std::endl, 0;
			}
		return puts("-1"), 0;
	}
	int c0 = 0, c1 = 0;
	for (int i = 1; i <= m; i++) (val[i] ? c1 : c0)++;
	if (c0 != c1) return puts("-1"), 0;
	for (int i = 1; i <= m; i++) tmp[pos[i]] += val[i] ? 1 : -1;
	for (int i = 1; i <= tot; i++) tmp[i] += tmp[i - 1];
	std::sort(tmp + 1, tmp + tot + 1);
	int mid = tot + 1 >> 1;
	for (int i = 1; i <= tot; i++)
		ans += i <= mid ? tmp[mid] - tmp[i] : tmp[i] - tmp[mid];
	return std::cout << ans << std::endl, 0;
}

Measured memory_bytes: 12544
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
//l={1,2,3,4}
//greater<int>()
//sort(l.bigin(),l.end())
//sort(l,l+n)

int main(void)
{
	int n, a, b;
	cin >> n >> a >> b;
	int num = n * a;

	if (num <= b)
		cout << num << endl;
	else
		cout << b << endl;
	
}


Measured memory_bytes: 256
#include <iostream>
#include <string.h>
using namespace std;
int main(void){
    string str;
    getline(cin, str);
    for(int i=0; i<str.size(); i++){
        char c=str[i];
        if('A' <= c && c <= 'Z'){
            c = c + 32;
        }
        else if('a' <= c && c <= 'z'){
            c = c - 32;
        }
        cout << c;
    }
    cout << endl;
    return 0;
    
}



Measured memory_bytes: 3128
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

r = 0
if b-a >k or c-a >k or d-a>k or e-a>k or c-b>k or d-b>k or e-b>k or d-c>k or e-c >k or e-d>k:
    print(":(")
else:
    print("Yay!")


Measured memory_bytes: 3060
def B(w,arpha,count):
    for c in w:
        for i,a in enumerate(arpha):
            if c == a:
                count[i]+=1

    for i in count:
        if  i % 2 != 0:
            return print("No")
    print("Yes")

w = input()
arpha = [chr(i) for i in range(97,97+26)]
count = [0 for i in range(26)]
B(w,arpha,count)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100001,INF=1<<30;

ll rui(ll a,ll b){
    if(b==1) return a%mod;
    else if(b==0) return 1;
    else if(b%2==0) return (rui(a,b/2)*rui(a,b/2))%mod;
    else return (rui(a,b-1)*a)%mod;
}

ll inv[MAX],fac[MAX],finv[MAX];

void make(){
    
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    
    for(int i=2;i<MAX;i++){
        inv[i]=mod-inv[mod%i]*(mod/i)%mod;
        fac[i]=fac[i-1]*(ll)i%mod;
        finv[i]=finv[i-1]*inv[i]%mod;
    }
    
}

ll comb(ll a,ll b){
    if(a<b) return 0;
    return fac[a]*(finv[b]*finv[a-b]%mod)%mod;
}

int main(){

    int N,K;cin>>N>>K;
    make();
    cout<<comb(K,N)*rui(finv[N],mod-2)%mod<<endl;
}




Measured memory_bytes: 5436
var
	ax,ay,bx,by,cx,cy,a,b,c,s,r,m:double;
begin
	read(ax,ay,bx,by,cx,cy);
	a:=sqrt((ax-bx)*(ax-bx)+(ay-by)*(ay-by));
	b:=sqrt((bx-cx)*(bx-cx)+(by-cy)*(by-cy));
	c:=sqrt((cx-ax)*(cx-ax)+(cy-ay)*(cy-ay));
	m:=a;
	if m<b then m:=b;
	if m<c then m:=c;
	r:=(a+b+c)/2;
	s:=sqrt(r*(r-a)*(r-b)*(r-c));
	r:=s/r;
	writeln(m/(2+m/r):0:15);
end.

Measured memory_bytes: 128
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		FastScanner in = new FastScanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		ProblemC solver = new ProblemC();
		solver.solve(1, in, out);
		out.close();
	}

	static class ProblemC {
		public void solve(int testNumber, FastScanner in, PrintWriter out) {
			int n = in.nextInt();
			int[] a = new int[n];
			int[] cnt = new int[n];
			int max = 0;
			for (int i = 0; i < n; i++) {
				a[i] = in.nextInt();
				max = Math.max(max, a[i]);
				++cnt[a[i]];
			}
			if (max == 1) {
				out.println(n == 2 ? "Possible" : "Impossible");
				return;
			}
			int mid = (max + 1) / 2;
			int min = mid + 1;
			boolean can = true;
			int spareMids = max % 2 == 0 ? 1 : 2;
			int numMaxes = 0;
			for (int i = 0; i < n; i++) {
				if (a[i] == max) {
					++numMaxes;
				}
				if (a[i] >= min) {
					continue;
				}
				if (a[i] == mid && spareMids > 0) {
					--spareMids;
					continue;
				}
				can = false;
			}
			if (max == n - 1 && numMaxes > 2) {
				can = false;
			}
			for (int i = mid; i <= max; i++) {
				int need = 2;
				if (i == mid && max % 2 == 0) {
					need = 1;
				}
				if (cnt[i] < need) {
					can = false;
				}
			}
			out.println(can ? "Possible" : "Impossible");
		}

	}

	static class FastScanner {
		private BufferedReader in;
		private StringTokenizer st;

		public FastScanner(InputStream stream) {
			in = new BufferedReader(new InputStreamReader(stream));
		}

		public String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					String rl = in.readLine();
					if (rl == null) {
						return null;
					}
					st = new StringTokenizer(rl);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return st.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

	}
}



Measured memory_bytes: 8528
#include <cstdio>
#define MOD 1000000007
typedef long long ll; 
ll fact[1000005], inv[1000005]; 
inline ll quick_pow(ll a, int n)
{
	ll res = 1; 
	while (n)
	{
		if (n & 1)
			res = res * a % MOD; 
		a = a * a % MOD; 
		n >>= 1; 
	}
	return res; 
}
inline ll C(int n, int m)
{
	if (n < m)
		return 0; 
	return fact[n] * inv[m] % MOD * inv[n - m] % MOD; 
}
int main()
{
	// freopen("AGC023-C.in", "r", stdin); 
	int n; 
	scanf("%d", &n); 
	ll ans = 0; 
	fact[0] = 1; 
	for (int i = 1; i <= n; i++)
		fact[i] = fact[i - 1] * i % MOD; 
	inv[n] = quick_pow(fact[n], MOD - 2); 
	for (int i = n; i; i--)
		inv[i - 1] = inv[i] * i % MOD; 
	for (int k = 1; k < n; k++)
		(ans += C(k - 1, n - k - 1) * fact[k] % MOD * fact[n - k - 1]) %= MOD; 
	printf("%lld\n", (fact[n - 1] * n - ans + MOD) % MOD);
	return 0; 
}


Measured memory_bytes: 15744
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;
 
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;
}
 
const long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
 
#define comuse Comuse()
 
ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
 
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  st s;
  	ci(s);
  ll n=s.sz;
  ll ans=0;
  ch now=s[0];
  FOR(i,1,n){
    if(s[i]!=now){
      now=s[i];
      ans++;
    }
  }
  co(ans)
}

Measured memory_bytes: 512
/*
a + 2sqrt(ab) + b < c
4ab < (c-a-b)**2
*/

#include <iostream>
using namespace std;

signed main(){
  long long a, b, c;
  cin >> a >> b >> c;
  if(c>=a+b && 4*a*b<(c-a-b)*(c-a-b)) puts("Yes");
  else puts("No");
  return 0;
}


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

using namespace std;

typedef long long ll;

const ll mod = 1e9 + 7;
const int sz = 2e6 + 1;

int k;
string s;
ll fact[sz];

ll bpow(ll x, ll p) {
	if (p == 0)
		return 1;
	if (p % 2)
		return (x * bpow(x, p - 1)) % mod;
	else {
		ll b = bpow(x, p / 2);
		return (b * b) % mod;
	}
}

ll inv(ll x) {
	return bpow(x, mod - 2);
}

void calc_fact() {
	fact[0] = 1;
	for (int i = 1; i < sz; i++)
		fact[i] = (fact[i - 1] * i) % mod;
}

ll cnk(ll nn, ll kk) {
	return fact[nn] * inv(fact[nn - kk]) % mod * inv(fact[kk]) % mod;
}

void solve() {
	cin >> k >> s;
	int n = s.size();
	calc_fact();
	ll ans = 0;
	for (int i = 0; i <= k; i++) {
		ans += cnk(n + k - i - 1, n - 1) * bpow(25, k - i) % mod * bpow(26, i) % mod;
		ans %= mod;
	}
	cout << ans;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int q = 1;
	//cin >> q;
	for (; q > 0; q--) {
		solve();
		cout << endl;
	}
}

Measured memory_bytes: 19812
#include <cstdio>
#include <queue>
#include <vector>
#include <algorithm>

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

int main( void ){
	// int n, k;
	// if (!scanf( "%d%d", &n, &k ))
	// 	return -1;
	char* str_a = new char[ 4 ];
	char* str_b = new char[ 4 ];
	if (!scanf( "%s", str_a ))
		return -1;
	if (!scanf( "%s", str_b ))
		return -1;
	int count = 0;
	rep(i,0,3){
		if (str_a[i] == str_b[i])
			count++;
	}
	printf("%d\n", count);
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int a,b;
  cin >> a >>b;
  if(a%3==0)cout << "Possible\n";
  else if(b%3==0)cout << "Possible\n";
  else if((a+b)%3==0)cout << "Possible\n";
  else cout << "Impossible\n";
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<complex>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define FOR(i, a, b) for(ll i = a; i < b; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF (long long)1000000000
#define MOD 1000000007
#define EPS (long double) 1e-8
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
int dh[4] = {1, 0, -1, 0};
int dw[4] = {0, 1, 0, -1};

using namespace std;

int m;
int tsuri(int n10, int n50, int n100, int n500) {
	int n = n10 * 10 + n50 * 50 + n100 * 100 + n500 * 500;
	if(m > n) return -1;
	int ret = n - m;
	int res = 0;
	while(ret >= 500) {
		ret -= 500;
		++res;
	}
	while(ret >= 100) {
		ret -= 100;
		++res;
	}
	while(ret >= 50) {
		ret -= 50;
		++res;
	}
	while(ret >= 10) {
		ret -= 10;
		++res;
	}
	return res;
}


int main() {
	cin>>m;
	while(true) {
		vector<int> c(4);
		REP(i, 4) cin>>c[i];
		int sum = 0;
		REP(i, 4) sum += c[i];
		int resm = INF;
		int res[4];
		REP(i, c[0] + 1) {
			REP(j, c[1] + 1) {
				REP(k, c[2] + 1) {
					REP(l, c[3] + 1) {
						int buf = tsuri(i, j, k, l);
						if(buf == -1) continue;
						if(resm > sum - (i + j + k + l) + buf) {
							resm = sum - (i + j + k + l) + buf;
							res[0] = i;
							res[1] = j;
							res[2] = k;
							res[3] = l;
						}
					}
				}
			}
		}
		if(res[0] != 0) cout<<"10"<<" "<<res[0]<<endl;
		if(res[1] != 0) cout<<"50"<<" "<<res[1]<<endl;
		if(res[2] != 0) cout<<"100"<<" "<<res[2]<<endl;
		if(res[3] != 0) cout<<"500"<<" "<<res[3]<<endl;
		cin>>m;
		if(m != 0) cout<<endl;
		else break;
	}
}

Measured memory_bytes: 3092
X,K,D = map(int,input().split())
X = abs(X)
s = X//D
if s == K:
    print(X%D)
elif s > K:
    print(abs(X-D*K))
elif (K-s) % 2 == 0:
    print(X%D)
else:
    print(abs(X%D-D))
    

Measured memory_bytes: 9172
#include <bits/stdc++.h>
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
//#define _GLIBCXX_DEBUG
#include <iostream>
#include <bits/stdc++.h>
    
    
using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cout(n) cout<<fixed<<setprecision(n)
    
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll h,n;
    cin>>h>>n;
    cout<<(h+n-1)/n<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define INF 999999999
#define rep(i,n) for(int i=0;i<n;i++)
const int MOD = 1000000007;
ll cnt =0,ans=0;

int main(){
   string s,t;
   cin >> s >> t;
   int n = s.size(), m=t.size();
   ans = INF;
   for(int i=0;i<=n-m;i++){
       cnt = 0;
       for(int j=0;j<m;j++){
           if(s.at(i+j) != t.at(j))
           cnt++;
       }
       if(cnt < ans) ans = cnt ;
   }
   cout << ans << endl;
}

Measured memory_bytes: 3616
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<stack>
#include<cstring>
#include<cmath>
#include<queue>
#include<set>
using namespace std;
typedef long long ll;
ll a[1111111];
ll b[1111111];
ll c[1111111];

int main()
{
	//ios::sync_with_stdio(false);
	ll n,k,q,x;
	cin>>n>>k>>q;
	for(ll i=0;i<n;i++)
		a[i]=k;
	set<ll> st; 
	for(ll i=0;i<q;i++)
	{
		scanf("%lld",&x);
		a[x-1]++;
	}
	

	for(ll j=0;j<n;j++)
		if(a[j]-q>0)
			cout<<"Yes"<<endl;
		else
			cout<<"No"<<endl;
	return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

int w, h;
int p[100005], q[100005];
int a[2][100005];
PII ord[200010];

inline bool cmp(const PII &lhs, const PII &rhs) {
    return a[lhs.first][lhs.second] < a[rhs.first][rhs.second];
}

int main() {
    scanf("%d%d", &w, &h);
    forn(i, w) {
        scanf("%d", p + i);
    }
    forn(i, h) {
        scanf("%d", q + i);
    }
    forn(i, w) {
        a[0][i] = p[i];
        ord[i] = mp(0, i);
    }
    forn(i, h) {
        a[1][i] = q[i];
        ord[w + i] = mp(1, i);
    }
    int cnt = w + h;
    sort(ord, ord + cnt, cmp);
    LL ans = 0;
    int ww = w + 1, hh = h + 1;
    forn(i, cnt) {
        PII x = ord[i];
        if (x.first == 0) {
            ans += (LL)hh * a[x.first][x.second];
            --ww;
        } else {
            ans += (LL)ww * a[x.first][x.second];
            --hh;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3328
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<random>
typedef long long int ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<signed(n);i++)
#define EREP(i,n) for(int i=1;i<=signed(n);i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
//#define EVEL 1
#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const int INF = 1e9;
typedef std::pair<int,int> P;
struct edge {int to,cost;};
#define VMAX 500+10
    int X,Y,Z;
int main(){
    cin>>X>>Y>>Z;
    X-=Z;
    cout<<X/(Y+Z);
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)
from collections import deque

n = int(input())
u = [[] for i in range(n+1)] #隣接リスト
for i in range(n):
    v = list(map(int, input().split()))
    u[v[0]] = v[1:] #v = [次数, 頂点...]

d = [-1] * (n+1)
f = [-1] * (n+1)
visited = [False] * (n+1)
visited[0] = True
time = 1

#再帰
def dfs(c):
    global time
    d[c] = time
    time += 1
    visited[c] = True
    for i in range(1, u[c][0]+1):
        if not visited[u[c][i]]:
            dfs(u[c][i])
    f[c] = time
    time += 1
"""
探索は元の始点から到達可能なすべての頂点を発見するまで続き、
未発見の頂点が残っていれば、
その中の番号が一番小さい１つを新たな始点として探索を続けます。
"""
while False in visited:
    dfs(visited.index(False))

for i in range(1, n+1):
    print(i, d[i], f[i])


Measured memory_bytes: 6068
import Control.Monad
import Data.List
import Text.Printf

infixl 0 `dot`
dot :: (c -> d) -> (a -> b -> c) -> a -> b -> d
dot = ((.).(.))

main :: IO ()
main = do
  xs <- replicateM 10 readLn
  forM_ (solve xs) $ \x -> do
    print x

solve :: [Int] -> [Int]
solve = take 3 . sortBy (flip compare)



Measured memory_bytes: 3704
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
input = sys.stdin.readline

# bisect_left(lists, 3)
# bisect_right(lists, 3)

def main():
	N = int(input())
	me = []
	mini = -1
	for i in range(5):
		tmp = int(input())
		me.append(tmp)
		if mini == -1 or mini > tmp:
			mini = tmp

	time = 5
	tmp = N // mini
	amari = N % mini

	if amari > 0:
		print(time + tmp)
	else:
		print(time + tmp-1)
	
if __name__ == "__main__":
	main()
	

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int N; cin >> N;
    vector<int> v(9, 0);

    for (int i=0; i<N; i++) {
        int a; cin >> a;
        if (a >= 3200) v[8]++;
        else v[a/400] = 1;
    }

    int min = 0; for (int i=0; i<8; i++) min += v[i];
    int max = min + v[8];
    if (min == 0) min = 1;

    cout << min << " " << max << endl;

    return 0;
}

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

int main(){
    string S;
    cin >> S;
    ll s = 0;
    ll e = 0;
    rep(i, 0, S.size()){
        if(S[i] == 'S'){
            s++;
        }else{
            if(s > 0){
                s--;
                e += 2;
            }
        }
    }

    cout << S.size() - e << endl;
    return 0;
}

Measured memory_bytes: 640
ab=input().split()
a=int(ab[0])
b=int(ab[1])
count=0
if a<=1 and b<=1 :
  count=0

elif b>1 and a<=1 :
  count=b*(b-1)/2

elif a>1 and b<=1 :
  count=a*(a-1)/2

elif a>1 and b>1 :
  count=a*(a-1)/2+b*(b-1)/2

print(int(count))

Measured memory_bytes: 38384
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <cstring>
#include <deque>
#include <cstdio>
#include <cmath>

using namespace std;

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

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

bool isA(const char* str)
{
	int n = strlen(str);
	if(n<6) return false;
	if(str[0]!='>' || str[1]!='\'') return false;
	
	int cnt, i;
	for(cnt=0, i=2; i<n && str[i]=='='; ++cnt, ++i);
	if(cnt==0 || i>=n || str[i] != '#') return false;
	++i;
	
	int s;
	for(s=0; i<n && str[i]=='='; ++s, ++i);
	if(cnt!=s || i+1!=n) return false;
	
	return str[i] == '~';
}

bool isB(const char* str)
{
	int n = strlen(str);
	if(n<6) return false;
	if(str[0]!='>' || str[1]!='^') return false;
	
	int i;
	for(i=2; i+1<n && str[i]=='Q' && str[i+1]=='='; i+=2);
	if(i==2 || i+2!=n) return false;
	
	return str[i]=='~' && str[i+1] == '~';
}

int main()
{
	int n;
	scanf("%d", &n);
	rep(i, n){
		char str[256];
		scanf("%s", str);
		if(isA(str))
			puts("A");
		else if(isB(str))
			puts("B");
		else
			puts("NA");
	}
	
	return 0;
}

Measured memory_bytes: 0
//? http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_3_D

#include <algorithm>
#include <iostream>
#include <stack>
#include <string>
#include <vector>


using namespace std;

signed main()
{
    stack<int> S1;
    stack<pair<int, int>> S2;
    char ch;
    int sum = 0;
    for(int i = 0; cin >> ch; i++)
    {
        if(ch == '\\')
            S1.push(i);
        else if(ch == '/' && S1.size() > 0)
        {
            int j = S1.top();
            S1.pop();
            sum += i - j;
            int a = i - j;
            while(S2.size() > 0 && S2.top().first > j)
            {
                a += S2.top().second;
                S2.pop();
            }
            S2.push({j, a}); // todo或者 S2.push(make_pair(j,a))
        }
    }
    vector<int> ans;
    while(S2.size() > 0)
    {
        ans.push_back(S2.top().second);
        S2.pop();
    }
    reverse(ans.begin(), ans.end());
    cout << sum << endl;
    cout << ans.size();
    for(int i = 0; i < ans.size(); i++)
    {
        cout << " ";
        cout << ans[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3152
N,M = map(int,input().split())
comb = ["0"*(N-len(format(i,"b")))+format(i,"b") for i in range(2**N)]
result = 0
setting = list()
for i in range(M):
    temp = (list(map(int,input().split())))
    setting.append(temp[1:len(temp)])
p = list(map(int,input().split()))
for i in comb:
    light = [0]*M
    for j in range(len(setting)):
        on_count = 0
        for k in setting[j]:
            if i[k-1] =="1":
                on_count +=1
        if on_count %2 == p[j]:
            light[j] = 1   
    if sum(light) == M:
        result +=1
        
    
print(result)

Measured memory_bytes: 3064
#include "bits/stdc++.h"

#define rep(i, a) for (int i = 0; i < (int)a; ++i)
#define REP(i, a, b) for (int i = (a); i < (int)b; ++i)

using namespace std;
using ll = long long;
using P = pair<int, int>;

ll euk(ll a, ll b) {
  if (b==0) return a;
  return euk(b, a%b);
}

void Main() {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ll C = b/c - (a-1)/c;
  ll D = b/d - (a-1)/d;
  ll cd = c*d/euk(c, d);
  ll CD = b/cd - (a-1)/cd;
  ll ans = b - a + 1 - (C + D - CD);
  cout << ans << endl;
}

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


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long power = 1;
        
        for(int i = 1; i <= N; i++) {
            power = (power * (long)i) % 1000000007;
          }
          System.out.println(power);
          
	}

}

Measured memory_bytes: 21844
#include <iostream>
#include <queue>
#include <unordered_map>
#include <utility>
#include <array>
#include <cstring>

bool isObstacle[1000][1000];
bool done[1000][1000];

int main() {
	int h, w, n;
	std::cin >> h >> w >> n;

	std::unordered_map<int, int> factories;

	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			char c;
			std::cin >> c;

			if (c == 'S')
				factories[0] = j * 1000 + i;
			else if ('1' <= c && c <= '9')
				factories[c - '0'] = j * 1000 + i;
			else if (c == 'X')
				isObstacle[j][i] = true;
		}
	}

	int ans = 0;
	for (int i = 0; i < n; ++i) {
		const int sx = factories[i] / 1000, sy = factories[i] % 1000;
		const int gx = factories[i + 1] / 1000, gy = factories[i + 1] % 1000;

		std::memset(done, 0, sizeof(done));

		done[sx][sy] = true;

		auto candidate = [h, w](int x, int y) {
			std::array<int, 4> arr;
			arr[0] = ((x == 0 || isObstacle[x - 1][y] || done[x - 1][y]) ? -1 : (done[x - 1][y] = true, (x - 1) * 1000 + y));
			arr[1] = ((x == w - 1 || isObstacle[x + 1][y] || done[x + 1][y]) ? -1 : (done[x + 1][y] = true, (x + 1) * 1000 + y));
			arr[2] = ((y == 0 || isObstacle[x][y - 1] || done[x][y - 1]) ? -1 : (done[x][y - 1] = true, x * 1000 + y - 1));
			arr[3] = ((y == h - 1 || isObstacle[x][y + 1] || done[x][y + 1]) ? -1 : (done[x][y + 1] = true, x * 1000 + y + 1));

			return std::move(arr);
		};

		std::queue<std::pair<int, int>> q;
		q.push({ factories[i], 0 });
		while (!q.empty()) {
			const auto& top = q.front();
			const int nx = top.first / 1000, ny = top.first % 1000;
			int cost = top.second;

			auto&& c = candidate(nx, ny);
			for (auto v : c) {
				if (v != -1) {
					if (v / 1000 == gx && v % 1000 == gy) {
						ans += cost + 1;
						q.pop();
						goto end;
					}
					q.push({ v, cost + 1 });
				}
			}

			q.pop();
		}
	end:;
	}

	std::cout << ans << std::endl;
}

Measured memory_bytes: 5064
#include<bits/stdc++.h>
    using namespace std;
    #define ll long long
    #define vv vector<ll>
    #define pp pair<ll,ll>
    #define ff first
    #define ss second
    #define vp vector<pp>
    #define ld long double
    #define pb push_back
    #define mp make_pair
    #define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
    const ll mod=987654319;
    const ll N=200000;
    bool prime[N];
    const ll H=64;
    void isprime()
    {
        memset(prime,true,N);
        for(ll i=2;i*i<N;i++)
        {
            if(prime[i]==true)
            {
                for(ll j=i*i;j<N;j+=i)
                {
                    prime[j]=false;
                }
            }
        }
    }
    ll power(ll a,ll n)
    {
        ll ans=1;
        a=a%mod;
        while(n>0)
        {
            if(n&1)
            {
                ans=(ans*a)%mod;
            }
            n=n>>1;
            a=(a*a)%mod;
        }
        return ans;
    }
    ll gcd(ll a,ll b)
    {
        if(b==0)
        return a;
        
        return gcd(b,a%b);
    }
    int main()
    {
    	string s;
    	cin>>s;
    	ll n=s.length();
    	ll d=0;
    	ll st=0;
    	for(ll i=0;i<=n-3;)
    	{
    		if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C')
    		{
    			ll j=i;
				s[j-st]='B';
				s[j-st+1]='C';
				if(st==0)
				{
					s[i+2]='A';
					st++;
				}
				else
				{
					s[i+1]='A';
					s[i+2]='A';
					st++;
				}
				d=d+st;
				i=i+2;
				st=st-1;
			}
			else
			{ 
			    if(s[i]=='A')
			    {
			    	st++;
				}
				else
				{
				   st=0;
			    }
			    i++;
			}
		}
		//cout<<s<<endl;
		cout<<d;
		return 0;
	}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <complex>
#include <map>
#include<unordered_map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include<bitset>
#include<deque>
#include<string>
#include<list>
#include<iterator>
#include<sstream>
#include <algorithm>
#include <numeric>
#include <math.h>

#define user spaesk
#define lli long long int
#define ld long double
#define ff first
#define ss second
#define lower(a) transform(a.begin(),a.end(),a.begin(),::tolower);

using namespace std;

const int N = 3e5 + 500;
const long long mod = 1e9 + 7;
const long long cmod = 998244353 ;
const long long inf = 1LL << 61;
const int M = 1e6 + 500;
const lli ths = 1LL << 40;
const int NN = 5e3 + 6;

vector<lli> g[N];

void solve()
{
    lli n;
    cin>>n;
    for(int i = 2; i <= n; i ++) {
        lli x;
        cin>>x;
        g[x].push_back(i);
    }
    for(int i = 1; i <= n; i ++) {
        cout<<g[i].size()<<'\n';
    }
    cout<<'\n';
    return ;
}

/*
*/

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

    int t = 1;
//    cin>>t;
    while(t --)
    {
        solve();
    }
    return 0;
}



Measured memory_bytes: 16896
// Template Headers {{{
#include <bits/stdc++.h>
using namespace std;

using pii = pair<int, int>; using vpii = vector<pii>;
using vi = vector<int>; using vvi = vector<vi>;
using ll = long long;
using pll = pair<ll, ll>; using vpll = vector<pll>;
using vll = vector<long long>; using vvll = vector<vll>;
template <class T> using min_queue = priority_queue<T, vector<T>, greater<T>>;
template <class T> istream &operator>>(istream &, vector<T> &);
template <class T> ostream &operator<<(ostream &, const vector<T> &);
template <class T, class U> istream &operator>>(istream &, pair<T, U> &);
template <class T, class U> ostream &operator<<(ostream &, const pair<T, U> &);
template <class T> struct Inf { static constexpr T inf() { return std::numeric_limits<T>::has_infinity ? std::numeric_limits<T>::infinity() : std::numeric_limits<T>::max(); } };
template <> struct Inf<int> { static constexpr int inf() { return 0x3f3f3f3f; } };
template <> struct Inf<long long> { static constexpr long long inf() { return 0x3f3f3f3f3f3f3f3fLL; } };
constexpr int INF = Inf<int>::inf(); constexpr ll BINF = Inf<ll>::inf();
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// }}}
// Preprocessing & "Global" variables {{{
struct Solver {
	Solver() {}
	int solve();
};
// }}}

int Solver::solve() {
	int n; cin >> n;
	if (n >= 30)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

// Template Main {{{
int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	Solver solver;
	#ifdef JUDGE_MULTI_CASE
		int t; cin >> t; for (int i = 1; i <= t; i++)
	#endif
	solver.solve();
	// cout << "Case #" << i << ": ", solver.solve();
	return 0;
}

template <class T> istream &operator>>(istream &is, vector<T> &v) {
	for (auto it=v.begin();it!=v.end();++it) is >> *it;
	return is;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
	for (auto it=v.begin();it!=v.end();) os << *it, os << " \n"[++it==v.end()];
	return os;
}

template <class T, class U> istream &operator>>(istream &is, pair<T, U> &p) {
	return is >> p.first >> p.second;
}

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

// vim: fdm=marker


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

typedef long long ll;
typedef int64_t i6;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 1; i <= n; ++i)
#define ALL(v) (v).begin(), (v).end()
#define Sort(x) sort(ALL(x))
#define Sort_rev(x) Sort(x);reverse(ALL(x))

template<typename V,typename T>
T find_num(V v, T num) {
    if ( find(ALL(v), num) == v.end() ) {
        return false;
    } else {
        return true;
    }
}

// π M_PI
// deg = rad*180/M_PI

ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

int main() {
    ll n;
    cin >> n;
    ll ans = 0;
    rep2(i, n) {
        rep2(j, n) {
            rep2(k, n) {
                ans += gcd(i, gcd(j, k));
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3636