akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)

class Point
{
public:
  double x, y;
  Point(double x = 0, double y = 0) : x(x), y(y) {}

  Point operator+(Point p)
  {
    return Point(x + p.x, y + p.y);
  }
  Point operator-(Point p)
  {
    return Point(x - p.x, y - p.y);
  }
  Point operator*(double a)
  {
    return Point(a * x, a * y);
  }
  Point operator/(double a)
  {
    return Point(x / a, y / a);
  }

  double abs()
  {
    return sqrt(norm());
  }
  double norm()
  {
    return x * x + y * y;
  }

  bool operator<(const Point &p) const
  {
    return x != p.x ? x < p.x : y < p.y;
  }
  bool operator==(const Point &p) const
  {
    return equals(x, p.x) && equals(y, p.y);
  }

  void print()
  {
    printf("%.10f %.10f\n", x, y);
  }
};

typedef Point Vector;

double dot(Vector a, Vector b)
{
  return a.x * b.x + a.y * b.y;
}
double cross(Vector a, Vector b)
{
  return a.x * b.y - a.y * b.x;
}

struct Segment
{
  Point p1, p2;
};

typedef Segment Line;

class Circle
{
public:
  Point c;
  double r;
  Circle(Point c = Point(), double r = 0) : c(c), r(r) {}
};

typedef vector<Point> Polygon;

Point projection(Line l, Point p)
{
  return l.p1 + (l.p2 - l.p1) * (dot(p - l.p1, l.p2 - l.p1) / (l.p2 - l.p1).norm());
}

Point reflection(Line l, Point p)
{
  Point x = projection(l, p);
  return p + (x - p) * 2;
}

bool ccw(Point p0, Point p1, Point p2)
{
  Vector a = p1 - p0, b = p2 - p0;
  return cross(a, b) > 0;
}

bool cw(Point p0, Point p1, Point p2)
{
  Vector a = p1 - p0, b = p2 - p0;
  return cross(a, b) < 0;
}

int main()
{
  double x0, y0, x1, y1;
  cin >> x0 >> y0 >> x1 >> y1;
  Point p0 = {x0, y0}, p1 = {x1, y1};
  int q;
  cin >> q;
  rep(i, q)
  {
    double x2, y2;
    cin >> x2 >> y2;
    Point p2 = {x2, y2};
    Vector a = p1 - p0, b = p2 - p0;
    if (ccw(p0, p1, p2))
    {
      cout << "COUNTER_CLOCKWISE" << endl;
    }
    else if (cw(p0, p1, p2))
    {
      cout << "CLOCKWISE" << endl;
    }
    else if (a.x * b.x < 0 || a.y * b.y < 0)
    {
      cout << "ONLINE_BACK" << endl;
    }
    else if (a.norm() < b.norm())
    {
      cout << "ONLINE_FRONT" << endl;
    }
    else
    {
      cout << "ON_SEGMENT" << endl;
    }
  }
}


Measured memory_bytes: 3224
#include<iostream>
#include<algorithm>
using namespace::std;
#define int long long int

int ar[200005],sum;

main(){
  int n,k;
  cin>>n>>k;
  for(int i=0;i<n;i++)
    cin>>ar[i];
  sort(ar,ar+n,greater<int>());
  for(int i=k;i<n;i++)
    sum+=ar[i];
  cout<<sum<<'\n';
}

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

int main(){
    double a,b,h,m, x;
    scanf("%lf%lf%lf%lf",&a,&b,&h,&m);
    double y=m/2;
    if (h*5>=m){
        x=((h*5)-m)*6+y;
    }
    else{
        x=(m-(h*5))*6-y;
    }
    double ans=sqrt((a*a)+(b*b)-(2*a*b*cos(x* M_PI /180.0)));
    printf("%17.13f",ans);
}

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

using namespace std;

const int maxN = 555;
int a[maxN][maxN];
int st[maxN];
int row[maxN];

int main(void) {

    int n;
    cin >> n;
    int sum = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            char c;
            cin >> c;
            a[i][j] = c == '.' ? 0 : 1;
            sum += a[i][j];
            st[j] += a[i][j];
            row[i] += a[i][j];
        }
    }
    if (sum == 0) {
        cout << -1 << endl;
        return 0;
    }
    int mn = 1e9;
    int extra = 0;
    for (int i = 0; i < n; i++) {
        extra += st[i] != n;
        if (st[i]) {
            mn = min(n - row[i], mn);
        } else {
            mn = min(mn, n - row[i] + 1);
        }
    }
    cout << mn + extra << endl;
    return 0;
}


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

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

