akhauriyash/Code-Regression huggingface dataset:
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;

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

	cin >> N;
	vector<int>ans;
	int index = 1;	
	int box = 1;
	while (box * 2 <= N) {
		box *= 2;
	}
	M = box;
	box /= 2;
	while (box) {
		ans.push_back(index);
		ans.push_back(index + 1);
		ans.push_back(box);
		ans.push_back(index);
		ans.push_back(index + 1);
		ans.push_back(0);
		index++;
		box /= 2;
	}
	vector<int>num(20);
	num[0] = 0;
	for (int i = 1; i < 20; i++) {
		num[i] = num[i - 1] * 2 + 1;
	}
	if (M + 1 == N) {
		ans.push_back(1);
		ans.push_back(index);
		ans.push_back(M);
		M++;
	}
	//cout << index << endl;
	while (M < N) {
	//	cout << M << endl;
		int box = 0;
		for (int i = 0; i < 20; i++) {
			if (M + num[i] < N) {
				box = i;
			}
		}
		ans.push_back(1);
		ans.push_back(index - box);
		ans.push_back(M);
		M += num[box] + 1;
	}
	cout << index << " " << ans.size() / 3 << endl;
	for (int i = 0; i < ans.size(); i++) {
		cout << ans[i];
		if (i % 3 == 2) cout << endl;
		else cout << " ";
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace  std;
using ll = long long;
#define REP(i, n) for(long long (i)=0, i_bound = (long long)(n); (i)<i_bound; ++i)
#define ALL(a) (a).begin(),(a).end()
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }

vector<int> Zalgorithm(string &S){
    int N = (int)S.size();
    vector<int> res(N);
    res[0] = N;
    int i = 1;
    int j = 0;
    while(i<N){
        while(i+j<N and S[j]==S[i+j]) j++;
        res[i] = j;
        if(j==0) {++i; continue;}
        int k = 1;
        while(i+k<N and k + res[k] < j){
            res[i+k] = res[k];
            k++;
        }
        i += k;
        j -= k;
    }
    return res;
}

