akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools

class cin():
    def int():
        return int(sys.stdin.readline().rstrip())
    def string():
        return sys.stdin.readline().rstrip()
    def mapInt():
        return [int(x) for x in cin.string().split()]
    def stringList(n):
        return [input() for i in range(n)]
    def intListList(n):
        return [cin.mapInt() for i in range(n)]

class Util():
    def roundUp(a,b):
        return -(-a // b)
    def toUpperMultiple(a,x):
        return Util.round_up(a,x) * x
    def toLowerMultiple(a,x):
        return (a // x) * x

N = cin.int()

ans = ""
while(N != 0):
    q = N % 2
    p = (N - q) // (-2)
    ans += str(q)
    N = p
if ans == "":
    ans += "0"
print(ans[::-1])

Measured memory_bytes: 38384
####################################################################
import sys
def _p(*_a):
  #return
  _s=" ".join(map(str,_a))
  #print(_s)
  sys.stderr.write(_s+"\n")
####################################################################
def _pa(_aa):
  #return
  for _a in _aa: _p(_a)
####################################################################

N,M = map(int, input().split())

F=[ [] for i in range(N+1) ]
for i in range(M):
  a,b = map(int, input().split())
  F[a].append(b)
  F[b].append(a)

_pa(F)

from collections import deque

G=[-1]*(N+1)
for i in range(N+1):
  if G[i]>-1: continue
  G[i] = i
  Q = deque()
  Q.append(F[i])
  while Q:
    l = Q.popleft()
    for f in l:
      if G[f]==-1:
        G[f] = i
        Q.append(F[f])

_pa(G)


from collections import Counter
C = Counter(G)
ans = 1
for k,v in C.items():
  ans = max(ans, v)

_p(C)
_p(*C)

print(ans)

Measured memory_bytes: 69984
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(0);cin.tie();cout.tie();
#define ff first
#define ss second
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 9223372036854775807;
const ll mininf = -9223372036854775807;
const ll nax = 0;
string a;

bool cek(string s){
	int l=0;
	int r=s.length()-1;
	while(l<r){
		if(s[l]!=s[r]){
			return false;
		}
		l++;
		r--;
	}
	return true;
}

int main(){
	IOS
	cin >> a;
	int n=a.length();
	string b, c;
	for(int i=0;i<(n-1)/2;i++){
		b=b+a[i];
	}
	for(int i=(n+3)/2-1;i<n;i++){
		c=c+a[i];
	}
	bool satu=cek(a);
	bool dua=cek(b);
	bool tiga=cek(c); 
	if(satu&dua&tiga){
		cout << "Yes" << '\n';
	}
	else{
		cout << "No" << '\n';
	}
}

Measured memory_bytes: 3636
import java.util.Scanner;
public class Main {
	public static Scanner sc = new Scanner(System.in);

	public static void main(String[] args){
		//A
		/*
		String s = sc.next();
		int ans = 0;
		for(int i = 0 ; i < 4 ; i++){
			if(s.charAt(i) == '+')
				ans++;
			else
				ans--;
		}
		System.out.println(ans);
		*/
		//B
		int n = sc.nextInt();
		int length = String.valueOf( n ).length();
		int sn = 0;
		for(int i  = 0; i < length ; i++){
			sn += n/(int)(Math.pow(10, i))%10;
		}
		if(n % sn == 0)
			System.out.println("Yes");
		else
			System.out.println("No");
	}
}


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

using namespace std;

typedef long long ll;

int main()
{
    ll N, Y;
    cin >> N;
    cin >> Y;
    for (int x = 0; x <= N; x++) {
        for (int y = 0; y <= N - x; y++) {
            int z = N - y - x;
            if (Y == 10000 * x + 5000 * y + 1000 * z) {
                cout << x << " " << y << " " << z << endl;
                return 0;
            }
        }
    }
    cout << -1 << " " << -1 << " " << -1 << endl;
}

Measured memory_bytes: 256
import sys, io, os
input = sys.stdin.readline
inputt = lambda: range(int(input()))
inputn = lambda n = 1: range(n)
inputi = lambda: map(int, input().split())
inputl = lambda: list(inputi())
from math import *
from heapq import *
from bisect import *
from functools import reduce, lru_cache
from collections import Counter, defaultdict
from builtins import *

a, b, c = inputi()
print(c, a, b)

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 1000000007
#define FT() int t; scanf("%d",&t); while(t--)
#define pb push_back
#define nl printf("\n")
#define fi(i,start,end) for(int i=start; i < (int)end ; ++i)
#define ip(n)   scanf("%d",&n)
#define mz(a)   memset(a,0,sizeof(a))
#define inpArr(A,n) fi(i,0,n)   ip(A[i]);
#define print(a)  for(auto i : a)   cout<<i<<" "; nl;
#define Fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
ll max(ll a,ll b)   {return a>b?a:b;}
ll min(ll a,ll b)   {return a<b?a:b;}

int main() {
    #ifndef ONLINE_JUDGE
    freopen("D:/Sublime/Rough/input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    #endif
    //std::cout << std::fixed;
    //std::cout << std::setprecision(6);
    Fastio;
    int testcase = 1;
//    cin>>testcase;
    while(testcase--)
    {
        string s,t;
        cin>>s>>t;
        int n = s.length(), m = t.length();
        int mx = 0;
        for(int i=0;i<m;i++)
        {
            for(int j=i;j<=n-m + i; j++)
            {
                if(t[i] == s[j])
                {   //cout<<i<<":"<<t[i]<<", "<<j<<":"<<s[j]<<"\n";
                    int ic = i, jc = j, len = 0;
                    while(ic<m && jc<n)
                    {
                        if(t[ic] == s[jc])
                            len++; 
                        ic++; jc++;
                    }
                    //cout<<len<<"\n";
                    mx = max(mx,len);
                }
            }
        }
        cout<<(m-mx)<<"\n";
    }

    #ifndef ONLINE_JUDGE
    cout<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s";
    #endif
    
    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n; cin >> n;
	int a[n], b[n], c[n-1];
	for(int i = 0; i < n; i++) { cin >> a[i]; a[i]--; }
	for(int i = 0; i < n; i++) cin >> b[i];
	for(int i = 0; i < n; i++) cin >> c[i];
	int res = 0;
	for (int i = 0; i < n; i++)
	{
		res += b[a[i]];
		if(i < n-1) {
			if(a[i] + 1 == a[i+1]) res += c[a[i]];
		}
	}
	cout << res << endl;
	return 0;
}


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

using namespace std;

typedef long long int ll;

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll a,b,c,d;
    cin >> a >> b >> c >> d;

    ll cc = 0;
    while(1)
    {
        if(a<=0 || c<=0)
            break;

        if(cc%2==0)
        {
            c-=b;
        }
        else
        {
            a-=d;
        }
        cc++;
    }
    if(a<=0)
        cout << "No";
    else
        cout << "Yes";

    return 0;
}


Measured memory_bytes: 3608
import java.io.*;
import java.util.Random;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) {
        FastReader scan = new FastReader();
        PrintWriter out = new PrintWriter(System.out);
        Task solver = new Task();
        int t = 1;
        while (t --> 0) solver.solve(1, scan, out);
        out.close();
    }

    static class Task {

        public void solve(int testNumber, FastReader scan, PrintWriter out) {
            long n = scan.nextLong(), total = 0;
            if(n % 2 == 0) {
                n /= 2;
                long curr = 5;
                for(int i = 0; i < 25; i++) {
                    total += n/curr;
                    curr *= 5;
                }
            }
            out.print(total);
        }
    }

    static void shuffle(int[] a) {
        Random get = new Random();
        for (int i = 0; i < a.length; i++) {
            int r = get.nextInt(a.length);
            int temp = a[i];
            a[i] = a[r];
            a[r] = temp;
        }
    }

    static void shuffle(long[] a) {
        Random get = new Random();
        for (int i = 0; i < a.length; i++) {
            int r = get.nextInt(a.length);
            long temp = a[i];
            a[i] = a[r];
            a[r] = temp;
        }
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public FastReader(String s) throws FileNotFoundException {
            br = new BufferedReader(new FileReader(new File(s)));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

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

int main() {
	int N, A;
	cin >> N;
	vector<int> ans(N);
	for (int i = 0; i < N; ++i) {
		cin >> A;
		int a = 0;
		while (0 == A % 2) {
			A /= 2;
			++a;
		}
		ans[i] = a;
	}
	cout << *min_element(ans.begin(), ans.end());
}

Measured memory_bytes: 256
#include <stdio.h>

static void red_or_string(int a, char *str);

int main(void){
  int a = 0;
  char str[11];

  scanf("%d", &a);
  scanf("%s", str);
  
  red_or_string(a, str);

  return 0;
}

static void red_or_string(int a, char *str){
  if(a < 3200){
    printf("red\n");
  } else {
    printf("%s", str);
  }
}

Measured memory_bytes: 128
#include <cstdio>

const int N = 200005;

int c;
long long re;
char s[N];

int main() {
  scanf("%s", s + 1);
  for (int i = 1; s[i]; ++i) {
    if (s[i] == 'B') {
      ++c;
    } else {
      re += c;
    }
  }
  printf("%lld\n", re);
  return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int main(void)
{
  char s[] = "";
  int i, answer;
  answer = 0;
  scanf("%s",s);
  for(i=0; i<=2; i++)
  {
    if ((s[i]) == '1')
    {
      answer += 1;
    }
    
  }
  printf("%d",answer);

  return 0;
}


Measured memory_bytes: 128
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
	string s;
	cin>>s;
	sort(s.begin(),s.end());
	puts(s=="abc"?"Yes":"No");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define rrep(i,a,b) for(int i = a ; i >= b; i--)
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define sq(a) (a)*(a)
#define nl "\n"
#define debug2(x, y) cout << #x << " = " << x << "   " << #y << " = " << y << nl;
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,
//tree_order_statistics_node_update> indexed_set;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef unsigned long long ull;
const int MAXN = 100005;
ll mod=1000000007;


int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  t = 1;
  // cin>>t;
  while(t--){
      int n;
      cin>>n;
      ii p = {0,0};
      rep(i,0,n-1){
        int u, v;
        cin>>u>>v;
        if(mp(u,v) > p){
          p = mp(u,v);
        }
        //largest a[i] se smaller all values
      }
      cout<<(p.F + p.S)<<nl;
  }
  return 0;
}


Measured memory_bytes: 3632
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
char s[1000010];
int n,sufmx[1000010];
int work(int mx)
{
	int add=0,mi=0,cur=0;
	for(int i=1;i<=n;++i)
	{
		if(s[i]=='?'&&add+sufmx[i]+2<=mx)++cur,add+=2;
		else cur+=s[i]=='1'?1:-1;
		mi=min(mi,cur);
	}
	return mx-mi;
}
int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	int cur=0;
	for(int i=1;i<=n;++i)
	{
		cur+=s[i]=='1'?1:-1;
		sufmx[i]=cur;
	}
	for(int i=n-1;i>=0;--i)sufmx[i]=max(sufmx[i+1],sufmx[i]);
	printf("%d",min(work(sufmx[0]),work(sufmx[0]+1)));
	return 0;
}

Measured memory_bytes: 6612
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main(){
    char a[11],b[11],c[11];
    scanf("%s %s %s",&a,&b,&c);

    int al,bl,cl;
    al=strlen(a);
    bl=strlen(b);

    if(a[al-1]==b[0]&&b[bl-1]==c[0]){
        printf("YES");
    }
    else
    {
        printf("NO");
    }

    return 0;
}

Measured memory_bytes: 128
# Code for C - Half and Half
# Use input() to fetch data from STDIN
[a, b, c, x, y] = [int(x) for x in input().split()]

s = []
for i in range(0, 10 ** 5 + 1):
    s.append(i * c * 2 + max(x - i, 0) * a + max(y - i, 0) * b)

print(min(s))


Measured memory_bytes: 7096
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=(0);i<(n);i++)
#define fi first
#define se seoncd
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
 
template<class T> inline void read(T &x){
	int f=0;x=0;char ch=getchar();
	for(;!isdigit(ch);ch=getchar())f|=(ch=='-');
	for(;isdigit(ch);ch=getchar())x=x*10+ch-'0';
	if(f)x=-x;
}

const int N=1055;
int a[N][N];

void solve(int n,int m){
	if(n==1||m==1){
		rep(i,1,(1<<n)-1) rep(j,1,(1<<m))
			a[i][j]=1;
		return;
	}
	solve(n-1,m-1);
	int x=1<<(n-1),y=1<<(m-1);
	rep(i,1,x-1) rep(j,1,y-1)
		a[i+x][j]=a[i][j+y]
       =a[i+x][j+y]=a[i][j];
	rep(i,1,x-1) a[i][y]=a[i+x][y]=1;
	rep(i,1,y-1) a[x][i]=a[x][i+y]=1;
}

int main(){
	int n,m;
	read(n),read(m);
	solve(n,m);
	rep(i,1,(1<<n)-1){
		rep(j,1,(1<<m)-1) putchar('0'+a[i][j]);
		puts("");
	}
	return 0;
}

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

#define int long long

#if defined(__GNUC__)
#define __int32 __int32_t
#endif // __GNUC__

#define itn __int32
#define REP(i, n) for(itn (i) = 0; (i) < (n); (i)++)
#define REP2(i, x, n) for(itn (i) = x; (i) < (n); (i)++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define SORT(x) sort(ALL(x))
#define RSORT(x, T) sort(ALL(x), greater<T>())
#define REVERCE(x) reverce(ALL(x))

#define INT_POW(x, y) [](int a, int b) -> int {int c = a; REP(i, b - 1){c *= a;} return c;}(x, y)
#define INT_POWM(x, y, m) [](int a, int b, int m) -> int {int c = a; REP(i, b - 1){c *= a; c %= m;} return c;}(x, y, m)

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

	int n;

	cin >> n;

	vector<int> a(n);

	REP(i, n) {
		cin >> a[i];
	}

	int l, r;
	l = r = 0;

	int all_value = 0;

	REP(i, n) {
		all_value += a[i];
	}

	int up_hf = 0;
	int i = 0;

	while (up_hf < all_value / 2) {
		up_hf += a[i];
		i++;
	}

	int lw_hf = up_hf - a[i - 1];

	cout << min(abs(lw_hf - (all_value - lw_hf)), abs(up_hf - (all_value - up_hf)));

	return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>

int main(){
    int a1,a2,a3;
    
    scanf("%d %d %d",&a1,&a2,&a3);
    
    if(a1+a2+a3 >=22){
        printf("bust\n");
    }
    
    else{
        printf("win\n");
    }
    
    return 0;
}

Measured memory_bytes: 128
import java.util.*;
import static java.lang.System.*;
import java.io.*;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		char[] str = sc.next().toCharArray();
		int cnt = 0;
		int max = 0;
		for(char c: str) {
			if (c == 'A' || c == 'T' || c == 'G' || c == 'C') {
				cnt++;
				if (cnt > max) max = cnt;
			} else {
				cnt = 0;
			}
		}
		out.println(max);
		
		out.close();
	}
	  private static long gcd(long m, long n) {
		    if(m < n) return gcd(n, m);
		    if(n == 0) return m;
		    return gcd(n, m % n);
		}

