akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")   //Comment optimisations for interactive problems (use endl)
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>

using namespace std;

#define  fastio         ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
#define  randomINIT     mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define  all(x)         (x).begin(),(x).end()
#define  mset(x,val)    memset(x,val,sizeof(x))
#define  endl           "\n"
#define  pb             push_back
#define  sym(s)         s="#"+s+"#";
#define  mp             make_pair
#define  s              second
#define  f              first
#define  dline          cerr<<"///REACHED///\n";
#define  debv(a)        for(auto it: a)cout<<it<<" ";cout<<endl;
#define  deb1(a)        cout<<a<<endl;
#define  deb2(a,b)      cout<<a<<" "<<b<<endl;
#define  deb3(a,b,c)    cout<<a<<" "<<b<<" "<<c<<endl;
#define  deb4(a,b,c,d)  cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;
#define  uniq(a)        a.resize(unique(a.begin(), a.end()) - a.begin());

typedef  long long             ll;
typedef  unsigned long long    ull;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  vector<pll>           vpll;

const ll   MOD   =  1e+9+7;
const ll   INF   =  0x7f7f7f7f7f7f7f7f;
const int  INFi  =  0x7f7f7f7f;
const ll   N  =  3e+5+7;

vll adj[N];ll vis[N]={};
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1};
int dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};

//<<-----Declare Variable Here------->>//
int t=1;
ll n;
vpll v;
//<<-----Implement Functions Here---->>//


//<<-----Start of Main--------------->>//
void MAIN(){
		cin>>n;
		for(ll i=1;i<=n;i++)
		{
			ll x,y;cin>>x>>y;v.pb({x,y});
		}
		for(ll i=0;i<=n-3;i++)
		{
			if(v[i].f==v[i].s&&v[i+1].f==v[i+1].s&&v[i+2].s==v[i+2].f){
				cout<<"Yes"<<endl;return;
			}
		}
		cout<<"No"<<endl;
}

int main(){
    fastio;randomINIT;

    //cin>>t;
    while(t--){
        MAIN();
    }

    #ifndef ONLINE_JUDGE
    cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
    #endif
}

Measured memory_bytes: 10688
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
      	int n = sc.nextInt();
      	String s = sc.next();
        String t = sc.next();
      
        String a[] = s.split("");
        String b[] = t.split("");
        String ans = "";
        for(int i = 0;i < n;i++){
          ans += a[i] + b[i];
        }
      
        
        System.out.println(ans);
      
    }
}

Measured memory_bytes: 39360
#include<stdio.h>
int main(){
    int x;
    int value = 0;
    
    scanf("%d",&x);
    while(1){
        if(x < 500) break;
        value += 1000;
        x -= 500;
    }
    while(1){
        if(x < 5) break;
        value += 5;
        x -= 5;
    }
    printf("%d\n",value);
    return 0;
}


Measured memory_bytes: 128
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  auto rd = readln.split.to!(int[]), n = rd[0], a = rd[1];
  auto x = readln.split.to!(int[]), xs = x.sum;

  auto dp = new long[][][](n+1, n+1, xs+1);
  dp[0][0][0] = 1;

  foreach (i; 0..n)
    foreach (j; 0..n+1)
      foreach (k; 0..xs+1) {
        dp[i+1][j][k] = dp[i][j][k];
        if (j >= 1 && k >= x[i])
          dp[i+1][j][k] += dp[i][j-1][k-x[i]];
      }

  auto ans = 0L;
  foreach (i; 1..n+1) {
    if (i*a > xs) break;
    ans += dp[n][i][i*a];
  }

  writeln(ans);
}


Measured memory_bytes: 54396
n,m=map(int,input().split())
u=[]
v=[]
g=[[] for _ in range(n)]

for i in range(m):
    uu,vv=map(int,input().split())
    u.append(uu)
    v.append(vv)
    g[uu-1].append(vv-1)
    
s,t=map(int,input().split())
s-=1
t-=1

from collections import deque
 
def bfs(u):
    queue1 = deque([u])
    queue2 = deque([0])
    d=[]
    for i in range(n):
        d.append([-1]*3)
    d[u][0]=0
    while queue1:
        v=queue1.popleft()
        l=queue2.popleft()
        nl=(l+1)%3
        for i in g[v]:
            if d[i][nl] is -1:
                d[i][nl]=d[v][l]+1
                queue1.append(i)
                queue2.append(nl)
    return d

d=bfs(s)

ans=int(d[t][0]/3)
if d[t][0]==-1:
    ans=-1
print(ans)

Measured memory_bytes: 46004
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif


using namespace std;

// #define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

const int MOD = 1e9 + 7;
const int INF = INT_MAX;