int main(){
    vector<int> s, t;
    int n,q;
    cin >> n;
    s.resize(n);
    rep(i,n){
        int k;
        cin >> k;
        s[i] = k;
    }
    cin >> q;
    t.resize(q);
    rep(i,q){
        int k;
        cin >> k;
        t[i] = k;
    }
    sort( s.begin(), s.end() );
    sort( t.begin(), t.end() );
    int cnt = 0, is=0, it=0;
    while( is<n && it<q ){
        if( s[is] == t[it] ){
            cnt++;
            is++;
            it++;
        }else if( s[is] < t[it] )
            is++;
        else
            it++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 1248
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define eb emplace_back
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define cinarr(A,len) for(int i=0;i<len;i++){cin>>A[i];}
#define coutarr(A,len) for(int i=0;i<len;i++){cout<<A[i]<<' ';}cout<<endl
#define coutin(V) for(auto& i : V){cout << i << ' ';}cout<<endl // for vect and set
#define coutmap(U) for(auto& i : U){cout << i.first << "->" << i.second << ", ";}cout<<endl // for map
#define deb(x) cout << #x << '\t' << x << endl
const int imax = numeric_limits<int>::max(), imin = numeric_limits<int>::min();
const long long	lmax = numeric_limits<long long>::max(), lmin = numeric_limits<long long>::min();
/*========================================================================*/
/* strategi/note:



/================================*/



const int md = 1000000007;
bool Svd=0;
void solve(){Svd=1;
    int n;
    cin >> n;
    int dp[n+1] = {0};
    dp[0] = 1;
    for(int i = 3; i<=n; i++){
        for(int j = 3; j<=i; j++){
            dp[i] = ((dp[i]%md)+(dp[i-j]%md))%md;
        }
    }
    cout << dp[n] << endl;
}


/*========================================================================*/

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

 solve();
 //int t;cin>>t;while(t--){solve();}

if(!Svd)cout<<"solve() function blm dipanggil!"<<endl;
//cout.flush(); cin.get();
return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <cstdio>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
using namespace std;
const int N=1e5+10;
#define ll long long
#define inf 0x3f3f3f3f
#define mem(x) memset(x,0,sizeof(x))
#define sca(x) scanf("%d",&x)
#define scall(x) scanf("%lld",&x)
#define eps 1e-6
string s;
int main()
{
	int n;cin>>n;
	string s;cin>>s;
	int l=0,r=n-1;
	int ans=0;
	while(l<r)
	{
		if(s[r]=='W')
		{
			r--;
			continue;
		}
		if(s[l]=='R')
		{
			l++;
			continue;
		}
		ans++;
		l++;r--;
	}
	cout<<ans<<endl;
}

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

using namespace std;
typedef long long ll;

int ctoi(char c) {
  return c - '0';
}

int main() {
  string A, B;
  cin >> A >> B;

  if (A.size() > B.size()) {
    cout << "GREATER" << endl;
  } else if (A.size() < B.size()) {
    cout << "LESS" << endl;
  } else {
    for (int i = 0; i < A.size(); i++) {
      if (A[i] != B[i]) {
        if (ctoi(A[i]) > ctoi(B[i])) {
          cout << "GREATER" << endl;
          return 0;
        } else {
          cout << "LESS" << endl;
          return 0;
        }
      }
    }
    cout << "EQUAL" << endl;
  }

  return 0;
}

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

using namespace std;

using u128 = __uint128_t;

#define int long long
#define mod 1000000007

void get_all_primes(int upto_primes, vector<int> &primes){
    primes.clear();
    vector < bool > mark(upto_primes +2,true);

    for(int i=3 ; i * i <= upto_primes ; i+=2){
        if(mark[i]){
            for(int j=i*i ; j<=upto_primes ; j+=2*i){
                mark[j]=false;
            }
        }
    }
    primes.push_back(2);
    for(int i=3 ; i<=upto_primes ; i+=2 ){
        if(mark[i]){
            primes.push_back(i);
        }
    };
}
int exp(int base, int e ){
    int result = 1;
    base %= mod;
    while(e){
        if(e & 1 )
        result =  result  * base % mod;

            base = base * base % mod;
            e >>=1 ;
    }
    return result;
}
int lcm(const int *a , int n){
    vector<int> primes;
    get_all_primes(1000001, primes);
    unordered_map<int, int> x;

    for(int k = 0; k < n; k++){
        int ele = a[k];
        for(int i = 0; primes[i]*primes[i] <= ele ; i++){
            int p = primes[i];
            int count = 0;
            while(ele % p == 0){
                ele /= p;
                count ++;
            }
            if(count != 0) x[p] = max(x[p], count);
        }
        if(ele != 1) x[ele] = max(x[ele], (int)1);
    }
    int ans = 1;
    for(auto i: x){
        ans = ans * exp(i.first, i.second);
        ans %= mod;
    }
    return ans;
}

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin>>n;
    int *a = new int [n];
    for(int i = 0; i< n; i++){
        cin>>a[i];
    }
    int l = lcm(a, n);
    int result = 0;
    for(int i = 0; i< n; i++){
        int d = exp(a[i] , mod -2);
        result += l * d % mod;
    }
    cout<<result % mod<<endl;
    return 0;
}

Measured memory_bytes: 1656
#include<bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define rep(i,a,n) for(int i=(a);i<=(n);++i)
#define dep(i,a,n) for(int i=(a);i>=(n);--i)
#define eps 1e-8
#define pi 3.1415926535897
#define sqr(x) ((x)*(x))
#define MAX(a,b) a=max(a,b)
#define MIN(a,b) a=min(a,b)
#define SZ(x) ((int)(x).size())
#define CPY(a,b) memcpy(a,b,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
#define POSIN(x,y) (1<=(x)&&(x)<=n&&1<=(y)&&(y)<=m)
#define all(x) (x).begin(),(x).end()
#define COUT(S,x) cout<<fixed<<setprecision(x)<<S<<endl
#define buli(x) (__builtin_popcountll(x))
#define bur0(x) (__builtin_ctzll(x))
#define bul2(x) (63-__builtin_clzll(x))
#define pw(x) ((ll(1))<<(x))
#define upmo(a,b) (((a)=((a)+(b))%mo)<0?(a)+=mo:(a))
#define mmo(a,b) (((a)=1ll*(a)*(b)%mo)<0?(a)+=mo:(a))
#define y0 y0z
#define y1 y1z
#define yn ynz
#define j0 j0z
#define j1 j1z
#define jn jnz
#define tm tmz
#ifdef LOCAL
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(...) 
#endif
typedef long long ll;
typedef double lf;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<lf,lf> pff;
typedef complex<double> CD;
const int inf=0x3f3f3f3f;
const int mo=1000000007;
inline void gn(long long&x){
	int sg=1;char c;while(((c=getchar())<'0'||c>'9')&&c!='-');c=='-'?(sg=-1,x=0):(x=c-'0');
	while((c=getchar())>='0'&&c<='9')x=x*10+c-'0';x*=sg;
}
inline void gn(int&x){long long t;gn(t);x=t;}
inline void gn(unsigned long long&x){long long t;gn(t);x=t;}
inline void gn(double&x){double t;scanf("%lf",&t);x=t;}
inline void gn(long double&x){double t;scanf("%lf",&t);x=t;}
template<class T1,class T2>inline void gn(T1&r,T2&s){gn(r),gn(s);}
template<class T1,class T2,class T3>inline void gn(T1&r,T2&s,T3&t){gn(r),gn(s),gn(t);}
template<class T1,class T2,class T3,class T4>inline void gn(T1&r,T2&s,T3&t,T4&u){gn(r),gn(s),gn(t),gn(u);}
inline void gs(char *s){scanf("%s",s);}
inline void gc(char &c){while((c=getchar())>126 || c<33);}
inline void pc(char c){putchar(c);}
const int DX[]={1,0,-1,0},DY[]={0,1,0,-1};
ll powmod(ll a,ll b) {ll res=1;a%=mo;for(;b;b>>=1){if(b&1)res=res*a%mo;a=a*a%mo;}return res;}
ll powmod(ll a,ll b,ll mo) {ll res=1;a%=mo;for(;b;b>>=1){if(b&1)res=res*a%mo;a=a*a%mo;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
//*******************************************

const int N=111111,M=111111;
int l,m,n,t,C;
int a1,a2,a4;
int main(){
#ifdef LOCAL
	freopen("C.in","r",stdin);//freopen("C.out","w",stdout);
#endif
	scanf("%d",&n);rep(i,1,n){
        scanf("%d",&t);
        if(t%4==0)a4++;
        else if(t%2==0)a2++;
        else a1++;
    }
    int ok=1;
    if(a1>a4&&a2)ok=0;
    if(a1>a4+1)ok=0;
    puts(ok?"Yes":"No");
	return 0;
}







































Measured memory_bytes: 256
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
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<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n;

// int getnum(int f, int l, int n){
//   for(int i=1;i<=5;i++){

//   }
// }

map<pi,int> mp;
int ans = 0;

signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  
  // cin >> n;
  // for(int f=1;f<=9;f++){
  //   for(int l=1;l<=9;l++){
  //     ans+=getnum(f,l,n);
  //   }
  // }
  cin >> n;
  for(int i=1;i<=n;i++){
    int x = i;
    int f = x%10;
    int l = x%10;
    while(x>0){
      l = x%10;
      x/=10;
    }
    mp[{f,l}]++;
  }
  for(int f=1;f<=9;f++){
    for(int l=1;l<=9;l++){
      ans+=(mp[{f,l}]*mp[{l,f}]);
    }
  }
  cout << ans << endl;


return 0;
}
///....


Measured memory_bytes: 256
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

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

int main() {
	int ans=0;

	char n[3];
	cin >> n;

	int tmp;
	rep(i,3){
		if(n[i]=='R'){
			tmp++;
			if(tmp>ans) ans=tmp;
		}else{
			tmp=0;
		}

	}



	cout << ans << endl;

}

Measured memory_bytes: 3632
#pragma target("avx")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
  cin.tie(0);
  cout.tie(0);
  ios::sync_with_stdio(false);
  int k,x;
  cin >> k >> x;
  for(int i=x-k+1;i<x+k;i++){
    cout << i << " ";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 384
def main():
    S = input()
    mod = 10**9+7
    dp0 = 1
    dp1 = 0
    dp2 = 0
    dp3 = 0

    for s in S:
        tmp0 = dp0
        tmp1 = dp1
        tmp2 = dp2
        tmp3 = dp3

        if s == '?':
            tmp0 += 2*dp0 % mod
            tmp1 += (2*dp1 + dp0) % mod
            tmp2 += (2*dp2 + dp1) % mod
            tmp3 += (2*dp3 + dp2) % mod
        elif s == 'A':
            tmp1 += dp0 % mod
        elif s == 'B':
            tmp2 += dp1 % mod
        elif s == 'C':
            tmp3 += dp2 % mod
        dp0 = tmp0
        dp1 = tmp1
        dp2 = tmp2
        dp3 = tmp3

    print(dp3%(mod))
if __name__ == '__main__':
    main()

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

typedef long long ll;
using namespace std;

int main(){
     string a,b;
     cin >> a >> b;
     int n = a.size(),m = b.size();
     ll dp[n+1][m+1];
     for(int i=0;i<=n;i++) for(int j=0;j<=m;j++) dp[i][j] = 0;
     for(int i=1;i<=n;i++)
          for(int j=1;j<=m;j++)
               if(a[i-1] == b[j-1]) dp[i][j] = dp[i-1][j-1] + 1;
               else dp[i][j] = max({dp[i][j],dp[i-1][j],dp[i][j-1]});
     string ans = "";
     int i = n ,j = m;
     while(i > 0 && j > 0){
          if(dp[i][j] == dp[i-1][j-1] + 1 && dp[i][j] == dp[i-1][j] +1 && dp[i][j] == dp[i][j-1] + 1){
            ans += a[i-1];
            i--;
            j--;
          }
          else if(dp[i][j-1] > dp[i-1][j]) j--;
          else i--;
          
     }
     reverse(ans.begin(),ans.end());
     cout << ans << endl;
     return 0;
}//////////////

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

int main(){
  int N;cin >> N;
  vector<int> B(N,0);
  for(int i=1;i<N;i++){
    int x;cin >> x;
    B[x-1] += 1;
  }
  for(int i=0;i<N;i++){
    cout << B[i] << endl;
  }
}

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

using namespace std;
using ll = long long;

int tree_diameter(const vector<vector<int>>& g) {
	const int INF = 1e8;
	int V = g.size();
	vector<int> d(V, INF);
	deque<int> que;

	d[0] = 0;
	que.push_back(0);
	while (!que.empty()) {
		int s = que.front();
		que.pop_front();
		for (int i = 0; i < g[s].size(); ++i) {
			if (d[s] < d[g[s][i]]) {
				d[g[s][i]] = d[s] + 1;
				que.push_back(g[s][i]);
			}
		}
	}

	int t = 0, max_d = 0;
	for (int i = 0; i < V; ++i) {
		if (max_d < d[i]) {
			max_d = d[i];
			t = i;
		}
		d[i] = INF;
	}

	d[t] = 0;
	que.push_back(t);
	while (!que.empty()) {
		int s = que.front();
		que.pop_front();
		for (int i = 0; i < g[s].size(); ++i) {
			if (d[s] < d[g[s][i]]) {
				d[g[s][i]] = d[s] + 1;
				que.push_back(g[s][i]);
			}
		}
	}

	int ret = 0;
	for (int i = 0; i < V; ++i) { ret = max(ret, d[i]); }

	return ret + 1;
}

int main() {
	int N;
	cin >> N;
	vector<vector<int>> g(N);
	for (int i = 0; i < N - 1; ++i) {
		int a, b;
		cin >> a >> b;
		--a, --b;
		g[a].push_back(b);
		g[b].push_back(a);
	}

	int x = tree_diameter(g);
	if (x % 3 == 2) { cout << "Second" << endl; }
	else { cout << "First" << endl; }

	return 0;
}


Measured memory_bytes: 13556
#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;

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

	string S;
	cin >> S;

	if(S == "0000"){
		cout << "NA" << endl;
		return 0;
	}

	string t = S.substr(0, 2);
	string u = S.substr(2, 2);
	if(t == "00"){
		if(u > "12"){
			cout << "NA" << endl;
			return 0;
		}else{
			cout << "YYMM" << endl;
			return 0;
		}
	}

	if(u == "00"){
		if(t > "12"){
			cout << "NA" << endl;
			return 0;
		}else{
			cout << "MMYY" << endl;
			return 0;
		}
	}

	if(t > "12"){
		if(u > "12"){
			cout << "NA" << endl;
			return 0;
		}else{
			cout << "YYMM" << endl;
			return 0;
		}
	}else{
		if(u > "12"){
			cout << "MMYY" << endl;
			return 0;
		}else{
			cout << "AMBIGUOUS" << endl;
			return 0;
		}
	}

}


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

unsigned long op(unsigned long a, unsigned long b){
    return std::max(a, b);
}

unsigned long e(){
    return 0;
}

int main(){
    using namespace std;
    using namespace atcoder;
    unsigned long N, K;
    cin >> N >> K;
    constexpr unsigned long Amax = 300000;
    segtree<unsigned long, op, e> sgt(Amax + 1);
    for(unsigned long i{0}, A; i < N; ++i){
        cin >> A;
        sgt.set(A, sgt.prod(max(K, A) - K, min(A + K, Amax) + 1) + 1);
    }
    cout << sgt.all_prod() << endl;
    return 0;
}


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

int main()
{
	int a, b;
	cin >> a >> b;
	
	if (a < b)
	{
		cout << "a < b" << endl;
	}
	else if (a > b)
		{
		cout << "a > b" << endl;
	}
	else 
	{
		cout << "a == b" << endl;
	}
		return 0;
}

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

signed main(){

    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    vector<int> v1 = {2,3};
    vector<int> v2 = {1,3};
    vector<int> v3 = {1,2};
    vector<int> a(2);
    rep(i,2) cin >> a[i];
    sort(a.begin(), a.end());
    if (a == v1) cout << 1 << endl;
    if (a == v2) cout << 2 << endl;
    if (a == v3) cout << 3 << endl;
    return 0;
}

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

using namespace std;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(long long i=(a),i##Len_=(b);i<i##Len_;i++)
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;


ll get_digit(ll i)
{


}

//abc057_c
int main()
{
    ll a,b,c;
    cin >> a >> b >> c;

    string res;
    if(b-a == c-b)res = "YES";
    else res = "NO";


    cout << res << endl;


    return 0;
}



Measured memory_bytes: 256
b = gets.to_i
# s = gets.chomp
# s,t = gets.split.map(&:to_s)
# r= gets.split.map(&:to_i)

# s = gets.chomp.chars.uniq
# puts gets.chomp.chars.uniq.size != 1 ? "Yes" : "No"
# r = a-b
p 3*(b**2)

Measured memory_bytes: 3836
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
/*---------------------DEBUGGING--------------------------------------------*/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
/*-------------------------------------------------------------------------------------*/
#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pcc pair<char,char>
#define F first
#define S second
#define int long long
#define pi 3.141592653589793238462643383279502
#define M  998244353  //1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define N 300005
#define vi vector<int>


signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int a[3];
    cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3);
    if((a[0]== a[1]  && a[1]!=a[2] ) ||(a[1]==a[2] && a[0]!=a[1]))
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;

}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL LINF=1ll<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};