int main(){
    cin.tie(0);
    cout.sync_with_stdio(false);
    int N; cin>>N;
    string s;
    cin>>s;
    int res = 0;
    for(int i=0; i<N; i++){
        string t = s.substr(i);
        auto z = Zalgorithm(t);
        for(int j=0; j<t.size(); j++){
            if(z[j]>j) res = max(res, j);
            else res = max(res, z[j]);
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long
#define ar array<int,2>
#define inf 1000000000000000000 
int mod=1e9+7;
int min(int a,int b){return (a<b)?a:b;}
int max(int a,int b){return (a>b)?a:b;}
int fp(int a,int b){if(b==0) return 1;int x=fp(a,b/2);x=(x*x)%mod;if(b&1) x=(x*a)%mod;return x;}


const int N=2e5+5;



void solve()
{
    int d,t,s;
    cin>>d>>t>>s;
    int x=(d+s-1)/s;
    if(x<=t)
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
}

signed main() {
 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
 srand(time(0));
 int t;
 t=1;
 for(int i=1;i<=t;i++)
 {
   solve();
 }


}

Measured memory_bytes: 3648
// inputに入力データ全体が入る
function Main(input) {
  var str = input.split('\n');

  var tmp = str[0].split(' ');
  var N = parseInt(tmp[0]);
  var M = parseInt(tmp[1]);
  var X = parseInt(tmp[2]);
  var Y = parseInt(tmp[3]);

  var tmp2 = str[1].split(' ');
  var numX = [];
  for (var i = 0; i < N; i++){
    numX.push(parseInt(tmp2[i]));
  }
  // 降順
  numX.sort(function(a, b){
    return (b - a);
  });

  var tmp3 = str[2].split(' ');
  var numY = [];
  for (var i = 0; i < M; i++){
    numY.push(parseInt(tmp3[i]));
  }
  // 昇順
  numY.sort(function(a, b){
    return (a - b);
  });

  if(numY[0] - numX[0] <= 0){
    console.log("%s", 'War');
    return;
  }

  if(X >= numX[0]){
    console.log("%s", 'War');
    return;
  }

  if (numY[0] > Y){
    console.log("%s", 'War');
    return;
  }

  console.log("%s", 'No War');
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));



Measured memory_bytes: 9420
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define all(a) (a).begin(), (a).end()


int main(){
    int N;
    cin >> N;
    ll count = 0;
    for(int i = 1; i <= N;i ++) if(i % 3 != 0 and i % 5 != 0) count+=i;
    cout << count << endl;
}


Measured memory_bytes: 3552
def main():
    N = int(input())
    S = input()
    ans = 0

    for i in range(10):
        for j in range(10):
            for k in range(10):
                i_index = S.find(str(i))
                if i_index == -1:
                    continue

                j_index = S.find(str(j), i_index + 1)
                if j_index == -1:
                    continue

                k_index = S.find(str(k), j_index + 1)
                if k_index != -1:
                    ans += 1

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9232
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<cmath>
#include<limits>
#define ll long long
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define pint_INF 2000000000
#define ll_INF 	9223372036854775807
#define MOD 1000000007
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvll vector<vector<long long>>
#define vvc vector<vector<char>>
#define vll vector<long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
#define sysp system("PAUSE")
#define pno cout << "no" << endl
#define pyes cout << "yes" << endl
#define pYes cout << "Yes" << endl
#define pNo cout << "No" << endl
using namespace std;


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

    for (int i = 1; i * i <= M; i++) {
        if (M % i == 0) {
            if (i != M / i) {
                vec.push_back(i - N);
                vec.push_back(M / i - N);
            }
            else {
                vec.push_back(i - N);
            }
        }
    }
    sort(ALL(vec));
    auto iter = lower_bound(ALL(vec), 0);
    ll S = *iter + N;
    ll g = M / S;
    
    cout << g << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <cstring>
#include <algorithm>
#include <functional>
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
 
int main () {
  int n;
  cin >> n;
  int i = 1;
  while (i * 2 <= n){
    i = i * 2;
  }
 
  cout << i << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		
		System.out.println(Math.min(A * N, B));
	}
}

Measured memory_bytes: 21844
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline int my_getchar_unlocked(){
  static char buf[1048576];
  static int s = 1048576;
  static int e = 1048576;
  if(s == e && e == 1048576){
    e = fread_unlocked(buf, 1, 1048576, stdin);
    s = 0;
  }
  if(s == e){
    return EOF;
  }
  return buf[s++];
}
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = my_getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = my_getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
struct MY_WRITER{
  char buf[1048576];
  int s;
  int e;
  MY_WRITER(){
    s = 0;
    e = 1048576;
  }
  ~MY_WRITER(){
    if(s){
      fwrite_unlocked(buf, 1, s, stdout);
    }
  }
}
;
MY_WRITER MY_WRITER_VAR;
void my_putchar_unlocked(int a){
  if(MY_WRITER_VAR.s == MY_WRITER_VAR.e){
    fwrite_unlocked(MY_WRITER_VAR.buf, 1, MY_WRITER_VAR.s, stdout);
    MY_WRITER_VAR.s = 0;
  }
  MY_WRITER_VAR.buf[MY_WRITER_VAR.s++] = a;
}
inline void wt_L(char a){
  my_putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    my_putchar_unlocked('-');
  }
  while(s--){
    my_putchar_unlocked(f[s]+'0');
  }
}
int N;
int A[100];
int main(){
  int i;
  int res = 0;
  rd(N);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=(0);Lj4PdHRW<(N);Lj4PdHRW++){
      rd(A[Lj4PdHRW]);
    }
  }
  for(i=(0);i<(N);i+=(2)){
    if(A[i]%2){
      res++;
    }
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20200509-1

// --- original code ---
// int N, A[100];
// {
//   int res = 0;
//   rd(N,A(N));
//   rep(i,0,N,2) if(A[i]%2) res++;
//   wt(res);
// }


Measured memory_bytes: 3640
#include <stdio.h>

int main()
{
    int a, b, c, d;
    int s, e, t;
    while(scanf("%d%d%d%d", &a, &b, &c, &d) != EOF)
    {
        if(b <= c || d <= a)
            t = 0;
        else
        {
            s = (a > c) ? a : c;
            e = (b < d) ? b : d;
            t = e - s;
        }
        printf("%d\n", t);
    }
    return 0;
}




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

using namespace std;
typedef long long ll;

ll mergeCnt_inversion(vector<int>& v) {
    int n = v.size();
    if (n <= 1) {
        return 0;
    }

    ll cnt = 0;
    vector<int> v1(v.begin(), v.begin() + n / 2);
    vector<int> v2(v.begin() + n / 2, v.end());

    cnt += mergeCnt_inversion(v1);
    cnt += mergeCnt_inversion(v2);

    int i = 0, i1 = 0, i2 = 0;

    while (i < n) {
        if (i1 < n / 2 && (i2 == n - n / 2 || v1[i1] <= v2[i2])) {
            v[i] = v1[i1];
            i1++;
        }
        else {
            cnt += n / 2 - i1;
            v[i] = v2[i2];
            i2++;
        }
        i++;


    }

    return cnt;

}

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

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

    ll len = ((1LL * n) * (n + 1)) / 2;
    ll cri = (len) / 2 + ((len % 2 == 0) ? 0 : 1);
    //ll MAX = 1LL * (n + 1) + (n + 1);

   // cout << cri << endl;
    vector<int> b(a);
    sort(b.begin(), b.end());


    int r = n - 1;
    int l, mid;
    {
        int x = b[r];
        vector<int> s(n + 1);

        s[0] = 0;
        for (int i = 1; i <= n; i++) {
            s[i] = s[i - 1] + ((a[i - 1] < x) ? -1 : 1);
            //cout << s[i] << endl;
        }
        // cout << len - mergeCnt_inversion(s) << endl;
        if (len - mergeCnt_inversion(s) < cri) {
            l = 0;
        }
        else {
            l = n - 1;
        }
    }
    //cout << l << endl;
    mid = (l + r) / 2;


    while (l != mid) {

        int x = b[mid];
        vector<int> s(n + 1);

        s[0] = 0;
        for (int i = 1; i <= n; i++) {
            s[i] = s[i - 1] + ((a[i - 1] < x) ? -1 : 1);
        }

        // cout << len - mergeCnt_inversion(s) << endl;
        // cout << len - mergeCnt_inversion(s) << endl;
        if (len - mergeCnt_inversion(s) < cri) {
            r = mid;

        }
        else {
            l = mid;
        }
        mid = (r + l) / 2;
        // cout << mid << endl;
    }

    cout << b[l] << endl;

} 

Measured memory_bytes: 2252
#include <stdio.h>
#define N 100

