akhauriyash/Code-Regression huggingface dataset:
#d

        
#     import sys
#     input = sys.stdin.readline

n,m,k = map(int,input().split())

friends_pair=[]
friend=[[] for _ in range(n)]
for i in range(m):
    a,b = map(int,input().split())
    a-=1
    b-=1
    friends_pair.append((a,b))
    friend[a].append(b)
    friend[b].append(a) 
        
    
block=[]
for i in range(k):
    a,b = map(int,input().split())
    block.append((a-1,b-1))

from collections import deque
clusters=[]
visited=[0]*n
list_cluster=[0]*n
i_c=0
# while sum(visited)<n:
#     for i in range(n):
#         if visited[i]==0:
#             start=i
#             break
for i in range(n):
    if visited[i]==0:
        start=i
    else:
        continue

    cluster =[start]
    q=deque([(start,togo) for togo in friend[start]]) #スタート地点から行ける場所を列挙
    visited[start]=1
    list_cluster[start]=i_c
    for togo in friend[start]:
        visited[togo]=1
        cluster.append(togo)
        list_cluster[togo]=i_c
    while q:
        parent,x = q.popleft()
        for y in friend[x]:
            if y == parent:#親ノードを飛ばし
                continue
            if visited[y]==0:
                q.append((x,y))#子ノードを追加
                visited[y]=1
                cluster.append(y)
                list_cluster[y]=i_c
#        print(parent,x,q)
    clusters.append(cluster)
    i_c+=1

ans = [len(clusters[list_cluster[i]])-1 for i in range(n)  ]
for f0,f1 in friends_pair:
    if list_cluster[f0] ==  list_cluster[f1]:
        ans[f0]-=1
        ans[f1]-=1
for b0,b1 in block:
    if list_cluster[b0] ==  list_cluster[b1]:
        ans[b0]-=1
        ans[b1]-=1
print(*ans)


Measured memory_bytes: 103584
#include <bits/stdc++.h>
#define int long long
using namespace std;
int N,M,C,B[25]={},A,c=0;
signed main(){
  cin >> N >> M >> C;
  for(int i=0;i<M;i++){
    cin >> B[i];
  }
  for(int i=0;i<N;i++){
    int num=C;
    for(int i=0;i<M;i++){
      cin >> A;
      num+=A*B[i];
    }
    if(num>0) c++;
  }
  cout << c << endl;
  return 0;
}


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

#define cMaxLimit 250

typedef struct {
	int key;
	int parent;
	int leftChild;
	int rightChild;
}Node;

void print(Node node[], int maxNum) {
	for (int i = 1; i <= maxNum; i++) {
		cout << "node " << i << ": ";
		cout << "key = " << node[i].key << ", ";
		if (node[i].parent != -1) {
			cout << "parent key = " << node[i].parent << ", ";
		}
		if (node[i].leftChild != -1) {
			cout << "left key = " << node[i].leftChild << ", ";
		}
		if (node[i].rightChild != -1) {
			cout << "right key = " << node[i].rightChild << ", ";
		}
		cout << endl;
	}
}

int main() {
	int nodeMaxNum;
	Node node[cMaxLimit+1];//????????????????????????1-???????????????????????????
	cin >> nodeMaxNum;

	for (int i = 1; i <= nodeMaxNum; i++) {
		int key; cin >> key;
		node[i].key = key;
		node[i].leftChild = -1;
		node[i].rightChild = -1;
		node[i].parent = -1;
	}
	for (int i = 1; i <= nodeMaxNum; i++) {
		cout << "node " << i << ": ";
		cout << "key = " << node[i].key << ", ";
		if (i/2 >= 1) {
			cout << "parent key = " << node[i/2].key << ", ";
		}
		if (i*2 <= nodeMaxNum) {
			cout << "left key = " << node[i * 2].key << ", ";
		}
		if (i*2+1 <= nodeMaxNum) {
			cout << "right key = " << node[i * 2 + 1].key << ", ";
		}
		cout << endl;
	}
	//for (int i = 1; i <= nodeMaxNum; i++) {
	//	if (i / 2 >= 1) {
	//		node[i].parent = node[i / 2].key;
	//	}
	//	if (i * 2 <= nodeMaxNum) {
	//		node[i].leftChild = node[i * 2].key;
	//	}
	//	if (i * 2 + 1 <= nodeMaxNum) {
	//		node[i].rightChild = node[i * 2 + 1].key;
	//	}
	//}

//	print(node, nodeMaxNum);

	return 0;
}

Measured memory_bytes: 3048
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	private static final Map<String, Integer> map = new HashMap<>();
	static {
		map.put("SAT", 1);
		map.put("FRI", 2);
		map.put("THU", 3);
		map.put("WED", 4);
		map.put("TUE", 5);
		map.put("MON", 6);
		map.put("SUN", 7);
	}

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			System.out.println(map.get(scanner.next()));
		}
	}
}


Measured memory_bytes: 21972
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b;
    cin>>a>>b;
    int c=0;
    if(a>b){
        for(c=0;c<a;c++)cout<<b;
    }
    else{
        for(c=0;c<b;c++)cout<<a;
    }
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int l, r, d;
	cin >> l >> r >> d;
	if ( l > r)
	{
		cout << 0;
		return 0;
	}
	else
	{
		int num = 0;
		for (int i = l;i <= r;i++)
		{
			if (i % d == 0) { num++; }
		}
		cout << num;
		return 0;
	}
	return 0;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
//#include<fstream>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
#define endl '\n'
#define pb push_back
#define fi first
#define se second
typedef long long ll;
#define double long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define all(con) con.begin(),con.end()
#define w(x) int x; cin>>x; while(x--)
const ll infl=0x3f3f3f3f3f3f3f3fLL;
const int infi=0x3f3f3f3f;
//const int mod=998244353;
const int mod=1000000007;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

/*ofstream fout("bcount.out");
ifstream fin("bcount.in");*/

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    cout<<fixed<<setprecision(8);
    char ch;
    cin>>ch;
    if(isupper(ch))
        cout<<"A"<<endl;
    else
        cout<<"a"<<endl;
    return 0;
}

