akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

ll N,K;
ll A[1001];
ll C[64];
bool ng[1000000];

int main(){
    cin >> N >> K;
    for(int i=1;i<=N;i++) cin >> A[i];
    for(int i=0;i<N;i++) A[i+1] += A[i];
    vector<ll> v;
    for(int i=0;i<N;i++){
        for(int j=i+1;j<=N;j++){
            v.push_back(A[j]-A[i]);
        }
    }
    for(int i=0;i<v.size();i++) ng[i] = true;
    ll ans = 0;
    for(int i=63;i>=0;i--){
        vector<ll> idx;
        ll c = 0;
        for(int j=0;j<v.size();j++){
            if(!ng[j]) continue;
            bitset<64> bt(v[j]);
            if(!bt[i]) idx.push_back(j);
            else c++;
        }
        if(c < K) continue;
        ans += (ll)1 << (ll)i;
        for(auto &e : idx) ng[e] = false;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 15520
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A;
  cin >> A;
  vector<int>N(A);
  for(int i=0;i<A;i++)cin >> N[i];
  sort(N.begin(),N.end());
  cout << N[A-1]-N[0] << endl;
}

Measured memory_bytes: 256
import collections
import math

def nC2(n):
    return n * (n - 1) / 2

N = int(input())
A = list(map(int, input().split()))

c = collections.Counter(A)
sum_values = sum(map(nC2, c.values()))

for n in range(N):
    if c[A[n]] == 1:
        print(int(sum_values))
    else:
        print(int(sum_values - (c[A[n]] - 1)))

Measured memory_bytes: 26780
/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
        Comilla  University

*/
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define ll long long
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node
#define spc " "
#define  E  2.71828182845904523536
#define pb push_back
#define pp pop_back
#define valid(nx,ny) nx>=0 && nx<n && ny>=0 && ny<m
#define ee endl
#define pii pair<int,int>
#define infinity 10000000000000000
#define mod 1000000007
int fx[]={0,0,+1,-1};
int fy[]={+1,-1,0,0};

using namespace std;
///check n=1;
///check corner case;
const int maX=1e5+1;
vector<ll>Graph[maX],cost[maX];
ll visit[maX];
ll x[10];
ll y[10];

int main()
{
    ll n,m,i,j,cc=0;
    cin>>n>>m;
    vector<ll>ara(m+1);
    for(i=0;i<n;i++){
        ll x;cin>>x;
        while(x--){
            ll y;cin>>y;
            ara[y]++;
        }
    }
    for(i=1;i<=m;i++){
        if(ara[i]==n)cc++;
    }
    cout<<cc<<endl;
return 0;
}


Measured memory_bytes: 4992
#encoding=utf-8
def solve(n):
    ans_a = calc_digit_sum(n)
    ans_b = calc_digit_sum(n - n % 10 - 1)
    ans_c = calc_digit_sum(10 ** (len(str(n)) - 1) - 1 + 10 ** (len(str(n)) - 1) * (int(str(n)[0]) - 1) )
    return max(ans_a, ans_b, ans_c)

def calc_digit_sum(n):
    if n <= 0:
        return 0
    str_n = str(n)
    ans = 0
    for x in range(len(str_n)):
        ans = ans + int(str_n[x])
    return ans

if __name__ == "__main__":
    n = int(input())
    print(solve(n))


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
#include <ctime>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    rep(i,a.size()) cout << a[i] << " ";
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
ll pcount(ll x) {return __builtin_popcountll(x);}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
	ll n; cin >> n;
	vl a(n); rep(i,n) cin >> a[i];
	ll ans = 1;
	rep(i,n) ans *= 3;
	ll minus = 1;
	rep(i,n){
		if(a[i] & 1 ^ 1) minus *= 2;
	}
	cout << ans - minus << endl;
}

Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
typedef long long ll;
using namespace std;
//#define int long long

//素数判定
inline bool IsPrime(int p) {
	if (p == 1) return false;
	for (int i = 2; i <= sqrt(p); i++) {
		if (p%i == 0) return false;
	}
	return true;
}

//10進数の自然数の桁数を返す
inline int GetDigit(int num) {
	return (int)log10(num) + 1;
}

//各位の和を返す
int GetDigitsSum(int num) {
	int N = 0;
	while (num > 0) {
		N += num % 10;
		num /= 10;
	}
	return N;
}

//互除法
ll gcd(ll a, ll b) {
	if (a < b) {
		return gcd(b, a);
	}
	else if (a%b) {
		return gcd(b, a%b);
	}
	else {
		return b;
	}
}

//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b; // Be careful not to overflow

}

//異なるn個からr個の整数を取り出す組合せの数を求める
int combination(int n, int r) {
	if (r == 0 || n == r) {
		return 1;
	}
	else if (r == 1) {
		return n;
	}
	else {
		return combination(n - 1, r - 1) + combination(n - 1, r);
	}

}

//Ｏ(√n)
//素因数分解
map<int, int> prime_factor(int n) {
	map<int, int> res; // map[i]:=ｎを素因数分解したときiは何乗か。
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0) {
			while (n % i == 0) {
				res[i]++;
				n /= i;
			}
		}
	}
	if (n != 1)
		res[n] = 1;
	return res;
}