static 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 static 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: 23252
import numpy as np

def fLOOR(a,b,x):
    return np.floor(a * x / b) - a * np.floor(x / b)
"""
def fLOOR1(a,b,x):
    return np.floor(a * x / b)

def fLOOR2(a,b,x):
    return np.floor(x / b)
"""
def main():
    a,b,n = map(int, input().split(" "))
    
    """
    for x in range(n):
        x += 1
        val = fLOOR(a,b,x)
        val1 = fLOOR1(a,b,x)
        val2 = fLOOR2(a,b,x)
        print(val)
    """
    if b <= n:
        ans = fLOOR(a,b,b-1)
    else:
        ans = fLOOR(a,b,n)
    print(int(ans))

if __name__ == '__main__':
    main()

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

using namespace std;

int main()
{
    int n;
    cin >> n;
    int a[n][3];
    int dp[n][3];
    for (int i = 0; i < n; i++)
    {
        cin >> a[i][0] >> a[i][1] >> a[i][2];
        dp[i][0] = dp[i][1] = dp[i][2] = 0;
    }
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            if (i == 0)
            {
                dp[i][j] = a[i][j];
            }
            else
            {
                for (int k = 0; k < 3; k++)
                {
                    if (k == j)
                        continue;
                    dp[i][j] = max(dp[i][j], dp[i - 1][k] + a[i][j]);
                }
            }
        }
    }
    int ans = 0;
    ans = max(ans, dp[n - 1][0]);
    ans = max(ans, dp[n - 1][1]);
    ans = max(ans, dp[n - 1][2]);
    cout << ans;
}


