akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define dump(x) cerr<<#x<<": "<<(x)<<endl
using namespace std;
using vint = vector<int>;
using ll = long long;
using vll = vector<ll>;
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

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

    int A, B;
    cin >> A >> B;
    cout << max(A + B, max(A - B, A * B)) << endl;
}

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

int main(){
	int N;
	char S[50];
	int i,j,count=0;

	cin>>N;
	cin>>S;

	for(i=0;i<N-2;i++){
		if(S[i]=='A' && S[i+1]=='B' && S[i+2]=='C') count++;
	}

	cout<<count<<endl;
	return 0;
}


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

int main(){
	int A,B;
  cin>>A>>B;
  int K=B;
  int count=0;
  for(int i=0;i<3;i++){
      K=K/10;
      count++;
      if(K==0)
        break;
    }
  int X=A*pow(10,count)+B;
  for(int i=0;i<340;i++){
  	if(X==pow((i+1),2)){
      cout<<"Yes"<<endl;
      X=0;
      break;
    }
  }
  if(X!=0)
    cout<<"No"<<endl;
}

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

using namespace std;

int main() {
  vector<bool> used(4, false);
  for (int i = 0; i < 2; i++) {
    int A;
    cin >> A;
    used[A] = true;
  }

  for (int i = 1; i <= 3; i++) {
    if (!used[i]) {
      cout << i << endl;
      break;
    }
  }

  return 0;
}


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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

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

constexpr llong mod = 1e9;
constexpr llong inf = mod * mod;

int main() {
  llong N;

  cin >> N;
  __int128_t ans = 1;
  for (int i = 0; i < N; ++i) {
    llong in;
    cin >> in;
    if (ans <= inf || in == 0) {
      ans *= in;
    }
  }
  if (ans > inf) {
    ans = -1;
  }

  cout << llong(ans) << endl;

  return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
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; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

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

  bool ans = false;
  rep(i, ll(s.size())) {
    if (s.substr(s.size()-i, i) + s.substr(0, s.size()-i) == t) ans = true;
  }

  if (ans) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 3640
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;

//List of Top 3 Hills
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Queue<Integer> q = new PriorityQueue<Integer>(10, new Comparator<Integer>(){
			public int compare(Integer o1, Integer o2) {
				return o2-o1;
			}
		});
		for(int i=0;i<10;i++)q.add(sc.nextInt());
		for(int i=0;i<3;i++)System.out.println(q.poll());
	}
}

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