signed main() {
    Fast();

    int a, b;
    cin >> a >> b;
    cout << ((a * b) % 2 == 0 ? "Even" : "Odd") << endl;

    return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;
int main()
{
	long long a, b;
	while (cin >> a >> b)
	{
		int A, B; 
		int n = a, m = b;
		int q = a, w = b;
		
//			int n = , m = M;
		while (true)
		{
			if (q == 0) { cout << w << " "; break; }
			if (w == 0) { cout << q << " ";  break; }
			if (w > q) { w -= q; }
			else { q -= w; }
		}
		int s = 1;
		while (true)
		{
			if ((s*n) % m == 0)
			{
				break;
			}
			else { s++; }
		}
		//cout << s*n << " ";

		B = n*s;
		cout<< B<<endl;
	}
	return 0;

}

Measured memory_bytes: 3068
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const long double PI = (acos(-1));
#define rep(i, x, n) for (int i = x; i < (int)(n); i++)
#define sc(x) scanf("%d",&x)
#define scll(x) scanf("%lld",&x)

ll mpow(ll a, ll n){
    ll res = 1;
    while (n > 0){
        if (n & 1) res = res * a;
        a = a * a;
        n >>= 1;
    }
    return res;
}

int main(){
    int x; sc(x);
    bool check = false;
    vector<ll> v1, v2;
    ll now = 0, tmp, a, b, tmp1, tmp2;
    while(1){
        tmp = mpow(now, 5);
        if (now == 1000) break;
        v1.push_back(tmp);
        v2.push_back(now);
        now++;
    }
    rep(i, 0, v1.size()){
        a = v1[i];
        tmp1 = a + x;
        tmp2 = x - a;
        auto it1 = lower_bound(v1.begin(), v1.end(), tmp1);
        auto it2 = lower_bound(v1.begin(), v1.end(), tmp2);
        if (*it1 - a == x){
            cout << v2[it1-v1.begin()] << " " << v2[i] << endl;
            break;
        }
        if (*it2 + a == x){
            cout << v2[it2-v1.begin()] << " " << -v2[i] << endl;
            break;
        }
    }
    return 0;
}

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

using namespace std;

int main(void) {
    int n;
    cin >> n;
    vector<int> a(n);
    for (auto &_a: a) cin >> _a;

    int cnt_four = 0, cnt_two = 0, cnt_odd = 0;
    for (auto ea : a) {
        if (ea % 4 == 0) cnt_four++;
        else if (ea % 2 == 0) cnt_two++;
        else if (ea % 2 == 1) cnt_odd++;
    }

    bool ok = cnt_four >= n / 2 ||
              max(cnt_odd - cnt_four, 0) == 0;

    cout << (ok ? "Yes" : "No") << endl;
}

Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;

class Process {
	String name;
	int time;
	
	Process(String name, int time) {
		this.name = name;
		this.time = time;
	}
}

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		// BufferedReader br = new BufferedReader(new FileReader("in1.txt"));
		String[] line1 = br.readLine().split(" ");
		int n = Integer.parseInt(line1[0]), q = Integer.parseInt(line1[1]);
		Deque<Process> que = new ArrayDeque<Process>();
		for (int i = 0; i < n; i++) {
			String[] line = br.readLine().split(" ");
			que.addLast(new Process(line[0], Integer.parseInt(line[1])));
		}
		
		StringBuilder sb = new StringBuilder();
		int timeStamp = 0;
		while (!que.isEmpty()) {
			Process p = que.removeFirst();
			if (p.time <= q) {
				timeStamp += p.time;
				sb.append(p.name);
				sb.append(' ');
				sb.append(timeStamp);
				sb.append('\n');
			} else {
				timeStamp += q;
				p.time -= q;
				que.addLast(p);
			}
		}
		
		System.out.print(sb.toString());
	}
}

Measured memory_bytes: 60156
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
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;}

int main() {
    ll x,y,z,k;
    cin >> x >> y >> z >> k;
    vector<ll>a(x),b(y),c(z);
    rep(i,x) {
        cin >> a[i];
    }
    rep(i,y) {
        cin >> b[i];
    }
    rep(i,z) {
        cin >> c[i];
    }
    sort(a.rbegin(),a.rend());
    sort(b.rbegin(),b.rend());
    vector<ll>e;
    rep(i,x) rep(j,y) {
        e.push_back(a[i]+b[j]);
    }
    sort(e.rbegin(),e.rend());
    
    
    vector<ll>ans;
    int n = min((ll)e.size(),k);
    //a+bの大きい方からk個とcの組み合わせを全探索し
    //その中から大きいものｋ個が答え
    rep(i,n) rep(j,z) {
        ans.push_back(e[i]+c[j]);
    }
    sort(ans.rbegin(),ans.rend());
    
    rep(i,k)cout << ans[i] << endl; 
}

Measured memory_bytes: 44104
#include <iostream>
#include <cmath>

using namespace std;
#define MAX 200000

unsigned int A[MAX];
int main(void){
  int N;
  cin >> N;
  unsigned int s = 0;
  for(int i=0;i<N;i++){
    unsigned int tmp;
    cin >> tmp;
    A[i] = tmp;
    s = s^A[i];
  }
  for(int i=0;i<N;i++){
    cout << (unsigned int)(s^A[i]) << endl;
  }
  return 0;
}

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

int main() {

  int n, k;
  cin >> n >> k;
  int num = 1, a = 1, b = 1;
  
  for(int i=0; i<n; i++){
    a = num * 2;
    b = num + k;
    if(a < b) num = a;
    else num = b;
  }
  cout << num << endl;
  
  return 0;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;
const int INF = INT_MAX;

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

	string T = "2019/04/30";
	if (S <= T) cout << "Heisei" << endl;
	else cout << "TBD" << endl;
}

Measured memory_bytes: 3380
#include <iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
	int n, a, b; cin >> n >> a >> b;
	string ans = "NG";
	for (int i=0;i<1000;i++)
		if ((a<=n*i)&&(n*i)<=b) { ans = "OK"; }
	cout << ans << endl;
}

Measured memory_bytes: 3548
def resolve():
    import sys
    input = sys.stdin.readline
    N, Q = [int(i) for i in input().split()]
    S = input()
    pre = [0 for _ in range(N)]
    for i in range(N - 1):
        pre[i + 1] = pre[i] + (1 if S[i:i + 2] == "AC" else 0)
    for _ in range(Q):
        l, r = [int(i) for i in input().split()]
        print(pre[r - 1] - pre[l - 1])


resolve()


Measured memory_bytes: 13304
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
using ll = long long int;

