akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		int k = Integer.parseInt(sa[1]);
		int[] a = new int[n + 1];
		sa = br.readLine().split(" ");
		for (int i = 0; i < n; i++) {
			a[i + 1] = Integer.parseInt(sa[i]);
		}
		br.close();

		int[] b = new int[n + 1];
		for (int i = 0; i < n; i++) {
			b[i + 1] = b[i] + a[i + 1];
		}
		
		long[][] dp = new long[n + 1][k + 1];
		dp[0][0] = 1;
		for (int i = 1; i <= n; i++) {
			dp[i][0] = dp[i - 1][0];
			for (int j = 1; j <= k; j++) {
				dp[i][j] = dp[i][j - 1] + dp[i - 1][j];
				if (j > a[i]) {
					dp[i][j] += 1000000007 - dp[i - 1][j - a[i] - 1];
				}
				dp[i][j] %= 1000000007;
			}
		}
		System.out.println(dp[n][k]);
	}
}


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

int main() {
  int N,K,a,b;
  cin >>N >>K;
  vector<int> data(N);
  for(int i=0;i<K;i++){
    cin >>a;
    for(int j=0; j<a; j++){
      cin >>b;
      data.at(b-1) = data.at(b-1)+1;
    }
  }
  int c=0;
  for(int i=0; i<N; i++){
    if(data.at(i)==0){
      c++;
    }
  }
  cout <<c <<endl;
}

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

using namespace std;

int main() {
	int n;
	cin>>n;
	int unit = n % 10;
	set<int> s1{2, 4, 5, 7, 9};
	set<int> s2{0,1,6,8};
	if(s1.find(unit) != s1.end()) {
		cout<<"hon\n";
	} else if(s2.find(unit) != s2.end()) {
		cout<<"pon\n";
	} else {
		cout<<"bon\n";
	}
	return 0;
}


Measured memory_bytes: 3632
#include <stdio.h>

int main(void)
{
  char str[100];
  int judge = 0;

  fgets(str,100,stdin);

  if(strcmp(str,"7 5 5\n") == 0)
    judge = 1;
  else if(strcmp(str,"5 7 5\n") == 0)
    judge = 1;
  else if(strcmp(str,"5 5 7\n") == 0)
    judge = 1;

  if(judge == 1)
    printf("YES\n");
  if(judge == 0)
    printf("NO\n");

   return 0;
}

Measured memory_bytes: 128
MOD = 10 ** 9 + 7
INF = 10 ** 10
import sys
sys.setrecursionlimit(100000000)
dy = (-1,0,1,0)
dx = (0,1,0,-1)

def main():
    n,m = map(int,input().split())
    a = list(map(int,input().split()))
    tot = sum(a)
    a.sort(reverse = True)

    if a[m - 1] * 4 * m >= tot:
        print('Yes')
    else:
        print('No')

 
if __name__ =='__main__':
    main()  

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z temp.cpp
//./a.exe

int f(int x){
    if (x%2==0)
    {
        x=x/2;
    }else
    {
        x=3*x+1;
    }
    
    return x;
}

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

int s;
cin >> s;
for(int i=1;i<1000000;i++){
    if(s==1||s==2||s==4){
        i += 3;
    cout << i << endl;
    return 0;
    }
    s = f(s);
}






//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
#include <math.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <sstream>
#include <vector>

using namespace std;
using Graph = vector<vector<int>>;

using ll = long long;
typedef pair<ll, ll> P_ll;
typedef pair<int, int> P;

const ll INF_ll = 1e17;
const int INF = 1e8;

int main() {
  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    string X, Y;
    cin >> X >> Y;
    vector<vector<int>> dp(X.size() + 1, vector<int>(Y.size() + 1, 0));
    for (int j = 0; j < X.size(); j++) {
      for (int k = 0; k < Y.size(); k++) {
        if (X[j] == Y[k]) {
          dp[j + 1][k + 1] = dp[j][k] + 1;
        } else {
          dp[j + 1][k + 1] = max(dp[j + 1][k], dp[j][k + 1]);
        }
      }
    }
    cout << dp[X.size()][Y.size()] << endl;
  }

  return 0;
}


Measured memory_bytes: 6816
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
 
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define inf (1<<29)
#define MAX 160 
using namespace std;

bool dp[MAX][MAX][2];
 
int main()
{
  int T;
  while(cin >> T)
    {
      while(T--)
	{
	  rep(i,MAX)rep(j,MAX)rep(l,2)dp[i][j][l] = false;
	  int N;
	  cin >> N;
	  int input[N];
	  rep(i,N) cin >> input[i];
       
	  if(N <= 2)
	    {
	      cout << input[N-1] << endl;
	      continue;
	    }
       
	  int ans = input[N-1];
 
	  REP(cur,1,N-1)
	    {
	      dp[input[cur-1]][input[cur]][cur&1] = true;
	      int R = input[cur+1];
	      rep(L,MAX)
		{
		  rep(M,MAX)
		    {
		      if(!dp[L][M][cur&1])continue;
		      if(M == 0)
			{
			  if(cur+2 < N) dp[M][R][(cur+1)&1] = true;
			  else          ans = max(ans,R);
			}
		      else
			{
			  if(cur+2 < N)
			    {
			      dp[M][R][(cur+1)&1] = true;
			      dp[M-1][R+L][(cur+1)&1] = true;
			    }
			  else ans = max(ans,R+L);
			}
		    }
		}
	      rep(i,MAX)rep(j,MAX)dp[i][j][cur&1] = false;
	    }
	  
	  cout << ans << endl;      
	}
    }
  return 0;
}