int main(){
    int r;cin >> r;
    cout << r * r << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

const int bits = 50;

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int N;
  while (cin >> N) {
    vector<ll> A(N);
    for (auto& x : A) cin >> x;
    ll X = A[0], Y = A[1], Z = 0;
    for (int i = 2; i < N; i++) Z ^= A[i];
    ll W = X + Y;
    // bit, carry, keep, nonzero
    auto dp = make_v(bits, 2, 2, 2, -1ll);
    dp[0][0][1][0] = 0;
    for (int b = 0; b < bits - 1; b++) {
      int a = (X >> b) & 1, w = (W >> b) & 1, z = (Z >> b) & 1;
      for (int carry = 0; carry < 2; carry++) {
        for (int keep = 0; keep < 2; keep++) {
          for (int nonzero = 0; nonzero < 2; nonzero++) {
            ll value = dp[b][carry][keep][nonzero];
            if (value < 0) continue;
            for (int x = 0; x < 2; x++) {
              int ncarry = 0;
              int y = w - carry;
              if (y < 0) {
                ++ncarry;
                y += 2;
              }
              y -= x;
              if (y < 0) {
                ++ncarry;
                y += 2;
              }
              if (x ^ y ^ z) continue;
              int nkeep = 0;
              if (x < a) {
                nkeep = 1;
              } else if (x == a) {
                nkeep = keep;
              }
              int nnonzero = nonzero | (x > 0);
              chmax(dp[b + 1][ncarry][nkeep][nnonzero], (ll(x) << b) + value);
            }
          }
        }
      }
    }
    ll sub = dp[bits - 1][0][1][1];
    if (sub < 0) {
      cout << -1 << endl;
    } else {
      cout << X - sub << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3628
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;
const int MAXN = 100005;
const int INF = 1e9;
int n, K;
int V[MAXN], P[MAXN];
int et, fir[MAXN], to[MAXN << 1], ne[MAXN << 1];
int s[2][MAXN], v[MAXN];

void link(int u, int v) {
    to[++et] = v, ne[et] = fir[u], fir[u] = et;
    to[++et] = u, ne[et] = fir[v], fir[v] = et;
}

#include <queue>
#define xx first
#define yy second
typedef pair<int, int> pii;
void solve(int t) {
    if (!t) {
        priority_queue<pii> h;
        for (int i = 1; i <= K; i++)
            h.push(make_pair(P[i], V[i]));
        while (!h.empty()) {
            pii o = h.top(); h.pop();
            if (s[t][o.yy] != o.xx)
                continue;
            for (int i = fir[o.yy]; i; i = ne[i])
                if (s[t][to[i]] < o.xx - 1)
                    s[t][to[i]] = o.xx - 1, h.push(make_pair(s[t][to[i]], to[i]));
        }
    } else {
        priority_queue<pii, vector<pii>, greater<pii> > h;
        for (int i = 1; i <= K; i++)
            h.push(make_pair(P[i], V[i]));
        while (!h.empty()) {
            pii o = h.top(); h.pop();
            if (s[t][o.yy] != o.xx)
                continue;
            for (int i = fir[o.yy]; i; i = ne[i])
                if (s[t][to[i]] > o.xx + 1)
                    s[t][to[i]] = o.xx + 1, h.push(make_pair(s[t][to[i]], to[i]));
        }
    }
}

void dfs(int o, int fa) {
    for (int i = fir[o], t; i; i = ne[i])
        if ((t = to[i]) != fa) {
            v[t] = v[o] + 1 <= s[1][t] ? v[o] + 1 : v[o] - 1;
            dfs(t, o);
        }
}

int main() {
    scanf("%d", &n);
    for (int i = 1, x, y; i < n; i++)
        scanf("%d %d", &x, &y), link(x, y);
    for (int i = 1; i <= n; i++)
        s[0][i] = -INF, s[1][i] = INF;
    scanf("%d", &K);
    for (int i = 1; i <= K; i++) {
        scanf("%d %d", V + i, P + i);
        s[0][V[i]] = s[1][V[i]] = P[i];
    }
    solve(0), solve(1);
    for (int i = 1; i <= n; i++)
        if (s[0][i] > s[1][i]) {
            printf("No");
            return 0;
        }
    v[V[1]] = P[1], dfs(V[1], 0);
    for (int i = 1; i <= n; i++)
        if (v[i] < s[0][i] || v[i] > s[1][i]) {
            printf("No");
            return 0;
        }
    puts("Yes");
    for (int i = 1; i <= n; i++)
        printf("%d\n", v[i]);
    return 0;
}


Measured memory_bytes: 9020
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <utility> 

#define rep(i,m,n) for(int i = m;i < n;++i)
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;
const int MOD = 1e9 + 7;



int main() {	
	string s1, s2;
	cin >> s1;
	cin >> s2;
	vector<string> ans;
	if (s1.size() < s2.size()) {
		cout << "UNRESTORABLE" << endl;
	}
	else {
		for (int i = 0; i <= s1.size() - s2.size();i++) {
			int cnt = 0;
			for (int j = i; j < i+s2.size();j++) {
				if (s1[j] == '?' || s1[j] == s2[j-i]) {
					cnt++;
					continue;
				}
				else {
					break;
				}
			}
			if (cnt == s2.size()) {
				string temp = s1;
				for (int k = 0; k < s1.size();k++) {
					if (i<=k && k<i+s2.size()) {
						temp[k] = s2[k - i];
					}
					else if(s1[k] == '?'){
						temp[k] = 'a';
					}
				}
				ans.push_back(temp);
			}

		}
		if (ans.size() > 0) {
			sort(ans.begin(),ans.end());
			cout << ans[0] << endl;
		}
		else {
			cout << "UNRESTORABLE" << endl;
		}
	}
	
	
	return 0;
}

Measured memory_bytes: 256
import itertools

n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))

for i in range(n):
    p[i] -= 1
    q[i] -= 1

p = tuple(p)
q = tuple(q)

numbers = [i for i in range(n)]
l = list(itertools.permutations(numbers))

p_order = l.index(p)
q_order = l.index(q)

ans = abs(p_order - q_order)
print(ans)

Measured memory_bytes: 13864
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
//vector<vector<ll>> dp(n,vector<ll>(n))
//exist x map o set
constexpr ll D=365;
ll c[26];
ll s[365][26];
void input(){
    for(int i=0;i<26;i++) cin >> c[i];
    for(int i=0;i<D;i++) for(int j=0;j<26;j++) cin >> s[i][j];
}
constexpr ll INF=1e18;
signed main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    input();
    vector<int> last(26,0);
    rep(i,D){
        ll plus=-INF;
        int ans=0;
        rep(j,26){
            //open j contest
            ll ret=s[i][j];
            rep(k,26){
                if(j!=k) ret-=c[k]*(i+1-last[k]);
            }
            if(ret>plus){
                plus=ret;
                ans=j;
            }
        }
        cout << ans+1 << endl;
    }
}