int main()
{
  int b,c,i,j,k,v;
  int A[N];

  scanf("%d",&b);
  for(i=0;i<b;i++)
    scanf("%d",&A[i]);
   for(j=0;j<b;j++){
      printf("%d",A[j]);
      if(j<b-1) printf(" ");
    }
    printf("\n");
  for(i=1;i<b;i++){
    v=A[i];
    j=i-1;
    while((j>=0)&&(A[j]>v)){
	A[j+1]=A[j];
	j--;
     A[j+1]=v;
    }
    for(j=0;j<b;j++){
      printf("%d",A[j]);
      if(j<b-1) printf(" ");
    }
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2112
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

#define mp make_pair
#define pb push_back
#define pf push_front
#define ss second
#define ff first
#define sz(x) (int)x.size()
#define newl "\n"
#define vi vector<int>
#define pii pair<int, int>
#define vii vector<pii>
#define vl vector<ll>
#define pll pair<ll, ll>
#define vll vector<pll>
#define coutp cout << fixed << setprecision(12)
#define mem(x, val) memset(x, val, sizeof(x))
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define all(v) (v).begin(), (v).end()

const ld pi = 3.14159265359;
ll INF = 1e18 + 10;
ll MOD = 998244353;
ll mod = 1e9 + 7;

inline ll add(ll a, ll b, ll m)
{
    if ((a + b) >= m)
        return (a + b) % m;
    return a + b;
}

inline ll mul(ll a, ll b, ll m)
{
    if ((a * b) < m)
        return a * b;
    return (a * b) % m;
}

ll power(ll x, ll y, ll m)
{
    ll res = 1;
    x = x % m;
    if (x == 0)
        return 0;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % m;
        y = y >> 1;
        x = (x * x) % m;
    }
    return res;
}

void solve()
{
    int n,m;
    cin>>n>>m;
    vector<string> a(n),b(m);
    for(int i=0;i<n;i++) {
        cin>>a[i];
    }
    for(int i=0;i<m;i++) {
        cin>>b[i];
    }

    for(int i=0;i<n-m+1;i++) {
        for(int j=0;j<n-m+1;j++) {
            bool f=1;
            for(int p=0;p<m;p++) {
                for(int q=0;q<m;q++) {
                    if(a[p+i][q+j]!=b[p][q]) {
                        f=0;
                        break;
                    }
                }
                if(!f) {
                    break;
                }
            }
            if(f) {
                cout<<"Yes";
                return;
            }
        }
    }

    cout<<"No";
}

int main()
{
    fastio;
    int t;
    t = 1;
    //cin >> t;
    //int test=t;
    
    while (t-- > 0)
    {
        //cout<<"Case #"<<(test-t)<<": ";
        solve();
        cout << newl;
    }

    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

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

    map<char,int> mapS;
    for(auto s:S) mapS[s]++;

    map<char,int> mapSubS;
    int64_t ans=0;
    rep(i,0,N-1){
        int64_t _ans=0;
        mapSubS[S.at(i)]++;
        for(auto _s:mapSubS){
            if(mapS[_s.first]-_s.second>0) _ans++;
        }

        ans=max(ans,_ans);
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ll long long
#define ld long double
#define MOD 1000000007
#define nl cout << bl
#define rt ll Q[100005] = {0}
#define mp make_pair
#define test() \
    ull t;     \
    cin >> t;  \
    while (t--)
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define s(ar, n) sort(ar, ar + n)
#define rs(ar, n) sort(ar, ar + n, greater<ll>())
#define oa(a, n)               \
    for (ll i = 0; i < n; i++) \
        cout << a[i] << " ";
#define cn(a, n)               \
    for (ll i = 0; i < n; i++) \
        cin >> a[i];
#define ov(a, n)                    \
    for (ll i = n - 1; i >= 0; i--) \
        cout << a[i] << " ";        \
    nl
#define ovp(a, n)              \
    for (ll i = 0; i < n; i++) \
        cout << a[i].ff << " " << a[i].ss << bl;
#define maxa(ar, N) *max_element(ar, ar + N)
#define mina(ar, N) *min_element(ar, ar + N)
#define present(c, x) ((c).find(x) != (c).end())
#define fastio()                  \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
typedef pair<int, int> pii;
ll fast_exp(ll base, ll exp)
{
    ll res = 1;
    while (exp > 0)
    {
        if (exp % 2 == 1)
            res = (res * base) % MOD;
        base = (base * base) % MOD;
        exp /= 2;
    }
    return res % MOD;
}
ll fib(ll n)
{
    if (n < 2)
        return n;
    ll a = 0, b = 1, pre;
    int i = 1;
    while (i < n)
    {
        pre = (a + b) % MOD;
        a = b;
        b = pre;
        i++;
    }
    return pre;
}
ll fac(ll n)
{
    if (n % 2 == 0)
        return 2;

    for (ll i = 3; i * i <= n; i += 2)
    {
        if (n % i == 0)
            return i;
    }

    return n;
}
ll fact(ll n)
{
    if (n > 1)
        return n * fact(n - 1);
    else
        return 1;
}
bool sortbysec(const tuple<int, int, int> &a,
               const tuple<int, int, int> &b)
{
    return (get<1>(a) < get<1>(b));
}
int last_digit(int n)
{
    int ans = 0;
    while (n != 0)
    {
        ans = n % 10;
        n /= 10;
    }
    return ans;
}
int main()
{
    int n;
    cin >> n;
    vector<vector<int>> dp(10, vector<int>(10, 0));
    for (int i = 1; i <= n; i++)
    {
        int first = i % 10;
        int last = last_digit(i);
        dp[first][last]++;
    }
    ll total = 0;
    for (int i = 0; i < 10; i++)
    {
        for (int j = 0; j < 10; j++)
        {
            total += (dp[i][j] * dp[j][i]);
        }
    }
    cout << total;
}

Measured memory_bytes: 3600
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>
#include<bits/stdc++.h>
#define se cout << "test ok" << endl;
#define sp << " " <<
#define enl "\n"
using namespace std;
using ll=long long;
using ld=long double;
ll mod = ll(1e9)+7;
ll inf = ll(1e18);
void bl(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void bl2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b){a=b; return true;} return false; }
template<typename T> inline bool chmin(T &a, T b){ if(a>b){a=b; return true;} return false; }
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

#include <iostream>
#include <vector>
#include <map>
using namespace std;

namespace dbg {
    using ll = long long;

    class Debug {
    public:
        Debug(){}
        template<typename T>
        void vd(vector<T> vec);
        template<typename T>
        void vd2(vector<vector<T>> vec);
        template<typename T>
        void ad(T *arr, ll n);
        template<typename T, size_t N>
        void ad2(T (&arr)[N], ll n);
        template<typename T>
        void md(T mp);
    };

    template<typename T>
    void Debug::vd(vector<T> vec) {
        for (auto vv : vec) cout << vv << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::vd2(vector<vector<T>> vec) {
        for (auto vv : vec) {
            for (auto vvv : vv) cout << vvv << " ";
            cout << endl;
        }
    }

    template<typename T>
    void Debug::ad(T *arr, ll n) {
        for (int i = 0; i <= n; i++) cout << arr[i] << " ";
        cout << endl;
    }

    template<typename T, size_t N>
    void Debug::ad2(T (&arr)[N], ll n) {
        for (int i = 0; i <= N; i++) for (int j = 0; j <= n; j++) cout << arr[i][j] << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::md(T mp) {
        cout << "key : value" << endl;
        for (auto const &m : mp) cout << m.first << " : " << m.second << endl;
        cout << endl;
    }

}

#endif //INCLUDE_DEBUG_HPP

using dbg::Debug;
Debug debug;

class a {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int n, q;
	    in >> n;
	    set<int> s;
	    int sin;
	    for(int i=0; i<n; i++){
	        in >> sin;
	        s.insert(sin);
	    }
	    in >> q;
	    vector<int> t(q);
	    for(int i=0; i<q; i++){
	        in >> t[i];
	    }

	    int cnt = 0;
	    for(int i=0; i<q; i++){
            if(s.find(t[i]) != s.end()) cnt++;
	    }

	    out << cnt << enl;
	}
};


int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
	a solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}



Measured memory_bytes: 7784
#include <iostream>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int N;
  cin >> N;
  string str;
  int ans = 0;

  rep(i, N) {
    str = to_string(i + 1);
    if (str.size() % 2 == 1) ans++;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(a) (a).begin(),(a).end()
#define rep(i,n) for(ll (i)=0,(i##_len)=(n);(i)<(i##_len);(i)++)
#define rep2(i,a,b) for(ll (i)=(a),(i##_len)=(b);(i)<=(i##_len);(i++))
#define rrep(i,n) ll(i)=(n);ll now=-1;while((i)--&&(now++||1))
#define Yes(n) cout<<((n)?Yes:No)<<"\n"
#define vll vector<ll>
#define pb push_back
using namespace std;
using ll = long long;

static inline void ignore_ret(int x) {}
template<class T> bool chmax(T&a,const T&b){if(a<b){a=b;return true;}return false;}
template<class T> bool chmin(T&a,const T&b){if(a>b){a=b;return true;}return false;}
template<class T> T abs(T x){return max(x,-x);}
template<class T> T gcd_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=gcd(r,v.at(i));return r;}
template<class T> T lcm(T m,T n) {return m*n/gcd(m,n);}
template<class T> T lcm_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=lcm<T>(r,v.at(i));return r;}
template<class T> T factorial(T n){if(n==0)return 1;T r=1;for(T i=2;i<=n;i++)r*=i;return r;}
template<class T> T nCr(T n,T k){return factorial<T>(n)/(factorial<T>(k)*factorial<T>(n-k));}
template<class T> T dot_product(vector<T>u,vector<T>v){T r=0;for(T i=0;i<u.size();i++)r+=u.at(i)*v.at(i);return r;}
template<class T> T sum(vector<T>v){return reduce(all(v),0LL);}

// Template ends here

void solve(ll A, ll B, ll M, vector<ll> a, vector<ll> b, vector<ll> x, vector<ll> y, vector<ll> c){
    ll answer = LLONG_MAX;
    rep(i, M) {
        chmin(answer, a.at(x.at(i) - 1) + b.at(y.at(i) - 1) - c.at(i));
    }
    sort(all(a)); sort(all(b));
    cout << min(answer, a.at(0) + b.at(0)) << "\n";
}

int main() {
    ll A;
    ignore_ret(scanf("%lld",&A));
    ll B;
    ignore_ret(scanf("%lld",&B));
    ll M;
    ignore_ret(scanf("%lld",&M));
    vector<ll> a(A);
    for(int i = 0 ; i < A ; i++){
        ignore_ret(scanf("%lld",&a[i]));
    }
    vector<ll> b(B);
    for(int i = 0 ; i < B ; i++){
        ignore_ret(scanf("%lld",&b[i]));
    }
    vector<ll> x(M);
    vector<ll> y(M);
    vector<ll> c(M);
    for(int i = 0 ; i < M ; i++){
        ignore_ret(scanf("%lld",&x[i]));
        ignore_ret(scanf("%lld",&y[i]));
        ignore_ret(scanf("%lld",&c[i]));
    }
    solve(A, B, M, move(a), move(b), move(x), move(y), move(c));
    return 0;
}

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

using Int = int;
using namespace std;

#define ARC(i, a, b) for(Int i = (a); i < (b); ++i)
#define RC(i, n) ARC(i, 0, n)
#define ARCH(i, a, b) for(Int i = (a) - 1; i >= (b); --i)
#define RCH(i, n) ARCH(i, n, 0)
template<class T> T ant(const T &a, const T &b){ return a > b ? a : b; };
template<class T> T ont(const T &a, const T &b){ return a < b ? a : b; };
template<class T> void th(T &a, const T &b, T (*f)(const T &, const T &)){ a = f(a, b); }
#define anth(a, b) th(a, b, ant)
#define onth(a, b) th(a, b, ont)

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

	std::map<std::string, int> ans;
	int max = 0;

	RC(i, n){
		std::string s;
		cin >> s;
		auto it = ans.find(s);
		if(it == ans.end()){
			ans.insert(make_pair(s, 1));
			anth(max, 1);
		}else{
			++it->second;
			anth(max, it->second);
		}
	}

	for(auto s : ans){
		if(s.second == max){
			cout << s.first << endl;
		}
	}
}