//Ｏ(√n)
//素因数分解
map<int, int> prime_factor_ver2(int n, map<int, int> res) {
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0) {
			while (n % i == 0) {
				res[i]++;
				n /= i;
			}
		}
	}
	if (n != 1)
		res[n]++;
	return res;
}


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

	int a[26] = { 0 };
	int b[26] = { 0 };

	string s1, s2;
	cin >> s1 >> s2;

	for (int i = 0; i < (int)s1.size(); i++)
	{
		a[s1[i] - 'a']++;
	}
	
	for (int i = 0; i < (int)s2.size(); i++)
	{
		b[s2[i] - 'a']++;
	}

	sort(a, a + 26);
	sort(b, b + 26);

	bool flg = true;
	
	for (int i = 0; i < 26; i++)
	{
		if (a[i] != b[i]) {
			flg = false;
		}
	}

	if (flg) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 916
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define int ll
using namespace std;
using ll=long long;
using pii=pair<int,int>;

int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n,k; cin>>n>>k;
	vector<int> v;
	string s; cin>>s;
	if(s[0]=='0') v.emplace_back(0);
	int now=1;
	for(int i=1;i<sz(s);i++)
	{
		if(s[i]==s[i-1]) now++;
		else
		{
			v.emplace_back(now);
			now=1;
		}
	}
	v.emplace_back(now);
	if(s.back()=='0') v.emplace_back(0);
	int sum=0,mx;
	for(int i=0;i<sz(v) && i<k*2+1;i++) sum+=v[i];
	mx=sum;
	for(int i=k*2+2;i<sz(v);i+=2)
	{
		sum=sum+v[i]+v[i-1]-v[i-k*2-1]-v[i-k*2-2];
		mx=max(mx,sum);
	}
	cout<<mx<<"\n";
	//for(auto i:v) cout<<i<<" "; cout<<"\n";
	return 0;
}

















Measured memory_bytes: 1528
#include <stdio.h>
using namespace std;
int main()
{
    int a;
    int c,d;
    while(~scanf("%d",&a))
    {
        c=a%10;
        d=a/10;
        if(c==9||d==9)
        {
            printf("Yes\n");
        }
        else
        {
            printf("No\n");
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mem(s,t) memset(s,t,sizeof(s))
#define pb(s) push_back(s)
#define inf 0x3f3f3f3f
#define mn 100010
typedef long long ll;
using namespace std;
bool nusd[mn],musd[mn];
queue<int> q;
vector<int> K[mn],L[mn];
int main()
{
	int n,m;scanf("%d%d",&n,&m);
	for(int i=0;i<n;++i){
		int k,l;scanf("%d",&k);
		while(k--){
			scanf("%d",&l);
			L[i].pb(l);
			K[l].pb(i);
		}
	}
	int e=0;
	nusd[0]=1;
	q.push(e);
	while(!q.empty()){
		e=q.front();q.pop();
		for(int i=0;i<L[e].size();++i){
			int t=L[e][i];
			if(musd[t])continue;
			musd[t]=1;
			for(int j=0;j<K[t].size();++j){
				int p=K[t][j];
				if(nusd[p])continue;
				nusd[p]=1;
				q.push(p);
			}
		}
	}
	bool ok=1;
	for(int i=0;i<n&&ok;++i){
		if(!nusd[i])ok=0;
	}
	if(ok)printf("YES");else printf("NO");

    return 0;
}


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


int main() {
    int N;
    std::cin >> N;

    std::vector<std::vector<int>> jobs(N, std::vector<int>(2));
    for (int i = 0; i < N; i++) {
        std::cin >> jobs[i][0] >> jobs[i][1];
    }
    std::sort(jobs.begin(), jobs.end(), [](auto &lhs, auto &rhs) { return lhs[1] < rhs[1]; });

    int cost_time = 0;
    for (auto&& job : jobs) {
        cost_time += job[0];
        if (cost_time > job[1]) {
            std::cout << "No" << std::endl;
            return 0;
        }
    }
    std::cout << "Yes" << std::endl;
}


Measured memory_bytes: 14044
mod = 10 ** 9 + 7
x, y = map(int, input().split())
a = (2 * y - x) // 3
b = (2 * x - y) // 3
if (x + y) % 3 != 0 or a < 0 or b < 0:
    print(0)
    exit()
n = a + b
r = min(a, b)
ans = 1
for i in range(r):
    ans = ans * (n - i) * pow(i + 1, mod - 2, mod) % mod
print(ans)



Measured memory_bytes: 3064
import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(500000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

x=int(input())
if 30<=x:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 68180
#include <iostream>
#include <cstdio>
#include <map>
#include <algorithm>
using namespace std;

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

    

    map<string, long long> T;

    
    for(long long i = 0; i < n; i++){
        string s;
        cin >> s;
        sort(s.begin(), s.end());

        

        if(T.find(s) == T.end()){
            T[s] = 1;
        }
        else{
            T[s]++; 
        }
    }

    long long count = 0;

    map<string, long long >::iterator it;

    for(it = T.begin(); it != T.end(); it++){
        if(it->second >= 2){
            count += it->second*(it->second-1)/2;
        }
    }

    cout << count << endl;

    return 0;
}

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

int main(){
    int64_t a,b,x,n,m; cin >> a >> b >> x;

    if(a%x == 0){
        n = a;
    }else{
        n = a - a%x + x ;
    }
    
    if(b%x == 0){
        m = b;
    }else{
        m = b - b%x;
    }

    cout << (m-n)/x + 1 << endl;
}


Measured memory_bytes: 256
//#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 = 100010001;
const ll LINF = (ll)INF*INF*10;
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;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];

    if(accumulate(all(a), 0LL)%(ll(n+1)*n/2) != 0) {
        cout << "NO" << endl;
        return 0;
    }
    ll num = accumulate(all(a), 0LL)/(ll(n+1)*n/2);

    rep(i, n) {
        if((a[i]+num-a[(i+1)%n])%n != 0 or a[i]+num-a[(i+1)%n] < 0) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;

#define INF (i64)1e18
#define MOD (i64)(1e9+7)
#define REP(i, n) for(i64 i = 0; i < n; i++)
#define RANGE(i, a, b) for(i64 i = a; i < b; i++)

int main() {
  int n;
  cin >> n;
  vector<i64> a(n);
  for(auto& e : a) cin >> e;
  sort(a.begin(), a.end(), greater<i64>());

  i64 ans = 0;
  RANGE(k, 1, n) {
    ans += a[k/2];
  }
  cout << ans << endl;

  return 0;
}


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

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  bool Win1 = true;
  
  while(true)
  {
    C -= B;
    if( C <= 0 )
    {
      Win1 = true;
      break;
    }
    
    A -= D;
    if( A <= 0 )
    {
      Win1 = false;
      break;
    }
  }
  
  if( Win1 )
    cout << "Yes";
  else
    cout << "No";
  
  cout << flush;
}

Measured memory_bytes: 3140
#include<iostream>
#include<string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <math.h>
#include<iomanip>
using namespace std;

int main()
{
    string S;
    cin >> S;
    if (S[0]==S[1]&&S[1]==S[2]&&S[2]==S[3])
    {
        cout << "No" <<endl;
    }else{
        if(S[0]==S[1]&&S[2]==S[3])cout << "Yes" << endl;
        else if(S[0]==S[2]&&S[1]==S[3])cout << "Yes"<< endl;
        else if(S[0]==S[3]&&S[1]==S[2]) cout << "Yes"<< endl;
        else cout << "No" << endl;

    }
    
}

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

using namespace std;

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

    vector<vector<int>> x(n,vector<int>(d));

    for (int i = 0; i < n; i++){
        for(int j = 0; j < d; j++){
            cin >> x[i][j];
        }
    }
    int ans = 0;
    for (int i = 0; i < n; i++){
        for (int j = i + 1; j < n; j++){
            int norm = 0;
            for (int k = 0; k < d; k++){
                int diff = abs(x[i][k] - x[j][k]);
                norm += diff * diff;
            }

            bool flag = false;
            for (int k = 0; k <= norm; k++){
                if (k * k == norm ){
                    flag = true;
                }
            }
            if (flag) 
            ans++;
        }
    }
    cout << ans << endl;
    
}

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

int main(){
int N,a;
  int min,count;
  min=2*2*2*2*2*2*2*2*2;
  cin>>N;
  for(int i=0;i<N;i++){
    cin>>a;
    count=0;
    while(a%2==0){
      a=a/2;
      count+=1;
    }
    
    if(min>count){
      min=count;
    }
  }
  cout<<min<<endl;
}
  


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  double N, M, D;
  cin>>N>>M>>D;
  if(D==0) cout<<setprecision(20)<<1/N*(M-1)<<endl;
  else cout<<setprecision(20)<<2*(N-D)/(N*N)*(M-1)<<endl;
}