Measured memory_bytes: 3680
#include <bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define pb push_back
#define fastcin() ios_base::sync_with_stdio(false); cin.tie(0)
using namespace std;
typedef pair<int, int> ii;

const int maxn = 400, oo = 1e18; 
int n, m, q, cap; 
int dis[maxn][maxn], ans[maxn][maxn]; 

vector<int> adj[maxn]; 

signed main()
{
	cin >> n >> m >> cap; 
	for(int i = 1; i <= n; i++) 
		for(int j = 1; j <= n; j++) 
			if(i!=j) 
				dis[i][j] = ans[i][j] = oo; 
	for(int i = 1; i <= m; i++) 
	{
		int u, v, w; cin >> u >> v >> w; 
		dis[u][v] = dis[v][u] = w; 
	}
	for(int k = 1; k <= n; k++) 
		for(int i = 1; i <= n; i++) 
			for(int j = 1; j <= n; j++) 
				if(i != k and j != k)	
					dis[i][j] = min(dis[i][k] + dis[k][j], dis[i][j]); 
	for(int k = 1; k <= n; k++) 
		for(int i = 1; i <= n; i++) 
			for(int j = 1; j <= n; j++)
				ans[i][j] = min(min(ans[i][j], ans[i][k] + ans[k][j]), min(ans[i][k] + (dis[k][j] <= cap ? 1 : oo), ans[k][j] + (dis[i][k] <= cap ? 1 : oo))); 
//	cout << "dis\n"; 
//	for(int i = 1; i <= n; i++) 
//	{
//		for(int j = 1; j <= n; j++) 
//		cout << dis[i][j] << ' '; 
//		cout << '\n'; 
//	}
//	cout << "ans\n"; 
//	for(int i = 1; i <= n; i++) 
//	{
//		for(int j = 1; j <= n; j++) 
//		cout << ans[i][j] << ' '; 
//		cout << '\n'; 
//	}
	cin >> q; 
	while(q--) 
	{
		int s, t; cin >> s >> t; 
		cout << (ans[s][t] < oo ? ans[s][t] : 0) - 1 << '\n'; 
	}
}