Measured memory_bytes: 25216
#include <stdio.h>
#include <string.h>

char str[100001];
char mir1[] = "bdpq";
char mir2[] = "dbqp";

int main(void){
	int i, j, len, f = 0;
	
	gets(str);
	
	len = strlen(str);
	
	for (i = 0; i < len; i++){
		for (j = 0; j < 4; j++){
			if (str[i] == mir1[j] && str[len-i-1] != mir2[j]){
				f = 1;
				break;
			}
		}
		if (f == 1) break;
	}
	
	if (f == 0) printf("Yes\n");
	else printf("No\n");
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  int A, B, M;
  cin >> A >> B >> M;
  vector<int> a(A), b(B);
  for (auto& x : a) cin >> x;
  for (auto& x : b) cin >> x;
  int ans = *min_element(a.begin(), a.end()) + *min_element(b.begin(), b.end());
  for (int i = 0; i < M; i++) {
    int x, y, c;
    cin >> x >> y >> c;
    --x, --y;
    ans = min(ans, a[x] + b[y] - c);
  }
  cout << ans << endl;
}

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

int main(void){
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  int ans = 0;
  for(int i = A; i < D; i++){
    if(C <= i && i < B) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<string>
using namespace std;

long gcd(long x, long y) { if (x > y) { return gcd(y, x); } long r; while (y != 0) { r = x % y; x = y; y = r; }return x; }
long lcm(long x, long y) { return(x / gcd(x, y)) * y; }
void indexsort(long* first, long* last, long* func) { sort(first, last, [&](long a, long b) {return func[a] < func[b]; }); }
//--------------------

int main() {

	string res = "No";

	string N; cin >> N;

	if (N[0] == N[2]) res = "Yes";

	cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

signed main() {
	int n, a, b;
	cin >> n >> a >> b;
	cout << min(n * a, b) << endl;
	return 0;
}

Measured memory_bytes: 256
H,W=map(int,input().split())
ans=max(H, W)
S=[input() for i in range(H)]
T = [[0]*(W-1)]
for i in range(H-1):
    t,ts=[],[]
    for j in range(W-1):
      r=S[i][j:j+2]+S[i+1][j:j+2]
      t.append(r.count('.')%2)
      if t[j]==0:
        ts.append(T[-1][j]+1)
      else:
        ts.append(0)
    T.append(ts)
for L in T[1:]:
    stack=[]
    for i,l in enumerate(L+[0]):
      w=-1
      while stack and stack[-1][1]>=l:
        w,h=stack.pop()
        ans = max(ans, (h+1)*(i-w+1))
      if w!=-1:
        stack.append((w,l))
        continue
      stack.append((i,l))
print(ans)


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

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

  int n;
  cin >> n;

  if (n % 10 == 9 || (n / 10) % 10 == 9) cout << "Yes\n";
  else cout << "No\n";

  return (0);
}


Measured memory_bytes: 3612
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

ll gcd(ll a, ll b) {
  ll tmp;
  if ( b > a) {
    tmp = a;
    a = b;
    b = tmp;
  }
  while (a % b !=0) {
    tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}

ll lcm(ll a, ll b) {
  return a * b / gcd(a, b);
}

int main(void) {
  int n, a, b;
  cin>>n>>a>>b;
  std::cout << min(a*n, b) << std::endl;
  return 0;
}



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

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] s = br.readLine().trim().split("\\s+");
        int h = Integer.parseInt(s[0]);
        int w = Integer.parseInt(s[1]);
        int mod = (int) Math.pow(10, 9) + 7;
        char[][] arr = new char[h][w];
        for(int i = 0 ; i<h ; i++) {
            String temp = br.readLine().trim();
            for(int j=0 ; j<w ; j++)
                arr[i][j] = temp.charAt(j);
        }

        int[][] dp = new int[h][w];

        dp[h-1][w-1] = 1;

        for(int i=w-2 ; i>=0 ; i--)
        {
            if(arr[h-1][i] == '#')
                dp[h-1][i] = 0;
            else
                dp[h-1][i] = dp[h-1][i+1];
        }

        for(int i=h-2 ; i>=0 ; i--)
        {
            if(arr[i][w-1] == '#')
                dp[i][w-1] = 0;
            else
                dp[i][w-1] = dp[i+1][w-1];
        }

        for(int i=h-2 ; i>=0 ; i--)
        {
            for(int j=w-2 ; j>=0 ; j--)
            {
                if(arr[i][j] == '#')
                {
                    dp[i][j] = 0;
                    continue;
                }

                long temp = (long) dp[i+1][j] + dp[i][j+1];
                dp[i][j] = (int) (temp % mod);
            }
        }

        System.out.println(dp[0][0]);
    }
}