Measured memory_bytes: 3556
import sys

N=int(input())
n=N
while n%2==0:
    n//=2
if n==1:
    print("No")
    sys.exit()

m=0
while True:
    m+=1
    if 2**m>N:
        m-=1
        break

ans=[]
if N%2==0:
    ans.append([N,2**m])
    ans.append([2*N,(N-2**m+1+N)])

ans.append([N+1,3])
for i in range(1,(N-1)//2+1):
    num=2*i
    ans.append([1,num])
    ans.append([num,num+1])
    ans.append([1,N+num+1])
    ans.append([N+num+1,N+num])
    
print("Yes")
for u in ans:
    print(*u)

Measured memory_bytes: 71236
#include<cstdio>
#include<string>
#include<iostream>
using namespace std;
string s;int n;
int main()
{
	cin>>s;
	n=s.length();
	for(int i=0;i<n;++i)
	  if(s[i]=='?')printf("D");
	  else printf("%c",s[i]);
}

Measured memory_bytes: 3764
import java.io.IOException;
import java.util.Arrays;

public class Main {
	/**
	 * @param args
	 */
	public	static	int[]	c = new int[8*2];
	public	static	int[]	d = new int[8*1001];

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		int	m = 0;

		while((m = parseNum()) != 0) {
			solve(m);
		}
	}

	private static void solve(int m) {
		int	g = 0;

		Arrays.fill(c, 0);
		for (int i = 1; i <= m; i++) {
			c[i*2+0] = parseNum();
			c[i*2+1] = parseNum();
		}

		Arrays.fill(d, 0);
		d[0] = 1;
		for (int i = 1; i <= m; i++) {
			for (int j = 0; j <= c[i*2+1]; j++) {
				for (int k = 1000-c[i*2+0]*j; k >= 0; k--) {
					d[i*1001+k+c[i*2+0]*j] += d[(i-1)*1001+k];
				}
			}
		}

		g = parseNum();
		for (int i = 0; i < g; i++) {
			System.out.println(d[m*1001+parseNum()]);
		}
	}

	private static int parseNum() {
		try {
			int	buf = 0;
			int	num = 0;
			int	mns = 0;
			int	skp = 1;

			// -,0〜9以外は読み飛ばす
			while (true) {
				buf = System.in.read();
				if (buf == '-') {
					mns = 1;
					skp = 0;
				} else if (buf >= '0' && buf <= '9') {
					num = num * 10 + (buf - '0');
					skp = 0;
				} else if ((skp == 0 || buf == -1) && buf != '.') {
					return (mns == 0)?num:num*(-1);
				}
			}
		} catch (IOException e) {}
		return -1;
	}
}

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

int main() {
    int n;
    cin >> n;
    vector<ll> a(n+1);
    vector<ll> b(n);
    rep(i,n+1) cin >> a[i];
    rep(i,n) cin >> b[i];
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] >= b[i]) {
            ans += b[i];
        }
        else {
            ans += a[i];
            b[i] -= a[i];
            if (a[i+1] >= b[i]) {
                ans += b[i];
                a[i+1] -= b[i];
            }
            else {
                ans += a[i+1];
                a[i+1] = 0;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

int n, m;
vector<set <int>> likes;

int main() {
	cin >> n >> m;
	likes = vector<set <int>> (n);
	for(int i = 0; i < n; i++){
		int c;
		cin >> c;
		for(int j = 0; j < c; j++){
			int a;
			cin >> a;
			likes[i].insert(a);
//			cerr << a << " ";
		}
//		cerr << "\n";
	}
	int res = 0;
	for(int i = 1; i <= m; i++){
		bool t = true;
		for(int j = 0; j < n; j++){
			if(!(likes[j].count(i))){
				t = false;
				break;
			}
		}
		if(t) res++;
	}
	cout << res << "\n";
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  multiset <int> s;
  for(int i=0,x;i<(1<<n);i++)
  {
      cin>>x;
      s.insert(-x);
  }
  vector <int> v;
  v.push_back(*s.begin());
  s.erase(s.begin());
  for(int i=0;i<n;i++)
  {
      vector <int> tmp;
        for(int j=0;j<v.size();j++)
        {
            auto idx = s.upper_bound(v[j]);
            if(idx==s.end())
            {
                cout<<"No\n";
                return 0;
            }
            tmp.push_back((*idx));
            s.erase(idx);
        }
        for(int j=0;j<tmp.size();j++)
            v.push_back(tmp[j]);
        sort(v.begin(),v.end());
  }
  cout<<"Yes\n";
  return 0;
}


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

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

    int x;
    cin >> x;

    int fiveoo, five, ans;
    fiveoo = x/500;
    five = (x%500) / 5;
    ans = 1000*fiveoo + 5*five;
    cout << ans << endl;

    return 0;
}

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

#define MAX 1000

void initialize();
int isEmpty();
int isFull();
void  push(int x);
int pop();

int top;
int S[1000];

int main(){
  int x,n1,n2;
  char s[100];

  while( scanf("%s", s) != EOF ){

    if ( s[0] == '+' ){
      n1 = pop();
      n2 = pop();
      push(n1 + n2);
    } else if ( s[0] == '-' ){
      n1 = pop();
      n2 = pop();
      push(n2 - n1);
    } else if ( s[0] == '*' ){
      n1 = pop();
      n2 = pop();
      push(n1 * n2);
    } else {
      x = atoi(s);
      push(x);
    }
  }
  printf("%d\n",pop());
  return 0;
}

void initialize(){
  top = 0;
}

int isEmpty(){
  return top == 0;
}

int isFull(){
  return top >= MAX - 1;
}

void  push(int x){
  if (isFull()) fprintf(stderr,"overflow\n");
  top++;
  S[top] = x;
}

int pop(){
  if (isEmpty()) fprintf(stderr,"underflow\n");
  top--;
  return S[top+1];
}

Measured memory_bytes: 548
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class QuestionC
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数の入力
            var nm = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();

            var abs = new int[nm[1]][];

            var teikiFrom1 = new List<int>();
            var teikiToN = new List<int>();

            var ikeru = new Dictionary<int, int>();

            var flag = false;

            for (int i = 0; i < nm[1]; i++) {
                // 整数配列の入力
                abs[i] = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
                if(abs[i][0] == 1) {
                    if (ikeru.ContainsKey(abs[i][1])) {
                        flag = true;
                    } else { 
                        ikeru.Add(abs[i][1], 0);
                    }
                }

                if(abs[i][1] == nm[0]) {
                    if (ikeru.ContainsKey(abs[i][0])) {
                        flag = true;
                    } else {
                        ikeru.Add(abs[i][0], 0);
                    }
                }
            }

            if (flag) {
                Console.WriteLine("POSSIBLE");
            } else {
                Console.WriteLine("IMPOSSIBLE");
            }

            Console.Out.Flush();
        }
    }
}


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

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

  int x = 0;
  char c;
  for (int i = 0; i < n; i++) {
    cin >> c;
    if (c == 'Y') x++;
  }

  if (x == 0)
    cout << "Three" << endl;
  else
    cout << "Four" << endl;
}