Measured memory_bytes: 2560
#include<stdio.h>
#include<stdlib.h>
  
struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL
  
Node root;
  
Node treeMinimum(Node x){
    while (x->left != NIL){
        x = x->left;
        return x;
    }
}
  
Node treeMaximum(Node x){
    while (x->right != NIL){
        x = x->right;
        return x;
    }
}
  
Node treeSearch(Node x, int k){
  if(x==NIL || k==x->key){
    return x;
  }
  if(k<x->key){
    return treeSearch(x->left,k);
  }
  else{
    return treeSearch(x->right,k);
  }
 
}
  
void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
 
  while(x != NIL){
    y = x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
  }
  z->parent = y;
  if(y == NIL) root = z;
  else{
    if(z->key < y->key) y->left = z;
    else y->right = z;
  }
}
  
void inorder(Node u){
  if(u == NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node u){
  if(u == NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}
  
int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);
  
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    }
    }
  return 0;
}


Measured memory_bytes: 20608
import string

asclst = string.ascii_lowercase
count = [0 for i in range(len(asclst))]
string = ""
while True:
    try:
        string += input().lower()
    except EOFError:
        break


for char in string:
    for i,c in enumerate(asclst):
        if char == c:
            count[i] += 1

for i,ch in enumerate(asclst):
    print(f"{ch} : {count[i]}")