Measured memory_bytes: 32448
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <ios> 
#include <bits/stdc++.h>
using namespace std;
int a,b;
int main(){
	cin>>a>>b;
	cout<<max(a+b,max(a*2-1,b*2-1));
}

Measured memory_bytes: 256
=begin
N M
L1 R1
L2 R2
...
Lm Rm
=end

n, m = gets.chomp.split(" ").map(&:to_i)
lrs = m.times.map do
  gets.chomp.split(" ").map(&:to_i)
end

l, r = 0, 10 ** 6

lrs.each do |lc, rc|
  l = [l, lc].max
  r = [r, rc].min
end

if r >= l
  puts(r - l + 1)
else
  puts 0
end


Measured memory_bytes: 9468
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.StringTokenizer;
/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputReader in = new InputReader(System.in);
		PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)),true);
		TaskB solver = new TaskB();
		solver.solve(1, in, out);
		out.flush();
		out.close();
	}
}

class TaskB {
    public void solve(int testNumber, InputReader in, PrintWriter pw) {
    	int n=in.nextInt();
    	int arr[]=new int[n];
    	for(int i=0;i<n;i++) {
    		arr[i]=in.nextInt();
    	}
    	boolean flag=true;
    	int temp=arr[0];
    	int max=arr[0];
    	for(int i=1;i<n;i++) {
    		if(arr[i]<temp-1||arr[i]<max) {
    			flag=false;
    			break;
    		}
    		max=temp-1>max?temp-1:max;
    		temp=arr[i];
    	}
    	if(flag) {
    		pw.println("Yes");
    	}else {
    		pw.println("No");
    	}
    	
    		
    	}
}
class Pair<A,B>{
	A first;
	B second;
	Pair(A first,B second){
		this.first=first;
		this.second=second;
	}
}