int main(){
    string c;
    char tmp;
    cin >> c;

    if(c.size()==2)
        cout << c << endl;
    else{
        tmp = c[0];
        c[0] = c[2];
        c[2] = tmp;
        cout << c <<endl;
    }
    return 0;
}


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

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

  vector<vector<int>> dp(s.length() + 1, vector<int>(t.length() + 1, 0));
  for (int i = 0; i < s.length(); i++) {
    for (int j = 0; j < t.length(); j++) {
      if (s.at(i) == t.at(j)) {
        dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + 1);
      }
      dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i + 1][j + 1]);
      dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i + 1][j + 1]);
    }
  }

  int i = s.length();
  int j = t.length();
  int len = dp[i][j];
  string ans = "";
  while (len > 0) {
    while (dp[i][j] == dp[i - 1][j]) i--;
    while (dp[i][j] == dp[i][j - 1]) j--;
    if (dp[i][j] - 1 == dp[i - 1][j - 1]) {
      len--;
      i--;
      j--;
      ans = s.at(i) + ans;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 37120
s = list(map(int, input()))

ans = []

for i in range(8):
        isseven = 0
        ans = []
        if i < 4:
            isseven += (s[0] + s[1])
            ans.append('+')
        else:
            isseven += (s[0] - s[1])
            ans.append('-')
        if i % 4 == 0 or i % 4 == 1:
            isseven += s[2]
            ans.append('+')
        else:
            isseven -= s[2]
            ans.append('-')
        if i % 2 == 0:
            isseven += s[3]
            ans.append('+')
        else:
            isseven -= s[3]
            ans.append('-')
        if isseven == 7:
            break

for i in range(3):
    print(str(s[i]) + ans[i], end = '')

print(str(s[3]) + "=7")


Measured memory_bytes: 3064
#include<iostream>
#include<bitset>
#include<string>
#include<cmath>
using namespace std;
bool iseven(int x){ return x % 2 == 0; }
bool isodd(int x){ return !iseven(x); }
int dist(int x, int y) { return abs(x - y); }
int pow(int x, int y){
    // x^y
    int ret = 1;
    for (int i = 0; i < y; i++) ret *= x;
    return ret;
}
int main(){
    int D, N;
    cin >> D >> N;
    // 100でD回割り切れる数字 -> 100 ^ D * N
    // ただし，N=100に関してはちょうどD+1回割り切れてしまうため不適
    if (N < 100) cout << pow(100, D) * N;
    else cout << pow(100, D) * (N+1);
    //int tmp = 1;
    //for(int i = 0; i < D; i++) tmp *= 100;
    //if (N == 100) cout << tmp * (N+1);
    //else cout << tmp * N;
    //cout << "test" << pow(10, 0);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#define MOD 1e9+7
using namespace std;

int N,ans=0;
int a[100001],b[100001];
int main(){
  cin >> N;
  for(int i=0;i<N;i++)cin >> a[i];
  for(int i=0;i<N;i++){
    int x=a[i];
    b[x]++;
    b[x+1]++;
    if(x>0)b[x-1]++;
  }
  for(int i=0;i<=100001;i++){
    ans=max(ans,b[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a;
    cin >> a;
    if(a==1){
        cout << "Hello World" << endl;
    }else{
        int b, c;
        cin >> b >> c;
        cout << c + b << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
A,B = map(int,input().split())

S = input()

def it():
  try:
    for c in S[:A]:
      yield int(c) in range(10)
    yield S[A] == '-'
    for c in S[A+1:]:
      yield int(c) in range(10)
  except ValueError:
    yield False

print('Yes' if all(it()) else 'No')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1000000007;
constexpr ll mod998=998244353;


int N,M,A[1000],B[1000],C[1000],D[1000],E[1000],F[1000];
ll res;
vector<ll>H,W;
vector<vector<int>>U,L;
vector<vector<bool>>vis;

int id(vector<ll>&V,ll x){
	return lower_bound(V.begin(),V.end(),x)-V.begin();
}

int main(){
	cin>>N>>M;
	for(int i=0;i<N;i++){
		cin>>A[i]>>B[i]>>C[i];
	}
	for(int i=0;i<M;i++){
		cin>>D[i]>>E[i]>>F[i];
	}
	for(int i=0;i<N;i++){
		H.push_back(A[i]);
		H.push_back(B[i]);
		W.push_back(C[i]);
	}
	for(int i=0;i<M;i++){
		H.push_back(D[i]);
		W.push_back(E[i]);
		W.push_back(F[i]);
	}
	H.push_back(0);
	W.push_back(0);
	H.push_back(-1111111111);
	H.push_back(1111111111);
	W.push_back(-1111111111);
	W.push_back(1111111111);
	sort(H.begin(),H.end());
	sort(W.begin(),W.end());
	H.erase(unique(H.begin(),H.end()),H.end());
	W.erase(unique(W.begin(),W.end()),W.end());
	U=L=vector<vector<int>>(H.size(),vector<int>(W.size(),0));
	vis=vector<vector<bool>>(H.size(),vector<bool>(W.size(),false));
	for(int i=0;i<N;i++){
		L[id(H,A[i])][id(W,C[i])]++;
		L[id(H,B[i])][id(W,C[i])]--;
	}
	for(int i=0;i<M;i++){
		U[id(H,D[i])][id(W,E[i])]++;
		U[id(H,D[i])][id(W,F[i])]--;
	}
	for(int i=1;i<H.size()-1;i++){
		for(int j=1;j<W.size()-1;j++){
			L[i][j]+=L[i-1][j];
			U[i][j]+=U[i][j-1];
		}
	}
	queue<pair<int,int>>que;
	que.push({id(H,0),id(W,0)});
	while(!que.empty()){
		int x,y;
		x=que.front().first;
		y=que.front().second;
		que.pop();
		if(x==0||x==H.size()-1||y==0||y==W.size()-1){
			puts("INF");
			return 0;
		}
		if(!vis[x][y]){
			vis[x][y]=true;
			res+=(H[x+1]-H[x])*(W[y+1]-W[y]);
			if(!U[x][y])que.push({x-1,y});
			if(!L[x][y])que.push({x,y-1});
			if(!U[x+1][y])que.push({x+1,y});
			if(!L[x][y+1])que.push({x,y+1});
		}
	}
	cout<<res<<endl;
}


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

using namespace std;

#define REP(i, N) for (int i = 0; i < (int)N; i++)
#define RREP(i, N) for (int i =(int)N-1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define INF (1 << 30)
#define LLINF (1LL << 62)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

typedef long long ll;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;


int main(){
  int n;
  cin>>n;
  ll sum=0;
  string vs[n];
  REP(i,n){
    string tmp;
    cin>>tmp;
    sort(tmp.begin(),tmp.end());
    vs[i]=tmp;
  }
  sort(vs,vs+n);
  REP(i,n){
    string tmp;
    tmp=vs[i];
    ll count=1;
    while(vs[i]==vs[i+1]&&i<n){
      i++;
      count++;
    }
    sum+=count*(count-1)/2;
  }
  cout<<sum<<endl;
}

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

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

    int ans = 0;
    for(int i = 1; i < n - 2; i++){
        string tmp1 = str.substr(0, i);
        string tmp2 = str.substr(i, n - 1);

        sort(tmp1.begin(), tmp1.end());
        sort(tmp2.begin(), tmp2.end());

        decltype(tmp1)::iterator res1 = unique(tmp1.begin(), tmp1.end());
        tmp1.erase(res1, tmp1.end());
        decltype(tmp2)::iterator res2 = unique(tmp2.begin(), tmp2.end());
        tmp2.erase(res2, tmp2.end());
        //cout << "tmp1:" << tmp1 << endl;
        //cout << "tmp2:" << tmp2 << endl << endl;;

        int cnt = 0;
        for(int j = 0; j < tmp1.size(); j++){
            for(int k = 0; k < tmp2.size(); k++){
                if(tmp1[j] == tmp2[k]){
                    cnt++;
                    break;
                }
            }
        }
        if(cnt > ans){
            ans = cnt;
        }
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;

int main(int argc, char const *argv[])
{
    int a, b;
    cin >> a >> b;
    for (int i = 0; i < max(a, b); i++)
    {
        cout << min(a, b);
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
import Control.Monad
import Data.List

main = do
  li <- getLine
  let n = read li :: Int
  ss <- sequence $ replicate n getLine
  let ans = compute ss
  print ans

compute :: [String] -> Int
compute ss = sum $ map (f.length) $ group $ sort $ map sort ss
  where
    f n = (n-1) * n `div` 2


Measured memory_bytes: 114044
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace AtC
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = ReadInt();
            var A = ReadIntArray();
            int oddCount = 0;
            foreach (var i in A)
            {
                if ((i & 1) == 1) oddCount++;
            }

            Out((oddCount & 1) == 0 ? "YES" : "NO");
        }

        //最小公倍数
        static int LCM(int num1, int num2)
        {
            var gcd = GCD(num1, num2);
            return num1 * (num2 / gcd);
        }

        static long LCM(long num1, long num2)
        {
            var gcd = GCD(num1, num2);
            return num1 * (num2 / gcd);
        }

        //最大公約数
        static int GCD(int num1, int num2)
        {
            int a = Math.Max(num1, num2);
            int b = Math.Min(num1, num2);
            int mod;
            while ((mod = a % b) != 0)
            {
                a = b;
                b = mod;
            }

            return b;
        }

        static long GCD(long num1, long num2)
        {
            long a = Math.Max(num1, num2);
            long b = Math.Min(num1, num2);
            long mod;
            while ((mod = a % b) != 0)
            {
                a = b;
                b = mod;
            }

            return b;
        }

        static int[] ReadIntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }

        static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }

        static long[] ReadLongArray()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }

        static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }

        static string ReadString()
        {
            return Console.ReadLine();
        }

        static void Out(object o)
        {
            Console.WriteLine(o);
        }
    }

    static class EnumerableExtension
    {
        public delegate void Function<in T>(T val);

        public static void ForEach<T>(this IEnumerable<T> enumerable, Function<T> function)
        {
            foreach (var x in enumerable)
            {
                function(x);
            }
        }
    }

    class PriorityQueue<T>
    {
    }
}

Measured memory_bytes: 21600
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <algorithm>
#include <sstream>
#include <istream>

using namespace std;

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

int main(){
	ll l,r;
	cin >> l >> r;

	ll ans = 2018;

	r = min(r,l+2019);

	for(ll i=l;i<r;i++){
		for(ll j=l+1;j<=r;j++){
			ans = min((i%2019)*(j%2019)%2019,ans);
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <iostream>
#include <numeric>
#include <math.h>
#define ll long long
#define ull long
#define mpa make_pair
#define pb push_back
#define ff first
#define pii pair<ll,ll>
#define dd double
#define trace(x) cerr << #x << " : " << x << endl
#define ss second
#define boost ios_base::sync_with_stdio(0)
#define forp(i,a,b) for(ll i=a;i<=b;i++)
#define rep(i,n)    for(ll i=0;i<n;++i)
#define ren(i,n)    for(ll i=n-1;i>=0;i--)
#define forn(i,a,b) for(ll i=a;i>=b;i--)
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin()) i = (c).begin(); i != (c).end();
#define sc(x) scanf("%lld",&x)
#define clr(x,val) memset(x,val,sizeof(x))
#define pr(x) printf("%lld\n",x) 
#define gc getchar
#define pdd pair<dd,dd>
#define prec(x) cout<<fixed<<setprecision(x)
#define fre freopen("input.txt","r",stdin),freopen("output.txt","w",stdout)
using namespace std;
map<ll,ll> help;
ll a[55][55];
ll b[55][55];
int main(){
   ll n,d;
   cin>>n>>d;
   ll ans=0;
   
   for(ll i=1;i<=n;i++){
   	   ll x,y;
   	   cin>>x>>y;
   	   if(x*x+y*y<=d*d)ans++;
   }
   cout<<ans;
   
}
	
 
    

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

using namespace std;

int ball_db[10];

void solve()
{
    vector<int> left;
    vector<int> right;

    left.push_back(0);
    right.push_back(0);

    for (int i = 0; i < 10; ++i) {
        if (ball_db[i] > left.back()) {
            left.push_back(ball_db[i]);
        } else if (ball_db[i] > right.back()) {
            right.push_back(ball_db[i]);
        } else {
            cout << "NO" << endl;
            return;
        }
    }

    if (left.size() + right.size() == 10 + 2) {
        cout << "YES" << endl;
    }
}

int main()
{
    int data_num;

    cin >> data_num;

    for (int i = 0; i < data_num; ++i) {
        for (int j = 0; j < 10; ++j) {
            cin >> ball_db[j];
        }
        solve();
    }


    return 0;
}

Measured memory_bytes: 1208
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define vvec vector<vector<ll>>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
//ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 1000000007;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll c(ll n, ll k) { ll a = 1; rep(i, 1, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }

int main(void) {
	double a, b, h, m, k1, k2;
	cin >> a >> b >> h >> m;
	k1 = (h * 60 + m) * 2 / 12 / 60 * M_PI;
	k2 = (m) * 2 / 60 * M_PI;
	printf("%.10f\n", sqrt(a * a + b * b - 2 * a * b * cos(k1 - k2)));
	return 0;
}


Measured memory_bytes: 4196
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

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

int main(){
  cout << std::fixed << std::setprecision(16);
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  int n;
  cin>>n;
  std::vector<std::vector<int>> result;
  int first_push_pos=0;
  int second_push_pos=1;
  result.push_back(std::vector<int>(0));
  result.push_back(std::vector<int>(0));
  for(int i=1;i<=n;i++){
    if(first_push_pos==second_push_pos){
      result.push_back(std::vector<int>(0));
      first_push_pos=0;
      second_push_pos++;
    }
    result[first_push_pos].push_back(i);
    result[second_push_pos].push_back(i);
    first_push_pos++;

  }

  int size=result[0].size();
  for(auto v:result){
    if(size!=v.size()){
      cout<<"No"<<endl;
      exit(0);
    }
  }

  cout<<"Yes"<<endl;
  cout<<result.size()<<endl;
  for(auto v:result){
    cout<<v.size()<<" ";
    for(int i=0;i<v.size()-1;i++){
      cout<<v[i]<<" ";
    }
    cout<<v.back()<<endl;
  }

  return 0;
}

Measured memory_bytes: 2304
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():
    N = in_n()
    A = [0] + in_nl() + [0]
    N = N + 2

    dsum = 0
    for i in range(N - 1):
        dsum += abs(A[i + 1] - A[i])

    ans = [0] * (N - 2)
    for i in range(1, N - 1):
        if A[i - 1] <= A[i] and A[i] <= A[i + 1]:
            ans[i - 1] = dsum
        elif A[i - 1] >= A[i] and A[i] >= A[i + 1]:
            ans[i - 1] = dsum
        elif A[i - 1] <= A[i] and A[i] >= A[i + 1]:
            ans[i - 1] = dsum - abs(A[i - 1] - A[i]) - abs(A[i] - A[i + 1]) + abs(A[i - 1] - A[i + 1])
        elif A[i - 1] >= A[i] and A[i] <= A[i + 1]:
            ans[i - 1] = dsum - abs(A[i - 1] - A[i]) - abs(A[i] - A[i + 1]) + abs(A[i - 1] - A[i + 1])

    print('\n'.join(map(str, ans)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 24292
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
using namespace std;


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

int main(){
  string s;
  cin >> s;
  char tmp = s[0];
  bool hantei = false;
  for(int i = 1; i < s.length(); ++i){
    if(s[i] == tmp){
      hantei = true;
    } else {
      tmp = s[i];
    }
  }

  string ans;
  if(hantei){
    ans = "Bad";
  } else {
    ans = "Good";
  }

  cout << ans << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int L,R,d;
  cin >> L >> R >> d;
  int count=0;
  for(int i=L;i<=R;i++){
    if(i%d==0){
      count++;
    }
  }
  cout << count;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    ll N;
    cin >> N;
    vector<ll> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    map<ll, ll> mp;
    REP(i, N){
        mp[A[i]]++;
    }

    ll tot = 0;
    for(auto&& m : mp){
        ll ms = m.se;
        if(ms <= 1) continue;
        tot += ms*(ms-1)/2;
    }

    REP(i, N){
        ll ai = mp[A[i]];
        ll an = (ai<=1?0:ai*(ai-1)/2);
        ll next = (ai<=2?0:(ai-1)*(ai-2)/2);
        pr(tot-an+next);
    }
}

Measured memory_bytes: 11008
use std::io::*;
use std::str::*;
use std::cmp;

fn read<T: FromStr>(s: &mut StdinLock) -> T {
    let s = s.by_ref().bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}


fn main() {
    let s = stdin();
    let mut s = s.lock();
    let s = &mut s;

	let a = read::<i64>(s);
	let b = read::<i64>(s);
	let c = read::<i64>(s);
	let d = read::<i64>(s);

	let minab: i64 = cmp::min(a,b);
	let maxab: i64 = cmp::max(a,b);
	let mincd: i64 = cmp::min(c,d);
	let maxcd: i64 = cmp::max(c,d);

	let mut maxv = std::i64::MIN;

	if minab*mincd > maxv { maxv = minab*mincd; }
	if minab*maxcd > maxv { maxv = minab*maxcd; }
	if maxab*mincd > maxv { maxv = maxab*mincd; }
	if maxab*maxcd > maxv { maxv = maxab*maxcd; }


	println!("{}", maxv);


}



Measured memory_bytes: 2140
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  string s;
  cin >> s;
  ll sum;
  rep(i, s.size()) sum += (s[i] - '0');
  ll n = stoi(s);
  cout << (n % sum ? "No" : "Yes") << endl;
}

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

int main()
{
    int n;
    cin>>n;
    int q[n];
    for(int i=0;i<n;i++)
        cin>>q[i];
    for(int i=n-1;i>=0;i--)
        if(i==0) cout<<q[i];
        else cout<<q[i]<<' ';
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3084
#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++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
int main(){
	int N;
	map<int,int> mp;
	cin>>N;
	rep(i,N){
		int x;
		cin>>x;
		mp[x]++;
	}
	int M;
	cin>>M;
	rep(i,M){
		int x;
		cin>>x;
		mp[x]--;
		if(mp[x]<0){
			puts("NO");
			return 0;
		}
	}
	puts("YES");
}


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

void solve() 
{
    int n;map<int,int>m;
    cin>>n;
    REP(i,n-1){
        int x;cin>>x;x--;
        m[x]++;
    }
    REP(i,n){
        cout<<m[i]<<endl;
    }
}

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

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

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int N,i;

signed main() {
    cin >> N>>i;
    cout<<N-i+1<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

long long count(long long n, vector<long long>& vct, long long s) {
    long long cnt = 0;
    for (int i = 0; i < n; i++) {
        if (vct[i] * 2 >= s) {
            int l = i;
            int r = n - 1;
            while (l < r) {
                int mid = (l + r) / 2 + 1;
                if (vct[i] + vct[mid] >= s) {
                    l = mid;
                } else {
                    r = mid - 1;
                }
            }
            cnt += 1 + 2 * (l - i);
        }
    }
    return cnt;
}

long long calculate(long long n, long long m, vector<long long>& vct, vector<long long>& svct, long long s) {
    long long cnt = 0;
    long long val = 0;
    for (int i = 0; i < n; i++) {
        if (vct[i] * 2 >= s) {
            int l = i;
            int r = n - 1;
            while (l < r) {
                int mid = (l + r) / 2 + 1;
                if (vct[i] + vct[mid] >= s) {
                    l = mid;
                } else {
                    r = mid - 1;
                }
            }
            val += vct[i] * 2 + 2 * (svct[l + 1] - svct[i + 1] + vct[i] * (l - i));
            cnt += 1 + 2 * (l - i);
        }
    }
    val -= s * (cnt - m);
    return val;
}

int main() {
    long long n, m;
    scanf("%lld %lld", &n, &m);

    vector<long long> vct = vector<long long>(n);
    for (int i = 0; i < n; i++) {
        scanf("%lld", &vct[i]);
    }
    sort(vct.rbegin(), vct.rend());

    vector<long long> svct = vector<long long>(n + 1);
    for (int i = 0; i < n; i++) {
        svct[i + 1] = svct[i] + vct[i];
    }

    long long l = 1;
    long long r = 2000000;
    while (l < r) {
        int mid = (l + r) / 2 + 1;
        long long cnt = count(n, vct, mid);
        if (cnt >= m) {
            l = mid;
        } else {
            r = mid - 1;
        }
    }

    long long res = calculate(n, m, vct, svct, l);
    printf("%lld\n", res);
}

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;

const int inf=1<<30;
const long long int infll=1LL<<58;
const double eps=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
	os << "[";
	for (const auto &v : vec) {
		os << v << ",";
	}
	os << "]";
	return os;
}

int dp[100][5040];

map<vector<int>,int> encode;
map<int,vector<int>> decode;

int brute(int n,vector<int>& d,vector<int>& a){
    vector<int> order(n);
    rep(i,0,n) order[i]=i;
    int cnt=0,res=0;
    do{
        int tmp=0;
        vector<int> taste(n);
        for(int idx:order){
            tmp+=taste[idx];
            rep(i,max(0,idx-d[idx]),min(n,idx+d[idx]+1)) taste[i]+=a[idx];
        }
        encode[order]=cnt;
        decode[cnt]=order;
        dp[n-1][cnt]=tmp;
        res=max(res,tmp);
        ++cnt;
    }while(next_permutation(order.begin(),order.end()));
    return res;
}

void solve(){
    int n;
    cin >> n;
    vector<int> d(n),a(n);
    for(int& in:d) cin >> in;
    for(int& in:a) cin >> in;

    if(n<=7){
        cout << brute(n,d,a) << endl;
        return;
    }else brute(7,d,a);

    rep(i,7,n){
        rep(j,0,5040){
            vector<int> order=decode[j],next(8),form(7);
            rep(pos,0,8){
                next[pos]=7;
                rep(k,0,7) next[k+(k>=pos)]=order[k];
                int tmp=0;
                vector<int> taste(n);
                rep(k,0,8){
                    int p=i-7+next[k];
                    tmp+=taste[p];
                    rep(a_,max(i-7,p-d[p]),min(i+1,p+d[p]+1)) if(a_==i or p==i) taste[a_]+=a[p];
                }
                int cnt=0;
                rep(k,0,8) if(next[k]!=0){
                    form[cnt]=next[k]-1;
                    ++cnt;
                }
                int e=encode[form];
                dp[i][e]=max(dp[i][e],dp[i-1][j]+tmp);
            }
        }
    }

    cout << *max_element(dp[n-1],dp[n-1]+5040) << endl;
}

int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	solve();
	return 0;
}

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

#define FAST std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define DECIMAL(n)  std::cout << std::fixed;std::cout << std::setprecision(n);
#define hell 1000000007
#define PI 3.14159265358979323844
#define mp make_pair
#define pb push_back
#define fi first 
#define se second
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))  
#define REVERSE(v) reverse(ALL(v))
#define endl "\n"
#define maxc(v) max_element(all(v))
#define minc(v) min_element(all(v))
#define GCD(m,n) __gcd(m,n)
#define LCM(m,n) m*(n/GCD(m,n))
#define inputarr(a,n) for(int i=0;i<n;++i) cin>>a[i]
#define initarr(a,n,x) for (int i=0;i<n;++i) a[i]=x
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define sz(a) (int)a.size()
#define sl(a) (int)a.length()
#define invect(data,n,commands) for(int i = 0;i<n;i++){int tmp;cin>>tmp;data.pb(tmp);commands}
#define inset(data,n,commands) for(int i = 0;i<n;i++){int tmp;cin>>tmp;data.insert(tmp);commands}
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}

#define ll long long
#define ld long double 
#define pii std::pair<int, int> 
#define pll std::pair<ll, ll>  
#define vi vector<int>  
#define vvi vector<vi > 
#define vii vector<pii >

pii operator+(pii a, pii b)
{
    return {a.fi+b.fi,a.se+b.se};
}
pll operator+(pll a, pll b)
{
    return {a.fi+b.fi,a.se+b.se};
}
std::ostream& operator<<(std::ostream& out,pii a)
{
    out<<a.fi<<" "<<a.se<<endl;
    return out;
}
std::ostream& operator<<(std::ostream& out,pll a)
{
    out<<a.fi<<" "<<a.se<<endl;
    return out;
}
std::istream& operator>>(std::istream& in,pii &a)
{
    in>>a.fi>>a.se;
    return in;
}
std::istream& operator>>(std::istream& in,pll &a)
{
    in>>a.fi>>a.se;
    return in;
}

using namespace std;

int main()
{
    FAST;
    int n,k;
    cin>>n>>k;
    int h[n];
    inputarr(h,n);
    ll dp[n];
    dp[0]=0;
    dp[1]=dp[0]+abs(h[1]-h[0]);
    for (int i = 2; i < n; ++i)
    {
        dp[i]=dp[i-1]+abs(h[i]-h[i-1]);
        for (int j = max(0,i-k); j <i; ++j)
        {
            dp[i]=min(dp[i],dp[j]+abs(h[j]-h[i]));
        }
    }
    cout<<dp[n-1];


}

Measured memory_bytes: 1408
#include<iostream>

using namespace std;
#define int long long int

signed main()
{
	int x1,x2,y1,y2;
	int x3,x4,y3,y4;
	cin>>x1>>y1>>x2>>y2;

	x3=(x2-(y2-y1));
	y3=(y2+(x2-x1));
	x4=(x1-(y2-y1));
	y4=(y3-(y2-y1));
	cout<<x3<<" "<<y3<<" "<<x4<<" "<<y4;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define ll long long
using namespace std;

ll n,t[1005],a[1005];

int main() {
	#ifdef kvutxdy
	freopen("C:/Users/khanh/OneDrive/RoadtoPurple/Code/Codeforces/input.in", "r", stdin);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cin>>n;
	for(int i=0;i<n;++i) cin>>t[i]>>a[i];
	ll res_t=t[0],res_a=a[0];
	for(int i=1;i<n;++i){
		ll k_t=res_t/t[i]+(res_t%t[i]>0);
		ll k_a=res_a/a[i]+(res_a%a[i]>0);
		res_t=max(k_t,k_a)*t[i];
		res_a=max(k_t,k_a)*a[i];
	}
	cout<<res_t+res_a;
}

Measured memory_bytes: 256
/*
	@・ω・@ <だれだろうね
*/

/*****/

#include <iostream>
#include <array>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <iomanip>	//cout << fixed << setprecision(桁数);
#include <stdexcept>
#include <fstream>

//#define int long long

using namespace std;
using ll = long long;
using ld = long double;
using pll = pair<long long, long long>;
template<class T> using pr = pair<T, T>;
template<class T> using vec = vector<T>;

#define debug(x) (std::cerr << x)
#define debugln(x) (std::cerr << x << "\n")
#define debug_tab(n, x) (std::cerr << strMulti("\t",n) << (x) << "\n")
#define debug_cout(x) (std::cerr << #x << " : " <<  (x) << "\n")
#define debug_tabcout(n, x) (std::cerr << strMulti("\t",n) << #x << " : " <<  (x) << "\n")
#define debug_headcout(h, x) (std::cerr << h << " : " <<  (x) << "\n")
#define debug_tabheadcout(n, h, x) (std::cerr << strMulti("\t",n) << h << " : " <<  (x) << "\n")

#define str(n)	(n.toString())

#define rep(i, n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i, n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i, n) for(ll i=(n)-1; i >= 0; --i)
#define rrep1(i, n) for(ll i=(n); i > 0; --i)
#define step(i, a, n) for(ll i=(a), i##_len=(a)+(n); i<i##_len; ++i)
#define rstep(i, a, n) for(ll i=(a)+(n)-1, i##_len=(a); i>=i##_len; --i)
#define range(i, a, b) for(ll i=(a), i##_len=(b); i<i##_len; ++i)
#define rrange(i, a, b) for(ll i=(b)-1, i##_len=(a); i>=i##_len; --i)
#define all(x) (x).begin(), (x).end()
#define pair(a, b) make_pair(a, b)
constexpr int INF = 2000000100;
constexpr ll MOD = 1000000007;	// 10e9+7
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> T divup(T a, T b) { if (a % b == 0) { return a / b; } return a / b + 1; }
std::string strMulti(std::string t, int n) { std::string out = ""; for (int i = 0; i < n; i++) { out += t; } return out; }
template<class T> T math_P(T m, T n) { T ret = 1; for (T i = m; i > m - n; i--) { ret *= i; } return ret; }
template<class T> T math_C(T m, T n) { T ret = math_P(m, n); for (T i = 2; i <= n; i++) { ret /= i; } return ret; }
template<class T> bool cmp_2nd(pair<T, T> a, pair<T, T> b) { if (a.second != b.second) { return a.second < b.second; } return a.first < b.first; }
template<class T> T mod_pow(T x, T n, const T& p) { T ret = 1; while (n > 0) { if (n & 1) { (ret *= x) %= p; } (x *= x) %= p; n >>= 1; } return ret; }

/*****/

ll K;

void Main()
{
	cin >> K;

	queue<ll> Q;
	rep1(i, 9)
	{
		Q.push(i);
	}

	rep(i, K - 1)
	{
		ll n = Q.front();
		//debug_headcout(i, n);
		Q.pop();

		ll a = n % 10;

		n *= 10;

		range(b, max(0ll, a - 1), min(9ll, a + 1) + 1)
		{
			Q.push(n + b);
		}
	}

	cout << Q.front();
}

/*****/

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

	//std::cout << std::fixed << std::setprecision(10);

	/**
	while (true)
	{
		Main();
		std::cerr << flush;
		cout << endl;
	}
	/*/
	Main();
	std::cerr << flush;
	cout << endl;
	/**/

	return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <algorithm>
using namespace std;
using ll = long long;

int n, k, h[100010];
int main() {
	scanf("%d %d", &n, &k);
	for (int i = 0; i < n; i++)
		scanf("%d", h + i);
	int count = 0;
	for (int i = 0; i < n; i++)
		count += k <= h[i];
	printf("%d\n", count);
}

Measured memory_bytes: 512
//Utkarsh.25dec
#include <bits/stdc++.h>
#include <chrono>
#include <random>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// ordered_set s ; s.order_of_key(val)  no. of elements strictly less than val
// s.find_by_order(i)  itertor to ith element (0 indexed)
typedef vector<vector<ll>> matrix;
ll power(ll a,ll b) {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 modInverse(ll a){return power(a,mod-2);}
const int N=500023;
bool vis[N];
vector <int> adj[N];
ll ans[505][505];
void solve()
{
    int H,W,h,w;
    cin>>H>>W>>h>>w;
    if((H%h==0)&&(W%w==0))
    {
        cout<<"No\n";
        return;
    }
    int flag=0;
    if((H%h)==0)
    {
        swap(H,W);
        swap(h,w);
        flag=1;
    }
    ll pos=1000*(h-1)-1;
    ll neg=-1000;
    for(int i=0;i<H;i++)
    {
        for(int j=0;j<W;j++)
        {
            if((i%h)==0)
                ans[i][j]=pos;
            else
                ans[i][j]=neg;
        }
    }
    cout<<"Yes\n";
    if(flag==0)
    {
        for(int i=0;i<H;i++)
        {
            for(int j=0;j<W;j++)
                cout<<ans[i][j]<<' ';
            cout<<'\n';
        }
    }
    else
    {
        for(int i=0;i<W;i++)
        {
            for(int j=0;j<H;j++)
                cout<<ans[j][i]<<' ';
            cout<<'\n';
        }
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    //cin>>T;
    int t=0;
    while(t++<T)
    {
        //cout<<"Case #"<<t<<":"<<' ';
        solve();
        //cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 15488
N, M = [int(_) for _ in input().split()]
KA = [[int(_) for _ in input().split()] for i in range(N)]

from collections import defaultdict

cs = defaultdict(int)

for r in KA:
    for n in r[1:]:
        cs[n] += 1

result = sum([cs[k] == N for k in cs])

print(result)


Measured memory_bytes: 3564
fun main(args: Array<String>) {
    var a = 0.toDouble()
    for(i in 0 until readLine()!!.toInt()) {
        var l = readLine()!!.split(" ")
        when(l[1]){
            "JPY" -> a += l[0].toDouble()
            "BTC" -> a += l[0].toDouble() * 380000.0
        }
    }
    println(a)
}

Measured memory_bytes: 36232
def is_MMYY(xx, yy):
    if (xx >= 1) and (xx <= 12):
        return True
    return False

def is_YYMM(xx, yy):
    if (yy >= 1) and (yy <= 12):
        return True
    return False

S = list(input())

xx = int("".join(S[:2]))
yy = int("".join(S[2:]))

if is_MMYY(xx, yy) and is_YYMM(xx, yy):
    print("AMBIGUOUS")
elif is_MMYY(xx, yy):
    print("MMYY")
elif is_YYMM(xx, yy):
    print("YYMM")
else:
    print("NA")


Measured memory_bytes: 3064
/*********************************************JMD**********************************************/
//                                  |\  |     | |   |   /\                                   //
    //                              | \ |     | |---|  /--\                              //
        //                          |  \| |___| |   | /    \1999                     //
/*******************************************************************************************/
#include <bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;

#define mp make_pair
#define pb push_back
#define pf push_front
#define ss second
#define ff first
#define mem(x,val) memset(x,val,sizeof(x))
#define forr(i,a,b) for(ll i=a;i<b;i++)
#define f(i,n) forr(i,0,n)
#define sz(x) ll((x).size())
#define all(x) ((x).begin(),(x).end())
#define asc(x) ((int)(x))
#define precision(x) cout<<fixed<<setprecision((x));

const ll mod=1e9 + 7;

/*******************************************************************************************/

void solve()
{
    ll n;
    cin>>n;
    string s;
    cin>>s;

    ll a[n][3];

    f(i,n)f(j,3) a[i][j]=0;

    ll tr=0,tb=0,tg=0;

    f(i,n)
    {
        if(s[i]=='R') tr++;
        else if(s[i]=='B') tb++;
        else if(s[i]=='G') tg++;
    }

    a[0][0]=tr;
    a[0][1]=tb;
    a[0][2]=tg;

    if(s[0]=='R') a[0][0]--;
    if(s[0]=='B') a[0][1]--;
    if(s[0]=='G') a[0][2]--;

    for(ll i=1;i<n;i++)
    {
        a[i][0]=a[i-1][0];
        a[i][1]=a[i-1][1];
        a[i][2]=a[i-1][2];

        if(s[i]=='R') a[i][0]--;
        if(s[i]=='B') a[i][1]--;
        if(s[i]=='G') a[i][2]--;
    }

    ll ans=0;

    for(ll i=0;i<n;i++)
    {
        for(ll j=i+1;j<n;j++)
        {
            if(s[i]!=s[j])
            {
                ll tot=0;
                if((2*j-i)<n && s[2*j-i]!=s[i] && s[2*j-i]!=s[j]) tot--;
                if((s[i]=='R' && s[j]=='B') || (s[i]=='B' && s[j]=='R'))
                {
                    tot+=a[j][2];
                }
                if((s[i]=='R' && s[j]=='G') || (s[i]=='G' && s[j]=='R'))
                {
                    tot+=a[j][1];
                }
                if((s[i]=='G' && s[j]=='B') || (s[i]=='B' && s[j]=='G'))
                {
                    tot+=a[j][0];
                }
                ans+=tot;
            }
        }
    }

    cout<<ans<<"\n";

    return;
}

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

    ll t=1;
    //cin>>t;
    clock_t launch=clock();

    while(t--)
    {
        solve();
    }

    clog<<((long double)(clock()-launch)/CLOCKS_PER_SEC)<<"\n";
}


Measured memory_bytes: 3900
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
string alphabet="abcdefghijklmnopqrstuvwxyz";
int main(){
    ll n;
    cin >> n;
    ll a[n];
    ll sum = 0;
    ll count[100001] = {0};
    for(ll i =0;i<n;i++){
        cin >> a[i];
        count[a[i]]++;
        sum += a[i];
    }
    ll q;
    cin >> q;
    while(q--){
        ll b,c;
        cin >> b >> c;
        if(count[b] == 0){
            cout << sum << '\n';
            continue;
        }
        count[c] += count[b];
        sum += count[b]*c;
        sum -= count[b]*b;
        count[b] = 0;
        cout << sum << '\n';
    }
}


Measured memory_bytes: 5108
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
bool uru[3000];

void q93() {
	memset(uru, 0, sizeof(uru));
	for (int i = 0; i < 3000; i += 4) {
		uru[i] = true;
	}
	for (int i = 0; i < 3000; i += 100) {
		uru[i] = false;
	}
	for (int i = 0; i < 3000; i += 400) {
		uru[i] = true;
	}

	int a, b;
bool first = true;
	for (; cin >> a >> b;) {
		if (a == b && !a) break;
if (first) first = false;
else cout << endl;
		bool print_flag = false;
		for (int i = a; i <= b; i++) {
			if (uru[i]) {
				cout << i  << endl;
				print_flag = true;
			}
		}
		if (!print_flag) cout << "NA" << endl;
	}
}
int main() {
	q93();
	return 0;
}

Measured memory_bytes: 3016
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <limits.h>

bool update(int*m, const std::vector<int>& max);

int main(int argc, char* argv[]){
  int n;
  std::ios::sync_with_stdio(false);

  int* a;
  std::cin >> n;
  std::cin.ignore();
  a = new int[n];
 
  for(int i = 0; i < n; i++){
    std::cin>> a[i];
  }

  std::vector<unsigned int> pow2;
  unsigned int p = 2;
  while(p < 1000000000){
    pow2.push_back(p);
    p *= 2;
  }

  int c = 0;
  for (int i = 0; i < n; i++){
    int c_i = 0;
    for (int j = 0; j < pow2.size(); j++){
      if ((a[i] % pow2[j]) == 0){
        c_i = j + 1;
      } else {
        break;
      }
    }
    c += c_i;
  }
  std::cout << c;
  delete [] a;
  return 0;  
}


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

int main() {
 int h,w;
  cin >> h >> w;
  vector<string> a(h);
  for(int i = 0; i<h; i++){
   cin >> a.at(i);
  }
  vector<bool> row(h, false);
  vector<bool> calm(w, false);
  for(int i=0; i < h; i++){
   for(int j=0; j<w; j++){
    if(a.at(i).at(j) == '#'){
     row.at(i) = true;
      calm.at(j) = true;
    }
   }
  }
  for(int i=0;i<h;i++){
   if(row.at(i)){
    for(int j=0;j<w;j++){
     if(calm.at(j)){
      cout << a.at(i).at(j); 
     }
    }
     cout << endl;
   }
  }
}


Measured memory_bytes: 3536
import Data.Char

main = interact $ show . sol . filter (isLetter)

sol s = f n $ take n s where n = length s-2

f n s
  | t == u    = n
  | otherwise = f (n-2) $ take (n-2) s
  where
  (t,u) = splitAt (n `div` 2) s

Measured memory_bytes: 4436