Measured memory_bytes: 1208
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
#define int long long
#define mod(int)(1000000007)
using namespace std;
int test[213456];
int keta(int x) {
	int res = 0;
	while(x >= 1) {
		x /= 10; res++;
	}return res;
}
signed main() {
	int n, a, b, x, c = 0, d = 0; string s; cin >> s;
	for (int h = 0; h < s.size(); h++) {
		if (s[h] == '1') { cout << 9; }
		else { cout << 1; }
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#define int long long int
using namespace std;

void desperate_optimization(bool submitting=true,int precision=10)
{
  if(!submitting) return;
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout.setf(ios::fixed);
  cout.setf(ios::showpoint);
  cout.precision(precision);
}
const int maxn=301;
double p[maxn][maxn][maxn];
double ev[maxn][maxn][maxn];
//p[a][b][c] represents the probability (a,b,c) state will exist
//ev[a][b][c] represents the expected number of moves required to reach (a,b,c)

int32_t main()
{
  desperate_optimization(false);
  int n;
  cin>>n;
  vector<int> count(4,0);
  for(int i=0;i<n;i++)
  {
    int x;
    cin>>x;
    count[x]++;
  }  
  p[count[1]][count[2]][count[3]]=1;
  for(int c=n;c>=0;c--)
  {
    for(int b=n;b>=0;b--)
    {
      for(int a=n;a>=0;a--)
      {
        if(a+b+c==0 || a+b+c>n) continue;

        double p_samestate=((n-(a+b+c))*1.0)/(n);
        double ev_wasted=p_samestate/(1-p_samestate);

        ev[a][b][c]+=ev_wasted*p[a][b][c];

        if(a>0)
        {
          double p_transition=((double)a)/(a+b+c);
          p[a-1][b][c]+=p[a][b][c]*p_transition;
          ev[a-1][b][c]+=ev[a][b][c]*p_transition;
        }
        if(b>0)
        {
          double p_transition=((double)b)/(a+b+c);
          p[a+1][b-1][c]+=p[a][b][c]*p_transition;
          ev[a+1][b-1][c]+=ev[a][b][c]*p_transition;
        }
        if(c>0)
        {
          double p_transition=((double)c)/(a+b+c);
          p[a][b+1][c-1]+=p[a][b][c]*p_transition;
          ev[a][b+1][c-1]+=ev[a][b][c]*p_transition;
        }

      }
    }
  }
  printf("%.10f",ev[0][0][0]+count[1]+2*count[2]+3*count[3]);
  



  return 0;
}


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

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;

template<int M = 1000000007>
struct ModInt {
    int data;

    ModInt(int data) : data(data) {}

    ModInt() : data(0) {}

    inline ModInt<M> operator+(ModInt<M> const &right) const {
        int temp = data + right.data;
        return ModInt(temp > M ? temp - M : temp);
    }

    inline ModInt<M> &operator+=(ModInt<M> const &right) {
        data += right.data;
        data = data > M ? data - M : data;
        return *this;
    }

    inline ModInt<M> operator-(ModInt<M> const &right) const {
        int temp = data - right.data;
        return ModInt(temp < 0 ? temp + M : temp);
    }

    inline ModInt<M> &operator-=(ModInt<M> const &right) {
        data -= right.data;
        data = data < 0 ? data + M : data;
        return *this;
    }

    inline ModInt<M> operator*(ModInt<M> const &right) const {
        int temp = data * right.data % M;
        return ModInt(temp < 0 ? temp + M : temp);
    }

    inline ModInt<M> &operator*=(ModInt<M> const &right) {
        data = data * right.data % M;
        data = data < 0 ? data + M : data;
        return *this;
    }

    inline bool operator==(ModInt<M> const &right) const {
        return data == right.data;
    }

    inline bool operator!=(ModInt<M> const &right) const {
        return data != right.data;
    }


};

template<int M = 1000000007>
inline ostream &operator<<(ostream &os, const ModInt<M> mi) {
    os << mi.data;
    return os;
}


int N;
int D[100100];
int depth[100100];

signed main() {
    cin >> N;
    rep(i, N) {
        cin >> D[i];
    }
    if (D[0] != 0) {
        cout << 0 << endl;
        return 0;
    }
    for (int i = 1; i < N; ++i) {
        depth[D[i]]++;
        if (D[i] == 0) {
            cout << 0 << endl;
            return 0;
        }
    }
    bool flag = false;
    for (int i = N - 1; i >= 1; --i) {
        if (flag && depth[i] == 0) {
            cout << 0 << endl;
            return 0;
        } else {
            if (depth[i])flag = true;
        }
    }
    depth[0] = 1;
    ModInt<998244353> ans = 1;
    for (int i = 1; i < N; ++i) {
        if (depth[i] == 0)break;
        for (int j = 0; j < depth[i]; ++j) {
            ans *= depth[i - 1];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
a = gets.split(" ").map(&:to_i)
k = a[0]
x = a[1]

l = k - 1
ary = [x]

(1..l).each do |l|
    ary.unshift(x-l)
    ary.push(x+l)
end

ary.each do |a|
    puts "#{a} " 
end

Measured memory_bytes: 1788
#include<stdio.h>
int MIN(int a,int b){return  a<b?a:b;}
int main(){
  int n,m,r,i,j,k,t[10],d[210][210]={};
  int c[10][310]={};
  scanf("%d %d %d",&n,&m,&r);
  for(i=0;i<r;i++)scanf("%d",&t[i]);
  for(i=0;i<r;i++)t[i]--;
  for(i=0;i<n;i++){
    for(j=0;j<n;j++)d[i][j]=1e9;
    d[i][i]=0;
  }
  while(m--){
    scanf("%d %d %d",&i,&j,&k);
    d[i-1][j-1]=d[j-1][i-1]=k;
  }
  for(i=0;i<r;i++){
    for(j=0;j<300;j++)c[i][j]=1e9;
    c[i][1<<i]=0;
  }
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      for(k=0;k<n;k++)d[j][k]=MIN(d[j][k],d[j][i]+d[i][k]);
    }
  }
  for(i=0;i<(1<<r);i++){
    for(j=0;j<r;j++){
      if((i&(1<<j))==0)continue;
      for(k=0;k<r;k++)c[k][i|(1<<k)]=MIN(c[k][i|(1<<k)],c[j][i]+d[t[j]][t[k]]);
    }
  }
  /*for(i=0;i<(1<<r);i++){
    for(j=0;j<r;j++)printf("%10d ",c[j][i]);printf("\n");
    }//*/
  j=(1<<r)-1;
  for(i=0;i<r;i++)c[0][j]=MIN(c[0][j],c[i][j]);
  printf("%d\n",c[0][j]);
  return 0;
}
  


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

int pr[50847534];
int fact[5000];
int x = 0;
int n,pn=0;
short *arr;

int nextpr(int p){
  int nxp=p+2;
  int i;
  int ok;
  pr[x]=p;
  x++;
  if(p==2)return 3;
  while(1){
      /*printf("p=%d->",nxp);*/
    for(i=0;pr[i]*pr[i]<=nxp;i++){
      ok = 1;
      if(!(nxp%pr[i])){
        ok = 0;
        break;
      }
    }
    if(ok){
        /*printf("O\n");*/
      return nxp;
    }else{
        /*printf("X\n");*/
      nxp+=2;
    }
  }
}

int main(){
    int n2;
    int p=2,prod,ans=0;
    int i,j,k;
    scanf("%d",&n);
    n2 = n;
    while(n>1){
        if(!(n%p)){
            while(!(n%p))n /= p;
            fact[pn] = p;
            pn++;
        }else{
            p = nextpr(p);
        }
        if(p*p>n){
            /*?´???°?????£??????????????????????????????*/
            if(n-1){
            fact[pn]=n;
            pn++;
            }
            break;
        }
    }
    /*printf("facts:");
    for(i=0;i<pn;i++){
        printf(" %d",fact[i]);
    }
    printf("\n");*/
    arr = (short *)calloc(pn,sizeof(short));
    for(i=0;i<pn;i++)arr[i]=0;
    while(1){
        /*for(i=0;i<pn;i++)printf(" %d",arr[i]);*/
        prod = 1;
        for(j=0;j<pn;j++){
            if(arr[j]){
                prod*=fact[j];
                prod*=-1;
            }
        }
        ans += (n2/prod);
        /*printf(" prod=%d ans=%d\n",prod,ans);*/
        /*????????????arr????¬???????????????????????????????*/
        arr[0]+=1;
        for(k=0;k<pn;k++){
            if(arr[k]>1){
                if(k==pn-1){
                    printf("%d\n",ans);
                    exit(0);
                }
                arr[k]=0;
                arr[k+1]+=1;
            }
        }/*???????????§arr????¬???????????????????????????????*/
    }
}

Measured memory_bytes: 1032
import java.util.*;
import java.lang.*;
import java.io.*;
class Main
{
    public static int divide(int n, int[] p)
    {
        if(n%2 != 0)
		{
		    return 0;
		}
		else
		{  
		    int output = 0;
		    Arrays.sort(p);
		    int mid = n/2;
		    //if(p[mid] != p[mid-1])
		    //{
		        output = p[mid-1]-p[mid];
		    //}
		    //else if(p[mid] == p[mid-1])
		    //{
		        
		    //}
		    return output;
		}
    }
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] p = new int[n];
		for(int i=0; i<n;i++)
		{
		    p[i] = sc.nextInt();
		}
		int output = divide(n,p);
		if(output < 0)
      	    System.out.println((-1)*output);
      	else
      	    System.out.println(output);
	}
}

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

typedef long long int ll;
//Factors of an num
/*
vector<ll> fact(ll n){
	vector<ll>v;
	for(int i=1;i*i<=n;i++){
		if(n%i ==0){
			v.push_back(i);
		
		if(i!=n/i)
			v.push_back(n/i);
	    }
	}

	return v;
}
*/


/*
Seive Of Eratos..
int N=1e5;
vector<bool> isprime(N+1,true);
void pri(int n){
	for(int i=2;i*i<=n;i++){
		if(isprime[i]){
			for(int j=i*i;j<=n;j+=i){
				isprime[j]=false;
			}
		}
	}
	return;
}
*/

/*
//Prime Factors
vector<bool> isprime(1e6+1,true);
 vector<int> primes;
 void sieve()
 {

    ll  i,j;
    isprime[0] = false;
    isprime[1] = false;

    for(i=2; i<=1e6 ;i++)
  {

    if(isprime[i])
    {

      primes.push_back(i);

      for(j=i*i; j<=1e6; j+=i)
      {
        isprime[j]=false;
      }

    }

  }
}

vector<int> primefactors(int  N)

 {

    vector<int> factors;
    ll pf_idx = 0, pf=primes[pf_idx];

    while(pf*pf<=N)
    {
        while(N % pf == 0)
        {
            N/=pf;
            factors.push_back(pf);
        }
        pf = primes[++pf_idx];
    }
    
    if(N != 1) factors.push_back(N);
    return factors;
}
 */   




int main(){
	 
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin.tie(NULL);
int a;
cin>>a;
cout<<a+a*a+a*a*a<<endl;
}

Measured memory_bytes: 3604
n = int(input())
lst = list(map(int, input().split()))
mul = 1
thr = 10 ** 18
if 0 in lst:
  print('0')
  exit()
for i in range(n):
  mul = mul * lst[i]
  if mul > thr:
    print('-1')
    exit()
print(mul)

Measured memory_bytes: 21464
#include<bits/stdc++.h>
using namespace std;
int main(){

  int N,M,C;
  cin>>N>>M>>C;
  vector<int> B(M);
 

  for(int i=0;i<M;i++){
  cin>>B[i];
  }
   vector<vector<int>> A(N,vector<int>(M));
  for(int j=0;j<N;j++){
  for(int i=0;i<M;i++){
  cin>>A[j][i];
  }
  }
  
  int a=0;
  for(int j=0;j<N;j++){
    int count=0;
  for(int i=0;i<M;i++){
 
    count+=B[i]*A[j][i];
  }
    if(count+C>0){
    a++;
    }
  
  }
  cout<<a<<endl;
  
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        // SOLUTION A
//        Scanner scanner = new Scanner(System.in);
//        int n = scanner.nextInt();
//        int a = scanner.nextInt();
//        int b = scanner.nextInt();
//        int answer = solutionA(n, a, b);
//        System.out.println(answer);
//    }
//
//    public static int solutionA (int n, int a, int b) {
//        if ((n * a) < b) {
//            return (n * a);
//        } else {
//            return b;
//        }
//    }

        // SOLUTION B
        Scanner scanner = new Scanner(System.in);
        long i = scanner.nextLong();
        long j = scanner.nextLong();
        System.out.println(solutionB(i, j));
    }

    // james wuz here lul
    public static long solutionB(long l, long r) {
        if (l + 2019 <= r) {
            return 0;
        } else {
            long min = 2019;
            for (long i = l; i <= r; i++) {
                for (long j = i + 1; j <= r; j++) {
                    long x = (i * j) % 2019;
                    if (x < min) {
                        min = x;
                    }
                }
            }
            return min;
        }
    }
}