class InputReader{
    BufferedReader br;
    StringTokenizer st;
    public InputReader(InputStream in){
        br=new BufferedReader(new InputStreamReader(in));
        st=null;
    }
    public String next(){
    while(st==null||!st.hasMoreTokens()){
        try{
            st=new StringTokenizer(br.readLine());
        }catch(IOException e){
            throw new RuntimeException(e);
        }
    }
   return st.nextToken();
    }
    public int nextInt(){
        return Integer.parseInt(next());
    }
    public long nextLong() {
    	return Long.parseLong(next());
    }
}


Measured memory_bytes: 40892
n = int(input())
v = [0] + list(map(int,input().split())) #index調整
odds = [0] * (10**5+1)
evens = [0] * (10**5+1)
oddmax, evenmax = 0, 0
oddindex, evenindex = 0, 0
for i in range(1,n+1):
    if i % 2 == 1:
        odds[v[i]] += 1
    else:
        evens[v[i]] += 1
for i in range(1,10**5+1):
    if oddmax < odds[i]:
        oddmax = odds[i]
        oddindex = i
    if evenmax < evens[i]:
        evenmax = evens[i]
        evenindex = i
if oddindex != evenindex:
    print(n-oddmax-evenmax)
else:
    odds.sort()
    odds.reverse()
    evens.sort()
    evens.reverse()
    ans = min(n-odds[0]-evens[1], n-odds[1]-evens[0])
    print(ans)

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

int n,t,a;
long int h[1000];
double tem_delta[1000];
double tem_delta2[1000];

int main(){

   cin>>n;
   cin>>t>>a;

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

   for(int i=0;i<n;i++){
       tem_delta[i]=abs(t-0.006*h[i]-a);
       tem_delta2[i]=tem_delta[i];
   }

   sort(tem_delta,tem_delta+n);


   for(int i=0;i<n;i++){
       if(tem_delta2[i]==tem_delta[0]){
           cout<<(i+1)<<endl;
           break;
       }
   }

   
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int appear[26] = {0};
int main () {
	string s;
	while (cin >> s) {
		for (int i = 0; i < s.length(); i++)
			if ('a' <= s[i] && s[i] <= 'z')
				appear[(int) s[i] - 97] += 1;
			else if ('A' <= s[i] && s[i] <= 'Z')
				appear[(int) s[i] - 65] += 1;
	}
	for (char j = 'a'; j <= 'z'; j++)
		cout << j << " : " << appear[(int) j - 97] << '\n';
}


Measured memory_bytes: 3172
# -*- coding: utf-8 -*-

import numpy as np

N = int(input())

A = np.array(list(map(int, input().split())))

if 0 in A:
    print(0)
    exit(0)

mul = A[0]

if np.sum(A < 0) % 2 == 1:
    for i in A[1:]:
        mul *= i
else:
    for i in A[1:]:
        if 1000000000000000000 / i < mul:
            print(-1)
            exit(0)
        mul *= i

if mul > 1000000000000000000:
    print(-1)
    exit(0)

print(mul)


Measured memory_bytes: 40096
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  scanf("%d",&n);
  set<int>a;
  int temp;
  int sum=0;
  for(int i=1;i<=n;++i){
    scanf("%d",&temp);
    if(a.find(temp)!=a.end()){
        sum--;
        a.erase(temp);
    }
    else{
        sum++;
        a.insert(temp);
    }
  }
  printf("%d\n",sum);
}


Measured memory_bytes: 4864
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		while(true){
			int n = sc.nextInt();
			int m = sc.nextInt();
			if(n == 0 && m == 0) break;

			ArrayList<ArrayList<Integer>> al = new ArrayList<ArrayList<Integer>>();
			for(int i=0;i<=n;i++){
				al.add(new ArrayList<Integer>());
			}
			for(int i=0;i<m;i++){
				int a = sc.nextInt();
				int b = sc.nextInt();
				al.get(a).add(b);
				al.get(b).add(a);
			}

			HashSet<Integer> ans = new HashSet<Integer>();
			ArrayList<Integer> tmp = new ArrayList<Integer>();
			ans.addAll(al.get(1));
			tmp.addAll(al.get(1));

			for(int x : tmp){
				ans.addAll(al.get(x));
			}

			ans.remove((Integer)1);
			System.out.println(ans.size());
		}
	}
}

Measured memory_bytes: 13000
N = int(input())
V = map(int, input().split())
C= map(int, input().split())

diff_val = []
for v, c in zip(V, C):
    diff_val.append(v - c)
ans = 0
#print(diff_val)
for d in diff_val:
    if d > 0:
        ans += d
print(ans)

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a, b, x;
    cin >> a >> b;
    
    x = (a+b)/2;
    
    if(2*x == a+b)
    {
        cout << x << endl;
    }
    else
    {
        cout << x + 1 << endl;
    }
}


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

typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;
typedef vector< vector< vector<ll> > > vvvint;
typedef vector<string> vstring;
typedef vector< vector<string> > vvstring;
typedef vector<char> vchar;
typedef vector< vector<char> > vvchar;
typedef vector<long double> vdouble;
typedef vector< vector<long double> > vvdouble;
typedef vector< vector< vector<long double> > > vvvdouble;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;
typedef vector<bool> vbool;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define ALL(obj) (obj).begin(), (obj).end()
// #define LLONG_MAX 9223372036854775806
#define vmax(vec) *max_element(vec.begin(), vec.end())
#define vmin(vec) *min_element(vec.begin(), vec.end())
#define vsort(vec) sort(vec.begin(), vec.end())
#define vsortgr(vec) sort(vec.begin(), vec.end(), greater<ll>())
#define MOD 1000000007
// #define MOD 998244353
// #define MOD LLONG_MAX
const double PI=3.14159265358979323846;
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; }