Measured memory_bytes: 256
from itertools import product

S = list(input())

states = list(product([i for i in range(2)], repeat=len(S)-1))

res = 0

#print(states)

for state in states:
    formula = S[0]
    for i in range(len(state)):
        if state[i] == 0:
            formula += S[i+1]
        else:
            formula += '+' + S[i+1]

    #print(formula)
    res += eval(formula)

print(res)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define Mod 1000000007
#define ll long long
#define dd double
#define pb push_back
#define ff first
#define ss second
#define Mp make_pair
#define INF 999999999999999999
#define NN (ll)(1e6+5)
int mod(string s,int a) 
{ 
    int ans=0; 
    for (int i=0;i<s.length();i++) 
         ans=(ans*10+(int)s[i]-'0')%a; 
    return ans; 
}
ll min(ll x,ll y){if(x<y) return x;return y;}
ll max(ll x,ll y){if(x>y) return x;return y;}
ll power(ll x,unsigned ll y) 
{ 
    if (y==0) 
        return 1; 
    else if (y%2==0) 
        return power(x,y/2)*power(x,y/2); 
    else
        return x*power(x,y/2)*power(x,y/2); 
}
ll hcf(ll a,ll b) 
{ 
    if(b==0) 
        return a; 
    return hcf(b,a%b);  
}
int main()
{
   fio;
   /*#ifndef ONLINE_JUDGE 
    	freopen("input.txt", "r", stdin); 
    	freopen("output.txt", "w", stdout); 
    	freopen("error.txt", "w", stderr); 
   #endif*/
   ll TT=1;
   //cin>>TT;
   while(TT--)
   {    
      ll n,k,i;
      cin>>n>>k;
      vector <ll> v(n+5),ans;
      for(i=1;i<=n;i++)
      {
          cin>>v[i];
      } 
      ans.pb(0);
      set <ll> s;
      ll x=1,y,z,ind;
      while(1)
      {
          y=v[x];
          if(s.find(y)!=s.end())
          {
              z=y;
              break;
          }
          ans.pb(y);
          s.insert(y);
          x=y;
      }
      for(i=0;i<ans.size();i++)
       if(ans[i]==z)
       {
           ind=i;
           break;
       }
      //for(auto u:ans)
       //cout<<u<<" ";
      if(k<ans.size()) 
       cout<<ans[k]<<"\n";
      else
       {
           k-=ind-1;
           x=k%(ans.size()-ind);
           if(x==0)
            x+=ans.size()-ind;
           cout<<ans[x+ind-1]<<"\n"; 
       } 
   }
}

Measured memory_bytes: 15492
#include<iostream>
#include<string>
using namespace std;
int main()
{

    int n,i,j;
    string st;
    cin >> st;
    if(st[1]==st[2] && (st[0]==st[1] || st[2]==st[3]))
        cout << "Yes";
    else
        cout << "No";
    cout << "\n";




    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define POWER9 1000000000
#define MOD POWER9+7
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483647
#define INT_MAX 2147483647
#define LL_MIN (LL)-9223372036854775807
#define LL_MAX (LL)9223372036854775807
#define PI 3.14159265359

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << setprecision(9);

	int N;
	cin >> N;
	int so[1001] = {};
	for(int i=1; i<=N; i++){
		int tmp = i;
		for(int j=2; j<=N; j++){
			if(tmp%j == 0){
				tmp /= j;
				so[j]++;
				j--;
			}
		}
	}
	LL ans = 1;
	for(int i=1; i<=N; i++){
		ans *= so[i]+1;
		ans %= MOD;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(){
    int n,a,b;
    while(1){
        int suma=0,i,sumb=0;
        scanf("%d",&n);
        if(n==0)break;
        for(i=0;i<n;i++){
            scanf("%d %d",&a,&b);
            if(a>b){
                suma=suma+a+b;
            }else if(a<b){
                sumb=sumb+a+b;
            }else{
                suma+=a;
                sumb+=b;
            }
        }
        printf("%d %d\n",suma,sumb);
    }
    return 0;
}

Measured memory_bytes: 600
// Sky's the limit :)
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    int T = 1; 
    // cin >> T; 
    while (T--) {
        int n, k;
        cin >> n >> k;

        int ans = min(n % k, k - n % k);
        cout << ans << '\n';
    }
    
    return 0;
}



Measured memory_bytes: 3600
import sys,math
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n,a,b = map(int,readline().split())
h = [int(readline()) for i in range(n)]

def is_ok(arg):
    chk = 0
    for i in h:
      chk += max(0,math.ceil((-arg*b+i)/(a-b)))
    return chk <= arg


def bisect_ok(ng, ok):
    '''
    初期値のng,okを受け取り,is_okを満たす最小(最大)のokを返す
    まずis_okを定義
    ng = 最小の値-1 ok = 最大の値+1 で最小
    最大最小が逆の場合はng ok をひっくり返す
    '''
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(mid):
            ok = mid
        else:
            ng = mid
    return ok

print(bisect_ok(0,10**9))


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

#define ipr pair<int, int>
#define pb push_back
#define ff first
#define ss second
#define fr(i, j, k) for (int i = j; i < k; i++)
#define rf(i, j, k) for (int i = j; i >= k; i--)
#define ll unsigned long long
#define int long long
#define ld long double
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define mp make_pair
#define cnt_ones(x) __builtin_popcountll(x)

#define IOS                           \
    std::ios::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);