Measured memory_bytes: 6692
#include "bits/stdc++.h"
using namespace std;

const int N=2e5+20;

int n,k,a[N];

int main()
{
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++) scanf("%d",&a[i]);

	sort(a,a+n);
	printf("%lld",k>n?0:accumulate(a,a+n-k,0ll));
}

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

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


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

using namespace std;

int main(int argc, char const *argv[]) {
  std::string s;
  std::cin >> s;
  long long counter = 0;
  stack<char> stack;
  for (auto i : s ) {
    if (stack.size() == 0) stack.push(i);
    else {
      if (stack.top() != i) {
        stack.pop();
        counter += 2;
      }
      else stack.push(i);
    }
  }
  std::cout << counter << '\n';


}


Measured memory_bytes: 512
import java.util.*;

import org.omg.Messaging.SYNC_WITH_TRANSPORT;

public class Main {
    public static void main(String[] args) {
        /*
        n: 5
        S: 1 2 3 4 5 
        q: 3
        T: 3 4 1
        out: 3
        */
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] s = new int[n+1];
        for (int i = 0; i < n; i++) {
            s[i] = sc.nextInt();
        }
        int q = sc.nextInt();
        int ans = 0;
        for (int i = 0; i < q; i++) {
            if(search(sc.nextInt(),n,s))ans++;;
        }
        System.out.println(ans);
    }
    
    static boolean search(int key, int n, int[] s) {
        //iは要素の半分、key以下だったらi-1をさらにその半分、以上だったらn+i/2
        //5 ・・・ 2 
        int left = 0;
        int right = n;
        int mid;
        while (left < right) {
            mid = (int) Math.floor((right + left) / 2.0);
            if (s[mid] == key) {
                return true;
            } else if (key < s[mid]) {
                right = mid;
            } else {
                left = mid + 1;
            }
        }
        return false;
    }
}


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

using namespace std;

typedef long long ll;

