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

using namespace std;

int main()
{
    int n;
    cin>>n;
    int *a=new int[n];
   // int *b=new int[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    if(n==1)
    {
        cout<<a[0]<<endl;
    }
    else{
        for(int i=n-1;i>=0;i-=2)
        {
            cout<<a[i]<<" ";
        }
    }
    if(n%2==1&&n>1)
    {
        for(int j=1;j<=n-2;j+=2)
        {
            if(j==n-2)
            {
                cout<<a[j]<<endl;
                break;
            }
            cout<<a[j]<<" ";
        }
    }
    else if(n%2==0&&n>1){
        for(int j=0;j<n;j+=2)
        {
            if(j==n-2)
            {
                cout<<a[j]<<endl;
                break;
            }
            cout<<a[j]<<" ";
        }
    }
    delete a;
    //delete b;
    return 0;
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

class HopcroftKarp {
    void bfs() {
        const int n = g.size();
        dist.assign(n, -1);
        queue<int> que;
        for (int i = 0; i < n; ++i) if (!used[i]) {
            que.push(i);
            dist[i] = 0;
        }
        while (!que.empty()) {
            int v = que.front();
            que.pop();
            for (int& u : g[v]) {
                int w = match[u];
                if (w >= 0 && dist[w] == -1) {
                    dist[w] = dist[v] + 1;
                    que.emplace(w);
                }
            }
        }
    }

    bool dfs(int v) {
        vv[v] = true;
        for (auto& u : g[v]) {
            int w = match[u];
            if (w < 0 || (!vv[w] && dist[w] == dist[v] + 1 && dfs(w))) {
                match[u] = v;
                used[v] = true;
                return true;
            }
        }
        return false;
    }
    
public:
    vector<vector<int>> g;
    vector<int> dist, match;
    vector<bool> used, vv;

    HopcroftKarp(int n, int m) : g(n), match(m, -1), used(n) {}

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

    int bipartite_matching() {
        const int n = g.size();
        int res = 0;
        while (true) {
            bfs();
            vv.assign(n, false);
            int flow = 0;
            for (int i = 0; i < n; ++i) {
                if (!used[i] && dfs(i)) ++flow;
            }
            if (!flow) break;
            res += flow;
        }
        return res;
    }

    void print() {
        for (int i = 0; i < match.size(); ++i) {
            if (~match[i]) cout << match[i] << " - " << i << endl;
        }
    }
};

// O(log max{a, b})
long long gcd(long long a, long long b) {
    while (b) {
        long long c = a % b;
        a = b;
        b = c;
    }
    return a;
}

int m, n;
int b[500], r[500];

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

    while (cin >> m >> n, m) {
        REP (i, m) cin >> b[i];
        REP (i, n) cin >> r[i];
        HopcroftKarp g(m, n);
        REP (i, m) REP (j, n) if (gcd(b[i], r[j]) > 1) {
            g.add_edge(i, j);
        }
        cout << g.bipartite_matching() << endl;
    }
}


Measured memory_bytes: 4448
#include<stdio.h>
#define MAX 100005
#define NIL -1

/*
 p: parent
 l: left-child
 r: right sibling
 */
struct Node{
  int p, l, r;
};
struct Node T[MAX]; // Tree
int n;
int depth(int u){
  int d = 0, i;
  for(i=u; T[i].p!=NIL; i=T[i].p, d++);
  return d;
}
int height(int u){
  int l = 0, r = 0,h=0;
    if (T[u].l != -1){
        l += height(T[u].l);
        l++;
    }
    if (T[u].r != -1){
        r += height(T[u].r);
        r++;
    }
    if(r>=l) h=r;
    else h=l;
  return h;
}
void print(int u){
  int sibling,degree;
  printf("node %d: parent = %d, ",u,T[u].p);
  if(T[u].p==NIL){
    sibling=-1;
  }else if(T[T[u].p].l==u){
    sibling=T[T[u].p].r;
  }else{
    sibling=T[T[u].p].l;
  }
  printf("sibling = %d, ",sibling);
  
  if(T[u].l == NIL && T[u].r == NIL){
    degree=0;
  }else if(T[u].l == NIL || T[u].r == NIL){
    degree=1;
  }else{
    degree=2;
  }
  printf("degree = %d, ",degree);
  printf("depth = %d, height = %d, ",depth(u),height(u));
  if(T[u].p==NIL){
    printf("root\n");
  }else if(height(u)==0){
    printf("leaf\n");
  }else{
    printf("internal node\n");
  }
  
   
}

int main(){
  int i, j, d, v, c, l,tmp;
  
  scanf("%d", &n);
  
  for ( i = 0; i < n; i++ ) {
    T[i].p = T[i].l = T[i].r = NIL;
  }
  
  for ( i = 0; i < n; i++ ){
    scanf("%d %d %d", &v, &d, &c);
    T[v].l = d;
    T[v].r = c;
    T[d].p = T[c].p = v;
  }
  for ( i = 0; i < n; i++ ) print(i);
  return 0;
}

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

int N;
int D[100005];
int main(){
  cin >> N;
  for(int i=0;i<N;i++){
    int a,b; cin >> a >> b;
    D[a]++; D[b+1]--;
  }
  D[0]++;

  int res = 0;
  for(int i=1;i<=N+1;i++){
    D[i] = D[i]+D[i-1];
    if( D[i] >= i ) res = i;
  }
  cout << res-1 << endl;
}

Measured memory_bytes: 1548
#include <bits/stdc++.h>
using namespace std;
#define int long long
int N , M , X;

int tab[20][20];
int c[20];
int actu[20];
int coutMin = 1e9;
void recursion(int in , int cc)
{
	if (in == N)
	{
		for (int i = 0 ; i < M ; i++)
		{
			if (actu[i] < X) return;
		}
		coutMin = min(coutMin , cc);
		return;
	}
	recursion(in + 1 , cc);
	for (int i = 0 ; i < M ; i++)
	{
		actu[i] += tab[in][i];
	}
	recursion(in + 1 , cc + c[in]);
	for (int i = 0 ; i < M ; i++)
	{
		actu[i] -= tab[in][i];
	}
}
int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	cin >> N >> M >> X;
	for (int i = 0 ; i < N ; i++)
	{
		cin>>c[i];
		for (int j = 0 ; j < M ; j++)
		{
			cin >> tab[i][j];
		}
	}
	recursion(0 , 0);
	if (coutMin != 1e9) cout<<coutMin<<endl;
	else cout<<-1<<endl;
}

