akhauriyash/Code-Regression huggingface dataset:
countPatty :: Int -> Int -> Int
countPatty n x = p
    where (t, p) = burger (prep n) (x, 0)

burger :: [(Int,Int)] -> (Int, Int) -> (Int, Int)
burger _ (0, ac) = (0, ac)
burger ((t, p):st) (x, ac)
    | x >= t      = (x-t, ac + p) 
    | otherwise = (bun.burger st.patty.burger st.bun) (x, ac)

bun :: (Int, Int) -> (Int, Int)
bun (0, ac) = (0, ac)       
bun (x, ac) = (x-1, ac)

patty :: (Int, Int) -> (Int, Int)
patty (0, ac) = (0, ac)
patty (x, ac) = (x-1, ac+1)

prep :: Int -> [(Int, Int)] 
prep 0 = [(1, 1)]
prep m = (2*t+3, 2*p+1):xs
    where
        (t, p) = head xs
        xs = prep (m-1)
    
main :: IO() 
main = do
    line1 <- getLine
    let [stN, stX] = words line1
        n = read stN :: Int
        x = read stX :: Int
    let ans = countPatty n x 
    print ans
    

Measured memory_bytes: 508
/**
 * ?´???°
?´???°??? 1 ??¨????????°??????????????§????????????????????¶??°????´???°??¨?¨?????????????????????°????????????8 ???????´???°???2, 3, 5, 7, 11, 13, 17, 19 ??¨???????????????1 ????´???°??§?????????????????????

n ????????´??°???????????????????????????????????????????´???°?????°???????????????????????°????????????????????????????????????

??\???
??????????????? n ?????????????????????????¶???? n ?????? n ????????´??°????????????????????????

??????
??\???????????????????´???°?????°???????????????????????????????????????

??¶?´?
1 ??? n ??? 10,000
2 ??? ?????????????????´??° ??? 10^8
??\?????? 1
6
2
3
4
5
6
7
??\?????? 1 ??????????????????
4
 */

#include <iostream>
#include <sstream>
#include <complex>

bool isPrime(unsigned int n) {
  switch (n) {
    case 0:
    case 1:
      return false;
    case 2:
      return true;
  }

  if (n % 2 == 0) {
    return false;
  }

  unsigned int Max = (int)sqrt(n);
  for (size_t i = 3; i <= Max; i += 2) {
    if (n % i == 0) {
      return false;
    }
  }
  return true;
}

int main(int argc, char const *argv[]) {
  unsigned short n;
  std::string Param;
  std::istringstream iss;

  while (true) {
    getline(std::cin, Param);
    iss.str(Param);
    iss >> n;
    iss.clear();
    if (n < 1 || n > 10000) {
      std::cout << "Error: 1 <= n <= 10,000" << std::endl;
    } else {
      break;
    }
  }

  size_t i = 0;
  unsigned short primeCount = 0;

  while (i < n) {
    unsigned int m;
    getline(std::cin, Param);
    iss.str(Param);
    iss >> m;
    iss.clear();
    if (m < 2 || m > 100000000) {
      std::cout << "Error: 2 <= n <= 100000000" << std::endl;
    } else {
      i++;
      if (isPrime(m)) {
        primeCount++;
      }
    }
  }
  std::cout << primeCount << std::endl;
    return 0;
}

Measured memory_bytes: 3184
import copy

h,w,k = map(int, input().split())
cij = ['' for i in range(h)]
for i in range(h):
    cij[i] =list(input())
Ans = 0

bb = 2 ** h
list_i = []
for i in range(bb):
    cc = str(bin(i)[2:]).zfill(h)
    dd = [list(cc)]
    list_i = list_i + dd

bbb = 2 ** w
list_j = []
for i in range(bbb):
    ccc = str(bin(i)[2:]).zfill(w)
    ddd = [list(ccc)]
    list_j = list_j + ddd

for i in range(len(list_i)):
    cij2 = copy.copy(cij)
    for i_ in range(len(list_i[i])):
        if list_i[i][i_]=='1':
            cij2[i_] = ['r' for i in range(w)]
    for j in range(len(list_j)):
        cij3 = copy.deepcopy(cij2)
        for j_ in range(h):
            for j__ in range(len(list_j[j])):
                if list_j[j][j__]=='1':
                    cij3[j_][j__] = 'r'
        cij4 = str(cij3)
        if cij4.count('#') == k:
            Ans = Ans + 1
print(Ans)

Measured memory_bytes: 9164
//       Author: Mostafa Mounir Shehab
 
#include <bits/stdc++.h>
using namespace std;
 
#define PI  acos(-1)
#define EPS (1e-10)
#define endl "\n"
#define SZ(v) (int)(v.size())
#define IO ios_base::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL), cerr.tie(NULL);
typedef long long ll;
typedef long double ld;
 

 
ll MOD=1e9 + 7;
ll OO=1e9 + 100;
const int N=1e6 + 2,M=10 + 1;
int lvl[N];


ll n,m,k,T,cnt,SU;
ll a,b,c,d;
ll l,r,mid;
vector<ll> pos,neg,zero;
int val;

ll mul(ll ans,ll val){
	
	val = (val + MOD)%MOD;
	ans = ((ans%MOD) * (val%MOD));
	
	return ans % MOD;
}

