akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

typedef struct DICE{
    int s[6];
}dice;

dice dice_rotate(dice d, char rotate){
    int swap;
    if(rotate == 'E'){
        swap = d.s[2];
        d.s[2] = d.s[0];
        d.s[0] = d.s[3];
        d.s[3] = d.s[5];
        d.s[5] = swap;
    }else if(rotate == 'N'){
        swap = d.s[4];
        d.s[4] = d.s[0];
        d.s[0] = d.s[1];
        d.s[1] = d.s[5];
        d.s[5] = swap;
    }else if(rotate == 'S'){
        swap = d.s[1];
        d.s[1] = d.s[0];
        d.s[0] = d.s[4];
        d.s[4] = d.s[5];
        d.s[5] = swap;
    }else if(rotate == 'W'){
        swap = d.s[3];
        d.s[3] = d.s[0];
        d.s[0] = d.s[2];
        d.s[2] = d.s[5];
        d.s[5] = swap;
    }else if(rotate == 'R'){
        swap = d.s[1];
        d.s[1] = d.s[2];
        d.s[2] = d.s[4];
        d.s[4] = d.s[3];
        d.s[3] = swap;
    }

    return d;
}

dice dice_jig(dice d, int i){
    if(i%2==0){
        d = dice_rotate(d, 'S');
    }else if(i%2==1){
        d = dice_rotate(d, 'E');
    }

    return d;
}

bool same_judge(dice d1, dice d2){
    int i;
    bool judge=true;
    for(i=0;i<6;i++){
        if(d1.s[i] != d2.s[i]) judge = false;
    }

    return judge;
}
int main(){
    dice d1,d2;
    int i,j;
    bool judge=false;

    for(i=0;i<6;i++){
        cin >> d1.s[i];
    }
    for(i=0;i<6;i++){
        cin >> d2.s[i];
    }

    for(i=0;i<6;i++){
        if(d1.s[0] == d2.s[0]) break;
        d2 = dice_jig(d2, i);
    }

    for(i=0;i<6;i++){
        for(j=0;j<4;j++){
            if(d1.s[1] == d2.s[1] && d1.s[2] == d2.s[2] && d1.s[4] == d2.s[4] && d1.s[3] == d2.s[3]) break;
            d2 = dice_rotate(d2, 'R');
        }
        if(same_judge(d1,d2)){
            judge = true;
            break;
        }
        d2 = dice_jig(d2, i);
    }

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

    return 0;
}



Measured memory_bytes: 3096
N=int(input())
A=list(map(int,input().strip().split(' ')))
temp=0
pre=[]
for i in range(len(A)):
    temp+=A[i]
    pre+=[temp]

total=pre[-1]
MAX=10**20
for i in range(len(A)-1):
    MAX=min(MAX,abs(total-2*pre[i]))
print(MAX)

Measured memory_bytes: 85724
n, h = map(int, input().split())
a = []
b = []
for _ in range(n):
    x, y = map(int, input().split())
    a.append(x)
    b.append(y)

a = max(a)
b.sort(reverse=True)
ans = 0
for i in b:
    if i<=a:
        ans += (h+a-1)//a
        print(ans)
        break
    h -= i
    ans += 1
    if h<=0:
        print(ans)
        break
else:
    ans += (h+a-1)//a
    print(ans)

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

using namespace std;

inline int read()
{
    int ret=0,flag=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')flag=-1;c=getchar();}
    while(c>='0'&&c<='9')ret=ret*10+(c^'0'),c=getchar();
    return flag*ret;
}

int h,a;

int main()
{
    h=read(),a=read();
    int ans=h/a+(h%a!=0);
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static int euclidean(int x, int y) {
		int result = -1, z = 1;
		while (z > 0) {
			z = x % y;
			if (z == 0) result = y;
			x = y; y = z;
		}
		return result;
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		if (y > x ) {
			int tmp = x; x = y; y = tmp;
		}
		int factor = euclidean(x, y);
		if (factor == -1) {
			System.out.println("not exist Greatest common factor");
		} else {
			System.out.println(factor);
		}
	}
}



Measured memory_bytes: 26228
def main():
    k = int(input())
    seven = 7
    already = set()
    cnt = 0
    if k%2==0:
        print(-1)
        return 
    while seven != 0:
        if seven in already:
            print(-1)
            return 
        seven %= k
        already.add(seven)
        cnt += 1 
        if seven != 0:
            seven = seven * 10 + 7
    print(cnt)
    return

if __name__ == '__main__':
    main()

Measured memory_bytes: 200384
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
void chmax(int &a,int b){	a=max(a,b);	return;	}

#define EPS 1e-8
#define EQ(x, y) (abs((x)-(y))<EPS)
#define GE(x, y) ((x)>(y)||EQ(x, y))
#define LE(x, y) ((x)<(y)||EQ(x, y))

typedef complex<double> point;//changed
typedef point vec;//changed
typedef array<point, 2> line;//changed
typedef vector<point> poly;//changed

struct circle {//changed
	point c;
	double r;
};