#define rep(i, n) for(ll i = 0; i < (n); i++)
int main() {
  ll n; cin >> n;
  vector<ll> as(n);
  rep(i, n) {
    cin >> as[i];
  }

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

  bool divisible[1000001] = {};

  ll cnt = 0;
  rep(i, n) {
    ll a = as[i];
    if (divisible[a]) {
      cnt++;
      continue;
    }

    if (i < n - 1) {
      if (as[i] == as[i+1]) {
        cnt++;
      }
    }

    for (ll x = a; x <= 1000000; x += a) {
      divisible[x] = true;
    }
  }

  cout << n - cnt << endl;
  return 0;
}

Measured memory_bytes: 5464
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
#define M 998244353
#define F first
#define S second
#define PB push_back
#define INF 1000000000
int q,par[100005];
ll n,k,m;
vector<P>u,s;
int find(int x){
	if(x==par[x])return x;
	return par[x]=find(par[x]);
}
bool same(int x,int y){
	x=find(x);
	y=find(y);
	return x==y;
}
void unit(int x,int y){
	x=find(x);
	y=find(y);
	par[x]=y;
}
int main(void){
	scanf("%lld%lld%d",&n,&m,&q);
	k=n;
	for(int i=0;i<n;i++)par[i]=i;
	for(int i=0;i<q;i++){
		int a,b,c;
		scanf("%d%d%d",&a,&b,&c);
		if(c==0)u.PB(P(a,b));
		else s.PB(P(a,b));
	}
	for(int i=0;i<u.size();i++){
		int a=u[i].F,b=u[i].S;
		if(!same(a,b)){
			k--;
			unit(a,b);
		}
	}
	if(s.size()>0&&m<n){
		printf("No\n");
		return 0;
	}
	for(int i=0;i<s.size();i++){
		int a=s[i].F,b=s[i].S;
		if(same(a,b)){
			printf("No\n");
			return 0;
		}
	}
	if(k*(k-1LL)/2LL+n-k>=m)printf("Yes\n");
	else printf("No\n");
}



Measured memory_bytes: 3316
#include<string>
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using ll = long long;
 
#define rep(i, n) for(ll i = 0; i < (int)(n); i++)
#define reps(i,x) for(ll i=1;i<=(int)(x);i++)
#define rrep(i,x) for(ll i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(ll i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define mp make_pair
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007 
using namespace std;
int a[200000];
int b[200000];

int main() {
  int n,m;
  cin >> n;
  map<string, int> fi;
  map<string, int> se;
  string tm;
  rep(i,n){
    cin >> tm;
    fi[tm]++;
  }
  cin >>m;
  rep(i,m){
    cin >> tm;
    se[tm]++;
  }
  int ans = 0;
  for(auto e: fi){
    ans = max(ans, fi[e.first] - se[e.first]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
void insertionSort(int *,int);
int main(){
  int n,*array,i;
  scanf("%d",&n);
  array = (int *)malloc(n * sizeof(int));
  for(i=0;i<n;i++){
    scanf("%d",&array[i]);
  }
  insertionSort(array,n);
  
  return 0;
}

void insertionSort(int *array,int n){
  int i,j,l,data;
  for(j=0;j<n;j++){
    printf("%d",array[j]);
    if(j != n-1){
      printf(" ");
    }
  }
  printf("\n");
  for(i=1;i<n;i++){
    data = array[i];
    j = i-1;
    while(j>=0 && array[j]>data){
      array[j+1] = array[j];
      j--;
    }
    array[j+1] = data;
    for(l=0;l<n;l++){
      printf("%d",array[l]);
      if(l != n-1){
	printf(" ");
      }
    }
      printf("\n");
  }
}



Measured memory_bytes: 2144
<?php
$n = trim(fgets(STDIN));
$max = 0; 
for($i = 1; $i < 33; $i++){
    for($j = 2; $j <=10; $j++){
        if(pow($i, $j) <= $n){
            $max = max($max, pow($i, $j));
        }else{
            break;
        }
    }
}
echo $max;


Measured memory_bytes: 4604
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int num;
		boolean ap = true;
		while(sc.hasNext()) {
			num = sc.nextInt();
			if(num%2!=0) continue;
			if(num%3!=0 && num%5!=0) {
				System.out.println("DENIED");
				ap = false;
				break;
			}
		}
		if(ap) System.out.println("APPROVED");
	}

}


Measured memory_bytes: 22736
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;


int main(void)
{
	char s[200000+2];

	while(scanf("%200000[1-9]\n", s)==1)
	{
		int l=strlen(s);

		vi u(l);
		u[0]=1;
		for(int i=1;i<l;i++)
		{
			u[i]=(u[i-1]*10)%2019;
		}

		ll ans=0;
		vi c(2019);
		for(int i=0;i<l;i++)
		{
			vi n(2019);
			int x=s[i]-'0';

			for(int j=0;j<2019;j++)
			{
				n[(j*10+x)%2019]+=c[j];
			}
			n[x]++;

			c.swap(n);
			ans+=c[0];
		}
		printf("%lld\n", ans);
	}
	return 0;
}


Measured memory_bytes: 3780
#include <iomanip>
#include <iostream>
#include <math.h>
using namespace std;
main()
{
    double r,area,circum;
    cin >> r;
    area = r*r*M_PI;
    circum = 2*r*M_PI;
    cout << fixed << setprecision(6)<< area << " " << circum << endl; 
    return 0;
}

Measured memory_bytes: 1288
#include <iostream>
#include <algorithm>
#include <stdlib.h>
#include <math.h>
using namespace std;
#define mod 1000000007

int main(void) {
	// your code goes here
	int n,d,x,a,i;
	cin >> n >> d >> x;
	for(i=1;i<=n;i++){
		cin >> a;
		x+=((d-1)-(d-1)%a)/a+1;
	}
	cout << x << endl;
	return 0;
}


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

typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)