ll Solve(){
	ll ans = 1;

	if(k&1){
		if(SZ(pos)){
			ans = mul(ans,pos.back());
			pos.pop_back();
		}else{
			for(int i=0;i<SZ(neg) && k;++i){
				ans = mul(ans,neg[i]);
				--k;
			}
			return ans;
		}
		--k;
	}

	while(k >= 2 && (SZ(pos) >= 2 || SZ(neg) >= 2)){
		
		if(SZ(pos) >= 2 && SZ(neg) >= 2){
			
			ll v1 = pos[SZ(pos)-1] * pos[SZ(pos)-2];
			ll v2 = neg[SZ(neg)-1] * neg[SZ(neg)-2];
			
			if(v1 > v2){
				ans = mul(ans,v1);
				pos.pop_back();
				pos.pop_back();
			}else{
				ans = mul(ans,v2);
				neg.pop_back();
				neg.pop_back();
			}
			
		}else if(SZ(pos) >= 2){
			ll v1 = pos[SZ(pos)-1] * pos[SZ(pos)-2];
			ans = mul(ans,v1);
			pos.pop_back();
			pos.pop_back();
		}else if(SZ(neg) >= 2){
			ll v2 = neg[SZ(neg)-1] * neg[SZ(neg)-2];
			ans = mul(ans,v2);
			neg.pop_back();
			neg.pop_back();
		}
		
		k-=2;
	}
	
	while(k && SZ(pos)){
		ans = mul(ans,pos.back());
		pos.pop_back();
		--k;
	}
	
	for(int i=0;i<SZ(neg) && k;++i){
		ans = mul(ans,neg.back());
		--k;
	}

	
	return ans;
	
}


int main(){
	
	IO
	
	cin>>n>>k;
	for(int i=0;i<n;++i){
		cin>>a;
		if(a >= 0)
			pos.push_back(a);
		else
			neg.push_back(a);
	}
	
	sort(pos.begin(),pos.end());
	sort(neg.rbegin(),neg.rend());
	
	
	
	
	cout<<Solve()<<endl;
	
	
}




Measured memory_bytes: 5488
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()
	m := make(map[int]int)
	for i := 0; i < n; i++ {
		tmp := nextInt()
		m[tmp]++
		if m[tmp] >= 2 {
			fmt.Println("NO")
			return
		}
	}
	fmt.Println("YES")
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}


Measured memory_bytes: 12672
#! /usr/bin/env python3

from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations, combinations_with_replacement

N, K = [int(_) for _ in input().split()]
A = [[int(_) for _ in input().split()] for i in range(K+K)]
A = [A[i] for i in range(K+K) if i % 2 == 1]
a = []
for i in A:
    a += i
print(N - len(list(set(a))))

Measured memory_bytes: 10448
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int a[200005];
vector<vector<int> > edge(200005);
vector<int> arr(200005, inf);
int DP[200005];

void solve(int v) {
  int index;
  int prev;
  index = lower_bound(arr.begin(), arr.end(), a[v]) - arr.begin();
  prev = arr[index];
  arr[index] = a[v];
  DP[v] = lower_bound(arr.begin(), arr.end(), inf) - arr.begin();
  for(int i=0;i<edge[v].size();++i){
    if(DP[edge[v][i]]>0) continue;
    solve(edge[v][i]);
  }
  index = lower_bound(arr.begin(), arr.end(), a[v]) - arr.begin();
  arr[index] = prev;
}

int main() {
  int N;
  cin>>N;
  for(int i=0;i<N;++i) cin>>a[i];
  int u, v;
  for(int i=0;i<N-1;++i){
    cin>>u>>v;
    u--;
    v--;
    edge[u].push_back(v);
    edge[v].push_back(u);
  }
  solve(0);
  for(int i=0;i<N;++i) {
    cout<<DP[i]<<endl;
  }
}


Measured memory_bytes: 30772
# -*- coding: utf-8 -*-
N = int(input())
A = list(map(int, input().split(' ')))

if len([a for a in A if a == 0]) > 0:
    n = sum(map(abs, A))
    print(n)

elif len([a for a in A if a < 0]) % 2 == 0:
    n = sum(map(abs, A))
    print(n)

else:
    A.sort(key=lambda x: abs(x))
    n = sum(map(abs, A[1:]))
    n -= abs(A[0])
    print(n)





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

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int hp = scan.nextInt();
		int attack = scan.nextInt();
		int re = 0;

		do {

			hp -= attack;
			re++;
		}while(hp > 0);

		System.out.println(re);
		scan.close();

	}

}


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

using namespace std;

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

uint64_t p3[100];
uint64_t mod = 1000000007;

map<pair<uint64_t, uint64_t>, uint64_t> memo;

uint64_t solve(uint64_t l, uint64_t r, int b){
  if(l > r) return 0;
  if(l == r) return 1;
  if(l == 0 && r == (1ull << b) - 1){
    return p3[b];
  }
  auto it = memo.find(make_pair(l, r));
  if(it != memo.end()){
    return it->second;
  }
  uint64_t h = 1ull << (b - 1);
  uint64_t ret = 0;
  // 0, 0
  if(l < h){
    ret += solve(l, min(r, h - 1), b - 1);
  }
  // 0, 1
  if(l < h && r >= h){
    ret += solve(l, r - h, b - 1);
  }
  // 1, 1
  if(r >= h){
    ret += solve(max(l, h) - h, r - h, b - 1);
  }
  ret %= mod;
  memo[make_pair(l, r)] = ret;
  return ret;
}