Measured memory_bytes: 2432
#include<stdio.h>

int main(void) {
	int n, m, l;
	int A[101][101], B[101][101];
	long C[101][101];
	int i, j, k;
	
	
	scanf("%d %d %d", &n, &m, &l);
	
	for(i = 0; i < n; i++) {
		for(j = 0; j < m; j++) {
			scanf("%d", &A[i][j]);
		}
	}
	
	for(i = 0; i < m; i++) {
		for(j = 0; j < l; j++) {
			scanf("%d", &B[i][j]);
		}
	}
	
	for(i = 0; i < n; i++) {
		for(j = 0; j < l; j++) {
			C[i][j] = 0;
		}
		
	}
	
	for(i = 0; i < n; i++) {
		for(j = 0; j < l; j++) {
			for(k = 0; k < m; k++) {
				C[i][j] += A[i][k] * B[k][j];
			}
		}
	}
	
	for(i = 0; i < n; i++) {
		for(j = 0; j < l; j++) {
			printf("%ld", C[i][j]);
			if(j != l-1) {
				printf(" ");
			}
		}
		printf("\n");
	}
	
	return 0;
}

Measured memory_bytes: 760
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int h,w,k;
string str;
int fie[31][31];
int tmp[31][31];
int cnt[31][31];

void fall(){
	memset(cnt,0,sizeof(cnt));
	for(int i=0;i<w;i++){
		for(int j=h-1;j>=0;j--){
			cnt[j][i]=cnt[j+1][i];
			if(tmp[j][i]==0){
				cnt[j][i]++;
			}
		}
		for(int j=h-1;j>=0;j--){
			if(tmp[j][i]!=0 && cnt[j][i]!=0){
				tmp[j+cnt[j][i]][i]=tmp[j][i];
				tmp[j][i]=0;
			}
		}
	}
}

