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

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

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

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

using namespace std;

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

using ll=long long;
using R = long double;
const R PI = acos(-1.0L);

const ll prime = 200003LL;
const ll root = 2LL;

using C = complex<R>;

// inline C mul (const C &a, const C &b) {
// 	const R ar = real(a);
// 	const R ai = imag(a);
// 	const R br = real(b);
// 	const R bi = imag(b);
	
// 	const C ret = C(
// 		ar * br - ai * bi,
// 		ar * bi + br * ai
// 	);

// 	return ret;
// }

void fft(vector<C> &a, bool inv) {
	const int n = a.size();
	const R sign = (inv ? -1.0 : 1.0);

	int rj = 0;
	rep(j, 1, n - 1) {
		for (int k = n >> 1; k > (rj ^= k); k >>= 1);
		if (j < rj) swap(a[j], a[rj]);
	}

	for (int m = 1; m < n; m <<= 1) {
		C wn = exp(C(0.0, sign * PI / m)), w = 1.0;
		rep(p, m) {
			for (int s = p; s < n; s += 2 * m) {
				C u = a[s];
				C v = a[s + m] *  w;
				a[s] = u + v, a[s + m] = u - v;
			}
			w *= wn;
		}
	}
	if (inv) rep(i, n) a[i] /= n;
}

vector<C> convolution(vector<C> a) {
	int fft_size = 1;
	while (fft_size < 2 * a.size()) fft_size <<= 1;

	a.resize(fft_size), fft(a, 0);
	
	vector<C> c(fft_size, 0.0);
	rep(i, fft_size) c[i] = a[i] * a[i];

	fft(c, 1);
	return c;
}

ll val2idx[prime];
ll idx2val[prime];

void init() {
	ll cur = root;
	rep(i, 1, prime) {
		val2idx[cur] = i;
		idx2val[i] = cur;
		cur = 1LL * cur * root % prime;
	}
}