int main(){
  uint64_t l, r;
  cin >> l >> r;
  p3[0] = 1;
  REP(i, 100) if(i > 0){
    p3[i] = p3[i - 1] * 3 % mod;
  }
  uint64_t ret = 0;
  REP(b, 62){
    uint64_t m = 1ull << b;
    uint64_t n = m * 2 - 1;
    if(l <= n && r >= m){
      ret += solve(max(l, m) - m, min(r, n) - m, b);
      ret %= mod;
    }
  }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 256
# ABC142D - Disjoint Set of Common Divisors
from fractions import gcd


def divisors(n: int) -> set:
    div = set()
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            div.add(i), div.add(n // i)
    return sorted(div)


def main():
    A, B = map(int, input().split())
    divs, groups = divisors(gcd(A, B)), set()
    for i in divs[1:]:
        if all(i % x for x in groups):
            groups.add(i)  # coprime to all numbers in "groups"
    ans = len(groups) + 1
    print(ans)


if __name__ == "__main__":
    main()

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

#define mod 1000000007

typedef long long ll;

int N,M,m;
ll sum[300030] = {0};
ll que[300030][2] = {0};
ll F[300030] = {0},R[300003] = {0};
ll dp[3030][3030];
vector<int> QL,QR;

ll con(ll a,ll b)
{
    return F[a] * R[b] % mod * R[a - b] % mod;
}

ll P(ll n,ll s)
{//printf("  %lld %lld\n",n,s);
    if(dp[n][s] != -1)return dp[n][s];
    ll res = 0;
    ll l,r;
    if(n == QR.size() - 1)
    {
        l = QL[n];r = QR[n];
        res = con(r - l + 1,sum[r] - s);
        return res;
    }
    l = QL[n],r = min(QR[n],QL[n + 1] - 1);
    ll mem = sum[QR[n]] - s;
    ll p = 0;
    if(QR[n] < QL[n + 1])p = sum[QL[n + 1] - 1] - sum[QR[n]];

    //printf(" %lld %lld %lld %lld\n",l,r,mem,(r - l + 1) - (QR[n] - l + 1 - mem));
    for(int i = max((ll)0,(r - l + 1) - (QR[n] - l + 1 - mem)); i <= min(mem,r - l + 1); i++)
    {
        res += P(n + 1,s + i + p) * con(r - l + 1,i);
        res %= mod;
    }
    return dp[n][s] = res;
}

ll power(ll a,ll b)
{
    if(b == 0)return 1;
    ll res = power(a * a % mod,b / 2);
    if(b & 1)res = res * a % mod;
    return res;
}

int main()
{
    scanf("%d%d",&N,&M);
    for(int i = 0; i < 3030; i++)for(int j = 0; j < 3030; j++)dp[i][j] = -1;
    F[0] = 1;
    for(int i = 1; i <= 3030; i++)F[i] = F[i - 1] * i % mod;
    for(int i = 0; i <= 3030; i++)R[i] = power(F[i],mod - 2);
    for(int i = 1; i <= N; i++)
    {
        char c;
        scanf(" %c",&c);
        sum[i] = sum[i - 1] + (c == '1');
    }
    for(int i = 0; i < M; i++)
    {
        scanf("%lld%lld",&que[i][0],&que[i][1]);
        if(i != 0)que[i][1] = max(que[i][1],que[i - 1][1]);
    }
    for(int i = 0; i < M; i++)
    {
        if(i == 0)
        {
            QL.push_back(que[i][0]);
            QR.push_back(que[i][1]);
        }
        if(QL[QL.size() - 1] == que[i][0] && QR[QR.size() - 1] < que[i][1])
        {
            QR[QR.size() - 1] = que[i][1];
        }
        else if(QL[QL.size() - 1] < que[i][0] && QR[QR.size() - 1] < que[i][1])
        {
            QL.push_back(que[i][0]);
            QR.push_back(que[i][1]);
        }
    }
    /*
    for(int i = 0; i < QR.size(); i++)
    {
        printf(" %d %d\n",QL[i] ,QR[i]);
    }
    */
    printf("%lld\n",P(0,sum[QL[0] - 1]));
    return 0;
}


Measured memory_bytes: 80256
n, k = map(int, input().split())
num = [0 for _ in range(k)]
ans = 0
for i in range(1, n+1):
    num[i%k] += 1
for a in range(k):
    b = (k - a) % k
    c = (k - a) % k
    if (b + c) % k != 0:
        continue
    ans  += num[a] * num[b] * num[c]
print(ans)

Measured memory_bytes: 4632
#include<stdio.h>
int main()
{
    int n,m,n1,m1,sum;
    scanf("%d%d%d%d",&n,&m,&n1,&m1);
    if(n-m>=0)
    {
        sum=m*n1+(n-m)*m1;
    }
    else
        sum=n*n1;
        printf("%d\n",sum);
    return 0;
}


Measured memory_bytes: 128
#include<iostream>

using namespace std;

int main()
{
  int r,g,b;

  cin >> r >> g >> b;

  int k;

  k = r*100+g*10+b;

  if(k%4 == 0) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
  
}

Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner (System.in);
        int N = sc.nextInt();
        int[] a = new int[N];
        int[] A = new int[N];
        int ans = 0;
        for(int i = 0;i < N;i++){
            a[i] = sc.nextInt();
            A[i] = a[i] - 1;
            ans += A[i];
        }
        System.out.println(ans);
    }
}

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

using namespace std;

#define ll long long
#define ull unsigned long long
#define PI acos(-1.0)
#define eps 1e-12
#define fi first
#define se second
#define MEM(a,b) memset((a),(b),sizeof(a))
#define mod(x) ((x)%MOD)
#define pii pair<int,int>
#define wz cout<<"-----"<<endl;
const int INF_INT = 2147483647;
const ll INF_LL = 9223372036854775807LL;
const ull INF_ULL = 18446744073709551615Ull;
const ll P = 92540646808111039LL;

const ll maxn = 1e3 + 10, MOD = 1e9 + 7;
const int Move[4][2] = {-1,0,1,0,0,1,0,-1};
const int Move_[8][2] = {-1,-1,-1,0,-1,1,0,-1,0,1,1,-1,1,0,1,1};

inline int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}


void init() {

}

char mp[maxn][maxn];
int step[maxn][maxn];
bool vis[maxn][maxn];
int n,m;

bool check(int x,int y) {
    if(x < 0 || y < 0|| x >= n || y >= m || vis[x][y] || mp[x][y] == '#') return false;
    return true;
}

int BFS() {
    queue<pair<int ,int> > q;
    q.push(make_pair(0,0));
    step[0][0] = 1;
    vis[0][0] = true;
    while (!q.empty()) {
        pair<int ,int> t = q.front();
        q.pop();
        for(int i = 0;i < 4;i++) {
            int tox = t.fi + Move[i][0];
            int toy = t.se + Move[i][1];
            if(tox == n - 1 && toy == m - 1) return step[t.fi][t.se] + 1;
            if(check(tox,toy)) {
                vis[tox][toy] = true;
                step[tox][toy] = step[t.fi][t.se] + 1;
                q.push(make_pair(tox,toy));
            }
        }
    }
    return -1;
}