vector<point> CrosspointCC(circle c1, circle c2) {
	vector<point> ret;
	double d = abs(c1.c - c2.c);
	double rc = (d*d + c1.r*c1.r - c2.r*c2.r) / (2*d);
	double dfr = c1.r*c1.r - rc*rc;

	if (EQ(dfr, 0.0)) dfr = 0.0;
	else if(dfr < 0.0) return ret;

	double rs = sqrt(dfr);
	vec sgn = (c2.c - c1.c) / d;
	ret.emplace_back(c1.c + sgn*point(rc, rs));
	if (dfr > 0.0) ret.emplace_back(c1.c + sgn*point(rc, -rs));
	return ret;
}

#define MAX_N 300
int n;
point p[MAX_N];

void solve(){
	int ans=1;
	for(int i=0;i<n;++i) for(int j=i+1;j<n;++j){
		circle c1=(circle){p[i],1.0},c2=(circle){p[j],1.0};
		vector<point> v=CrosspointCC(c1,c2);
		for(int l=0;l<v.size();++l){
			point q=v[l];
			int b=2;
			for(int k=0;k<n;++k) if(k!=i&&k!=j) if(abs(p[k]-q)<=1.0) ++b;
			chmax(ans,b);
		}
	}
	printf("%d\n",ans);
}

int main(){
	while(true){
		scanf("%d",&n);
		if(n==0) break;
		for(int i=0;i<n;++i){
			double a,b;
			scanf("%lf %lf",&a,&b);
			p[i]=complex<double>(a,b);
		}
		solve();
	}
}

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

int main(){
	int N;
	cin >> N;
	int v[5] = {0,0,0,0,0};
	rep(i,N) {
		string s;
		cin >> s;
		if (s[0] == 'M') v[0]++;
		else if (s[0] == 'A') v[1]++;
		else if (s[0] == 'R') v[2]++;
		else if (s[0] == 'C') v[3]++;
		else if (s[0] == 'H') v[4]++;
	}

	ll ans = 0;
	rep(i,32) {
		ll k = 1;	
		int c = 0;
		rep(j,5) {
			if (i>>j & 1) {
				c++;
				k *= v[j];
			}
		}
		if (c == 3) ans += k;
	}
	cout << ans << endl;
	return 0;
}


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

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

    int persons[N] = {0};
    for (int i = 0; i < K; i++) {
        int d; cin >> d;
        for (int j = 0; j < d; j++) {
            int holder; cin >> holder;
            persons[holder-1] = 1;
        }
    }

    int cnt = 0;
    for (int i = 0; i < N; i++) {
        if (persons[i] == 0) cnt++;
    }

    cout << cnt;
}

Measured memory_bytes: 3596
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <limits.h>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

#ifndef ULLONG
typedef unsigned long long ULLONG;
#endif
#ifndef LLONG
typedef long long LLONG;
#endif
template <class _T> static _T tp_abs(const _T& a) {
	return ((a < 0) ? (a * -1) : a);
}
template <class _T> static _T tp_min(_T a, _T b) {
	return a < b ? a : b;
}
template <class _T> static _T tp_max(_T a, _T b) {
	return a > b ? a : b;
}
template<class _T> static void get1int(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void get2int(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class _T> static void get3int(_T& a, _T& b, _T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}
static void getstring(char* buff) {
	if (scanf(" %s", buff) < 0) {
		printf("getstr error!\n");
	}
}
static const long long MOD_NUM = 1000000007LL;

static void D2_task();

int main()
{
	D2_task();
	fflush(stdout);
	return 0;
}

static void D2_dfs(std::vector<std::vector<int>>& graph, std::vector<LLONG>& tree, int now, int par)
{
	for (auto it = graph[now].begin(); it != graph[now].end(); it++) {
		if (*it == par) continue;
		tree[*it] += tree[now];
		D2_dfs(graph, tree, *it, now);
	}
}

static void D2_task()
{
	int N, Q;
	get2int(N, Q);

	std::vector<std::vector<int>> graph(N);
	int a, b;
	for (int i = 0; i < N - 1; i++) {
		get2int(a, b); a--; b--;
		graph[a].push_back(b);
		graph[b].push_back(a);
	}
	
	std::vector<LLONG> tree(N, 0);
	int p, x;
	for (int i = 0; i < Q; i++) {
		get2int(p, x); p--;
		tree[p] += (LLONG)x;
	}

	D2_dfs(graph, tree, 0, -1);

	for (int i = 0; i < N; i++) {
		printf("%lld ", tree[i]);
	}
}


Measured memory_bytes: 30464
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e9;
const ll MOD = 1e9 + 7;

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

    int ans = 0;
    rep(i, 10){
        rep(j, 10){
            bool a = false;
            bool b = false;
            bitset<10> ckd;
            rep(k, n){
                int d = s[k] - '0';
                if(!a && d == i) a = true;
                else if(a && !b && d == j) b = true;
                else if(a && b && !ckd[d]){
                    ans++;
                    ckd.set(d);
                }
            }
        }
    }


    cout << ans << endl;
}

Measured memory_bytes: 256
def main():
    a,b,k=map(int,input().split())

    if a<=k:
        k-=a
        a=0
    else:
        print(str(a-k) + ' ' + str(b))
        return

    if b <=k:
        b=0
    else:
        print(str(a)+' ' +str(b-k))
        return
    


    print(str(a) + ' ' + str(b))
if __name__=='__main__':
    main()


Measured memory_bytes: 38384
def func(x, a, n):
    if a[n] == 1:
        x[n] = a[n-1] * x[n-1] + a[n-2] * x[n-2]
    else:
        x[n] = 0

def main():
    K = 1000000007
    line = input().split(' ')
    N = int(line[0])
    M = int(line[1])
    a = [1] * (N + 1)
    x = [0] * (N + 1)

    for i in range(M):
        hole = int(input())
        a[hole] = 0

    x[0] = 1
    if a[1] == 1:
        x[1] = 1
    else:
        x[1] = 0

    for i in range(2, N+1):
        func(x, a, i)
        
    print(x[N]%K)

if __name__ == "__main__":
    main()

Measured memory_bytes: 466036
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int> L(N);
  for(int i=0;i<N;i++){
    cin>>L[i];
  }
  int count=0;
  for(int i=0;i<N;i++){
  for(int j=0;j<N;j++){
  for(int k=0;k<N;k++){
  if(i==j||j==k||k==i)continue;
    if(L[i]<L[j]&&L[j]<L[k]){
  if(max({L[i],L[j],L[k]})<L[i]+L[j]+L[k]-max({L[i],L[j],L[k]})){
    count++;
  }
  }
  }
  }
  }
  cout<<count<<endl;
}

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