Measured memory_bytes: 3664
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
using namespace std;

int main(void)
{
    int N;
    cin >> N;

    vector<int> d(N);
    for (int i = 0; i < N; i++)
        cin >> d[i];

    int ans = 0;
    for (int i = 0; i < N - 1; i++) {
        for (int j = i + 1; j < N; j++)
            ans += d[i] * d[j];
    }

    cout << ans << endl;

    return 0;
}


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

typedef long long int ll;

int mod(int a, int b) {  // 商を返す
  int res = a / b;
  if (a < res * b)
    res += 1;
  return res;
}

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

  if (!n) {  // ゼロ予防
    cout << 0 << endl;
    return 0;
  }

  int q;
  vector<int> res;
  while (n) {
    q = mod(n, -2);
    res.push_back(n - q * -2);
    n = q;
  }
  reverse(res.begin(), res.end());
  for (auto x : res) {
    cout << x;
  }
  cout << endl;
}


Measured memory_bytes: 256
n = gets.split.map(&:to_i)

if n[0] > n[1] && n[1] != 1 
	puts "Alice"
elsif n[0] < n[1] && n[0] != 1
	puts "Bob"
elsif n[0] == n[1]
	puts "Draw"
elsif n[0] == 1
	puts "Alice"
elsif n[1] == 1
	puts "Bob"
end

Measured memory_bytes: 1788
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<utility>
#include<algorithm>
using namespace std;
#define ll long long
#define vel vector<ll>
#define vvel vector<vel>
#define vvvel vector<vvel>
#define veb vector<bool>
#define pin pair<ll,ll>
#define mkp make_pair
#define mot pair<D,D>//time,dist
#define path pair<ll,int>//cost,to
#define int long long
using namespace std;
vvel ta_min(0);
vvel ta_max(0);
int leth = 1024 * 512;
int p = 1000000007;
vel par;
vel dis;
int n;
void mmax(ll &a, ll b) { a = max(a, b); }
void mmin(ll &a, ll b) { a = min(a, b); }
pin root(int ser) {
	if (par[ser] == -1) {return mkp(ser,0);}
	pin x=root(par[ser]);
	x.second += dis[ser];
	par[ser] = x.first;
	dis[ser] = x.second;
	return x;
}
void uni(int a, int b,int d) {
	pin p1 = root(a);
	pin p2 = root(b);
	int a1 = p1.first;
	int b1 = p2.first;
	if (a1 != b1) {
		par[b1] = a1;
		dis[b1] = d + dis[a] - dis[b];
	}
}
bool issame(int x, int y) {
	return root(x).first == root(y).first;
}
void ref(int &x) { x = x % p; x = (x + p) % p; }
int rui(int a, int n) {
	if (n == 0) { return 1; }
	int x = rui(a, n / 2);//return a^n%p
	x *= x; ref(x);
	if (n % 2 == 1) { x *= a; }
	ref(x);
	return x;
}
void nim(int x, int k) {
	while (1) {
		int x; int k; cin >> x >> k;
		vel gr(x + 1);
		gr[0] = 0;
		for (int i = 1; i <= x; i++) {
			vel ko(x + 1, 0);
			for (int j = 1; j <= i / k; j++) { ko[gr[i - j]]++; }
			int ind = 0;
			while (ko[ind] != 0) { ind++; }
			gr[i] = ind;
		}
		for (int i = 1; i <= x; i++) { cout << gr[i] << " "; }
	}
}
signed main() {
	int n, m; cin >> n >> m;
	cout << abs((n - 2)*(m - 2)) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstring>
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int n;
  vector<int> p;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int tmp;
    cin >> tmp;
    p.push_back(tmp);
  }
  int ans = 0;
  for (int i = 1; i < n - 1; i++) {
    if ((p[i - 1] < p[i] && p[i] < p[i + 1]) ||
        (p[i - 1] > p[i] && p[i] > p[i + 1]))
      ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
// Template
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <queue>

using namespace std;
typedef long long ll;

#define REP(i, n) for(int i = 0;i < n;i++)
#define INF 1 << 30
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

int MOD = 1000000007;

int H,W,D,Q;
std::vector<tuple<int, int, int>> A;

int main(){
    std::ios_base::sync_with_stdio(false);

    cin >> H >> W >> D;

    REP(i,H){
        REP(j,W){
            int a; cin >> a;
            A.push_back(tuple<int,int,int>(a,i,j));
        }
    }

    sort(A.begin(),A.end());

    std::vector<std::vector<int>> ruisekiwa;

    for(int start=0; start<D; start++){
        ruisekiwa.push_back(std::vector<int>());
        ruisekiwa[start].push_back(0);
        //cout << "start: " << start << endl;
        int i=0;
        for(int k=start+D; k<H*W; k+=D){

            int dist = abs(get<2>(A[k])-get<2>(A[k-D])) + abs(get<1>(A[k])-get<1>(A[k-D]));
            ruisekiwa[start].push_back(ruisekiwa[start][i]+dist);
            i++;
            //cout << ruisekiwa[start][i] << endl;
        }
        //cout << "\n";

    }

    cin >> Q;

    REP(i,Q){
        int l,r; cin >> l >> r;

        if(l%D==0){
            cout << ruisekiwa[D-1][max(0,r/D-1)] - ruisekiwa[D-1][max(0,l/D-1)] << endl;
        } else {
            cout << ruisekiwa[l%D-1][max(0,r/D)] - ruisekiwa[l%D-1][max(0,l/D)] << endl;
        }
        //cout << ruisekiwa[l%D][]
    }






    return 0;
}


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

int main(){
    int n, ans = 0;
    cin >> n;
    vector<int> d(n);
    for(int i = 0; i < n; i++) cin >> d[i];
    
    for(int i = 0; i < n - 1; i++){
        for(int j = i + 1; j < n; j++){
	    ans += d[i] * d[j];
        }
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(raw_input())
A = map(int, raw_input().split(' '))
B = map(int, raw_input().split(' '))

count = 0
zan_A_i = A[N]

for i in range(N):
    zan_B_i = B[N-1-i] - zan_A_i

    if zan_B_i < 0:
        zan_B_i = 0
    zan_A_i = A[N-1-i] - zan_B_i
    if zan_A_i < 0:
        count += zan_A_i 
        zan_A_i = 0

print(sum(B)+count)


Measured memory_bytes: 14520
/*
*/

#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>

#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk

#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds
#define ends asdgahhfdsfshdshfd

#define eps 1e-8
#define M_PI 3.141592653589793
#define bsize 512

#define ldouble long double
using namespace std;

#define bs 1000000007

const int N = 300031;

int a,b;

int main(){
//	freopen("apache.in","r",stdin);
//	freopen("apache.out","w",stdout);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
//	cin.tie(0);

	cin>>a>>b;
	if (b<a)
		--a;
	cout<<a<<endl;

//	cin.get(); cin.get();
	return 0;
}


Measured memory_bytes: 256
n = int(input())
xl = [list(map(int, input().split())) for _ in range(n)]

lr = []
for x, l in xl:
    lr.append([x - l, x + l])

lr.sort(key=lambda a: a[1])

cnt = 1
left, right = lr[0]
for ll, rr in lr:
    if ll >= right:
        cnt += 1
        left = ll
        right = rr

print(cnt)


Measured memory_bytes: 42792
import java.util.Scanner;

public class Main{
	public static void main(String[]args){
		//????????£?????????????????????
		Scanner sc = new Scanner(System.in);
		//??°?????????
		while(true){
			//a?????????
			int a = sc.nextInt();
			
			//op?????????
			String op = sc.next();
			
			//b?????????
			int b = sc.nextInt();
			
			//?????¶??? ?????????°??????
			if(op.equals("?")){
				break;
			}
			
			//?????¶??? op???+????????°??¨???
			if(op.equals("+")){
				System.out.println(a + b);
			//?????¶??? op???-????????°??¨???
			}else if(op.equals("-")){
				System.out.println(a - b);
			//?????¶??? op???*????????°??¨???
			}else if(op.equals("*")){
				System.out.println(a * b);
			//?????¶??? op???/????????°??¨???
			}else if(op.equals("/")){
				System.out.println(a / b);
			}
		}
	}
}

Measured memory_bytes: 26352
import java.io.BufferedReader
import java.io.BufferedWriter
import java.io.StringWriter

fun solve(c: Case) {
    if (c.intLine().any { it > 8 }) {
        c.println(":(")
    } else {
        c.println("Yay!")
    }
}

open class Case(
    val input: BufferedReader = System.`in`.bufferedReader(),
    val out: BufferedWriter = System.out.bufferedWriter()
) {
    fun exec(fn: (Case) -> Unit) = input.use { out.use { fn(this) } }
    fun println(c: CharSequence?) = out.appendln(c)
    fun intLine(): List<Int> = input.readLine().split(" ").map { it.toInt() }
}

fun main() = Case().exec(::solve)

Measured memory_bytes: 36628
A,B = map(int,input().split())

def solve(x):
    if x % 4 == 0:
        return x
    elif x % 4 == 1:
        return 1
    elif x % 4 == 2:
        return x+1
    elif x % 4 == 3:
        return 0
    
print(solve(A-1)^solve(B))

Measured memory_bytes: 2940
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <functional>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define REP(i,n) for(int i=0,_n=(n);(i)<(int)_n;++i)
#define RANGE(i,a,b) for(int i=(int)a,_b=(int)(b);(i)<_b;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define PRINT1(table, D0) REP(d0, D0) cout<<table[d0]<<" "; cout<<"\n";
#define PRINT2(table, D0, D1) REP(d0, D0) { REP(d1, D1) cout<<table[d0][d1]<<" "; cout<<"\n"; }
#define PRINT3(table, D0, D1, D2) REP(d0, D0) { REP(d1, D1) { REP(d2, D2) cout<<table[d0][d1][d2]<<" "; cout<<"\n"; } cout<<"\n"; }
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }

#define MOD 1000000007LL
#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	while(cin>>s) {
		bool ans = s[0]==s[1] && s[1]==s[2] || s[1]==s[2] && s[2]==s[3];
		cout<<(ans?"Yes":"No")<<endl;
	}
	
	return 0;
}


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