int rensa(int v){
	bool flag=false;
	int ans=0;
	/*
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			printf("%d",tmp[i][j]);
		}
		printf("\n");
	}
	printf("\n");
	*/
	for(int i=0;i<h;i++){
		int cnt=0;
		for(int j=1;j<w;j++){
			if(tmp[i][j]==tmp[i][j-1] && tmp[i][j]!=0){
				cnt++;
			}else{
				if(cnt+1>=k){
					flag=true;
					for(int k=j-1;k>=j-1-cnt;k--){
						ans+=tmp[i][k];
						tmp[i][k]=0;
					}
				}
				cnt=0;
			}
		}
		if(cnt+1>=k){
			flag=true;
			for(int k=w-1;k>=w-1-cnt;k--){
				ans+=tmp[i][k];
				tmp[i][k]=0;
			}
		}
	}
	if(!flag || ans==0)return ans;
	fall();
	return rensa(v*2)+v*ans;
}

int calc(int x,int y){
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			tmp[i][j]=fie[i][j];
		}
	}
	tmp[y][x]=0;
	fall();
	//printf("go!\n");
	return rensa(1);
}

int main(void){
	scanf("%d%d%d",&h,&w,&k);
	for(int i=0;i<h;i++){
		cin >> str;
		for(int j=0;j<w;j++){
			fie[i][j]=(str[j]-'0');
		}
	}
	int ans=0;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			ans=max(ans,calc(j,i));
			//printf("%d\n",ans);
		}
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
import math

