akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main(void){
int W,H,x,y,r;
scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
if(0<=x-r&&W>=x+r&&0<=y-r&&H>=y+r){
printf("Yes\n");
}else{
printf("No\n");
}
return 0;
}

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


using namespace std;


using ll = long long;


mt19937 mt(736);


void solve(istream &cin = std::cin, ostream &cout = std::cout)
{
	string s;

	cin >> s;

	vector<ll> arr(s.size() + 1);

	s = '>' + s + '<';

	for (int i = 1; i < s.size(); i++)
		if (s[i - 1] == '>' && s[i] == '<')
		{
			arr[i - 1] = 0;

			for (int j = i - 1; j > 0 && s[j] == '>'; j--)
				arr[j - 1] = max(arr[j - 1], arr[j] + 1);

			for (int j = i; j < arr.size() && s[j] == '<'; j++)
				arr[j] = max(arr[j], arr[j - 1] + 1);
		}

	cout << accumulate(arr.begin(), arr.end(), 0ll) << endl;
}


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

	cout << fixed;

#ifdef LOCAL
	auto st = clock();

	ifstream fin("../input.txt");

	solve(fin);

	cout << "clock: " << setprecision(4) << (clock() - st) / (double) CLOCKS_PER_SEC << endl;
#else
	solve();
#endif

	return 0;
}


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

#define REP(i,n) for(long long i=0;i<n;++i)
#define REPR(i,n) for(long long i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define MOD 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(v) {for(long long sitr=0;sitr<v.size();++sitr){cin>>v[sitr];}}

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  unsigned long long  a, b;
  double tmp;
  cin >> a >> tmp;
  b = (tmp + 0.001) * 100;
  
  cout << (a * b) / 100 << endl;
  return 0;
}



Measured memory_bytes: 3644
module String = struct
  include String

  let to_list str =
    let rec doit i acc =
      if i < 0 then acc
      else doit (i - 1) (String.get str i :: acc)
    in
    doit (String.length str - 1) []

end

let calc_area lst =
  let rec doit i idxs acc = function
    | [] -> acc
    | '_' :: tl -> doit (i + 1) idxs acc tl
    | '\\' :: tl -> doit (i + 1) (i :: idxs) acc tl
    | '/' :: tl -> begin
        match idxs with
        | [] -> doit (i + 1) idxs acc tl
        | j :: js -> doit (i + 1) js (((j, i), i - j) :: acc) tl
      end
    | _ -> exit 1
  in
  doit 0 [] [] lst

let integrale lst =
  let rec doit acc = function
    | [] -> acc
    | [e] -> e :: acc
    | (((j1, i1), area1) as xs) :: ((((j2, i2), area2) :: tl) as ys) ->
        if j1 < j2 && i1 > i2 then doit acc (((j1, i1), area1 + area2) :: tl)
        else doit (xs :: acc) ys
  in
  doit [] lst

let () =
  let lst = String.to_list (read_line ()) in
  let areas = integrale (calc_area lst) in
  Printf.printf "%d\n" (List.fold_left (fun acc (_, n) -> acc + n) 0 areas);
  Printf.printf "%d" (List.length areas);
  List.iter (fun (_, n) -> Printf.printf " %d" n) areas;
  print_newline ()

Measured memory_bytes: 4448
l, r = map(int, input().split())
lis = []
for i in range(l, r + 1):
    for j in range(i + 1, r + 1):
        lis.append((i * j)% 2019)
        if (i * j) % 2019 == 0:
            print(0)
            exit()
print(min(lis))