int main(void){
	init();
	vector<ll> coef(prime, 0LL);

	int n;
	cin >> n;
	vector<ll> a(n);
	rep(i, n) {
		cin >> a[i];
		if(a[i] == 0) continue;
		coef[val2idx[a[i]] - 1]++;
	}

	vector<C> tmp_coef;
	for(auto &elem: coef) {
		tmp_coef.push_back(C(elem, 0.0));
	}

	vector<C> tmp_res = convolution(tmp_coef);
	vector<ll> res;
	for(auto &elem: tmp_res) {
		res.push_back(round(real(elem)));
	}


	ll ans = 0LL;
	rep(i, 2 * prime) {
		const ll modified_i = (i + 1)  % (prime - 1) + 1;
		ans += 1LL * res[i] * idx2val[modified_i];
	}

	rep(i, n) {
		ans -= 1LL * a[i] * a[i] % prime;
	}

	ans /= 2LL;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 49184
#include<stdio.h>
#include<algorithm>
using namespace std;
int UF[1000000];
int FIND(int a){
	if(UF[a]<0)return a;
	return UF[a]=FIND(UF[a]);
}
void UNION(int a,int b){
	a=FIND(a);b=FIND(b);
	if(a==b)return;
	UF[a]+=UF[b];
	UF[b]=a;
}
int mod=1000000007;
int main(){
	int a,b;
	while(scanf("%d%d",&a,&b),a){
		for(int i=0;i<a;i++)UF[i]=-1;
		for(int i=0;i<b;i++){
			int c,d;
			scanf("%d%d",&c,&d);
			c--;d--;
			UNION(c,d);
		}
		int count=0;
		for(int i=0;i<a;i++){
			if(UF[i]<0)count++;
		}
		int ret=1;
		for(int i=0;i<count;i++)ret=ret*2%mod;
		if(count!=a)ret=(ret+1)%mod;
		printf("%d\n",ret);
	}
}

Measured memory_bytes: 1416
import math

inl = input().split(' ')
length = len(inl[0])
n = int(inl[0])

hate = input().split(' ')

def checkhate(n,hate):
	n_str = str(n)
	for c in n_str:
		if c in hate:
			return False
	return True

while not checkhate(n,hate):
	n += 1

print(n)


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

// macros
#define pb emplace_back
#define mk make_pair
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define irep(itr, st) for(auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for(auto itr = (st).rbegin(); itr != (st).rend(); ++itr)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define bit(n) (1LL<<(n))
// functions
template <class T>bool chmax(T &a, const T &b){if(a < b){a = b; return 1;} return 0;}
template <class T>bool chmin(T &a, const T &b){if(a > b){a = b; return 1;} return 0;}
template <typename T> istream &operator>>(istream &is, vector<T> &vec){for(auto &v: vec)is >> v; return is;}
template <typename T> ostream &operator<<(ostream &os, const vector<T>& vec){for(int i = 0; i < vec.size(); i++){ os << vec[i]; if(i + 1 != vec.size())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p){os << p.first << " " << p.second; return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << itr->first << ":" << itr->second; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const unordered_map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << itr->first << ":" << itr->second; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
//  types
using ll = long long int;
using P = pair<int, int>;
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1000000007;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};
// io
struct fast_io{
  fast_io(){ios_base::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(20);}
} fast_io_;


int main(int argc, char const* argv[])
{
  int n; cin >> n;
  vector<int> a(n); cin >> a;
  vector<int> e(n);
  rep(i, n)e[i] = i;
  sort(all(e), [&](int i, int j){
                 return a[i] < a[j];
               });
  rep(i, n)e[i]++;
  cout << e << endl;
  return 0;
}


Measured memory_bytes: 1664
N = int(input())
s = list(list(input())for i in range(N))
count = 1
ans = 0
for i in range(N):
    s[i].sort()
s.sort()
for i in range(0,N-1):
    if s[i] == s[i+1]:
        ans += count
        count += 1
    else:
        count = 1
print(ans)

Measured memory_bytes: 24652
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b=scanner.nextInt();
        int c=scanner.nextInt();
        if (a < b&& b<c ){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
        }
    }

Measured memory_bytes: 26208
#include <bits/stdc++.h>
#define rep(i, N) for (int i = 0; i < N; i++)
#define vec vector<int>
using namespace std;
int main()
{
    int N, K, sum = 0;
    cin >> N >> K;
    vec l(N);
    rep(i, N)
    {
        cin >> l[i];
    }
    sort(l.begin(), l.end());
    reverse(l.begin(), l.end());
    rep(i, K)
    {
        sum += l[i];
    }
    cout << sum << endl;
}

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

int main(){
  int N,M;
  cin >> N;
  string s[N];
  for(int i=0;i<N;i++){
    cin >> s[i];
  }
  cin >> M;
  string t[M];
  for(int i=0;i<M;i++){
    cin >> t[i];
  }
  int max,count;
  for(int i=0;i<N;i++){
    for(int k=0;k<N;k++){
      if(s[i]==s[k]) count++;
    }
    for(int j=0;j<M;j++){
      if(s[i]==t[j]) count--;
    }
    if(count>max) max=count;
    count =0;
  }
  if(max<0) max=0;
  cout << max << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	int x;
	cin>>a>>b;
	for(int i=1;i<=b;i++)
	{
		cin>>x;
		a-=x;
	}
	if(a<=0)
	{
		cout<<"Yes";
	}
	else
	{
		cout<<"No";
	}
	return 0;
}

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

#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll ans = 0;
    int N; cin >> N;
    string S; cin >> S;
    int ruiseki[3][S.length()+1];
    rep(i, 3) ruiseki[i][0] = 0;
    rep(i, S.length()){
        rep(j, 3) ruiseki[j][i+1] = ruiseki[j][i];
        if(S[i] == 'R') ruiseki[0][i+1]++;
        else if(S[i] == 'G') ruiseki[1][i+1]++;
        else ruiseki[2][i+1]++;
    }
    for(int i = 0; i < S.length(); i++){
        for(int j = i+1; j < S.length(); j++){
            if(S[i] == S[j]) continue;
            int chk;
            char c;
            if('R' != S[i] && 'R' != S[j]){chk = 0; c = 'R';}
            else if('G' != S[i] && 'G' != S[j]){chk = 1; c = 'G';}
            else {chk = 2; c = 'B';}
            //S[i+1]からS[j-1]まで
            ans += ruiseki[chk][j] - ruiseki[chk][i+1];
            if((j-i) % 2 == 0 && S[(j+i)/2] == c) ans--;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3680
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ULL;
const int nMax=1e6+1, MOD=1e9+7;
ULL inv[nMax], Fact[nMax], invF[nMax];
ULL Comb(int n, int r){ return (((Fact[n]*invF[r])%MOD)*invF[n-r])%MOD; }

ULL Ans(int n, int x){
ULL N=n;
if(x==0){ return 1; }
if(x>=n){ return Ans(n, n-1); }
else{ return (Ans(n, x-1)+(Comb(n, x)*Comb(n-1, n-x-1))%MOD)%MOD; } 
}

int main(){
int n, k;
inv[1]=Fact[0]=Fact[1]=invF[0]=invF[1]=1;
for(int i=2; i<nMax; i++){ 
  inv[i]=((MOD-MOD/i)*inv[MOD%i])%MOD;
  Fact[i]=(Fact[i-1]*i)%MOD; invF[i]=(invF[i-1]*inv[i])%MOD;
}
cin >> n >> k;  
cout << Ans(n, k) << "\n";
}

Measured memory_bytes: 29952
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.IO;

namespace SolutionCS
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int A = int.Parse(s[0]);
            int B = int.Parse(s[1]);

            if (B <= 1)
            {
                Console.WriteLine(0);
                return;
            }

            int ans = 1;
            B -= A;
            while (B > 0)
            {
                B -= (A - 1);
                ans++;
            }

            Console.WriteLine(ans);
        }
    }
}




Measured memory_bytes: 13140
#include <iostream>
#include <cstdio>
#define ll long long
#define ull unsigned long long
#define ld long double
using namespace std;
const ll mod=1e9+7;
int n; 
int main(){
	cin>>n;
	n=n%10;
	if(n==2||n==4||n==5||n==7||n==9)	printf("hon");
	else if(n==0||n==1||n==6||n==8)		printf("pon");
	else								printf("bon");



	return 0;
}


Measured memory_bytes: 3252
import java.util.*;class Main{public static void main(String[]_){Scanner S=new Scanner(System.in);for(int i=S.nextInt(),j,x,y,z,a[]=new int[3];i-->0;System.out.println(a[2]*a[2]==a[1]*a[1]+a[0]*a[0]?"YES":"NO")){for(j=0;j<3;)a[j++]=S.nextInt();Arrays.sort(a);}}}

Measured memory_bytes: 12000
using System;
using System.Collections.Generic;
using System.Linq;

namespace CodeFestivalA
{
	class Q3
	{
		static void Main()
		{
			List<char> str = Console.ReadLine().ToList();
			int N = int.Parse(Console.ReadLine());
			for(int i = 0; (i < str.Count)&&(N!=0); i++)
			{
				int toA = (26 - (str[i] - 'a')) % 26;
				if (N - toA < 0)
					continue;
				str[i] = 'a';
				N -= toA;
			}
			str[str.Count - 1] += (char)(N % 26); 
			Console.WriteLine(new string(str.ToArray()));
		}
	}
}


Measured memory_bytes: 4440
#include <stdio.h>

int main()
{
	int N, ball[10], B[10], C[10], b, c, k;

	scanf("%d", &N);

	for (int i = 0; i < N; i++){
		scanf("%d %d %d %d %d %d %d %d %d %d", &ball[0], &ball[1], &ball[2], &ball[3], &ball[4], &ball[5], &ball[6], &ball[7], &ball[8], &ball[9]);

		b = 0;
		c = 0;
		k = 0;
		for (int j = 0; j < 10; j++){
			if(b < ball[j] && (ball[j] - b) <= (ball[j] - c)) b = ball[j];
			else if(c < ball[j]) c = ball[j];
			else {k = 1; break;}
		}

		if(k == 0) printf("YES\n");
		else printf("NO\n");
	}
	
	return 0;
}

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

using namespace std;
typedef long long ll;

#define rep(i , j , n) for(long long i = j ; i <= n ; i++)
const ll N = 123456;

int a[N];

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

    int a , b , c;

    cin >> a >> b >> c;

    if(c <= a - b) {
        cout << 0 << endl;
    }
    else {
        cout << c - (a - b) << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int cnt[110];

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    REP(i, 1, N) {
        int num = i;
        int j = 2;
        while(num > 1) {
            while(num % j == 0) {
                cnt[j]++;
                num /= j;
            }
            j++;
        }
    }
    int ans = 0;
    REP(i, 2, 100) {
        if(cnt[i] >= 74) ans++;
    }
    REP(i, 2, 100) {
        REP(j, 2, 100) {
            if(i >= j) continue;
            if(cnt[i] >= 2 && cnt[j] >= 24) ans++;
            if(cnt[i] >= 4 && cnt[j] >= 14) ans++;
            if(cnt[i] >= 24 && cnt[j] >= 2) ans++;
            if(cnt[i] >= 14 && cnt[j] >= 4) ans++;
        }
    }
    REP(i, 2, 100) {
        REP(j, 2, 100) {
            if(i >= j) continue;
            REP(k, 2, 100) {
                if(i >= k || j >= k) continue;
                if(cnt[i] >= 2 && cnt[j] >= 4 && cnt[k] >= 4) ans++;
                if(cnt[i] >= 4 && cnt[j] >= 2 && cnt[k] >= 4) ans++;
                if(cnt[i] >= 4 && cnt[j] >= 4 && cnt[k] >= 2) ans++;
            }
        }
    }
    cout << ans << endl;

    return 0;
}
// 75 = 3 * 5 * 5
// (74), (2, 24), (14, 4), (2, 4, 4)

Measured memory_bytes: 3672
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
   	public int maxHappiness(int[][] plan) {
        int n = plan.length;
        int[][] dp = new int[n + 1][3];
        for (int i = 1; i <= n; i++) {
            for (int j = 0; j < 3; j++) {
                int act1 = plan[i - 1][(j + 1) % 3] + dp[i - 1][(j + 1) % 3];
                int act2 = plan[i - 1][(j + 2) % 3] + dp[i - 1][(j + 2) % 3];
                dp[i][j] = Math.max(act1, act2);
            }
        }
        return Math.max(dp[n][0], Math.max(dp[n][1], dp[n][2])); 
	}
    public static void main(String[] args)  {
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            int n = Integer.parseInt(br.readLine());
          	int[][] plan = new int[n][3];
            for (int i = 0; i < n; i++) {
                String[] split = br.readLine().split(" ");
                for (int j = 0; j < 3; j++) {
                    plan[i][j] = Integer.parseInt(split[j]);
                }
            }
          	Main app = new Main();
            int result = app.maxHappiness(plan);
            System.out.println(result);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}


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

using namespace std;
using ll = long long;

#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define REP(i,n) FOR(i, 0, n)
#define FORD(i,a,n) for(int i=(a); i>=(n); i--)
#define REPD(i,n) FOR(i, n, 0)

#define ALL(o) (o).begin(), (o).end()

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T, vector<T>, greater<T> >;

const ll MOD = 1000000007;

int main() {
	string s, t;
	cin >> s >> t;
	int a, b;
	cin >> a >> b;
	string u;
	cin >> u;

	if(s==u) {
		a--;
	}
	else {
		b--;
	}

	cout << a << " " << b << endl;
	return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <istream>
#include <map>
#include <set>
#include <queue>
#define rep0(i,n) for (int i = 0; i <= (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)
#define REP(a,b) for (int i = a; i <= (b); ++i) 
#define mREP(a,b) for (int i = a; i == (b); --i)
#define mod 1e9 + 7
typedef long long ll;
using namespace std;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	/*
	　　　　　 　 _... ..._
	　　　　　 , ´⌒ ⌒ヽ
	　　　 　 ﾉｨ（ノﾉ）ﾉ）ﾉ）
	　　　 　 （（q|.ﾟ ヮﾟﾉ|ﾊ
	　　　　　　△ﾑ,8ﾑﾌつ
	　　　　　/(ﾝ_/＿ヽ＼
	　　　　 ～～i_ﾌ_ﾌ～´
	*/
	vector<int>a(3);
	rep0(i, 2)cin >> a[i];
	sort(a.begin(), a.end());
	int k;
	cin >> k;
	rep0(j, k - 1) {
		a[2] *= 2;
	}
	cout << a[0] + a[1] + a[2] << endl;
	return 0;
}


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

double dp[51][5001];
int v[4], e[51], a[51];
int main() {
	int x, y, z;
	while (scanf("%d%d%d", &x, &y, &z), x) {
		memset(e, 0, sizeof(e));
		memset(dp, 0, sizeof(dp));
		rep(i, x)scanf("%d", &v[i]);
		rep(i, z) {
			int n; scanf("%d", &n);
			scanf("%d%d", &e[n], &a[n]);
		}
		dp[0][0] = 1;
		rep(i, y)rep(j, 5001) {
			if (dp[i][j] == 0)continue;
			rep(k, x) {
				int t = min(y, i + v[k]);
				if (!e[t])dp[t][j] += dp[i][j] / x;
				if (e[t] == 1)dp[min(y, t + a[t])][j] += dp[i][j] / x;
				if (e[t] == 2)dp[t][j + a[t]] += dp[i][j] / x;
				if (e[t] == 3)dp[t][max(0, j - a[t])] += dp[i][j] / x;
			}
		}
		double ans = 0;
		rep(i, 5001)ans += i*dp[y][i];
		printf("%d\n", (int)ans);
	}
}

Measured memory_bytes: 5076
N = int(input())
A = list(map(int, input().split()))
A.sort()
A = A[::-1]
# print(A)

cnt = 1
length = []
for i in range(1, N):
    if A[i] == A[i-1]:
        cnt += 1
        if cnt >= 2:
            length.append(A[i])
            cnt = 0
            if len(length) >= 2:
                break
    elif cnt == 0:
        cnt = 1
else:
    length = [0, 0]
print(length[0] * length[1])

Measured memory_bytes: 85112
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class Program
{
    static void Main()
    {
        var nm = ReadLine().Split().Select(int.Parse).ToArray();
        var n = nm[0];
        var m = nm[1];
        var aa = new List<int>[n];
        for (int i = 0; i < n; i++)
        {
            aa[i] = new List<int>();
        }
        for (int i = 0; i < m; i++)
        {
            var lie = ReadLine().Split().Select(int.Parse).ToArray();
            for (int j = 1; j < lie.Length; j++)
            {
                aa[lie[j] - 1].Add(i);
            }
        }
        var p = ReadLine().Split().Select(int.Parse).ToArray();
        var d = new int[m];
        var ans = 0;
        for (int i = 0; i < 1 << n; i++)
        {
            var c = i;
            for (int j = 0; j < n; j++)
            {
                if (((c >> j )& 1) == 1)
                    foreach (var item in aa[j])
                    {
                        d[item]++;
                    }
            }
            var b = true;
            for (int j = 0; j < m; j++)
            {
                if (d[j] % 2 != p[j])
                {
                    b = false;
                    break;
                }
            }
            d = new int[m];
            if (b) ans++;
        }
        WriteLine(ans);
    }
}

Measured memory_bytes: 13396
using System;
using System.Collections;
using System.Collections.Generic;

namespace ConsoleApplication6
{
    class Program
    {
        static void Main(string[] args)
        {
            var read = Console.ReadLine();
            var split = read.Split(' ');
            int a = int.Parse(split[0]);
            int b = int.Parse(split[1]);
            int c = int.Parse(split[2]);
            Console.WriteLine((a - c) / (b + c));

            Console.ReadLine();



            

        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl

int main() {
    int n, k; cin >> n >> k;
    vector<int> p(n);
    rep(i, n) cin >> p.at(i);

    vector<int> sum(10000);
    rep(i, 1010){
        sum.at(i) = i+1;
    }
    rep(i, 1010){
        sum.at(i+1) += sum.at(i);
        //if(i<=10) dump(sum.at(i));
    }

    vector<double> val(n);
    rep(i, n){
        val.at(i) = sum.at(p.at(i)-1)/(double)p.at(i);
        dump(val.at(i));
    }

    vector<double> sum2(n+k+1, 0.0);
    rep(i, n){
        sum2.at(i+1) = val.at(i);
    }
    rep(i, n+1){
        sum2.at(i+1) += sum2.at(i);
        dump(sum2.at(i));
    }

    double res = 0.0;
    rep(i, n-k+1){
        double tmp;
        tmp = sum2.at(i+k) - sum2.at(i);
        dump(tmp);
        res = max(res, tmp);
    }

    cout << fixed << setprecision(10) << res << endl;
}

Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
typedef long long int  ll;
typedef pair<int,int> PII;
const int mod = 1e9+7,INF = 1e9;
const int mx = 1e6+5;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int x,y;
    cin>>x>>y;
    if(2*x<=y && y<=4*x&& (y%2)==0)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}



Measured memory_bytes: 3632
#include <stdio.h>

int cnt_sum(int n, int s, int x){
  if(n == 0 && s == 0){
    return (1);
  }
  if(x>9){
    return (0);
  }
  
  return (cnt_sum(n-1, s-x, x+1) + cnt_sum(n, s, x+1));
}
int main(){
  int n, s;
  while(1){
    scanf("%d %d", &n, &s);
    if(n == 0 && s == 0){
      break;
    }
    printf("%d\n", cnt_sum(n, s, 0));
  }
  return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
using namespace std;

int main()
{
	int N;
	cin >> N;
	long long C[500];
	long long S[500];
	long long F[500];
	for (auto i = 0; i < N - 1; ++i)
	{
		cin >> C[i] >> S[i] >> F[i];
	}

	for (auto i = 0; i < N - 1; ++i)
	{
		auto t = S[i] + C[i];
		for (auto j = i + 1; j < N - 1; ++j)
		{
			if (t < S[j])
			{
				t = S[j];
			}
			else
			{
				auto exceed = t % F[j];
				if (exceed > 0)
				{
					t += F[j] - exceed;
				}
			}
			t += C[j];
		}
		cout << t << endl;
	}

	cout << 0 << endl;

	return 0;
}


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



int main() {

    int h,w;
    cin >> h >> w;

    string c[50];
    for(int i = 0; i < h; i++) cin >> c[i] ; 

    for(int i = 0; i < h; i++)
    {
        for(int j = 0; j < w; j++)
        {
            if(c[i][j] == '.'){
                int cnt = 0;
                if(i != 0 && j != 0 ){
                    if(c[i - 1][j - 1] == '#') cnt++;
                }
                if(i != 0){
                    if(c[i - 1][j] == '#') cnt++;
                }
                if(i != 0 && j != w - 1){
                    if(c[i - 1][j + 1] == '#') cnt++;
                }

                if(j != 0 ){
                    if(c[i][j - 1] == '#') cnt++;
                }
                if(j != w - 1){
                    if(c[i][j + 1] == '#') cnt++;
                }

                if(i != h - 1 && j != 0){
                    if(c[i + 1][j - 1] == '#') cnt++;
                }
                if(i != h - 1 ){
                    if(c[i + 1][j] == '#') cnt++;
                }
                if(i != h - 1 && j != w - 1){
                    if(c[i + 1][j + 1] == '#') cnt++;
                }
                c[i][j] = char(cnt) + '0';
            }
        }
    }
    for(int i = 0; i < h; i++){
        cout << c[i] << endl;
    }     
    
}




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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;
const ll INF = 1LL<<60;
//int INF = numeric_limits<int>::max();

int main(int, char**) {
	int n, k; cin >> n >> k;
	ll bai = n / k;
	ll half;
	if (k%2==0) {
		half = bai;
		if (n%k >= k/2) half++;
	} else {
		half = 0;
	}
	ll ret = bai * bai * bai + half * half * half;
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9+7;
const double EPS = 1e-11;
const double PI = 2 * acos(0.0);
using ll = long long;
using ull =  unsigned long long;

#define input freopen("input.txt", "r", stdin)
#define output freopen("output.txt", "w", stdout)
#define fast_io ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
#define pf printf
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
#define sii(x,y) scanf("%d %d",&x,&y)
#define sll(x,y) scanf("%lld %lld",&x,&y)

#define pii pair<int,int>
#define nl '\n'
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define ALL(v) v.begin(),v.end()
#define uniq(a) a.erase(unique(a.begin(), a.end()), a.end())
#define out(x) cout <<"#x = "<<x<<endl
#define outt(x,y) cout <<"# "<<x<<" "<<y<<endl
#define mem(array,value) memset(array,value,sizeof(array))

ll dp[405][405];
int a[406];
int n;
ll sum(int l,int r)
{
	ll x=0;
	for(int i=l;i<=r;i++){
		x+=a[i];
	}
	return x;
}
ll solve(int i,int j)
{
	if(i>=j)return 0;
	//outt(i,j);
	if(dp[i][j]!=-1)return dp[i][j];
	dp[i][j]=1e18;
	for(int pos=i;pos<=j;pos++){
		dp[i][j] = min(dp[i][j],solve(i,pos)+solve(pos+1,j)+sum(i,j));
		
	}
	return dp[i][j];
}
int main()
{
	mem(dp,-1);
	fast_io
	cin >>n;
	for(int i=0;i<n;i++)cin >>a[i];

	cout << solve(0,n-1)<<endl;
	return 0;
}


Measured memory_bytes: 1536
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <stdio.h>
#include <fstream>
#include <cmath>
#include <stdlib.h>
#include <iomanip>
#include <algorithm>
#include <limits.h>
using namespace std;
#define FAST_IO ios::sync_with_stdio(false);
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef pair<double,double> pdd;
typedef long long ll;
const int maxn = 1e6 + 10;
int N,K,Q,a[maxn],ans = INT_MAX;
void cal(int x){
    int l,r;
    l = r = 1;
    vector<int> choice;
    while(l <= N){
        vector<int> tmp;
        while(a[l] < x && l <= N) l++;
        r = l;
        while(a[r] >= x && r <= N) r++;
        for(int i = l; i < r; i++) tmp.push_back(a[i]);
        l = r;
        if(tmp.size() < K) continue;
        sort(tmp.begin(),tmp.end());
        for(int i = 0; i < tmp.size() - K + 1; i++) choice.push_back(tmp[i]);
    }
    if(choice.size() < Q) return;
    sort(choice.begin(),choice.end());
    ans = min(ans, choice[Q - 1] - x);
}

int main(){
    FAST_IO
    cin>>N>>K>>Q;
    for(int i = 1; i <= N; i++) cin>>a[i];
    for(int i = 1; i <= N; i++) cal(a[i]);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template<typename T>
inline void read(T &x)
{
	x=0;
	int f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9')
	{
		if(ch=='-') f=-1;
		ch=getchar();
}
	while(ch>='0'&&ch<='9') x=x*10+(ch^48),ch=getchar();
	x*=f;
	return;
}	
template<typename T>
void write(T x)
{
	if(x<0) putchar('-'),x=-x;
	if(x>=10) write(x/10);
	putchar(x%10+'0');
	return;
}
int a[35]={0,1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main()
{
	int k;
	cin>>k;
	cout<<a[k]<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
using namespace std;

const double infty = 100000;
bool c[50][50];
double k[50][50];
int n;
int r;

// const int d[4][2] = { {0,1}, {0,-1}, {1,0}, {-1,0} }; 

bool isedge(int x, int y) {
  return c[x][y] != c[x-1][y] || c[x][y] != c[x][y-1]; 
}
/* 独流でここに辿り着くまで時間がかかった。
   今後のために解法をまとめておく。
   ・境界の格子点がいつ円と交わるかを計算する。最小値が答え。(これはすぐ思いついた)
   ・塗ってあるパネルは、左下の頂点で管理する。ここで重要なのは半開区間で塗りつぶすことだ。閉区間だと隙間があるとき判定できない。(冷静になるまで時間がかかった)
   ・すると境界の判定は上記のようにできる。
 */

int main() {
  while (scanf("%d%d", &r, &n) != EOF && r) {
    fill(&c[0][0], &c[0][0]+50*50, false);
    for (int x=0; x<50; x++) {
      c[x][0] = true;
    }
    fill(&k[0][0], &k[0][0]+50*50, infty);
    for (int kkk=0; kkk<n; kkk++) {
      int x_l, x_r, h;
      scanf("%d%d%d", &x_l, &x_r, &h);
      x_l += 25;
      x_r += 25;
      h += 1;
      for (int x=x_l; x<x_r; x++) {
	for (int y=1; y<h; y++) {
	  c[x][y] = true;
	}
      }
    }
    double ans = infty;
    for (int x=26-r; x<25+r; x++) {
      for (int y=1; y<30; y++) {
	if (isedge(x, y)) {
	  k[x][y] = r + y - 1 - sqrt(r*r - (25-x)*(25-x));
	  /*if (k[x][y] < 3) {
	    cerr << "x = " << x-25 << ", y = " << y-1 << ", k[x][y] = " << k[x][y] << endl;
	    }*/
	  if (ans > k[x][y]) {
	    ans = k[x][y];
	  }
	}
      }
    }
    printf("%.4f\n", ans);
  }
}

Measured memory_bytes: 1228
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String S = sc.next();

		char[] s = S.toCharArray();
		for (char ss : s) {
			int test = ss;
			int byteNum = test + N;
			if (byteNum > 90) {
				byteNum -= 26;
			}
			System.out.print((char) byteNum);
		}
		sc.close();
	}
}

Measured memory_bytes: 28244
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

int glue(int a, int b){
  int b2 = b, p10 = 1;
  while(b > 9){
    p10 *= 10;
    b /= 10;
  }
  return a * (p10 * 10) + b2;
}

int main() {

  int a, b, ab, polpo;
  cin >> a >> b;
  ab = glue(a, b);
  //cout << ab;
  polpo = sqrt(ab);
  if(ab == polpo * polpo){
    cout << "Yes";
  }else{
    cout << "No";
  }
  return 0;
}


Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
typedef long long ll;
typedef pair<ll,ll> P;


int main(){
    ll t1,t2,a1,a2,b1,b2;
    cin>>t1>>t2>>a1>>a2>>b1>>b2;
    ll da1=t1*a1,db1=t1*b1,da2=da1+t2*a2,db2=db1+t2*b2;
    if(da2==db2){
        cout<<"infinity"<<endl;
        return 0;
    }
    if((da1>db1&&da2>db2)||(da1<db1&&da2<db2)){
        cout<<0<<endl;
        return 0;
    }
    ll an=2*(abs(da1-db1)/(ll)abs(da2-db2))+1;
    if(abs(da1-db1)%(ll)abs(da2-db2)==0)an--;
    cout<<an<<endl;
}

    









Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	int h, w, n;
	cin >> h;
	cin >> w;
	cin >> n;

	int max;
	if (h > w) {
		max = h;
	}
	else { max = w; }
	if (n % max == 0) {
		cout << n / max << endl;
	}
	else {
		cout << (n - (n % max)) / max + 1 << endl;
	}
	return 0;

}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<utility>
#include<stack>
#include<algorithm>
#include<string>
#include<string.h>
#include<assert.h>
#include<iomanip>
#define F first
#define S second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll,ll> ii;

int ar[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int k; cin >> k;
    cout << ar[k - 1] << endl;
}

Measured memory_bytes: 256
class Combinator
  MAX = 110000 # nCkの最大のnより大きいこと。MODより小さいこと。
  MOD = 1000000007

  def initialize
    @fac = Array.new(MAX)
    @fac[0] = 1
    @fac[1] = 1
    @finv = Array.new(MAX)
    @finv[0] = 1
    @finv[1] = 1
    @inv = Array.new(MAX)
    @inv[1] = 1
    (2..(MAX-1)).each do |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
    end
  end

  def call(all, select)
    return 0 if all < select
    return 0 if all < 0 || select < 0
    @fac[all] * (@finv[select] * @finv[all-select] % MOD) % MOD
  end
end
n, k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i).sort
sum = 0
com = Combinator.new
a.each.with_index do |ai, idx|
  p = com.call(idx, k-1) - com.call(n-1-idx, k-1)
  sum += ((ai % 1000000007) * (p % 1000000007)) % 1000000007
  sum %= 1000000007
end
puts sum

Measured memory_bytes: 12072
#include <stdio.h>

using namespace std;

int main(){
	int a,b;
	while(true){
		scanf("%d %d",&a,&b);
		if(a == 0 && b == 0) break;
		if(a > b) printf("%d %d\n",b,a);
		else{
			printf("%d %d\n",a,b);
		}
	}
}



Measured memory_bytes: 2608
#include<bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10, p = 1e9 + 7;
int n, ans, fac[N], inv[N], f[N];
inline void A(int &x, int y) { x += y; if (x >= p) x -= p; }
inline int C(int x, int y) { return 1ll * fac[x] * inv[y] % p * inv[x - y] % p; }
int main() {
	scanf("%d", &n); --n;
	fac[0] = 1; for (int i = 1; i <= n; ++i) fac[i] = 1ll * fac[i - 1] * i % p;
	inv[0] = inv[1] = 1; for (int i = 2; i <= n; ++i) inv[i] = 1ll * inv[p % i] * (p - p / i) % p;
	for (int i = 2; i <= n; ++i) inv[i] = 1ll * inv[i] * inv[i - 1] % p;
	int bd = (n + 2) >> 1;
	for (int i = bd; i <= n; ++i) f[i] = 1ll * C(i - 1, n - i) * fac[n - i] % p * fac[i] % p;
	for (int i = n; i > bd; --i) A(f[i], p - f[i - 1]);
	int ans = 0;
	for (int i = bd; i <= n; ++i) A(ans, 1ll * f[i] * i % p);
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 9984
#include <bits/stdc++.h>
#define LL long long
using namespace std;
const int N=2e5+50;
int n,nxt[N][26],last[26];
int dp[N];
string s;
int solve(int i)
{
    if(i>n)return 0;
    if(dp[i]!=-1)return dp[i];
    dp[i]=2e9;
    for(int j=0;j<26;j++)
        dp[i]=min(dp[i],1+solve(nxt[i][j]));
    return dp[i];
}
void print(int i)
{
    if(i>n)return;
    for(int j=0;j<26;j++)
    {
        if(dp[i]==1+solve(nxt[i][j]))
        {
            cout<<char(j+'a');
            print(nxt[i][j]);
            return;
        }
    }
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    memset(dp,-1,sizeof dp);
    cin>>s;
    n=s.size();
    for(int i=0;i<26;i++)
        last[i]=n+5;
    for(int i=n-1;;i--)
    {
        for(int j=0;j<26;j++)
            nxt[i+1][j]=last[j];
        if(i==-1)break;
        last[s[i]-'a']=i+1;
    }
    solve(0);
    print(0);
}


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

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

    int r = a % b;
    while (r != 0)
    {
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

int main(int argc, char const *argv[])
{
    long k;
    cin >> k;
    int t;
    int s;
    long long sum = 0;
    for (int i = 1; i <= k; i++)
    {
        for (int j = i; j <= k; j++)
        {
            for (int l = j; l <= k; l++)
            {
                s = gcd(i, j);
                t = gcd(l, s);
                if (i == j && j == l)
                {
                    sum += t;
                }
                else if (i == j || j == l || l == i)
                {
                    sum += (t * 3);
                }
                else
                {
                    sum += (t * 6);
                }
            }
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int main(void){
int n,m;
string tmp;
bool opened=false;
vector<string>pass;
cin>>n;
for(int i=0;i<n;i++){
	cin>>tmp;
	pass.push_back(tmp);
}
cin>>m;
for(int i=0;i<m;i++){
	bool matched=false;
	cin>>tmp;
	for(int j=0;j<n;j++){
		if(pass[j]==tmp){
			if(opened)cout<<"Closed by "<<tmp<<endl;
			else cout<<"Opened by "<<tmp<<endl;
			opened=!opened;
			matched=true;
			break;
		}
	}
	if(!matched)cout<<"Unknown "<<tmp<<endl;
}
return 0;
}



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

void check(int *str,int count){
	int i,j,temp;
	if((str[0]==str[1])&&(str[1]==str[2])){
		printf("%d\n",count);
	}else{
		for(i=0;i<2;i++){
			for(j=i+1;j<3;j++){
				if(str[i]<str[j]){
					temp=str[i];
					str[i]=str[j];
					str[j]=temp;
				}
			}
		}
		if(str[0]==str[1]){
			str[2]+=2;
			check(str,count+1);
		}else{
			if(str[1]==str[2]){
				str[0]--;
				check(str,count+1);
			}else{
				str[2]+=2;
				check(str,count+1);
			}
		}
	}
}

int main(void) {
	int str[3];
	scanf("%d %d %d",&str[0],&str[1],&str[2]);
	check(str,0);
	return EXIT_SUCCESS;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define era(t) t.erase(unique(be(t)),t.end())
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
typedef long long ll;
using namespace std;
const ll mod=1000000007,mod9=1000000009;
template <class T>inline T lcm(T a,T b){return (a*b/__gcd(a,b));}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k;
    string s;
    cin>>n>>s>>k;
    string t="";
    t+=s[k-1];
    for(int i=0;i<n;i++){
        if(s[i]==t[0]){
            cout << s[i];
        }
        else{
            cout << '*';
        }
    }
    cout <<endl;
    return 0;
}


Measured memory_bytes: 256
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, a);
    OUT(a + a * a + a * a * a);
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define DEBUG(x)           cout << '>' << #x << ':' << x << endl;
#define forn(i,n)          for(int i=0;i<(int)n;++i)
#define for1(i,n)          for(int i=1;i<=(int)n;++i)
#define forr(i,n)          for(int i=(int)n-1;i>=0;--i)
#define forre(i,a,b)       for(int i=(int)b;i>=(int)a;--i)
#define fore(i,a,b)        for(int i=(int)a;i<=(int)b;++i)
#define input(i,arr)       for(int& i:arr)cin>>i;
#define output(i,arr)      for(int& i:arr)cout<<i<<" ";
#define for_each(arr)      for(auto& it:arr)
#define ff                 first
#define ss                 second
#define PI                 acos(-1.0)
#define all(a)             a.begin(),a.end()
#define rall(a)            a.rbegin(),a.rend()
#define Unique(a)          sort(all(a)),a.erase(unique(all(a)),a.end())
#define pb(x)              push_back(x)
#define eb(x)              emplace_back(x) 
#define ppb(x)             pop_back(x)
#define pf(x)              push_front(x)
#define ppf(x)             pop_front(x)
#define in(x,y)            insert({x,y})
#define Sort(a)            sort(a.begin(),a.end())
#define mem(arr,a)         memset(arr,a,sizeof arr)
#define ins(a)             insert(a)
#define max2(a,b)          max(a,b)
#define max3(a,b,c)        max(a,max(b,c))
#define max4(a,b,c,d)      max(a,max3(b,c,d))
#define min2(a,b)          min(a,b)
#define min3(a,b,c)        min(a,min(b,c))
#define min4(a,b,c,d)      min(a,min3(b,c,d))
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<char> vc;
typedef vector<double> vd;
/*inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void Set(int & n, int b) { n |= two(b); }
inline void Reset(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }*/
/*int fx1[]={+1,-1,+0,+0};
int fy1[]={+0,+0,+1,-1};
int fx2={+0,+0,+1,-1,-1,+1,-1,+1};
int fy2={-1,+1,+0,+0,+1,+1,-1,-1};
*/
 
ll a,b,c,n,ans,cn1,cn2,cn3,t;
string s,s1,s2;
 
 
int main()
{
    FIO;
   // #ifndef ONLINE_JUDGE
   // freopen("input.txt","r",stdin);
   //freopen("output.txt","w",stdout);
   // #endif
   ll p,q,r;
    cin>>p>>q>>r;
   ll d=r-p-q;
    if(d>0&&d*d>(4*p*q))cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
   
    
   	
    #ifdef ONLINE_JUDGE
    cerr<<"Time elapsed: "<<1.0*clock()/CLOCKS_PER_SEC<<"s.\n";
    #endif
   return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
 
int main(){
	int counter = 0,i;  
  	string s;
  	cin >> s;
  	for(i = 0; i < 3;i++ ){
    if(s[i] == '1'){
    counter += 1;
    }
    }
	cout << counter << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
using namespace std;
int intinput() {
	int x;
	cin >> x;
	return x;
}
vector<int> forintinput(int n) {
	vector<int> x(100000);
	for(int i = 0;i < n;i++) cin >> x[i];
	return x;
}
int main(){
	string s;
	cin >> s;
	if(s == "ABC"){
		cout << "ARC" << endl;
	}else{
		cout << "ABC" << endl;
	}
}

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

using namespace std;

#define DPRINTF(...) printf(__VA_ARGS__)
#define FOR0(i, n) for(int i=0;i<n;i++)
#define ALL(c) (begin(c)), (end(c))
#define fst(t) get<0>(t)
#define snd(t) get<1>(t)
#define thd(t) get<2>(t)

typedef tuple<int,int> P;
typedef long long ll;

const ll MOD = 1e9 + 7;

ll inv(ll a, ll p){
    ll res = 1ll;
    ll n = p - 2;
    
    while(n > 0){
        if(n & 1ll){
            res = res * a % p;
        }
        a = a * a % p;
        n >>= 1;
    }

    return res;
}

ll fact[200000], inve[200000];

inline ll nCk(int n, int k){
    if(n < k){return 0;}

    return fact[n] * inve[n-k] % MOD * inve[k] % MOD;
}

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

  fact[0] = 1ll;
  inve[0] = 1ll;
  for(int i=1;i<200000;i++){
      fact[i] = fact[i-1] * i % MOD;
      inve[i] = inv(fact[i], MOD);
  }

  int H, W, A, B;
  cin >> H >> W >> A >> B;

  ll res = nCk(H-1 + W-1, H-1);

  // cout << "all:" << res << endl;
  
  FOR0(i, B){
      // cout << nCk(H-A-1 + i, i) * nCk(A-1 + W-i-1, A-1) << endl;
      res = ((res - nCk(H-A-1 + i, i) * nCk(A-1 + W-i-1, A-1) % MOD) + MOD) % MOD;
  }

  cout << res << endl;
}


Measured memory_bytes: 3328
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
//C++11
#if __cplusplus == 201103L
#include <tuple>
#endif

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;

int main(){
  int N;
  while(cin>>N && N){
    vector<int> ans;
    bool is[1000][1000] = {0};
    REP(i, N){
      int k; cin>>k;
      REP(j,k){
        int t; cin>>t;
        t--;
        is[i][t] = true;
      }
    }
    int k; cin>>k;
    bool row[1000] = {};
    REP(i, k){
      int t; cin>>t;
      t--;
      row[t] = true;
    }
    REP(i, N){
      bool ok = true;
      REP(j, N)if(row[j] && !is[i][j]) ok = false;
      if(ok) ans.push_back(i+1);
    }
    if(ans.size() == 1) cout<<ans.front()<<endl;
    else cout<<-1<<endl;
  }
  return 0;
}

Measured memory_bytes: 1884
#include <bits/stdc++.h>
#define ft first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;
static const ll INF=1e18;
static const ll MAX=1e5+7;
static const ll MOD=1e9+7;
ll max(ll a, ll b) {return a>b ? a:b;}
ll min(ll a, ll b) {return a<b ? a:b;}

int main(void) {
    ll N;
    cin >> N;
    ll a[5];
    ll i;
    
    ll ans=0;
    ll min=INF;
    for(i=0; i<5; i++) {
        cin >> a[i];
        chmin(min, a[i]);
    }
    
    pt((N+min-1)/min+4);
    
    
}







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

int main() {
  string s; ll k, an=0, an0=0;
  cin >> s >> k; ll n = s.size();
  
  if (n == 1) {
    cout << k/2 << endl;
    return 0;
  }
  
  if (s[0] == s[n-1]) {
    ll a=1, b=1;
    for(int i=1; i<n; i++) {
      if (s[i-1] == s[i]) a++;
      else break;
    }
    for(int i=n-1; i>=1; i--) {
      if (s[i-1] == s[i]) b++;
      else break;
    }
    an0 -= (a/2 + b/2 - (a+b)/2) * (k-1);
  }
  
  for(int i=1; i<n; i++) {
    if (s[i-1] == s[i]) {
      s[i] = '0'; an++;
    }
  } an *= k;
  an += an0;
  cout << min(an, n*k/2) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,m,i,j,k=0,e=0,f=0;
	cin>>n>>m;
	int c[n];
		memset(c,0,sizeof(c));
	int a[m],b[m];
	for(i=0;i<m;i++)
	cin>>a[i]>>b[i];
	for(i=0;i<m;i++)
	for(j=i+1;j<m;j++)
	if(a[i]==a[j] && b[i]!=b[j])
	{
		cout<<-1<<endl;
		return 0;
	}
	for(i=0;i<m;i++)
	if(a[i]==1 && b[i]==0 && n!=1)
	{
		cout<<-1<<endl;
		return 0;
	}
	for(i=0;i<m;i++)
	{
		if(a[i]==1)
		{
		c[a[i]-1]=b[i];
		k=1;
	}
		if(a[i]==2)
		{
		c[a[i]-1]=b[i];
		e=1; 
	}
		if(a[i]==3)
		{
		c[a[i]-1]=b[i];
		f=1;
	}
	}
	if(k==0 && n!=1)
	c[0]=1;
	if(n==1 && k==0)
	c[0]=0;
	int ans=0;
	if(n==1)
	cout<<c[0];
	if(n==2)
	cout<<c[0]*10+c[1]<<endl;
	if(n==3)
	cout<<c[0]*100+c[1]*10+c[2]<<endl;
	return 0;
}

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

bool isPrime(int n) {
	if (n == 2) {
		return true;
	}
	if ((n == 1) || (n % 2 == 0)) {
		return false;
	}
	for (int i = 3; i * i <= n; i++) {
		if (n % i == 0)
			return false;
	}
	return true;
}

int main()
{
	int n;
	cin >> n;
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		int m;
		cin >> m;
		if (isPrime(m))
			cnt++;
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 3096