using namespace std;

typedef long long ll;

int main()
{
	ll x, y;
	cin >> x >> y;
	if(x % y == 0)
	{
		cout << "-1" << endl;
	}
	else
	{
		cout << x << endl;
	}
	return 0;
}

Measured memory_bytes: 256
nums = gets.split().map(&:to_i)
n = nums[0]
a = nums[1]
b = nums[2]

def sum_each_digits(n)
    sum = 0
    while n > 0 do
        sum += n % 10
        n /= 10
    end
    return sum
end

total = 0

(1..n).each do |i|
  sum = sum_each_digits(i)
  if sum >= a && sum <= b
      total += i
  end
end

p total

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
int main()
{
	char st[10];
	cin>>st;
	if(st[2]==st[3] && st[4]==st[5]){
		cout<<"Yes"<<"\n";
	}
	else{
		cout<<"No"<<"\n";
	}
	return 0;
}

Measured memory_bytes: 256
import bisect
a,b,q=map(int,input().split())
s=[int(input()) for i in range(a)]
s.extend([float("-inf"),float("inf")])
s.sort()
t=[int(input()) for i in range(b)]
t.extend([float("-inf"),float("inf")])
t.sort()
for i in range(q):
    x=int(input())
    s2=bisect.bisect_right(s,x)
    s1=s2-1
    t2=bisect.bisect_right(t,x)
    t1=t2-1
    print(min(x-min(s[s1],t[t1]),max(s[s2],t[t2])-x,x-s[s1]*2+t[t2],t[t2]*2-x-s[s1],x-t[t1]*2+s[s2],s[s2]*2-x-t[t1]))

Measured memory_bytes: 12072
K = int(input())
A = tuple(map(int,input().split()))


lo = 2
hi = 3
for a in reversed(A):

    nl = (lo-1)//a+1
    nh = (hi-1)//a+1

    lo,hi = nl*a,nh*a

if lo < hi:
    print(lo,hi-1)
else:
    print(-1)

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

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