int main(){
//    freopen("C:\\Users\\Administrator\\Desktop\\in.txt","r",stdin);
//    freopen("C:\\Users\\Administrator\\Desktop\\out.txt","w",stdout);
//    ios_base::sync_with_stdio(0);
    init();
	cin>>n>>m;
	int cnt = 0;
	for(int i = 0;i < n;i++)
        for(int j = 0;j < m;j++) {
            cin>>mp[i][j];
            if(mp[i][j] == '#') cnt++;
        }
    int res = BFS();
    if(res == -1) {
        cout<<"-1"<<endl;
    } else {
        cout<<n*m - res - cnt<<endl;
    }
    return 0;
}


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

int gcd(int a, int b) {
  int tmp;
  if (a < b) {
    tmp = b;
    b = a;
    a = tmp;
  }

  int c;
  
  while (b != 0) {
    c = a % b;
    a = b;
    b = c;
  }

  return a;
  
}

int main() {

  int x, y;
  cin >> x >> y;

  cout << gcd(x, y) << endl;
  
  return 0;
}



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

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

  string s;
  cin >> s;

  int n = s.length();
  int ans = MAX;

  for (int i = 0; i < n-2; ++i) {
    string t = s.substr(i, 3);
    int d = stoi(t);

    ans = min(ans, abs(d - 753));
  }

  cout << ans << '\n';

  return (0);
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,A,B;
  cin >> N >> A >> B;
  int ans=0;
  for(int i=1;i<=N;i++){
    int sum=0,t=i;
    while(t>0) {
      sum+=t%10;
      t/=10;
    }
    if(A<=sum && sum<=B) {
      //cout << sum << endl;
      ans+=i;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import numpy as np
import math

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

maenogoukei = a[0]
goukei = a[0]
kaisuu = 0

if goukei == 0:
	kaisuu += 1
	maenogoukei = -1 
	goukei = maenogoukei



for a_i in a[1:]:
	goukei += a_i
	if maenogoukei > 0 and goukei >= 0:
		kaisuu += goukei + 1
		goukei = -1
		maenogoukei = -1
	elif maenogoukei < 0 and goukei <= 0:
		kaisuu += -goukei + 1
		goukei = 1
		maenogoukei = 1
	else:
		maenogoukei += a_i




maenogoukei2 = a[0]
goukei2 = a[0]
kaisuu2 = 0

if goukei2 == 0:
	kaisuu2 += 1
	maenogoukei2 = 1 
	goukei2 = 1
else:
	kaisuu2 += abs(goukei2) + 1
	maenogoukei2 = - int(np.sign(a[0]))
	goukei2 = - int(np.sign(a[0]))


for a_i2 in a[1:]:
	goukei2 += a_i2
	if maenogoukei2 > 0 and goukei2 >= 0:
		kaisuu2 += goukei2 + 1
		goukei2 = -1
		maenogoukei2 = -1
	elif maenogoukei2 < 0 and goukei2 <= 0:
		kaisuu2 += -goukei2 + 1
		goukei2 = 1
		maenogoukei2 = 1
	else:
		maenogoukei2 += a_i2

print( min([kaisuu,kaisuu2]) )

Measured memory_bytes: 23252
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <queue>
#include <set>
#include<deque>
#include <regex>
#include <list> 
#define rep(i,n) for(ll i=0;i<(n); ++i)
#define per(i,n) for(ll i=n-1;i>=0; --i)
#define all(x) (x).begin(),(x).end()
#define _GLIBCXX_DEBUG
using namespace std;
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 long long INF = 1LL << 60;
typedef long long ll;
const ll MOD = 1000000007;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll getDigit(ll n) {
	ll cnt = 0;
	while (n != 0) {
		n /= 10;
		cnt++;
	}
	return cnt;
}
int main() {
	ll n;
	cin >> n;
	string s, t;
	cin >> s >> t;
	bool f = true;
	for (ll k = 0; k < n; k++) {
		f = true;
		for (ll i = 0; i < n-k; i++) {
			if (s[i+k] != t[i]) {
				f = false;
			}
		}
		if (f == true) {
			return cout << n + k << endl,0;
		}
	}
	cout << 2 * n << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n,k;
  int array[105]={0};
  cin>>n>>k;
  for(int i=0;i<k;i++){
    int d;
    cin>>d;
    for(int j=0;j<d;j++){
      int a;
      cin>>a;
      array[a-1]++;
    }
  }
  
  int cnt=0;
  for(int i=0;i<n;i++){
    if(array[i]==0){
      cnt++;
    }
  }
  cout<<cnt<<endl;
  return(0);
}


Measured memory_bytes: 3604
from bisect import *
from collections import *
from fractions import gcd
from math import factorial
from itertools import *
N,A,B,C=map(int,input().split())
L=[int(input()) for i in range(N)]
value=10**10
itelst=[list(permutations(L,i)) for i in range(3,N+1)]
for n in range(N-2):
    for lst in itelst[n]:
        lstsum=sum(lst)
        a=0
        for i1 in range(len(lst)-2):
            a+=lst[i1]
            b=0
            for i2 in range(i1+1,len(lst)-1):
                b+=lst[i2]
                c=lstsum-a-b
                c1,b1,a1=sorted([a,b,c])
                a1=A-a1 if A-a1>0 else a1-A
                b1=B-b1 if B-b1>0 else b1-B
                c1=C-c1 if C-c1>0 else c1-C
                value=min(value, (len(lst)-3)*10 + a1+b1+c1)





print(value)


Measured memory_bytes: 89176
import string

alphabets = string.ascii_uppercase

players = {}
for i in range(3):
    players[alphabets[i]] = [letter for letter in input()]

first_player = 'A'

next_player = first_player
while True:
    current_player = next_player
    current_player_cards = players[current_player]
    if current_player_cards:
        next_player = current_player_cards[0].upper()
        current_player_cards.pop(0)
    else:
        winner = current_player
        print(winner)
        exit()

Measured memory_bytes: 3768
n = int(input())
h = list(map(int, input().split()))
ans = 0
i = 0
while i < n-1:
    k = 0
    while h[i] >= h[i+1]:
        k+=1
        i+=1
        if i >= n-1: break
    if k > ans:
        ans = k
    i+=1
print(ans)

Measured memory_bytes: 63984
#from fractions import gcd
#mod = 10 ** 9 + 7
#N = int(input())
#a = list(map(int,input().split()))
#a,b,c = map(int,input().split())
#ans = [0] * N
#math.ceilで切り上げ
#dp = [[0] * 4 for i in range(3)] #2次元配列初期化
#dp = [[[0] * 2 for i in range(3)] for j in range(5)]
#(ord('A'))でASCII出力 Aは65
import math
import string

def intinput():
    return int(input())

def listintinput():
    return list(map(int,input().split()))

def splitintinput():
    return map(int,input().split())

A,B,C = splitintinput()
if A == B and B!=C:
    print('Yes')
elif B == C and C!=A:
    print('Yes')
elif C == A and A!=B:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 4216
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rrep(i,n) for (int i=(int)(n)-1; i>=0; --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) rep(i, x.size()) cerr << x[i] << (i == x.size() - 1 ? "\n" : " ")
#define all(x) x.begin(),x.end()
#define int long long
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = ((1LL << 30) + (1LL << 29));
const int MOD = 1000000007;

//=============================
int N,M,K;
string S,T;
vector<int> A;
vector<int> B;
int D[30][30];
int t[3][30];
int C;
//=============================
void input()
{
    cin>>N>>C;
    rep(i,C){
        rep(j,C){
            cin>>D[i][j];
        }
    }
    rep(i,N){
        rep(j,N){
            cin>>K;
            --K;
            t[(i+j)%3][K]++;
        }
    }
}
//=============================
void func(){}
//=============================
void solve()
{
    int ans=INF;
    rep(i,C)rep(j,C)if(i!=j)rep(k,C)if(i!=k && j!= k) {
        int tt = 0;
        rep(l,C)tt += D[l][i]*t[0][l];
        rep(l,C)tt += D[l][j]*t[1][l];
        rep(l,C)tt += D[l][k]*t[2][l];
        if(tt<ans)ans=tt;
    }
    cout<<ans<<endl;
}
//=============================
signed main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
const ll MOD2=(ll)998244353;
const ll INF=(ll)1e18+10;
const double PI = 2.0*acos(0);

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dy[]={-1,1,0,0};
int dx[]={0,0,-1,1};

void solve(int ca){
    int a,b,c;
    string s,t;

    cin>>s;

    cout<<((s=="ABC")?"ARC":"ABC")<<endl;

}

//#define MULTI
int main() {
#ifdef MULTI
    int N; cin>>N;
    for (int i = 0; i < N; ++i) {
        solve(i+1);
    }
#else
    solve(0);
#endif
    return 0;
}


Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		final int n = sc.nextInt();

		int n2 = 0;
		final String nStr[] = String.valueOf(n).split("");

		for (final String item : nStr) {
			n2 = n2 + Integer.parseInt(item);
		}

		if (n % n2 == 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}

}


Measured memory_bytes: 21844
#include <stdio.h>
#include <math.h>
int a,i,t;

int main(void) {
  
  scanf("%d",&a);

  int s[a];

  for(i=0;i<a;i++)
 {
   s[i]=i+1;
 } 

 for(i=0;i<a;i++)
 {
  s[i]=log10(s[i]);
 } 

 for(i=0;i<a;i++)
 {
  if(s[i]%2==0)
  {
   t=t+1;
  }
 } 

 

 printf("%d",t);

 

  return 0;
}

Measured memory_bytes: 2776
use std::io;

fn read_line() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim_right().to_owned()
}