Measured memory_bytes: 21844
#include <stdio.h>
#define swap(type, x, y)  do{ type t = x; x = y; y = t; }while(0)
#define min(x, y)  ((x)>(y) ? (y) : (x))

void quick(int array[], int left, int right){
  int pl = left, pr = right, x = array[(left + right) / 2];
  do{
    while(array[pl] < x)  pl++;
    while(array[pr] > x)  pr--;
    if(pl <= pr){
      swap(int, array[pl], array[pr]);
      pl++, pr--;
    }
  }while(pl <= pr);
  if(pl < right)  quick(array, pl, right);
  if(pr > left)  quick(array, left, pr);
}

int main(){
  int n, k;  scanf("%d %d", &n, &k);
  int h[100005];
  for(int i=0; i<n; i++)  scanf("%d", h+i);
  quick(h, 0, n-1);
  int ans = 1000000000;
  for(int i=k; i<=n; i++)
    ans = min(ans, h[i-1]-h[i-k]);

  printf("%d\n", ans);
  return 0;
}


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

#define REP(i,a,b) for(int i=a;i<=b;++i)
typedef long long ll;

using namespace std;

void File(){
	freopen("ARC99D.in","r",stdin);
	freopen("ARC99D.out","w",stdout);
}

double cal(ll x){
	ll y=10,len=1,sum=0,ret=x;
	while(y<=x)y=(y<<1)+(y<<3),++len;
	while(len--){
		y/=10;
		sum+=x/y;
		x%=y;
	}
	return ret*1.0/sum;
}