const int max_n = 3000;
Int N,K;
Int fact[max_n];
Int invfact[max_n];
Int inv[max_n];

void init(void) {
    fact[0] = fact[1] = 1;
    inv[0] = inv[1] = 1;
    invfact[0] = invfact[1] = 1;

    for(Int i = 2;i <= N;i++) {
        fact[i] = i*fact[i-1]%MOD;
        inv[i] = MOD - (MOD/i)*inv[MOD%i] % MOD;
        invfact[i] = inv[i]*invfact[i-1]%MOD;
    }
}

Int comb(Int n, Int r) {
    if(n < 0 || n < r)
        return 0;

    return ((fact[n]*invfact[n-r]%MOD)*invfact[r])%MOD;
}

int main(void) {
    cin>>N>>K;

    init();

    for(Int i = 1;i <= K;i++) {
        cout<<comb(N-K+1,i)*comb(K-1,i-1)%MOD<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
n, k = [int(elem) for elem in input().split()]
sunukes = [0] * n
for i in range(k):
    d = int(input())
    a_lst = [int(elem) for elem in input().split()]
    for j in a_lst:
        sunukes[j-1] += 1

print(sunukes.count(0))

Measured memory_bytes: 9176
#include<iostream>
using namespace std;
int main() {
	int N;
	int d[100] = {};
	int sum = 0;
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> d[i];
	}

	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < i; j++)
		{
			sum += d[i] * d[j];
		}
	}
	
	cout << sum;
	return 0;


}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;

typedef pair<int, int>pi;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
typedef pair<P, P> PPP;

const ll MOD = 1e9 + 7;
const ll INF = 9e18;
const double DINF = 5e14;
const double eps = 1e-10;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };

#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define pb push_back
#define eb emplace_back
#define fr first
#define sc second

int mn[1 << 25], n, d[50], cnt[13], ans;
vector<int>v;

int main() {
	cin >> n;
	v.eb(0);
	cnt[0]++;
	cnt[12]++;
	for (int i = 0;i < n;i++) {
		cin >> d[i];
		if (cnt[d[i]] == 2) {
			cout << 0 << endl;
			return 0;
		}
		cnt[d[i]]++;
		v.eb(d[i]);
	}
	for (int i = 0;i < (1 << 24);i++)mn[i] = 1000;
	for (int i = 0;i < (1 << 24);i++) {
		int b = -1, fir = -1;
		for (int j = 0;j < 24;j++) {
			if (b == -1 && i&(1 << j))b = j, fir = j;
			else if (i&(1 << j)) {
				mn[i] = min(mn[i], j - b);
				b = j;
			}
		}
		if (b == fir) {
			mn[i] = 0;
			continue;
		}
		mn[i] = min(mn[i], fir + 24 - b);
	}
	for (int i = 0;i < (1 << (int)v.size());i++) {
		int now = 0;
		bool fl = 0;
		for (int j = 0;j < v.size();j++) {
			if (i&(1 << j)&&!(now&(1<<v[j])))now |= (1 << v[j]);
			else if (!(i&(1 << j)) && !(now&(1 << (24 - v[j]) % 24))) now |= (1 << (24 - v[j]) % 24);
			else {
				fl = 1;
				break;
			}
		}
		if(!fl)ans = max(ans, mn[now]);
	}
	cout << ans << endl;
	return 0;
}


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

string s;
int n;

int main(){

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

    cin>>s;
    for(int i=0;i<s.size();i++){
        n+=s[i]=='x';
    }
    if(n>7){
        cout<<"NO"<<endl;
    }else{
        cout<<"YES"<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
 string S;
 cin>>S;
 int a=S.size();
 if(S.at(a-1)=='3'){
   cout<<"bon"<<endl;
 }
 else if(S.at(a-1)=='0'||S.at(a-1)=='1'||S.at(a-1)=='6'||
 S.at(a-1)=='8'){
  cout<<"pon"<<endl;
 }
 else{
  cout<<"hon"<<endl;
 }
}



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

using namespace std;

#define ff first
#define ss second

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<long long, long long> pl;

const int MOD = 1e9 + 7;
const ll INF = 1e18;
const double EPS = 1e-6;
const int MAX_D = 105;

namespace modOp {
    ll add(ll a, ll b, ll mod = MOD) { return (a + b) % mod; }
    ll sub(ll a, ll b, ll mod = MOD) { return (a - b + mod) % mod; }
    ll mul(ll a, ll b, ll mod = MOD) { return (ll)a * b % mod; }
}
using namespace modOp;

string K;
int D;
ll dp[MAX_D][2][2];

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> K >> D;
	dp[0][0][0] = 1;
	for (int i = 0; i < K.size(); ++i) {
		for (int sum = 0; sum < D; ++sum) {
			for (bool flag: {true, false}) {
				for (int digit = 0; digit <= 9; ++digit) {
					if (digit > K[i] - '0' && !flag) break;
					dp[add(sum, digit, D)][flag || (digit < K[i] - '0')][1] = add(dp[sum][flag][0], dp[add(sum, digit, D)][flag || (digit < K[i] - '0')][1]);
				}
			}
		}
		for (int sum = 0; sum < D; ++sum) {
			for (bool flag: {true, false}) {
				dp[sum][flag][0] = dp[sum][flag][1];
				dp[sum][flag][1] = 0;
			}
		}
	}

	cout << sub(add(dp[0][0][0], dp[0][1][0]), 1) << '\n';

	return 0;
}

Measured memory_bytes: 256
// http://yumai6.hatenablog.com/entry/2015/12/21/222930

#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < (n);i++)
#define REPR(i, n) for(int i = (n);i >= 0;i--)
#define FOR(i, m, n) for(int i = (m);i < (n);i++)
#define FORR(i, m, n) for(int i = (m);i >= (n);i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

//---------------------------------------------------------------
//---------------------------------------------------------------


signed main(){
	int x;
	
	cin >> x;
	
	if(x==7||x==5||x==3) cout << "YES" << endl;
	else			cout << "NO" << endl;

	return 0;
}


Measured memory_bytes: 256
# coding: utf-8
# hello worldと表示する
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n,k=MI()
lis=LI()
minus=[]
plus=[]
zero=0
for i in range(n):
    if lis[i]<0:
        minus.append(lis[i])
    elif lis[i]>0:
        plus.append(lis[i])
    else:
        zero+=1