const int Maxn = (int)1e5 + 1;
const ld pi = acos(-1);
const int mod = (int)1e9 + 7;
const int inf = (int)1e18;

template <class T>
ostream &operator<<(ostream &out, vector<T> &A) {
    fr(i, 0, (int)A.size()) out << A[i] << " ";
    return out;
}

int32_t main() {
    IOS int Q = 1;
    // cin >> Q;
    while (Q--) {
        int n;  cin>>n;
        vector<int> A(n), B(n);
        fr(i,0,n){
            int x, y;   cin>>x>>y;
            A[i] = x+y;
            B[i] = x-y;
        }
        sort(all(A));   sort(all(B));
        cout << max((A[n-1]-A[0]), (B[n-1]-B[0])) << endl;
    }
    return 0;
}


Measured memory_bytes: 6356
#include<stdio.h>

int A[1000000],n;

int binarySearch(int key){
  int left = 0;
  int right = n;
  int mid;
  while(left < right){
    mid = (left + right) / 2;
    if(key == A[mid])return 1;
    if(key > A[mid])left = mid + 1;
    else if(key < A[mid])right = mid;
  }
  return 0;
}

int main(){
  int i,q,k,sum = 0;

  scanf("%d",&n);
  for(i = 0; i < n; i++){
    scanf("%d",&A[i]);
  }

  scanf("%d",&q);
  for(i = 0; i < q; i++){
    scanf("%d",&k);
    if(binarySearch(k))sum++;
  }
  printf("%d\n",sum);

  return 0;
}

  




Measured memory_bytes: 2088
N, K, Q = map(int, input().split())

X = K-Q

atai = [X for _ in range(N)]

for i in range(Q):
    A = int(input())-1
    atai[A] += 1

for i in range(N):
    if atai[i] <= 0:
        print('No')
    else:
        print('Yes')

Measured memory_bytes: 6608
N=gets.to_i
As=gets.split.map(&:to_i).sort
total = 1
MOD=1000000007
if N%2==0
    (0...N/2).each{|i|
        if As[i*2]!=i*2+1 || As[i*2+1]!=i*2+1
            puts 0
            exit
        end
        total = total * 2 % MOD
    }
else
    if As[0] != 0
        puts 0
        exit
    end
    (0...N/2).each{|i|
        if As[1+i*2]!=i*2+2 || As[1+i*2+1]!=i*2+2
            puts 0
            exit
        end 
        total = total * 2 % MOD
    }
end
puts total


Measured memory_bytes: 9736
r1, c1, r2, c2 = map(int, input().split())
mod = 10 ** 9 + 7

n = r2 + c2 + 10

fac = [0] * n
inv = [0] * n
finv = [0] * n
fac[0] = fac[1] = 1
finv[0] = finv[1] = 1
inv[1] = 1