Measured memory_bytes: 3756
//templates
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <unordered_map>
#include <map>
#include <cmath>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define SZ(x) ((int)(x).size())
typedef long long ll;

using namespace std;

int main(){
  int A,B;
  cin >> A >> B;
  if(A>=13) cout << B << endl;
  else if(A>=6) cout << B/2 << endl;
  else cout << 0 << endl;
}


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

int main(){
	ll N,M,a,b;
	cin >> N >> M;
	vector<P> v;
	for (ll i= 0;i < M;i++){
		cin >> a >> b;
		v.pb(mp(a,b));
	}
	ll ans = 1;
	sort(ALL(v));
	a = v[0].fs;
	b = v[0].sc;
	for (ll i= 1;i < M;i++){
		if (v[i].fs < b){
			a = max(a,v[i].fs);
			b = min(b,v[i].sc);
		}
		else{
			a = v[i].fs;
			b = v[i].sc;
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2420
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=1e5+10;
int n;
map<ll,int> m;
ll a[N],ans=1,tot;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
	sort(a+1,a+n+1);
	for(int i=n;i>=1;i--){
		m[a[i]]++;
		if(m[a[i]]==2) m[a[i]]=0,tot++,ans*=a[i];
		if(tot==2){
			printf("%lld",ans);
			return 0;
		}
	}
	printf("0");
	return 0;
}

Measured memory_bytes: 6272
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#define pb push_back
#define ff first
#define ss second
#define sz size()
#define mp make_pair
#define p(x) cout<< x << " ";
#define pe(x) cout<< x << endl ;
#define deb(x) cout<<#x<<" : "<<x<<endl;
#define debug(x,y) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<endl;
#define el endl
#define M 998244353 
#define int long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROR(i,a,b) for(int i=a;i>=b;i--)
const int N = 1e5 + 5;
void solve()
{
    string s,t;
    cin>>s>>t;
    int n=s.size(),m=t.size();
    int dp[n+1][m+1];
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=m;j++)
        {
            if(i==0 || j==0)
            dp[i][j]=0;
            else if(s[i-1]==t[j-1])
            dp[i][j]=1+dp[i-1][j-1];
            else
            dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
    string ans;
    while(n && m)
    {
        if(s[n-1]==t[m-1]) ans+=s[n-1],n--,m--;
        else if(dp[n-1][m]>dp[n][m-1]) n--;
        else m--;
    }
    reverse(ans.begin(),ans.end());
    cout<<ans;
}
int32_t main() 
{ 
  solve();
} 

Measured memory_bytes: 70656
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define until(x) while(!(x))
#define unless(x) if(!(x))
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define pc __builtin_popcount

string haystack[55];
string needle[55];
int n,m;

bool ok(int i, int j){
	for(int k=0;k<m;k++){
		for(int l=0;l<m;l++){
			if(haystack[i+k][j+l]!=needle[k][l]){
				return 0;
			}
		}
	}
	return 1;
}

int32_t main(){
	cin>>n>>m;
	for(int i=0;i<n;i++){
		cin>>haystack[i];
	}
	for(int i=0;i<m;i++){
		cin>>needle[i];
	}
	for(int i=0;i<n-m+1;i++){
		for(int j=0;j<n-m+1;j++){
			if(ok(i,j)){
				cout<<"Yes";
				return 0;
			}
		}
	}
	cout<<"No";
}


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

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


Measured memory_bytes: 3084
object Main extends App {
	val pw = new java.io.PrintWriter(System.out)

	@scala.annotation.tailrec
	def loop(start: Int, end: Int)(f: Int => Unit): Unit =
		if (start < end) {
			f(start)
			loop(start + 1, end)(f)
		}

	pw.println( if (Scanner.next == "ABC") "ARC" else "ABC")
	pw.flush()
}

object Scanner {
	private val buf = new Array[Byte](1024); private var ptr = 0; private var len = 0

	@inline private def isPrintableChar(c: Int): Boolean = 33 <= c && c <= 126
	@inline private def hasNextByte(): Boolean = if (ptr >= len) { ptr = 0; len = System.in.read(buf); len > 0 } else true
	@inline private def hasNext(): Boolean = {
		while (hasNextByte() && !isPrintableChar(buf(ptr))) ptr += 1
		hasNextByte()
	}
	@inline private def readByte(): Byte = if (hasNextByte()) { val res = buf(ptr); ptr += 1; res } else -1

	def next(): String = {
		if(!hasNext()) ???
		val sb = new StringBuilder; var b = readByte()
		while (isPrintableChar(b)) { sb.append(b.toChar); b = readByte() }
		sb.toString
	}

	def nextInt(): Int = {
		val n = nextLong()
		if (n < Int.MinValue || Int.MaxValue < n) ???
		n.toInt
	}

	def nextLong(): Long = {
		if(!hasNext()) ???
		var minus = false; var b = readByte()
		if (b == '-') { minus = true; b = readByte() }

		@scala.annotation.tailrec
		def go (b: Byte, n: Long = 0): Long = if ('0' <= b && b <= '9') go(readByte(), n * 10 + b - '0') else if (minus) -n else n

		go(b)
	}

	def nextDouble(): Double = next().toDouble
}


Measured memory_bytes: 54664
import Data.List
import Data.Char
import Data.Maybe
import Control.Monad
import qualified Data.ByteString.Char8 as BS8

main :: IO ()
main = do
    n <- fst . fromJust . BS8.readInt <$> BS8.getLine
    s <- getLine

    putStrLn $ ((map chr $ map (\x -> ((x - 0x41 + n) `mod` 26) + 0x41) $ map ord s) :: String)


Measured memory_bytes: 1404
#!/usr/bin/env python3
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float("inf")


def main():
    H1, M1, H2, M2, K = map(int, readline().split())
    MM1 = H1*60+M1
    MM2 = H2*60+M2
    print(max(MM2-MM1-K, 0))
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9236
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int len = Integer.parseInt(sc.nextLine());
		String line = sc.nextLine();
		sc.close();
		int con = 0;
		for (int i = 0; i < len - 2; i++) {
			String cut = line.substring(i, i + 3);
			if (cut.equals("ABC")) {
				con++;
			}
		}

		System.out.println(con);

	}
}