def is_prime(n):
    if n <= 1:
        return False
    if n == 2:
        return True
    if n % 2 == 0:
        return False
    for i in range(3, math.ceil(math.sqrt(n))+1, 2):
        if n % i == 0:
            return False
    return True
    
n = int(input())
ans = 0
for _ in range(n):
    x = int(input())
    if is_prime(x):
        ans += 1
print(ans)


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

int main() {
  char c[3][3];
  for (int i=0; i<3; i++) {
    for (int j=0; j<3; j++) {
      cin>>c[i][j];
    }
  }
  for (int i=0; i<3; i++) {
    cout<<c[i][i]<<flush;
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
 
char S[101010];
 
int main()
{
	scanf("%s", S);
 
	bool app[26];
	for (int i = 0; i < 26; ++i) {
		app[i] = false;
	}
	for (int i = 0; S[i] != '\0'; ++i) {
		app[S[i] - 'a'] = true;
	}
	for (int i = 0; i < 26; ++i) {
		if (!app[i]) {
			printf("%c\n", (char)(i + 'a'));
			return 0;
		}
	}
	puts("None");
	return 0;
}

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

using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

template<class Z> map<Z, int> factorize(Z n) {
  map<Z, int> res;
  for (Z i = 2; i * i <= n; ++i) while (n % i == 0) ++res[i], n /= i;
  if (n != 1) ++res[n];
  return res;
}

int main() {
  //cin.tie(nullptr); ios::sync_with_stdio(false);
  lint a, b; cin >> a >> b;
  auto mp = factorize(__gcd(a, b));
  cout << mp.size() + 1 << '\n';
}


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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;

template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

const int mod=1e9+7;

struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
};

mint c[4005][4005];
void init() {
  c[0][0] = 1;
  for (int i = 0; i <= 4000; i++) {
    for (int j = 0; j <= i; j++) {
      c[i+1][j] += c[i][j];
      c[i+1][j+1] += c[i][j];
    }
  }
}
mint comb(int n, int k) {
  return c[n][k];
}

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }

    return true;
}

map<ll, ll> primeFact(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1) res[n]++;
  return res;
}

