akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>

#define Q_MAX (400000)

typedef struct {
	char block[10][11];
    int num[3];
	int time;
} COLOR;

int head, tail;
COLOR queue[Q_MAX];

void enq(COLOR t)
{
	queue[tail++ % Q_MAX] = t;
}

void deq(COLOR *t)
{
	*t = queue[head++ % Q_MAX];
}

int conv(char c)
{
    return ((c > 'B') + (c > 'G'));
}

int x, y;

void dfs(COLOR *exm, char c, char change, int p, int q)
{
	int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
	int mx, my;
	int i;
	
    exm->num[conv(exm->block[q][p])]--;
    exm->num[conv(c)]++;
	exm->block[q][p] = c;
	
	for (i = 0; i < 4; i++){
		mx = p + dx[i];
		my = q + dy[i];
		if (0 <= mx && mx < x && 0 <= my && my < y && exm->block[my][mx] == change){
			dfs(exm, c, change, mx, my);
		}
	}
}

int main(void)
{
	COLOR puzzle, temp;
	int i, j;
	char c;
    
	while (1){
		scanf("%d%d", &x, &y);
		
		if (x + y == 0){
			break;
		}
        memset(puzzle.num, 0, sizeof(puzzle.num));
        
		
		for (i = 0; i < y; i++){
			for (j = 0; j < x; j++){
				do {
					c = puzzle.block[i][j] = getchar();
				} while (c != 'R' && c != 'G' && c != 'B');
                puzzle.num[conv(c)]++;
			}
		}
		memset(queue, 0, sizeof(queue));
		head = tail = 0;
		puzzle.time = 0;
		enq(puzzle);
        
		while (1){
			deq(&temp);
			
			if (temp.num[0] == x * y || temp.num[1] == x * y || temp.num[2] == x * y){
				break;
			}
			
			if (temp.block[0][0] != 'R'){
				puzzle = temp;
				puzzle.time = temp.time + 1;
				dfs(&puzzle, 'R', temp.block[0][0], 0, 0);
				enq(puzzle);
			}
			
			if (temp.block[0][0] != 'G'){
				puzzle = temp;
				puzzle.time = temp.time + 1;
				dfs(&puzzle, 'G', temp.block[0][0], 0, 0);
				enq(puzzle);
			}
			
			if (temp.block[0][0] != 'B'){
				puzzle = temp;
				puzzle.time = temp.time + 1;
				dfs(&puzzle, 'B', temp.block[0][0], 0, 0);
				enq(puzzle);
			}
		}
		
		printf("%d\n", temp.time);
	}
	
	return (0);
}

Measured memory_bytes: 49000
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <limits.h>
#include <cinttypes>
#include <string.h>

#define max(a,b) (((a) > (b)) ? (a) : (b))
#define min(a,b) (((a) < (b)) ? (a) : (b))
#define abs(a) (((a) < 0) ? -(a) : (a))

#define FOR(var, to)          for (register int var = 0; var < to; var++)
#define FROMTO(var, from, to) for (register int var = from; var <= to; var++)

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;

static inline int ri() {
	int a;
	scanf("%d", &a);
	return a;
}

static inline s64 rs64() {
	s64 a;
	scanf("%" SCNd64, &a);
	return a;
}

static inline void wi(int a) {
	printf("%d", a);
}

static inline void wu64(u64 a) {
	printf("%" PRIu64, a);
}

int main() {
	char str[1001];
	scanf("%s", str);
	int n = ri();
	size_t len = strlen(str);
	
	size_t cur = 0;
	while (cur < len) {
		printf("%c", str[cur]);
		
		cur += (size_t) n;
	}
	
	return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(a < b && b < c)
	{
		printf("Yes\n");
	}else
	{
		printf("No\n");
	}	

	return 0;
}

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