fn main() {
    let s = read_line();

    for c in s.chars() {
        print!("{}", if c == ',' {' '} else {c});
    }
}


Measured memory_bytes: 380
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define reprr(i, m, n) for (ll i = m; i < n; i++)
#define inf 2e9
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
using Graph = vector<vector<pair<ll, ll>>>;


int main()
{
    double L; cin >> L;
    printf("%.12lf\n", pow(L / 3, 3));
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    cin>>a>>b;
    if(a>b){
        rep(i,a){
            cout<<b;
        }
    }
    else{
        rep(i,b){
            cout<<a;
        }
    }
    return(0);
}

Measured memory_bytes: 256
a,b,c,d = [int(i) for i in input()]
for i in range(8):
  pattern = []
  for j in [1,2,4]:
    pattern.append("+"if i&j else"-")
  line = "{0}{1}{2}{3}{4}{5}{6}".format(a,pattern[0],b,pattern[1],c,pattern[2],d)
  if eval(line) == 7:
    print(line + "=7")
    break


Measured memory_bytes: 38384
import sys

a, b, c, d = map(int, sys.stdin.readline().split())

def main():
  dy, dx = d - b, c - a
  res = 'U' * dy + 'R' * (dx + 1) + 'D' * (dy + 1) + 'L' * (dx + 1)
  res += 'UL'
  res += 'U' * (dy + 1) + 'R' * (dx + 1) + 'D' * (dy + 1) + 'L' * dx
  print(res) 
if __name__ == '__main__':
  main()

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>

#define f first
#define s second
#define mp make_pair

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

using namespace std;

typedef unsigned int uint;
typedef long long ll;

int main(){
  int n;
  while(cin>>n, n){
    int j[n];
    int r = 32;
    int rr = 0;
    REP(i,n) cin>>j[i];
    while(r > 0){
      r -= (r-1)%5;
      cout << r << endl;
      r -= j[(rr++)%n];
      if(r < 0) r = 0;
      cout << r << endl;
    }
  }
  return 0;
}

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

string S;
int N;

bool pal(int a, int b) {
	for (int i = 0; i < (b - a + 1)/2; i++) {
		if (S[a + i - 1] != S[b - i - 1]) {
			return false;
		}
	}
	return true;
}

int main(){
	cin >> S;
	N = S.length();
	if (pal(1, N) && pal(1, (N - 1)/2) && pal((N + 3)/2, N)) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}

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

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

_10000 = 10000
_5000 = 5000
_1000 = 1000

_sum = 0
ans = [-1, -1, -1]
# for i in range(Y//_10000 + 1):
for i in range(N+1):
    for j in range(N-i+1):
            k = N - i - j
            _sum = (_10000 * i) + (_5000 * j) + (_1000 * k)
            if _sum == Y:
                ans = [i, j, k]
                break