int N, M, Q;
int a[50], b[50], c[50];
ll d[50];

vector<vector<int>> Alist;

void dfs(int i, int Min, vector<int> outcome) {
	if (i == N) {
		Alist.push_back(outcome);
		return;
	}
	for (int j = Min; j <= M; j++) {
		outcome.push_back(j);
		dfs(i + 1, j, outcome);
		outcome.pop_back();
	}
}

int main() {
	cin >> N >> M >> Q;
	for (int i = 0; i < Q; i++)
		cin >> a[i] >> b[i] >> c[i] >> d[i];

	vector<int> t;
	dfs(0, 1, t);

	ll ans = 0;
	for (int i = 0; i < Alist.size(); i++) {
		ll tmp = 0;
		for (int j = 0; j < Q; j++) {
			if (Alist[i][b[j] - 1] - Alist[i][a[j] - 1] == c[j])tmp += d[j];
		}
		ans = max(ans, tmp);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 9796
import sys
readline = sys.stdin.readline
write = sys.stdout.write
def solve():
    MOD = 10**9 + 7
    N, M, K = map(int, readline().split())
    MOD = 10**9 + 7

    L = N+M+2*K

    fact = [1]*(L+1)
    rfact = [1]*(L+1)
    r = 1
    for i in range(1, L+1):
        fact[i] = r = r * i % MOD
    rfact[L] = r = pow(fact[L], MOD-2, MOD)
    for i in range(L, 0, -1):
        rfact[i-1] = r = r * i % MOD

    def C(n, k):
        return fact[n] * rfact[n-k] * rfact[k] % MOD
    def F(n, k):
        return (fact[n+k] * (n-k+1) % MOD) * (rfact[k] * rfact[n+1] % MOD) % MOD
    ans = 0
    for a in range(K+1):
        b = K-a
        ans += C(N+2*a+M+2*b, N+2*a) * F(N+a, a) * F(M+b, b) % MOD
    ans %= MOD
    write("%d\n" % ans)
solve()



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


int main() {
    int n;
    cin >> n;
    vector<int> vec(n);
    for (int i = 0; i < n; i++) {
        cin >> vec.at(i);
    }

    int count = 1;
    for (int i = 1; i < n; i++) {
        bool flag = true;
        for (int j = 0; j < i; j++) {
            if (vec.at(j) > vec.at(i)) flag = false;
        }

        if (flag) count++;
    }

    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
int x, a, b;

int main()
{
	scanf("%d%d%d", &x, &a, &b);
	int cnt = (x - a)/b;
	int ans = (x - a) - (cnt * b);
	printf("%d\n", ans);
	return 0;
}

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

int main(){
    char a[1];cin >> a;

    if('a' <= a[0] && a[0] <= 'z'){
        cout << 'a' << endl;
    }else{
        cout << 'A' << endl;
    }
    
    

}


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

using namespace std;

const int N = 3003;
int v[N][N];
long long dp[N][N][4];

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

  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 0; i < k; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    v[a][b] = c;
  }

  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      // from top
      dp[i][j][0] = *max_element(dp[i - 1][j], dp[i - 1][j] + 4);
      dp[i][j][1] = *max_element(dp[i - 1][j], dp[i - 1][j] + 4) + v[i][j];
      // from left
      dp[i][j][0] = max(dp[i][j][0], dp[i][j - 1][0]);
      for (int c = 1; c <= 3; c++) {
        dp[i][j][c] = max(dp[i][j][c], dp[i][j - 1][c]);
        dp[i][j][c] = max(dp[i][j][c], dp[i][j - 1][c - 1] + v[i][j]);
      }
    }
  }

  long long ans = *max_element(dp[n][m], dp[n][m] + 4);
  cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 320260
import sys
from collections import defaultdict


class SegTree:
    """
    今回の問題に特化したセグ木
    """

    def __init__(self, n, s):
        """
        :param n: 文字列長
        :param s: 初期文字列
        """
        n2 = 1 << (n - 1).bit_length()
        self.offset = n2
        self.tree = [None] * n2 + [{} for _ in range(n2)]
        lmd0 = lambda: 0

        for i, c in enumerate(s):
            x = ord(c) - 97
            i += self.offset
            self.tree[i][x] = 1
        for i in range(self.offset - 1, 0, -1):
            sti = self.tree[i] = defaultdict(lmd0, self.tree[i << 1])
            stj = self.tree[(i << 1) + 1]
            for x in stj:
                sti[x] += stj[x]
        # print(*(dict(t) for t in self.tree), sep='\n')

    def update(self, i, x):
        """
        i番目の値をxに変更
        :param i: index(0-indexed)
        :param x: update value
        """
        i += self.offset
        if x in self.tree[i]:
            return
        y, _ = self.tree[i].popitem()
        self.tree[i][x] = 1
        i >>= 1
        while i > 0:
            sti = self.tree[i]
            sti[x] += 1
            if sti[y] == 1:
                del sti[y]
            else:
                sti[y] -= 1
            i >>= 1

    def get_types(self, a, b):
        """
        [a, b)の文字種数を得る
        :param a: index(0-indexed)
        :param b: index(0-indexed)
        """
        result = set()

        l = a + self.offset
        r = b + self.offset
        while l < r:
            if r & 1:
                result.update(self.tree[r - 1].keys())
            if l & 1:
                result.update(self.tree[l].keys())
                l += 1
            l >>= 1
            r >>= 1

        return len(result)