bool judge(ll x){
	ll a=1;
	while(a<=x){
		if(cal(x+a)<cal(x))return false;
		a=(a<<1)+(a<<3);
	}
	return true;
}

ll k,now;


int main(){
	//File();
	cin>>k;
	while(k--){
		ll a=1;
		while(true){
			if(judge(now+a)){
				now+=a;
				break;
			}
			a=(a<<1)+(a<<3);
		}
		cout<<now<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
import sys
readline = sys.stdin.readline
write = sys.stdout.write
def cross3(O, A, B):
    ox, oy = O; ax, ay = A; bx, by = B
    return (ax - ox) * (by - oy) - (bx - ox) * (ay - oy)
def cross_point(p0, p1, q0, q1):
    x0, y0 = p0; x1, y1 = p1
    x2, y2 = q0; x3, y3 = q1
    dx0 = x1 - x0; dy0 = y1 - y0
    dx1 = x3 - x2; dy1 = y3 - y2
    s = (y0-y2)*dx1 - (x0-x2)*dy1
    sm = dx0*dy1 - dy0*dx1
    if -EPS < sm < EPS:
        return None
    return x0 + s*dx0/sm, y0 + s*dy0/sm
EPS = 1e-9
def convex_cut(P, line):
    q0, q1 = line
    N = len(P)
    Q = []
    for i in range(N):
        p0 = P[i-1]; p1 = P[i]
        cv0 = cross3(q0, q1, p0)
        cv1 = cross3(q0, q1, p1)
        if cv0 * cv1 < EPS:
            v = cross_point(q0, q1, p0, p1)
            if v is not None:
                Q.append(v)
        if cv1 > -EPS:
            Q.append(p1)
    return Q
def polygon_area(P):
    s = 0
    N = len(P)
    for i in range(N):
        p0 = P[i-1]; p1 = P[i]
        s += p0[0]*p1[1] - p0[1]*p1[0]
    return abs(s) / 2

def solve():
    N, M = map(int, input().split())
    if N == M == 0:
        return False
    P = [list(map(int, readline().split())) for i in range(N)]
    Q = [list(map(int, readline().split())) for i in range(M)]
    for i in range(M):
        x0, y0 = Q[i]
        P0 = P
        for j in range(M):
            if i == j:
                continue
            x1, y1 = Q[j]
            ax = (x0 + x1) / 2; ay = (y0 + y1) / 2
            q0 = (ax, ay)
            q1 = (ax - (y1 - y0), ay + (x1 - x0))
            P0 = convex_cut(P0, (q0, q1))
        write("%.16f\n" % polygon_area(P0))
    return True
while solve():
    ...



Measured memory_bytes: 5648
def main():
    n = int(input())
    ab = [] # type:[[int]] 
    for i in range(n):
        ab.append([int(x) for x in input().split()])
    a, b = max(ab, key=lambda x: x[0])
    print(a + b)


if __name__ == "__main__":
    main()

Measured memory_bytes: 21172
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    string s;
    cin >> s;
    ll ans = 700;
    F0R(i,s.length()) if(s[i] == 'o') ans +=100;
    cout << ans << endl;

    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 256
n, m = map(int, input().split())
a = [input().split() for i in range(m)]

solved = [False] * n
ac_cnt = 0
wa_l = [0] * n

for i in range(m):
    cn, cj = int(a[i][0]) - 1, a[i][1]
    if not solved[cn]:
        if cj == 'WA':
            wa_l[cn] += 1
        else:
            ac_cnt += 1
            solved[cn] = True
wa_cnt = 0
for i in range(n):
    wa_cnt += solved[i] * wa_l[i]
print(ac_cnt, wa_cnt)


Measured memory_bytes: 39740
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
//container util
//------------------------------------------
#define SIZEOF(x) sizeof(x)/sizeof(x[0])
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;


template <class T>
T max(T *a , LL n){
    T maxi = a[0];
    for(LL i = 0; i < n; ++i){
        if(a[i] > maxi)maxi = a[i];
    }
    return maxi;
}
template <class T>
T min(T *a , LL n){
    T mini = a[0];
    for(LL i = 0; i < n; ++i){
        if(a[i] < mini)mini = a[i];
    }
    return mini;
}
template <class T>
T sum(T *a , LL n){
    T s=0;
    for(LL i = 0; i < n; ++i){
       s+=a[i]; 
    }
    return s;
}

#define MAX(x) max(x,SIZEOF(x))
#define MIN(x) min(x,SIZEOF(x))
#define SUM(x) sum(x,SIZEOF(x))





int main(){
    LL n;

    cin >> n;
    long long  w[n];
    REP(i,n){
        cin >> w[i];
    }
    long long j = SUM(w);
    long long sum = 0;
    long long  frag = 0;
    long long f = 0;
    REP(i,n){
        sum += w[i];
        
        

        if(sum > j/2){
            f=i;
            break;
        }
    }
    LL k = 0;
    LL l = 0;
    FOR(i,0,f+1){
        k+=w[i];
    }
    FOR(i,f+1,n){
        k-=w[i];
    }

    FOR(i,0,f){
        l+=w[i];
    }
    FOR(i,f,n){
        l-=w[i];
    }

    if(k<0)k*=-1;
    if(l<0)l*=-1;
    

    LL o[2]={k,l};
    cout<< MIN(o);







    return 0;

}


Measured memory_bytes: 256
while True:
    a=input()
    b=a.split()
    n=int(b[0])
    x=int(b[1])
    if n==0 and x==0:
        break
    count=0
    for i in range(1,n+1):
        for j in range(1,n+1):
            for k in range(1,n+1):
                if i>=j or j>=k or i>=k:
                    pass
                elif i+j+k==x:
                    count+=1
    print(count)
                



Measured memory_bytes: 5596
use proconio::input;

fn main() {
    input! {
        k: usize,
        x: usize,
    }

    solve(k, x);
}

fn solve(k: usize, x: usize) {
    match (500 * k).cmp(&x) {
        std::cmp::Ordering::Less => println!("No"),
        _ => println!("Yes"),
    }
}


Measured memory_bytes: 2116
#include <iostream>
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<ll>> vvll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
struct io
{
    io()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

signed main(void)
{   ll sum = 0;
    ll n;
    cin >> n;
    for (ll i = 1; i < n; i++)
    {
        
        sum = sum + i;
    }
    cout << sum ;
}


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

using namespace std;

int main() {
    using ll = long long;
    
    ll x, y, z, k;
    cin >> x >> y >> z >> k;
    
    vector<ll> a(x), b(y), c(z);
    
    for (int i = 0; i < x; i++) {
        cin >> a[i];
    }
    
    for (int i = 0; i < y; i++) {
        cin >> b[i];
    }
    
    for (int i = 0; i < z; i++) {
        cin >> c[i];
    }
    
    sort(a.rbegin(), a.rend());
    
    vector<ll> bc;
    bc.reserve(y * z);
    
    for (int i = 0; i < y; i++) {
        for (int j = 0; j < z; j++) {
            bc.push_back(b[i] + c[j]);       
        }
    }
    
    sort(bc.rbegin(), bc.rend());
    
    vector<ll> d;
    
    for (int i = 0; i < x; i++) {
        for (int j = 0; j < min(k, (ll)bc.size()); j++) {
            d.push_back(a[i] + bc[j]);   
        }
    }
    
    sort(d.rbegin(), d.rend());
    
    for (int i = 0; i < k; i++) {
        cout << d[i] << endl;
    }
}

Measured memory_bytes: 42984
/// Bismillahir Rahmanir Rahim
/* Mohammad Morsalin
   Dept of ICE, NSTU
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long
#define pb push_back
#define mp make_pair
#define endl "\n"
#define int long long
#define f0(n) for(int i=0;i<n;i++)
#define ms(x) memset(x,0,sizeof(x))
#define ms2d(x,m,n) memset(x, 0, sizeof(x[0][0]) * m * n)
#define uniq(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define pi pair<int,int>
#define tc(t) int t;cin>>t;while(t--)
#define bits(n) __builtin_popcount(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define ins insert
#define ALL(v) v.begin(),v.end()
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define fi first
#define se second
#define PI acos(-1)
#define sz(a) (int)a.size();
#define IOS ios::sync_with_stdio(false);
using namespace std;
int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a);}
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const long long MOD = 1000000007;
double sq(double x) {return x*x;}
template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}

bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}
signed main()
{
    IOS
    int n;
    cin>>n;
    int arr[n];
    int pre[n+1];
    ms(pre);
    for(int i=0;i<n;i++){
        cin>>arr[i];
        pre[i+1]=(pre[i]%MOD+arr[i]%MOD)%MOD;
        pre[i+1]%=MOD;
    }
    int ans=0;
    for(int i=0;i<n;i++){
        ans+=(((pre[n]-pre[i+1])%MOD)*(arr[i]%MOD))%MOD;
        ans%=MOD;
        //cout << ans << endl;
    }
    if(ans<0){
        ans+=MOD;
    }
    ans%=MOD;
    cout << ans << endl;
    return 0;
}
///Alhamdulillah


Measured memory_bytes: 6768
#include <bits/stdc++.h>
#define MOD 1000000007
#define NMAX 300005
#define INF 0x3f3f3f3f
#define pb push_back

using namespace std;

int bad[10];

int main() {
	int n,k,i,x;

	cin>>n>>k;
	for(i=1;i<=k;++i) {
		cin>>x;
		bad[x]=1;
	}

	for(i=n;;++i) {
		x = i;

		bool ok=1;
		while(x) {
			if(bad[x%10]) {
				ok = 0;
				break;
			}
			x/=10;
		}

		if(ok) {
			cout << i;
			break;
		}
	}

	return 0;
}



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

#define ll long long
ll num_mul(ll l,ll r,ll k)
{
	ll m1=(l-1)/k;
	ll m2=r/k;
	return m2-m1;
}

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

int main()
{
	long long l,r,m,n;
	cin>>l>>r>>m>>n;
	long long count =r-l+1;
	ll lcd;
	lcd= m*n/gcd(m,n);
	ll k1=num_mul(l,r,m);
	ll k2=num_mul(l,r,n);
	ll k3=num_mul(l,r,lcd);
	//cout<<k1<<k2<<k3<<" ";
	cout<<(count-(k1+k2))+k3 ;
	}



Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstring>

#define REP(i,x) for(int i=0 ; i<(int)(x) ; i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long

using namespace std;

int N, K;
vector<vector<int> > graph;
vector<pair<int,int> > edges;

// return num of delete nodes
int dfs(int v,int prev, int sum){
    int res = 0;
    REP(i, graph[v].size()){
        int u = graph[v][i];
        if(u==prev)continue;
        res += dfs(u, v, sum+1);
    }
    if(sum>K/2)res++;
    return res;
}


int main(){
    cin >> N >> K;
    graph.assign(N, vector<int>());
    edges.clear();
    REP(i, N-1){
        int A, B;
        cin >> A >> B;
        A--;
        B--;
        edges.push_back(make_pair(A, B));
        graph[A].push_back(B);
        graph[B].push_back(A);
    }
    int res = N;
    if(K%2==0){
        REP(i,N){
            res = min(res, dfs(i, -1, 0));
        }
    }else{
        K--;
        REP(i,N-1){
            int a = edges[i].first;
            int b = edges[i].second;
            res = min(res, dfs(a, b, 0) + dfs(b, a, 0));
        }
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 512
//============================================================================
// Name        : AOJ.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;

int main() {
	int a,b;
	cin>>a>>b;
	int X,Y;
	X=a*b;
	Y=2*a+2*b;
	cout << X << " " << Y << endl; // prints !!!Hello World!!!
	return 0;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
#define INF 1e9+7
typedef long long int ll;
const int maxn = 1000000;
ll mod = INF;


int main(){
    int a[100];
    int n;
    int cnt=0;
    cin >> n;
    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++){
            for(int k=j+1;k<n;k++){
                if(abs(a[i]-a[j])<a[k]&&a[k]<a[i]+a[j]){
                    if(a[i]!=a[j]&&a[j]!=a[k]&&a[k]!=a[i]){
                        cnt++;
                    }
                }
            }
        }
    }

    cout << cnt<<endl;

    return 0;
}

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

bool dp[1000][3][30000], done[1000][3][30000];
string S;

int solve(int num, int pos, int indx)
{
    if(pos < 0)
        return 1;
    
    if(indx < 0)
        return 0;

    if(done[num][pos][indx])
        return dp[num][pos][indx];
    
    int ans = 0;
    done[num][pos][indx] = 1;

    ans = solve(num, pos, indx-1);

    if(num % 10 == S[indx] - '0')
        ans |= solve(num / 10, pos-1, indx-1);

    return dp[num][pos][indx] = ans;
}

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

    int N;
    cin >> N >> S;

    int ans = 0;

    for(int i=0; i<1000; i++)
        ans += solve(i, 2, N-1);
    
    cout << ans << "\n";
    return 0;
}


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

int main() {
	string S;
	cin >> S;
	int length = S.length();
	int i[2] = {0, 0};
	int s = 0, e = 0;
	for (int l = 0; l < length; l++) {
		if (S[l] == 'L' && (l + 1 == length || S[l + 1] == 'R')) {
			e = l;
			int a = 0;
			for (int p = s; p <= e; p++) {
				i[p & 1]++;
				if (S[p] == 'R' && S[p + 1] == 'L') a = p;
			}
			for (int p = s; p <= e; p++) {
				if (p == a) cout << i[p & 1] << " ";
				else if (p == a + 1) cout << i[p & 1] << " ";
				else cout << "0 ";
			}
			i[0] = 0;
			i[1] = 0;
			s = l + 1;
		}
	}
}

Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main()
{
    int N;
    int a;
    int ans = 0;

    cin >> N;
    for (int i = 0; i < N; i++)
    {
        cin >> a;
        ans += a - 1;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for( int i = 0 ; i < n ; i++ )
typedef long long ll ;
ll gcd (ll a , ll b ){ return b ? gcd(b,a%b) : a; }
vector<ll> divisor(ll n){
vector<ll> ret;
for (ll i = 1 ; i*i <= n ; i++){
if(n%i == 0 ){
ret.push_back(i);
if(i!=1&&i*i!=n){
ret.push_back(n/i);
}
}
}
sort(ret.begin(),ret.end());
return ret;
}

int main() {
  int N , M , k ;
  cin >> N >> M >> k  ;
    int E = max(N,M)  ;
    int F = min(N,M)  ;
    int  A = gcd(E,F) ;
    //cout << A << endl << endl ;
    vector<ll> B =  divisor(A)  ;
    int C = B.size() ;
    vector<int> D(C+1);
    D.at(C) = A  ;
    rep(i,C) D.at(i) = B.at(i)  ;
    //rep(i,C+1) cout << D.at(i) << endl ;
    cout  << D.at(C+1-k) << endl ;
}
  

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

int main(void){
    string S;
    cin >> S;
    string T;
    cin >> T;
    int day{0};
    for(int i=0;i<3;++i){
        if(S[i]==T[i]){
            ++day;
        }
    }
    cout << day << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
#define ld long double
#define pb push_back
#define vl vector
#define ff first
#define ss second
using namespace std;
int main()
{
    ll a,b,i,j,n,t,c,m;
    cin>>n>>m;
    ll arr[n];
    for(i=0;i<n;i++) cin>>arr[i];
    sort(arr,arr+n);
    vl<pair<ll,ll>> p;
    for(i=0;i<m;i++)
    {
        cin>>a>>b;
        p.pb({b,a});
    }
    sort(p.rbegin(),p.rend());
    j=0;
    ll flag=0;
    for(i=0;i<m;i++)
    {
        a=p[i].ss;
        b=p[i].ff;
        while(a-- && j<n)
        {
            if(arr[j]<b) arr[j]=b;
            else
            {
                flag=1;
                break;
            }
            j++;
        }
        if(flag==1 || j>=n) break;
    }
    ll sum=0;
    //for(i=0;i<n;i++) cout<<arr[i]<<" ";cout<<endl;
    for(i=0;i<n;i++) sum+=arr[i];
    cout<<sum;
}

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

void print(char m,vector<bool>&v){
	for(int i=1;i<v.size();++i){
		if(!v.at(i))cout<<m<<" "s<<i<<"\n"s;
	}
}

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	vector<bool>s(14),h(14),c(14),d(14);
	for(int i=0;i<n;++i){
		char m; int g; cin>>m>>g;
		if(m=='S')s.at(g)=true;
		else if(m=='H')h.at(g)=true;
		else if(m=='C')c.at(g)=true;
		else d.at(g)=true;
	}
	print('S',s);
	print('H',h);
	print('C',c);
	print('D',d);
}


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

int main() {
	int n,m;
  	cin>>n>>m;
  	
  	vector<int> cnt(m,0);
  	
     
    for (int i = 0; i < n; i++) {
      	int k;cin>>k;
    for (int j = 0; j < k; j++) {
      int a; cin>>a; --a;
      ++cnt[a];
    }
  }
  
  int ans=0;
  for(int i=0;i<m;i++){
  	if(cnt[i]==n){
    	ans++;
    }
  }
  
  cout<<ans<<endl;
  
  
}

Measured memory_bytes: 3604
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2000000000;//10^9
ll MOD  = 1000000007;

int main(void){
    int N;
    cin >> N;
    for(int i = 1; i < 10; i++){
        if(N <= 111 * i){
            cout << 111 * i << endl;
            break;
        }
    }
}


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

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto A = RD;
	auto B = RD;
	auto K = RD;
	bool[long] ans;
	foreach (i; A..min(A+K, B+1))
		ans[i] = true;
	foreach (i; max(B+1-K, A)..B+1)
		ans[i] = true;

	foreach (key; ans.keys.sort())
		writeln(key);
	stdout.flush();
	debug readln();
}


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

#define fo(i,s,t) for(int i = s; i <= t; ++ i)
#define fd(i,s,t) for(int i = s; i >= t; -- i)
#define bf(i,s) for(int i = head[s]; i; i = e[i].next)
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pb push_back
#define VI vector<int>
#define sf scanf
#define pf printf
#define fp freopen
#define SZ(x) ((int)(x).size())
// #define MPS
typedef long long ll;
typedef double db;
typedef unsigned long long ull;
const int inf = 1<<30;
const ll INF = 1ll<<60;
const db Inf = 1e20;
const db eps = 1e-9;

void gmax(int &a,int b){a = (a > b ? a : b);}
void gmin(int &a,int b){a = (a < b ? a : b);}

const int maxn = 4000050;
const int maxm = 2005;
const int P = 1e9+7;

int n, k, dp[maxm][maxm], fac[maxn], infr[maxn];

ll comb(int n,int m) {return 1ll*fac[n]*infr[m]%P*infr[n-m]%P;}
int qpow(int a,int b) {int ans = 1; while(b) {if(b&1) ans = (ans*1ll*a)%P; b >>= 1; a = (a*1ll*a)%P;} return ans;}
int main()
{
	#ifdef MPS
		fp("agc02f.in","r",stdin);
		fp("agc02f.out","w",stdout);
	#endif
	sf("%d%d",&n,&k);
	fac[0] = 1; fo(i,1,n*k) fac[i] = (fac[i-1]*1ll*i)%P;
	infr[n*k] = qpow(fac[n*k],P-2);
	fd(i,n*k-1,0) infr[i] = infr[i+1]*1ll*(i+1)%P;
	if(k == 1) return 0*pf("1\n");
	dp[0][0] = 1;
	fo(i,0,n) fo(j,0,n)
	{
		if(i < j) dp[i+1][j] = (dp[i+1][j] + dp[i][j])%P;
		if(j < n) dp[i][j+1] = (dp[i][j+1] + (dp[i][j] * comb(j*(k-1)+k+i-2,k-2))%P)%P;
	}
	pf("%lld\n",(1ll*dp[n][n]*fac[n])%P);
	return 0;
}


Measured memory_bytes: 47104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MN = 500500;
ll v[MN],mex[MN],w[MN];
bitset<MN> bs;
int main() {
	ios::sync_with_stdio(0);cout.tie(0);cin.tie(0);
	ll n,d;
	cin >> n >> d;
	for(int i=0;i<n;i++) {
		cin >> v[i];
	}
	mex[n] = 1;
	for(int i=n-1;i>=0;i--) {
		ll val = mex[i+1];
		if(abs(val-v[i]) < val) {
			val += v[i];
		}
		mex[i] = val;
	}
	w[0] = d;
	for(int i=0;i<n;i++) {
		w[i+1] = min(w[i],abs(w[i]-v[i]));
		if(w[i] >= mex[i+1]) {
			bs.set(i);
		}
	}
	int q;
	cin >> q;
	while(q--) {
		int a;
		cin >> a;a--;
		cout << (bs[a]?"YES":"NO") << '\n';
	}
}

Measured memory_bytes: 13696
# https://atcoder.jp/contests/abc150/tasks/abc150_b

read n ; n=$((n))
read S
l=${#S}
ans=$((0))
for ((i = 0; i < l; i++)) ; do
  str=${S:i:3}
  if [ $str = "ABC" ] ; then
    ans=$((ans + 1))
  fi
done
echo $ans


Measured memory_bytes: 376
#include <iostream>

using namespace std;

int main(){

    int s;
    cin >> s;

    int begin = s / 100;
    int end = s % 100;

    if (begin <= 12 && 1 <= begin){
        if (end <= 12 && 1 <= end){
            cout << "AMBIGUOUS" << endl;
        }else{
            cout << "MMYY" << endl;
        }
    }else{
        if (end <= 12 && 1 <= end){
            cout << "YYMM" << endl;
        }else{
            cout << "NA" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256
// c++include
#include <iostream>
// cinclude
#include <stdio.h>
#include<string.h>
#include<math.h>
//c++標準ライブラリ
#include<vector>
#include<string>
//std使用<-namespace
using namespace std;

// define, typedef
#define rpt(i, n) for(i = 0; i < (n); i++)
typedef long long ll;

// main関数
int main(void) {
	ll n;
	cin >> n;
	ll ans;
	ans = n * (n - 1) / 2;
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
  ll n, a, b;
  cin >> n >> a >> b;
  if (abs(a - b) % 2 == 0)
    cout << abs(a - b) / 2 << endl;
  else
    cout << min((a + b - 1) / 2, (2 * n - a - b + 1) / 2) << endl;
  return 0;
}

Measured memory_bytes: 3608
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;


int n, t, a;
double h[1000];
double tmp = inf;
int ans;

int main(){
	
	cin >> n >> t >> a;
	rep(i, n)cin >> h[i];

	rep(i, n){
		if (tmp > abs(a - (t - h[i] * 0.006))){
			ans = i + 1;
			tmp = abs(a - (t - h[i] * 0.006));
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
import sys
input=sys.stdin.readline
mod=10**9+7

n=int(input())
e=[[] for i in range(n)]
dp=[[0,0] for i in range(n)]
for i in range(n-1):
    a,b=[int(j)-1 for j in input().split()]
    e[a].append(b)
    e[b].append(a)

par=[-1]*(n)
l=[]
from collections import deque
q=deque([0])
while q:
    p=q.pop()
    l.append(p)
    for i in e[p]:
        if i==par[p]:
            continue
        par[i]=p
        q.append(i)

dpw=[1]*(n+1)
dpb=[1]*(n+1)

for i in l[::-1]:
    w=dpw[i]
    b=dpb[i]
    p=par[i]
    dpw[p]*=(b+w)
    dpw[p]%=mod
    dpb[p]*=w
    dpb[p]%=mod

print((dpw[0]+dpb[0])%mod)


Measured memory_bytes: 42120
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <utility>
#include <vector>

int main()
{
  	int n;
  	std::cin >> n;
  	int ac=0,wa=0,tle=0,re=0;
  	for(int i=0;i<n;i++){
      	std::string str;
      	std::cin >> str;
      	if(str=="AC")
          	ac++;
      	if(str=="WA")
          	wa++;
      	if(str=="TLE")
          	tle++;
      	if(str=="RE")
          	re++;
    }
  	std::cout << "AC x " << ac << "\n";
  	std::cout << "WA x " << wa << "\n";
  	std::cout << "TLE x " << tle << "\n";
  	std::cout << "RE x " << re << "\n";
    return 0;
}


Measured memory_bytes: 3224
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define pii pair<int, int>
#define ff first
#define ss second
#define PI acos(-1)
#define ld long double
//mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());
const int mod = 1e9+7, N = 2e5+5;

int a[N], n, m, k;

void solve(int test_case){
	int cnt = 0, i, j, d;
	cin >> n >> d;
	d *= d;
	for(i=0;i<n;i++){
		int p ,q;
		cin >> p >> q;
		int temp = (p*p+q*q);
		if(temp <= d)cnt++;
	}cout << cnt << '\n';
	return;
}

signed main(){
	FASTIO;
#define MULTITEST 0
#if MULTITEST
	int ___T;
	cin >> ___T;
	for(int T_CASE = 1; T_CASE <= ___T; T_CASE++)
		solve(T_CASE);
#else
	solve(1);
#endif
	return 0;
}



Measured memory_bytes: 3640