#print(plus)
#print(minus)
#print(zero)
p=len(plus)
m=len(minus)

if n-zero<k:
    ans=0
    print(ans%mod)
    sys.exit()
if p>=k:
    state="plus"
elif (k-p)%2==0:
    state="plus"
elif m>=k-p+1:
    if k%2==1:
        if p>0:
            state="plus"
        else:
            if zero>0:
                ans=0
                print(ans%mod)
                sys.exit()
            else:
                state="minus"
    else:    
        state="plus"
else:
    if zero>0:
        ans=0
        print(ans%mod)
        sys.exit()
    else:
        state="minus"
#print(state)
if state=="plus":
    ans=1
    plus.sort(reverse=True)
    minus.sort()
    pros=[]
    if k%2==1:
        ans*=plus[0]
        k-=1
        for i in range((p-1)//2):
            pros.append(plus[2*i+1]*plus[2*i+2])
    else:
        ans*=1
        for i in range(p//2):
            pros.append(plus[2*i]*plus[2*i+1])
    for i in range(m//2):
        pros.append(minus[2*i]*minus[2*i+1])
    pros.sort(reverse=True)
    for i in range(k//2):
        ans=(ans*pros[i])%mod
    print(ans%mod)
    sys.exit()
elif state=="minus":
    ans=1
    plus.sort()
    minus.sort(reverse=True)
    pros=[]
    ans*=minus[0]
    k-=1
    if k%2==1:
        ans*=plus[0]
        k-=1
        for i in range((p-1)//2):
            pros.append(plus[2*i+1]*plus[2*i+2])
    else:
        for i in range(p//2):
            pros.append(plus[2*i]*plus[2*i+1])
    for i in range((m-1)//2):
        pros.append(minus[2*i+1]*minus[2*i+2])
    pros.sort()
    for i in range(k//2):
        ans=(ans*pros[i])%mod
    print(ans%mod)
    sys.exit()
    
    
        
        
            
    
    
        
        

    

Measured memory_bytes: 104488
#define  _CRT_SECURE_NO_WARNINGS
#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144*2LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

unsigned long xor128() {
	static unsigned long x = 123456789, y = 362436069, z = 521288629, w = time(NULL);
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(20);
}
#define int ll
vector<int> gogo[200];
int dp[(1 << 16)];
void solve(){
	int n, m, k;
	cin >> n >> m >> k;
	vector<int> black;
	REP(i, m) {
		int a;
		cin >> a;
		a--;
		black.push_back(a);
	}
	REP(i, n) {
		REP(q, k) {
			int a;
			cin >> a;
			a--;
			gogo[i].push_back(a);
		}
	}
	REP(i, (1 << 16)) {
		dp[i] = 1e9;
	}
	queue<int> next;
	next.push((1 << m) - 1);
	dp[next.front()] = 0;
	while (next.empty() == false) {
		int now = next.front();
		next.pop();
		REP(i, k) {
			int next_go = 0;
			REP(q, m) {
				if ((1 << q) & now) {
					int going = gogo[black[q]][i];
					REP(j, black.size()) {
						if (black[j] == going) {
							next_go |= (1 << j);
						}
					}
				}
			}
			if (dp[next_go] == 1e9) {
				dp[next_go] = dp[now] + 1;
				next.push(next_go);
			}
		}
	}
	cout << dp[0] << endl;
}

#undef int
int main() {
	init();
	solve();
}


Measured memory_bytes: 3864
#include"bits/stdc++.h"
using namespace std;
int main(){
	int n,m;
	int temp;
	cin>>n>>m;
	priority_queue <int> q;
	for(int i=0;i<n;i++){
		scanf("%d",&temp);
		q.push(temp);
	}
	for(int i=0;i<m;i++){
		q.push(q.top()/2);
		q.pop();
	}
	long long sum=0;
	while(!q.empty()){
		sum+=q.top();
		q.pop();
	}
	cout<<sum<<endl;
}

Measured memory_bytes: 892
#include <iostream>
int main(){
   
    int a = 0,b = 0,c = 0,d = 0;
    std::cin >> a >> b >> c >> d;
    
    d = a+b;
        
    if(d >= c){
        
     std::cout << "Yes";
      
    }else{
     
        std::cout << "No";
        
    }
    
}


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

#define ll 				long long
#define vi 				vector<ll>
#define vb 				vector<bool>
#define vvi				vector<vi>
#define vvb				vector<vb>
#define vii				vector<pair<ll,ll>>
#define pii				pair<ll,ll>
#define mii 			map<ll,ll>
#define rev(a); 		reverse(a.begin(), a.end());
#define sortv(a); 		sort(a.begin(), a.end());
#define sortd(a); 		sort(a.begin(), a.end(), greater<int>());
#define FOR(i,a,b) 		for (int i = (a); i < (b); i++)
#define ROF(i,a,b) 		for (int i = (b)-1; i >= (a); i--)
#define pb 				push_back
#define mp 				make_pair
#define printv(a);		FOR(_Q,0,(int)(a).size())cout<<(a)[_Q]<<" ";cout<<'\n';
#define IOS 			ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);

void solve();

ll MOD = 1000000007;
ll INF = LLONG_MAX;

/*****************************************************************************/
signed main() {
	IOS;
	int s,w;cin>>s>>w;
	if (w>=s) {
		cout<<"un";
	} 
		cout<<"safe";
	
}

Measured memory_bytes: 3596
#include <iostream>
using namespace std;
int main(){
   int a;
   int b;
   cin>>a;
   cin>>b;
   
    if(a<b) {
    cout<<"a < b"<<endl;
    }
    else if(a>b){
    cout<<"a > b"<<endl;
    }
    else if(a=b){
        cout<<"a == b"<<endl;
    }
}


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

void solve(std::istream &ist, std::ostream &ost)
{
    /* ------- 宣言と入力 ------- */

    int N, M;

    ist >> N >> M;

    vector<int> A;
    int vote_sum = 0;

    for (int i = 0; i < N; i++)
    {
        int tmp;
        ist >> tmp;
        A.emplace_back(tmp);
        vote_sum += A[i];
    }

    /* ------- 計算 ------- */

    //sort(A.begin(), A.end(), std::greater<int>());

    int choose = 0;

    for (auto it = A.begin(); it != A.end(); it++)
    {
        if (*it >= ceil((double)vote_sum / (4 * M)))
        {
            choose++;
        }
    }

    if (choose >= M)
    {
        ost << "Yes" << endl;
    }
    else
    {
        ost << "No" << endl;
    }
}

#ifndef WOMAIN
int main()
{
    solve(std::cin, std::cout);
    return 0;
}
#endif


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


int main(){
  int A, B, i, s = 0;

  cin >> A >> B;
  for(i = A; i < B+1; i++){
    if(i/10000 == i % 10 && (i/1000) % 10 == (i/10) % 10){
      s++;
      //cout << i << endl;
    }
  }
  cout << s << endl;    
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <map>
using namespace std;

int N;

vector<int> mem;
vector<int> mas;

vector<int> item[25];


int w[16];
int h[16];
int a[4][4];
int memo[(1<<25)/6+10];

char dfs(int bit){

	if( bit == 0 ) return 0;
	int idx = bit/6;
	int pos = (bit%6)*5;
	//cout << pos << endl;
	char val = memo[idx] >> pos & ((1<<5)-1);
	//cout << (int)val << endl;
	if( val != ((1<<5)-1) ) return val;
	
	char ans = 30;
	for(int p = 0 ; p < 25 ; p++){
		if( bit >> p & 1 ){
			for(int i = 0 ; i < item[p].size() ; i++)
				ans = min(ans,(char)(dfs(bit^item[p][i])+1));
			break;
		}
	}
	memo[idx] &= ~(((1<<5)-1) << pos);
	memo[idx] |= ((int)ans << pos );
	return  ans;
}

int main(){
	memset(memo,-1,sizeof(memo));
	
	for(int w = 1 ; w <= 5 ; w++){
		for(int h = 1 ; h <= 5 ; h++){
			for(int i = 0 ; i <= 5 - h ; i++){
				for(int j = 0 ; j <= 5 - w ; j++){
					int mask = 0;
					for(int k = 0 ; k < h ; k++)
						for(int l = 0 ; l < w ; l++)
							mask |= (1<<((i+k)*5+j+l));
					//cout << init << " " << mask << endl;
					item[i*5+j].push_back(mask);
				}
			}
		}
	}
	while(cin >> N && N){
		int init = 0;
		for(int i = 0 ; i < N ; i++){
			for(int j = 0 ; j < N ; j++){
				int c = 0;
				cin >> c;
				init |= (c<<(i*5+j));
			}
		}
		//cout << init << endl;
		int x = (int)dfs(init);
		for(int i = 0 ; i < x ; i++) cout << "myon";
		cout << endl;
	}
}

Measured memory_bytes: 23060
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    if (A <=8 && B <= 8) {
      System.out.println("Yay!");
    } else {
      System.out.println(":(");
    }
  }

  private static final long MOD = 998244353;
  private static long FACT[];
  private static long IFACT[];

  // Pre-calculate factorial and its mod_inverse for calculate nCr in O(1)
  private static void create_fact(int N) {
    FACT = new long[N+1];
    IFACT = new long[N+1];
    FACT[0] = 1;
    IFACT[0] = 1;
    for (int i=1; i<=N; i++) {
      FACT[i] = FACT[i-1] * i % MOD;
      IFACT[i] = mod_inverse(FACT[i]);
    }
  }

  // Return nCr
  private static long comb(int n, int r) {
    if (n < 0 || r < 0 || n < r) {
      return 0;
    }
    if (r > n/2) {
      r = n - r;
    }
    return FACT[n]*IFACT[n-r]%MOD*IFACT[r]%MOD;
  }

  // Fast mod inverse
  private static long mod_inverse(long a) {
    long b = MOD;
    long p = 1, q = 0;
    while (b > 0) {
      long c = a / b;
      long d;
      d = a;
      a = b;
      b = d % b;
      d = p;
      p = q;
      q = d - c * q;
    }
    return p < 0 ? p + MOD : p;
  }
}


Measured memory_bytes: 23764
#include <cstdio>



int main() {
    int k, s, rez = 0;
    scanf("%d%d", &k, &s);
    for (int x = 0; x <= k; x++) {
        for (int y = 0; y <= k; y++) {
            if (s - k <= x + y && x + y <= s)
                rez++;
        }
    }
    printf("%d", rez);
    return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using namespace std;
const static int INT_INF = 2147483647;

int main()
{
	int p, q, r;
	cin >> p >> q >> r;
	int ans = min(r + p, min(p + q, q + r));
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 384
import java.util.ArrayList

fun main(args: Array<String>){
    val n :Int = readLine()!!.toInt()
    val a :List<String> = readLine()!!.split(" ")
    val input :ArrayList<Int> = ArrayList()
    var large :Int = 0
    var small :Int = 0
    for(i in a.indices){
        input.add(a[i].toInt())
    }
    input.sort()
    for(i in n-1 downTo 0 step 2){
        large += input[i]
        //println(input[i])
    }
    for(i in n-2 downTo 0 step 2){
        small += input[i]
        //println(input[i])
    }
    println(large - small)
}


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

const int maxn = 200005;
int n, a[maxn], l[maxn], r[maxn];

int main() {
    cin >> n;
    stack <int> stk;
    stk.push(0);
    for (int i = 1; i <= n; i++){
        cin >> a[i];
        while (a[i] < a[stk.top()]) stk.pop();
        l[i] = stk.top();
        stk.push(i);
    }
    while (!stk.empty()) stk.pop();
    stk.push(n+1);
    long long ans = 0;
    for (int i = n; i >= 1; i--){
        while (a[i] < a[stk.top()]) stk.pop();
        r[i] = stk.top();
        stk.push(i);
        ans += 1LL * a[i] * (i-l[i]) * (r[i]-i);
    }
    cout << ans << "\n";
}


Measured memory_bytes: 3456
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if(a*c <= b) System.out.println(c);
		else System.out.println(b/a);

	}

}


Measured memory_bytes: 23636
#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <stack>
#include <map>
#include <numeric>
#include <sstream>
#include <queue>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define PUSH(n,v) for(int i=0; i<(n); i++) {int j; cin >> j; v.push_back(j);}
#define ALL(v) v.begin(), v.end()
#define print(s) cout << (s) << endl

typedef pair<int,int> P;
const P NOT_EXIST = make_pair(-1,-1);

P getNonZero(vector<vector<int>> bd) {
    REP(i,bd.size()) {
        REP(j,bd[0].size()) {
            if (bd[i][j] != 0) return make_pair(i,j);
        }
    }
    return NOT_EXIST;
}

bool hasSameId(int x, int y, int id, vector<vector<int>> bd) {
    int H = bd.size();
    int W = bd[0].size();
    if (id == 0) return false;
    if (!(x >= 0 && x < H)) return false;
    if (!(y >= 0 && y < W)) return false;
    return bd[x][y] == id;
}

void printBoard(vector<vector<int>> bd) {
    REP(i,bd.size()) {
        REP(j,bd[0].size()) {
            cout << bd[i][j];
        }
        cout << endl;
    }
}

void solve118(int H, int W) {
    vector<vector<int>> bd(H,vector<int>(W));
    REP(i,H) {
        string s;
        cin >> s;
        REP(j,W) {
            if (s[j] == '#') bd[i][j] = 1;
            else if (s[j] == '*') bd[i][j] = 2;
            else bd[i][j] = 3;
        }
    }
    
    int ans = 0;
    P nonZero;
    while ((nonZero = getNonZero(bd)) != NOT_EXIST) {
        queue<P> q;
        q.push(nonZero);
        ans += 1;
        while (q.size()) {
            P fr = q.front();
            int x, y, id;
            x = fr.first;
            y = fr.second;
            id = bd[x][y];
            bd[x][y] = 0;
            if (hasSameId(x+1,y,id,bd)) q.push(make_pair(x+1, y));
            if (hasSameId(x-1,y,id,bd)) q.push(make_pair(x-1, y));
            if (hasSameId(x,y+1,id,bd)) q.push(make_pair(x, y+1));
            if (hasSameId(x,y-1,id,bd)) q.push(make_pair(x, y-1));
            q.pop();
        }
        //printBoard(bd);
    }
    cout << ans << endl;
}

int main() {
    int H, W;
    while (cin >> H >> W, H + W) {
        solve118(H,W);
    }
    return 0;
}

Measured memory_bytes: 3264
#include <iostream>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

const int INF = 1 << 29;
const int MAXN = 8;
const int MAXM = 30;

int main()
{
	while (true) {
		int n, m, p, a, b;

		cin >> n >> m >> p >> a >> b;

		if (n == 0 && m == 0 && p == 0 && a == 0 && b == 0) {
			break;
		}

		int dist[MAXM][MAXM];
		double dp[MAXM][1 << MAXN];
		int t[MAXN];
		priority_queue<pair<double, pair<int, int>>, vector<pair<double, pair<int, int>>>, greater<pair<double, pair<int, int>>>> pq;

		rep(i, MAXM) {
			rep(j, 1 << MAXN) {
				dp[i][j] = INF;
			}
		}

		rep(i, MAXM) {
			rep(j, MAXM) {
				dist[i][j] = -1;
			}
		}

		rep(i, n) {
			cin >> t[i];
		}

		rep(i, p) {
			int x, y, z;

			cin >> x >> y >> z;

			dist[x - 1][y - 1] = z;
			dist[y - 1][x - 1] = z;
		}

		pq.push({ 0,{a - 1,0} });
		dp[a - 1][0] = 0;

		while (pq.empty() == false) {
			pair<double, pair<int, int>> temp = pq.top();
			pq.pop();

			if (temp.first > dp[temp.second.first][temp.second.second]) {
				continue;
			}

			rep(i, m) {
				if (dist[temp.second.first][i] != -1) {
					rep(j, n) {
						if (((temp.second.second >> j) & 1) == 0) {
							double plus = (double)dist[temp.second.first][i] / t[j];
							double ndist = temp.first + plus;
							int next = temp.second.second | (1 << j);

							if (ndist < dp[i][next]) {
								dp[i][next] = ndist;
								pq.push({ ndist,{i,next} });
							}
						}
					}
				}
			}
		}

		double ans = INF;

		rep(i, 1 << n) {
			ans = min(ans, dp[b - 1][i]);
		}

		if (ans == INF) {
			cout << "Impossible" << endl;
		}
		else {
			cout << ans << endl;
		}
	}

	return 0;
}

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

int main() {
  int N,M;
  cin>>N>>M;
  vector<int>L(M),R(M);
  for(int i=0;i<M;i++){
    cin>>L.at(i)>>R.at(i);
  }
  sort(L.begin(),L.end());
  sort(R.begin(),R.end());
  if(R.at(0)-L.at(M-1)+1<0){
    cout<<"0"<< endl;
    return 0;
  }
  cout<<R.at(0)-L.at(M-1)+1<< endl;
}

Measured memory_bytes: 1024
import java.io.*;
import java.util.*;

class Main{
	public static void main(String[] args){
		solve();
	}
	public static void solve(){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int count = 0;
		boolean flag = false;
		for(int i=1;i<=12;i++){
			for(int j=1;j<=31;j++){
				if(i==j){
					count++;
				}
				if(i==a && j==b){
					flag = true;
					break;
				}
			}
			if(flag){
				break;
			}
		}

		System.out.println(count);
	}
}


Measured memory_bytes: 21844
import Prelude
import Data.List
import Control.Monad

solver :: Int->[Int]->Int
solver p list
    |p==1 && on==0 = 0
    |p==0 && on==0 = 2^nn
    |otherwise = 2^(nn-1)
    where
        on = length $ filter odd list
        nn = length list

main = do
    [n, p] <- map read . words <$> getLine
    list <- map read . words <$> getLine
    -- 出力
    print $ solver p list



Measured memory_bytes: 764
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define yesno(flg) if(flg){cout<<'YES'<<endl;}else{cout<<'NO'<<endl;}
#define vi vector<int>
#define pb push_back
#define i197 1000000007
#define MAX_N 200002
using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<Pii,int> Piii;
typedef pair<int,ll> Pil;
typedef pair<ll,ll> Pll;
typedef pair<string,int> Psi;
typedef pair<Psi,int> Psii;

const int inf=1000000000;
struct edge{
	int myc,to,c,cost;
};
struct pos{
	int to,cost,color;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

vi vec[200001];
int x[200001]={};
int dp[200001];
int main() {
	string s,t;
	cin>>s>>t;
	int r=0;
	rep(i,3){
		if(s[i]==t[i])r++;
	}
	cout<<r<<endl;	
	return 0;
}


Measured memory_bytes: 4992
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string;

immutable long MOD = 10^^9 + 7;

void main() {
    auto s = readln.split.map!(to!int);
    auto H = s[0];
    auto W = s[1];
    auto A = readln.split.map!(to!int).array;
    auto B = readln.split.map!(to!int).array;

    int[int] cnta;
    int[int] cntb;
    foreach (a; A) cnta[a] += 1;
    foreach (b; B) cntb[b] += 1;

    if (cnta.values.map!(v => v >= 2).any || cntb.values.map!(v => v >= 2).any) {
        writeln(0);
        return;
    }

    auto AA = H.iota.map!(i => tuple(A[i], i)).array;
    auto BB = W.iota.map!(i => tuple(B[i], i)).array;
    AA.sort!"a > b";
    BB.sort!"a > b";
    auto usedr = new bool[](H);
    auto usedc = new bool[](W);
    long ans = 1;
    long tmpr = 0;
    long tmpc = 0;

    for (int i = 0, j = 0, k = H * W; k > 0; --k) {
        bool fa, fb;
        if (i < H && AA[i][0] == k) fa = true;
        if (j < W && BB[j][0] == k) fb = true;

        if (fa && fb) {
            usedr[AA[i][1]] = true;
            usedc[BB[j][1]] = true;
            tmpr += 1;
            tmpc += 1;
            ++i;
            ++j;
        } else if (fa) {
            if (tmpc == 0) {
                writeln(0);
                return;
            }
            ans = ans * tmpc % MOD;
            usedr[AA[i][1]] = true;
            tmpr += 1;
            ++i;
        } else if (fb) {
            if (tmpr == 0) {
                writeln(0);
                return;
            }
            ans = ans * tmpr % MOD;
            usedc[BB[j][1]] = true;
            tmpc += 1;
            ++j;
        } else {
            if (tmpr == 0 || tmpc == 0 || tmpr * tmpc <= H * W - k) {
                writeln(0);
                return;
            }
            ans = ans * (tmpr * tmpc % MOD - (H * W % MOD - k)) % MOD;
            ans = (ans + MOD) % MOD;
        }
    }

    ans.writeln;
}


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

public class Main {

	public static void main(String[] args) throws IOException {
		//
		BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
		String[] inputStr = new String[Integer.parseInt((input.readLine()))];
		inputStr = (input.readLine()).split("\\s");
		int[] inputInt = new int[inputStr.length];

		for (int i = 0; i < inputInt.length; i++) {
			inputInt[i] = Integer.parseInt(inputStr[i]);
		}

/*		int tmp;
		for (int i = 0; i < inputInt.length; i++) {
			for (int j = 0; j < inputInt.length -1; j++) {
				if (inputInt[j] <= inputInt[j +1]) {
					tmp = inputInt[j];
					inputInt[j] = inputInt[j +1];
					inputInt[j +1] = tmp;
				}
			}
		}
*/		for (int i = inputInt.length -1; i >= 0; i--) {
			System.out.print(inputInt[i]);
			if (i != 0) {
			  System.out.print(" ");
			}
		}
		System.out.println();
	}

}



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

using namespace std;

int main() {
    string s;
    cin >> s;

    int p = s.length() / 2;
    for (int i = 0; i < s.length(); i++) {
        if (s[i] == 'p') {
            p--;
        }
    }

    cout << p << endl;

    return 0;
}

Measured memory_bytes: 512
#include <cstdio>
#include <stdlib.h>

int main()
{
    int s[600];
    int t[6];
    int c = 0;
    char h[4] = {'N', 'S', 'W', 'E'};
    int n;
    bool a = false;
    scanf("%d", &n);
    for (int i = 0; i < 6 * n; i++)
    {
        scanf("%d", &s[i]);
    }
    for (int i = 0; i < n; i++)
    {
        while (1)
        {
            int k = rand() % 4;
            if (h[k] == 'N')
            {
                t[4] = s[0 + i * 6];
                t[0] = s[1 + i * 6];
                t[1] = s[5 + i * 6];
                t[5] = s[4 + i * 6];
                t[2] = s[2 + i * 6];
                t[3] = s[3 + i * 6];
            }
            if (h[k] == 'S')
            {
                t[0] = s[4 + i * 6];
                t[1] = s[0 + i * 6];
                t[5] = s[1 + i * 6];
                t[4] = s[5 + i * 6];
                t[2] = s[2 + i * 6];
                t[3] = s[3 + i * 6];
            }
            if (h[k] == 'W')
            {
                t[0] = s[2 + i * 6];
                t[2] = s[5 + i * 6];
                t[5] = s[3 + i * 6];
                t[3] = s[0 + i * 6];
                t[1] = s[1 + i * 6];
                t[4] = s[4 + i * 6];
            }
            if (h[k] == 'E')
            {
                t[2] = s[0 + i * 6];
                t[5] = s[2 + i * 6];
                t[3] = s[5 + i * 6];
                t[0] = s[3 + i * 6];
                t[1] = s[1 + i * 6];
                t[4] = s[4 + i * 6];
            }
            for (int j = 0; j < 6; j++)
            {
                s[j + i * 6] = t[j];
            }
            for (int j = i + 1; j < n; j++)
            {
                if (s[0 + i * 6] == s[0 + j * 6] && s[1 + i * 6] == s[1 + j * 6] && s[2 + i * 6] == s[2 + j * 6] && s[3 + i * 6] == s[3 + j * 6] && s[4 + i * 6] == s[4 + j * 6] && s[5 + i * 6] == s[5 + j * 6])
                {
                    a = true;
                    break;
                }
            }
            if (c == 1000)
            {
                break;
            }
            c += 1;
        }
    }

    if (a == false)
    {
        printf("Yes\n");
    }
    if (a == true)
    {
        printf("No\n");
    }
}


Measured memory_bytes: 2684