int main(){
    int N;
    string T;
    cin >> N >> T;
    int L = T.size();

    vector<vector<int>> P(N+1), W(N+1);
    P[0] = {0};
    W[0] = vector<int>(L, 0);

    for(int n=1; n<=N; n++){
        int M = pow(3, n);
        vector<int> D(M);
        for(int i=0; i<M; i++) D[i] = i/(M/3);
        W[n].resize(L);
        vector<int> done(M);
        int s = 0;
        for(int j=0; j<L; j++){
            int w = W[n-1][j];
            for(int i=w; i<M; i+=M/3){
                if((s-done[i]) % 2 && D[i]) D[i] = 3-D[i];
                done[i] = s;
                if(D[i] == 2) W[n][j] = i;
            }
            if(T[j] == 'S'){
                s++;
            }else{
                for(int i=w; i<M; i+=M/3){
                    D[i] = (D[i]+1) % 3;
                }
            }
        }
        for(int i=0; i<M; i++) if((s-done[i]) % 2 && D[i]) D[i] = 3-D[i];
        P[n].resize(M);
        for(int i=0; i<M; i++) P[n][i] = D[i]*(M/3) + P[n-1][i%(M/3)];
    }

    for(int a : P[N]) cout << a << " ";
    cout << endl;
    return 0;
}


Measured memory_bytes: 21528
<?php
    fscanf(STDIN, "%d", $n);
    fscanf(STDIN, "%s", $s);
    if($n % 2 === 0){
        $t = substr($s, 0, $n/2);
        if($t.$t === $s){
            echo 'Yes';
        }else{
            echo 'No';
        }
    }else{
        echo 'No';
    }
?>

Measured memory_bytes: 4728
#include <iostream>

int P[10000];

void init(int N)
{
    for (int i = 0; i < N; i++)
    {
        P[i] = i;
    }
}

int root(int a)
{
    if (P[a] == a)
    {
        return a;
    }
    else
    {
        return (P[a] = root(P[a]));
    }
}

bool is_same_set(int a, int b)
{
    return root(a) == root(b);
}

void unite(int a, int b)
{
    P[root(a)] = root(b);
}