Measured memory_bytes: 22228
def main():
    S = input()
    X, Y = map(int, input().split())
    d = 0
    L = [[0], [0]]
    for s in S:
        if s == 'T':
            d = 1 - d
            if L[d][-1] != 0:
                L[d].append(0)
        else:
            L[d][-1] += 1
    xs, ys = set([L[0][0] if S[0] == 'F' else 0]), set([0])
    for i in L[0][1 if S[0] == 'F' else 0:]:
        xs = set(x + i for x in xs) | set(x - i for x in xs)
    for i in L[1]:
        ys = set(y + i for y in ys) | set(y - i for y in ys)
    return X in xs and Y in ys

print('Yes' if main() else 'No')


Measured memory_bytes: 4940
# 後ろからみていって最小値or0で更新
n = int(input())
b = list(map(int, input().split()))
a = [10 ** 5 for _ in range(n)]  # どうせ後で更新されるので
a[-1] = b[-1]

for i in range(n - 2, -1, -1):
    a[i] = min(a[i], b[i])
    a[i + 1] = min(a[i + 1], a[i])
print(sum(a))


Measured memory_bytes: 3060
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(s: str):
    print(s[:4]+' '+s[4:])
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    s = next(tokens)  # type: str
    solve(s)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<iostream>  
#include<algorithm>  
#include<string>  
#include<sstream>  
#include<set>  
#include<vector>  
#include<stack>  
#include<map>  
#include<queue>  
#include<deque>  
#include<cstdlib>  
#include<cstdio>  
#include<cstring>  
#include<cmath>  
#include<ctime>  
#include<functional> 
#define INT_MAX 2147483647
#define INT_MIN -2147483648
typedef long long LL;
using namespace std;
const int maxn = 1024 + 10;
int main()
{
	//freopen("data_in.txt", "r", stdin);
	//freopen("data_out.txt", "w", stdout);
	vector<int> rs{ 1,100,10000 };
	int d = 0, n = 0;
	cin >> d >> n;
	if(n < 100) cout << rs[d] * n;
	else cout << rs[d] * (n + 1);
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getlist():
    return list(map(int, input().split()))
import math
import heapq
from collections import defaultdict, Counter, deque
MOD = 10**9 + 7
INF = 10**15


def main():
    n, k = getlist()
    nums = getlist()
    if sum(nums) >= n:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()

"""
9999
3

2916
"""

Measured memory_bytes: 52464
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<math.h>

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62);