int main()
{
    int n,m,i,beg,fin;
    cin>>n>>m;

    int num_load[n]={};
    for(i = 0; i < m; i++)
    {
        cin>>beg>>fin;
        num_load[beg-1]++;
        num_load[fin-1]++;
    }

    for(i = 0; i < n; i++) cout<<num_load[i]<<endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
constexpr int MOD = 998244353;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
int N;
vector<pair<lint, lint>> XD;
vector<int> ne;
vector<lint> dp;
vector<bool> used;
lint solve(int idx) {
  lint ret = 1;
  while(ne[idx] != -1) {
    if(XD[ne[idx]].first < XD[idx].first + XD[idx].second) {
      ret = ret * dp[ne[idx]] % MOD;
      used[ne[idx]] = true;
      ne[idx] = ne[ne[idx]];
    } else {
      break;
    }
  }
  //cout << ret+1 << endl;
  return ret+1;
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> N;
  XD = vector<pair<lint, lint>>(N);
  ne = vector<int>(N);
  dp = vector<lint>(N, 1);
  used = vector<bool>(N);
  REP(i, N) cin >> XD[i].first >> XD[i].second;
  sort(XD.begin(), XD.end(), [](auto const &a, auto const &b) { return a.first < b.first; });
  ne[N-1] = -1;
  REP(i, N-1) ne[i] = i+1;
  IREP(i, N) {
    dp[i] = solve(i);
  }
  lint ans = 1;
  REP(i, N) {
    if(!used[i]) ans = ans * dp[i] % MOD;
  }
  cout << ans << endl;
}

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

int N;
int C[110][110];

void _main() {
    cin >> N;
    REP (i, N) REP (j, N) cin >> C[i][j];
    int ans = 0;
    REP (i, N) FOR (j, i + 1, N) {
        ans += min(C[i][j], C[j][i]);
    }
    cout << ans << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}


Measured memory_bytes: 3308
#include<iostream>
#include<string>
#include<cmath>
#include<algorithm>/*toupperとかが入っている*/
#include<vector>/*可変長配列vectorのインクルード*/

const int MOD=1000000007;/* 1,000,000,007 で割った余りを出力する　のとき使う*/
using namespace std;/*標準名前空間を利用する。cinやcoutはこれによって利用可能になる*/

string S;
string T;

int main(void) {
  cin >> S;
  if(S=="Sunny") T="Cloudy";
  if(S=="Cloudy") T="Rainy";
  if(S=="Rainy") T="Sunny";

  cout << T << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>

int main(void){
    long long w, h, x, y;
    std::pair<double, double> c;
    std::cin >> w >> h >> x >> y;
    c = std::make_pair(w / 2.0, h / 2.0);
    double ans = h * w / 2.0;
    std::cout << ans << " ";
    if(x == w / 2.0 && y == h / 2.0) std::cout << 1 << std::endl;
    else std::cout << 0 << std::endl;
    return 0;
}

Measured memory_bytes: 3788
/*　　　　　　　{:i:i:|i:i:/l/l--　 　 　--l/li:i:i|i:i:i:i}
　　　　　　 　 {:rx|:i:i ィi芥ミ 　 　 .ィi芥ミｉ:ｉ|ﾍ:i:i:}
.　　　 　 　 　 ｛ﾏ|ｉ:  {::’:} 　 　 　{:‘::} :ｉ:i:|〉｝:/
　　 　 　 　 　 乂|:i:| ｀¨¨¨¨´ 　 　　｀¨¨¨´  :i:ｉ:|ｼ/
　 　 　 　 　 　 ﾉ:|:i|　　　　　　′　　　 　   |:i:i:|ﾂ
　　　　　　　　/:/|:i:| ､　　　 　_ _ 　　　　  |:i:i:|
　 　 　　 　 /:/ .|:i:|/ ＼　　　 　 　     ｨ〔|:i:/
　　 　 　  　 〈;/ く刈＿ 个 　   -   　＜}　./|/_〉
　　     　　 r-っ'~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ|___
　　 　     /／ニつ　　　　　　 ､　　　　　　　ノﾆﾆ　＼
.　　　     |　　ニ⊃ 　./　/　 ──   /　/　　..⊆ﾆﾆ　　:|
.　　　     |　　丁´　 /|￣|￣  ─‐ /|￣|￣ 　 .￣|丁 　|
.　　　     |　　ﾉ.  　 |￣|￣  ─‐  |￣|￣ 　 　.|八 　|
.　　　     |　　||. 　 |￣|￣ |￣| |￣|￣ 　   .|　|
.　 　 　   |  　||   　￣￣￣　￣ 　￣￣￣　　  .|　|  |
.　 　 　  　    ||＿＿＿＿＿＿＿＿＿＿＿＿______|__　　 ',
　 　      ,′　 | ７ﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆ}  ,′
.　　     {　　　|/　}ﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆ{/ 　 　
*///讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐。
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <limits>

using namespace std;

#define rep(a) _rep(0,int(a))
#define repj(a) for(int j=0;j<int(a);j++)
#define repk(a) for(int k=0;k<int(a);k++)
#define _rep(a,b) for(int i=int(a);i<int(b);i++)
#define ll long long
#define fst first
#define snd second
#define pf(b) printf("%.12f\n",(double)b)
#define _GLIBCXX_DEBUG
const double pai = 3.1415926535897;
#define _cos(n) cos(n*pai/180)
#define l_b lower_bound
#define u_b upper_bound
#define b_s binary_search

//factorial(練習)　階乗
int fact(int n) {
	int a = 1;
	for (int i = 1;i <= n;i++) a *= i;
	return a;
}
int sa(int n, int m) {      //差！
	if (n < m)return m - n;
	else return n - m;
}
int keta(int num) {
	int n = 0;
	if (num==0) {
		return 1;
	}
	while (num != 0) {
		num /= 10;
		n++;
	}
	return n ;
}

string s;
signed main() {
	cin >> s;
	int n = s.size(),a=0;
	rep(n) {
		if (s[i] == '+')a++;
		if (s[i] == '-')a--;
	}
	cout << a << endl;
}

Measured memory_bytes: 256
// 2014/10/27 Tazoe

#include <iostream>
using namespace std;

int L[250001], R[250001];

int Cnt;

void Merge(int A[500000], int left, int mid, int right)
{
	const int SENTINEL = 1000000001;

	int n1 = mid-left;
	int n2 = right-mid;

	for(int i=0; i<n1; i++){
		L[i] = A[left+i];
	}
	for(int i=0; i<n2; i++){
		R[i] = A[mid+i];
	}
	L[n1] = SENTINEL;
	R[n2] = SENTINEL;

	for(int i=0, j=0, k=left; k<right; k++){
		if(Cnt++, L[i]<=R[j]){
			A[k] = L[i];
			i++;
		}
		else{
			A[k] = R[j];
			j++;
		}
	}
}

void Merge_Sort(int A[500000], int left, int right)
{
	if(left+1>=right)
		return;

	int mid = (left+right)/2;
	Merge_Sort(A, left, mid);
	Merge_Sort(A, mid, right);
	Merge(A, left, mid, right);
}

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

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

	Cnt = 0;

	Merge_Sort(S, 0, n);

	for(int i=0; i<n; i++){
		cout << S[i];

		if(i<n-1){
			cout << ' ';
		}
		else{
			cout << endl;
		}
	}

	cout << Cnt << endl;

	return 0;
}

Measured memory_bytes: 5060
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<vector>
#include<queue>
#include<bitset>
#include<string>
#include<stack>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<complex>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<algorithm>
#include<list>
#include<functional>
#include<cassert>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define y0 y12
#define y1 y22
#define INF 1987654321
#define PI 3.141592653589793238462643383279502884
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset((a),0,sizeof(a));
#define MEM_1(a) memset((a),-1,sizeof(a));
#define ALL(a) a.begin(),a.end()
#define SYNC ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<ld, ld> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<double> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef tuple<int,int,int,int> iiii;
typedef tuple<ll, ll, ll> LLL;
typedef vector<iii> Viii;
typedef vector<LLL> VLLL;
typedef complex<double> base;
const ll MOD = 1000000007;
ll POW(ll a, ll b, ll MMM = MOD) {ll ret=1; for(;b;b>>=1,a=(a*a)%MMM)if(b&1)ret=(ret*a)% MMM; return ret; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { if (a == 0 || b == 0)return a + b; return a*(b / gcd(a, b)); }
int dx[] = { 0,1,0,-1,1,1,-1,-1 }, dy[] = { 1,0,-1,0,1,-1,1,-1 };

char s[500][501];
bool chk[500];
int main(){
	int n;
	scanf("%d",&n);
	fup(i,0,n-1,1)scanf("%s",s[i]);
	bool o=0;
	int c=0;
	fup(i,0,n-1,1)
	{
		fup(j,0,n-1,1)
		{
			if(s[i][j]=='#')
			{
				o=1;
				chk[j]=1;
			}
		}
	}
	if(!o)return !printf("-1");
	fup(j,0,n-1,1)
	{
		int t=0;
		fup(i,0,n-1,1)
			if(s[i][j]=='#')t++;
		if(t!=n)c++;
	}
	int ans=INF;
	fup(i,0,n-1,1)
	{
		int t=0;
		fup(j,0,n-1,1)
			if(s[i][j]=='.')t++;
		ans=min(ans,t+c+1-chk[i]);
	}
	return !printf("%d",ans);
}

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

int main(){
    string s, t;
    cin >> s >> t;
    int cnt = 0;
    for(int i = 0; i < s.size(); i++){
        if(s[i] != t[i]) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3812
N = gets.chomp.to_i

pat = ([1] + (1..6).map{|i| 6**i} + (1..6).map{|i| 9**i}).select {|v| v <= N}
dp = {0=>0}

1.upto(N) do |i|
  dp[i] = 1 + pat.select {|v| i - v >= 0}.map {|v| dp[i-v]}.min
end
puts dp[N]


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

using namespace std;

void dfs(int curr, int& ts, const vector<set<int> >& graph
        , vector<int>& d, vector<int>& f) {

    ++ts;
    d[curr] = ts;
    const set<int>& nextNodes = graph[curr];
    for (int n : nextNodes) {
        if (d[n] > 0) {
            continue;
        }
        dfs(n, ts, graph, d, f);
    }
    ++ts;
    f[curr] = ts;
}

void Main() {
    int n;
    cin >> n;
    vector<set<int> > graph(n, set<int>());
    for (int i = 0; i < n; ++i) {
        int u, k;
        cin >> u >> k;
        --u;
        for (int j = 0; j < k; ++j) {
            int v;
            cin >> v;
            --v;
            graph[u].insert(v);
        }
    }

    vector<int> d(n, -1);
    vector<int> f(n, -1);
    int timestamp = 0;
    for (int i = 0; i < n; ++i) {
        if (d[i] < 0) {
            dfs(i, timestamp, graph, d, f);
        }
    }
    for (int i = 0; i < n; ++i) {
        cout << (i + 1) << " " << d[i] << " " << f[i] << endl;
    }
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}



Measured memory_bytes: 3092
#include <cstdio>
#define repeat(i, n) for (int i = 0; (i) < int(n); ++(i))
using namespace std;

int main() {
    while (true) {
        int n, k, s; scanf("%d%d%d", &n, &k, &s);
        if (n == 0 and k == 0 and s == 0) break;
        int result = 0;
        repeat (x, 1 << n) if (__builtin_popcount(x) == k) {
            int acc = 0;
            repeat (i, n) if (x & (1 << i)) {
                acc += i + 1;
            }
            result += (acc == s);
        }
        printf("%d\n", result);
    }
    return 0;
}

Measured memory_bytes: 2668
#include<bits/stdc++.h>
using namespace std;
 
int main(){
    int n;
    cin>>n;
    int a[n];
    long double ans=0.0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        ans+=1.0/a[i];
    }
    cout<<setprecision(10)<<1.0/ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
#define fast                                                                   \
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define ll long long
#define f(i, n) for (int i = 0; i < n; i++)
#define fo(i,a,n) for (i = a; i <= n; i++)
#define F first
#define S second
#define pii pair<int,int>
#define sz size()
#define all(v) v.begin(),v.end()
#define pb push_back
#define pf push_front    
#define PB pop_back
#define pll pair<long long, long long>
#define vi vector<int>
#define vl vector<int>
#define mp make_pair
#define mod 1000000007
typedef unsigned long long ull;
const int N = 200005;
const int MOD = 998244353 ;


void solve(){
    int n, a, b;
    cin>>n>>a>>b;
    cout<<(a*(n/(a+b)) + (min(a,(n%(a+b)))));
}

int32_t main() {
    fast
    int t;
    t = 1;
    //cin >> t;
    while(t--)solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pb push_back
#define mp make_pair
#define SZ(x) ((int)(x).size())
#define all(x) x.begin(),x.end()
#define mem0(s) memset(s,0,sizeof(s))
#define meminf(s) memset(s,0x3f,sizeof(s))
#define mp_insert(a,b,c) mp.insert(map<pair<int,int>,int>::value_type(make_pair(a,b),c))
double pi=acos(-1);
typedef long long ll;
typedef unsigned long long ull;
inline ll lowbit(ll x){return x&(-x);}
inline ll min(ll a,ll b){return a<b?a:b;}
inline ll max(ll a,ll b){return a>b?a:b;}
const int INF=0x3f3f3f3f,max_n=200005,mod=19260817;
inline ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
inline ll pow(ll a,ll b,ll mod){ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll a[max_n],b[max_n];int x;
vector<int>v[max_n];
ll ans1;
int main()
{
	int n;cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>x;
		a[i]=x+i;
		b[i]=i-x;
	}
	for(int i=1;i<=n;i++)
	{
		if(b[i]>=2&&b[i]<=199999)
		{
			v[b[i]].push_back(i);
		}
	}
	for(int i=1;i<=n;i++)
	{
		x=a[i];
		if(x>=2&&x<=199999)
		{
			if(v[x].size()!=0)
			{
				//¶þ·ÖµØÕÒµÚÒ»¸ö´óÓÚiµÄÊý×Ö
				int ll=upper_bound(v[x].begin(),v[x].end(),i)-v[x].begin();
				//cout<<ll<<endl;
				ans1+=v[x].size()-ll;
			}
		}
	}
	cout<<ans1<<endl;
    return 0;
}

Measured memory_bytes: 15200
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define ll long long

void test_case()
{
    ll n,k;
    cin>>n>>k;
    ll mod=1e9+7;
    ll a[n+1],i,j;
    for(i=1;i<=n;i++)
        cin>>a[i];
    ll dp[n+1][k+1];    // n candies k people
    dp[0][0]=1;

    for(i=1;i<=k;i++) // 0 candies
        dp[0][i]=0;

    for(i=1;i<=n;i++)
    {
        ll sums[k+1];   // prefix sum
        sums[0]=dp[i-1][0];

        for(j=1;j<=k;j++)
            sums[j]=(sums[j-1]+dp[i-1][j])%mod;

        for(j=0;j<=k;j++)
        {
            ll temp=sums[j];
            ll unreachable=j-1-a[i];
            if(unreachable>=0)
            {
                temp=(temp-sums[unreachable]+mod)%mod;
            }
            dp[i][j]=temp;
        }
    }
    cout<<dp[n][k];
}

int main()
{
    fastio
//    int t;
//    cin>>t;
//    while(t--)
    test_case();
}


Measured memory_bytes: 80000
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  int n, m;
  readf("%s %s\n", &n, &m);
  auto cnt = new int[](m);
  foreach (i; 0..n) {
    auto t = readln.chomp.split.to!(int[]);
    foreach (e; t[1..$]) {
      cnt[e-1]++;
    }
  }
  int res;
  foreach (i; 0..m) {
    if (cnt[i] == n) {
      res++;
    }
  }
  res.writeln;
}


Measured memory_bytes: 256
//#define MYDEBUG
#include <bits/stdc++.h>
#ifdef MYDEBUG
#define debug(x) cout<<#x<<": "<<x<<endl
#define ifcin(x) std::ifstream cin(x)
#else
#define debug(x)
#define ifcin(x)
#endif
#define ll long long
#define ull unsigned long long
#define eps 1e-14
#define all(x) x.begin(), x.end()
#define rep(i,from,to) for(int i=from; i<to; ++i)
#define REP(i,from,to) for(int i=from; i<=to; ++i)
using std::cout;
using std::cin;
using std::endl;
using std::vector;
using std::ostream;
using std::swap;
using std::max;
using std::min;
using std::queue;
typedef struct edge edge;
typedef struct unionfind unionfind;
typedef struct Graph Graph;

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
  out << "[";
  size_t last = v.size() - 1;
  for (size_t i = 0; i < v.size(); ++i) {
    out << v[i];
    if (i != last)
      out << ",";
  }
  out << "]";
  return out;
}

struct unionfind{
	vector<int> par;
	vector<int> rank;
	unionfind(int n) {
		par = vector<int>(n);
		rank = vector<int>(n);
		rep(i,0,n){//0????????????
			par[i] = i;
			rank[i] = 1;
		}
	}
	
	int find(int x){
		if(par[x] == x){
			return x;
		}
		return par[x] = find(par[x]);
	}
	
	bool same(int x, int y){
		return find(x) == find(y);
	}
	
	void unite(int x, int y){//rank[x] > rank[y]?????????
		x = find(x);
		y = find(y);
		if(x == y){
			return;
		}
		if(rank[x] < rank[y]){
			swap(x,y);
		}
		par[y] = x;
		rank[x] += rank[y];
		rank[y] = 0;
	}
	
	int size(int x){
		return rank[x];
	}
};

struct edge{
	int from, to;
	double cost;
	edge(int from, int to, double cost){
		this->from = from;
		this->to = to;
		this->cost = cost;
	}
	
	edge(){
		*this = edge(-1,-1,-1);
	}
	
	bool operator<(const edge& e) const{
		return cost < e.cost;
	}
};

class Graph{
	public:
	static double kruskal(vector<edge>& es, int n){
		sort(all(es));
		double min_cost = 0;
		unionfind uf(n);
		rep(i,0,es.size()){
			edge &e = es[i];
			if(!uf.same(e.from, e.to)){
				min_cost += e.cost;
				uf.unite(e.from, e.to);
			}
		}
		return min_cost;
	}
};

struct sphere{
	double x,y,z,r;
	sphere(double x, double y, double z, double r){
		this->x = x;
		this->y = y;
		this->z = z;
		this->r = r;
	}
	double dist(sphere& s){
		return std::sqrt((x-s.x)*(x-s.x) + (y-s.y)*(y-s.y) + (z-s.z)*(z-s.z));
	}
	double corridor(sphere& s){
		double d = dist(s) - r - s.r;
		if(d<=eps){
			return 0.0;
		}else{
			return d;
		}
	}
};

typedef struct sphere sphere;
const int maxn = 100100;
vector<edge> g;
vector<sphere> sp;
int n, m;

void solve(){
	ifcin("/storage/emulated/0/AppProjects/AtCoder/jni/in.txt");
	while(cin>>n, n){
		g = vector<edge>();
		sp = vector<sphere>();
		rep(m,0,n){
			double x,y,z,r;
			cin >> x >> y >> z >> r;
			sp.push_back(sphere(x,y,z,r));
			rep(i,0,sp.size()){
				sphere& s1 = sp[i];
				rep(k,0,sp.size()){
					sphere& s2 = sp[k];
					double cost = s1.corridor(s2);
					g.push_back(edge(i, k, cost));
					g.push_back(edge(k, i, cost));
				}
			}
		}
		printf("%.3f\n",Graph::kruskal(g, n));
	}

}

int main() {
	solve();
}

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

int main(){

        int n;
        cin>>n;
        int r[51],t[51];
        for(int i=0;i<n;i++){
        int bufa=0;
        cin>>r[i]>>t[i];
        bufa=(r[i]/100)+5*(t[i]/30);
        if(r[i]%100==0){
         if(t[i]%30==0||t[i]==0){
              cout<<bufa<<endl;//頂点上
          }
         else {
              cout<<bufa<<" "<<bufa+5<<endl;//円弧上
          }
         }
         else if(t[i]%30==0||t[i]==0){
              cout<<bufa<<" "<<bufa+1<<endl;//直線上
         }
         else{
              cout<<bufa<<" "<<bufa+1<<" "<<bufa+5<<" "<<bufa+6<<endl;
         }
       }
        return 0;
}


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

typedef long long int ll;
typedef string str;

int main ()
{
	// ios::sync_with_stdio(0);
 //    cin.tie(0);
 //    cout.tie(0);
	ll t,n,m,k,i,a,b,j;
	cin >> n;
	ll arr[n+2];
	for(i=0;i<=n;i++)
	{
		cin >> arr[i];
	}
	b=0;
	ll node[n+2],atnode[n+2];
	node[n]=arr[n];
	atnode[n]=arr[n];
	for(i=n-1;i>=0;i--)
	{
		a=node[i+1]/2 + node[i+1]%2 + arr[i];
		if(i<60 && pow(2,i)<a)
		{
			b=1;
			break;
		}
		else
		{
			node[i]=a;
		}
	}
	for(i=n-1;i>=0;i--)
	{
		atnode[i]=atnode[i+1]+arr[i];
		if(i<60 && atnode[i]>pow(2,i))
			atnode[i]=pow(2,i);
	}
	if(!b)
	{
		node[0]=1;
		k=1;
		// cout << k << " hi\n";
		for(i=1;i<n;i++)
		{

			a=(node[i-1]-arr[i-1])*2;
			m=atnode[i+1]+arr[i];
			if(a>m)
			{
				node[i]=m;
			}
			else
			{
				node[i]=a;
			}
			k+=node[i];
			// cout << k << " hi\n";
		}
		k+=arr[n];
		// cout << k << " hi\n";
	}
	if(n==0 && arr[0]>1)
		b=1;
	else if(n==0)
		k=1;
	if(b)
		cout << "-1\n";
	else
	{
		cout << k << "\n";

	}
	return 0;
}

Measured memory_bytes: 6380
#include<map>
#include<bits/stdc++.h>
#include<string>
#include<algorithm>
typedef long long int ll;
using namespace std;
#define MAXN 100005
#define X first
#define Y second
#define MOD 1000000007
#define inf 1e18
#define fr(a,b,c) for(ll a=b;a<c;++a)
#define pb push_back
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
ll n,i,j,t;

int main()
{
    cout<<fixed<<setprecision(20);
    fastio;
    ll k;
    cin>>n>>k;
    vector<ll > v(n);
    for(i=0;i<n;i++) cin>>v[i];
    bool dp[MAXN]={true};
    //for(i=0;i<a[0];i++){
      //  dp[i][0]=false; dp[i][1]=false;
    //}
    bool a;
    for(i=0;i<=k;i++){
        a=true;
        for(j=0;j<n;j++){
            if(i-v[j]>=0){
                a&=dp[i-v[j]];
            }
        }
        dp[i]=!a;
    }
   // for(i=1;i<=k;i++)
     //   cout<<dp[i]<<" ";
    //cout<<endl;
    if(dp[k]) cout<<"First"<<endl;
    else cout<<"Second"<<endl;
}


Measured memory_bytes: 384
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int min =1000000000;
		for(int i=0;i<n;i++) {
			int a = sc.nextInt();
			int cut = 0;
			while(a%2 ==0) {
				cut++;
				a/=2;
			}
			min = Math.min(min, cut);
		}
		System.out.println(min);
	}
}

Measured memory_bytes: 21716
#include <iostream>
#define INF 1000000000

using namespace std;

main(){
  int items[]={200, 300, 500, 1000, 1200, 1500};
  int price[]={380, 550, 850, 1520, 1870, 2244};
  int dp[5001];
  for(int i=0;i<=5000;i++){
    dp[i]=INF;
  }
  dp[0]=0;
  for(int i=0;i<6;i++){
    for(int j=0;j+items[i]<=5000;j++){
      dp[j+items[i]]=min(dp[j+items[i]], dp[j]+price[i]);
    }
  }
  int n;
  while(1){
    cin >> n;
    if(n==0) break;
    cout << dp[n] << endl;
  }
  return 0;
}

Measured memory_bytes: 0
a, b, c, d = STDIN.gets.chars.map(&:to_i)

ops = ['+', '-']

catch(:break_loop) do
  ops.each do |op1|
    ops.each do |op2|
      ops.each do |op3|
        sum = a.send(op1, b).send(op2, c).send(op3, d)
        if (sum == 7)
          puts "#{a}#{op1}#{b}#{op2}#{c}#{op3}#{d}=7"
          throw :break_loop
        end
      end
    end
  end
end

Measured memory_bytes: 1788
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<functional>
#include<vector>
#include<stack>
#include<queue>
#include<iostream>
#define M -1;
using namespace std;
int dp[1001][1001];
vector<int> value,weight;
int main(void) 
{
	int i,j,w,n,mm,mx,cnt=0;;
	while(1) {
		cin>>w;
		if(w==0) break;
		cin>>n;
		weight.resize(n);
		value.resize(n);
		for(i=0;i<n;i++) scanf("%d,%d",&value[i],&weight[i]);
		for(i=0;i<=n;i++){
			for(j=0;j<=w;j++) dp[i][j]=M;
		}
		dp[0][0]=0;
		for(i=0;i<n;i++) {
			for(j=0;j<=w;j++) {
				if(dp[i][j]!=-1) {
					dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
					if(j+weight[i]<=w) {
						dp[i+1][j+weight[i]]=max(dp[i+1][j+weight[i]],dp[i][j]+value[i]);
					}
				}
			}
		}
		mm=-1;mx=-1;
		for(i=0;i<=w;i++) {
			if(mx<dp[n][i]) {
				mx=dp[n][i];
				mm=i;
			}
		}
		cnt++;
		cout<<"Case"<<" "<<cnt<<":"<<endl;
		cout<<mx<<endl<<mm<<endl;
	}
	exit(0);
}
		
		

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

int func(vector<ll> arr) 
{ 
    ll n = arr.size(); 
    unordered_set<ll> s; 
    for (ll i = 0; i < n; i++) { 
        s.insert(arr[i]); 
    } 
  
    if(s.size() == arr.size()) return 1;
    else return 0;
}

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,temp,i;
    cin >> n ;
    vector<ll> v;
    rep(i,n)
    {
        cin >> temp;
        v.push_back(temp);
    }
    if(func(v)==1) cout << "YES" ;
    else cout << "NO" ;
}