int main()
{
    int n, q;
    std::cin >> n >> q;
    init(n);
    for (int i = 0; i < q; i++)
    {
        int com, a, b;
        std::cin >> com >> a >> b;
        if (com == 0)
        {
            unite(a, b);
        }
        else
        {
            std::cout << is_same_set(a, b) << std::endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
#define ALL(obj) obj.begin(),obj.end()
#define pb(obj) push_back(obj)
#define REP(i,N) for(ll i=0;i<N;i++)
typedef long long ll;
int main(){
    string S;
    cin>>S;
    int Wgu=0,Wki=0,Bgu=0,Bki=0;
    int siz=S.size();
    for(int i=0;i<siz;i++){
        if(i%2==0){
            if(S[i]=='0'){
                Bgu++;
            }
            else{
                Wgu++;
            }
        }
        else{
            if(S[i]=='0'){
                Bki++;
            }
            else{
                Wki++;
            }
        }
    }
    cout<<min(Bgu+Wki,Bki+Wgu)<<endl;
}

Measured memory_bytes: 512
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
	int num[3];
	int a,b,c;
	while(~scanf("%d%d%d",&num[0],&num[1],&num[2]))
	{
		sort(num,num+3);
		if(num[2]==num[1])
			printf("No\n");
		else
		{
			if(num[0]+num[1]==num[2])
				printf("Yes\n");
			else
				printf("No\n");
		}	
	}
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

vector<int> path2[220000],path[220000];
int num[220000];
int dep[220000];
int par[220000];

void dfs(int pos,int bef=-1){
	for(auto to:path2[pos]){
		if(to==bef)continue;
		path[pos].push_back(to);
		par[to]=pos;
		dfs(to,pos);
	}
}

int count(int pos,int s=0){
	dep[pos]=s;
	int a=0;
	for(auto to:path[pos]){
		a=max(a,count(to,s+1));
	}
	num[pos]=a;
	return a+1;
}

int main(){
	int n,m;
	int i,j,k;
	int a,b,c;
	int p,q;
	cin>>n>>p>>q;
	p--,q--;
	for(i=0;i<n-1;i++){
		cin>>a>>b;
		a--,b--;
		path2[a].push_back(b);
		path2[b].push_back(a);
	}
	dfs(q);
	count(q);
	a=dep[p];
	a=(a-1)/2;
	for(i=0;i<a;i++){
		p=par[p];
	}
	cout<<dep[p]+num[p]-1<<endl;
}

Measured memory_bytes: 23296
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=998244353;
ll powmod(ll a, ll k){
    ll ap=a, ans=1;
    while(k){
        if(k&1){
            ans*=ap;
            ans%=MOD;
        }
        ap=ap*ap;
        ap%=MOD;
        k>>=1;
    }
    return ans;
}
ll inv(ll a){
    return powmod(a, MOD-2);
}
ll f[20020], invf[20020];
void fac(int n){
    f[0]=1;
    for(ll i=1; i<=n; i++) f[i]=f[i-1]*i%MOD;
    invf[n]=inv(f[n]);
    for(ll i=n-1; i>=0; i--) invf[i]=invf[i+1]*(i+1)%MOD;
}
ll comb(int x, int y){
    if(!(0<=y && y<=x)) return 0;
    return f[x]*invf[y]%MOD*invf[x-y]%MOD;
}
int main()
{
  string a, b; cin>>a>>b;
  int n=a.size();
  fac(2*n);
  int x=0, y=0;
  for(int i=0; i<n; i++){
    if(a[i]=='1'){
      if(b[i]=='0') x++;
      else y++;
    }
  }
  ll dp[2][10010]={};
  dp[0][0]=1;
  for(int i=1; i<=x; i++){
    fill(dp[i&1], dp[i&1]+y+1, 0);
    for(int j=0; j<=y; j++){
      if(j) (dp[i&1][j]+=dp[i&1][j-1]*i*j)%=MOD;
      (dp[i&1][j]+=dp[(i&1)^1][j]*i*i)%=MOD;
    }
  }
  ll ans=0;
  for(int i=0; i<=y; i++){
    (ans+=f[y]*invf[y-i]%MOD*f[x+y]%MOD*invf[x+y-i]%MOD*dp[x&1][y-i])%=MOD;
  }
  cout<<ans<<endl;
	return 0;
}

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

int main(void) {
  int N, T, A;
  cin >> N >> T >> A;
  vector<double> H(N);

  for (int i = 0; i < N; i++) {
    int h;
    cin >> h;
    H[i] = abs(T - h * 0.006 - A);
  }
  cout << min_element(H.begin(), H.end()) - H.begin() + 1 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define rep(X, Y) for (int(X) = 0; (X) < (Y); ++(X))
#define rrep(X, Y) for (int(X) = (Y)-1; (X) >= 0; --(X))
#define all(X) (X).begin(), (X).end()
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define print(x) cout << x << endl

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const string YES = "YES";
const string NO = "NO";

class UnionFindTree {
private:
  vector<int> par;
  vector<int> rnk;
  vector<int> siz;

public:
  UnionFindTree(int n) {
    par.assign(n, -1);
    rnk.assign(n, -1);
    siz.assign(n, -1);

    for (int i = 0; i < n; ++i) {
      par[i] = i;
      rnk[i] = 0;
      siz[i] = 1;
    }
  }

  int find(int x) {
    if (par[x] == x)
      return x;
    else
      return par[x] = find(par[x]);
  }

  bool same(int x, int y) { return find(x) == find(y); }

  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y)
      return;
    if (rnk[x] < rnk[y]) {
      par[x] = y;
      siz[y] += siz[x];
    } else {
      par[y] = x;
      siz[x] += siz[y];
      if (rnk[x] == rnk[y])
        ++rnk[x];
    }
  }

  int size(int x) {
    x = find(x);
    return siz[x];
  }
};

int main() {
  ll N, M;
  scanf("%lld", &N);
  scanf("%lld", &M);

  vl K(N);
  vector<vl> L(N);
  rep(n, N) {
    scanf("%lld", &K[n]);
    rep(k, K[n]) {
      ll tmp;
      scanf("%lld", &tmp);
      L[n].push_back(tmp);
    }
  }

  UnionFindTree uf(N + M + 100);
  rep(n, N) {
    rep(k, K[n]) { uf.unite(n, N + L[n][k]); }
  }

  bool ok = true;
  rep(n, N) {
    if (!uf.same(0, n)) {
      ok = false;
    }
  }

  if (ok) {
    print(YES);
  } else {
    print(NO);
  }

  return 0;
}


Measured memory_bytes: 8832
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int count = 0;
		for(int i = 0; i < 4; i++) {
			if (s.charAt(i) == '+') {
				count++;
			}else if(s.charAt(i) == '-') {
				count--;
			}
		}
		System.out.println(count);
	}

}


Measured memory_bytes: 35576
while True:
    try:
        s = input()
    except:
        break
    joi = 0
    ioi = 0
    s_list = [s[i:i+3] for i in range(len(s) - 2)]
    for i in s_list:
        if i == "JOI":
            joi += 1
        if i == "IOI":
            ioi += 1
    print(joi)
    print(ioi)

Measured memory_bytes: 7844
//encoding:utf-8
#include <iostream> //c++
#include<time.h> //時間にかんして
#include<stack> //スタックに関して　最新のデータから捨てる
#include<queue> //キューに関して　最古のデータから捨てる
#include<math.h>
#include<vector>
#include<algorithm> //sort とかにいる