for i in range(2, n) :
  fac[i] = fac[i-1] * i % mod
  inv[i] = mod - inv[mod%i] * (mod // i) % mod
  finv[i] = finv[i-1] * inv[i] % mod

def comb(n, r) :
  return fac[n] * finv[n-r] % mod * finv[r] % mod

def g(x, y) :
  return comb(x + y, y)

ret = g(r2+1, c2+1) - g(r2+1, c1) - g(r1, c2+1) + g(r1, c1)
ret %= mod

print(ret)

Measured memory_bytes: 87276
#include <iostream>

using namespace std;

class B {
	int a, b, c;
	int k;
public:
	void solve()
	{
		int maximum{ a };
		if (maximum < b) maximum = b;
		if (maximum < c) maximum = c;

		int ans{ a + b + c - maximum };
		ans += (maximum <<= k);
		
		cout << ans << endl;
	}

	B() { cin >> a >> b >> c >> k; }
};


int main()
{
	B solution;
	solution.solve();

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<cstdlib>
using namespace std;


struct Node {
	int key;
	Node *right, *left, *parent;
};

Node *root, *NIL;

void insert(int k) {
	Node *y = NIL;
	Node *x = root;
	Node *z;


	z = (Node *)malloc(sizeof(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;
	string com;

	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> com;
		if (com == "insert") {
			scanf("%d", &x);
			insert(x);
		}
		else if (com=="print"){
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");

		}
	}

	return 0;

}


Measured memory_bytes: 26728
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#include <vector>
using namespace std;
typedef long long ll;

//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

using namespace std;
int main(void){

    string s;
    cin >> s;
    ll a[s.length()+1];
    for(ll i=0;i<(ll)s.length()+1;i++){
      a[i] = 0;
    }
    for(ll i=0;i<(ll)s.length();i++){
      if( s[i] == '<'){
        a[i+1] = max(a[i+1], a[i]+1);
      } 
    }
    for(ll i=(ll)s.length();i>=0;i--){
      if( s[i] == '>'){
        a[i] = max(a[i], a[i+1]+1);
      } 
    }
    ll sum = 0;
    for(ll i=0;i<(ll)s.length()+1;i++){
      sum += a[i];
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 7688
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <string.h>
#include <utility>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>

using namespace std;
typedef long long ll;

#ifndef INT_MAX
#  define INT_MAX std::numeric_limits<int>().max()
#endif
#ifndef INT_MIN
#  define INT_MIN std::numeric_limits<int>().min()
#endif
#define LL_MAX std::numeric_limits<ll>().max()
#define LL_MIN std::numeric_limits<ll>().min()
#define INF LL_MAX

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())

ll H, W;

ll search(ll e1, ll e2) {
    ll ans = 10000000000;
    ll s1, s2, s3, min_s, max_s;
    for(ll i = e1 - 1; i > 0; --i) {
        s1 = (e2 / 2) * (e1 - i);
        s2 = e2 * i;
        s3 = W * H - s1 - s2;
        min_s = min(min(s1, s2), s3);
        max_s = max(max(s1, s2), s3);
        ans = min(ans, abs(max_s - min_s));
        i--;
    }
    return ans;
}

ll kawa(ll e1, ll e2) {
    ll s1 = e1 / 3;
    ll s3 = e1 / 3;
    if(e1 % 3 > 0) {
        s1++;
    }
    s1 *= e2;
    s3 *= e2;
    return abs(s1 - s3);
}

int main()
{
    cin >> H >> W;

    if(H % 3 == 0 || W % 3 == 0) {
        //printf("0\n");
        //return 0;
    }
    ll ans = 10000000000;
    if(H >= 3) {
        ans = min(ans, kawa(H, W));
    }
    if(W >= 3) {
        ans = min(ans, kawa(W, H));
    }
    ans = min(ans, min(search(H, W), search(W, H)));
    printf("%lld\n", ans );
    return 0;
}


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

using namespace std;

int main(){
    int n;
    vector <int> arr;
    cin >> n;
    arr.resize(n);
    vector <int > sorted;
    for (auto &it : arr){
        cin >> it;
        sorted.push_back(it);
    }
    sort(sorted.begin(), sorted.end());
    int i = 0;
    int sol = 0;
    for (auto &it : arr){
        auto pos = lower_bound(sorted.begin(), sorted.end(), it);
        auto pos2 = pos-sorted.begin();
        //cout << pos2 << " ";

        if (pos2 % 2 == 0 and i % 2 == 1)
            sol++;

        i++;
    }
    cout << sol << "\n";
}


Measured memory_bytes: 1276
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int CM = 130000;
char cn[CM + 10], * ci = cn + 10, * owa = cn + CM;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	char c = ci[8];
	ci[8] = 0;
	ll tmp = *(ll*)ci;
	int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci[8] = c;
	ci += (64 - dig >> 3) + 1;

	if (ci - owa > 0) {
		memcpy(cn, owa, 10);
		ci -= CM;
		fread(cn + 10, 1, CM, stdin);
	}
	return tmp;
}

char* di = cn;
const int MAX = 200000;
class shuturyoku_unko {
public:
	char C[MAX * 6 - 100000];
	int K[MAX + 10];
	constexpr shuturyoku_unko() : C(), K() {
		auto di = C + 1;
		C[0] = '0';
		K[1] = 1;
		rep1(i, MAX) {
			int X = i;
			int keta = 0;
			char c[10] = {};
			while (X) {
				*(c + keta) = '0' + X % 10;
				X /= 10;
				keta++;
			}
			for (int j = keta - 1; j >= 0; j--)* di++ = (*(c + j));
			K[i + 1] = K[i] + keta;
		}
	}
} f;
const char z[4] = { '0','0','0','0' };
inline void putint(ll X) {
	int ue = X / 100000;
	if (ue) {
		memcpy(di, f.C + f.K[ue], f.K[ue + 1] - f.K[ue]);
		di += f.K[ue + 1] - f.K[ue];
		int sita = X - ue * 100000ll;
		int k = f.K[sita + 1] - f.K[sita];
		memcpy(di, z, 5 - k);
		memcpy(di + 5 - k, f.C + f.K[sita], k);
		di += 5;
	}
	else {
		memcpy(di, f.C + f.K[X], f.K[X + 1] - f.K[X]);
		di += f.K[X + 1] - f.K[X];
	}
	*di++ = '\n';
}

int B[200001];

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


	fread(ci, 1, CM, stdin);

	int N = getint();
	ll kotae = 1;
	int A[200000];
	rep(i, N) kotae += B[(A[i] = getint())]++;
	int *a = A;
	
	int amari = N % 10800;
	int shou = N / 10800;
	rep(j, shou) {
		rep(k, 10800) putint(kotae - B[*a++]);
		fwrite(cn, 1, di - cn, stdout);
		di = cn;
	}
	rep(k, amari) putint(kotae - B[*a++]);
	fwrite(cn, 1, di - cn, stdout);

	Would you please return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define Rep(i, r, n) for (ll i = r; i < n; i++)
#define debug(x) cout << #x << " = " << (x) << endl;
#define pb push_back
#define MOD 1000000007
//#define MOD 998244353
//define MOD 1000000007000000
#define INF 1000000000000
#define EPS 0.00000000001
typedef long long ll;

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


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

typedef long long int ll;
#define deb(x) cout << #x << " " << x << endl;
#define debtwo(x,y) cout << #x << " " << x << ", " << #y << " " << y << endl;
#define mod 100000007

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  string s, t;
  cin >> s >> t;

  int mc = 0, lc;

  for (int i = 0; i < t.length(); i++) {
    for (int j = i; j <= s.length() - (t.length() - i); j++) {
      lc = 0;
      int x = i, y = j;

      if (t[x] == s[y]) {
        while (x < t.length() && y < s.length()) {
          if (t[x++] == s[y++]) lc++;
        }
      }

      mc = max(mc, lc);
    }
  }
  cout << t.length() - mc;
}

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

#ifdef __linux__
#define getchar getchar_unlocked
#define putchar putchar_unlocked
#endif
template <class Z> Z getint() {
  char c = getchar();
  bool neg = c == '-';
  Z res = neg ? 0 : c - '0';
  while (isdigit(c = getchar())) res = res * 10 + (c - '0');
  return neg ? -res : res;
}
template <class Z> void putint(Z a, char c = '\n') {
  if (a < 0) putchar('-'), a = -a;
  int d[40], i = 0;
  do d[i++] = a % 10; while (a /= 10);
  while (i--) putchar('0' + d[i]);
  putchar(c);
}

template <class T, class Op> struct segtree {
  const Op op;
  const T e;
  const int n;
  vector<T> t;
  segtree(int _n, Op _op, T _e) : op(_op), e(_e), n(_n), t(2 * n, e) {}
  T& operator[](int i) { return t[n + i]; }
  void build() { for (int i = n; i-- > 1; ) t[i] = op(t[2 * i], t[2 * i + 1]); }
  T fold(int l, int r) const {
    T a = e, b = e;
    for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
      if (l & 1) a = op(a, t[l++]);
      if (r & 1) b = op(t[--r], b);
    }
    return op(a, b);
  }
  void set(int i, T a) {
    t[i += n] = a;
    while (i >>= 1) t[i] = op(t[2 * i], t[2 * i + 1]);
  }
};
template <class T, class Op> auto make_segtree(int n, Op op, T e) {
  return segtree<T, Op>(n, op, e);
}

int main() {
  int n = getint<int>();
  int q = getint<int>();
  auto st = make_segtree<pair<int, int>>(n + 1, [](auto l, auto r) -> pair<int, int> {
    return {l.first + r.first, min(l.second, l.first + r.second)};
  }, {0, 0x3f3f3f3f});
  for (int i = 0; i < n; ++i) {
    st[i] = {0, 0};
  }
  st.build();
  while (q--) {
    if (getint<int>() == 0) {
      int l = getint<int>();
      int r = getint<int>() + 1;
      int x = getint<int>();
      st.set(l, {st[l].first + x, st[l].second + x});
      st.set(r, {st[r].first - x, st[r].second - x});
    } else {
      int l = getint<int>();
      int r = getint<int>() + 1;
      putint(st.fold(0, l).first + st.fold(l, r).second);
    }
  }
}


Measured memory_bytes: 4352
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main{

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws IOException{
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        String str=br.readLine();
        String[] t=str.split("\\ ");
        int K=Integer.parseInt(t[0]); int X=Integer.parseInt(t[1]);
        int l=X-K+1;
        int r=X+K-1;
        for(int i=Math.max(-1000000, l);i<=Math.min(1000000,r);i++){
            System.out.print(i+" ");
        }
    }
    
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
#define MAX 114514
#define NIL -1

struct Node {int p,l,r;};    //Node?????????????????????????????????????????????????????±???????????????

Node T[MAX];
int n,D[MAX];

void print(int u){
    int i,c;
    printf("node %d: ",u);
    printf("parent = %d, ",T[u].p);
    printf("depth = %d, ",D[u]);
    if(T[u].p==NIL) printf("root, ");
    else if(T[u].l==NIL) printf("leaf, ");
    else printf("internal node, ");

    printf("[");

    for(i=0,c=T[u].l;c!=NIL;i++,c=T[c].r){
        if(i) printf(", ");
        printf("%d",c);
    }

    printf("]\n");
}

int rec(int u,int p){    //?????°????????±???????±???????
    D[u] = p;
    if(T[u].r != NIL) rec(T[u].r,p);    //???????????????????????±???????¨????
    if(T[u].l != NIL) rec(T[u].l,p+1);  //?????????????????????????????±???+1????¨????
}

int main(){
    int i,k,d,v,tmp,l,r;
    scanf("%d",&n);
    for(i=0;i<n;i++) T[i].p=T[i].l=T[i].r = NIL;
    for(i=0;i<n;i++){
        scanf("%d %d",&v,&d);   //v??????????????????d????¬???°
        for(k=0;k<d;k++){
            scanf("%d",&tmp);
            if(k==0) T[v].l = tmp;
            else T[l].r = tmp;
            l = tmp;
            T[tmp].p = v;
        }
    }

    for(i=0;i<n;i++){   //????????¢???(????????????????????§(??¢???))
        if(T[i].p==NIL) r = i;
    }

    rec(r,0);

    for(i=0;i<n;i++) print(i);

    return 0;
}

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

#define HASH_SIZE 8388617

typedef struct _node {
	int val;
	struct _node *next;
} node;

void push(node **p, int val)
{
	node *w = (node *)malloc(sizeof(node));
	w->val = val;
	w->next = *p;
	*p = w;
}

void terminate(node **p, int n)
{
	int i;
	node *w1, *w2;

	for (i = 0; i < n; i++)
	{
		w1 = p[i];
		while (w1 != NULL)
		{
			w2 = w1->next;
			free(w1);
			w1 = w2;
		}	
	}
}

int getCode(char *s)
{
	int code = 1;
	int i;
	for (i = 0; s[i] != '\0'; i++)
	{
		s[i] = s[i] & 0x06;
		s[i] = s[i] >> 1;
		code = code << 2;
		code = code | s[i];
	}
	return code;
}


int isInclude(node *p, int val)
{
	while (p != NULL)
	{
		if (p->val == val) break;
		p = p->next;
	}
	
	if (p == NULL) return 0;
	return 1;
	
}
int main()
{
	int i, n, key, code;
	char str[13], order[7];
	node **top = (node **)malloc(sizeof(node *) * HASH_SIZE);
	
	for (i = 0; i < HASH_SIZE; i++) top[i] = NULL;

	scanf("%d", &n);
	for (i = 0; i < n; i++)
	{
		scanf("%s%s", order, str);
		code = getCode(str);
		key = code % HASH_SIZE;
		switch (order[0])
		{
		case 'i':
			push(&top[key], code);
			break;
		case 'f':
			if (isInclude(top[key], code)) printf("yes\n");
			else printf("no\n");
			break;
		}
	}

	terminate(top, HASH_SIZE);
	free(top);

	return 0;
}

Measured memory_bytes: 84892
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                           \
  cerr << __LINE__ << ": " << #x << " = {";        \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];        \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  pair<int, long long> AB[N];
  for (int i = 0; i < N; i++) cin >> AB[i].first >> AB[i].second;
  sort(AB, AB + N);
  long long ans = 0;
  priority_queue<long long> pq;
  int j = 0;
  for (int i = min(M, N) - 1; i >= 0; i--) {
    while (j < N && i + AB[j].first <= M) pq.push(AB[j++].second);
    if (!pq.empty()) {
      ans += pq.top();
      pq.pop();
    }
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 5788
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
int main() {
  string s, t;
  cin >> s >> t;
  s += s;
  rep(i,t.size())
  {
    bool f = true;
    rep(j,t.size())
      if (t[j] != s[i + j])
        f = false;
    if (f) {
      cout << "Yes";
      return 0;
    }
  }
  cout << "No";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
const int MOD = 1000000007;

void solve() {
  int n, m, k;
  cin >> n >> m >> k;
  vector<ll> a(n);
  vector<ll> b(m);
  rep(i,n) cin >> a[i];
  rep(i,m) cin >> b[i];
  vector<ll> sumA(n+1);
  vector<ll> sumB(m+1);
  rep(i,n) sumA[i+1] = sumA[i] + a[i];
  rep(i,m) sumB[i+1] = sumB[i] + b[i];
  int ans = 0;
  rep(i,n+1) {
    if (sumA[i] > k) continue;
    ll s = sumA[i];
    ll t = k - s;
    int j = upper_bound(sumB.begin(), sumB.end(), t) - sumB.begin();
    int temp = i + (j-1);
    ans = max(temp, ans);
  }
  cout << ans << endl;
}

int main() {
  solve();
  return 0;
}

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

int main() {
	int n , a , b , c; cin >>n >> a >> b >> c;
	int INF = 100000000;
	vector<int> k(8,INF), p(4,0), q(4,0);
	for(int i = 0 ; i < n ; i++){
		cin >> k[i];
	}
	int ans = INF;
	for(int a1 = 0 ; a1 < 4 ; a1++)
	for(int a2 = 0 ; a2 < 4 ; a2++)
	for(int a3 = 0 ; a3 < 4 ; a3++)
	for(int a4 = 0 ; a4 < 4 ; a4++)
	for(int a5 = 0 ; a5 < 4 ; a5++)
	for(int a6 = 0 ; a6 < 4 ; a6++)
	for(int a7 = 0 ; a7 < 4 ; a7++)
	for(int a8 = 0 ; a8 < 4 ; a8++){
		p[a1] += k[0];
		p[a2] += k[1];
		p[a3] += k[2];
		p[a4] += k[3];
		p[a5] += k[4];
		p[a6] += k[5];
		p[a7] += k[6];
		p[a8] += k[7];
		q[a1]++;
		q[a2]++;
		q[a3]++;
		q[a4]++;
		q[a5]++;
		q[a6]++;
		q[a7]++;
		q[a8]++;
		if(p[0]==0||p[1]==0||p[2]==0){
			p[0]=0; p[1]=0; p[2]=0; p[3]=0;
			q[0]=0; q[1]=0; q[2]=0; q[3]=0;
			continue;
		}
		ans = min(ans , abs(p[0]-a)+abs(p[1]-b)+abs(p[2]-c)+10*(max(1,q[0])-1)
		                +10*(max(1,q[1])-1)+10*(max(1,q[2])-1));
		p[0]=0; p[1]=0; p[2]=0; p[3]=0;
		q[0]=0; q[1]=0; q[2]=0; q[3]=0;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#define INF 999999999
using namespace std;
std::map<string,int> z;
std::map<string,vector<string> > l;
int n;
int m;

int saisyo(string str){
	int ans=INF;
	if(z.count(str)!=0)ans=z[str];
	if(l.count(str)==0)return ans;
	int sum=0;
	for(int i=0;i<l[str].size();i++){
		sum+=saisyo(l[str][i]);
	}
	return min(ans,sum);
}

int main(void){
	while(cin>>n,n){
		z.clear();l.clear();
		string s;
		int v;
		for(int i=0;i<n;i++){
			cin>>s>>v;
			z[s]=v;
		}
		cin>>m;
		for(int i=0;i<m;i++){
			cin>>s>>v;
			string s2;
			for(int j=0;j<v;j++){
				cin>>s2;
				l[s].push_back(s2);
			}
		}
		cin>>s; //search
	cout<<saisyo(s)<<endl;
	}
	return 0;
}

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

int main() {
    int N, K, ch = 0;
    string S;
    cin >> N >> K >> S;
    for(int i = 0; i < S.length() - 1; ++i) {
        if(S[i] == S[i + 1])
            ++ch;
    }
    cout << min(ch + 2 * K, N - 1) << endl;
    return 0;
}


Measured memory_bytes: 512
#include <stdio.h>

int s[10000];
int n;

int linear_search(int s[], int n,  int t) {
  for (int i = 0; i < n; i++)
    if (s[i] == t)
      return 1;
  return 0;
}

int main(void) {
  int q;
  int t[500];
  int i;
  int count = 0;
  
  scanf("%d", &n);
  for (i = 0; i < n; i++)
    scanf("%d", &s[i]);
  scanf("%d", &q);
  for (i = 0; i < q; i++)
    scanf("%d", &t[i]);

  for (i = 0; i < q; i++) {
    count += linear_search(s, n, t[i]);
  }

  printf("%d\n", count);
  
  return 0;
}



Measured memory_bytes: 2048
fun main(arr:Array<String>) {
    val n = readLine()!!.toInt()
    val ans = readLine()!!.split(" ").map { getDiv2Count(it.toLong()) }.sum()!!
    println(ans)
}

fun getDiv2Count(num:Long):Int {
    var cnt = 0
    var tmp = num
    while (tmp%2==0L) {
        cnt++
        tmp /= 2
    }
    return cnt
}

Measured memory_bytes: 39856
import java.util.*

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val N = scanner.nextInt()
    var mo4 = 0
    var odd = 0
    for (i in 1..N) {
        val a = scanner.nextInt()
        if (a % 2 == 1)
            odd++
        else if (a % 4 == 0)
            mo4++
    }
    if (mo4+odd<N)
        odd++

    println(if (odd<=(mo4+1)) "Yes" else "No")
}

Measured memory_bytes: 54856
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ull unsigned long long 
#define int long long 
#define pb push_back 
#define mp make_pair
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define MAX 1e18
#define PI 3.14159265
const int mod = 1e9 + 7;

int power(int x, int y) 
{ 
   int res = 1;      
  
   
    while (y > 0) 
    { 
       
        if (y & 1) 
            res = (long long)(res*x); 
  
 
        y = y>>1; 
 
        if (x<=100000000)
        x = (long long)(x*x);
 
        //cout<<x<<'\n'; 
    } 
    return res; 
} 


void solve()
{
    int n,k;
    cin>>n>>k;
    int sum=0;
    int p[n];
    for(int i=0;i<n;i++){
        cin>>p[i];
    }
    sort(p,p+n);
    for(int i=0;i<k;i++){
        sum+=p[i];
    }
    cout<<sum<<endl;
   
    return;

}


int32_t main()
{
    IOS;
    solve();
    return 0;
}

Measured memory_bytes: 3704
//{
#include<bits/stdc++.h>
using namespace std;
 
// #define DEBUG

typedef long long int ll;
typedef long double ld;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define MOD (ll)(1e9 + 7)
#define vi vector<int>
#define vii vector<vector<int> >
#define vl vector<ll>
#define vll vector<vector<ll> >
#define vc(T, nm) vector<T> nm
#define pb push_back
#define popb pop_back
#define si set<int>
#define sl set<ll>
#define F first
#define S second
#define pii pair<int, int>
#define mp make_pair
#define ins insert
#define ers erase
#define endl "\n"
#define mul(a, b) ((a % MOD) * (b % MOD)) % MOD
#define adr(a, b) ((a % MOD) + (b % MOD)) % MOD
#define FORA(x, s, e, inc) for(ll x = s; x != e; x += inc)
#define ROFA(x, s, e, inc) for(ll x = s; x != e; x -= inc)
#define FOR(x, s, e) FORA(x, s, e, 1)
#define ROF(x, s, e) ROFA(x, s, e, 1)
#define loop(x, n) FOR(x, 0, n)
#define rd1(t, a) 					t a; cin >> a;
#define rd2(t, a, b) 				rd1(t, a); rd1(t, b); 
#define rd3(t, a, b, c) 			rd2(t, a, b); rd1(t, c);
#define rd4(t, a, b, c, d) 			rd3(t, a, b, c); rd1(t, d);
#define rd5(t, a, b, c, d, e) 		rd4(t, a, b, c, d); rd1(t, e);
#define rd6(t, a, b, c, d, e, f) 	rd5(t, a, b, c, d, e); rd1(t, f);
#define rdA(t, nm, len)				t nm[len]; loop(i, len) {cin >> nm[i];}
#ifdef DEBUG
	#define deb(v) cout << endl << #v << ": " << v << endl
	#define db1(v) cout << endl << #v << ": " << "[ "; for(auto x: v) {cout << x << " ";}; cout << "]" << endl;
	#define db2(v) cout << endl << #v << ": " << endl; for(auto r: v) {cout << "[ "; for(auto x: r) {cout << x << " ";}; cout << "]" << endl;};
	#define dbl cout << "-------------------------------" << endl
#else
	#define deb(v)
	#define db1(v)
	#define db2(v)
	#define dbl
#endif
//}


string solve(string s, ll k) {
    
}

void Input() {
    rd2(ll, n, k);
    vl A(n);
    FOR(i, 0, n)
        cin >> A[i];
    sort(A.begin(), A.end());
    ll sm = 0;
    FOR(i,0,k){
        sm += A[i];
    }
    
    cout << sm;
}

int main() {
	
	fastio;

    // rd1(ll, t);
	ll t = 1;

    while(t--) {
        Input();
    }
    
	return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  ll h1, m1, h2, m2, k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;

  ll leng = 0;
  if(m2 < m1){
    leng += m2 + 60 - m1;
    h2--;
  } else{
    leng += m2 - m1;
  }

  leng += 60 * (h2 - h1);

  cout << leng - k << endl;
  
  return 0;
}


Measured memory_bytes: 3600
n, m = map(int, input().split())
a = [int(i) for i in input().split()]
a = sorted(a)

l = []
for i in range(m):
  l.append(list(map(int, input().split())))
  
l = sorted(l, reverse=True, key=lambda x: x[1])

b = []
for _ in range(n):
  b.append(l[0][1])
  l[0][0] -= 1
  if l[0][0] == 0:
    l.pop(0)
  if l == []:
    break

for i in range(len(b)):
  if a[i] < b[i]:
    a[i] = b[i]
  else:
    break
    
print(sum(a))


Measured memory_bytes: 33644
#include <bits/stdc++.h>
using namespace std;
int n,i,x,pas,nr;
int main()
{
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>x;
        if(x==pas+1)
            pas=x , nr++;
    }
    if(nr==0)
        cout<<-1;
    else cout<<n-nr;
    return 0;
}


Measured memory_bytes: 256
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
def resolve():
    N = ir()
    A = lr()
    t = [0]*N
    for i in range(1, N):
        t[A[i-1]-1] += 1
    print(*t, sep='\n')
resolve()

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

int selectionSort(int A[],int n)
{
    int ret = 0;
    for(int i=0;i<n;i++){
        int mini = i;
        for(int j = i+1; j<n;j++){
            if(A[j] < A[mini])
                mini = j;
        }
        if(mini != i){
            swap(A[i],A[mini]);
            ret ++;
        }
    }
    return ret;
}


int main()
{
    int n;
    cin >> n;
    int A[100];
    for(int i=0;i<n;i++)
        cin >> A[i];
    int ret = selectionSort(A,n);
    for(int i=0;i<n;i++){
        if(i>0)
            cout << ' ';
        cout << A[i];
    }
    cout << endl;
    cout << ret << endl;
}


Measured memory_bytes: 3064