Measured memory_bytes: 6888
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long int;
const ll inf = 2 * 1e9;

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

  vector<ll> a(N), b(N), c(M), d(M);

  REP (i, N)
    cin >> a[i] >> b[i];

  REP (i, M)
    cin >> c[i] >> d[i];

  REP (i, N) {
    int ans = M;
    ll mindist = inf;

    REP (j, M) {
      ll dist = abs(a[i] - c[j]) + abs(b[i] - d[j]);
      if (dist < mindist) {
        mindist = dist;
        ans = j;
      }
    }

    cout << ans + 1 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N = 3005;

ll n, mod;

ll st[N][N] = {1}, t[N] = {1}, tt[N] = {2}, fac[N] = {1}, fi[N] = {1};

ll calc (ll X, ll Y) {
	if(!Y) return 1;
	ll R = calc(X, Y/2);
	R = R * R % mod;
	if(Y&1) R = R * X % mod;
	return R;
}

ll comb (ll X, ll Y) {
	return fac[X] * fi[Y] % mod * fi[X-Y] % mod;
}

int main()
{
	scanf("%lld%lld",&n,&mod);
	for(ll i=1;i<=n;i++) {
		fac[i] = fac[i-1] * i % mod;
		fi[i] = calc(fac[i], mod-2);
		t[i] = t[i-1] * 2 % (mod-1);
		tt[i] = calc(2, t[i]);
	}
	for(ll i=1;i<=n;i++) for(ll j=1;j<=n;j++) {
		st[i][j] = (st[i-1][j-1] + st[i-1][j] * j) % mod;
	}
	ll ans = tt[n];
	for(ll i=n;i--;) {
		ll T = comb(n, i) * tt[i] % mod, S = 0, W = calc(2, i), C = 1;
		for(ll j=1;j<=n-i;j++) {
			S = (S + (j * C + C * W) % mod * st[n-i][j]) % mod;
			C = C * W % mod;
		}
		ans = (ans + T * S % mod * (mod+1-(n-i)%2*2)) % mod;
	}
	printf("%lld\n",ans);
}


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

int main(){
	int x, y, z;
	cin >> x >> y >> z;
	if(x < z - y){
		cout << "dangerous" << endl;
	}
	else if( y >= z ){
		cout << "delicious" << endl;
	}
	else {
		cout << "safe" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
/* ex3_3
   kohei_suzuki */

#include <stdio.h>

int main(void){
    int n, m=9 ;

    scanf("%d",&n);

    int l = n / m;

    while(n % m != 0 && m > 0){
        m -= 1;
        l = n / m;
    }

    if(l < 10 && m != 0){
        printf("Yes\n");
    }else{
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 128
package main

import (
	"fmt"
)

func main() {
	var a, b, c int
	fmt.Scan(&a, &b, &c)

	for i := a; i <= 100000000; i += a {
		if (i-c)%b == 0 {
			fmt.Println("YES")
			return
		}
	}
	fmt.Println("NO")
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
string S;
  cin>>S;
  int N=S.size();
  int ans=0;
  for(int i=0;i<N;i++){
  if(i%2==0){
  if(S.at(i)!='0')
    ans++;
  
  }else{
    if(S.at(i)!='1')
      ans++;
  
  }
   }if(N-ans<=ans)
    ans=N-ans;
  cout<<ans<<endl;

return 0;
}

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

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long long ll;
typedef unsigned long long ull;

#define Max_effort ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define debug(x) cerr<<#x<<" = "<<(x)<< nl
#define nl "\n"
#define sp " "

int n;

int main() {
	Max_effort
	cin >> n;
	int a[n], b[n], arr[n];

	for (int i = 0; i < n; i++) {
		cin >> a[i];
		arr[i] = i + 1;
	}

	for (int i = 0; i < n; i++) {
		cin >> b[i];
	}

	ll fst = -1, snd = -1, cnt = 0;
	do {
		cnt++;
		bool f1 = false, f2 = false;

		for (int i = 0; i < n; i++) {
			if (arr[i] != a[i])
				f1 = true;
			if (arr[i] != b[i])
				f2 = true;
		}

		if (!f1) fst = cnt;
		if (!f2) snd = cnt;

	} while (next_permutation(arr, arr + n));
	
	cout << (abs(fst - snd));
}



Measured memory_bytes: 256
# region header
import sys
import math
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement
from math import ceil, floor, factorial, log, sqrt, sin, cos
from operator import itemgetter
from string import ascii_lowercase, ascii_uppercase, digits
sys.setrecursionlimit(10**7)
rs = lambda: sys.stdin.readline().rstrip()
ri = lambda: int(rs())
rf = lambda: float(rs())
rs_ = lambda: [_ for _ in rs().split()]
ri_ = lambda: [int(_) for _ in rs().split()]
rf_ = lambda: [float(_) for _ in rs().split()]
INF = float('inf')
MOD = 10 ** 9 + 7
PI = math.pi
# endregion
print('Yes' if tuple([i for i in rs()]) in list(permutations('abc')) else 'No')

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


int main()
{

	int N;
	cin >> N;
	int h[101],m[101];
	for (int  i = 0; i < N; i++)
	{
		cin >> h[i] >> m[i];

	}
	h[N] = 24;
	m[N] = 0;
	int k[101],g[101];
	int M;
	cin >> M;

	for (int  i = 0; i < M; i++)
	{
		cin >> k[i] >> g[i];
	}
	k[M] = 24;
	g[M] = 0;
	for (int  i = 0,j=0; i <N||j<M ; )
	{
		if (h[i] == k[j] && m[i] == g[j]) {
			cout << h[i] << ":" << m[i] / 10 << m[i] % 10;
			i++;j++;

		}
		else if (h[i] < k[j] || (h[i] == k[j] && m[i] < g[j])) {
			cout << h[i] << ":" << m[i] / 10 << m[i] % 10;
			i++;
		}else{
			cout << k[j] << ":" << g[j] / 10 << g[j] % 10;
			j++;

		}
		if (i == N&&j == M) {
			cout << endl;
		}
		else {
			cout << " ";
		}
	}
	



	return 0;
}

Measured memory_bytes: 3092
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

int main()
{
  int n;
  cin >> n;
  vector<ll> vs(n);
  for(int i = 0; i < n; i++)
  {
	cin >> vs[i];
  }

  for(int i = 1; i < n; i++)
  {
	vs[i] += vs[i - 1];
  }

  ll sum_first_pos = 0;
  ll offset = 0;
  for(int i = 0; i < n; i++)
  {
	const ll val = vs[i] + offset;
	if(i % 2 == 0 && val <= 0)
	{
	  sum_first_pos += 1 - val;
	  offset += 1 - val;
	}
	if(i % 2 == 1 && val >= 0)
	{
	  sum_first_pos += val + 1;
	  offset -= val + 1;
	}
  }

  ll sum_first_neg = 0;
  offset = 0;
  for(int i = 0; i < n; i++)
  {
	const ll val = vs[i] + offset;
	if(i % 2 == 1 && val <= 0)
	{
	  sum_first_neg += 1 - val;
	  offset += 1 - val;
	}
	if(i % 2 == 0 && val >= 0)
	{
	  sum_first_neg += val + 1;
	  offset -= val + 1;
	}
  }
  cout << min(sum_first_neg, sum_first_pos) << endl;  
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    string S;
    cin >> S;
    // v[0] = head, v[1] = tail
    vector<string> v(2, "");
    int Q;
    cin >> Q;
    int rev = 0;
    for (int i = 0; i < Q; i++) {
        int T;
        cin >> T;
        if (T == 1) rev = (rev + 1) % 2;
        else {
            int F;
            string C;
            cin >> F >> C;
            F--;
            // F == 0 -> head, F == 1 -> tail
            v[(F + rev) % 2] += C;
        }
    }

    reverse(v[rev].begin(), v[rev].end());
    if (rev == 0) { cout << v[0] << S << v[1] << '\n'; }
    else {
        reverse(S.begin(), S.end());
        cout << v[1] << S << v[0] << '\n';
    }
}


Measured memory_bytes: 3980
#include<stdio.h>
typedef long long ll;

int main(){
	ll n, a, b, old, now;
	scanf("%lld%lld%lld%lld", &n, &a, &b, &old);
	ll ans = 0;
	for(int i = 1; i < n; ++i){
		scanf("%lld", &now);
		ans += (a * (now - old) > b ? b : a * (now - old));
		old = now;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 128
import sys
sys.setrecursionlimit(10**5+5)
input = sys.stdin.readline

N,M=map(int,input().split())
adj=[[] for _ in range(N)]

for i in range(M):
    x,y=map(int,input().split())
    x-=1
    y-=1
    adj[x].append(y)
    
dp=[-1]*N#i番目絡みた最長経路
for i in range(N):
    if len(adj[i])==0:
        dp[i]=0

def rec(ii):
    new=0
    for to in adj[ii]:
        if dp[to]!=-1:
            new=dp[to]
        else:
            new=rec(to)
        dp[ii]=max(new+1,dp[ii])
    return dp[ii]
        
for i in range(N):
    rec(i)
    
print(max(dp))

Measured memory_bytes: 136028
program main
  implicit none
  integer :: n, i, j, res
  integer, allocatable :: x(:, :), y(:, :), a(:)
  logical, allocatable :: is_honest(:)
  read (*, *) n
  allocate (x(n, n), y(n, n), a(n), is_honest(n))
  do i = 1, n
    read (*, *) a(i)
    do j = 1, a(i)
      read (*, *) x(i, j), y(i, j)
    end do
  end do

  res = 0
  is_honest(:) = .false.  ! can be anything
  call dfs(0, is_honest)

  write (*, "(i0)") res

  contains

  recursive subroutine dfs(depth, is_honest)
    integer, intent(in) :: depth
    logical, intent(in) :: is_honest(n)
    logical :: is_honest_new(n)
    if (depth == n) then
      if (is_possible(is_honest)) then
        res = max(res, count(is_honest))
      end if
    else
      is_honest_new(:) = is_honest(:)
      is_honest_new(depth + 1) = .true.
      call dfs(depth + 1, is_honest_new)
      is_honest_new(depth + 1) = .false.
      call dfs(depth + 1, is_honest_new)
    end if
  end subroutine dfs

  logical function is_possible(is_honest)
    logical, intent(in) :: is_honest(n)
    is_possible = .true.
    do i = 1, n
      if (.not. is_honest(i)) cycle
      do j = 1, a(i)
        if (is_honest(x(i, j)) .neqv. (y(i, j) == 1)) is_possible = .false.
      end do
    end do
  end function is_possible
end program main


Measured memory_bytes: 768
#include<stdio.h>
#include<string.h>
char S[300];
int A,a,b,T[300],W[300];

int ltr(char *S)
{
	int r=S[0]-'0',i,t;
	for(i=2;S[i];i+=2)
	{
		t=S[i]-'0';
		if(S[i-1]=='+')r+=t;
		else r*=t;
	}
	return r;
}

int cal()
{
	int i,j,t;
	for(i=0;i<strlen(S);i++)
		T[i]=S[i]=='*'?-2:S[i]=='+'?-1:S[i]-'0';
	T[i]=-3;
	for(;;)
	{
		for(i=1,j=0;T[i]!=-3;i+=2)
		{
			if(T[i]==-2)
			{
				W[j++]=T[i-1]*T[i+1];
				for(i=i+2;T[i-1]!=-3;i++)W[j++]=T[i];
				break;
			}
			else 
			{
				W[j++]=T[i-1];
				W[j++]=T[i];
			}
		}
		if(T[i]==-3)break;
		memcpy(T,W,sizeof(T));
	}
	t=0;
	for(i=0;T[i-1]!=-3;i+=2)t+=T[i];
	return t;
}

int main()
{
	gets(S);
	scanf("%d",&A);
	a=ltr(S);
	b=cal();
	if(a==b&&A==a)puts("U");
	else if(a==A)puts("L");
	else if(b==A)puts("M");
	else puts("I");
	return 0;
}

Measured memory_bytes: 576
N,A,B = map(int,input().split())
total_num = 0
cnt = 0
for i in range(1,N+1):
    num = i
    for j in range(5): # N <= 10**4より
        total_num +=  num % 10
        num = num // 10
    if A <= total_num <= B:
        cnt += i
    total_num = 0
print(cnt)

Measured memory_bytes: 3060
#include <stdio.h>
#define N 100001
#define Q 1000

int linear(int);
int n;
int S[N];

int main(){
  int q, i, c=0, flag;
  int T[Q]={};

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

  scanf("%d",&q);
  for(i=0; i<q; i++){
    scanf("%d",&T[i]);
  }

  for(i=0; i<q; i++){
    flag = linear(T[i]);
    if(flag == 1){
      c++;
    }
  }
    
  printf("%d\n",c);

  return 0;
}

int linear(int key){
  int i=0;
  S[n]=key;

  while(S[i] != key){
    i++;
    if(i == n){
      return 0;
    }
  }
  return 1;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#define debug(x) cerr << __LINE__ << ' ' << #x << ':' << x << '\n'
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
template<class T> using pque = priority_queue<T, vector<T>, greater<T>>;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr int mod1e9 = 1000000007;
constexpr int mod998 = 998244353;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
constexpr ll ten(int n) { return n ? 10 * ten(n - 1) : 1; };
int dx[] = { 1,0,-1,0,1,1,-1,-1 }; int dy[] = { 0,1,0,-1,1,-1,1,-1 };
void fail() { cout << "-1\n"; exit(0); } void no() { cout << "No\n"; exit(0); }
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }
template<class T> istream &operator >> (istream &s, vector<T> &v) { for (auto &e : v) s >> e; return s; }
template<class T> ostream &operator << (ostream &s, const vector<T> &v) { for (auto &e : v) s << e << ' '; return s; }

struct fastio {
	fastio() {
		cin.tie(0); cout.tie(0);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(20);
		cerr << fixed << setprecision(20);
	}
}fastio_;

ll modinv(ll a, ll mod) {
	a %= mod;
	if (a == 0) abort();
	ll b = mod, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= mod;
	if (u < 0) u += mod;
	return u;
}

int main() {
	ll n;
	cin >> n;
	n *= 2;
	ll ans = n - 1;
	for (ll i = 2; i * i <= n; i++) {
		if (n % i != 0) continue;
		ll x = i; ll y = n / i;
		if (gcd(x, y) != 1) continue;
		{
			ll a = modinv(y, x);
			ll k = a * y - 1;
			chmin(ans, k);
		}
		swap(x, y);
		{
			ll a = modinv(y, x);
			ll k = a * y - 1;
			chmin(ans, k);
		}
	}
	cout << ans << '\n';
}

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

const int MAX = 510000;
const int mod = 1000000007;

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

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

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

    ll n,k;
    cin>>n>>k;
    COMinit();
    ll a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    ll ans = 0;
    sort(a,a+n);
    for(int i=0;i<n;i++){
        ll ret = COM(i,k-1) * a[i];
        ret %= mod;
        ans += ret;
        ans %= mod;
        ret = COM(n-1-i,k-1) * a[i];
        ret %= mod;
        ans += mod - ret;
        ans %= mod;
    }
    cout << ans << endl;

}

Measured memory_bytes: 13056
#include<stdio.h>

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

using namespace std ;


int main( void )
{
	int N ,F ;
	scanf( "%d %d" ,&N ,&F ) ;	--F ;

	int M ;
	set< string > pair ;
	multiset< string > pair_data ;

	int i ,j ,k ;
	for( i = 0 ; i < N ; ++i )
	{
		vector< string > food ;

		scanf( "%d" ,&M ) ;
		for( j = 0 ; j < M ; ++j )
		{	string in ;	cin >> in ;	food.push_back( in ) ;	}
		
		sort( food.begin() ,food.end() ) ;

		for( j = 0 ; j < M ; ++j )
		{
			for( k = j + 1 ; k < M ; ++k )
			{
				string union_str = food[ j ] + ' ' + food[ k ] ;

				pair.insert( union_str ) ;
				pair_data.insert( union_str ) ;
			}
		}
	}

	vector< string > output ;
	set< string >::iterator itr ;
	for( itr = pair.begin() ; itr != pair.end() ; ++itr )
	{
		if( pair_data.count( *itr ) > F )
		{	output.push_back( *itr ) ;	}
	}

	cout << output.size() << "\n" ;
	for( i = 0 ; i < output.size() ; ++i )
	{	cout << output[ i ] << "\n" ;	}

	return 0 ;
}


Measured memory_bytes: 4156
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<set>
#include<utility>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ll> p;
typedef unsigned long long int ull;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const int MAXN=100000;
const int MAXE=100000;
const int MAXV=10000;
const int INF=2e9;
const ll MOD=1e9+7;
int N,K;
vector<ll> fac,inv,finv;
vector<ll> A;
void initCOM(){
    fac.resize(N+1);inv.resize(N+1);finv.resize(N+1);
    fac[0]=fac[1]=1;
    inv[1]=1;
    finv[0]=finv[1]=1;
    for(int i=2;i<=N;++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;
    }
}
ll COM(ll n,ll k){
    if(n<0||k<0) return 0;
    if(n<k) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
ll solve(){
    initCOM();
    ll res=0;
    for(int i=K-1;i<N;++i){
        res+=A[i]*COM(i,K-1)%MOD;
        res%=MOD;
    }
    for(int i=0;i<N-K+1;i++){
      res-=A[i]*COM(N-1-i,K-1)%MOD;
      res%=MOD;
    }
    if(res<0) res+=MOD;
    return res;
}
int main(){
    cin>>N>>K;
    A.resize(N);
    for(int i=0;i<N;++i) cin>>A[i];
    sort(A.begin(),A.end());
    cout<<solve()<<endl;
    return 0;
}

Measured memory_bytes: 6380
W, H, N = map(int, input().split())
L = [(0, 0)]
R = [(W, H)]
U = [(W, H)]
D = [(0, 0)]

for _ in range(N):
    x, y, a = map(int, input().split())
    if a == 1:
        L.append((x, y))
    if a == 2:
        R.append((x, y))
    if a == 3:
        D.append((x, y))
    if a == 4:
        U.append((x, y))

L.sort(key=lambda x: x[0])
R.sort(key=lambda x: x[0])
U.sort(key=lambda x: x[1])
D.sort(key=lambda x: x[1])

print(max(R[0][0] - L[-1][0], 0) * max(U[0][1] - D[-1][1], 0))


Measured memory_bytes: 3064
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<iostream>
#include<numeric>
using namespace std;

int main() {
	int a, b; cin >> a >> b;
	if (a + b < 10)
		cout << a + b << endl;
	else
		cout << "error" << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long [] ABC = {sc.nextLong(),sc.nextLong(),sc.nextLong()};
        Arrays.sort(ABC);
        long ans = 0;
        long sum = 0;
        String S = "";
        for(int i=0; i<3; i++){
            sum+=ABC[i];
            S+=(ABC[i]+" ");
        }
        HashSet<String> Set = new HashSet<>();
        Set.add(S);
        
        while(true){
            long x = ABC[0]/2;
            long y = ABC[1]/2;
            long z = ABC[2]/2;
            long [] nextABC = {x+y,y+z,z+x};
            Arrays.sort(nextABC);
            long tmpsum=0;
            String tmpS="";
            for(int i=0; i<3; i++){
                tmpsum+=nextABC[i];
                tmpS+=(nextABC[i]+" ");
                ABC[i] = nextABC[i];
            }
            if(Set.contains(tmpS)){
                System.out.println(-1);
                return;
            }else if(sum!=tmpsum){
                break;
            }
            Set.add(tmpS);
            ans++;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 23764
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

template<typename V>
constexpr string join(const V &v, const string &sep) {
  stringstream ss;
  if (v.size()) ss << v[0];
  loop(i, 1, v.size()) ss << sep << v[i];
  return ss.str();
}

void solve() {
  int n;
  while (cin >> n, n) {
    string s;
    getline(cin, s);
    vs v;
    map<string, int> m;
    while (n--) {
      getline(cin, s);
      istringstream ss(s);
      while (ss >> s) v.pb(s), m[s]++;
    }
    char k;
    cin >> k;
    set<string> t;
    for (auto &x : v) {
      if (x.front() == k) t.insert(x);
    }
    vs w;
    copy(all(t), back_inserter(w));
    sort(all(w), [&](string a, string b) {
      return m[a] > m[b];
    });
    if (w.size() > 5) w.resize(5);
    if (w.size() == 0) w.pb("NA");
    cout << join(w, " ") << endl;
  }
}

Measured memory_bytes: 3240
#include <bits/stdc++.h>
using namespace std;
set<int> tb;

int main(){
    int n, stamp = 1;
    cin >> n;
    while(tb.find(n) == tb.end())
    {
        ++stamp;
        tb.insert(n);
        if(n & 1)
        {
            n = 3 * n + 1;
        }
        else
        {
            n = n / 2;
        }
    }
    cout << stamp << '\n';
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll mod = 1e9+7;
ll power(ll a,ll b){
    ll res=1;
    while(b){
        if(b&1)res=res*a%mod;
        b>>=1;
        a=a*a%mod;
    }
    return res;
}
ll inv(ll x){
    return power(x,mod-2);
}
ll dp[211111],dp2[211111];
ll f(ll n,ll x){
    ll res=0,i;
    for(i=0;i<=x;i++){
        res+=dp[i]*dp2[i]%mod;
        res%=mod;
    }
    return res;
}
int main(){
    ll n,i,j,t,x,k,y,ma=0,mi=1e17;
    cin>>n>>x;
    dp[0]=1,dp2[0]=1;
    t=n,k=1;
    for(i=1;i<n;i++){
        dp[i]=dp[i-1]*t%mod*inv(k)%mod;
        dp2[i]=dp2[i-1]*(t-1)%mod*inv(k)%mod;
        t--,k++;
    }
    //for(i=0;i<=n-1;i++)cout<<dp[i]<<" "<<dp2[i]<<endl;
    if(x>=n-1){
        cout<<f(n,n-1)%mod;
    }
    else cout<<f(n,x)%mod;
}
/*
7
140 1
120 2
100 3
120
100
-1
100
*/


Measured memory_bytes: 3328
#include<iostream>
#include<map>
#include<vector>
#include<cmath>
#include<string>
#include <algorithm> 
using namespace std;

# define p(s) std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;

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

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

int main()
{
    
    int x[100000]={};
    int n;cin >> n >> x[0];
    
    for(int i=1;i<=n;i++){
        cin >> x[i];
    }
    sort(x,x+n+1);

    int g=x[1]-x[0];
    for(int i=1;i<n;i++){
        g=gcd(g,x[i+1]-x[i]);
    }
    p(g)
}

Measured memory_bytes: 640
# Date [ 2020-08-15 21:53:58 ]
# Problem [ d.py ]
# Author Koki_tkg

import sys;      from decimal import Decimal
import math;     from itertools import combinations, product, accumulate
import bisect;   from collections import Counter, deque, defaultdict

# sys.setrecursionlimit(10 ** 6)
MOD = 10 ** 6 + 7
INF = 10 ** 9
PI = 3.14159265358979323846

def read_str():      return sys.stdin.readline().strip()
def read_int():      return int(sys.stdin.readline().strip())
def read_ints():     return map(int, sys.stdin.readline().strip().split())
def read_str_list(): return list(sys.stdin.readline().strip().split())
def read_int_list(): return list(map(int, sys.stdin.readline().strip().split()))
def lcm(a: int, b: int) -> int: return (a * b) // math.gcd(a, b)

def Main():
    n, k = read_ints()
    p = read_int_list()
    c = read_int_list()
    loop_list = []
    visit = [False] * n

    # 閉路を探してloop_listに格納
    for i in range(n):
        if visit[i]:
            continue

        visit[i] = True
        now = i
        loop_tmp = []

        while True:
            now = p[now] - 1
            visit[now] = True
            loop_tmp.append(c[now])
            if visit[p[now] - 1]:
                loop_tmp.append(c[p[now] - 1])
                break
        loop_list.append(loop_tmp)

    #print(loop_list)
    ans = -10 ** 18

    #loopごとに全部試す
    for loop in loop_list:
        length = len(loop)
        score = sum(loop)
        if k > length:
            if score > 0:
                ans = max(ans, (k // length) * score + search_max_score(loop, k % length, length), (k // length - 1) * score + search_max_score(loop, length, length))
            else:
                ans = max(ans, search_max_score(loop, length, length))
        else:
            ans = max(ans, search_max_score(loop, k, length))
    
    print(ans)


def search_max_score(loop, rest, length):
    if rest == 0:
        ans = 0
    elif rest == 1:
        ans = max(loop)
    else:
        ans = -10**18
        loop += loop
        for i in range(length):
            tmp = list(accumulate(loop[i:i + rest]))
            #print(tmp)
            ans = max(ans, max(tmp))
    
    return ans

if __name__ ==  '__main__':
    Main()

Measured memory_bytes: 10884
N = int(input())
ans = 0
inputlist = []
for i in range(N):
  a, b = map(int, input().split())
  inputlist.append([a,b])
  
inputlist.reverse()
for i in range(N):
  a = inputlist[i][0]
  b = inputlist[i][1]
  
  a += ans
  if a % b == 0:
    continue
  ans += b - a % b
print(ans)

Measured memory_bytes: 19620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double ld;

#define for0(i, n) for (ll i = 0; i < (ll)(n); ++i) // 0 based indexing
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i) // 1 based indexing
#define forc(i, l, r) for (ll i = (ll)(l); i <= (ll)(r); ++i) // closed interver from l to r r inclusive
#define forr0(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i) // reverse 0 based.
#define forr1(i, n) for (ll i = (ll)(n); i >= 1; --i) // reverse 1 based

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
  ll n;
  cin >> n;
  vector < ld> num(n);
  ld a = 1;
  for0(i,n){
    cin >> num[i] ;
    a *= num[i];
  }
  ld b = 0;
  for0(i,n){
    b += a/num[i];
  }
  cout << a/b << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ff first
#define ss second
typedef long long ll;
ll power(ll a, ll b){//a^b
    ll res=1;
    a=a%MOD;
    while(b>0){
        if(b&1){res=(res*a)%MOD;b--;}
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
bool isPalin(string s){
    if (s==string(s.rbegin(),s.rend()))
        return true;
    return false;
}
ll fermat_inv(ll y){return power(y,MOD-2);}
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
int main(){
    ll t=1;
    //cin>>t;
    while(t--){
        ll x,k,d;
        cin>>x>>k>>d;
        x=abs(x);
        ll val=x/d;
        if(k<=val){
            x-=d*k;
            x=abs(x);
            cout<<x<<"\n";
        }
        else{
            x-=val*d;
            k-=val;
            if(k%2==1)
                x-=d;
            x=abs(x);
            cout<<x<<"\n";
        }
    }
    return 0;
}


Measured memory_bytes: 3632
a, b, c, x, y = map(int, input().split())
res = min(a*x+b*y, c*max(x, y)*2)
if x < y:
    res = min(res, 2*c*x+b*(y-x))
else:
    res = min(res, 2*c*y+a*(x-y))
print(res)

Measured memory_bytes: 3060
/*
    Problem 86
    https://atcoder.jp/contests/abc075/tasks/abc075_c?lang=ja
*/
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* class */
class DisjointSet {
    public:
    vector<int> d;
    DisjointSet(int size) : d(size, -1) {}
    int find(int x) {
        if (d[x] < 0) return x;
        return d[x] = find(d[x]);
    }
    bool unite(int x, int y) {
        x = find(x), y = find(y);
        if (x == y) return 0;
        if (d[x] > d[y]) swap(x, y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x, int y) { return find(x) == find(y); }
    int size(int x) { return -d[find(x)]; }
};
/* constant */
/* global variables */
/* function */
/* main */
int main(){
    int N, M, x, y;
    cin >> N >> M;
    vector<pii> vp(M);
    for (int i = 0; i < M; i++) {
        cin >> x >> y;
        x--; y--;
        vp[i] = pii(x, y);
    }
    int ans = 0;
    for (pii remove : vp) {
        DisjointSet ds = DisjointSet(N);
        for (pii p : vp) {
            if (p == remove) continue;
            ds.unite(p.first, p.second);
        }
        if (ds.size(0) != N) ans++;
    }
    cout << ans << '\n';
}


Measured memory_bytes: 256
N = int (input())
H = list(map(int,input().split()))
ans = 'Yes'
for  i in range(N-1):
    diff = H[i+1] - H[i]
    if diff >= 1:
        H[i+1] -= 1
    elif diff < 0:
        ans ='No'
print(ans)


Measured memory_bytes: 14396
#include <stdio.h>
#include <math.h>

int main(void)
{
    long int H, cnt = 0, cnt1 = 0, i;
    scanf("%ld", &H);
    while (H != 0)
    {
        H = (long)floor(H / 2.0);
        cnt++;
    }
    for (i = 0; i < cnt; i++)
    {
        cnt1 += pow(2, i);
    }
    printf("%ld", cnt1);

    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<cstring>
#include<cmath>
#include<set>
#include<queue>
#include<algorithm>
#include<climits>
#include<map>
#include<unordered_map>
#define ll long long

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

#define w(t) ll t,tt=1;	cin>>t;		while(t--)
#define ps(x,y) fixed<<setprecision(y)<<x
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ff first
#define ss second
#define pb push_back
#define mp make_pair

#define vi vector<int>
#define vll vector<ll>
#define mii map<ll,ll>
#define umii unordered_map<ll,ll>
#define pi pair<int,int>
#define pll pair<ll,ll>
#define vpii vector<pair<int,int>>
#define vpll vector<pair<ll,ll>>

#define mod 1e9+7
#define inf 1e18

#define lln ll n; cin>>n
#define intn int n; cin>>n
#define YES cout<<"YES"
#define NO cout<<"NO"
#define strr    string str; cin>>str;
#define strn   n=str.length()
#define fr(a,n) for(ll i=a;i<n;i++)
#define loop for(ll i=0;i<n;i++)

using namespace std;

void solve (){
    intn;
    if(n>=30)   cout<<"Yes";
    else    cout<<"No";
}

int main(){
    IOS
    solve();
    return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <cstring>
#include <queue>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)

int main(void){
	while(1){
		int n, m; cin >> n >> m;
		if(n == 0 && m == 0) return 0;
		vector<int> p(n);
		rep(i, n) cin >> p[i];
		p.push_back(0);//??¢????????????????????\??????
		vector<int> pp((n + 1) * (n + 1));
		int cnt = 0;
		rep(i, n + 1)rep(j, n + 1){
			pp[cnt] = p[i] + p[j];
			cnt++;
		}
	
		sort(pp.begin(), pp.end());
		int ans = 0;
		//?¨???????(n^2*log(n*n))
		rep(i, (n + 1) * (n + 1)){
			int tmp = pp[i];
			int aim = m - tmp;
			if(aim < 0) continue;
			tmp += *(upper_bound(pp.begin(), pp.end(), aim) - 1);
			if(tmp <= m) ans = max(ans, tmp);
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 5380
#include <stdio.h>

int main(int argc, char const *argv[]) {
    int a, b;
    scanf("%d %d", &a, &b);

    if (a < b) {
        printf("a < b\n");
    }
    else if (a > b) {
        printf("a > b\n");
    }
    else {
        printf("a == b\n");
    }
    return 0;
}



Measured memory_bytes: 2556
#include <iostream>
#include <vector>
#include <cstring>

using namespace std;
#define f first
#define s second
#define p pair<int,int>
#define P pair<ll,ll>
#define pb push_back
#define ll long long
#define ull unsigned long long
#define db double
#define zero(a) memset(a,0,sizeof(a))
#define inff(a,n) fill(a,a+n+1,inf)
#define all(a) a.begin(),a.end()
#define sz(a) int((a).size())
#define read(x) scanf("%d",&x)
#define read2(x,y) scanf("%d%d",&x,&y)
#define write(x) printf("%d\n",x)


const ll inf = 1e9;

int n, m, cnt, ans, flag = 1, a[100010];
vector<int>v[100010];

void dfs(int u, int fa)
{
	for (auto i : v[u])
	{
		if (i == fa)continue;
		if (a[i] == -1)
		{
			a[i] = (a[u] ^ 1);
			dfs(i, u);
		}
		else
		{
			if (a[i] == a[u])flag = 0;
		}
	}
}

int main()
{
	cin >> n >> m;
	for (int i = 0; i<m; i++)
	{
		int x, y;
		cin >> x >> y;
		v[x].pb(y);
		v[y].pb(x);
	}
	memset(a, -1, sizeof(a));
	a[1] = 0;
	dfs(1, 0);
	if (flag)
	{
		for (int i = 1; i <= n; i++)if (a[i])cnt++;
		cout << 1ll * cnt*(n - cnt) - m;
	}
	else
	{
		cout << 1ll * n*(n - 1) / 2 - m;
	}
	return 0;
}

Measured memory_bytes: 6912
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin.bytes().map(|c| c.expect("faild") as char).skip_while(|c| c.is_whitespace()).take_while(|c| !c.is_whitespace()).collect();
    token.parse().ok().expect("faild parse")
}
fn main(){
    let a: i32 = read();
    let b: i32 = read();
    if a > b{
        println!("a > b");
    }else if a < b{
        println!("a < b");
    }else{
        println!("a == b");
    }
}


Measured memory_bytes: 1044
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int ac = 0,wa=0,tle=0,re=0;
        int n = sc.nextInt();
        for(int i = 0;i<n;i++){
            String s = sc.next();
            if(s.equals("AC"))ac++;
            else if(s.equals("WA"))wa++;
            else if(s.equals("TLE"))tle++;
            else if(s.equals("RE"))re++;
        }
        System.out.println("AC x "+ac);
        System.out.println("WA x "+wa);
        System.out.println("TLE x "+tle);
        System.out.println("RE x "+re);
    }
}

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

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 (b<a) { a=b; return 1; } return 0; }

using ll = long long;
using lb = long double;
using P = pair<ll,ll>;
using graph = vector<vector<ll>>;

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

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

int main() {
  ll N,M;
  cin>>N>>M;
  scc_graph g(N);
  rep(i,M) {
    int a,b;
    cin>>a>>b;
    g.add_edge(a,b);
  }
  auto ans = g.scc();
  cout<<ans.size()<<endl;
  for(auto x:ans){
    cout<<x.size()<<" ";
    for(auto y:x) cout<<y<<" ";
    cout<<endl;
  }
}

Measured memory_bytes: 40592
using System;

namespace ABC087B___Coins
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = int.Parse(Console.ReadLine());
            var b = int.Parse(Console.ReadLine());
            var c = int.Parse(Console.ReadLine());
            var x = int.Parse(Console.ReadLine());
            var ans = 0;
            for (var i = 0; i <= a; i++)
            {
                for (var j = 0; j <= b; j++)
                {
                    for (var k = 0; k <= c; k++)
                    {
                        if (500 * i + 100 * j + 50 * k == x)
                        {
                            ans++;
                        }
                    }
                }

            }
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 11092
from collections import deque,Counter
N,M = map(int,input().split())
A = []
for i in range(N):
  KA = deque(list(map(int,input().split())))
  KA.popleft()
  A += KA
A = Counter(A)
values, counts = zip(*A.most_common())

print(counts.count(N))

Measured memory_bytes: 3316
n,x,m = list(map(int,input().split()))

if x == 0:
    ans = 0
else:
    ans = x % m
dicNum = dict()
dicSum = dict()
dicNum[x] = 1
dicSum[1] = x
dicSum[0] = 0

for i in range(2,n+1):
    b = x
    x = x**2 % m
    if x in dicNum.keys():
        t = i - dicNum[x]
        zan = n - i + 1
        k = zan // t
        ans += (dicSum[i-1] - dicSum[dicNum[x]-1]) * k
        if zan% t != 0:
            zan = zan % t
            ans += dicSum[dicNum[x] - 1 + zan] - dicSum[dicNum[x]-1]
        break
    else:
        ans += x
        dicSum[i] = ans
        dicNum[x] = i

print(ans)

Measured memory_bytes: 82336
#include<stdio.h>
#define MAX 100000

int binarySearch(int[], int, int);

main()
{
  int i, n1, n2, S[MAX], T[MAX], count=0;
  
  scanf("%d", &n1);
  for(i=0; i<n1; i++)
    {
      scanf("%d", &S[i]);
    }
  
  scanf("%d", &n2);
  for(i=0; i<n2; i++)
    {
      scanf("%d", &T[i]);
    }
  
  for(i=0; i<n2; i++)
    {
      count += binarySearch(S, T[i], n1);
    }
  printf("%d\n", count);
  
  return 0;
}

int binarySearch(int A[], int key, int n)
{
  int left=0, right=n, mid;

  while(left < right)
    {
      mid = (left + right) / 2;

      if(A[mid] == key)
	{
	  return 1;
	}
      else if(key < A[mid])
	{
	  right = mid;
	}
      else
	{
	  left = mid + 1;
	}
    }

  return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e9 + 7, MOD = 1e9 + 7;
const long long LINF = 1e18;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {
	int n;
	cin >> n;
	int a[n], b[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		b[i] = a[i];
	}
	sort(a, a + n);
	int cmp = a[n / 2];
	for (int i = 0; i < n; i++) {
		if (b[i] < cmp) cout << cmp << endl;
		else cout << a[n / 2 - 1] << endl;
	}
	return 0;
}

Measured memory_bytes: 5248
k = int(input())
count = 9
from collections import deque
que = deque([1,2,3,4,5,6,7,8,9])
if k<10:
    print(k)
    exit()
while que:
    v = que.popleft()
    matu = v%10
    for i in range(10):
        if abs(matu-i)<=1:
            que.append(v*10+i)
            count +=1
            if count == k:
                print(que.pop())
                exit()


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

int main() {
  vector<vector<int>> c(3, vector<int>(3));
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> c.at(i).at(j);
    }
  }

  for (int a1 = 0; a1 <= c.at(0).at(0); a1++) {
    int a2, a3, b1, b2, b3;
    b1 = c.at(0).at(0) - a1; 
    b2 = c.at(0).at(1) - a1; 
    b3 = c.at(0).at(2) - a1;
    a2 = c.at(1).at(0) - b1; 
    a3 = c.at(2).at(0) - b1;
    if (a2 + b2 == c.at(1).at(1)
        && a2 + b3 == c.at(1).at(2)
        && a3 + b2 == c.at(2).at(1)
        && a3 + b3 == c.at(2).at(2)) {
          cout << "Yes" << endl;
          return 0;
        }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(long long i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }


int main(){
    ll n,m; cin>>n>>m;
    vector<ll> a(m), b(m);
    rep(i,m) cin>>a[i]>>b[i];
    vector<vector<ll>> edge(n+1);
    vector<ll> res(n+1, -1);
    rep(i,m){
        edge[a[i]].push_back(b[i]);
        edge[b[i]].push_back(a[i]);
    }
    res[1]=0;
    queue<ll> que;
    que.push(1);
    while(!que.empty()){
        ll x=que.front();
        que.pop();
        for(ll y : edge[x]){
            if(res[y]!=-1) continue;
            res[y]=x;
            que.push(y);
        }
    }
    cout<<"Yes"<<endl;
    rep(i,n-1) cout<<res[i+2]<<endl;
    return 0;
}

Measured memory_bytes: 16004
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    ll N,K; cin >> N>>K;
    vector<ll> A(N); for(auto& in:A) cin >> in;
    cout << 1 + max(0LL,(N-K+(K-1)-1)/(K-1)) << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
const int maxn = 2e6 + 10;
ll fac[maxn], inv[maxn], facinv[maxn];
ll norm(ll x) { return (x % mod + mod) % mod;}
void pre()
{
	fac[0] = 1; for(int i = 1; i < maxn; ++i) fac[i] = fac[i - 1] * i % mod;
	inv[1] = 1; for(int i = 2; i < maxn; ++i) inv[i] = (mod - mod / i) * inv[mod % i] % mod;
	facinv[0] = 1; for(int i = 1; i < maxn; ++i) facinv[i] = facinv[i - 1] * inv[i] % mod;
}
ll C(int n, int m) { return fac[n] * facinv[m] % mod * facinv[n - m] % mod;};
ll f(int x, int y)
{
	return norm(C(y + x + 2, y + 1) - 1);
}
int main()
{
	pre();
	int r1, c1, r2, c2;
	cin >> r1 >> c1 >> r2 >> c2;
	ll ans = f(r2, c2) - f(r1 - 1, c2) - f(r2, c1 - 1) + f(r1 - 1, c1 - 1);
	ans = norm(ans);
	printf("%lld\n", ans);
	return 0;
}

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

int main(void){
    char s[11], t[11];
    int sn, tn;
    scanf("%s%s",s,t);

    sn = strlen(s);
    tn = strlen(t);

    if(strncmp(s,t,sn)==0 && sn+1 == tn){
        printf("Yes");
    }else{
        printf("No");
    }

    return 0;
}

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

using namespace std;

int main(){
    string S;
    while(cin >> S){
        int res = 0;
        string pre = "";
        for(int i=0;i<S.size();i++){
            if(pre.size() == 1 && pre[0] == S[i]){
                if(i+1 < S.size()){
                    pre = S.substr(i, 2);
                    ++res;
                    ++i;
                }
            } else {
                pre = S[i];
                ++res;
            }
        }
        cout << res << endl;
    }
}

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

const ll p = 1e9+7;
const ll inv2 = (p+1)/2;

ll dp[3][3005][3005], n, q, a[3005];

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

	cin >> n >> q;
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	for (int i = 0; i < n; ++i)
		for (int j = i+1; j < n; ++j) {
			if (a[i] == a[j])
				dp[1][i][j] = 1;
			else {
				dp[0][i][j] = (a[i] < a[j]);
				dp[2][i][j] = (a[i] > a[j]);
			}
		}

	for (int k = 0; k < q; ++k) {
		int x, y;
		cin >> x >> y;
		if (x > y)
			swap(x, y);
		x--; y--;
		vector<ll> vx[3], vy[3];
		vx[0].resize(n);
		vx[1].resize(n);
		vx[2].resize(n);
		vy[0].resize(n);
		vy[1].resize(n);
		vy[2].resize(n);
		for (int i = 0; i < n; ++i) {
			if (i < x) {
				vx[0][i] = (dp[0][i][x] + dp[0][i][y])%p;
				vy[0][i] = (dp[0][i][y] + dp[0][i][x])%p;
				vx[1][i] = (dp[1][i][x] + dp[1][i][y])%p;
				vy[1][i] = (dp[1][i][y] + dp[1][i][x])%p;
				vx[2][i] = (dp[2][i][x] + dp[2][i][y])%p;
				vy[2][i] = (dp[2][i][y] + dp[2][i][x])%p;
			} if (x < i && i < y) {
				vx[0][i] = (dp[0][x][i] + dp[2][i][y])%p;
				vy[0][i] = (dp[0][i][y] + dp[2][x][i])%p;
				vx[1][i] = (dp[1][x][i] + dp[1][i][y])%p;
				vy[1][i] = (dp[1][i][y] + dp[1][x][i])%p;
				vx[2][i] = (dp[2][x][i] + dp[0][i][y])%p;
				vy[2][i] = (dp[2][i][y] + dp[0][x][i])%p;
			} if (i > y) {
				vx[0][i] = (dp[0][x][i] + dp[0][y][i])%p;
				vy[0][i] = (dp[0][x][i] + dp[0][y][i])%p;
				vx[1][i] = (dp[1][x][i] + dp[1][y][i])%p;
				vy[1][i] = (dp[1][x][i] + dp[1][y][i])%p;
				vx[2][i] = (dp[2][x][i] + dp[2][y][i])%p;
				vy[2][i] = (dp[2][y][i] + dp[2][x][i])%p;				
			}
		}

		for (int i = 0; i < n; ++i) {
			for (int k = 0; k < 3; ++k) {
				if (i == x || i == y)
					continue;
				// cout << k << ' ' << i << ' ' << vx[k][i] << ' ' << vy[k][i] << endl;
				if (i < x)
					dp[k][i][x] = vx[k][i]*inv2%p;
				else
					dp[k][x][i] = vx[k][i]*inv2%p;
				if (i < y)
					dp[k][i][y] = vy[k][i]*inv2%p;
				else
					dp[k][y][i] = vy[k][i]*inv2%p;
			}
		}

		ll r = dp[0][x][y] + dp[2][x][y];
		dp[0][x][y] = dp[2][x][y] = r*inv2%p;
	}

	ll ans = 0;
	for (int i = 0; i < n; ++i)
		for (int j = i+1; j < n; ++j) {
			ans = (ans + dp[2][i][j])%p;
			// cout << i << ' ' << j << ' ' << dp[0][i][j] + dp[1][i][j] + dp[2][i][j] << endl;
		}
	for (int i = 0; i < q; ++i)
		ans = ans*2%p;
	cout << ans << endl;
}

Measured memory_bytes: 211564