_ans = [str(s) for s in ans]
__ans = ' '.join(_ans)
print(__ans)


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

int q_a(int a) {
	return a / 1000;
}

int main() {
	int a;
	cin >> a;
	if (
		(a/10)%111==0
		||
		(a-q_a(a)*1000)%111==0
		) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (ll i = 0; i < n; i++)
#define IREP(i, n) for (ll i = n - 1; i >= 0; i--)
#define REPEACH(i,k) for(auto& i:k)
#define FOR(a, b) for (ll i = a; i < b + 1; i++)
#define all(v) v.begin(), v.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

const ll INF = 1LL << 60;
template<class T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}
template<class T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}


signed main(){
    string s,t;
    cin >> s >> t;
    vector<vector<int>> dp(s.size()+1,vector<int>(t.size()+1,0));
    REP(i,s.size()){
        REP(j,t.size()){
            dp[i + 1][j + 1] = max(dp[i+1][j],dp[i][j+1]);
            if(s[i]==t[j]){
                dp[i + 1][j + 1] =max(dp[i+1][j+1],dp[i][j]+1);
            }
        }
    }
    string ans="";
    int x=s.size();
    int y=t.size();
    while(dp[x][y]!=0&&x!=0&&y!=0){
        if(dp[x][y]==dp[x][y-1]){
            y--;
        }
        else if(dp[x][y]==dp[x-1][y]){
            x--;
        }
        else{
            ans+=s[x-1];
            x--;
            y--;
        }
    }
    reverse(all(ans));
    cout << ans << endl;
}

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

int main(){
	vector <int> a,b;
	int n,t;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>t;
		a.push_back(t);
		b.push_back(t);
	}
	sort(a.begin(),a.end());
	for(int i=0;i<n;i++){
		if(b[i]==a[n-1]){
			cout<<a[n-2]<<endl;
		}else{
			cout<<a[n-1]<<endl;
		}
	}
	return 0;
}

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

int n, a[10010][10010], z;
bool vis[10010], flag;
bool ok() {
  for (int i = 1; i <= n; ++i)
    if (a[i][0] != n) return 0;
  return 1;
}

int main() {
  // ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n - 1; ++j) cin >> a[i][j];
    a[i][0] = 1;
  }
  while (1) {
    if (ok()) {
      printf("%d\n", z);
      return 0;
    }
    flag = 0;
    z++;
    memset(vis, 0, sizeof vis);
    for (int i = 1; i <= n; ++i) {
      if (vis[i] || a[i][0] == n) continue;
      int x = a[i][a[i][0]];
      if (!vis[i] && !vis[x] && a[x][a[x][0]] == i) {
        ++a[i][0];
        ++a[x][0];
        vis[i] = vis[x] = 1;
        flag = 1;
      }
    }
    if (!flag) {
      printf("-1\n");
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 39552
n,y = map(int,input().split())
ans = [-1,-1,-1]
cnt = 0

for i in range(n+1):
    if cnt == 1:
        break
        
    for j in range(n-i+1):
        k = n-i-j
        
        if i*10000 + j*5000 + k*1000 == y:
            ans = [i,j,k]
            cnt += 1
            break
                
print(*ans,sep=" ")

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <cstdio>
#define LL long long
#define pb push_back
#define mp make_pair
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
#define F first
#define S second
using namespace std;
typedef pair<int,int>pii;
int h,w,a,b;
int main(){
	cin>>h>>w;
	cin>>a>>b;
	int era=a*w+b*h-a*b;
	cout<<h*w-era<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;

int N;
set<int> A;
// vector<int> A;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N;
  for (int i = 0; i < N; i++) {
    int tmp;
    cin >> tmp;
    if (A.find(tmp) != A.end()) {
      cout << "NO" << endl;
      return 0;
    }
    A.insert(tmp);
  }

  cout << "YES" << endl;
  return 0;
}


Measured memory_bytes: 9600
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq 
from itertools import *
import math
import random
import re
import string
import sys

N = int(input())
As = list(map(int, input().split()))
Bs = list(map(int, input().split()))


def solve(N, As, Bs):
    A_sum = sum(As)
    B_sum = sum(Bs)
    if A_sum < B_sum:
        return -1
    margin = A_sum - B_sum
    
    ans = 0
    need = 0
    extra = []
    for a, b in zip(As, Bs):
        if b > a:
            need += b - a
            ans += 1
        elif a > b:
            extra.append(a - b)
    extra.sort()
    extra.reverse()
    i = 0
    while need > 0:
        need -= extra[i]
        i += 1
        ans += 1
    return ans

print(solve(N, As, Bs))    





Measured memory_bytes: 22260
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,string>;
using Map = map<string,ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;

// a^n mod を計算する
//ただしmとaが互いにその時のみ
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;
}

int main(){
ll N;
cin >> N;
ll K;
cin >> K;
ll ans=0;
ll MOD=1000000007;
vector<ll> howmany(K+1,0);
for(ll i=K;i>=1;i--){
  ll k=K/i;
  ll sum=modpow(k,N,MOD);
  for(ll j=2;j*i<=K;j++){
    sum-=howmany[i*j];
    sum%=MOD;
  ;}
  howmany[i]=sum;

;}
for(ll i=1;i<=K;i++){
  ans+=howmany[i]*i%MOD;
  ans%=MOD;
;}
cout<<ans<<endl;
return 0;
}


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

int main()
{
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  if (a[n/2] == a[n/2-1]) cout << 0 << endl;
  else cout << a[n/2] - a[n/2-1] << endl;
  
  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mypair;

int main(){
double a,b;
cin>>a>>b;
double ans,ans2,ans3;
ans= (a+b)/2;
ans2=ans-180;
ans3=ans+180;
double d =abs(ans-a);
if(d>min(abs(ans2-a),abs(ans2-b))){
d = min(abs(ans2-a),abs(ans2-b));
ans = ans2;
}
if(d>min(abs(ans3-a),abs(ans3-b))){
d = min(abs(ans3-a),abs(ans3-b));
ans = ans3;
}
if(ans>=360){
	ans-=360;
}
if(ans<0){
ans+=360;
}
cout<<fixed<<ans<<endl;
	return 0;
}



Measured memory_bytes: 3288
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  ll a,v,b,w,t;
  cin>>a>>v>>b>>w>>t;
 if(abs(b-a)<=(v-w)*t)
    cout<<"YES"<<endl;
  else
    cout<<"NO"<<endl;
}


Measured memory_bytes: 3624
n, m = map( int, input().split() )
edge_list = []
for _ in range( m ):
    a_i, b_i, c_i = map( int, input().split() )
    edge_list.append( ( a_i - 1, b_i - 1, - c_i ) )

INF = 10 ** 15
cost = [ INF ] * n
cost[ 0 ] = 0

NegativeLoopExist = False
for i in range( n ):
    for j in range( m ):
        a, b, c = edge_list[ j ]
        if cost[ a ] != INF and cost[ b ] > cost[ a ] + c:
            cost[ b ] = cost[ a ] + c
            if i == n - 1 and b == n - 1 :
                NegativeLoopExist = True

if NegativeLoopExist:
    print( "inf" )
else:
    print( - cost[ n - 1 ] )

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  string s;
  cin>>s;
  ll c[256]={},n=s.size(),ans=1;
  for(ll i=0;i<n;i++){
    c[s[i]]++;
    ans+=i+1-c[s[i]];
  }
  cout<<ans<<endl;
  return 0;
}

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