void printv(vi& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
void printv(vll& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
int vtotal(vi& v){
  int total=0;
  rep(i,v.size()) total+=v[i];
  return total;
}

int main()
{
  //init(); // mint初期化
  cin.tie( 0 );
  ios::sync_with_stdio( false );

  int n,m;
  cin>>n>>m;
  
  vi v(m,0);
  rep(i,n){
    int k;cin>>k;
    rep(j,k){
      int a;cin>>a;
      v[a-1]++;
    }
  }
  int ans=0;
  rep(i,m){
    if(v[i]==n)ans++;
  }
  
  cout<<ans<<endl;

  return 0;
}

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

long long INF = 1e18;

int main(){
    int n,k;
   cin>>n>>k;
   int h[n+100];
   for(int i=0; i<n;i++){
       cin>>h[i];
   }
   sort(h,h+n);
  reverse(h,h+n);
   if(n<=k){
       cout<<"0"<<endl;
       return 0;
   }
   long long ans = 0;
   for(int i = k;i<n;i++){
       ans+=h[i];
   }
   cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>

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


using namespace std;
void dout() { cerr << endl; }
typedef long long ll;
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

#define debug(x) cout << #x " = " << (x) << endl

using ll = long long;
using pii = pair<ll, ll>;
using ld = long double;
using pll = pair<long long, long long>;

template <typename T>
void do_uniq(vector<T> vec) {
    sort(all(vec));
    vec.resize(unique(all(vec)) - vec.begin());
}

#define solvsh
//#define multi
#ifdef solvsh

const int MAXN = 2e5 + 20;
const int MAXTIME = 1e2 + 20;

ll mod  = 1e9 + 7;

ll ml (ll a, ll b) {
    return (a * b) % mod;
}

ll bin_p(ll b, ll p) {
    if (p == 0)
        return 1;
    if (p % 2)
        return ml(b, bin_p(b, p - 1));
    ll v = bin_p(b, p >> 1);
    return ml(v, v);
}

ll add(ll a, ll b) {
    return (a + b) % mod;
}


int t[4 * MAXN];

void update (int v, int tl, int tr, int l, int r, int add) {
    if (l > r)
        return;
    if (l == tl && tr == r)
        t[v] += add;
    else {
        int tm = (tl + tr) / 2;
        update(v * 2, tl, tm, l, min(r, tm), add);
        update(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r, add);
    }
}

int get (int v, int tl, int tr, int pos) {
    if (tl == tr)
        return t[v];
    int tm = (tl + tr) / 2;
    if (pos <= tm)
        return t[v] + get(v * 2, tl, tm, pos);
    else
        return t[v] + get(v * 2 + 1, tm + 1, tr, pos);
}

int prevv[MAXN];
int init[MAXN];
int vals[MAXN];


void gen(){
    cout << 1 << " ";
    for (int i = 0; i < 1e5; ++ i){
        cout << 0 << " ";
    }

}

void solve() {
//    gen();
//    return;
    int n;
    int k;
    cin >> n >> k;
    for (int i = 0; i < n; ++i) {
        int curr;
        cin >> curr;
        init[i] = curr;
        update(1, 0, n - 1, max(0, i - curr), min(n - 1, i + curr), 1);
    }

    for (int j = 0; j < k; ++j) {
        for (int i = 0; i < n; ++i) {
            vals[i] = get(1, 0, n - 1, i);
        }

        for (int i = 0; i < n; ++i) {
            int val = vals[i];
            int curr = init[i];
            update(1, 0, n - 1, max(0, i - curr), min(n - 1, i + curr), -1);
            curr = val;
            update(1, 0, n - 1, max(0, i - curr), min(n - 1, i + curr), 1);
            init[i] = val;
        }

        bool eq = true;

        for (int i = 0; i < n; ++ i){
            if (prevv[i] != init[i])
                eq = false;
            prevv[i] = init[i];
        }

        if (eq){
            break;
        }
    }

    for (int i = 0; i < n; ++i)
        cout << init[i] << " ";
}

#else

void solve() {

}

#endif


void multisolve() {

    int t;
    cin >> t;

    int i = 1;
    while (t--) {
//        cout << "Mission #" << (i++) << ": \n";

        solve();
//        cout << "\n";
    }
}


#define int int
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    cout << fixed << setprecision(20);


#ifdef multi
    multisolve();
#else
    solve();
    //    gen();
#endif

}


Measured memory_bytes: 8016
#include<bits/stdc++.h>
#define F first
#define S second
#define ll long long
#define pb push_back
#define pf push_front
#define acm ios::sync_with_stdio(0),ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
int main()
{
string a,b;
cin>>a>>b;
int z=0,e=0;
while(z<3){
    if(a[z]==b[z]){
        e+=1;
    }
    z+=1;
}
cout<<e;
}



Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
#define len(n) (int)n.length()
#define pb push_back
#define ll long long
#define make_pair mkp
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ALL(v) (v).begin(), (v).end()
#define dbg(n) cerr << "//" << #n << ":" << n <<endl
typedef pair<ll, ll> LLARR;
#define INF 999999999

int n;

bool isSum(int *A, int i, int target)
{
	if (target == 0)
		return true;
	if (i >= n)
		return false;
	return isSum(A, i + 1, target) || isSum(A, i + 1, target-A[i]);
}

int main()
{
	ios::sync_with_stdio(false);

	int A[2001];

	cin >> n;
	REP(i, n)
	{
		cin >> A[i];
	}
	int m;
	cin >> m;

	REP (i,m)
	{
		// mi
		int mi;
		cin >> mi;
		cout << (isSum(A, 0, mi) ? "yes" : "no") << endl;
	}
	return 0;
}

Measured memory_bytes: 3092
#include <iostream>
#include <cstring>
#include <array>

using namespace std;

enum class Grade {
    A,
    B,
    C,
    D,
    F
};

struct Score{
    int m;
    int f;
    int r;
};

class ScoreData{
public:
    ScoreData()
    : numOfData(0)
    {
        data.fill({0, 0, 0});
    }

	void addAllData(){
        bool bAllInput = false;
        while(false == bAllInput){
            bAllInput = add();
        }
    }

	void printAllGrade(){
        bool bAllGet = false;
        for(int i = 0; i < numOfData; ++i){
            Grade grade = getGrade(i);
            printGrade(grade);
        }
    }

	void printGrade(Grade g){
		switch(g)
		{
		case Grade::A:
		    cout << "A" << endl;
		    break;
		case Grade::B:
		    cout << "B" << endl;
		    break;
		case Grade::C:
		    cout << "C" << endl;
		    break;
		case Grade::D:
		    cout << "D" << endl;
		    break;
		case Grade::F:
		    cout << "F" << endl;
		    break;

		default:
			break;
		}
	}

	Grade getGrade(int index){
        int m, f, r;
        m = data[index].m;
        f = data[index].f;
        r = data[index].r;

        if(-1 == m || -1 == f){
			return Grade::F;
		}
		else if(80 <= m + f){
            return Grade::A;
        }
		else if(65 <= m + f){
            return Grade::B;
        }
		else if(50 <= m + f){
            return Grade::C;
        }
		else if(30 <= m + f){
            return 50 <= r ? Grade::C : Grade::D;
        }
		else{
            return Grade::F;
        }
    }

private:
    int numOfData;
    array<Score, 50> data;

    bool add(){
        bool ret;
        int _m, _f, _r;
        cin >> _m;
        cin >> _f;
        cin >> _r;

        if((-1 == _m) && (-1 == _f) && (-1 == _r)) {
            ret = true;
        }else{
            data[numOfData].m = _m;
            data[numOfData].f = _f;
            data[numOfData++].r = _r;
            ret = false;
        }
        return ret;
    }
};

int main(){
    ScoreData scoredata;
    scoredata.addAllData();
    scoredata.printAllGrade();
    return 0;
}


Measured memory_bytes: 3084
H, W , N = map(int,input().split())
from bisect import bisect_left
from bisect import bisect_right
matrix = []
for _ in range(N):
    x,y = map(int,input().split())
    x -= 1
    y -= 1
    matrix.append([x,y])
matrix.sort()
ans = [0 for _ in range(10)]
cand = {}
for l in matrix:
    for x_r in [-2, -1 , 0]:
        for y_r in [-2, -1 , 0]:
            nowx = l[0] + x_r
            nowy = l[1] + y_r
            if nowx < 0 or nowy < 0 or nowx + 2>= H or nowy+ 2 >= W:
                continue
            #ここで起点(左上)nowx, nowy として　 9マスに着目する
            name = str(nowx) + ' '  +str(nowy)
            if name in cand : cand[name] += 1
            else: cand[name] = 1
tmp = ((H - 2) * (W - 2))
for x in cand.values():
    ans[x] += 1
    tmp -= 1
ans[0] = tmp
for x in ans:
    print(x)


Measured memory_bytes: 143380
#include<iostream>
using namespace std;
int main(){
    long long n,a,b,t,ans;
    cin>>n>>a>>b;
    if((b-a)%2==0LL){cout<<(b-a)/2LL<<endl;return 0;}
    //b->n
    t=n-b;
    ans=t+1+(b-a-1)/2LL;
    //a->1
    t=a-1;
    ans=min(ans,t+1+(b-a-1)/2LL);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256