n = int(input())
s = input()
st = SegTree(n, s)
q = int(input())
ans = []
for line in sys.stdin:
    i, j, k = line.rstrip().split()
    if i == '1':
        j = int(j) - 1
        k = ord(k) - 97
        st.update(j, k)
    else:
        l = int(j) - 1
        r = int(k)
        ans.append(st.get_types(l, r))
print('\n'.join(map(str, ans)))


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

typedef long long int ll;
const int mod = 1e9+7;
const ll inf = 1e18;
const double pi = 3.1415926535897932384626;

void solve(){
	//code
	char x;
	cin>>x;
	if(x>=65 and x<=90) cout<<"A";
	else cout<<"a";
}
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	solve();
 	return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <regex>
#include <map>
#include <set>
using namespace std;
int main(){
    int X,A;
    cin >> X >> A;
    
    if(X<A){
        cout << 0 << endl;
    }else{
        cout << 10 << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int n, k;
    cin >> n >> k;
    if (n % k == 0) cout << 0 << endl;
    else cout << 1 << endl;
    return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	ll a, b;
	while(cin>>a>>b, !(a==0 && b==0)){
		cout << min(a, b) << " " << max(a, b) << "\n";
	}
	return 0;
}


Measured memory_bytes: 3096
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String P = sc.next();
		String A = sc.next();
		int result = 0;
		for (int i = 0 ; i < 3 ; i++) {
			if (P.substring(i, i+1).equals(A.substring(i, i+1))) {
				result +=1;
			}
		}
		System.out.println(result);
	}
}

Measured memory_bytes: 22608
#include <bits/stdc++.h>
using namespace std;
#define boost ios::sync_with_stdio(false);cin.tie(nullptr)
#define pi pair<int,int>
#define ff first
#define ss second
#define int long long
	

int32_t main(){
	boost;
	int n,m;
	cin>>n>>m;
	vector<int>g[n+1];
	for(int i=0,u,v;i<m;i++){
		cin>>u>>v;
		g[u].push_back(v);
	}
	int s,d;
	cin>>s>>d;
	queue<pi>q;
	q.push({s,0});
	int v[3][n+1];
	memset(v,0,sizeof v);
	v[0][s] = 1;
	while(!q.empty()) {
		pi u = q.front();
		q.pop();
		if(u.ff == d && u.ss%3 == 0){
			cout<<u.ss/3<<endl;
			return 0;
		}
		int x = u.ss + 1;
		for(int t:g[u.ff]){
			if(v[x%3][t] == 0){
				v[x%3][t] = 1;
				q.push({t,x});
			}
		}
	}
	cout<<-1<<endl;
}



Measured memory_bytes: 11340
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    int n;
    cin>>n;
    vector<int> v(n);
    rep(i,n) cin>>v[i];
    deque<int> di;
    rep(i,n){
        int id = lower_bound(di.begin(),di.end(),v[i]) - di.begin();
        if(id==0) di.push_front(v[i]);
        else di[id-1]=v[i];
    }
    cout<<di.size()<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>

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

using namespace std;

int n, a, b;

int main(){
	cin >> n >> a >> b;
	int s = 0;
	rep(i, n){
		int t;
		cin >> t;
		if(t < a || b <= t){
			++s;
		}
	}
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		int d = scan.nextInt();
		int L = a+b;
		int R = c+d;
		if (L>R) {
			System.out.println("Left");
		}
		if (L<R) {
			System.out.println("Right");
		}
		if (L==R) {
			System.out.println("Balanced");
		}
	}
}


Measured memory_bytes: 22612
#include <iostream>
#include <string>

using namespace std;

pair<int, int> parse(const string& s, int& idx, int lower, int upper){
	int endIdx = s.size();
	if(isdigit(s[idx])){
		int v = s[idx]-'0';
		++idx;
		int l = v;
		int r = (v==0 ? 0 : 10*v+9);
		if(r <= lower || upper <= l){
			endIdx = idx;
		}
		if(isdigit(s[idx])){
			v *= 10;
			v += s[idx]-'0';
			++idx;
			endIdx = min(endIdx, idx);
			++idx;
		} else {
			++idx;
			endIdx = min(endIdx, idx);
		}
		return make_pair(v, endIdx);
	}
	bool isMin = (s[idx] == '_');
	++idx;
	++idx;
	pair<int, int> n1 = parse(s, idx, lower, upper);
	if(isMin) upper = min(upper, n1.first);
	else      lower = max(lower, n1.first);
	if(upper <= lower) endIdx = n1.second;
	while(!isdigit(s[idx]) && s[idx] != '_' && s[idx] != '^') ++idx;
	pair<int, int> n2 = parse(s, idx, lower, upper);
	endIdx = min(endIdx, n2.second);
	if(isMin) return make_pair(min(n1.first, n2.first), endIdx);
	return make_pair(max(n1.first, n2.first), endIdx);
}

