akhauriyash/Code-Regression huggingface dataset:
// {{{ include
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
// }}}
#include <cctype>
#include <cassert>
#include <climits>

using namespace std;

typedef long long ll;
inline int in(){int x;scanf("%d",&x);return x;}

struct Parser {
  typedef string::const_iterator cursor_t;
  Parser(){
    memset(prit, 0, sizeof(prit));
  }
  ll eval(const string& s){
    auto b = s.begin();
    ll x = expr(b);
    consume(b, '\0');
    return x;
  }
  inline void consume(cursor_t& cur, char expected){
    assert(*cur == expected);
    ++cur;
  }
  ll expr(cursor_t& cur, int pri=0){
    if (pri == 3){
      if (*cur == '('){
        consume(cur, '(');
        ll r = expr(cur);
        consume(cur, ')');
        return r;
      }
      return number(cur);
    }
    ll r = expr(cur, pri + 1);
    while (prit[pri][*cur]){
      if (*cur == '*') ++cur, r = r * expr(cur, pri + 1);
      else if (*cur == '+') ++cur, r = r + expr(cur, pri + 1);
      else if (*cur == '-') ++cur, r = r - expr(cur, pri + 1);
    }
    return r;
  }
  ll number(cursor_t& cur){
    ll r = 0;
    while (isdigit(*cur)){
      r = r * 10 + *cur - '0';
      ++cur;
    }
    return r;
  }
  int prit[3][256];
};

int main()
{
  Parser parser;
  string S;

  cin >> S;
  ll maxi = LLONG_MIN;
  for (int i = 0; i < 3; i++){
    for (int j = 0; j < 3; j++){
      for (int k = 0; k < 3; k++){
        for (int l = 0; l < 3; l++){
          parser.prit[l]['*'] = (i == l);
          parser.prit[l]['+'] = (j == l);
          parser.prit[l]['-'] = (k == l);
        }
        maxi = max(maxi, parser.eval(S));
      }
    }
  }
  cout << maxi << endl;
  return 0;
}

Measured memory_bytes: 1196
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
S = list(input())
clst=[]
count = 0
for s in S:
    if s == 'A' or s == 'T' or s =='C' or s == 'G':
        count += 1
        clst.append(count)
    else:
        
        count = 0
        clst.append(count)
print(max(clst))


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


int main() {
  int a,b;
  
  cin >> a >> b;
  
  if(a>=13)
    cout << b;
  
  else if(a<=12 && a>=6)
    cout << b/2;
  
  else
    cout << 0;
  
  
}

Measured memory_bytes: 256
hoge=input()
ho=int(hoge[:2])
ge=int(hoge[2:])
ym=0
my=0
if(1<=ge and ge<=12):
  ym=1
  
if(1<=ho and ho<=12):
  my=1
  
if(ym==1 and my==1):
  print("AMBIGUOUS")
elif(ym==1):
  print("YYMM")
elif(my==1):
  print("MMYY")
else:
  print("NA")

Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cout << #x << " = " << (x) << endl;
#define forauto(i, a) for(auto i : a)cout << i << " "; puts("");
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = 1e9;
const double pi = acos(-1.0);

int main() {
	vector<PII> d;

	int n; cin >> n;
	rep(i, n) {
		int x, y; cin >> x >> y;
		d.pb(mp(x, y));
	}
	int m; cin >> m;
	rep(i, m) {
		int x, y; cin >> x >> y;
		d.pb(mp(x, y));
	}

	sort(all(d));
	d.erase(unique(all(d)), d.end());

	rep(i, sz(d)) {
		printf("%d:%02d", d[i].first, d[i].second);
		cout << (i == sz(d) - 1 ? "\n" : " ");
	}
}


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

for i in range(m-1):
    if a[i] + 1 == a[i+1]:
        print(0)
        exit()
dp=[0]*(n+1)
dp[0]=1

for i in range(1,n+1):
    if len(a)!=0 and i == a[0]:
        dp[i]=0
        a.pop(0)
        continue
    dp[i]=dp[i-1]+dp[i-2]
    dp[i] = dp[i] % (10**9+7)

print(dp[n] % (10**9+7))

Measured memory_bytes: 7080
import numpy as np
import heapq

N, M = map(int, input().split())
A = np.fromiter(map(int, input().split()), np.int64)
B = np.empty(M, np.int)
C = np.empty(M, np.int)
for j in range(M):
	B[j], C[j] = map(int, input().split())

A = np.sort(A)

class Reps (object):
	def __init__(self, b, c):
		self.b = b
		self.c = c
	
	def __lt__(self, other):
		return self.c > other.c

Z = np.zeros(N, np.int)

heap = []
for j in range(M):
	heapq.heappush(heap, Reps(B[j], C[j]))

while heap:
	reps = heapq.heappop(heap)
	b, c = reps.b, reps.c
	i = np.searchsorted(A, c)
	b = min(b, i)
	if b == 0:
		break
	for h in range(i-b, i):
		heapq.heappush(heap, Reps(1, A[h]))
		A[h] = c

print(np.sum(A))


Measured memory_bytes: 59160
#include <bits/stdc++.h>
#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 sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

const int V = 100005;

vector<vector<int>> g;
vector<int> cnt;
vector<bool> seen;

void dfs(int v) {
    if (seen[v]) return;
    seen[v] = true;
    cnt[v/V]++;
    for (int u : g[v]) dfs(u);
}


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

    int n;
    cin >> n;
    g.resize(V * 2);
    rep(i, n) {
        int x, y;
        cin >> x >> y;
        y += V;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    seen.resize(V * 2);
    ll ans = 0;
    rep(i, V) {
        if (!seen[i]) {
            cnt.assign(2, 0);
            dfs(i);
            ans += 1LL * cnt[0] * cnt[1];
        }
    }
    ans -= n;
    cout << ans << endl;
}


Measured memory_bytes: 13120
def gcd(a, b):
    r = a % b
    return b if r == 0 else gcd(b, r)