Measured memory_bytes: 11632
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int h = sc.nextInt();
    int n = sc.nextInt();
    for (int i = 0; i < n;i++) {
      h-=sc.nextInt();
      if (h <= 0) {
        System.out.println("Yes");
        return;
      }
    }
    System.out.println("No");
  }
}




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

using namespace std;

using ll = long long;
using ld = long double;

#define st first
#define nd second

const int MAXN = 1e6 + 5, inf = 1e9, mod = 1e9 + 7;
const ll INF = 1e18, MOD = 1e15 + 37;
const ld PI = acos(-1);

int d[MAXN];

map<int, int> b;

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

    //////////////////////////////////////////
    //////////////////////////////////////////

    int n;
    cin >> n;
    vector<int> a(n);
    for (int &i : a) {
        cin >> i;
    }

    for (int i : a) {
        b[i]++;
    }

    for (auto i : b) {
        for (int j = 1; j * i.st < MAXN; ++j) {
            d[i.st * j] += i.nd;
        }
    }

    int res = 0;
    for (int i : a) {
        res += d[i] == 1;
    }
    cout << res << "\n";
}


Measured memory_bytes: 17080
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    string S;
    cin >> N >> S;
    for (int i = 0; i < S.size(); i++)
    {
        int c = (S[i] - 'A' + N) % 26;
        S[i] = 'A' + c;
    }
    cout << S << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=110000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