typedef long long i64;
typedef pair<i64,i64> P;


string s;

int main(){
	cin >> s;
	
	if(s.size() % 2 ^ s[0] == s[s.size()-1]) cout << "First" << endl;
	else cout << "Second" << endl;
	
	return 0;
}

Measured memory_bytes: 512
def reverse(l):
    """
    l: a list
    returns a reversed list

    >>> reverse([1,2,3,4,5])
    [5, 4, 3, 2, 1]
    >>> reverse([3,3,4,4,5,8,7,9])
    [9, 7, 8, 5, 4, 4, 3, 3]
    >>> reverse([])
    []
    """
    length = len(l)
    result = []
    for i in range(length):
        result.append(l[length-i-1])

    return result

if __name__ == '__main__':
    #import doctest
    #doctest.testmod()

    num = int(input())
    ilist = [int(i) for i in input().split(' ')]

    print(' '.join([str(i) for i in reverse(ilist)]))

Measured memory_bytes: 7724
#include <bits/stdc++.h>
using namespace std;
int n;
const int N = 1e5+10;
int a[N];
typedef long long ll;
void Maxi(ll &a, ll b) {
    if (b > a) a = b;
}
ll b[N];

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d", a + i);
    sort(a + 1, a + n + 1);
    for (int i = 1; i <= n; i++) b[i] = b[i - 1] + a[i];
    ll ans = 0;
    if (n % 2 == 0) {
        Maxi(ans, (b[n]-b[n/2])*2 - a[n/2+1] - b[n/2]*2 + a[n/2]);
    }
    else {
        int h = n/2;
        Maxi(ans, (b[n]-b[h])*2 - a[h+1] - a[h+2] - b[h]*2);
        Maxi(ans, (b[n]-b[h+1])*2 - b[h+1] * 2 + a[h] + a[h+1]);
    }
    printf("%lld\n", ans);
}

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

int linearSearch(std::vector<int>::iterator begin, std::vector<int>::iterator end, int key)
{
  auto itr = begin;
  for (; itr < end; itr++)
    {
      if ((*itr) == key) break;
    }
  return itr != end;
}
int main ()
{
  int n, q;
  std::vector<int> S, T;

  std::cin >> n;
  for (int i=0; i<n; i++)
    {
      int s;
      std::cin >> s;
      S.push_back(s);
    }

  std::cin >> q;
  int ans = 0;
  for (int i=0; i<q; i++)
    {
      int t;
      std::cin >> t;
      ans += linearSearch(S.begin(), S.end(), t);
    }
  std::cout << ans << std::endl;
}



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


public class Main
{
	public static void main(String[] args)
	{
		
		try{
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			String str;
			while(!((str =  br.readLine()).equals("-"))){
				int M = Integer.parseInt(br.readLine());
				int[] arrH = new int[M];
				for(int i = 0; i< M ; i++)
				{
					arrH[i] = Integer.parseInt(br.readLine());
				}
				shuff(str,arrH,M);
			}
		}catch(IOException e){
			e.printStackTrace();
		}
	}
	public static void shuff(String s , int[] h , int l)
	{
		StringBuilder sb = new StringBuilder();
		sb.append(s);
		for(int i = 0 ; i < l ; i++)
		{
			sb.append(sb.substring(0,h[i]));
			sb.delete(0,h[i]);
		}
		System.out.println(sb.toString());
	}
}