n, a = map(int, input().split())
X = list(map(int, input().split()))

X = [abs(x - a) for x in X]

for i in range(1, n):
    X[i] = gcd(X[i - 1], X[i])

print(X[-1])


Measured memory_bytes: 14224
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];

    int Mn=a[0],x=1;
    for(int i=1;i<n;i++){
        if(Mn>=a[i])
            x++;
        Mn=min(Mn,a[i]);
    }
    cout<<x<<endl;
}


Measured memory_bytes: 4408
(defmacro while (test &body body)
  `(do ()
       ((not ,test))
     ,@body))

(defun find-sum-of-digits (n)
  (let ((sum 0))
    (while (> n 0)
      (setf sum (+ sum (rem n 10)))
      (setf n (floor n 10)))
    sum))

(defun some-sums (n a b)
  (let ((total 0)
        (sum 0))
    (dotimes (i (+ n 1))
      (setf sum (find-sum-of-digits i))
      (if (and (>= sum a) (<= sum b))
          (setf total (+ total i))))
    total))

(format t "~A~%" (some-sums (read) (read) (read)))

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

const int N=2e5+1e3+7;

int n,a[N],b[N],tot;

int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	if(n&1)
	{
		for(int i=n;i>=1;i-=2)
			b[++tot]=a[i];
		for(int i=2;i<=n-1;i+=2)
			b[++tot]=a[i];
	}
	else
	{
		for(int i=n;i>=2;i-=2)
			b[++tot]=a[i];
		for(int i=1;i<=n-1;i+=2)
			b[++tot]=a[i];
	}
	for(int i=1;i<=n;i++)
		cout<<b[i]<<" ";
}

Measured memory_bytes: 3712
N, M = map(int,input().split())
#M 夏休み期間　M　宿題数
A = list(map(int, input().split()))
A_sum = 0
for i in range(0, M):
    A_sum += A[i]
    # A_sum 宿題全日数
x = N - A_sum
if x < 0:
    print("-1")
else:
    print(x)

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

int main()
{
   string s;
   cin>>s;
   if(s=="SUN"){
      cout<<"7\n";
   }else if(s=="MON"){
      cout<<"6\n";
   }else if(s=="TUE"){
      cout<<"5\n";
   }else if(s=="WED"){
      cout<<"4\n";
   }else if(s=="THU"){
      cout<<"3\n";
   }else if(s=="FRI"){
      cout<<"2\n";
   }else{
      cout<<"1\n";
   }
    return 0;
}




Measured memory_bytes: 256
import sys
from collections import deque

def solve():
    while 1:
        w, h = map(int, sys.stdin.readline().split())

        if w == h == 0:
            return

        room = [[False]*w for i in range(h)]

        si = sj = -1

        for i in range(h):
            line = input()

            for j, ch in enumerate(line):
                if ch == '@':
                    room[i][j] = True
                    si = i
                    sj = j
                elif ch == '.':
                    room[i][j] = True

        ans = bfs(w, h, room, si, sj)

        print(ans)

dx = (1, 0, -1, 0,)
dy = (0, 1, 0, -1,)

def bfs(w, h, room, si, sj):
    visited = [[False]*w for i in range(h)]
    visited[si][sj] = True
    q = deque([(si, sj)])
    cnt = 1

    while q:
        ci, cj = q.popleft()

        for k in range(len(dx)):
            ni = ci + dy[k]
            nj = cj + dx[k]

            if 0 <= ni < h and 0 <= nj < w and room[ni][nj] and not visited[ni][nj]:
                visited[ni][nj] = True
                q.append((ni, nj))
                cnt += 1

    return cnt

if __name__ == '__main__':
    solve()

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

#define ll long long
#define mx 1000005

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

    int a[n];

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

    ll sum=a[0]+a[n-2];
    int cur=min(a[0],a[1]);

    for(int i=1;i<n-1;i++)
    {
        //cout<<sum<<endl;

        sum+=cur;
        if(i!=n-1)
        {
           cur=min(a[i],a[i+1]);
        }
    }

    cout<<sum<<endl;




    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int inf = 1e9;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, b, a) for (int i = a - 1; i >= b; i--)
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dxx[8] = {1, 1, 1, 0, 0, -1, -1, -1}, dyy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

vector<vector<pint>> g (100005);
int n;
int seen[100005];
void search() {
    rep (i, 0, n) seen[i] = -1;
    queue<pint> q;
    q.push ({0, 0});
    seen[0] = 0;
    while (!q.empty()) {
        pint p = q.front();
        q.pop();
        int v = p.second;
        for (auto i : g[v]) {
            if (seen[i.second] == -1) {
                if (i.first % 2 == 0) {
                    // cout << i.second << "\n";
                    seen[i.second] = seen[v];
                    q.push ({seen[i.second], i.second});
                } else {
                    // cout << i.second << "\n";
                    seen[i.second] = abs (seen[v] - 1);
                    q.push ({seen[i.second], i.second});
                }
            }
        }
    }
}
int main() {
    cin >> n;
    rep (i, 0, n - 1) {
        int a, b, c;
        cin >> a >> b >> c;
        g[--a].push_back ({c, --b});
        g[b].push_back ({c, a});
    }
    search();
    rep (i, 0, n) cout << seen[i] << "\n";
}

Measured memory_bytes: 6784
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

sum_a = sum(A)
sum_b = sum(B)
if sum_a < sum_b:
    # impossible
    print(-1)
    exit()

ans = 0
lack = 0
remains = []
for i in range(N):
    a = A[i]
    b = B[i]
    if a < b:
        ans += 1
        lack += b - a
    elif a > b:
        remains.append(a - b)

if ans == 0:
    # no need to change
    print(ans)
    exit()

remains.sort(reverse=True)

count = 0
while lack > 0:
    lack -= remains[count]
    count += 1

print(ans + count)


Measured memory_bytes: 81584
#include <bits/stdc++.h>
using namespace std;
inline long long in(){long long x=0;char c=getchar();bool neg=false;while(c!='-'&&('0'>c||c>'9')) c=getchar();if(c=='-') neg=true,c=getchar();while('0'<=c&&c<='9') x=10*x+c-'0',c=getchar();if(neg) x=-x;return x;}
inline void out(long long x){if(x<0) putchar('-'),x=-x;if(x>9) out(x/10);putchar(x%10+'0');}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int l,int r){return l+rng()%(r-l+1);}
#define fasty ios_base::sync_with_stdio(false),cin.tie(nullptr);
#define task "S"
#define forinc(a,b,c) for(int a=b,_c=c;a<=_c;++a)
#define fordec(a,b,c) for(int a=b,_c=c;a>=_c;--a)
#define forv(a,b) for(auto&a:b)
#define fi first
#define se second
#define pb push_back
#define ii pair<int,int>
#define mt make_tuple
#define all(a) a.begin(),a.end()
#define reset(f, x) memset(f, x, sizeof(f))
#define bit(x,i) ((x>>(i-1))&1)
#define on(x,i) (x|(1ll<<(i-1)))
#define off(x,i) (x&~(1<<(i-1)))
#define _ putchar(' ')
#define __ putchar('\n')
const int M=1e9+7;
string s;
int d;
int b[10010];
int f[10010][110][2];
int F(int i,int r,int o)
{
    if(i>s.size()) return r==0;
    if(f[i][r][o]>-1) return f[i][r][o];
    int ans=0;
    forinc(j,0,(o ? 9 : b[i])) ans=(ans + F(i+1,(r+j)%d,j < b[i] || o))%M;
    return f[i][r][o]=ans;
}
main()
{
    fasty;
    //freopen(task".inp","r",stdin);
    //freopen(task".out","w",stdout);
    cin>>s;
    forinc(i,0,s.size()-1) b[i+1]=s[i]-'0';
    cin>>d;
    reset(f,-1);
    cout<<(F(1,0,0)-1+M)%M;
}


Measured memory_bytes: 9728
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		long w=sc.nextLong(),h=sc.nextLong();
		int x=sc.nextInt(),y=sc.nextInt();
		sc.close();
		System.out.printf("%.10f\n",(double)w*h/2);
		if(x==(double)w/2 && y==(double)h/2) System.out.println("1");
		else System.out.println("0");
	}
}

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

int main() {
	int n, d, x;
	cin >> n >> d >> x;
	vector<int> a(n);
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i < n; i++) {
		int day = 1;
		while (day <= d) {
			x++;
			day += a[i];
		}
	}
	cout << x << endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast,O3,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
using namespace __gnu_pbds;
using namespace std;

#define endl '\n'
#define hoise cerr<<"hoise - "<<__LINE__<<"\n";
#define tham getchar();
#define FASTIO ios::sync_with_stdio(false);cin.tie(nullptr);

using ll = long long;
using ii = pair <int, int>;
using vi = vector <int>;
using vl = vector <ll>;

const int MXN = (int)2e5+6;
const double PI = acos(-1.0);
const ll mod = 2019;
const int INF = 1e9;

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}

inline int Set(int N, int pos){return N=N | (1<<pos);}
inline int Reset(int N, int pos){return N=N & ~(1<<pos);}
inline bool Check(ll N, ll pos){return (bool)(N & (1LL<<pos));}

inline void normal(ll &a) { a %= mod; (a < 0) && (a += mod); }
inline ll modMul(ll a, ll b) { a %= mod, b %= mod; normal(a), normal(b); return (a * b) % mod; }
inline ll modAdd(ll a, ll b) { a %= mod, b %= mod; normal(a), normal(b); return (a + b) % mod; }
inline ll modSub(ll a, ll b) { a %= mod, b %= mod; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while (p) { if (p & 1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, mod - 2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }


template <typename T> using orderedSet = tree<T, null_type, greater<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T> using orderedSet1 = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
/*--------------------------------------------------------------------------------------------------------------------------*/



void solve () {
	string s;
	cin >> s;
	
	int n = s.size();
	
	int pot = 1;
	
	ll ans = 0;

	int suf = 0;
	vector <int> Map (mod);
	Map[suf] = 1;
	
	for (int i = n - 1; i >= 0; --i) {
		int digit = s[i] - '0';
		suf = (suf + digit * pot) % mod;
		pot = (pot * 10) % mod;
		//error (suf);
		ans += Map[suf];
		Map[suf]++;
	}
	cout << ans << endl;
}

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

/*

*/


Measured memory_bytes: 3772
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String S = scan.next();
        String T = scan.next();
        scan.close();

        int count = 0;

        for(int i = 0; i < 3; i++) {
            if (S.substring(i, i + 1).equals(T.substring(i, i + 1))) {
                count++;
            }
        }

        System.out.println(count);
    }
}

Measured memory_bytes: 23636
from collections import Counter, deque

n, m = map(int, input().split())
likes = []
for i in range(n):
    likes.append(deque(map(int, input().split())))

removed = set()
ans = n

for i in range(m):
    count = []
    for qu in likes:
        while qu and qu[0] in removed:
            qu.popleft()
        count.append(qu[0])
    v, c = Counter(count).most_common(1)[0]
    ans = min(ans, c)
    if c == 1:
        break
    removed.add(v)

print(ans)


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

int cmp(const void* x, const void* y) {
	int a = *(const int*)x, b = *(const int*)y;
	if (a < b) return -1;
	return a > b;
}

int main(void) {
	int n = 3;
	int abc[3];
	int i;
	int count;
	for (i = 0; i < n; i++) {
		if (scanf("%d", &abc[i]) != 1) return 1;
	}
	qsort(abc, n, sizeof(*abc), cmp);
	count = n > 0;
	for (i = 1; i < n; i++) {
		if (abc[i - 1] != abc[i]) count++;
	}
	printf("%d\n", count);
	return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <assert.h>
#include <sstream>
#include <string>
//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater <>())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
using namespace std;
using ll = long long;
typedef std::pair<ll,ll> P;
#include <boost/multiprecision/cpp_int.hpp>
using bint = boost::multiprecision::cpp_int;


int main(){
    bint a,b,c;
    cin >> a >> b >> c;
    bint d = c-a-b;
    if (d<0) {cout << "No"; rn 0;}
    d = d*d;
    bint e = 4*a*b;
    if (e<d){
        cout << "Yes";
    }
    else{
        cout << "No";
    }
}


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

int main(int argc, const char *argv[])
{
	char *S;
	S = malloc(21 * sizeof(char));

	scanf("%s", S);
	for (int i = 0; i < 3; i++) {
		printf("%c", S[i]);
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 1640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pii pair<int,int>
inline int read()
{
	int x=0;
	bool pos=1;
	char ch=getchar();
	for(;!isdigit(ch);ch=getchar())
		if(ch=='-')
			pos=0;
	for(;isdigit(ch);ch=getchar())
		x=x*10+ch-'0';
	return pos?x:-x;
}
int cnt[50][50];
int n,m;
int main()
{
	n=read();
	m=read();
	for(int i=1;i<=n;++i)
		{
			int k=read();
			for(int j=1;j<=k;++j)
				{
					int x=read();
					cnt[x][i]=1;
				}
		}
	int ans=0;
	for(int i=1;i<=m;++i)
		{
			int f=0;
			for(int j=1;j<=n;++j)
				f+=cnt[i][j];
			ans+=(f==n);
		}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define N 36

typedef struct{
  int suji;
  char moji;
}card;

main(){
  int n, i, j, minj, hantei = 1;
  card a[N], d[N], b, c;

  scanf("%d", &n);
  for(i = 0;i < n;i++){
    scanf(" %c%d", &a[i].moji, &a[i].suji);
  }
  for(i = 0;i < n;i++){
    d[i] = a[i];
  }
  for(i = 0;i < n-1;i++){ 
     for(j = n-1;j > i;j--){ 
       if(a[j].suji < a[j-1].suji){ 
   	b = a[j]; 
   	c = a[j-1]; 
   	a[j] = c; 
   	a[j-1] = b; 
       } 
     } 
   }
  for(i = 0;i < n;i++){
    minj = i;
    for(j = i;j < n;j++){
      if(d[j].suji < d[minj].suji){
	minj = j;
      }
    }
    b = d[i];
    c = d[minj];
    d[i] = c;
    d[minj] = b;
  }
  for(i = 0;i < n-1;i++){
    printf("%c%d ", a[i].moji, a[i].suji);
  }
  printf("%c%d\n", a[n-1].moji, a[n-1].suji);
  printf("Stable\n");
  for(i = 0;i < n-1;i++){
    printf("%c%d ", d[i].moji, d[i].suji);
  }
  printf("%c%d\n", d[n-1].moji, d[n-1].suji);
  for(i = 0;i < n;i++){
    if(a[i].moji != d[i].moji){
      hantei = 0;
      break;
    }
  }
  if(hantei == 1){
    printf("Stable\n");
  }
  else printf("Not stable\n");
  return 0;
}

Measured memory_bytes: 608
// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include<bits/stdc++.h>
using namespace std;

//for loop関係
#define rep(i,a,n) for(int i=(a);i<(n);++i)
#define repe(i,a,n) for(int i=(a);i<=(n);++i)
#define rrep(i,n,a) for(int i=(n);n>(a);--i)
#define rrepe(i,n,a) for(int i=(n);n>=(a);--i)

//略記
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define ENDL << "\n"

using ll = long long;
using P = pair<int,int>;
using itn = int;

//定数
const int INF = 1<<30;
const ll MOD = 1000000007;
const long double PI =(acos(-1));

//Degree <-> Radian
double toRad(double d){ double rad; rad=d*PI/180; return rad; }
double toDegree(double rad){ double d; d=rad*180/PI; return d; }
//The least common multiple : lcm
ll lcm(int a,int b){ return a*b/__gcd(a,b); }
//素数判定
bool isPrime(int n){
    int i; 
    if(n<2) return 0;
    else if(n==2) return 1;
    if(n%2==0) return 0;
    for(i=3;i*i<=n;i+=2) if(n%i==0) return 0;
    return 1;
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,r;
    cin >> n >> r;
    if(n<10){
        cout << r+100*(10-n) ENDL;
    }else{
        cout << r ENDL;
    }
    
    return 0;
}

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

using lint = long long;
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n, m;
  cin >> n >> m;

  int gcd;
  for (int i = m / n; i >= 1; i--) {
    if (m % i == 0) {
      gcd = i;
      break;
    }
  }

  cout << gcd << endl;
  return 0;
}


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

#define pb push_back
#define ff first
#define ss second

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

const int MAXN = 5 * 100 * 1000 + 17;

ll n, dp[MAXN], dp2[MAXN], sum;
string s;

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> s;
	s = '$' + s;
	n = s.size();
	for (int i = 2; i <= n; i++)
		dp[i] = (s[i - 1] == '<'? dp[i - 1] + 1: 0);
	for (int i = n - 1; i; i--)
		dp2[i] = (s[i] == '>'? dp2[i + 1] + 1: 0);
	for (int i = 1; i <= n; i++)
		sum += max(dp[i], dp2[i]);
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 8752
#include<bits/stdc++.h>
using namespace std;
main()
{
long long int n,i,j,k,n0=0,m,check=0,max=1000000007;
cin>>n;
long long int a[n],log[n];
for(i=0;i<n;i++)
{
    log[i]=0;
}


for(i=0;i<n;i++)
{
cin>>a[i];
log[a[i]]++;
}
/*for(i=0;i<n;i++)
{
    cout<<log[i]<<' ';
}*/



if(n%2==1)
{
if(log[0]!=1){cout<<0;return 0;}
for(j=2;j<=n;j+=2)
{
if(log[j]!=2)
{
cout<<0;
return 0;
}
}
long long int i=1,pp=(n-1)/2;
for(j=1;j<=pp;j++)
{
i=(i*2)%max;
}
cout<<i;
}


if(n%2==0)
{
    for(j=1;j<=n;j+=2)
    {
        if(log[j]!=2)
        {
            cout<<0;
            return 0;
        }
    }
    long long int i=1,pp=n/2;
    for(j=1;j<=pp;j++)
    {
        i=(i*2)%max;
    }
    cout<<i;
}





}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rrepi(i,a,b) for(int i=((int)(b)-1);i>=(a);--i)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) rrepi(i,0,n)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define ZERO(x) memset(x,0,sizeof(x))
#define MINUS(x) memset(x,-1,sizeof(x))
#define UNIQUE(x) (x).erase(unique(ALL(x)), (x).end())
#define TOUPPER(x) transform(ALL(x), (x).begin(), ::toupper)
#define TOLOWER(x) transform(ALL(x), (x).begin(), ::tolower)
#define debug(var)  do{std::cout << #var << " : "; view(var);}while(0)
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){for(const auto& v : vv){ view(v); } }
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void viewarr(T arr[], int n) { for(int i = 0; i < n; ++i) std::cout << arr[i] << " "; std::cout << std::endl; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll qp(ll a,ll b){ll ans=1;do{if(b&1)ans=1ll*ans*a;a=1ll*a*a;}while(b>>=1);return ans;}
ll qp(ll a,ll b,ll mo){ll ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const int INF = 1e9;
const ll INFL = 1e18;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5;

int main() {
    int N, M; cin >> N >> M;
    vector<int> A(N);
    rep(i,M) cin >> A[i];
    int sum = 0;
    rep(i,M) sum += A[i];
    cout << (sum <= N ? N - sum : -1) << endl;
    return 0;
}


Measured memory_bytes: 7220
#include<stdio.h>

int main(){

  int a,b,c,d,t,x,y;
  scanf("%d%d%d%d",&a,&b,&c,&d);
  t = a + b + c + d;
  x = t / 60;
  y = t % 60;

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




Measured memory_bytes: 2036
n = int(input())
s = input()

pin = []
cnt = 0

for i in range(0, 1000):
    pin.append(str(i).zfill(3))
#print(pin)

for i in range(0, 1000):
    k = 0
    for j in range(len(s)):
        if pin[i][k] == s[j]:
            k += 1
            if k == 3:
                cnt += 1
                break
                
print(cnt)

Measured memory_bytes: 73792
#include <bits/stdc++.h>
#define endl "\n"
#define ll long long int
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second
#define MAXN 1000007
#define fr(i, s, e, st) for(ll (i) = (s); (i) < (e); (i) += (st))
#define fre(i, s, e, st) for(ll (i) = (s); (i) <= (e); (i) += (st))
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
 
using namespace std;

int main()
{
    fastio;
    int T = 1;
    while(T--){
        string s;
        cin>>s;
        ll c = 0;
        fr(i, 0, s.length()/2, 1)
            if(s[i]!=s[s.length()-i-1])
                c++;
        cout<<c<<endl;
    }                                               
    return 0;
}

Measured memory_bytes: 256
from collections import Counter
n,m = map(int,input().split())
a = list(map(int,input().split()))
b = [0]
for i in range(len(a)):
    b.append((b[i]+a[i])%m)
ans = 0
for i in Counter(b).values():
    ans+=i*(i-1)//2
print(ans)

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

const int maxN = 100010;

int A[maxN];
char S[maxN], ox[maxN];

int main (){
	int i, j, c;
	scanf("%s", S);
	for(i = j = c = 0; S[i]; ++i){
		if(S[i] == 'x') ++c;
		else{
			ox[j] = S[i];
			A[j++] = c;
			c = 0;
		}
	}
	A[j] = c;
	for(i = 0; i < j; ++i) if(ox[i] != ox[j - 1 - i]) break;
	if(i == j){
		int ans = 0;
		for(i = 0; i <= j; ++i) ans += abs(A[i] - A[j - i]);
		printf("%d\n", ans / 2);
	}
	else puts("-1");
	return 0;
}


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

using namespace std;

#define endl '\n'
#define ll long long

const ll mod = 1e9 + 7;
const ll maxn = 2e5 + 5;
const double pi = 3.1415926535897932384626433832795028841971693993751058209749445923078;
//iostream::sync_with_stdio(false);

int main()
{
    int m[35] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int n;
    cin >> n;
    cout << m[n - 1] << endl;
    return 0;
}



Measured memory_bytes: 256
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
N = I()
A = I()
print(N**2-A)

Measured memory_bytes: 74512
#include <bits/stdc++.h>
    using namespace std;
    
    int main(){
        int r , g , b ;
        cin >> r >> g >> b ;
        if( (r * 100 + g * 10 + b) % 4 == 0){
            cout << "YES" << endl;
        }else{
            cout << "NO" << endl;
        }
        
        return 0;
    }

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

using namespace std;

#define llong long long int
#define ldouble long double
#define rep(i, n) for (int i = 0; i < n; ++i) 
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define stl_repr(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

constexpr static int MOD = 1000000000 + 7;
constexpr static int inf = INT_MAX / 2;
constexpr static llong INF = 1LL << 31;
constexpr static int dx[] = {1, 0, -1, 0};
constexpr static int dy[] = {0, 1, 0, -1};

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

    llong r, d, x;
    cin >> r >> d >> x;
    rep(i, 10) {
        llong xnew = r * x - d;
        cout << xnew << endl;
        x = xnew;
    }

    return 0;
}

Measured memory_bytes: 256
k, n = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
l = []

l.append(abs(k + a[0] - a[n - 1]))

for i in range(1, n):
    dis = abs(a[i] - a[i - 1])
    l.append(dis)
 
print(sum(l) - max(l))


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

#ifdef MYDEBUG
#define dbp(x) cout<<#x<<": "<<x<<endl
#define dbp2(x,y) cout<<#x<<","<<#y<<": "<<x<<","<<y<<endl
#define dbp3(x,y,z) cout<<#x<<","<<#y<<","<<#z<<": "<<x<<","<<y<<","<<z<<endl
#else
#define dbp(x)
#define dbp2(x,y)
#define dbp3(x,y,z)
#endif
#define ll long long
#define ull unsigned long long
#define eps 1e-14
#define all(x) x.begin(), x.end()
#define rep(i, from, to) for(int i=from; i<to; ++i)

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
  out << "[";
  size_t last = v.size() - 1;
  for (size_t i = 0; i < v.size(); ++i) {
    out << v[i];
    if (i != last)
      out << ",";
  }
  out << "]";
  return out;
}
struct edge {
  ll from, to, cost;
  edge(ll f, ll t, ll c) {
    from = f;
    to = t;
    cost = c;
  }
};

typedef struct edge edge;
const long long maxn = 1010;
int n, m;
const ll INF = 1e18 * -1;
vector<edge> g;
ll dist[maxn];
void solve() {
  cin >> n >> m;
  for (long long i = 0; i < m; ++i) {
    ll a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    g.push_back(edge(a, b, c));
  }
  //start is 0
  fill(dist, dist + maxn, INF);
  dist[0] = 0;
  int i = 0;
  bool change = true;
  int last = 0;
  while (change) {
    change = false;
    for (size_t k = 0; k < g.size(); ++k) {
      edge e = g[k];
      if (dist[e.from] != INF && e.cost + dist[e.from] > dist[e.to]) {
        dist[e.to] = e.cost + dist[e.from];
        if (e.to == n - 1) {//ゴールに至るスコアを更新した最後の反復回数iを持っとく
          last = i;
        }
        change = true;
        if (i == n) {//ベルマンフォード法でいう負の閉路発見（ここでは、スコアを際限なく増やせる正の閉路）
          if (last >= n - 1) {//n - 1回目以降でゴールNのスコア更新 ⇔ スタート～ゴール間にぐるぐる回れる閉路あり
            cout << "inf" << endl;
          } else {//閉路があっても、それがゴールに絡まないならinfでない。コーナーケース対策
            cout << dist[n - 1] << endl;
          }
          return;
        }
      }
    }
    i++;
  }
  cout << dist[n - 1] << endl;
}

int main() {
  solve();
  return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define mp1(a,b,c) P1(a,P(b,c))
#define pque(a) priority_queue<a>
#define rpque(a) priority_queue<a,vector<a>,greater<a>>

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};
const int kaijou[10]={1,1,2,6,24,120,720,5040,40320,362880};

int main(){
	while(1){
		static int n,m,h,k;
		static int s[1002];
		static int a[100010],b[100010];
		
		rep(i,1002)s[i] = 0;
		rep(i,100010){
			a[i] = 0;
			b[i] = 0;
		}
		
		scanf("%d%d%d%d",&n,&m,&h,&k); if(n == 0)break;
		rep1(i,n){
			scanf("%d",&s[i]);
		}
		rep(i,m){
			scanf("%d%d",&a[i],&b[i]);
		}
		
		vector<P> vec;
		rep(i,m){
			vec.pb ( P ( b[i] , a[i] ) );
		}
		sor(vec);
		rep(i,m){
			a[i] = vec[i].sc;
			b[i] = vec[i].sc+1;
		}
		
		static int ln[100010],rn[100010];
		static int num[1002] = {};
		rep1(i,k)num[i] = 1;
		
		rep(i,100010){
			ln[i] = 0;
			rn[i] = 0;
		}
		rep(i,1002){
			num[i] = 0;
		}
		rep1(i,k){
			num[i] =1;
		}
		
		rep(i,m){
			ln[i] = num[a[i]];
			rn[i] = num[b[i]];
			swap(num[a[i]],num[b[i]]);
		}
		
		static int ls[100010],rs[100010];
		
		rep(i,100010){
			ls[i] = 0;
			rs[i] = 0;
		}
		
		rrep(i,m){
			swap(s[a[i]],s[b[i]]);
			ls[i] = s[a[i]];
			rs[i] = s[b[i]];
		}
		
		int sum = 0;
		rep1(i,k){
			sum += s[i];
		}
		
		int ret = 0;
		rep(i,m){
			if(ln[i] > rn[i]){
				ret = min ( ret , rs[i] - ls[i] );
			}
			if(ln[i] < rn[i]){
				ret = min ( ret , ls[i] - rs[i] );
			}
		}
		
		printf("%d\n",sum+ret);
	}
}

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

// boost
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;

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

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

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

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
// #define mod (998244353ll)

const long long INF = 1LL << 60;

ll d;
vll c(26);
vvll s;

void create_first_answer(vll& ans) {
  vll last(26, -1);

  rep(today, d) {
    vll cand(26);

    rep(j, 26) {
      cand[j] = s[today][j] + c[j] * (today - last[j]);
    }

    ll choice = distance(cand.begin(), max_element(all(cand)));
    ans[today] = choice;
    last[choice] = today;
  }
}

ll update_diff(ll idx, const vll& choice) {
  ll last = -1;
  ll total = 0;
  rep(today, d) {
    if (choice[today] == idx) {
      last = today;
      total += s[today][idx];
    } else {
      total -= c[idx] * (today - last);
    }
  }
  return total;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  cin >> d;
  rep(i, 26) {
    cin >> c[i];
  }

  s = vvll(d, vll(26));
  rep(i, d) {
    rep(j, 26) {
      cin >> s[i][j];
    }
  }

  srand(s[0][0]);

  vll ans(d);

  create_first_answer(ans);

  vll score_con(26);
  ll score = 0;

  rep(i, 26) {
    score_con[i] = update_diff(i, ans);
    score += score_con[i];
  }

  rep(i, 90000) {
    vll cand = ans;
    vb changed(26);

    rep(j, (rand() % 6) + 1) {
      ll tgt = (i + j) % d;
      cand[tgt] = rand() % 26;

      changed[ans[tgt]] = true;
      changed[cand[tgt]] = true;
    }

    ll cs = score;
    vll score_cand = score_con;
    rep(i, 26) {
      if (changed[i]) {
        cs -= score_cand[i];
        score_cand[i] = update_diff(i, cand);
        cs += score_cand[i];
      }
    }
    if (cs > score) {
      ans = cand;
      score_con = score_cand;
    }
  }

  rep(i, d) {
    cout << ans[i] + 1 << endl;
  }

  return 0;
}


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

inline int Input() {
	char c = getchar(); int x = 0, z = 1;
	for(; c < '0' || c > '9'; c = getchar()) z = c == '-' ? -1 : 1;
	for(; c >= '0' && c <= '9'; c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
	return x * z;
}

int main() {
	int a = Input(), b = Input();
	for (int i = 1; i <= 3; ++i) if ((a * b * i) & 1) return puts("Yes"), 0;
	return puts("No"), 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//s[i]-'0'でchar文字→int数に;
//string s = to_string(int数);
//int n = stoi(string文字列)
//実行時間制約2秒では２×10^8回くらいまで計算できる


int main() {
  ll n,b,c;
  cin >> n >> b >> c;
  
  vector<ll> p(n,b-c);
  rep(i,c){
  ll x;
  cin >> x;
  p[x-1]++;
  }
  
  rep(i,n){
  cout << (p[i]>0?"Yes":"No") << endl;
  }

}

Measured memory_bytes: 1408
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int N;
map<int,int> m;

int main(){
    cin>>N;
    rep(i,N){
        int a;
        cin>>a;
        m[a]=m[a]^1;
    }

    int ans=0;
    repr(e,m){
        if(e.second) ans++;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 4864
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
typedef long long ll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)

int d[105][(1<<8)][105],n,m,e,s,t,r;
vector<int>edge[105];
vector<int>ev[105];
P pp[10];
int main()
{
	cin >> n >> m >> e >> s >> t >> r;
	
	for(int i=0;i<m;i++)
	{
		int a,b; scanf("%d%d",&a,&b);
		edge[a].pb(b); edge[b].pb(a);
	}
	for(int i=0;i<e;i++)
	{
		int a,b,c; scanf("%d%d%d",&a,&b,&c);
		ev[c].pb(i);
		pp[i] = mp(a,b);
	}
	for(int i=0;i<105;i++) for(int j=0;j<(1<<8);j++) for(int k=0;k<105;k++)d[i][j][k]=INF;
	priority_queue<P2,vector<P2>,greater<P2> >que;
	int mask = 0;
	for(int j=0;j<ev[s].size();j++) mask += (1<<ev[s][j]);
	d[s][mask][0] = 0;
	que.push(mp(mp(0,s),mp(mask,0)));
	
	while(!que.empty())
	{
		P2 p = que.top(); que.pop();
		
		if(d[p.fi.sc][p.sc.fi][p.sc.sc] != p.fi.fi) continue;
		
		if(d[s][p.sc.fi][0] > p.fi.fi+1)
		{
			d[s][p.sc.fi][0] = p.fi.fi+1;
			que.push(mp(mp(p.fi.fi+1,s),mp(p.sc.fi,0)));
		}
		if(p.sc.sc == r) continue;
		for(int j=0;j<edge[p.fi.sc].size();j++)
		{
			int x = edge[p.fi.sc][j];
			int a = p.sc.fi;
			for(int j=0;j<ev[x].size();j++) a |= (1<<ev[x][j]);
			if(d[x][a][p.sc.sc+1] > p.fi.fi+1)
			{
				d[x][a][p.sc.sc+1] = p.fi.fi+1;
				que.push(mp(mp(p.fi.fi+1,x),mp(a,p.sc.sc+1)));
			}
		}
		for(int j=0;j<e;j++)
		{
			if(!((p.sc.fi>>j)&1)) continue;
			int x;
			if(pp[j].fi == p.fi.sc)
			{
				x = pp[j].sc;
			}
			else if(pp[j].sc == p.fi.sc)
			{
				x = pp[j].fi;
			}
			else
			{
				continue;
			}
			int a = p.sc.fi;
			for(int j=0;j<ev[x].size();j++) a |= (1<<ev[x][j]);
			if(d[x][a][p.sc.sc+1] > p.fi.fi+1)
			{
				d[x][a][p.sc.sc+1] = p.fi.fi+1;
				que.push(mp(mp(p.fi.fi+1,x),mp(a,p.sc.sc+1)));
			}
		}
	}
	int res = INF;
	for(int i=0;i<(1<<8);i++) for(int j=0;j<=r;j++) res = min(res,d[t][i][j]);
	if(res == INF) puts("-1");
	else printf("%d\n",res);
}

Measured memory_bytes: 14248
import java.util.HashMap;
import java.util.Scanner;

public class Main{

	public static void main (String[] args) {

		Scanner sc = new java.util.Scanner (System.in);

		int N = sc.nextInt();
		String s = sc.next();

		String[] list  = new String[s.length()];
		list = s.split("");

		String[] moji = new String[26];

		moji[0]="A";
		moji[1]="B";
		moji[2]="C";
		moji[3]="D";
		moji[4]="E";
		moji[5]="F";
		moji[6]="G";
		moji[7]="H";
		moji[8]="I";
		moji[9]="J";
		moji[10]="K";
		moji[11]="L";
		moji[12]="M";
		moji[13]="N";
		moji[14]="O";
		moji[15]="P";
		moji[16]="Q";
		moji[17]="R";
		moji[18]="S";
		moji[19]="T";
		moji[20]="U";
		moji[21]="V";
		moji[22]="W";
		moji[23]="X";
		moji[24]="Y";
		moji[25]="Z";

		HashMap <String, Integer> map = new HashMap <String,Integer>();

		map.put("A",1);
		map.put("B",2);
		map.put("C",3);
		map.put("D",4);
		map.put("E",5);
		map.put("F",6);
		map.put("G",7);
		map.put("H",8);
		map.put("I",9);
		map.put("J",10);
		map.put("K",11);
		map.put("L",12);
		map.put("M",13);
		map.put("N",14);
		map.put("O",15);
		map.put("P",16);
		map.put("Q",17);
		map.put("R",18);
		map.put("S",19);
		map.put("T",20);
		map.put("U",21);
		map.put("V",22);
		map.put("W",23);
		map.put("X",24);
		map.put("Y",25);
		map.put("Z",26);

		for (int index=0; index<s.length(); index++) {
			int num = N+map.get(list[index])-1;

			if (num>=26) {
				num-=26;
			}
			list[index]=moji[num];
		}

		for (int index=0; index<s.length(); index++) {
			System.out.print(list[index]);
		}

		System.out.println();
		sc.close();


	}
}

Measured memory_bytes: 26068
//https://atcoder.jp/contests/abl/tasks/abl_c
//查并集
#include <bits/stdc++.h>

using namespace std;

map<int, int> ds;
map<int, int> ranks;

int find_root(int x) {
    return x==ds[x]?x:ds[x]=find_root(ds[x]);
}

void union_set(int x, int y) {
    int x_root=find_root(x);
    int y_root=find_root(y);
    if (x_root!=y_root) {
        if (ranks[x_root]>ranks[y_root]) {
            ds[y_root]=x_root; 
        } else if (ranks[x_root]<ranks[y_root]) {
            ds[x_root]=y_root;
        } else {
            ds[x_root]=y_root;
            ranks[y_root]++;
        }
    }
}

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

    //初始化
    for (int i=1; i<=n; i++) {
        ds[i]=i;
        ranks[i]=0;
    }

    int cnt=0;
    for (int i=1; i<=m; i++) {
        int x,y;
        cin>>x>>y;

        x=find_root(x);
        y=find_root(y);
        if (x==y) {
            continue;
        }

        union_set(x, y);
        cnt++;
    }

    cnt=n-1-cnt;
    if (cnt<0) {
        cnt=0;
    }
    cout<<cnt<<"\n";

    return 0;
}

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

int main(){
    long N,K,tmp=1e9;
    cin >> N >> K;
    vector<long> h(N);
    for(int i=0;i<N;++i) cin >> h[i];

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

    for(int i=0;i<N-K+1;++i){
        tmp = min(tmp,h[i+K-1] - h[i]);
    }

    cout << tmp << endl;

}


Measured memory_bytes: 1024
require 'set'

s = gets.chomp
gx, gy = gets.split.map(&:to_i)

a = []
t = 0
n = s.length
n.times do |i|
  
  t += 1 if s[i] ==  ?F
  
  if s[i] == ?T || i == n - 1
    a << t
    t = 0
  end
end

xstep = []
ystep = []
a.each_with_index do |i, j|
  xstep << i if j.even?
  ystep << i if j.odd?
end

gx = gx - xstep[0]
xstep = xstep[1..-1]

xsum = xstep.inject(:+)
ysum = ystep.inject(:+)

xsum = 0 if xsum.nil?
ysum = 0 if ysum.nil?

# p [xstep, ystep]

# p [gx, gy]
# p [xsum, ysum]

if gx > xsum || gy > ysum
  puts "No"
  exit
end

if gx == xsum && gy == ysum
  puts "Yes"
  exit
end

dx = xsum - gx
dy = ysum - gy

nx = xstep.size
ny = ystep.size

hx = Array.new(nx+1){ Hash.new(false) }
hy = Array.new(ny+1){ Hash.new(false) }

hx[0][0] = true
nx.times do |i|
  
  hx[i].each do |v,k|
    hx[i+1][v] = true
    hx[i+1][v+2*xstep[i]] = true
  end
end

# p [dx, dy]
# p [hx, hy]

hy[0][0] = true
ny.times do |i|
  
  hy[i].each do |v,k|
    # p hy
    hy[i+1][v] = true
    hy[i+1][v+2*ystep[i]] = true
  end
end



if hx[nx][dx] && hy[ny][dy]
  puts "Yes"
else
  puts "No"
end



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

int main()
{
    int a,b,c,d,i,j;
    while(~scanf("%d %d %d %d",&a,&b,&c,&d))
    {
        if(a>b)
        {
            i=b;
        }
        if(a<=b)
        {
            i=a;
        }
        if(c>d)
        {
            j=d;
        }
        if(c<=d)
        {
            j=c;
        }
        printf("%d\n",i+j);
    }


    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		boolean ans = false;
		for (int i = 0; i <= n / 7; i++) {
			if ((n - i * 7) % 4 == 0) {
				ans = true;
			}
		}

		if (ans) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 23764
public class Main {
	public static void main(String[]args) {
		
		java.util.Scanner scanner = new java.util.Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int c = scanner.nextInt();
		
		if ( a < b && b < c ) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 26352
#include<stdio.h>

int S[1000000],n;
int binarySearch(int);


int binarySearch(int key){
  int l=0;
  int r=n;
  int mid;
  while(l<r){
    mid=(l+r)/2;
    if(key==S[mid])return 1;
    if(key>S[mid])l=mid+1;
    else if(key<S[mid])r=mid;
  }
  return 0;
}


int main(){
  int a,q,T[1000000],sum=0;


  scanf("%d",&n);
  for(a=0;a<n;a++){
    scanf("%d",&S[a]);
  }



  scanf("%d",&q);
  
  for(a=0;a<q;a++){
    scanf("%d",&T[a]);
    if(binarySearch(T[a]))sum++;
  }
  
  printf("%d\n",sum);


  return 0;
  
}

  



Measured memory_bytes: 2284