ll gcd(ll x, ll y){
  if(x%y==0)return y;
  return gcd(y,x%y);
}
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);  
  
  ll n,t;
  cin >> n >>t;
  ll ans=INF;
  rep(i,n){
    ll a,b;
    cin >> a >> b;
    if(b<=t){
      chmin(ans,a);
    }
  }
  if(ans<INF)cout << ans << endl;
  else cout<<"TLE"<<endl;
}


Measured memory_bytes: 256
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7


#############
# Main Code #
#############

A, B, Q = getNM()
# 神社
S = getArray(A)
# 寺
T = getArray(B)
query = getArray(Q)

S.insert(0, -float('inf'))
T.insert(0, -float('inf'))
S.append(float('inf'))
T.append(float('inf'))

def close(data, point):
    west = data[bisect_left(data, point) - 1]
    east = data[bisect_left(data, point)]

    return west, east

for i in range(Q):
    now = query[i]
    shrine_west, shrine_east = close(S, now)
    temple_west, temple_east = close(T, now)

    ww = now - min(shrine_west, temple_west)
    we_1 = (now - shrine_west) * 2 + (temple_east - now)
    we_2 = (now - temple_west) * 2 + (shrine_east - now)
    ee = max(shrine_east, temple_east) - now
    ew_1 = (shrine_east - now) * 2 + (now - temple_west)
    ew_2 = (temple_east - now) * 2 + (now - shrine_west)

    print(min(ww, we_1, we_2, ee, ew_1, ew_2))

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