int fac(int a){
    if (a==0){
        return 1;
    }
    else {
        return a*fac(a-1);
    }
}

int main() {
  int n;
  cin >> n;
  vector<pint> des(n);
  rep(i,n){
      cin >> des[i].first;
      cin >> des[i].second;
  }
  int cnt=n-1;
  double ans=0;
  cnt=fac(cnt);
  rep(i,n){
      for (int j=i+1; j < n; j++){
           ans+=sqrt((des[i].first-des[j].first)*
                     (des[i].first-des[j].first)
                     +(des[i].second-des[j].second)*
                     (des[i].second-des[j].second));
                     
        
        }
  }
  cout << fixed << setprecision(10) << ans*2/n << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ld long double
#define fio() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define MOD 1000000007
#define nl '\n'
#define pb push_back
#define mp make_pair

using namespace std;
const int N = 10;
int32_t main()
{
	fio();
	int n;
	cin>>n;
	int val[n];
	for(int i=0;i<n;i++)
		cin>>val[i];
	int dp[n];
	dp[0]=0;
	dp[1]=abs(val[1]-val[0]);
	for(int i=2;i<n;i++)
		dp[i]=min(dp[i-2]+abs(val[i]-val[i-2]),dp[i-1]+abs(val[i]-val[i-1]));
	cout<<dp[n-1];
}



Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int x[8000000][2], a[999], b[999], s, n;
int main() {
	a[0] = 1; b[0] = 1;
	for (int i = 1; i < 300; i++) {
		a[i] = a[i - 1] + (i + 1)*(i + 2) / 2;
		if (a[i] % 2 == 1) {
			s++; b[s] = a[i];
		}
	}
	n = 1200000;
	memset(x, 127, sizeof(x));
	x[0][0] = 0; x[0][1] = 0;
	for (int i = 0; i < 200; i++) {
		for (int j = 0; j < n; j++) {
			x[j + a[i]][0] = min(x[j + a[i]][0], x[j][0] + 1);
		}
	}
	for (int i = 0; i < 50; i++) {
		for (int j = 0; j < n; j++) {
			x[j + b[i]][1] = min(x[j + b[i]][1], x[j][1] + 1);
		}
	}
	while (true) {
		cin >> n; if (!n) { break; }
		cout << x[n][0] << ' ' << x[n][1] << endl;
	}
}

Measured memory_bytes: 63676
#include <iostream>
#include <vector>
#include <utility>
#include <tuple>
#include <map>
#include <algorithm>
using Int = long long;
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
int main()
{
    int N, M; cin >> N >> M;
    vector<int> C(N);
    REP(i, M) {
        int a, b;
        cin >> a >> b;
        C[a-1]++;
        C[b-1]++;
    }
    REP(i, N) cout << C[i] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unistd.h>
#define ll long long
#define inf 1000000007
#define inf16 0x3f3f3f3f
#define INF 1000000000000000007LL
#define VI vector<int>
#define VPII vector<pair<int, int> >
#define VLL vector<ll>
#define PII pair<int, int>
#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define endl '\n'
#define ALL(c) (c).begin(), (c).end()
using namespace std;

const int N = 57;

int n;

ll ans;

int a[N];
int b[N];

bitset<N> curr;

int dp[N][N];

bool check()
{
	for(int i = 0; i < N; ++i)
	{
		memset(dp[i], 0, sizeof dp[i]);
	}

	for(int i = 0; i <= 50; ++i)
	{
		dp[i][i] = 1;
	}

	for(int m = 1; m <= 50; ++m)
	{
		if(curr[m])
		{
			for(int i = 0; i <= 50; ++i)
			{
				for(int j = 0; j <= i; ++j)
				{
					if(dp[i%m][j])
						dp[i][j] = 1;
				}	
			}
		}
	}

	for(int i = 1; i <= n; ++i)
	{
		if(!dp[a[i]][b[i]])
			return 0;
	}

	return 1;
}

int32_t main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);

	cin >> n;

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

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

	for(int i = 1; i <= 50; ++i)
	{
		curr[i] = 1;
	}

	if(!check())
	{
		cout << -1;
		return 0;
	}

	for(int i = 50; i >= 1; --i)
	{
		curr[i] = 0;

		if(!check())
		{
			curr[i] = 1;
			ans += 1ll<<i;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
import math

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True
    
x = int(input())
while True:
    tf = is_prime(x)
    if tf:
        break
    else:
        x += 1
    
    
print(x)

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

int d[33];
int main()
{
int n,m,k,a,an=0;
cin>>n>>m;
for(int i=0;i<n;i++)
{cin>>k;
	while(k--)
	{cin>>a;d[a]++;}
}
for(int i=0;i<=m;i++)if(d[i]==n)an++;
cout<<an<<endl;

}



Measured memory_bytes: 3632
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <string>
#include <iterator>
#include <cmath>
#include <deque>
using namespace std;

int main()
{
    {
        if (fopen("input.txt", "r")) {
            freopen("input.txt", "r", stdin);
            freopen("output.txt", "w", stdout);
        }
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
    }
    int n;
    cin >> n;
    vector<long long> a(n);
    for (int i = 0; i != n; ++i)
        cin >> a[i];
    vector<long long> p(n + 1);
    long long sum = 0;
    for (int i = n - 1; i >= 0; --i) {
        sum += a[i];
        p[i] = sum;
    }
    long long ans = sum;
    long long l = 0;
    for (int i = 0; i != n; ++i) {
        l += a[i];
        ans = min(ans, abs(l - p[i + 1]));
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3328
#include <iostream>
using namespace std;
main () {
	string s, t;
  	bool salah = false;
  	cin>>s>>t;
  	int panjang1 = s.length();
  	int panjang2 = t.length();
  if (panjang1 + 1 == panjang2) {
	  	for (int i=0;i<panjang1;i++) {
		    if (s[i] != t[i]) {
		    	salah = true;
		    }
		}
	} else {
		salah = true;
	}
	
	if (salah) {
		cout<<"No"<<endl;
	} else {
		cout<<"Yes"<<endl;
	}
}

Measured memory_bytes: 3528
/*====Corycle====*/
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdlib>
#include<complex>
#include<cstdio>
#include<vector>
#include<cmath>
#include<ctime>
#include<stack>
#include<queue>
#include<map>
#define ll long long
#define pii pair<int,int>
#define fst first
#define scd second
#define mp make_pair
using namespace std;
const int inf=0x3f3f3f3f;
const int Maxn=(1<<19)+5;
const int N=2e5+5;
const int M=20;
int read(){
	int s=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){s=s*10+c-'0';c=getchar();}
	return s*f;
}
pii P[N];
int n,V,cnt,tot,Sta,a[N],L[M][N],R[M][N],Ans[N],FL[Maxn],FR[Maxn];
int main(){
//	freopen("_.in","r",stdin);
//	freopen("_.out","w",stdout);
	n=read();V=read();
	for(int i=1;i<=n;i++)a[i]=read();a[0]=-inf;a[n+1]=inf;
	for(int v=V;;v>>=1){
		tot++;L[tot][0]=0;R[tot][n+1]=n+1;
		for(int i=1;i<=n;i++)L[tot][i]=(a[i]-a[i-1]<=v?L[tot][i-1]:i);
		for(int i=n;i>=1;i--)R[tot][i]=(a[i+1]-a[i]<=v?R[tot][i+1]:i);
		if(v==0)break;
	}
	Sta=(1<<tot)-1;
	for(int i=1;i<=n;i++)P[i]=mp(L[1][i],R[1][i]);
	sort(P+1,P+n+1);cnt=unique(P+1,P+n+1)-P-1;
	for(int S=0;S<=Sta;S++){FL[S]=0;FR[S]=n+1;}
	for(int S=0;S<=Sta;S+=2){
		for(int i=1;i<=tot;i++){
			if(!((S>>(i-1))&1))continue;
			FL[S]=max(FL[S],R[i][FL[S^(1<<(i-1))]+1]);
			FR[S]=min(FR[S],L[i][FR[S^(1<<(i-1))]-1]);
		}
	}
	if(cnt>tot){for(int i=1;i<=tot;i++)puts("Impossible");return 0;}
	for(int i=1;i<=cnt;i++){
		for(int S=0;S<=Sta;S+=2){
			if(FL[S]>=P[i].fst-1&&FR[Sta^S^1]<=P[i].scd+1){
				for(int j=P[i].fst;j<=P[i].scd;j++)Ans[j]=1;
				break;
			}
		}
	}
	for(int i=1;i<=n;i++)puts(Ans[i]?"Possible":"Impossible");
	return 0;
}

Measured memory_bytes: 39592
#include<stdio.h>
int main(){
    int a;
    scanf("%d",&a);
    while(a--){
        int ax,bx,cx,dx,ex;
        int ay,by,cy,dy,ey;
        scanf("%d%d%d%d%d%d%d%d%d%d",&ax,&ay,&bx,&by,&cx,&cy,&dx,&dy,&ex,&ey);
        int count=0;
        int p=(dx-ax)*(by-ay)-(dy-ay)*(bx-ax);
        int q=(dx-bx)*(cy-by)-(dy-by)*(cx-bx);
        int r=(dx-cx)*(ay-cy)-(dy-cy)*(ax-cx);
        if(p>=0&&q>=0&&r>=0)count++;
        else if(p<=0&&q<=0&&r<=0)count++;
        p=(ex-ax)*(by-ay)-(ey-ay)*(bx-ax);
        q=(ex-bx)*(cy-by)-(ey-by)*(cx-bx);
        r=(ex-cx)*(ay-cy)-(ey-cy)*(ax-cx);
        if(p>=0&&q>=0&&r>=0)count++;
        else if(p<=0&&q<=0&&r<=0)count++;
        if(count==1)printf("OK\n");
        else printf("NG\n");
    }
}

Measured memory_bytes: 1012
#pragma region header
#include <bits/stdc++.h>
using namespace std;

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;
#pragma endregion

#pragma region const
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#pragma endregion

#pragma region util
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}
#pragma endregion

#pragma region init
struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

int main()
{
	i64 P, Q, R;
	cin >> P >> Q >> R;
	cout << min({ P + Q, Q + R, P + R }) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main(int argc, char const *argv[]) {
	int tmp;
	for(int i =0; i < 5; i++) {
		std::cin>>tmp;
		if (tmp  == 0) {
			std::cout << (i + 1) << std::endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 3588
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define ROF(i,b,a) for (int i=(b);i>(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,n-1,-1)

typedef long long int int64;
typedef unsigned long long int uint64;
typedef float float32;
typedef double float64;
typedef long double float128;


int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    string ans="No";
    if(abs(a-c)<=d){
        ans = "Yes";
    }else if(abs(b-a)<=d && abs(c-b)<=d){
        ans = "Yes";
    }
    cout << ans;
}




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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(auto i=0;i<(n);i++)
#define rep1(i,n) for(auto i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()

using namespace std;


struct init{ init(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20); }; }aaaaaaa;



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

  cout << (ll)pow(n, 3) << endl;


  return 0;
}


Measured memory_bytes: 256
from functools import reduce
mod=10**9+7

def f(A):
 dem=reduce(lambda x,y:x*y%mod,range(n,n-A,-1))
 num=reduce(lambda x,y:x*y%mod,range(1,A+1))
 return dem*pow(num,mod-2,mod)%mod

stdin=open(0)
n,a,b=map(int,stdin.read().split())
ans=pow(2,n,mod)-f(a)-f(b)-1
ans%=mod
print(ans)

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

int main(){
	int N;
	cin>>N;
	char S[N];
	int max_num=0;
	for(int i=0;i<N;i++)
		cin>>S[i];

	for(int i=1;i<N;i++){
		if(S[i]=='E')
			max_num=max_num+1;
	}

	int num=max_num;
	for(int i=0;i<N-1;i++){
		if((S[i]=='W') && (S[i+1]=='W'))
			num=num+1;
		if((S[i]=='E') && (S[i+1]=='E'))
			num=num-1;
		if(max_num>num)
			max_num=num;
	}
	cout<<max_num<<endl;
	return 0;
}

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

int main(){
	string week[7] = {"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"};
	int month[12] = {31,29,31,30,31,30,31,31,30,31,30,31};
	int m,d,cnt,mc;

	while( cin >> m >> d ){
		if(m==0) break;

		mc = 1;
		cnt = 3;
		while(1){
			for(int i=1 ; i <= month[mc-1] ; i++, cnt++){
				if(m==mc && d==i) break;
			}
			if(m==mc) break;
			mc++;
		}
		cout << week[cnt%7] << endl;
	}
	return 0;
}

Measured memory_bytes: 0
n=int(input())
C=input()
L=0
R=n-1
ans=0
while True:
    while L<n:
        if C[L]=="W":
            break
        else:
            L+=1
    while R>=0:
        if C[R]=="R":
            break
        else:
            R-=1
    if L<R:
        ans+=1
        L+=1
        R-=1
    else:
        break
print(ans)

Measured memory_bytes: 9476
# frozen_string_literal: true

def z_algorithm(s)
  n = s.size
  return [] if n == 0
 
  z = [0]
  j = 0
  1.upto(n-1){ |i|
    k = j+z[j] <= i ? 0 : j+z[j]-i < z[i-j] ? j+z[j]-i : z[i-j]
    k += 1 while i+k<n && s[k]==s[i+k]
    j = i if j+z[j] < i+k
    z << k
  }
  z[0] = n
  return z
end

s, t = $<.map &:chomp

ss = s+s
ss << s while ss.size < t.size*2
z = z_algorithm(t+ss)[t.size,s.size].map{ |z| z >= t.size }

vis = [false]*s.size

ans = (0 ... s.size).map{ |u|
  next if vis[u]
  vis[u] = true
  now = u
  cnt = 0
  while z[now]
    now = (now+t.size) % s.size
    vis[now] = true
    cnt += 1
    break if now == u
  end
  now==u && cnt.nonzero? ? 10**9 : cnt
}.compact.max

ans = -1 if ans >= 10**9
puts ans


Measured memory_bytes: 51988
using System;
using static System.Console;
using static System.Math;
 
public class Hello{
    public static void Main(){
        long read = rlong();
        if(read %2 == 0){
        read /= 10;
        long counter = read;
        while(read >= 5){
            read /= 5;
            counter += read;
        }
        WriteLine(counter);
        }else{
            WriteLine(0);
        }
    }
    //各種読取
    static string rstr(){
        return ReadLine();
    }
    static int rint(){
        return int.Parse(ReadLine());
    }
    static long rlong(){
        return long.Parse(ReadLine());
    }
    static string[] stra(){
        return ReadLine().Split(' ');
    }
    static int[] inta(){
        string[] read_str_array = ReadLine().Split(' ');
        int[] return_int_array = new int[read_str_array.Length];
        for(int countup_i=0;countup_i<read_str_array.Length;countup_i++){
            return_int_array[countup_i] = int.Parse(read_str_array[countup_i]);
        }
        return return_int_array;
    }
    static int[,] inta2(int num_array,int in_array){
        int[,] int_array2 = new int[num_array,in_array];
        for(int i=0;i<num_array;i++){
            int[] temp_array = inta();
            for(int j=0;j<in_array;j++){
                int_array2[i,j] = temp_array[j];
            }
        }
        return int_array2;
    }
    // A/B小数点以下切上
    static int divideup(int divided,int divid){
        int temp_divide = divided/divid;
        if(divided % divid > 0){
            temp_divide++;
        }
        return temp_divide;
    }
}


Measured memory_bytes: 13140
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll L[100010], R[100010];
    rep(i,0,N) cin >> L[i] >> R[i];
    vector<lpair> lp;
    rep(i,0,N) lp.push_back({L[i], R[i]});
    sort(lp.begin(), lp.end());
    ll ans = 0;
    ll group1[100010] = {}, group2[100010] = {};
    ll lv = lp[0].first, rv = lp[0].second;
    group1[0] = rv - lv + 1;
    ll lv_memo1[100010] = {}, rv_memo1[100010] = {};
    lv_memo1[0] = lv;
    rv_memo1[0] = rv;
    rep(i,1,N-1){
        lv = max(lv, lp[i].first);
        rv = min(rv, lp[i].second);
        if(lv <= rv){
            group1[i] = rv - lv + 1;
        }
        lv_memo1[i] = lv;
        rv_memo1[i] = rv;
    }
    lv = lp[N-1].first; rv = lp[N-1].second;
    group2[0] = rv - lv + 1;
    ll lv_memo2[100010] = {}, rv_memo2[100010] = {};
    lv_memo2[0] = lv;
    rv_memo2[0] = rv;
    rrep(i,N-2,1){
        lv = max(lv, lp[i].first);
        rv = min(rv, lp[i].second);
        if(lv <= rv){
            group2[N-1-i] = rv - lv + 1;
        }
        lv_memo2[N-1-i] = lv;
        rv_memo2[N-1-i] = rv; 
    }
    rep(i,0,N-1){
        ans = max(ans, group1[i] + group2[N-2-i]);
    }
    rep(i,1,N-1){
        ll v1 = lp[i].second - lp[i].first + 1;
        ll lv2 = max(lv_memo1[i-1], lv_memo2[N-2-i]);
        ll rv2 = min(rv_memo1[i-1], rv_memo2[N-2-i]);
        ll res = v1;
        if(lv2 <= rv2) res += rv2 - lv2 + 1;
        ans = max(ans, res);

    }
    print(ans);



    

}


Measured memory_bytes: 8176
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<queue>
#include<vector>
typedef long long int ll;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(int i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))
#define BIT(b, i) (((b) >> (i)) & 1)
#define LOG_F 1
#define LOG(...) if(LOG_F) fprintf(stderr, __VA_ARGS__)

using namespace std;

ll pow(int x, int n){
  return n == 0 ? 1 : x * pow(x, n - 1);
}

void Yn(bool f)
{
  cout << (f ? "Yes" : "No") << endl;
}

void yn(bool f)
{
  cout << (f ? "yes" : "no") << endl;
}

void YN(bool f)
{
  cout << (f ? "YES" : "NO") << endl;
}

int x, t;
int main()
{
  cin >> x>>t;
  cout << max(x-t,0) << endl;
  return 0;
}


Measured memory_bytes: 764
/*   LazyBones
*
*/

#include <bits/stdc++.h>
#include<cctype>
#include <sstream>
#include<ctime>
using namespace std;
#define rep(i,b) for(int i=0;i<b;i++)
#define getarr(a,n) for(int i=0;i<n;i++){cin>>a[i];}
#define disparr(a,n) for(int i=0;i<n;i++){cout<<a[i];}cout<<"\n";
#define disparrs(a,n) for(int i=0;i<n;i++){cout<<a[i]<<" ";}cout<<"\n";
#define disparrl(a,n) for(int i=0;i<n;i++){cout<<a[i]<<"\n";}cout<<"\n";
#define mem0(a) memset(a,0,sizeof(a));
#define ull unsigned long long int
#define ll long long int
#define ld long double
#define key pair<ld,ld>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define si set<int>
#define vii vector<pair<int,int> >
#define vi vector<int>
#define vll vector<ll>
#define vb vector<bool>
#define vvi vector<vector<int>>
#define vs vector<string>
#define all(v) v.begin(),v.end()
#define pb push_back
#define pob pop_back
#define pof pop_front
#define pf push_front
#define mp make_pair
#define F first
#define S second
//#define nu 100001
#define M 1000000007
#define mul(x,y) ((ll)(x)*(y))%M
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)
#define fastio  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define INF 0x3f3f3f3f
int MOD(int a, int b)
{
    if(a>b)
    return a-b;
    else
    return b-a;
}
ll max3(ll a,ll b,ll c)
{
    return max(c,max(a,b));
}
ll power(ll x,ll y, ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
ll max(ll a,ll b)
{
    return (a>b)?a:b;
}
ll min(ll a,ll b)
{
    return (a<b)?a:b;
}
ll gcd(ll a,ll b)
{
    if(b==1)
    return 1;
    else if(a%b==0)
    return b;
    else
    return gcd(b,a%b);
}
ll mod(ll x){
    if(x>=0)
    return x;
    else
    return -x;
}
int x=8;
int main()
{
    fastio;
    ll n,m;
    cin>>n>>m;
    int f[m]={};
    rep(i,n){
    	int k;
    	cin>>k;
    	rep(j,k){
    		int f1;
    		cin>>f1;
    		f1--;
    		f[f1]++;
    	}
    }
    int res=0;
    rep(i,m){
    	if(f[i]==n)
    	res++;
    }
    cout<<res;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const double eps = 1e-8;
const int NINF = 0xc0c0c0c0;
const int INF  = 0x3f3f3f3f;
const ll  mod  = 1e9 + 7;
const ll  maxn = 1e6 + 5;
const int t = 226732710;
const int N = 2e5 + 5;

int n,k;
ll ans;

// ll qpow(ll a,ll b,ll p){
// 	ll ans=1;
// 	while(b>0){
// 		if(b&1) ans=ans*a%p;
// 		a=a*a%p;
// 		b>>=1;
// 	}
// 	return ans;
// }

void check(ll x){
	ll mi=(1+x)*x/2%mod,ma=(n+1-x+1+n+1)*x/2%mod;
	// cout<<"mi="<<mi<<"  ma="<<ma<<"\n";
	ans=(ans+mod+(ma-mi+1)%mod)%mod;
	// cout<<"x="<<x<<"  delta="<<(ma-mi)%mod/2%mod<<'\n';
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	// cout<<qpow(10,100,mod)<<'\n';
	cin>>n>>k;
	// for(int i=0;i<=n;i++){
	// 	a[i]=(k+i)%mod;
	// }
	for(int i=k;i<=n+1;i++){
		check(i);
	}
	cout<<ans%mod<<'\n';
	return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;

int main(){
    int n, m, ans=false, A, B;
    cin >> n >> m;
    vector<int> a, b;
    rep(i, m){
        cin >> A >> B;
        if(A==1) a.push_back(B);
        if(B==n) b.push_back(A);
    }
    sort(all(a));
    sort(all(b));
    rep(i, a.size()){
        if(binary_search(all(b), a.at(i)))ans=true;
    }
    if(ans)cout << "POSSIBLE";
    else cout << "IMPOSSIBLE";
}

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

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

    int N, M, R;

    cin >> N >> M >> R;

    vector<int> r(R);
    vector<vector<int> > x(N, vector<int>(N, 1000000000));

    for(int i = 0; i < N; i++) {
        x[i][i] = 0;
    }

    for(int i = 0; i < R; i++) {
        cin >> r[i];
        r[i]--;
    }

    for(int i = 0; i < M; i++) {
        int A, B, C;
        cin >> A >> B >> C;
        A--;
        B--;
        x[A][B] = C;
        x[B][A] = C;
    }

    for(int i = 0; i < N; i++) {
        for(int j = 0; j < N; j++) {
            for(int k = 0; k < N; k++) {
                x[j][k] = min(x[j][k], x[j][i] + x[i][k]);
            }
        }
    }

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

    int ans = 1000000000;

    do {
        int a = 0;
        for(int i = 0; i < r.size() - 1; i++) {
            a += x[r[i]][r[i + 1]];
        }
        ans = min(ans, a);
    } while(next_permutation(r.begin(), r.end()));

    cout << ans << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <iomanip>
#include <vector>
#include <cmath>
using namespace std;

int main(){
  int x, y;
  cin >> x >> y;
  if(x == 1){
    if(y == 2 || y == 4){
      cout<<"Yes\n";
    }else{
      cout<<"No\n";
    }
    return 0;
  }
  if(y % 2 != 0 || x * 4 < y){
    cout<<"No\n";
    return 0;
  }
  if(y < x * 2){
    cout<<"No\n";    
    return 0;
  }
  cout <<"Yes\n";
  return 0;
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/04/03  Problem: ABC 047 B / Link: http://abc047.contest.atcoder.jp/tasks/abc047_b  ----- */

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

	LL W, H, N; cin >> W >> H >> N;
	VVL a(H, VL(W, 0));
	auto fillrange = [&](int sy, int sx, int ty, int tx) {
		FOR(i, sy, ty) {
			FOR(j, sx, tx) {
				a[i][j] = 1;
			}
		}
	};
	FOR(i, 0, N) {
		{
			LL x, y, a; cin >> x >> y >> a;
			if (a == 1) {
				fillrange(0, 0, H, x);
			}
			else if (a == 2) {
				fillrange(0, x, H, W);
			}
			else if (a == 3) {
				fillrange(0, 0, y, W);
			}
			else if (a == 4) {
				fillrange(y, 0, H, W);
			}
		}
	}

	LL ans = 0LL; {
		FOR(i, 0, H) {
			FOR(j, 0, W) {
				ans += !a[i][j];
			}
		}
	}


	cout << (ans) << "\n";

	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define HohleFeuerwerke using namespace std
HohleFeuerwerke;
unsigned long long a,b;
int main()
{
	ios::sync_with_stdio(false);
	cout.tie(0);cin.tie(0);
	cin>>a>>b;
	if(a==1) cout<<1<<endl;
	else if(b==1) cout<<1<<endl;
	else if(a*b%2==0) cout<<a*b/2<<endl;
	else cout<<a*b/2+1<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define sqr(x) ((x)*(x))
#define mp make_pair
#define uint unsigned
#define ld long double
#define PI pair<int,int>
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int N=1000005;
queue<int> q;
int n,ans,p;
char s[N],t[N];
signed main(){
	n=p=read();
	scanf("%s%s",s+1,t+1);
	if(!strcmp(s+1,t+1)){puts("0"); return 0;}
	for(int i=n;i;i--)if(t[i]!=t[i-1]){
		p=min(p,i);
		while(s[p]!=t[i]&&p)p--;
		if(!p){puts("-1"); return 0;}
		while(q.size())if(q.front()>=q.size()+i)q.pop(); else break;
		q.push(p); if(p!=i)ans=max(ans,(int)q.size());
	}
	cout<<ans+1<<endl;
}

Measured memory_bytes: 6272
#![allow(unused_mut)]
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(unused_imports)]
#![allow(dead_code)]
use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        S: chars,
    }
    let mut p = ' ';
    for s in S {
        if s == p {
            println!("Bad");
            return;
        }
        p = s;
    }
    println!("Good");
}



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

using namespace std;
long long MOD = (long long)1e9 + 7LL;

long long calcFactorial(long long a) {
  long long ans = a;
  a--;
  while (a > 0) {
    ans = (ans * a) % MOD;
    a--;
  }
  return ans;
}

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

  if (abs(N - M) > 1) {
    cout << 0 << endl;
  } else {
    long long ans = calcFactorial(N);
    ans = (ans * calcFactorial(M)) % MOD;
    if (N == M) {
      ans = (ans * 2LL) % MOD;
    }
    cout << ans << endl;
  }
  return 0;
}



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

using namespace std;

const int N = 2e5 + 5;

vector<vector<int> > g(N , vector<int>());
vector<long long> sum(N , 0);

void dfs(int v , int p = 0) {
   sum[v] += sum[p];
   for (int to : g[v]) {
      if (to != p) {
         dfs(to , v);
      }
   }
}

int main() {
   ios_base :: sync_with_stdio(0);
   cin.tie(0) , cout.tie(0);
   int n , q;
   cin >> n >> q;
   for (int i = 2; i <= n; i++) {
      int u , v;
      cin >> u >> v;
      g[u].push_back(v);
      g[v].push_back(u);
   }
   for (int i = 1; i <= q; i++) {
      int v , x;
      cin >> v >> x;
      sum[v] += x;
   }
   dfs(1);
   for (int i = 1; i <= n; i++) {
      cout << sum[i] << " ";
   }
   return 0;
}


Measured memory_bytes: 24320