#define ll long long
using namespace std;
int inf = INFINITY;

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

  int ans = inf;
  sort(h.begin(),h.end());

  for(int i=0;i<n-k+1;i++){
    ans = min(h[i+k-1]-h[i],ans);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 640
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   main.cpp                                           :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: monoue <marvin@student.42.fr>              +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2020/04/22 12:30:15 by monoue            #+#    #+#             */
/*   Updated: 2020/05/01 09:21:44 by monoue           ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#include <bits/stdc++.h>

/* #include <boost/multi_array.hpp> */
/* #include <boost/optional.hpp> */
/* #include <boost/range/irange.hpp> */
/* #include <boost/range/algorithm.hpp> */
/* #include <boost/range/adaptors.hpp> */
// #include <boost/multiprecision/cpp_int.hpp>
/* #include <boost/algorithm/string/classification.hpp> // is_any_of */
/* #include <boost/algorithm/string/split.hpp> */
/* #include <boost/algorithm/string/join.hpp> */
/* #include <boost/algorithm/string/replace.hpp> */
/* #include <boost/math/tools/minima.hpp> */
/* namespace adaptor = boost::adaptors; */
/* using boost::math::tools::brent_find_minima; */
/* using boost::irange; */
/* using boost::algorithm::join; */
/* using boost::algorithm::split; */
/* using boost::algorithm::replace_all; */
// using boost::multiprecision::cpp_int;

using namespace std;

typedef long long ll;
typedef vector<int> VI;
typedef pair<int, int> PII;

#define	int	long long
#define MOD 1000000007
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rrep(i, n) for (int i = (n); i >= 0; --i)

// TOP
void	Main()
{
	int	n, k;
	cin >> n >> k;

	VI	V(n);
	rep(i, n)
		cin >> V.at(i);
	int	sum;
	sum = 0;
	rrep(i, n - 1)
	{
		rrep(j, i - 1)
		{
			if (V.at(j) > V.at(i))
				sum++;
		}
	}
	sort(V.begin(), V.end());
	int	x;
	x = 0;
	rep(i, n - 1)
	{
		auto itr = upper_bound(V.begin(), V.end(), V.at(i));
		int a = V.end() - itr;
		x += a;
	}
	int f;
	f = k * (k - 1) / 2 % MOD;
	cout << ((f * x) % MOD + (sum * k) % MOD) % MOD << endl;
}
// END

int32_t	main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int,int> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout<<(bool x?"Yes":"No")<<endl;
#define out(s) cout<<s<<endl;
#define pb push_back;
#define sp " ";
void vout(vector<int> v){
    for(int i=0;i<v.size();i++)
    cout<<
    v.at(i)<<endl;
}
int modpow(long long int a, long long int n, long long int p) {
  if (n == 0) return 1; // 0乗にも対応する場合
  if (n == 1) return a % p;//n=1ならaを返す
  if (n % 2 == 1) return (a * modpow(a, n - 1, p)) % p;//nが奇数なら偶数にする
  long long t = modpow(a, n / 2, p);//nが偶数なら半分にする
  return (t * t) % p;
}
int modchoose(lli n,lli k,lli m){
  lli ans=1;
  rep(i,k){
    ans=(ans*(n-i))%m;
    ans=(ans*modpow(i+1,m-2,m))%m;
  }
  return ans;
}

int main(){
    lli ele=1000000007;
    lli all,a,b,n;
    cin>>n>>a>>b;
    all=modpow(2,n,ele)-1;
    a=modchoose(n,a,ele);
    b=modchoose(n,b,ele);
    all=all-a-b;
    while(all<0){
      all+=ele;
    }
    cout<<all;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <functional>
#define rep(i,n) for (int i = 0; i< (n); i++)
using namespace std;
 
int main() {
  int N,max=1;
  cin >>N;
 
  vector<string> s(N); 
  vector<string> dic;
  
  rep(i,N) cin >> s[i];

  sort(s.begin(), s.end());
  
  int count = 1;
  for(int i = 1; i<N;i++){
    if(s[i-1] == s[i]){
      count++;
    }
    else{
      if (count>max) max = count;
      count = 1;
    }
    
    if(i==N-1){
      if (count>max) max = count;
    } 
  }
  
  count = 1;
  for(int i = 1; i<N;i++){
    if(s[i-1] == s[i]){
      count++;
    }
    else{
      if (count==max) {
        dic.push_back(s[i-1]);
      }  
      count = 1;
    }
    
    if(i==N-1){
      if (count==max) {
        dic.push_back(s[i]);
      } 
    } 
  }
  
  
  sort(dic.begin(), dic.end());
  
  for(int i = 0; i<dic.size();i++){
    cout<<dic[i]<<endl;
  }
  
  return 0;
}

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

int main(){
  int n, m, k; cin >> n >> m >> k;
  for(int i = 0; i <= n; i++){
  for(int j = 0; j <= m; j++){
  
  	if(i*j+(n-i)*(m-j)==k){
    	cout << "Yes" << endl;
    	return 0;
    }
  
  }
  }
  
  cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007
#define int long long
#define rep(i,a,b) for(int i=a; i<=b; ++i)
#define rev(i,a,b) for(int i=a; i>=b; --i)

using namespace std;

int n, done[100050], ncr[100050], sub[100050];
int exp(int b, int e){
	if(e == 0) return 1;
	int half = exp(b, e/2)%mod;
	half *= half; half%=mod;
	if(e%2==1) half *= b;
	return half%mod;
}
inline int inv(int a){ return exp(a, mod-2); }
int32_t main(){
	cin >> n;
	int x = 0, y = 0;
	rep(i,1,n+1){
		int a; cin >> a;
		if(done[a] != 0){
			assert(x == 0 and y == 0);
			x = done[a];
			y = i;
		}
		done[a] = i;
	}
	x+=n-y;
	n++;
	ncr[0] = sub[0] = 1;
	rep(i,1,n){
		// calculate n choose i and x+y
		ncr[i] = ncr[i-1];
		ncr[i] *= n-i+1; ncr[i] %= mod;
		ncr[i] *= inv(i); ncr[i] %= mod;
		ncr[i] += mod; ncr[i] %= mod;
		sub[i] = sub[i-1]; 
		sub[i] *= x-i+1; sub[i] %= mod;
		sub[i] *= inv(i); sub[i] %= mod;
		sub[i] += mod; sub[i] %= mod;
	}
	rep(k,1,n){
		cout << (ncr[k]-sub[k-1]+mod)%mod << "\n";
	}
}


Measured memory_bytes: 3584
import numpy as np
n,a = map(int,input().split())
x = list(map(int,input().split()))
"""
平均がa <=> 集合をlとして, len(l)a = sum(l)
dp[i][j][k] := i番目までのカードを選んだとき, 選んだ枚数がkでの総和がちょうどjになる場合の数.
これだとメモリが足りないので, iを省略する.
"""
sumx = sum(x)
dp = np.zeros((n, sumx+1), dtype=np.int64)
for i in range(n):
	for j in range(i)[::-1]:
		dp[j+1][x[i]:] += dp[j][:-x[i]]
	dp[0][x[i]] += 1
ans = 0
for i in range(n):
	if (i+1)*a <= sumx:
		ans += dp[i][(i+1)*a]
print(ans)

Measured memory_bytes: 27532
#include<iostream>
#include<cstdio>
#include<cctype>
using namespace std;
int main(){
    string a;
    while(1){
        cin>>a;
        if(a=="0")break;
        int b=0;
        for(int i=0;i<a.size();i++){
            b += a[i]-'0';
        }
        cout<<b<<endl;
    }
    return 0;
}


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define maxn 200010
#define LL long long 
#define INF 0x3f3f3f3f

LL a[maxn];
int n,k;
LL ans;

int main(){
	//freopen("test.in","r",stdin);
	
	cin>>n>>k;
	for(int i=1;i<=n;i++) a[i%k]++;
	
	ans=a[0]*a[0]*a[0];
	if(k%2==0) ans+=a[k/2]*a[k/2]*a[k/2];
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 1024
import java.io.*;
import java.util.*;
import java.util.stream.*;

class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		long n = saori.saorihayami();
		long k = saori.saorihayami();
		long ans = 0;
		long num = 0;
		if(n > k){
			num = n%k;
			ans = Math.min(num,Math.abs(k-num));
		} else {
			ans = Math.min(n, Math.abs(n-k));
		}

		System.out.println(ans);
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 23252
#include<bits/stdc++.h>
#define For(i,l,r) for(int i=(l),i##end=(r);i<=i##end;i++)
#define Fordown(i,r,l) for(int i=(r),i##end=(l);i>=i##end;i--)
using namespace std;
typedef long long ll;
const int INF=1e9;
const double eps=1e-9;
inline int read(){
	int x=0,flag=1;
	char ch=getchar();
	while(!isdigit(ch) && ch!='-')ch=getchar();
	if(ch=='-')flag=-1,ch=getchar();
	while(isdigit(ch))x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
	return x*flag;
}
int main(){
	int a,b,c,x,y;
	a=read(),b=read(),c=read(),x=read(),y=read();
	ll ans=1ll*a*x+1ll*b*y;
	if(x==y)ans=min(ans,2ll*c*x);
	else if(x>y){
		ans=min(ans,2ll*c*y+1ll*a*(x-y));
		ans=min(ans,2ll*c*x);
	}
	else if(x<y){
		ans=min(ans,2ll*c*x+1ll*b*(y-x));
		ans=min(ans,2ll*c*y);
	}
	printf("%lld\n",ans);
	return 0;
}


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

template<long long mod = 1000000007>
struct modint{
	long long a;

	modint() : a(0){}
	modint(long long t){
		a = t % mod;
		if(a < 0) a += mod;
	}

	bool operator==(const modint &x) const{ return a == x.a; }
	bool operator!=(const modint &x) const{ return a != x.a; }

	modint operator-() const{ return modint(a ? (mod - a) : 0); }
	modint operator~() const{ return pow(mod - 2); }

	modint operator+(const modint &x) const{ return modint(*this) += x; }
	modint operator-(const modint &x) const{ return modint(*this) -= x; }
	modint operator*(const modint &x) const{ return modint(*this) *= x; }
	modint operator/(const modint &x) const{ return modint(*this) /= x; }

	modint &operator+=(const modint &x){
		a += x.a;
		if(a >= mod) a -= mod;
		return *this;
	}
	modint &operator-=(const modint &x){
		a -= x.a;
		if(a < 0) a += mod;
		return *this;
	}
	modint &operator*=(const modint &x){
		a = a * x.a % mod;
		return *this;
	}
	modint &operator/=(const modint &x){
		a = a * (~x).a % mod; 
		return *this;
	}

	modint &operator++(){ return (*this) += 1; }
	modint &operator--(){ return (*this) -= 1; }
	modint &operator++(int){
		modint tmp = *this;
		(*this) += 1;
		return tmp;
	}
	modint &operator--(int){
		modint tmp = *this;
		(*this) -= 1;
		return tmp;
	}

	friend ostream &operator<<(ostream &os,const modint &x){
		return os << x.a;
	}
	friend istream &operator>>(istream &is,modint &x){
		long long t;
		is >> t;
		x = modint(t);
		return is;
	}

	modint pow(long long x) const{
		modint ret = 1,tmp = a;
		for(;x;tmp *= tmp,x >>= 1){
			if(x & 1) ret *= tmp;
		}
		return ret;
	}
};

signed main(){
	modint<> m;
	long long n;
	cin >> m >> n;
	cout << m.pow(n) << endl;
}



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

int main(){
    char s ;
    cin >> s ;
    int a = s ;
    if( a <= 90 && a >= 65)cout <<'A' <<endl;
    else cout <<'a' << endl;
}

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

int main(int argc,char* argv[]){
	int a , b;
	cin >> a >> b;
	int ans;
	int tap=1;
	while(tap < b){
		--tap;
		tap+=a;
		++ans;
	}
 	cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int nums[50];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n,m;
    cin>>n>>m;
    
    rep(i,n){
        int k;
        cin>>k;
        rep(j,k){
            int a;
            cin>>a;
            nums[a]++;
        }
    }
    
    int ans=0;
    rep(i,m+1){
        if(nums[i]==n) ans++;
    }
    cout1(ans)
}

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

int main()
{
	int N, K, count{};
	scanf("%d%d", &N, &K);
	for (int i{}; i < N; i++)
	{
		int h;
		scanf("%d", &h);
		if (h >= K) count++;
	}
	printf("%d\n", count);

	return 0;
}

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  
  int count = 0;
  for (int i = a; i <= b; i++) {
    if (c%i == 0) {
      count++;
    }
  }
  cout << count << endl;
  
  return 0;
  
}


Measured memory_bytes: 3120
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
using namespace std;
using ll = long long;

unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

ll ll_gcd(ll a, ll b) {
    if (a < b) return ll_gcd(b, a);
    ll r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
    ll n,c;
    cin >> n >> c;
    vector<vector<ll>>z(c,vector<ll>(c));
    vector<vector<ll>>x(n, vector<ll>(n));
    for (int i = 0; i < c; i++) {
        for (int j = 0; j < c; j++) {
            cin >> z[i][j];
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cin >> x[i][j];
            x[i][j]--;
        }
    }
    vector<vector<ll>>jans(c, vector<ll>(3));
    for (int t = 0; t < c; t++) {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                jans[t][(i + j) % 3] += z[x[i][j]][t];
            }
        }
    }
    ll ans = 12345678901;
    for (int i = 0; i < c; i++) {
        for (int j = 0; j < c; j++) {
            for (int k = 0; k < c; k++) {
                if (i != j && j != k && k != i)ans = min(ans, jans[i][0] + jans[j][1] + jans[k][2]);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 5484
h,w,k = gets.chomp.split(" ").map(&:to_i)

arr = h.times.map{gets.chomp.split("").map{|s| s == "." ? 0 : 1}}

result = 0
(2 ** h).times do |i|
  arr_i = "%0#{h}d" % i.to_s(2)
  (2 ** w).times do |j|
    arr_j = "%0#{w}d" % j.to_s(2)
    count = 0
    0.upto(h-1) do |i2|
      next if arr_i[i2] == "0"
      0.upto(w-1) do |j2|
        next if arr_j[j2] == "0"
        count += 1 if arr[i2][j2] == 1
      end
    end
    result += 1 if count == k
  end
end

puts result

Measured memory_bytes: 14356
#include<stdio.h>

int main(){
    int a,b,c;
    scanf("%d",&a);
    for (int i = 0; i < 3; i++)
    {
        b = a;
        for (int f = 0; f < i; f++)
        {
            b /= 10;
        }
        if (b % 2 == 1)
        {
            c++;
        }
        
    }
    printf("%d",c);
}

Measured memory_bytes: 1680
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
typedef unsigned long long int ull;
typedef long long lint;
 
int main(void){
    int N;
    cin >> N;
    string s[N];
    rep(i,N) cin >> s[i];
    int M;
    cin >> M;
    string t[M];
    rep(i,M) cin >> t[i];
    int ans=0;
    rep(i,N){
        string check=s[i];
        int count=0;
        rep(j,N) if(check==s[j]) count++;
        rep(j,M) if(check==t[j]) count--;
        ans=max(ans,count);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////


int main(){
    
    string o,e;
    cin >> o >> e;
    rep(i,0,min(sz(o),sz(e)))cout << o[i] << e[i];
    if(sz(o) < sz(e))cout << e[sz(e)-1] << endl;
    else if(sz(o) > sz(e))cout << o[sz(o)-1] << endl;
    else cout << endl;
    return  0;
}


Measured memory_bytes: 256
import itertools
S = list(input())
ans = []
a = S[0]
pl = ["+",""]

for i in itertools.product(pl, repeat=len(S)-1):
    for j in range(len(S)-1):
        a += i[j]+S[j+1]
    ans.append(eval(a))
    a = S[0]

print(sum(ans))

Measured memory_bytes: 9080
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;
typedef pair<int,int> P;
int gcd(int x,int y){
  x=abs(x);
  y=abs(y);
  if(x<y) swap(x,y);
  while(x%y!=0){
    int r=x%y;
    x=y;
    y=r;
  }
  return y;
}
int main(){
  int n,k;
  cin>>n>>k;
  int border=k*(k-1)/2;
  vector<P> ps;
  for(int i=0;i<n;i++){
    int a,b;
    cin>>a>>b;
    ps.push_back(P(a,b));
  }
  for(int i=0;i<n;i++){
    map<P,int> mp;
    for(int j=0;j<n;j++){
      if(i==j) continue;
      int dx=ps[i].first-ps[j].first,dy=ps[i].second-ps[j].second;
      if(dx<0){
        dx*=-1;
        dy*=-1;
      }
      if(dx==0){
        dy=1;
      }
      else if(dy==0) {
        dx=1;
      }
      else{
        int g=gcd(dx,dy);
        dx/=g;
        dy/=g;
      }
      P p=P(dx,dy);
      if(mp.find(p)!=mp.end()) {
        mp[p]++;
        if(mp[p]>=k-1){
          cout<<1<<endl;
          return 0;
        }
      }
      else mp[p]=1;
    }
  }
  cout<<0<<endl;
}



Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
int main(void){
	 char a[101][101];
	 int h,w;
	 int i,j,k;
	 cin>>h>>w;
	 for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			 cin>>a[i][j];
		}
	 }
	 
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			if(a[i][j]=='#'){
				break;
			}
		}
		if(j==w){
			for(j=0;j<w;j++){
				a[i][j]='*';
			}
		}
	}
	for(j=0;j<w;j++){
		for(i=0;i<h;i++){
			if(a[i][j]=='#'){
				break;
			}
		}
		if(i==h){
			for(i=0;i<h;i++){
				a[i][j]='*';
			}
		}
	}
	/*for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			cout<<a[i][j];
		}
		cout<<endl;
	}
	cout<<endl;*/
	for(i=0;i<h;i++){
		int flg=0;
		for(j=0;j<w;j++){
			if(a[i][j]=='*')	continue;
			cout<<a[i][j];
		}
		for(j=0;j<w;j++){
			if(a[i][j]!='*'){
				break;
			}
		}
		if(j==w)	flg=1;
		if(flg==0)cout<<endl;
	}
	return 0;
}
				
				

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int visit[101];
int main(){
	int N, K;
	cin >> N >> K;
	for(int i=1; i<=K; i++){
		int d1, v;
		cin >> d1;
		for(int j=1; j<=d1; j++){
			cin >> v;
			visit[v] = 1;
		}
	}
	int ans = 0;
	for(int i=1; i<=N; i++){
		if(!visit[i]) ans++;
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 3608
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007

int main(){
  ll n,k;
  cin>>n>>k;
  ll c = 0;
  while(n>0){
    n/=k;
    c++;
  }
  cout << c << endl;
  return 0;
}

Measured memory_bytes: 256
from collections import deque

N, Q = map(int, input().split())
AB = [tuple(map(int, input().split())) for _ in range(N-1)]
PX = [tuple(map(int, input().split())) for _ in range(Q)]
T = [[] for _ in range(N+1)]
for a, b in AB:
    T[a].append(b)
    T[b].append(a)

C = [0 for _ in range(N+1)]
for p, x in PX:
    C[p] += x

S = deque([(1, 0)])
while S:
    v, p = S.popleft()
    for t in T[v]:
        if t == p:
            continue
        C[t] += C[v]
        S.append((t, v))

print(*C[1:])

Measured memory_bytes: 100372
from collections import defaultdict

n = int(input())
V = list(map(int,input().split()))

ODD = defaultdict(int)
EVEN = defaultdict(int)
NUMBER = set()

for i in range(n):
    if i%2==0:
        EVEN[V[i]] += 1
    else:
        ODD[V[i]] += 1
    NUMBER.add(V[i])
    
    
ODD[999999] = 0
EVEN[999999] = 0
if len(NUMBER)==1:
    print(n//2)
else:
    flag = True
    max_ODD = max(ODD, key=ODD.get)
    max_EVEN = max(EVEN, key=EVEN.get)
    O = [ODD[max_ODD]]
    E = [EVEN[max_EVEN]]
    if max_ODD != max_EVEN:
        print(n-O[0]-E[0])
    else:
        ODD.pop(max_ODD)
        EVEN.pop(max_EVEN)
        max_ODD = max(ODD, key=ODD.get)
        max_EVEN = max(EVEN, key=EVEN.get)
        O.append(ODD[max_ODD])
        E.append(EVEN[max_EVEN])
        print(min([n-O[0]-E[1],n-O[1]-E[0]]))

Measured memory_bytes: 22100
H, W, K = map(int, input().split())
X = [[1 if a == "#" else 0 for a in input()] for _ in range(H)]
ans = 0
for ii in range(1 << H):
    for jj in range(1 << W):
        if sum([sum([X[i][j] for j in range(W) if jj >> j & 1]) for i in range(H) if ii >> i & 1]) == K:
            ans += 1
print(ans)

Measured memory_bytes: 69696