signed main(){
	int n;
	cin>>n;
	int v[n];
	r(i,n)cin>>v[i];
	int q;
	cin>>q;
	while(q--){
		int w,e,re;
		cin>>w>>e>>re;
		rotate(v+w,v+e,v+re);
	}
	r(i,n){
		if(i)cout<<' ';
		cout<<v[i];
	}
	cout<<endl;
}


Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;

const ll mod = 1e9+7;
struct mint {
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vec<mint> cnt0(61),cnt1(61);
    vec<ll> A(N);
    for(int i=0;i<N;i++){
        ll a;
        cin >> a;
        A[i] = a;
        for(int j=0;j<60;j++){
            ((a&(1LL<<j))? cnt1[j]:cnt0[j]) += 1;
        }
    }
    mint ans = 0;
    for(int i=0;i<60;i++) ans += cnt0[i]*cnt1[i]*(1LL<<i);
    cout << ans.x << endl;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  
  if (abs(N - M) >= 2) {
    cout << 0 << endl;
    return 0;
  }
  
  long x = 1;
  for (int i = 1; i <= N; i++)
    x = (x * i) % 1000000007;
  
  long y = 1;
  for (int j = 1; j <= M; j++)
    y = (y * j) % 1000000007;
  
  long ans;
  if (abs(N - M) == 0)
    ans = (x * y * 2) % 1000000007;
  else // abs(N - M) == 1
    ans = (x * y) % 1000000007;
  cout << ans << endl;
  return 0;
}

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

#define	HASHTABLEMAX	16777216

unsigned short hashTable[HASHTABLEMAX];

void init(void){
	unsigned int i;
	for( i=0; i<HASHTABLEMAX; i++){
		hashTable[i] = 0;
	}
}

unsigned int makehash(char *str){
	unsigned int i;
	unsigned int hash;
	unsigned int code;
	
	i = 0;
	hash = 0;
	code = 0;
	while(str[i] != '\0'){
		hash <<= 2;
		switch(str[i]){
			case 'A':
				code = 0b00;
				break;
			case 'C':
				code = 0b01;
				break;
			case 'G':
				code = 0b10;
				break;
			case 'T':
				code = 0b11;
				break;
			default:
				break;
		}
		hash += code;
		i++;
	}
	return hash;
}

void find(unsigned int hash,unsigned int length){
	unsigned short lengthBit;
	lengthBit = 1 << (length - 1);
	if(hashTable[hash] & lengthBit){
		printf("yes\n");
	}else{
		printf("no\n");
	}
}

void insert(unsigned int hash,unsigned int length){
	unsigned short lengthBit;
	lengthBit = 1 << (length - 1);
	hashTable[hash] = hashTable[hash] | lengthBit;
}

int main(void){
	unsigned int i;
	unsigned int n;
	unsigned int hash;
	unsigned int length;
	char command[7];
	char str[13];
	
	init();
	scanf("%d",&n);
	for( i=0; i<n; i++){
		scanf("%s",command);
		scanf("%s",str);
		length = strlen(str);
		hash = makehash(str);
		//printf("%d\n",hash);
		if(strcmp(command,"find") == 0){
			find(hash,length);
		}else if(strcmp(command,"insert") == 0){
			insert(hash,length);
		}else{
			;
		}
	}
}

Measured memory_bytes: 34500
#include <bits/stdc++.h>
#define ld double
#define ull unsigned long long
#define ll long long
#define pii pair <int, int>
#define iiii pair <int, pii >
#define mp make_pair
#define INF 1000000000
#define MOD 1000000007
#define rep(i, x) for(int (i) = 0; (i) < (x); (i)++)
inline int getint() {
  int x = 0, p = 1; char c = getchar();	
  while (c <= 32) c = getchar();
  if (c == 45) p = -p, c = getchar();
  while (c > 32) x = x * 10 + c - 48, c = getchar();
  return x * p;
}
using namespace std;
//ruogu_alter
const int mod = MOD;
const int N = 1e6 + 5;
int n, fac[N], inv[N];
int f[2][3];
//
inline void reduce(int &x) {
  x += x >> 31 & mod;
}
inline void add(int &x, int y) {
  x += y - mod;
  reduce(x);
}
inline int mul(int x, int y) {
  return 1ll * x * y % mod;
}
inline int modpow(int x, int y) {
  int ans = 1;
  while (y) {
    if (y & 1) ans = mul(ans, x);
    x = mul(x, x);
    y >>= 1;
  }
  return ans;
}
inline int modinv(int x) {
  return modpow(x, mod - 2);
}
void init() {
  fac[0] = 1; 
  for (int i = 1; i < N; i++) fac[i] = mul(fac[i - 1], i);
  inv[N - 1] = modinv(fac[N - 1]);
  for (int i = N - 2; i >= 0; i--) inv[i] = mul(inv[i + 1], i + 1);
}
int c(int x, int y) {
  if (y > x || y < 0) return 0;
  return mul(fac[x], mul(inv[y], inv[x - y]));
}
int main() {
  init(); n = getint();
  int p = 0, q = 1, sum = modinv(mul(n, modpow(3, n)));
  f[p][0] = 1;
  int res = 0;
  for (int i = 1; i <= n; i++) {
    rep(j, 3) {
      rep(k, 3) if(j != k) add(f[q][k], f[p][j]);
      f[p][j] = 0;
    }
    swap(p, q);
    add(res, mul(mul(inv[i], fac[i - 1]), mul(c(n, i), f[p][1])));
  }
  cout << mul(res, sum) << endl;
  return 0;
}