Measured memory_bytes: 24452
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define FOR(i, m, n) for(ll i = m; i < (n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vii = vector<vi>;
using pii = pair<int, int>; 
using vl = vector<ll>;
using vll = vector<vl>;
using pll = pair<ll, ll>;

int main() {
    string s;
    cin >> s;
    if(s[s.size()-1] != 's'){
        s += 's';
    }else{
        s += "es";
    }
    cout << s;
}

Measured memory_bytes: 3624
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

#define pv(val) cerr << #val << '=' << (val) << endl
#define pvn(name, val) cerr << name << '=' << (val) << endl
#define pl cerr << '@' << __LINE__ << endl

using namespace std;

using ll = int64_t;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

template <class T>
ostream &operator<<(ostream &os, vector<T> const &vec) {
    if (vec.empty()) {
        os << "{}";
    } else {
        os << '{';
        for (size_t i = 0; i < vec.size() - 1; i++) os << vec[i] << ", ";
        os << vec.back() << '}';
    }
    return os;
}

template <class T, size_t S>
ostream &operator<<(ostream &os, array<T, S> const &arr) {
    if (arr.empty()) {
        os << "{}";
    } else {
        os << '{';
        for (size_t i = 0; i < arr.size() - 1; i++) os << arr[i] << ", ";
        os << arr.back() << '}';
    }
    return os;
}

template <class T, class U>
ostream &operator<<(ostream &os, pair<T, U> const &p) {
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

namespace math {
ll gcd(ll u, ll v) {
    while (v != 0) {
        ll r = u % v;
        u = v;
        v = r;
    }
    return u;
}
ll lcm(ll m, ll n) {
    if ((0 == m) || (0 == n)) return 0;

    return ((m / math::gcd(m, n)) * n);
}
}  // namespace math

struct UnionFind {
    vector<ll> data;
    UnionFind(ll size) : data(size, -1) {}
    bool unionSet(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x != y) {
            if (data[y] < data[x]) swap(x, y);
            data[x] += data[y];
            data[y] = x;
        }
        return x != y;
    }
    bool findSet(ll x, ll y) { return root(x) == root(y); }
    ll root(ll x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
    ll size(ll x) { return -data[root(x)]; }
};

template <class T, class U>
pair<T, U> operator+(pair<T, U> const &a, pair<T, U> const &b) {
    return pair<T, U>(a.first + b.first, a.second + b.second);
}

template <class T, class U>
pair<T, U> operator-(pair<T, U> const &a, pair<T, U> const &b) {
    return pair<T, U>(a.first - b.first, a.second - b.second);
}

ll bound(function<bool(ll)> f, ll ng, ll ok) {
    while (abs(ng - ok) > 1) {
        ll mid = (ng + ok) / 2;
        if (f(mid))
            ok = mid;
        else
            ng = mid;
    }

    return ok;
}


int main(void) {
    ll N;
    cin >> N;

    ll ans = 0;
    vector<ll> yakusuu;
    for(ll i = 1; i * i <= N; i++){
        if(N % i == 0){
            yakusuu.push_back(i);
            if(i * i != N) yakusuu.push_back(N / i);
        }
    }
    for(ll const y : yakusuu){
        ll const x = N / y;
        ll const m = y - 1;
        if(x >= m)
            continue;
        ans += m;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 888
#include <iostream>
using namespace std;
int main(void){
    int H,W,i,j,k;
    while(1){
        cin >> H >> W;
        if(H==0&&W==0) break;{
            for(i=0;i<W;i++){
                cout << "#";
            }
            cout << endl;
            for(j=0;j<H-2;j++){
                cout << "#";
                for(k=0;k<W-2;k++){
                    cout << ".";
                }
                cout << "#";
                cout << endl;
            }
            for(k=0;k<W;k++){
                cout << "#";
            }cout << endl;}
    cout << endl;}
}



Measured memory_bytes: 3004
import java.util.*;
import java.io.*;
class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int min = Math.min(a,b);
        int max = Math.max(a,b);
        for(int i = 0; i<max; i++) {
            pp(min);
        }
        p("");
    }
    public static <T> void p(T element) {
	System.out.println(element);
    }
    public static <T> void pp(T element) {
        System.out.print(element);
        }
    public static int min(int a, int b, int c) {
	int min = Math.min(a,b);
	min = Math.min(min,c);
	return min;
    }
    public static int max(int a, int b,int c) {
	int max= Math.max(a,b);
	max = Math.max(max,c);
        return max;
    }
}
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
 
    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }
 
    private boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }
 
    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }
 
    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
 
    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
 
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }
 
    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

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

int main(void){
    long long n, p_min = 1000000, result = 0;
    
    cin >> n;
    
    vector<long long> p(n);
    
    rep(i, n){
        cin >> p.at(i);
    }
    
    rep(i, n){
        if(p_min > p.at(i)){
            p_min= p.at(i);
            result++;
        }
    }
    
    cout << result << endl;
    
    return 0;
}

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

int main () {
  vector<int> a(3);
  rep(i, 3) cin >> a[i];
  sort(a.begin(), a.end());
  string ans = "No";
  if(a[0] == a[1] && a[0] != a[2]) ans = "Yes";
  else if (a[0] != a[1] && a[1] == a[2]) ans = "Yes";
  cout << ans << endl;
}

Measured memory_bytes: 256
// AtCoder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

// AtCoder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//


#define _USE_MATH_DEFINES
#include<math.h>

//#include<cmath>

#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>



//#include "Ants.h"
using namespace std;
typedef long long ll;
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,n) for(int i=0;i<n;i++)
#define show(s) cout<<s<<endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define LINF (1000000000000000000ll)

//typedef pair < int, int> P;
ll gcd(ll a, ll b) {//最大公約数を求める///最大公倍数a*b/gcd(a,b)
	if (b == 0) return a;
	return gcd(b, a % b);
}

ll lcd(ll a, ll b) {//最小公倍数を求める　b=0のときaを返す
	if (b == 0) return a;
	return (a / gcd(a, b)) * b;
}
vector<int> calc(ll num) {
	int dig;
	vector<int>p;
	while (num) {
		dig = num % 10;
		p.push_back(dig);
		num /= 10;
	}
	return p;
}
ll N;
ll A, B;

int main()
{
	cin >> N >> A >> B;
	ll res = N % (A + B);
	ll ans = N / (A + B);
	cout << ans*A + min(res, A)<< endl;
	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ff(i,n) for(i=0;i<n;i++)
#define pb push_back
ll bg =  998244353;
ll fac[300000];
ll power(ll x,ll y)
{
    if(y==0)
	    return 1;
	ll d = power(x,y/2)%bg;
	ll f = (d*d)%bg;
	if(y%2==0)
	  return f;
	else
	  return (f*x)%bg;	 	
}
ll modinv(ll m)
{
	return power(m,bg-2);	
}
ll ncr(ll n,ll r)
{
	ll s1 = fac[n],s2 = fac[r],s3 = fac[n-r];
	ll d1 = (s1*modinv(((s2*s3)%bg)))%bg;
	return d1;
}
int main()
{
	fac[0]=1;
	for(ll j=1;j<300000;j++)
	  fac[j] = (j*fac[j-1])%bg;
	ll t;
	t=1;
	while(t--)
	{
		set<ll>set1;
		ll i,j,n,m;
		cin>>n>>m;
		vector<vector<ll> >vec(n);
		ll h[n];
		ff(i,n)
		 cin>>h[i];
		ff(i,m)
		{
			ll a,b;
			cin>>a>>b;
			a--; b--;
			vec[a].pb(b);
			vec[b].pb(a);
		}
		ll ans=0;
		ff(i,n)
		{
			ll flag=1;
			ff(j,vec[i].size())
			   if(h[i]<=h[vec[i][j]])
			     flag=0;
			ans+=flag;     
		}
		cout<<ans;
	}
	 return 0;
}

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

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    double xa, ya, ra, xb, yb, rb, d;
    cin >> xa >> ya >> ra >> xb >> yb >> rb;
    d = hypot(xa - xb, ya - yb);
    if (d > ra + rb)
      cout << 0;
    else if (d + rb < ra)
      cout << 2;
    else if (d + ra < rb)
      cout << -2;
    else
      cout << 1;
    cout << "\n";
  }
}



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