int  main()
{
	string s; cin >> s;
	map <string, string> mp;
	mp["Sunny"] = "Cloudy";
	mp["Rainy"] = "Sunny";
	mp["Cloudy"] = "Rainy";
	cout << mp[s] << endl;
	return (0);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define pii pair<int,int>
#define REP(i,a) for(int (i)=0; (i)<(a); (i)++)
#define REP2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
#define m0(x) memset(x,0,sizeof(x))
typedef long long ll;

using namespace std;

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};

ll modpow(ll a,ll n){
  ll ans=1;
  if(n==0)return 1;
  if(n%2==0) ans=modpow(a,n/2)*modpow(a,n/2)%MOD;
  else ans = a * modpow(a, n-1) % MOD;
  return ans;
}

ll comb(ll n,ll k){
  if(n<k)return 0;
  if(n==k || k==0)return 1;
  ll tmp=1,tmp2=1,tmp3=1;
  REP2(i,1,n+1){
    tmp*=i;
    tmp%=MOD;
  }
  REP2(i,1,k+1){
    tmp*=modpow(i,MOD-2);
    tmp%=MOD;
  }
  REP2(i,1,n-k+1){
    tmp*=modpow(i,MOD-2);
    tmp%=MOD;
  }
  return tmp;
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int N,K;
  cin>>N>>K;
  ll ans=0;
  REP2(i,1,K+1){
    cout<<(comb(N-K+1,i)*comb(K-1,i-1))%MOD<<"\n";
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <string>

using namespace std;

int a[26];
string alp = "abcdefghijklmnopqrstuvwxyz";

int main(void) {
	string s;
	cin >> s;
	if (s.size() != 26) {
		for (int i = 0; i < s.size(); i++) {
			for (int j = 0; j < 26; j++) {
				if (s[i] == alp[j]) {
					a[j]++;
					break;
				}
			}
		}
		for (int i = 0; i < 26; i++) {
			if (a[i] != 0) {
				break;
			}
		}
		for (int i = 0; i < 26; i++) {
			if (a[i] == 0) {
				s += alp[i];
				break;
			}
		}
		cout << s << endl;
	}
	else {
		int pos = -1;
		for (int i = s.size() - 1; i > 0; i--) {
			if (s[i - 1] < s[i]) {
				for (int j = 0; j < 26; j++) {
					if (s[i] == alp[j]) {
						a[j]++;
					}
				}
				pos = i - 1;
				break;
			}
			else {
				for (int j = 0; j < 26; j++) {
					if (s[i] == alp[j]) {
						a[j]++;
					}
				}
			}
		}
		if (pos != -1) {
			for (int i = 0; i < pos; i++) {
				cout << s[i];
			}
			for (int i = 0; i < 26; i++) {
				if (a[i] != 0 && alp[i] > s[pos]) {
					cout << alp[i] << endl;
					break;
				}
			}
		}
		else {
			cout << -1 << endl;
		}
	}
	system("pause");
	return 0;
}

Measured memory_bytes: 504
#include <iostream>
#include <vector>
#include <algorithm>

using std::cin;
using std::cout;
using std::endl;

using std::string;
using std::pair;

using std::vector;
using std::sort;
using std::lower_bound;
using std::upper_bound;
using std::find_if;
using std::copy;
using std::copy_if;

int main(){
    int x,t;
    cin >> x >> t;

    cout << std::max(x-t,0) << endl;
    return 0;
}



Measured memory_bytes: 256
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from math import ceil, floor
from sys import setrecursionlimit

import heapq as hq
import itertools as its
import operator as op


# globals
inf = float('inf')
N = 0


def set_inputs():
    global N
    return


class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # 同じ集合に属するか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)


def main():
    setrecursionlimit(100000)
    set_inputs()
    # ----------MAIN----------
    N, M = get_li()
    X, Y, Z = get_data(M, [int, int, int])
    uf = UnionFind(N)
    for x, y, _ in zip(X, Y, Z):
        uf.union(x, y)
    for i in range(N+1):
        uf.find(i)
    print(len(set(uf.par[1:])))
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def get_data(n, types, sep=None):
    if len(types) == 1:
        return [types[0](input().strip()) for _ in range(n)]
    return list(zip(*(
        [t(x) for t, x in zip(types, input().strip().split(sep=sep))]
        for _ in range(n)
    )))


if __name__ == '__main__':
    main()


Measured memory_bytes: 122452
/* Author : Aaryan Srivastava ^__^ */ 
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define pb push_back
#define popb pop_back
#define mt make_tuple 
#define eb emplace_back
#define mp make_pair
#define ff first
#define ss second 
#define ull unsigned long long  
#define pii pair<int, int>
#define piii pair<int,pii>
#define beg begin
#define rep(i,n) for(int (i) = 0 ; i < (n) ; i++)
#define repA(i,x,y) for(int i = (x) ; i <= (y) ; i++)
#define repD(i,x,y) for(int i = (x) ; i >= (y) ; i--)
#define all(c) (c).begin(),(c).end()
#define fill(a,val) memset(a,val,sizeof(a))
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define int ll
using ll = long long;
const int N = 3*1e5 +5 ;
const int mod = 1e9 + 7 ;
const int inf = 1e18 ;
const int SZ = 101 ;
const double eps = 1e-9 ;
using namespace __gnu_pbds;
using namespace std;
using ordered_set =  tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ;

#ifdef AaryanS
#define mycout cout
#define mycerr cerr 
#endif

#ifndef AaryanS
#define mycout if(false) cout
#define mycerr if(false) cerr
#endif


void solve()
{
	int n;
	cin >> n;
	vector<int> dp[3] , a[3];
	for(int i = 0 ; i < 3 ; ++i) dp[i].resize(n+1,0), a[i].resize(n+1);
	for(int i = 0 ; i < n ; ++i)
		for(int j = 0; j < 3 ; ++j)
			cin >> a[j][i];
	for(int i = 0 ; i < 3 ; ++i) dp[i][0] = a[i][0] ;
	for(int i = 0 ; i < n-1 ; ++i){
		for(int j = 0 ; j < 3 ; ++j){
			for(int k = 0 ; k < 3 ; ++k){
				if(k == j) continue;					
				dp[k][i+1] = max(dp[k][i+1],dp[j][i] + a[k][i+1]);
			}
		}
	}
	cout << max(dp[0][n-1], max(dp[1][n-1], dp[2][n-1]));
}   

     
int32_t main(int32_t argc, char *argv[])
{
    double t1 = clock() ;
    ios::sync_with_stdio(0);    
    cin.tie(0); cout.tie(0);
    int TC = 1, t = 0;
    //cin >> TC ;
    while(t++ < TC)
    {
        //cout << "Case #" << t << ": " ;
        solve();
        //cout << endl ;
    }
    mycerr << "Time : " << 1000 *(clock() - t1)/CLOCKS_PER_SEC << " ms\n" ;
    return 0;
}

Measured memory_bytes: 4992
n, m, c = [int(x) for x in input().split()]
b_list = [int(x) for x in input().split()]
ans = 0
for _ in range(n):
    a_list = [int(x) for x in input().split()]
    temp = sum([a * b for a, b in zip(a_list, b_list)])
    if temp + c > 0:
        ans += 1
print(ans)

Measured memory_bytes: 3060
#include <iomanip>
#include <random>
#include <time.h>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <functional>
#include <map>
#include <string>
#include <iostream>
#include <cstdlib>
#include <typeinfo>

using namespace std;
int main() {
	long long int n, i, ans = 0;
	cin >> n;
	for (i = 1; i > 0; i++) {
		if (i*(i + 1) / 2 >= n) {
			cout << i << endl;
			return 0;
		}
	}
}


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

int main()
{
    int n, k, i, a, mx = 0, g = 0;
    cin >> n >> k;
    for(i = 0; i < n; i++)
    {
        cin >> a;
        mx = max(a, mx);
        g = __gcd(g, a);
    }

    if(k%g == 0 && mx >= k)
        cout << "POSSIBLE";
    else
        cout << "IMPOSSIBLE";
}


Measured memory_bytes: 3584
//#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
//#include <queue>
//#include <stack>
#include <cstring>
#include <cassert>

using namespace std;

#ifdef LOCAL_DEBUG
#include <local_debug.h>
#define DEBUG(...) DBG2::print(#__VA_ARGS__, __LINE__, __VA_ARGS__)
#else
#define DEBUG(...)
#endif

#define SZ(a) int((a).size())
#define REP(i,n) for(int i=0,_n=(n);i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)

typedef long long llong;
typedef vector<int> VI;
typedef vector<VI> VVI;

llong sqr_dist(llong x, llong y) {
   return x*x + y*y;
}

int main(int argc, char* argv[]) {
   ios_base::sync_with_stdio(false); 
   cin.tie(nullptr);

   int N, D;
   cin >> N >> D;

   llong D2 = D*1LL*D;

   int res = 0;
   REP(i, N) {
      int x, y;
      cin >> x >> y;
      llong d2 = sqr_dist(x, y);
      if (d2 <= D2)
         ++res;
   }

   cout << res << '\n';

   return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int r; cin >> r;
    if(r < 1200) cout << "ABC";
    else if(r < 2800) cout << "ARC";
    else cout << "AGC";

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define nikal ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main()
{
    nikal;
    int k,a,b,p,q;
    cin>>k>>a>>b;
    p=a%k;
    if(p==0)
    {
        cout<<"OK";
    }
    else{

    p=a-p;
    p+=k;
    if(p>=a && b>=p)
        cout<<"OK";
    else
        cout<<"NG";
    }
    return 0;
}


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

/**
 * 
 */

/**
 * @author cthanh
 *
 */
public class Main {

	/**
	 * @param args
	 * @throws IOException
	 */

	public static void main(String[] args) throws IOException {
		// TODO ?????????????????????????????????????????????

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] str = br.readLine().split(" ");
		int n = Integer.parseInt(str[0]);
		int m = Integer.parseInt(str[1]);
		int[][] matrix = new int[n][m];
		int[] vector   = new int[m];


		for (int i = 0; i < n; i++) {
			str = br.readLine().split(" ");
			for (int j = 0; j < m; j++) {

				matrix[i][j] = Integer.parseInt(str[j]);
			}
		}
		for (int k = 0; k < m; k++) {
			String str1 = br.readLine();
			vector[k] = Integer.parseInt(str1);
		}

		for (int i = 0; i < n; i++) {
			int kakezan= 0;
			for (int j = 0; j < m; j++) {
				
				kakezan += matrix[i][j] * vector[j];

			}
			System.out.println(kakezan);
		}

	}

}

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

using namespace std;
using ll = long long;

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

  int n;
  cin >> n;
  int ans = 0;
  for (int a = 1; a <= n; a++) {
    for (int b = 1; b <= n; b++) {
      for (int c = 1; c <= n; c++) {
        ans += __gcd(a, __gcd(b, c));
      }
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#pragma GCC optimize ("O2,unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl;
#define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl;
#define debugv(v) {cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;}
#define all(x) x.begin(), x.end()
#define pb push_back
#define kill(x) return cout<<x<<'\n', 0;

const ld eps=1e-7;
const int inf=1000000010;
const ll INF=10000000000000010LL;
const int mod=1000000007;
const int MAXN=100010, LOG=20;

int n, m, k, u, v, x, y, t, a, b, ans;
int par[MAXN], h[MAXN], P[MAXN];
bool mark[MAXN];

int geth(int v){
	if (v==1 || h[v]) return h[v];
	return h[v]=geth(par[v])+1;
}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin>>n>>k;
	for (int i=1; i<=n; i++) cin>>par[i];
	for (int i=1; i<=n; i++) geth(i), P[i]=i;
	sort(P+1, P+n+1, [](int i, int j){
		return h[i]>h[j];
	});
	for (int i=1; i<=n; i++){
		int v=P[i];
		if (mark[v] || h[v]<=k) continue ;
		int tmp=k-1;
		while (!mark[v] && tmp--){
			mark[v]=1;
			v=par[v];
		}
		if (!mark[v]) mark[v]=1, ans++;
	}
	ans+=(par[1]!=1);
	cout<<ans<<'\n';
	
	return 0;
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
ll gcd(ll a,ll b){if(a>b)swap(a,b);for(;a>0;b%=a,swap(a,b));return b;}
int modpow(ll a,ll n,int m){if(a==0)return a;ll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(int)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;

struct Dijk{
  // solve(s, g) or solve(s).
  // show d and p.
  typedef pair<ll,int> pli;
  int n;
  vector<vpll>E;
  vl d;
  vi p;
  void init(const vector<vpll>&e){n=sz(e);E=e;FOR(i,0,n)sort(rng(E[i]));d.resize(n);p.resize(n);}
  void o(int S,int G){FOR(i,0,n){d[i]=(i==S)?0:linf;p[i]=-1;}priority_queue<pli,vector<pli>,greater<pli>>Q;Q.push(pll(0,S));pli t;vector<bool>F;FOR(i,0,n)F.pb(0);ll f;int c=0,s;while(!Q.empty()){t=Q.top();Q.pop();f=t.fi;s=t.se;if(F[s])continue;F[s]=1;c++;if(c==n||s==G)break;each(itr,E[s]){ll ff=itr->fi,ss=itr->se;if((!F[ff])&&(f+ss<d[ff])){d[ff]=f+ss;p[ff]=s;Q.push(pll(f+ss,ff));}}}}
  ll solve(int s,int g){o(s,g);return d[g];}
  void solve(int s){o(s,-1);}
} dijk;
int k;
vector<vpll> E;

main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> k;
  E.resize(k);
  FOR(i, 0, k){
    E[i].pb(mp((i+1)%k, 1));
    E[i].pb(mp((i*10)%k, 0));
  }
  dijk.init(E);
  cout << dijk.solve(1, 0) + 1 << endl;
  return 0;
}

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

int main() 
{
    int n, m;
    cin >> n >> m;
    int h[n];
    rep(i,n) cin >> h[i];
    bool g[n];
    rep(i,n) g[i] = true;

    rep(i,m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        if (h[b] >= h[a]) g[a] = false;
        if (h[a] >= h[b]) g[b] = false;
    } 

    int ans = 0;
    rep(i,n) if (g[i]) ans++;

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


Measured memory_bytes: 4104
from numba import njit
import numpy as np


@njit
def main(N, K, A):
    for _ in range(min(K, 41)):
        ne = np.zeros_like(A)
        for i in range(N):
            ne[max(0, i-A[i])] += 1
            if i+A[i]+1 < N:
                ne[i+A[i]+1] -= 1
        A = ne.cumsum()
    return A


N, K = map(int, input().split())
A = np.array(input().split(), np.int64)
ans = main(N, K, A)
print(*ans)


Measured memory_bytes: 124900