int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0,};

void printv(vint &v){
    for(auto e:v) cout<<e<<" ";
        cout<<endl;
    }

// 繰り返し二乗法
ll power(ll a, ll b){
    if(a==1)return a;
    // if(a==0)re
    ll res=1;
    while(b>0){
        if(b&1) res=res*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return res;
}

const int MAX=2100000;

ll fact[MAX], fact_inv[MAX];

void init_fact(ll n){
    fact[0]=1;
    // 階乗の計算
    for(ll i=0; i<n; i++) fact[i+1]=fact[i]*(i+1)%MOD;
    fact_inv[n]=power(fact[n], MOD-2);
    // 逆元の計算
    for(ll i=n-1;i>=0;i--) fact_inv[i]=fact_inv[i+1]*(i+1)%MOD;
}

ll comb(ll n, ll r){
    return (fact[n]*fact_inv[r])%MOD*fact_inv[n-r]%MOD;
}

ll perm(ll n, ll r){
    return (fact[n]*fact_inv[n-r])%MOD;
}

ll n,a,b;
vint h;

bool isOK(ll x){
    ll cnt = 0;
    for(auto e:h){
        if(e - b*x <= 0) continue;
        ll diff = e - b*x;
        cnt += diff/(a-b) + min(1ll, diff%(a-b));
    }
    return cnt <= x;
}

ll BS(){
    ll left = -1;
    ll right = 1e10;

    while(right - left > 1){
        ll mid = left + (right - left)/2;
        if(isOK(mid)) right = mid;
        else left = mid;
    }
    return right;
}



int main() {
    cout<<fixed<<setprecision(10);

    cin>>n>>a>>b;
    h.resize(n); rep(i,n) cin>>h[i];


    cout<<BS()<<endl;

    return 0;

}

Measured memory_bytes: 1024
N = int(input())
f = [0]*10000001

for i in range(1,101):
	for j in range(i,101):
		for k in range(j,101):
			n = i**2+j**2+k**2+i*j+j*k+k*i
			if i == j == k:
				f[n] += 1
			elif (i == j and j != k) or (i != j and j == k):
				f[n] += 3
			else:
				f[n] += 6

for i in range(1,N+1):
	print(f[i])

Measured memory_bytes: 87120
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
int m,n;
bool t[22][11000];
int dp[2000][11000];
int main(){
while(cin>>m>>n,n||m){
rep(i,2000)rep(j,10000)dp[i][j]=0;
rep(i,22)rep(j,10000)t[i][j]=0;
rep(i,m){
	rep(j,n)cin>>t[i][j];
}

int ans=0,cnt=0;
rep(i,(1<<m)){

	cnt=0;
	rep(j,n){
		rep(k,m){
			if(i&(1<<k)&&t[k][j])dp[i][j]++;
			if((!(i&(1<<k)))&&!t[k][j])dp[i][j]++;
			
		}
	}
	rep(j,n)cnt+=max(dp[i][j],m-dp[i][j]);
	ans=max(cnt,ans);
}

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


Measured memory_bytes: 89256
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=100000000000000000;


int main() {
    int n,m;
    cin >> n >> m;
    vector<int> a(m,0);
    for(int i=0;i<n;i++){
        int k;
        cin >> k;
        for (int j=0;j<k;j++){
            int r;
            cin >> r;
            a[r-1]++;
        }
    }
    int ans=0;
    for (int i=0;i<m;i++){
        if (a[i]==n) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  long long x,ans;
  cin >> x;
  ans = x / 11;
  ans *= 2;
  x = x%11;
  if (x > 6) {
    ans += 2;
  } else if (x > 0) {
    ans += 1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>

using namespace std;

const long long int MAX_N = 100000;

int main(int argc, char const *argv[]) {
  long long int n;
  cin >> n;
  long long int ans = n, a = n/2;

  for (size_t i = 0; i < n/2; i++) {
    long long int sum = 0, b = n-a, asum = 0, bsum = 0;
    long long int tempa = a, tempb = b;

    while (tempa>0) {
      asum += tempa%10;
      tempa /= 10;
    }
    while (tempb > 0) {
      bsum += tempb%10;
      tempb /= 10;
    }
    if (asum+bsum<ans) ans = asum+bsum;
    a--;
  }

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


Measured memory_bytes: 256
from itertools import  product

n=int(input())

f=[list(map(int,input().split())) for _ in range(n)]
#曜日
p=[list(map(int,input().split())) for _ in range(n)]
#利益
ans=-10**50
for z in product((0, 1), repeat=10):#bit全探索のくみあわせを勝手に作ってくれるので使うとよい
    profit_count=0  #利益の合計
    for i in range(n):
        work_count=0  #働く時間帯が同じ回数
        for j in range(10):  #個数を調べる
            if f[i][j]==1 and z[j]==1:  #f[i][j]==z[j]だと両方0の時もcountしちゃう
                work_count+=1
        profit_count+=p[i][work_count]
    if ans<profit_count:  #ans=max(ans,profit_count)だと000000000000の時確認できない
        if 1 in z:   #１日以上働いているかの確認
            ans=profit_count
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <queue>
#include <cstdio>
#include <cstring>

using namespace std;

int cap[500][500];

int maximumFlow(int n, int s, int t, bool first = false){
	int res = 0;
	int prev[500];
	while(true) {
		queue<int> qu; qu.push(s);
		memset(prev, -1, sizeof(prev)); prev[s] = s;
		while(!qu.empty()&&prev[t]<0){
			int u = qu.front(); qu.pop();
			for(int i=0;i<n;i++){
				if(prev[i]<0&&cap[u][i]>0){
					prev[i] = u;
					qu.push(i);
				}
			}
		}
		if(prev[t] < 0) return res;
		for(int j=t;prev[j]!=j;j=prev[j])
			cap[prev[j]][j]--, cap[j][prev[j]]++;
		res++;
		if(!first) return res;
	}
	return 0;
}

int main(){
	int N, E, Q;
	while(cin >> N >> E >> Q){
		memset(cap, 0, sizeof(cap));
		for(int i=0;i<E;i++){
			int F, T; scanf("%d %d", &F, &T);
			cap[F-1][T-1] = 1;
			cap[T-1][F-1] = 1;
		}
		int cur = maximumFlow(N, 0, N-1, true);
		for(int i=0;i<Q;i++){
			int M, A, B; scanf("%d %d %d", &M, &A, &B);
			if(M==1){
				cap[A-1][B-1] = 1;
				cap[B-1][A-1] = 1;
				cur += maximumFlow(N, 0, N-1);
			}
			if(M==2){
				int s = A-1, t = B-1;
				for(int k=0;k<2;k++){
					if(cap[t][s] == 2){
						cap[t][s] = 0;
						int tmp = maximumFlow(N, s, t); 
						if(tmp==0){
							maximumFlow(N, s, 0);
							maximumFlow(N, N-1, t);
							cur--;
						}
					}
					swap(s, t);
				}
				cap[s][t] = cap[t][s] = 0;
			}
			cout << cur << endl;
		}
	}
}

Measured memory_bytes: 1928
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 0xccccccc;
const ll LINF = 0xcccccccccccccccLL;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}



//head

ll n, s;
ll ans = -1;
const int m = 1e6;

ll ff(ll b, ll n) {
  if(n < b) return n;
  return ff(b, n/b) + n%b;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> s;
	if(n == s) {
		cout << n+1 << endl;
		return 0;
	}
	for(int b = 2; b <= m; b++) {
		if(ff(b, n) == s) {
			cout << b << endl;
			return 0;
		}
	}
	int z = n/m;
	for(int _ = z; _ > 0; _--) {
		ll bi = n/_;
		ll sm = n/(_+1)+1;
		ll _bi = ff(bi, n);
		ll _sm = ff(sm, n);
		assert(_bi+bi-sm <= _sm);
		if(_bi <= s and s <= _sm and (s-_bi)%_ == 0) {
			ans = (_sm-s)/_ + sm;
			cout << ans << endl;
			return 0;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3648
H, W, K = map(int, input().split())
grid = []
for _ in range(H):
    w = input()
    grid.append(w)

output = [[0] * W for _ in range(H)]
k = 1
for i in range(H):
    for j in range(W):
        if grid[i][j] == '#':
            output[i][j] = k
            k += 1

def h_paint(i, j):
    dj = j
    k = output[i][j]
    while (dj-1 >= 0):
        if output[i][dj - 1] == 0:
            output[i][dj - 1] = k
            dj -= 1
        else:
            break
    dj = j
    while (dj + 1 < W):
        if output[i][dj + 1] == 0:
            output[i][dj + 1] = k
            dj += 1
        else:
            break
            

for i in range(H):
    for j in range(W):
        if grid[i][j] == '#':
            h_paint(i, j)

for i in range(H-2, -1, -1):
    for j in range(W):
        if output[i][j] == 0:
            output[i][j] = output[i + 1][j]

for i in range(1, H):
    for j in range(W):
        if output[i][j] == 0:
            output[i][j] = output[i-1][j]

for o in output:
    print(*o)

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

using namespace std;
using ll = long long;

const int maxa = 100000;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll N, K;
  cin >> N >> K;
  vector<ll> C(maxa + 5, 0);
  for (int i = 0; i < N; i++) {
    ll a, b;
    cin >> a >> b;
    C[a] += b;
  }
  for (int i = 0; i <= maxa; i++) {
    if (K - C[i] > 0) {
      K -= C[i];
    } else {
      cout << i << '\n';
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 1024
#include<iostream>

int l, m, n, money = 0, month;

int main(){
	while(true){
		std::cin >> l;
		if(!l)
			return 0;
		for(int i=0; i<12; i++){
			std::cin >> m >> n;
			money += m-n;
			if(money >= l && !month)
				month = i+1;
		}
		if(!month)
			std::cout << "NA" << std::endl;
		else
			std::cout << month << std::endl;
		money = 0;
		month = 0;
	}
}

Measured memory_bytes: 0
/*
(1)for binary shift operator always use 'LL' 1LL<<63

*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll M=2e6+1;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll a,b,c,d;cin>>a>>b>>c>>d;
	ll i=0;
	while(a>0 and c>0){
		if(i%2)
			a-=d;
		else c-=b;
		i++;
	}
	if(a>0)
		cout<<"Yes";
	else cout<<"No";
	return 0;
} 

Measured memory_bytes: 3612
<?php

fscanf(STDIN, '%d', $T);
$result = [];
while ($T-- > 0) {
	fscanf(STDIN, '%d %d', $N, $D);
	if ($N%2 === 0) $D = $D ^ 127;
	$result[] = ($D + ($N - 1) * 127);
}
foreach ($result as $r) {
	echo $r . PHP_EOL;
}


Measured memory_bytes: 3704
import bisect

N=int(input())
L=list(map(int, input().split()))
L.sort()

ans=0
for i in range(N-2):
  for j in range(i+1,N-1):
    #small = bisect.bisect_left(L, L[j]-L[i])
    large = bisect.bisect_left(L, L[j]+L[i])    
    #print(i,j,L[i],L[j],"  ",L[j]-L[i],L[j]+L[i],small,large)
    ans += max(large-j-1,0)    

print(ans)

Measured memory_bytes: 3188