int n, m, k;
int card[200];
int card_buf[200];

void riffle_shuffle(){
	for(int i = 0; i < n; i++) card_buf[i * 2] = card[i];
	for(int i = 0; i < n; i++) card_buf[i * 2 + 1] = card[i + n];
	for(int i = 0; i < 2 * n; i++) card[i] = card_buf[i];
}

void cut_shuffle(int num){
	for(int i = 0; i < num; i++) card_buf[2 * n - num + i] = card[i];
	for(int i = num; i < 2 * n; i++) card_buf[i - num] = card[i];
	for(int i = 0; i < 2 * n; i++) card[i] = card_buf[i];
}

int main(){
	cin >> n >> m;
	for(int i = 0; i < 2 * n; i++) card[i] = i + 1;
	for(int i = 0; i < m; i++){
		cin >> k;
		if(k == 0) riffle_shuffle();
		else cut_shuffle(k);
	}
	for(int i = 0; i < 2 * n; i++) cout << card[i] << endl;
	return 0;
}

Measured memory_bytes: 3092
import math
n,k = map(int,input().split())
lis = list(map(int,input().split()))
li = []
num = sum(lis)
for i in range(1,math.ceil(math.sqrt(num))+1):
    if num % i == 0:
        li.append(i)
        li.append(num // i)
li.sort(reverse = True)


for numb in li:
    liss = []
    for i in lis:
        if i % numb == 0:
            liss.append(numb)
        else:
            liss.append(i % numb)
    liss.sort(reverse=True)
    co = 0
    numm = sum(liss)

    for i in range(numm//numb):
        co += numb-liss[i]
    if co <= k:
        print(numb)
        exit()

Measured memory_bytes: 3188
#include <iostream>

using namespace std;

int x[16][16];
int y[16][16];
int a[16];
int main() {
  int n;
  cin >> n;
  for(int i = 0; i < n; i++) {
    cin >> a[i];
    for(int j = 0; j < a[i]; j++) {
      cin >> x[i][j] >> y[i][j];
      x[i][j]--;
    }
  }

  int ans = 0;
  for(int i = 0; i < (1 << n); i++) {
    int c = 0;
    bool ok = true;
    //  cout << "i = "<<i<<endl;
    for(int j = 0; j < n; j++) {
      if(i & (1 << j)) {
	c++;
	for(int k = 0; k < a[j]; k++) {
	  if(((i >> x[j][k]) & 1) != y[j][k] ) {
	    ok = false;
	    break;
	  }
	}
      }
    }
    if(ok) {
      ans = max(ans,c);
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<limits.h>
#include<algorithm>
typedef long long LL;
#define rep(i,N) for(int i=0;i<(LL)N;i++)
const int sz=1<<17;
inline char CH()
{
  static char buf[1<<17],*c1=buf+sz,c2;
  if(c1-buf==sz)fread_unlocked(buf,1,sz,stdin),c1=buf;
  return *c1++;
}
inline LL IN(void)
{
  LL x=0;short f=0,c=CH();
  while(c<48||c>57)f^=c==45,c=CH();
  while(c>47&&c<58)x=x*10+c-48,c=CH();
  return f?-x:x;
}
signed main(void)
{
  int N,NG,OK,BASE,minus;
  LL K,L=-pow(16,16)/16,M,R=LLONG_MAX/3,count;
  N=IN(),K=IN();
  int A[N];
  rep(i,N)A[i]=IN();
  std::sort(A,A+N);
  while(R-L>1)
  {
    M=(L+R)/2,count=0;
    rep(i,N)
    {
      NG=i,OK=N,minus=(A[i]<0);
      while(OK-NG>1)
      {
        BASE=(NG+OK)/2;
        if((LL)A[i]*A[BASE]<=M){if(minus)OK=BASE;else NG=BASE;}
        else{if(minus)NG=BASE;else OK=BASE;}
      }
      count+=(minus)?N-OK:NG-i;
    }
    if(count<K)L=M;else R=M;
  }
  return printf("%lld\n",R),0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)

const ll MOD = (ll)1e9 + 7;
const ll HIGHINF = (ll)1e18;

int main() {
  ll n; cin >> n;
  vll h(n);
  REP(i, n) cin >> h.at(i);
  vll dp(n, 0);
  dp.at(1) = abs(h.at(1) - h.at(0));
  rep(i, 2, n) {
    dp.at(i) = min(dp.at(i-1) + abs(h.at(i) - h.at(i-1)),
                   dp.at(i-2) + abs(h.at(i) - h.at(i-2)));
  }
  cout << dp.at(n-1) << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <math.h>

using namespace std;
int main(){
  int N;
  cin >> N;
  //long long* x = (long long *)calloc(N, sizeof(long long));
  string x[10];
  string u[10];
  for(int i=0;i<N;i++){
    cin >> x[i] >> u[i];
  }

  double ans = 0.;
  for(int i=0;i<N;i++){
    //cout << x[i] << " " << u[i] << endl;
    if(u[i]=="JPY"){
      //ans += x[i]-'0';
      int subans = 0;
      int j = 0;
      while(j<x[i].length()){
       subans += (x[i][j]-'0')*pow(10, x[i].length()-j-1);
       j++;
      }
      ans += subans;
    } else {
      string subs;
      int j=0;
      while(j<x[i].length()){
        subs += x[i][j];
        j++;
      }
      double subans = stod(subs);
      double ibtc = 380000.;
      ans += ibtc*subans;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#define pb push_back
#define ff first
#define ss second
#define ll long long
#define maxn 200005
#include <bits/stdc++.h>
using namespace std;


int main() {
    double x;
    cin >> x;
    x = x / 3.0;
    x = x * x * x;
    printf("%.10lf\n", x);
    //cout << x << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int main(){
	int a,b,c;
	while(scanf("%d%d%d",&a,&b,&c)!=EOF){
		if(a==b &&a == c && b ==c){
			printf("Yes\n");
		}
		else{
			printf("No\n");
		}
	}
	return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	unsigned long long n,m;
	cin>>n>>m;
	unsigned long long t=n*m;
	if(n==1||m==1){
		cout<<"1";
		return 0;	
	}
	if(t%2==0){
		cout<<t/2;
	}
	else {
		cout<<t/2+1;	
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int k = in.nextInt();
		int n = in.nextInt();
		List<List<Integer>> list = new ArrayList<>();
		for (int i = 0; i <= k; i++) list.add(new ArrayList<>());
		int[] degrees = new int[k+1];
		for (int i = 0; i < n; i++) {
			int a = in.nextInt();
			int b = in.nextInt();
			list.get(a).add(b);
			degrees[b]++;
		}
		Queue<Integer> queue = new LinkedList<>();
		for (int i = 1; i <= k; i++) {
			if(degrees[i] == 0) queue.add(i);
		}
		int depth = -1;
		while(!queue.isEmpty()){
			depth++;
			int size = queue.size();
			for (int i = 0; i < size; i++) {
				int tmp = queue.poll();
				for(int node : list.get(tmp)){
					if(--degrees[node] == 0) queue.add(node);
				}
			}
		}
		System.out.println(depth);
	}
}

Measured memory_bytes: 100340
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<stack>
using namespace std;

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

bool CheckMatch(string A[], string B[], int M, int y, int x) {
	for (int i = 0;i < M;i++) {
		for (int j = 0;j < M;j++) {
			if (A[y + i][x + j] != B[i][j]) return 0;
		}
	}
	return 1;
}

bool IsMatch(string A[], string B[], int N, int M) {
	for (int i = 0;i < N - M + 1;i++) {
		for (int j = 0;j < N - M + 1;j++) {
			if(A[i][j] == B[0][0]){
				if (CheckMatch(A, B, M, i, j)) return 1;
			}
		}
	}
	return 0;
}

int main() {
	int N, M;
	cin >> N >> M;

	string A[51];
	REP(i, N) {
		cin >> A[i];
	}

	string B[51];
	REP(i, M) {
		cin >> B[i];
	}

	cout << (IsMatch(A, B, N, M) ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 256
// UNNECESSARY
// #include <chrono>//std::chrono::/system_clock/steady_clock/high_resolution_clock/duration
// #include <cstdio>//printf/scanf/fopen/fclose/fprintf/fscanf/snprintf/putc/puts/getc/gets
// #include <fstream>//ifstream/ofstream

// DATA STRUCTURES
#include <array>
#include <bitset>
#include <list>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <valarray>
#include <vector>

// MISCELLANEOUS
#include <algorithm>//min/max/sort(rand-access it)/merge
#include <cassert>
#include <climits>//INT_MAX/INT_MIN/ULLONG_MAX
#include <cmath>//fmin/fmax/fabs/sin(h)/cos(h)/tan(h)/exp/log/pow/sqrt/cbrt/ceil/floor/round/trunc
#include <cstdlib>//abs/atof/atoi/atol/atoll/strtod/strtof/..., srand/rand, calloc/malloc, exit, qsort
#include <iomanip>//setfill/setw/setprecision/fixed/scientific
#include <iostream>//cin/cout/wcin/wcout/left/right/internal/dec/hex/oct/fixed/scientific
#include <iterator>
#include <limits>//numeric_limits<type>::max/min/lowest/epsilon/infinity/quiet_NaN/signaling_NaN
#include <new>
#include <string>//stoi/stol/stoul/stoll/stoull/stof/stod/stold/to_string/getline
#include <utility>//pair

#ifndef REP
#define REP(i,n) for (int i = 0; i < n; ++i)
#endif

#ifndef REPST
#define REPST(i,n) for (size_t i = 0; i < n; ++i)
#endif

#ifndef READ
#define READ(x) std::cin >> x
#endif

typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int, int> pii;
typedef std::pair<ll, int> plli;
typedef std::pair<ull, int> puli;
typedef std::pair<double, int> pdi;
typedef std::pair<ll, ll> pllll;
typedef std::pair<ull, ull> pulul;
typedef std::pair<double, double> pdd;
typedef std::tuple<int, int, int> ti3;
typedef std::tuple<int, int, int, int> ti4;

const bool debug = false;

// --------------------------------------------------------------------------------------

using namespace std;

int main(void)
{
    int x, a, b;
    cin >> x >> a >> b;
    cout << ((x - a) % b) << endl;
    return 0;
}


Measured memory_bytes: 256