akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;

ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll COM (int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

    COMinit();
    ll N, M;
    cin >> N >> M;
    ll mcopy = M;
    set<ll> fact;
    map<ll, ll> factor;
    for (ll i = 2; i * i <= mcopy; i++) {
        if (mcopy % i == 0) {
            ll cnt = 0;
            while (mcopy % i == 0) {
                cnt++;
                mcopy /= i;
            }
            factor[i] = cnt;
        }
    }

    if (mcopy != 1) factor[mcopy] = 1;

    // for (auto e : factor) {
    //     cout << e.first << " " << e.second << endl;
    // }
    ll ans = 1;
    for (auto e : factor) {
        ans *= COM(N-1+e.second, N-1);
        ans %= MOD;
    }

    cout << ans << endl;
}

Measured memory_bytes: 12160
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)

using namespace std;

int main(){

	int n,p;
	while(1){
		cin>>n>>p;
		if(n==0&&p==0) break;
		bool t = false;
		int wan=p,a[50]={},i=0;
		while(1){
			if(wan>0){
				wan--;
				a[i]++;
				bool flag = false;
				if(wan==0){	
					for(int j=0; j<n; j++){
						if(j==i) continue;
						if(a[j]!=0 || t==false) flag = true;
					}
					if(!flag){
						cout<<i<<endl;
						break;
					}
				}

			}else{
				if(a[i]==0){

				}else{
					wan += a[i];
					a[i] = 0;
				}
			}

			t = true;
			
			i++;
			if(i==n) i=0;
		}
	}

	return 0;
}

Measured memory_bytes: 3056
sCard = [0] * 13
hCard = [0] * 13 
cCard = [0] * 13
dCard = [0] * 13

callNum = int(input())

for cardLoop in range(callNum):
    symbol, cardNum = input().split()
    cardNum = int(cardNum)
    if symbol == "S":
        sCard[cardNum-1] = cardNum
    elif symbol == "H":
        hCard[cardNum-1] = cardNum
    elif symbol == "C":
        cCard[cardNum-1] = cardNum
    elif symbol == "D":
        dCard[cardNum-1] = cardNum

sLack = 0
hLack = 0
cLack = 0
dLack = 0

for cardLoop in range(13):
    if sCard[cardLoop] == 0:
        print("S " + str(cardLoop+1))
for cardLoop in range(13):
    if hCard[cardLoop] == 0:
        print("H " + str(cardLoop+1))
for cardLoop in range(13):
    if cCard[cardLoop] == 0:
        print("C " + str(cardLoop+1))
for cardLoop in range(13):
    if dCard[cardLoop] == 0:
        print("D " + str(cardLoop+1))


Measured memory_bytes: 5612
import java.io.InputStream;
import java.io.IOException;
import java.util.NoSuchElementException;

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        int n = sc.nextInt();
        int k = sc.nextInt();
        String s = sc.next();
        char[] charArray = s.toCharArray();

        if (charArray[k - 1] == 'A') {
            charArray[k - 1] = 'a';
        } else if (charArray[k - 1] == 'B') {
            charArray[k - 1] = 'b';
        } else {
            charArray[k - 1] = 'c';
        }

        System.out.println(String.valueOf(charArray));
    }
}

class MyScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int pointer = 0;
    private int bufLength = 0;

    private boolean hasNextByte() {
        if (pointer < bufLength) {
            return true;
        } else {
            pointer = 0;
            try {
                bufLength = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (bufLength <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte()) {
            return buffer[pointer++];
        } else {
            return -1;
        }
    }

    private static boolean isNumberChar(int c) {
        return '0' <= c && c <= '9';
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[pointer])) {
            pointer++;
        }
        return hasNextByte();
    }

    public String next() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        long num = 0;
        boolean isNegative = false;
        int b = readByte();
        if (b == '-') {
            isNegative = true;
            b = readByte();
        }
        if (!isNumberChar(b)) {
            throw new NumberFormatException();
        }
        while (true) {
            if (isNumberChar(b)) {
                num *= 10;
                num += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return isNegative ? -num : num;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long temp = nextLong();
        if (temp < Integer.MIN_VALUE || Integer.MAX_VALUE < temp) {
            throw new NumberFormatException();
        }
        return (int) temp;
    }

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


Measured memory_bytes: 32352
#include <iostream>
#include <string>
#include <stack>
using namespace std;

int main(){
	string str;
	while (1){
		getline(cin,str);
		if (str[0] == '.') break;
		string ans = "yes";
		stack<char> L;
		for (int i = 0; i < str.size(); i++){
			if (str[i] == '(' || str[i] == ')' || str[i] == '[' || str[i] == ']'){
				if (str[i] == '(' || str[i] == '['){
					L.push(str[i]);
					continue;
				}
				if (L.empty() == false){
					if (str[i] == ')' && L.top() == '('){
						L.pop();
						continue;
					}
					if (str[i] == ']' && L.top() == '['){
						L.pop();
						continue;
					}
				}
				ans = "no";
				break;
			}
		}
		if (L.empty() == false){
			ans = "no";
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1184
#include<iostream>
using namespace std;
int main()
{
  int day,j,m,maxj,maxm;
  int jday,mday;

  cin >> day >> j >> m >> maxj >> maxm;

  if(j%maxj==0) jday=j/maxj;
  else jday=j/maxj+1;
  if(m%maxm==0) mday=m/maxm;
  else mday=m/maxm+1;
  int ans;
  if(jday>=mday) ans=jday;
  else ans=mday;
  cout << day-ans << endl;
  return 0;
}

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

#define BR "\n"
#define SP " "
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << SP; } cout << BR;
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << BR;

int main() {
  ll A, B;
  cin >> A >> B;

  ll ans = A + B;
  ans = max(ans, A - B);
  ans = max(ans, A * B);
  cout << ans << "\n";

  return 0;
}

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

int getNum(string a,int &i){
  int res=0;
  while(isdigit(a[i]))res=res*10+a[i++]-'0';
  return res;
}

double getx(double R,double r){return sqrt((R+r)*(R+r)-(R-r)*(R-r));}


int n;
vector<double> num;
double mem[11][11][1<<12];
int used[11][11][1<<12];
double dfs(int l,int r,int sta){
  if(sta==(1<<n)-1)return 0;
  if(used[l][r][sta]++)return mem[l][r][sta];

  double res=INF;
  for(int i=0;i<n;i++){
    if((sta&(1<<i)))continue;
    double lcost=num[i]+getx(l,num[i])-l;
    double rcost=num[i]+getx(num[i],r)-r;
    res=min(res,lcost+dfs(num[i],r,sta|(1<<i)));
    res=min(res,rcost+dfs(l,num[i],sta|(1<<i)));
  }
  return mem[l][r][sta]=res;
}

int main(){
  string str;
  while(getline(cin,str)){
    int w,idx=0;
    w = getNum(str,idx);
    num.clear();
    while(idx++<str.size())num.push_back(getNum(str,idx));
    n = num.size();
    memset(used,0,sizeof(used));
    double mn=INF;
    for(int i=0;i<n;i++)mn=min(mn,2*num[i]+dfs(num[i],num[i],1<<i));
    cout<<(mn<=w? "OK":"NA")<<endl;
  }
  return 0;
}

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

int main(){
    string s;
    cin>>s;
    if(s[0]=='Y'&&s[1]=='A'&&s[2]=='K'&&s[3]=='I'){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
const Main = ipt => {
  const c = ipt.slice(-1);
  switch(c) {
    case '2':
    case '4':
    case '5':
    case '7':
    case '9':
      console.log('hon')
      return;
    case '0':
    case '1':
    case '6':
    case '8':
      console.log('pon')
      return;
    case '3':
      console.log('bon')
      return;
  }
};

Main(require('fs').readFileSync('/dev/stdin', 'utf8').trim())

//Main(``)


Measured memory_bytes: 29616
/*
 *           AUTHOR: Maria Theresa M. Padayhag
 *             DATE: 20160326
 *  PRE-REQUIREMENT: JDK 1.8
 */
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;


class RomanFigure
{
   private final int arabic_number;
   
   public RomanFigure( String romanNumeral ) throws Exception
   {
      if( romanNumeral.length() == 0 ) {
         throw new Exception();
      }
      
      int tmp_arabic_number = 0;
      
      for( int i = 0; i < romanNumeral.length(); ) {
         char letter = romanNumeral.charAt( i );  
         int number  = letterToNumber( letter );  
         
         if(number < 0) {
            throw new Exception();
         } else {
            i++;
            if (i == romanNumeral.length()) {
               tmp_arabic_number += number;
            } else {
               int nextNumber = letterToNumber(romanNumeral.charAt(i));
               if (nextNumber > number) {
                  tmp_arabic_number += (nextNumber - number);
                  i++;
               } else {
                  tmp_arabic_number += number;
               }
            }               
         }
      }
      
      arabic_number = tmp_arabic_number;
   }
   
   public final int toArabic() 
   {
      return arabic_number;
   }
   
   private int letterToNumber( char letter ) 
   {
      switch ( letter ) {
         case 'I':  return 1;
         case 'V':  return 5;
         case 'X':  return 10;
         case 'L':  return 50;
         case 'C':  return 100;
         case 'D':  return 500;
         case 'M':  return 1000;
         default:   return -1;
        }
    }
}


public class Main
{
   public static void main( String args[] ) throws IOException
   {
      BufferedReader br = new BufferedReader( new InputStreamReader( System.in ) );
      String input;
      RomanFigure rf;
      
      READ: 
      while( ( input = br.readLine() ) != null && input.length() !=0) {
         try {
            rf = new RomanFigure(input);
            System.out.println(rf.toArabic());
         } catch( Exception e ) {
            System.out.println("Invalid input.");
            continue READ;
         }      
      }
   }
}

Measured memory_bytes: 24180
#include <iostream>
using namespace std;
int main(void){
	int A,B,C;
	cin >> A >> B >> C;
	int i,temp;
	for(i=0;i<10000;i++){
		temp = i * A;
		if(temp%B == C){
			cout << "YES";
			return 0;
		}
	}
	cout << "NO";
	return 0;
}

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

#define pb push_back
#define mp make_pair
#define ft first
#define sc second
#define ull unsigned long long int
#define lli long long int
#define li long int

#define si(n) scanf("%d",&n)
#define sl(n) scanf("%ld",&n)
#define sll(n) scanf("%lld",&n)

#define pi(n) printf("%d",n)
#define pl(n) printf("%ld",n)
#define pll(n) printf("%lld",n)

using namespace std;

const int MAX=1e5+5;

int main() {
    // freopen("a.in","r",stdin);
    // freopen("a.out","w",stdout);
    int N, ans = 0; cin >> N;
    int prev = -1, cnt = 0;
    for(int i=0; i<N; i++) {
        int x; cin >> x;
        if(x == prev) {
            cnt += 1;
        }
        else {
            ans += (cnt>>1); cnt = 1; prev = x;
        }
    }
    ans += (cnt>>1);
    cout << ans << "\n";

    return 0;
}


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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;
using vii=vector<vector<int>>;

const ll LINF=1LL<<60;
const int INF=1<<29;
const ll MOD=1e9+7;

const int MAX = 1000000+5;

ll fac[MAX], finv[MAX], inv[MAX];


void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD; 
        finv[i] = finv[i - 1] * inv[i] % MOD; 
    }
}


ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
    ll X, Y; cin >> X >> Y;
    ll res=0;
    COMinit();
    for(int i=0; i<=X/2; i++){
        if((Y-i)%2 != 0) continue;
        if((Y-i)/2+2*i != X) continue;
        res=(res+COM(Y-(Y-i)/2, i))%MOD;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 27040
#include <stdio.h>

int x,a,b ;

int main(void){

    scanf ("%d%d%d",&x,&a,&b) ;
    
    if ( a>=b ){
        printf ("delicious\n") ;
        
    } else if ( a+x>=b ){
        printf ("safe\n") ;
        
    } else {
        printf ("dangerous\n") ;
        
    }
    
    return 0 ;
    
}


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



int main()
{


        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
    
    int t=1;
    while(t--)
    {
      int count,m;
      cin>>count>>m;

    vector<int>nish;
    long long int total=0;
    for(int i=0;i<count;i++)
    {
        int first;
        cin>>first;
        total+=first;
        nish.push_back(first);
    }
    sort(nish.rbegin(),nish.rend());
    int temp=total%(4*m)==0?total/(4*m):total/(4*m)+1;
    int flag=0;
    for(int i=0;i<count;i++)
        {
            //cout<<nish[i]<<" "<<temp;
            if(nish[i]>=temp)
                m--;
            if(m>0 && nish[i]<temp)
            {
                flag=1;
                break;
            }
            if(m==0)
                break;
        }
        if(flag)
            cout<<"No"<<endl;
        else
            cout<<"Yes"<<endl;

       //cot<<c<<" "<<a<<" "<<b<<endl; 
    }

return 0;

}

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

using namespace std;

const int N = 3e5 + 7;

int main() {
    std :: ios :: sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin >> s;
    if(s[s.size() - 1] == 's') {
       cout << s << "es\n";
       return 0;
    }
    else {
        cout << s << "s\n";
    }
    return 0;
}


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

int main(){
  long long n , k;
  cin >> n >> k;
  long long SMin=0;
  long long SMax=0;
  long long s = 0;
  for(int i = 0; i < k-1; i++){
    SMin += i;
    SMax += n - i;
  }
  for(int i = k-1; i < n + 1; i++){
    SMin += i;
    SMax += n - i;
    s += SMax - SMin + 1;
  }
  cout << s % 1000000007 << endl;
  return 0;
}

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

using namespace std;

typedef long long ll;

const ll mod = 1e4 + 7;

int main() {
  int H, W;
  cin >> H >> W;
  // vector<vector<string>> s(H, vector<string>(W));
  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      string s;
      cin >> s;
      if (s == "snuke") cout << (char)('A' + j) << i + 1 << endl;
    }
  }
}

Measured memory_bytes: 256
def isPrime(n):
    if n == 2 or n == 3:
        return True
    if n % 2 == 0 or n < 2:
        return False
    for i in range(3, int(n**0.5)+1, 2):
        if n % i == 0:
            return False

    return True


N = int(input())
count = 0

for i in range(N):
    a = int(input())
    if isPrime(a):
        count += 1

print(count)


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

using namespace std;

int main()
{
    string N;
    cin >> N;
    if(N[0] == '7' || N[1] == '7' || N[2] == '7')
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    
}


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

vector<int> children[100010];
priority_queue<int> query[100010];
int markedAt[100010];
int ans[100010];

void pull(int v) {
    for (int c : children[v]) {
        pull(c);
        if (query[v].size() < query[c].size()) {
            swap(query[v], query[c]);
        }
        while (query[c].size()) {
            query[v].push(query[c].top());
            query[c].pop();
        }
    }
    while (query[v].size() && query[v].top() > markedAt[v]) {
        ans[query[v].top()] = v;
        query[v].pop();
    }
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, q;
    while (cin >> n >> q && n) {
        fill(children, children + n, vector<int>());
        fill(query, query + n, priority_queue<int>());
        fill(markedAt, markedAt+n, 1e9);
        fill(ans, ans + q, -1);
        for (int i = 1; i < n; ++i) {
            int p;
            cin >> p;
            --p;
            children[p].push_back(i);
        }
        markedAt[0] = -1;
        for (int i = 0; i < q; i++) {
            char c;
            int v;
            cin >> c >> v;
            --v;
            if (c == 'Q') {
                query[v].push(i);
            } else {
                if (markedAt[v] == 1e9) {
                    markedAt[v] = i;
                }
            }
        }
        pull(0);
        long long sum = 0;
        for (int i = 0; i < q; ++i) {
            if (ans[i] != -1) {
                sum += ans[i] + 1;
            }
        }
        cout << sum << endl;
    }
}

Measured memory_bytes: 24512
//#include "pch.h"
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <bitset>

#define ll long long
#define fri(n) for(i=0;i<(n);i++)
#define frj(n) for(j=0;j<(n);i++)
#define min(p,q) ((p)<(q)?(p):(q))
#define max(p,q) ((p)>(q)?(p):(q))
#define INF 1000000000000000000//10^18
#define INFINT 2000000001//2*10^9+1
#define MOD 1000000007
#define MODANOTHER 998244353
#define PI acos(-1)

using namespace std;

struct edge{
	int to;
	int cost;
};

vector<edge> graph[100010];
int come[100010];
struct edge e;

int search(int x){
	int i;

	come[x]=1;

	for(i=0;i<graph[x].size();i++){
		e=graph[x][i];
		if(come[e.to]==-1){
			search(e.to);
		}
	}

	return 0;
}

int main(void)
{
	//変数の宣言
	int n,m;

	//よく使う変数
	int i,j,k,l;
	int flag=0;
	int ans=0;
	int count=0;
	int temp=0;
	int temp1=0;
	int temp2=0;
	int max=0;
	int min=INFINT;
	int len=0;
	int sum=0;
	int ok=0;
	int ng=0;
	char dummy;



	//データの読み込み


	scanf("%d %d",&m,&n);
//	scanf_s("%d %d",&m,&n);

//	scanf("%s",&s);
//	scanf_s("%s",&s,5);


/*	for(i=0;i<m;i++){
//		scanf("%d %d %d",&x,&y,&z);
		scanf_s("%d %d %d",&x,&y,&z);
	}

	for(i=1;i<=n;i++){
		come[i]=-1;
	}*/

	//	printf("nは%dです\n", n);
	//	printf("データの読み込み終了\n");
	//実際の処理

	temp=(1<<m);

	if(m==1 && n==1){
		printf("-1");
		return 0;
	}
	
	if(m==1 && n==0){
		printf("1 1 0 0");
		return 0;
	}


	if(temp<=n){
		printf("-1");
		return 0;
	}

	for(i=0;i<temp;i++){
		if(i!=n){
			printf("%d ",i);
		}
	}
	printf("%d ",n);

	for(i=temp-1;i>=0;i--){
		if(i!=n){
			printf("%d ",i);
		}
	}
	printf("%d",n);


	//	printf("計算部分終了\n");

	//出力
	//printf("%d",ans);


	//	printf("結果の出力終了\n");

	return 0;
}



Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repr(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<(int)(n);i++)
#define INF 9999999999

    /*Solve*/
int main(){
    ll n;
    ll a[100010],b[100010];
    cin >> n;
    ll ans=0;
    vector<pair<ll,ll>> v;
    rep(i,n){
        cin >> a[i] >> b[i];
        v.push_back({a[i]+b[i],i});
    }
    sort(v.begin(),v.end(),greater<>());
    rep(i,n){
        if(i%2==0){
            ans+=a[v[i].second];
        }else ans-=b[v[i].second];
    }
    cout << ans;
}

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

const int mod = 1e9+7;


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

  int n;
  cin >> n;

  vector<double> dp(n+1);
  dp[0] = 1;
  for(int i=0; i<n; i++) {
    double p;
    cin >> p;
    for(int j=i+1; j>=0; j--)
      dp[j] = (j? dp[j-1]*p : 0) + dp[j]*(1-p);
  }

  double ans = 0;
  for(int i = n/2+1; i <= n; i++)
      ans += dp[i];
  cout << setprecision(10) << ans << '\n';

  return 0;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()

using namespace std;
using ll = long long;
using P = pair<int, int>;

class UnionFind{
public:
  vector<int> p;		// 親
  vector<int> rank;	// サイズ・各集合の根のみ有効
  UnionFind(int n){
    p.resize(n, -1);
    rank.resize(n, 1);
  }
  int root(int x){
    if(p[x] == -1)return x;
    else return p[x] = root(p[x]); // 深さを 1 にしている
  }
  void unite(int x, int y){
    x = root(x); y = root(y);
    if(x == y)return;
    if(rank[x] > rank[y]) swap(x, y); // rankの小さいものを下につける
    rank[y] += rank[x];
    p[x] = y;
  }
  //xが属すグループのサイズ
  int size(int x){ return rank[root(x)]; }
  bool same(int x, int y){ return (root(x) == root(y)); }
};

void solve()
{
  ll n, m, a, b;
  cin >> n >> m;
  vector<P> edge(m);
  for(int i = 0; i < m; ++i)
  {
    cin >> a >> b;
    a--; b--;
    edge[i] = P(a, b);
  }

  int ans = 0;
  for(int removed = 0; removed < m; ++removed)
  {
    UnionFind uf(n);
    for(int i = 0; i < m; ++i)
    {
      if (i == removed) continue;
      uf.unite(edge[i].first, edge[i].second);
    }
    if (uf.size(0) < n) ans++;
  }
  cout << ans;
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  string s, t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  reverse(t.begin(), t.end());
  if (s<t) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

int main(){
    string s;
    cin>>s;
    int num=0;
    if(s[0]=='o')num++;
    if(s[1]=='o')num++;
    if(s[2]=='o')num++;
    int sum=700+100*num;
    cout<<sum<<endl;
    
    return 0;   

}

Measured memory_bytes: 256
#include <bits//stdc++.h>
using namespace std;
#define rep(i,n,k) for(int i=n;i<k;i++)
#define int long long
#define F first 
#define S second
#define P make_pair 

signed main(void){
    int ans=0;
    int n,m,q,p;
    string s;
    cin>>s;
    if(s[0]=='S'){
        if(s[1]=='U')
        cout<<"7"<<endl;
        else
        cout<<"1"<<endl;
    }
    else if(s[0]=='F'){
        cout<<"2"<<endl;
    }
    else if(s[0]=='T'){
        if(s[1]=='U')
            cout<<"5"<<endl;
            else
            cout<<"3"<<endl;
        
    }
    else if(s[0]=='W'){
        cout<<"4"<<endl;
    }
    else{
        cout<<"6"<<endl;
    }
    
    
}


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

using std::cin;
using std::cout;
using std::endl;

using std::string;
using std::pair;

using std::vector;
using std::sort;
using std::lower_bound;
using std::upper_bound;
using std::find_if;
using std::copy;
using std::copy_if;

int main(){
    string s;
    cin >> s;
    for(int i=0;i<s.size();i+=2){
        cout << s[i];
    }
    cout << endl;
    return 0;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
using ld=long double;
using VI=vector<ll>;
using VD=vector<ld>;
using VVI=vector<VI>;
using VC=vector<char>;
using VVC=vector<VC>;
using VS=vector<string>;
using PLL =pair<ll,ll>;
using PLD=pair<ld,ld>;
using VPLL=vector<PLL>;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element((x).begin(),(x).end())
#define MIN(x) *min_element((x).begin(),(x).end())
#define SORTR(x) sort((x).rbegin(),(x).rend())
#define SORT(x) sort((x).begin(),(x).end())
#define SUM(x) accumulate((x).begin(),(x).end(), 0)
#define FILL(x,a) fill(x.begin(),x.end(),a)
#define EACH(i,x) for(typeof((x).begin()) i=(x).begin(); i!=(x).end(); ++i)
#define COUT(x) cout<<x<<"\n"

const ll INF = 1e18;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;
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 (b<a) { a=b; return 1; } return 0; }
template <class BidirectionalIterator>
bool next_partial_permutation(BidirectionalIterator first, BidirectionalIterator middle,BidirectionalIterator last){reverse(middle, last); return next_permutation(first , last);}
ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll GCD(VI v){ll a = v[0]; for (ll i = 1; i<SIZE(v); i++) {a = gcd(a, v[i]);} return a;}
ll LCM(VI v){ll a = v[0]; for (ll i = 1; i<SIZE(v); i++) {a = lcm(a, v[i]);} return a;}
ll Ceil(ll val,ll div){	return (1 + (val - 1) / div);}
ll Floor(ll val,ll div){return (-1 + (val + 1) / div);}

void Main()
{
	ll a,b,N;
	ll res=0;
	string sres;
	cin>>a>>b>>N;
	ll x=0;
	if(N<=b-1) x=N;
	else x=b-1;
	res=floor(a*x/b)-a*floor(x/b);

	cout << res << "\n";
	return;
}

int main()
{
	std::cin.tie(0);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}


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

int main()
{
    int n,m;
    std::cin >> n >>m;
    std::vector<std::pair<int,int>> v;
    for (int i = 0; i < n; i++) {
        int a,b;
        std::cin >> a >> b;
        v.emplace_back(a,b);
    }
    std::sort(v.begin(), v.end());

    long long cost = 0;

    for (int i = 0; i < n && m > 0; i++) {
        long long now = std::min(v[i].second, m);
        cost += (long long )v[i].first * now;
        m -= now;
    }

    std::cout << cost << std::endl;

    return 0;
}


Measured memory_bytes: 1400
#include<stdio.h>

#define MAX 2000000

int H,A[MAX+1];

void maxHeapify(int i){
  int l,r,largest,C;
  l=2*i;
  r=2*i+1;

  if(l<=H&&A[l]>A[i])largest=l;
  else largest = i;
  if(r<=H&&A[r]>A[largest])largest=r;

  if(largest!=i){
    C=A[i];
    A[i]=A[largest];
    A[largest]=C;
    maxHeapify(largest);
  }
}

int main(){
  int i;

  scanf("%d",&H);

  for(i=1;i<=H;i++)scanf("%d",&A[i]);
  for(i=H/2;i>=1;i--)maxHeapify(i);
  for(i=1;i<=H;i++){
    printf(" %d",A[i]);
  }

  printf("\n");
  
  return 0;
}



Measured memory_bytes: 3640
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << x << endl;
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

template <class T>
std::vector<std::vector<T>> Imos2D(const std::vector<std::vector<T>>& a) {
    int h = (int)a.size(), w =(int) a[0].size();
    std::vector<std::vector<T>> s(h + 1, std::vector<T>(w + 1, 0));
    rep(i, h) rep(j, w) s[i + 1][j + 1] = a[i][j];
    rep(i, h + 1) rep(j, w) s[i][j + 1] += s[i][j];
    rep(i, h) rep(j, w + 1) s[i + 1][j] += s[i][j];
    return s;
}

template <class T>
int sum(const std::vector<std::vector<T>>& s, int i, int j, int h, int w) {
    swap(j,h);
    h-=i;
    w-=j;
    return s[i + h][j + w] - s[i][j + w] + s[i][j] - s[i + h][j];
}
int main(){
    int n,k;
    cin >> n >> k;
    int cnt = 0;
    int cnt2 = 0;
    vector<vector<int>>a(2*k+5,vector<int>(2*k+5,0));
    vector<vector<int>>s(2*k+5,vector<int>(2*k+5,0));
    vector<vector<int>>aa(2*k+5,vector<int>(2*k+5,0));
    vector<vector<int>>ss(2*k+5,vector<int>(2*k+5,0));
    rep(i,n){
        int x,y;
        char c;
        cin >> x >> y >> c;
        x = x%(2*k);
        y = y%(2*k);
        if(c == 'W'){
            a[x][y]++;
            cnt2++;
        }else{
            aa[x][y]++;
            cnt++;
        }
    }
    s = Imos2D(a);
    ss = Imos2D(aa);
    int ans = 0;
    for(int i = 0;i <= k; i++){
        for(int j = 0; j <= k; j++){
            int temp = 0;
            int temp2 = 0;
            temp += sum(s,i,i+k,j,j+k);
            temp2 += sum(ss,i,i+k,j,j+k);
            if(i>0 and j > 0){
                temp += sum(s,0,i,0,j);
                temp2 += sum(ss,0,i,0,j);
            }
            if(i > 0 and j!=k){
                temp += sum(s,0,i,j+k,2*k);
                temp2 += sum(ss,0,i,j+k,2*k);
            }
            if(j > 0 and i!=k){
                temp += sum(s,i+k,2*k,0,j);
                temp2 += sum(ss,i+k,2*k,0,j);
            }
            if(i!=k and j!=k){
                temp += sum(s,i+k,2*k,j+k,2*k);
                temp2 += sum(ss,i+k,2*k,j+k,2*k);
            }
            //cout << i << " "  << j << " " << temp << " " << temp2 << endl;
            int mitasu = max(temp + (cnt-temp2),temp2 + (cnt2-temp));
            ans = max(ans,mitasu);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 81152
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <sstream>
#include <cmath>
#include <queue>

using namespace std;

// union-find ???????????£??????

int main(){
	
	string r, a;
	
	while(true){
		cin >> r >> a;
		if(r == "0" && a == "0"){
			break;
		}
		
		int hit = 0;
		int blow = 0;
		
		for(int i = 0; i < 4; i++){
			for(int j = 0; j < 4; j++){
				if(r[i] == a[j]){
					if(i == j){
						hit++;
					}else{
						blow++;
					}
				}
			}
		}
		
		cout << hit << " " << blow << endl;
		
	}
	
	return 0;
}

Measured memory_bytes: 3156
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD=1000000007;

int main() {
    int N; cin>>N;
    vector<ll> A(N,0);
    vector<ll> B(N,0);
    for(int i=0;i<N;i++){
        cin>>A[i]>>B[i];
    }
    ll ans=0;
    for(int i=N-1;i>=0;i--){
        A[i]+=ans;
        if(A[i]%B[i]!=0){
            int tmp=(A[i]/B[i]+1)*B[i]-A[i];
            A[i]+=tmp;
            ans+=tmp;
        }
    }
    cout<<ans;
    return 0;
}

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

struct pii {
	pii(int v, int c) : val(v), count(c)
	{}
	int val;
	int count;
};

bool operator < (pii const& x, pii const& y) {
	return x.val > y.val;
}

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

    int n, m;
    cin >> n >> m;
    priority_queue<pii> q;
    while (n--) {
        int x;
        cin >> x;
        q.emplace(x, 1);
    }
    while (m--) {
        int b, c;
        cin >> b >> c;
        int i = b;
        while (i && q.top().val < c) {
            auto& p = q.top();
            if (i < p.count) {
                const_cast<pii&>(p).count -= i;
                i = 0;
            }
            else {
                i -= p.count;
                q.pop();

            }
        }
        if (i < b) {
            q.emplace(c, b - i);
        }

    }
    long long s = 0;
    while (!q.empty()) {
        auto& p = q.top();
        s += (long long) p.val * p.count;
        q.pop();
    }

    cout << s << '\n';

    return 0;
}


Measured memory_bytes: 1400
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

n = ni()
s = set()
for i in range(n):
    x = ni()
    if x in s:
        s.remove(x)
    else:
        s.add(x)
print(len(s))

Measured memory_bytes: 11884
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx")
//#undef LOCAL
#include <bits/stdc++.h>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

#ifdef LOCAL
struct PrettyOS {
    ostream& os;
    bool first;
    template <class T> auto operator<<(T&& x) {
        if (!first) os << ", ";
        first = false;
        os << x;
        return *this;
    }
};
template <class... T> void dbg0(T&&... t) {
    (PrettyOS{cerr, true} << ... << t);
}
#define dbg(...)                                            \
    do {                                                    \
        cerr << __LINE__ << " : " << #__VA_ARGS__ << " = "; \
        dbg0(__VA_ARGS__);                                  \
        cerr << endl;                                       \
    } while (false);
#else
#define dbg(...)
#endif

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

template <class T> ostream& operator<<(ostream& os, const V<T>& v) {
    os << "[";
    for (auto d : v) os << d << ", ";
    return os << "]";
}

using D = double;
using P = complex<D>;
D PI = acos(D(-1));

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int n;
    D l;
    cin >> n >> l;

    // cos(ar), sin(ar)
    V<D> ar(n);
    for (int i = 0; i < n; i++) {
        cin >> ar[i]; ar[i] = 2 * PI * ar[i] / l;
    }

    P sm = P(0, 0);
    for (int i = 0; i < n; i++) {        
        for (int j = i + 1; j < n; j++) {
            {
                D md = (ar[i] + ar[j]) / 2;
                sm += polar<D>(1, md) * D(n - 2 - (j - i - 1));
            }
            {
                D md = (ar[i] + ar[j]) / 2 + PI;
                sm += polar<D>(1, md) * D(j - i - 1);
            }
        }
    }
    sm /= D(n) * D(n - 1) * D(n - 2) / 6;
    cout << sm.real() << " " << sm.imag() << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>
#define debug cout << "Ok" << endl;

using namespace std;

void solve(){

	return;
}
 
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	map<string,int>ma;
	int n,maior=0;
	string s;
	cin >> n;

	while(n--){
		cin >> s;
		ma[s]++;
		maior = max(maior,ma[s]);
	}

	for(auto i: ma){
		if(i.second == maior){
			cout << i.first << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 19244
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

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

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

int main(){
    int N, M;
    cin >> N >> M;
    cout << N - M - 1 << endl;
    return 0;
}


Measured memory_bytes: 3116
#include <iostream>

using namespace std;

long long int kaidan (int n) {
	if (n == 0) {
		return 1;
	} else {
		if (n >= 3) {
			return kaidan(n-3)+kaidan(n-2)+kaidan(n-1);
		} else if (n > 1) {
			return kaidan(n-2)+kaidan(n-1);
		} else {
			return kaidan(n-1);
		}
	}
}


int main() {
	int n;
	while (cin >> n) {
		if (n == 0) {
			break;
		}
		long long int a = kaidan(n);
		long long int b;
		b = a / 10;
		if (a % 10 != 0) {
			b++;
		}
		a = b / 365;
		if (b % 365 != 0) {
			a++;
		}
		cout << a << endl;
	}
	return 0;
}

Measured memory_bytes: 1152
import java.util.Scanner;

public class Main {
	void spread(){
		Scanner s = new Scanner(System.in);
		int r = s.nextInt();
		int c = s.nextInt();
		int rxc[][] = new int[r+1][c+1];
		for(int i = 0;i < r;i++){
			int sumJ = 0;
			for(int j = 0;j<c;j++){
				rxc[i][j] = s.nextInt();
				sumJ+=rxc[i][j];
			}
			rxc[i][c] = sumJ;
		}
		for(int j = 0;j < c + 1;j++){
			int sumI = 0;
			for(int i = 0;i < r;i++){
				sumI+=rxc[i][j];
			}
			rxc[r][j] = sumI;
		}
		for(int i = 0;i < r+1;i++){
			for(int j = 0;j < c+1;j++){
				System.out.print(rxc[i][j]);
				if(j < c){
					System.out.print(" ");
				}
			}
			System.out.print("\n");
		}
	}
	public static void main(String args[]){
		Main m = new Main();
		m.spread();
	}
}

Measured memory_bytes: 43940
#include<stdio.h>

int main(){

	int sx,sy,tx,ty;
	int x,y;

	scanf("%d %d %d %d",&sx,&sy,&tx,&ty);

	x = sx;
	y = sy;
	
	while( y != ty ){
		printf("U");
		y++;
	}

	while( x != tx ){
		printf("R");
		x++;
	}
	
	while( y != sy ){
		printf("D");
		y--;
	}

	while( x != sx ){
		printf("L");
		x--;
	}

	x--;
	printf("L");

	while( y != ty+1 ){
		printf("U");
		y++;
	}

	while( x != tx ){
		printf("R");
		x++;
	}
	
	y--;
	printf("D");

	x++;
	printf("R");

	while( y != sy-1 ){
		printf("D");
		y--;
	}

	while( x != sx ){
		printf("L");
		x--;
	}

	y++;
	printf("U");

	printf("\n");

	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main(){
           int W,H,x,y,r;
           scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
		   if(x-r>=0&&x+r<=W&&y-r>=0&&y+r<=H){
             printf("Yes\n");
           }else{
             printf("No\n");
           }
           return 0;
}

Measured memory_bytes: 2692
#include <iostream>
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
using namespace std;
#define EPS (1.0e-8)
#define equals(a, b) (fabs((a) - (b)) < EPS) 
typedef complex<double> P;

struct Segment {
  P p1, p2;
  Segment(P p1, P p2) {
    this->p1 = p1;
    this->p2 = p2;
  }
};
typedef Segment Line;
double cross(P a, P b) {
  return a.real()*b.imag() - a.imag()*b.real();
}

P getCrossPoint(Line s1, Line s2) {
  P a = s1.p2 - s1.p1;
  P b = s2.p2 - s2.p1;
  double d1 = cross(b, a);
  double d2 = cross(b, s2.p1 - s1.p1);
  return s1.p1 + a*d2/d1;
}
P getCrossPoint(P p1, P p2, P p3, P p4) {
  return getCrossPoint(Line(p1, p2), Line(p3, p4));
}
int N;
P V[32][32];

void solve() {
  for(int i = 1; i <= N; ++i) {
    for(int j = 1; j <= N; ++j) {
      V[i][j] = getCrossPoint(V[0][j], V[N+1][j], V[i][0], V[i][N+1]);
    }
  }
  double res = 0;
  for(int i = 0; i+1 < N+2; ++i) {
    for(int j = 0; j+1 < N+2; ++j) {
      double S = 0;
      S += fabs(cross(V[i+1][j]-V[i][j], V[i][j+1]-V[i][j]));
      S += fabs(cross(V[i+1][j]-V[i+1][j+1], V[i][j+1]-V[i+1][j+1]));
      S /= 2.0;
      res = max(res, S);
    }
  }
  printf("%.6f\n", res);
}

main() {
  while((cin >> N) && N) {
    V[0][0] = P(0, 0);
    V[0][N+1] = P(1, 0);
    V[N+1][0] = P(0, 1);
    V[N+1][N+1] = P(1, 1);

    for(int i = 0; i < N; ++i) {
      cin >> V[0][i+1].real();
      V[0][i+1].imag() = 0;
    }
    for(int i = 0; i < N; ++i) {
      cin >> V[N+1][i+1].real();
      V[N+1][i+1].imag() = 1;
    }
    for(int i = 0; i < N; ++i) {
      V[i+1][0].real() = 0;
      cin >> V[i+1][0].imag();
    }
    for(int i = 0; i < N; ++i) {
      V[i+1][N+1].real() = 1;
      cin >> V[i+1][N+1].imag();
    }
    solve();
  }
}

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

int main() {
    int N;
    cin >> N;
    double sum = 0;
    for (int i = 0; i < N; i++) {
        double x;
        string u;
        cin >> x >> u;
        if (u == "BTC") x *= 380000.0;
        sum += x;
    }
    cout << setprecision(20) << sum << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		long H = sc.nextLong();
		int count = 0;
		if( H>1 ){

		for( int i=0; i<40; i++ ){
			H = H/2;
			count++;
			if( H==1 ){
				break;
			}
		}

		}
		long ans = 1;
		long a = 1;
		for( int i=0; i<count; i++ ){
			a = a*2;
			ans += a;		
		}
		System.out.println(ans);
	}
}


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

using namespace std;
using ll = long long;
#define rep(i,n) for (int i = 0; i < (int)n; i++)

int main(){
  map<string, int> s;
  int n;
  cin >> n;
  rep(i,n) {
    string key;
    cin >> key;
    s[key] += 1;
  }
  int maxv = 0;
  for (const auto &x : s) {
    int v = x.second;
    maxv = max(maxv, v);
  }
  for (auto it = s.begin(); it != s.end(); it++) {
    if (it->second == maxv) {
      cout << it->first << endl;
    }
  }
}


Measured memory_bytes: 19228
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;
int main()
{

	int n;
	cin>>n;
	vector<int>s(n);
	for(int i=0;i<n;i++)
		cin>>s[i];
	int q;
	cin>>q;
	vector<int>T(q);
	for(int k=0;k<q;k++)
		cin>>T[k];
	sort(s.begin(),s.end());
	
	//int left=0,right=s.size();
	
	int cnt=0;
	//int mid=(left+right)/2;
	for(int k=0;k<q;++k){
		int left=0,right=s.size();
		while(true){
			if(left==right){
				//cout<<"0"<<endl;
				break;
			}
			int mid=(left+right)/2;
			if(s[mid]<T[k]){
				left=mid+1;
			
			}else if(s[mid]>T[k]){
				right=mid;
			}else{
				cnt++;
				break;
			}
		}
		
	}
	printf("%d\n",cnt);
}	
		
		


Measured memory_bytes: 3452
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define numrep(i,n) for(int i=1;i<=n;i++)
#define bitrep(n) for(int bit=0;bit<(1<<n);bit++)
#define ll int64_t
#define all(v) v.begin(), v.end()

const int MOD = 1000000007;

int main() {

int N,K; cin >> N >> K ;

vector<bool> x(N+1);

rep(i,K){
  int d; cin>>d;
  rep(j,d){
    int y; cin>>y;
    x[y]=true;
  }
}
ll ans=0;

for(int i=1;i<=N;i++){
  if(x[i]) ans++;
}

cout << N-ans << endl;

return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    int n;cin>>n;
    vector<double> arr(n);

    for(int i = 0; i < n; i++){
        cin>>arr[i];
    }
    sort(arr.begin(),arr.end());
    vector<double> pw(n);
    ll p = 1;
    pw[0] = 1;
    for(int i = 1; i < n; i++){
        pw[i] = pw[i-1]*2;
    }
    double res = 0;
    res+=arr[0]/pw[n-1];
    res+=arr[1]/pw[n-1];
    for(int i = 2;  i < n; i++){
        res+=arr[i]/pw[n-i];
    }
    cout<<setprecision(5)<<res;
  }


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

using namespace std;

#define pb push_back
#define mp make_pair
constexpr int INF = 1e9 + 1;
constexpr int MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;

constexpr int dx[4] = {1, 0, -1, 0};
constexpr int dy[4] = {0, 1, 0, -1};

int cnt = 0;
void marge(vector<int> &A, int left, int mid, int right) {
	int n1 = mid - left;
	int n2 = right - mid;
	vector<int> L(n1), R(n2);
	for(int i = 0; i < n1; i++) {
		L[i] = A[left + i];
	}
	for(int i = 0; i < n2; i++) {
		R[i] = A[mid + i];
	}
	L.push_back(INF);
	R.push_back(INF);
	int i = 0, j = 0;
	for(int k = left; k < right; k++) {
		cnt++;
		if (L[i] <= R[j]) {
			A[k] = L[i++];
		} else {
			A[k] = R[j++];
		}
	}
}

void margesort(vector<int> &A, int left, int right) {
	if (left + 1 < right) {
		int mid = (left + right) / 2;
		margesort(A, left, mid);
		margesort(A, mid, right);
		marge(A, left, mid, right);
	}
}

int main() {
	int N;
	cin >> N;
	vector<int> A;
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		A.push_back(a);
	}
	margesort(A, 0, N);
	for (int i = 0; i < N; i++) {
		cout << A[i];
		if (i != N - 1) cout << " ";
	}
	cout << endl;
	cout << cnt << endl;

	return 0;
}



Measured memory_bytes: 8588
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef long double ld;

int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
   	ll n,w;
   	cin >> n >> w;
   	vector <vector<ll>> dp(n,vector<ll>(100001,LLONG_MAX));
   	vector <pair<ll,ll>> arr(n);
   	for (int z=0;z<n;z++){
   		cin >> arr[z].first >> arr[z].second;
   	}
   	for (int z=0;z<n;z++){
   		dp[z][0] = 0;
   	}
   	for (int z=0;z<=100000;z++){
   		if (z >= arr[0].second){
   			dp[0][z] = arr[0].first;
   			break;
   		}
   	}
   	for (int z=1;z<n;z++){
   		for (int x=0;x<=100000;x++){
   			dp[z][x] = dp[z-1][x];
   			if (x-arr[z].second >= 0 && dp[z-1][x-arr[z].second] != LLONG_MAX)
   			dp[z][x] = min(dp[z-1][x],dp[z-1][x-arr[z].second]+arr[z].first);
   		} 
   	}
   	ll ans = 0;
   	for (ll z=0;z<=100000;z++){
   		if (dp[n-1][z] <= w){
   			ans = max(ans,z);
   		}
   	}
   	cout << ans << endl;
   	cin >> n;
}


Measured memory_bytes: 79488
#include <stdio.h>
int main(void){
  int i, j, n; //nは持っているトランプの枚数
  char mark, a;
  int num; //numは持っているトランプのランク（トランプ上の数字）
  char marks[4] = {'S', 'H', 'C', 'D'};
  int cards[4][13];
  
  for(i=0;i<4;i++){
      for(j=0;j<13;j++){
          cards[i][j] = 0;
      }
  }

  scanf("%d", &n);

  for(i=0; i<n; i++){
      scanf("%d", &a);
      scanf("%c %d", &mark, &num);
      j=0;
      for(j = 0; j < 4; j++){
          if(mark == marks[j]){
              cards[j][num - 1] = 1;
              break;
          }
      }
  }
  
//   for(i=0;i<4;i++){
//       for(j=0;j<13;j++){
//           printf("%d ", cards[i][j]);
//       }
//       printf("\n");
//   }

  for(i = 0; i < 4; i++){
      for(j = 0; j < 13; j++){
          if(!cards[i][j]) printf("%c %d\n", marks[i], j + 1);
      }
  }
  return 0;
}


Measured memory_bytes: 2132
import sys

while 1:
  n=input()+1
  if n==1:break
  N=range(n)
  N1=N[1:]
  A=[''*n]+[' '+raw_input() for i in N1]
  M=[[0]*n for i in N]
  y=M[0]
  for i in N1:
    x=[0]*n
    B=A[i]
    for j in N1:
      if B[j]=='.': x[j]=min(y[j-1],y[j],x[j-1])+1
    M[i]=x
    y=x
  print max(map(max,M))

Measured memory_bytes: 32992
// W i B
#include <bits/stdc++.h>
#define F first
#define S second
#define MOD 998244353
#define pb push_back
#define bit(x,p) ((x>>p) & 1)
#define ll long long
#define Task "CF"
using namespace std;

const int base = 100003;
const int maxn = 200005;

int n,k;
ll tree[8 * maxn],T1[maxn],P[maxn],lazy[4 * maxn];

void LazyUpd(int node,int l,int r){
    if(l == r || lazy[node] == 0) return;
    int mid = (l + r) >> 1;
    tree[node * 2] = lazy[node] * T1[mid - l + 1] % MOD;
    tree[node * 2 + 1] = lazy[node] * T1[r - mid] % MOD;
    lazy[node * 2] = lazy[node * 2 + 1] = lazy[node];
    lazy[node] = 0;
}

void Update(int node,int l,int r,int u,int v,ll val){
    LazyUpd(node,l,r);
    if(l > v || r < u) return;
    if(l >= u && r <= v){
        tree[node] = val * T1[r - l + 1] % MOD;
        lazy[node] = val;
        return;
    }
    int mid = (l + r) >> 1;
    Update(node * 2,l,mid,u,v,val);
    Update(node * 2 + 1,mid + 1,r,u,v,val);
    tree[node] = (tree[node * 2] * P[r - mid] % MOD + tree[node * 2 + 1]) % MOD;
}

void Solve(){
    cin >> n >> k;
    P[0] = 1;
    for(int i = 1;i <= n;++i){
        T1[i] = (T1[i - 1] * 10 + 1) % MOD;
        P[i] = P[i - 1] * 10 % MOD;
    }
    Update(1,1,n,1,n,1);
    while(k --){
        int l,r,val;
        cin >> l >> r >> val;
        Update(1,1,n,l,r,val);
        cout << tree[1] << "\n";
    }

}
void NumTime(){
    cerr << "Toi" << "\n";cerr << "Di" << "\n";cerr << "Chep" << "\n";cerr << "Code" << "\n";
}


int main(){
    ios_base::sync_with_stdio(0);
    cout.tie(0); cin.tie(0);
	if(fopen(Task".inp","r")){
		freopen(Task".inp","r",stdin);
		freopen(Task".out","w",stdout);
	}
    int test = 1;
//    cin >> test;
    while(test --){
        NumTime();
        Solve();
    }
}
 // V T An


Measured memory_bytes: 14996