int main(){
	int T;
	while(cin >> T){
		while(T--){
			string s; cin >> s;
			int idx = 0;
			pair<int,int> res = parse(s, idx, 0, 99);
			cout << res.first << " " << res.second << endl;
		}
	}
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int INF = 1000000005;
const int MAX = 100005;

class edge {
  public:
  int t, c;

  edge() {}
  edge(int t, int c): t(t), c(c) {}
};

vector<edge> to[MAX];
bool seen[MAX];
int n, d[MAX];

void dfs(int u) {
  seen[u] = true;
  for (edge e: to[u]) {
    if (seen[e.t]) continue;
    d[e.t] = d[u] + e.c;
    dfs(e.t);
  }
}

int solve() {
  rep(i, n) {
    seen[i] = false;
    d[i] = 0;
  }
  dfs(0);
  int idx = 0;
  rep(i, n) {
    if (d[i] > d[idx]) idx = i;
  }

  rep(i, n) {
    seen[i] = false;
    d[i] = 0;
  }
  dfs(idx);
  int ans = 0;
  rep(i, n) ans = max(ans, d[i]);

  return ans;
}

int main() {
  cin >> n;
  int s, t, w;
  rep(i, n-1) {
    cin >> s >> t >> w;
    to[s].push_back(edge(t, w));
    to[t].push_back(edge(s, w));
  }

  cout << solve() << endl;;


  
  return 0;
}


Measured memory_bytes: 12124
#include<bits/stdc++.h>                                                   //---------------------------------------------------------------
                                                                    
# define ll long long   
# define ld long double                                               
# define mod 1000000007                                                   
# define MAX 100005
# define pi 3.141592653589793238                                                                                  //shortcut keys
                                                                                
# define pb push_back                                                                     
# define mp make_pair 
# define all(x) x.begin(),x.end()                                                      
                                                                  
# define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);        //---------------------------------------------------------------                                       
using namespace std;
int main()
{
	int k;
	cin>>k;
	string s;
	cin>>s;
	int n=s.length();
	if(n<=k)cout<<s;
	else{
		string s1=s.substr(0,k);
		string ans="";
		ans=s1+"...";
		cout<<ans<<'\n';
	}
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
 
using namespace std;
 
int main()
{
	int num;
	int ans;
	bool same = true;
	int cnt = 0;
	vector<int> v;
 
	cin >> num;
 
	while (count(v.begin(),v.end(),num)==0) {
		cnt++;
 
		v.push_back(num);
		if (num % 2 == 0) {
			num = num / 2;
		}
		else {
			num = 3 * num + 1;
		}
	}
	cout << cnt+1;
 
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcdEx(ll a, ll b, ll *x, ll *y) {
    if (!a) {*x = 0; *y = 1; return b;}
    ll x1, y1, gcd = gcdEx(b % a, a, &x1, &y1); *x = y1 - (b / a) * x1; *y = x1; return gcd;
}
ll modI(ll b, ll m)      {ll x, y; gcdEx(b, m, &x, &y); return (x % m + m) % m;}
typedef pair<ll, ll>      pii;
typedef vector<ll>         vi;
typedef vector<pii>         vii;
typedef set<ll>            si;
typedef map<string, ll>    msi;
#define all(x) (x).begin(), (x).end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
#define loop(i,b,n)           for(ll i=b;i<n;i++)
#define loopv(i,b,n,a)         for(ll i=b;i<n;i+=a)
#define loopr(i,b,n)           for(ll i=n;i>=0;i--)

#define sum(a)     ( accumulate ((a).begin(), (a).end(), 0ll))
#define mine(a)    (*min_element((a).begin(), (a).end()))
#define maxe(a)    (*max_element((a).begin(), (a).end()))
#define mini(a)    ( min_element((a).begin(), (a).end()) - (a).begin())
#define maxi(a)    ( max_element((a).begin(), (a).end()) - (a).begin())
#define lowb(a, x) ( lower_bound((a).begin(), (a).end(), (x)) - (a).begin())
#define uppb(a, x) ( upper_bound((a).begin(), (a).end(), (x)) - (a).begin())

#define start_routine() ll begtime = clock();
#define end_routine() ll endtime = clock(); \
                      cerr << "\n\n" << "Time elapsed: " << \
                      (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n"; \
                      return 0
#define mp                  make_pair
#define ff                  first
#define ss                  second
#define pb                  push_back
#define MOD                 1000000007
#define modA(a,b)           (((a%MOD)+(b%MOD))%MOD)
#define modS(a,b)           (((((a%MOD)-(b%MOD))%MOD)<0)?(ll)(MOD+((a%MOD)-(b%MOD))%MOD):(ll)(((a%MOD)-(b%MOD))%MOD))
#define modM(a,b)           (ll)((((ll)(a%MOD))*((ll)(b%MOD)))%MOD)
#define modD(a,b)           ((modI(b,MOD)*(a%MOD))%MOD)
ll modP(ll x, ll y)         {
    ll r = 1; x %= MOD; while (y > 0) {
        if (y & 1) {r = (r * x) % MOD;}
        y = y >> 1; x = (x * x) % MOD;
    } return r;
}
ll max(ll a, ll b) {return (a > b ? a : b);}
ll min(ll a, ll b) {return (a < b ? a : b);}
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << '\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " = " << arg1 << " | "; __f(comma + 1, args...);
}
ll gcd( ll a, ll b )
{
    if (b == 0)
    {
        return a;
    }
    else
    {
        return gcd( b, (a % b) );
    }
}
ll lcm (ll a, ll b)
{
    ll ans = (a  / gcd(a, b)) * b;
    return ans;
}

#define test int t;cin >>t;while(t--)
void solve()
{
    ll n;
    ll ans = 0;
    n = 5;
    vector<ll> v(6);

    for (int i = 1; i <= n; i++)
    {
        cin >> v[i];
        if (v[i] == 0) ans = i;
    }

    cout << ans << "\n";
}
int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 3620
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(a) (a).begin(), (a).end()

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;

    double mean = (a + b) / 2.0;

    cout << ceil(mean) << endl;

    return 0;
}


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

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n, m;
	cin >> n >> m;
	vector<int> elevations(n);
	vector<vector<int>> roads(n);
	for(auto &el: elevations) cin >> el;
	for(int i = 0; i < m; ++i) {
		int a, b;
		cin >> a >> b;
		--a;
		--b;
		roads[a].push_back(b);
		roads[b].push_back(a);
	}
	int good = 0;
	for(int i = 0; i < n; ++i) {
		bool is_good = true;
		for(auto it = roads[i].begin(); it != roads[i].end(); ++it) {
			if(elevations[i] <= elevations[*it]) {
				is_good = false;
				break;
			}
		}
		if(is_good) good++;
	}
	cout << good << "\n";
	return 0;
}

Measured memory_bytes: 8748
n,m = map(int, input().split())
a = list()
m = [0 for i in range(m)]
for i in range(n):
    b = list(map(int, input().split()))
    for j in range(b[0]):
        m[b[j+1]-1] += 1
tabemono = 0
for i in m:
    if i == n:
        tabemono += 1
print(tabemono)


Measured memory_bytes: 3060
#include<stdio.h>
int main(void)
{
    int n,m,i,j,flg,b,a[100][100];
	char s[100][100];
	scanf("%d %d",&n,&m);
	for(i=0;i<n;i++){
	    scanf("%s",&s[i]);
	}
	for(i=0;i<n;i++){
		flg=0;
		for(j=0;j<m;j++){
		    if(s[i][j]=='c'){
			    flg=1;
				a[i][j]=0;
				b=1;
			}
			else if(flg==1){
			    a[i][j]=b;
				b++;
			}
			else{
			    a[i][j]=-1;
			}
		}
	}
	for(i=0;i<n;i++){
	    for(j=0;j<m;j++){
		    if(j<m-1) printf("%d ",a[i][j]);
			else printf("%d\n",a[i][j]);
		}
	}
	return 0;
}

Measured memory_bytes: 2736
n = gets
a = { }
i = 1
while c = gets
  n = c.chomp.to_i
  a[i] = n
  i = i + 1
end

pair = 0
a.each do |val, num|
  if num == 0
    # nopairs
  else
    #puts "val #{val}, num: #{num}"
    pair = pair + num / 2
    if num % 2 == 1 && !a[val+1].nil? && a[val+1] != 0
      # pair with next val
      pair = pair + 1
      a[val+1] = a[val+1] - 1
    end
  end
end

puts pair



Measured memory_bytes: 8316
#include <iostream>
#include <cstdio>
#include <bitset>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>

using namespace std;

#define ll long long
#define vec vector
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)