Measured memory_bytes: 8064
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i,a,b) for(ll i=(a);i<(b);i++)
#define all(a)  (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)
//#define INF (1LL<<59)

int main(){
    int a,b;
    cin>>a>>b;
    if(a%3==0 || b%3==0 || (a+b)%3==0 )cout<<"Possible"<<endl;
    else cout<<"Impossible"<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>

using namespace std;

int main() {
    vector<int> a(5);
    for (size_t i=0; i<5; ++i)
        scanf("%d", &a[i]);

    sort(a.begin(), a.end(), greater<int>());

    for (size_t i=0; i<5; ++i)
        printf("%d%c", a[i], i<4? ' ':'\n');

    return 0;
}

Measured memory_bytes: 2820
import sys

def main():
    input = sys.stdin.readline
    H, W, A, B = map(int, input().split())

    ans = []
    for h in range(B):
        row = [0]*A + [1]*(W-A)
        ans.append(row)
    
    for h in range(H-B):
        row = [1]*A + [0]*(W-A)
        ans.append(row)
    
    for a in ans:
        print(''.join(map(str, a)))

if __name__ == '__main__':
    main()

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

using namespace std;
string s, t;
int memo[3001][3001] = {};
int operations[3001][3001];

int dp(int a,int b)
{
    if (a == s.length() || b == t.length())
        return 0;
    if (memo[a][b] != 0)
        return memo[a][b] - 1;
    int x, y, best;
    if (s[a] == t[b])
    {
        operations[a][b] = 2;
        best = 1 + dp(a + 1, b + 1);
        memo[a][b] = best + 1;
        return best;
    }
    else
    {
        x = dp(a + 1, b);
        y = dp(a, b + 1);
        best = max(x, y);
        if (x < y)
            operations[a][b] = 1;
        else
            operations[a][b] = 3;
        memo[a][b] = best + 1;
        return best;
    }
}

int main(void)
{
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
    cin >> s >> t;
    int best, a = 0, b = 0;
    best = dp(0, 0);
    for (int i = 0; i < best;)
    {
        if (operations[a][b] == 2)
        {
            i++;
            cout << s[a];
            a++;
            b++;
        }
        else if (operations[a][b] == 1)
            b++;
        else if (operations[a][b] == 3)
            a++;
    }
    printf("\n");
    
}

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

#define int long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint=vector<int>;
using vvint=vector<vint>;
using pint=pair<int, int>;
using vpint=vector<pint>;
template<typename T> using priority_queue_rev=priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028L;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T1, typename T2> bool chmax(T1 &a, const T2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> bool chmin(T1 &a, const T2 &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int N;
int ok[220000];
vint G[550];
signed main() {
    cin >> N;
    for (int i = 2; i < 500; i++) { ok[i * (i - 1) / 2] = i; }
    if (ok[N] == 0) { fin("No"); }
    cout << "Yes" << endl;
    cout << ok[N] << endl;
    int idx = 1;
    rep(i, ok[N]) {
        for (int j = i + 1; j < ok[N]; j++) {
            G[i].push_back(idx);
            G[j].push_back(idx);
            idx++;
        }
        cout << ok[N] - 1 << " ";
        rep(j, ok[N] - 1) { cout << G[i][j] << " "; }
        cout << endl;
    }
}


Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

int main() {
    ll K;
    cin >> K;
    cout << 50 << endl;
    vector<ll> ret(50);
    for(int i = 0;i < 50;i++) {
        ret.at(i) = 49;
    }
    ll cnt = K / 50;
    for(int i = 0;i < 50;i++) {
        ret.at(i) += cnt;
    }
    cnt = K % 50;
    for(int i = 0;i < 50;i++) {
        if(i < cnt) {
            cout << ret.at(i) + 50 - (cnt - 1) << " ";
        }
        else {
            cout << ret.at(i) - cnt << " ";
        }
    }
    cout << endl;
}

Measured memory_bytes: 256
use proconio::input;

#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars, Usize1};
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::ops::*;

#[derive(Clone, Debug, Default)]
struct Struct;







//#[proconio::fastout]
fn main() {
    input! {
        n: Bytes,
    }
    let len = n.len();
    
    let mut sum = 0;
    for i in 0..len {
        sum += (n[i] - b'0') as usize; 
    }


    if sum % 9 == 0 {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 2320
input = require('fs').readFileSync(process.stdin.fd, 'utf8')
lines = input.split('\n')
line = lines.shift().split(' ')
N = line[0]
K = line[1]
Q = line[2]

a = []
for(i = 0; i < N; i++) {
    a[i] = K - Q
}

for(i = 0; i < Q; i++) {
    a[lines[i]-1]++
}

for(i = 0; i < N; i++) {
    console.log(a[i] > 0 ? 'Yes' : 'No')
}


Measured memory_bytes: 29316
#include<stdio.h>
int main() {
    long a, b, r;
    scanf("%ld %ld", &a, &b);
    long g = a * b;

   
    if (a < b) {
        long tmp = a;
        a = b;
        b = tmp;
    }

    
    r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }

    printf("%ld\n", g / b);
    return 0;
}

Measured memory_bytes: 128