int main()
{
	ll n;
	string s;
	ll count[3] = {0,0,0};

	cin >> s;

	forll(i, 0, 3)
	{
		if (s[i] == 'a')
			count[0]++;
		if (s[i] == 'b')
			count[1]++;
		if (s[i] == 'c')
			count[2]++;
	}
	
	if (count[0]==1 && count[1] == 1 && count[2] == 1)
		cout << "Yes";
	else
		cout << "No";
}

Measured memory_bytes: 256
import os
import sys
from io import BytesIO, IOBase

BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
INF = 10 ** 18
MOD = 10**9+7

from math import gcd

Ri = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()

N = 10**6+1

prime = [True]*(N+1)
n = int(input())
a = Ri()
dic = {}
for i in a:
    dic[i] = dic.get(i, 0)+1
odic = {}
def sieve():
    for i in range(2,N):
        if prime[i]:
            for j in range(i , N,i):
                prime[j] = False
                if j in dic:
                    if i not in odic:
                        odic[i] = 0
                    odic[i]+= dic[j]
sieve()
# print(odic)
flag1,flag2 = True,True
for i in odic:
    if odic[i] >= 2:
        flag1 = False
    if odic[i] == n:
        flag2 = False

if not flag2:
    print("not coprime")
else:
    if flag1:
        print("pairwise coprime")
    else:
        print("setwise coprime")



Measured memory_bytes: 241204