akhauriyash/Code-Regression huggingface dataset:
import copy

n, m = map(int,input().split())
h = list(map(int,input().split()))
peak = [0] * n

for i in range(m):
    a, b = map(int,input().split())
    #print("a="+str(a)+" b="+str(b))
    peak[a-1] = max(h[b-1],peak[a-1])
    peak[b-1] = max(h[a-1],peak[b-1])
    
    #print(peak)
    #print(h)

ans = 0
for j in range(n):
    if h[j] > peak[j]:
        ans += 1

print(ans)

Measured memory_bytes: 21032
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n, k, l;
    cin >> n >> k >> l;
    vector<vector<int> >g1(n + 3), g2(n + 3);
    for(int i = 0; i < k; i++){
        int u, v;
        cin >> u >> v;
        g1[u].push_back(v);
        g1[v].push_back(u);
    }
    for(int i = 0; i < l; i++){
        int u, v;
        cin >> u >> v;
        g2[u].push_back(v);
        g2[v].push_back(u);
    }
    vector<int>a(n + 3), b(n + 3), vis(n + 3, 0);
    queue<int>q;
    int cnt = 0;
    for(int i = 1; i <= n; i++){
        if(vis[i] == 0){
            cnt++;
            q.push(i);
            a[i] = cnt;
            vis[i] = 1;
            while(!q.empty()){
                int u = q.front();
                q.pop();
                for(int j = 0; j < g1[u].size(); j++){
                    int v = g1[u][j];
                    if(vis[v] == 0){
                        vis[v] = 1;
                        a[v] = cnt;
                        q.push(v);
                    }
                }
            }
        }
    }
    cnt = 0;
    for(int i = 1; i <= n; i++){
        vis[i] = 0;
    }
    for(int i = 1; i <= n; i++){
        if(vis[i] == 0){
            cnt++;
            q.push(i);
            b[i] = cnt;
            vis[i] = 1;
            while(!q.empty()){
                int u = q.front();
                q.pop();
                for(int j = 0; j < g2[u].size(); j++){
                    int v = g2[u][j];
                    if(vis[v] == 0){
                        vis[v] = 1;
                        b[v] = cnt;
                        q.push(v);
                    }
                }
            }
        }
    }
    map<pair<int, int>, int>mp;
    for(int i = 1; i <= n; i++){
        mp[make_pair(a[i], b[i])]++;
    }
    for(int i = 1; i <= n; i++){
        cout << mp[make_pair(a[i], b[i])] << ' ';
    }
    return 0;
}

Measured memory_bytes: 30900
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define VVi vector<vector<ll>>
#define Vd vector<double>
#define Vb vector<bool>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

template<class T> inline bool chmin(T& a, T b) {if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if(a<b){a=b;return true;}return false;}

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  IN2(n,m);
  REP(i,n){
    IN(s);
    OUT(s);
    OUT(s);
  }
}

Measured memory_bytes: 256
import sys, os

if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

f = lambda:list(map(int,input().split()))

def get_qsa(file_name):
    audio, size = readfile(file_name)
    headers = {
        'Connection': 'keep-alive',
        'Content-Length': str(size)
    }

    
    parameter = {
                "request_id":int(time.time()*100),
                "th":1,
                "tht":"qf492_100fps",
                "the":1.000000,
                "thst":"neural"
                }
    res = requests.post(f"http://{config['ip']}:{config['port']}", timeout=120, data=audio, headers=headers, params = parameter)
    # print(res.url)

    res_json = res.json()
    # print(res_json.keys())


    if res_json['retmsg']!="success":
        raise Exception
    

    bin_str = res_json["th"][0]["feat"]
    bin_data = base64.b64decode(bin_str)

    bin2qsa_siren(bin_data, file_name)


def solve():
    from math import sqrt, pi, cos
    a,b,h,m = f()

    theta1 = (h + m/60) / 12
    
    theta2 = m/60

    l = sqrt(a**2 + b**2 - 2 * a * b * cos( 2*pi * abs(theta1 - theta2)))
    print(f"{l:.10f}")

       
    
solve()



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

int main(){
    int N, M ;
    cin >> N>> M ;
    vector<vector<bool>> data(M,vector<bool>(N,0));
    vector<int> st(M) ;
    rep(i,M){
        int k ;
        cin >> k ;
        rep(j,k){
            int num ;
            cin >> num ;
            data[i][num-1] = 1 ;
        }
    }
    int ans = 0 ;
    rep(i,M) cin >> st[i] ;
    for(int bit=0;bit<(1<<N);bit++){
        int cnt = 0 ;
        for(int i=0; i < M; i++){
            int p = 0 ;
            for(int j=0;j<N;j++){
                if(bit & (1 << j) && data[i][j]){
                    p++;
                } 
            }
            if(p%2 == st[i]) cnt ++ ;
        }
        if(cnt == M) ans++ ;

    }
    cout << ans << endl ;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  string ss = s;
  int sizes = s.size();
  int counta = 0;
  for(int i=0;i<sizes;i++){
    if(i==0){
      if(ss[0]=='1'){
        counta++;
      }
      ss[0]='0';
    }
    if(ss[i]==ss[i+1]&&ss[i]=='0'){
      ss[i+1]='1';
      counta++;
    } else if (ss[i]==ss[i+1]&&ss[i]=='1'){
      ss[i+1]='0';
      counta++;
    }
  }
  int bb = 0;
  for(int i=0;i<sizes;i++){
    if(i==0){
      if(s[0]=='0'){
        bb++;
      }
      s[0]='1';
    }
    if(s[i]==s[i+1]&&s[i]=='0'){
      s[i+1]='1';
      bb++;
    } else if (s[i]==s[i+1]&&s[i]=='1'){
      s[i+1]='0';
      bb++;
    }
  }
  cout << min(counta,bb) << endl;
}


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

using namespace std;

void solve()
{
	int n;
	string s;
	cin >> s;
	n = s.size();
	int ans = 0, ans2 = 0;
	for (int i = 0; i < n; i++)
	{
		if (s[i]-'0' != i%2) ans++;
		if (s[i]-'0' == i%2) ans2++;
	}
	ans = min(ans, ans2);
	cout << ans << endl;
}

int main()
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 512
#!/usr/bin/ruby

NN = ARGF.gets.chomp.to_i
AA = ARGF.gets.chomp.split.collect {|el| el.to_i}
QQ = ARGF.gets.chomp.to_i
MM = ARGF.gets.chomp.split.collect {|el| el.to_i}

#p NN, AA, QQ, MM
MMAX = 2000 + 1

$dp = Array.new(AA.size) {Array.new(MMAX)}

def search(idx, tm)
  if tm == 0
    return true
  elsif AA.size <= idx
    return false
  else
    dpv = $dp[idx][tm]
    if dpv.nil?
      if search(idx + 1, tm)
        dpv = true
      elsif search(idx + 1, tm - AA[idx])
        dpv = true
      else
        dpv = false
      end
      $dp[idx][tm] = dpv
    end
    return dpv
  end
end

MM.each do |mi|
  ans = search(0, mi)
  puts ans ? "yes" : "no"
end



Measured memory_bytes: 7200
//bismillahir rahmanir rahim            //Author:Fayed Anik
 
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
//using namespace __gnu_pbds;
 
//#define         ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define         ll                          long  long
#define         lf                          double
#define         pb(x)                       push_back(x)
#define         ull                         unsigned long long
#define         sfl(a)                      scanf("%lld",&a)
#define         sf(a)                       scanf("%d",&a)
#define         pf(a)                       printf("%d\n",a)
#define         pfl(a)                      printf("%lld\n",a)
#define         FOR(x,n)                    for(ll x=1;x<=n;++x)
#define         pii                         pair< ll , ll >
#define         mp(a,b)                     make_pair(a,b)
#define         UNIQUE(v)                   v.resize(distance(v.begin(),unique(v.begin(),v.end())))
#define         mod                         1000000007
#define         INF                         2e18
#define         EPS                         1e-15
#define         f1                          first
#define         f2                          second
#define         all(v)                      v.begin(),v.end()
#define         PI                          acos(-1)
#define         printminusone               printf("-1\n")
#define         bug                         printf("bug")
#define         FILEIN                      freopen("in.txt","r",stdin)
#define         FILEOUT                     freopen("out.txt","w",stdout)
 
//ll SET(ll mask,ll pos){ return mask = (mask | (1ll<<pos)); }
//ll RESET(ll mask,ll pos){ return mask = mask & ~(1ll<<pos); }
//bool CHECK(ll mask,ll pos) { return (bool) (mask & (1ll<<pos)); }
//priority_queue <ll, vector<ll>, greater<ll> > pq;
//int dx[]={0,0,1,-1,1,1,-1,-1};
//int dy[]={1,-1,0,0,1,-1,1,-1};

#define lim 200005

ll a[lim];

int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ll n;
    sfl(n);
    FOR(i,n) sfl(a[i]);
    ll tot=0,prev = 0;
    for(ll i=1;i<=n;i++){
        if(prev>a[i]){
            tot += prev-a[i];
        }
        prev = max(prev,a[i]);
    }    
    pfl(tot);
    return 0;
}

Measured memory_bytes: 5300
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
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 T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m, q; cin >> n >> m >> q;
    vector<vector<int> > b(n + 2, vector<int>(n + 2));
    rep (_, m) {
        int l, r; cin >> l >> r;
        b[l][r]++;
    }
    rep (i, n + 2) { rep (j, n + 2) eprintf("%d ", b[i][j]); eprintf("\n"); }
    rep (i, n + 1) rep (j, n + 2) b[i + 1][j] += b[i][j];
    rep (i, n + 2) rep (j, n + 1) b[i][j + 1] += b[i][j];
    rep (i, n + 2) { rep (j, n + 2) eprintf("%d ", b[i][j]); eprintf("\n"); }
    rep (_, q) {
        int p, q; cin >> p >> q; p--;
        cout << b[q][q] + b[p][p] - b[p][q] - b[q][p] << "\n";
    }
    return 0;
}

Measured memory_bytes: 1920
#include <stdio.h>
#include <stdlib.h>

int data[100000] = {0};

int f(int n) {
	if ((n & 1) == 0) {
		//printf("%d\n",n/2);
		return n/2;
	}
	//printf("%d\n",(3*n) + 1);
	return (3 * n) + 1;
}

int comp(int i) {
	int org_i = i;
	while(1) {
		i--;
		if(i < 0) {
			break;
		}
	//	printf("c %d %d\n", data[org_i], data[i]);
		if (data[org_i] == data[i]) {
			return 1;
		}
	}
	return 0;
}

int main()
{
	int n_in;
	int i = 0;
	int result = 0;
	scanf("%d", &n_in);

	data[i] = n_in;
	while(1) {
		i++;
		data[i] = f(data[i-1]);
		result = comp(i);
		if (result == 1) {
			break;
		}
	}
	printf("%d\n",i+1);
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int hp = sc.nextInt();
    int num = sc.nextInt();
    int sum = 0;
    for(int i = 0; i < num; i++){
      sum += sc.nextInt();
    }
    System.out.println(sum >= hp ? "Yes" : "No");
  }
}

Measured memory_bytes: 49300
#include<stdio.h>
int main(void){
	
	int in[5],n[5],k,r;
	
	n[1]=0;
	n[2]=0;
	n[3]=0;
	n[4]=0;
	n[5]=0;
	
	r=0;
	
	for(k=1;k<=5;k++){
		
		scanf("%d",&in[k]);
		
		if(in[k]==0)break;
		
		r++;
		
//		printf("%d\n",in[k]);
	}
	
	
	for(k=1;k<=r;k++){
		
		in[k]=1000-in[k];
		
		while(in[k]>=500){
			
			in[k]=in[k]-500;
			
			n[k]++;
		}
		
		while(in[k]>=100){
			
			in[k]=in[k]-100;
			
			n[k]++;
		}
		
		while(in[k]>=50){
			
			in[k]=in[k]-50;
			
			n[k]++;
		}
		
		
		while(in[k]>=10){
			
			in[k]=in[k]-10;
			
			n[k]++;
		}
		
		while(in[k]>=5){
			
			in[k]=in[k]-5;
			
			n[k]++;
		}
		
		
		while(in[k]>=1){
			
			in[k]=in[k]-1;
			
			n[k]++;
		}
		
//		printf("in[%d]=%d",k);
		
	}
	
	
	for(k=1;k<=r;k++){
		
		printf("%d\n",n[k]);
		
	}
	
	return 0;
}



Measured memory_bytes: 2052
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define pb push_back
#define all(v) v.begin(),v.end()
#define sort_1(v) sort(v.begin(),v.end())
#define sort_2(v) sort(v.begin(),v.end(),greater<ll>())
#define reverse(v) reverse(v.begin(),v.end())
typedef long long ll;
typedef long double la;
using namespace std;

int main(){
	int n;
    cin >> n;
    int money = 1000;
    while(1){
        if(money >= n){
            cout << money - n << endl;
            return 0;
        }
        money += 1000;
    }
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;++i)
using namespace std;
void insertionSort(int a[],int n){
  rep(i,1,n){
    int b=a[i];
    int j=i-1;
    while(j>=0&&a[j]>b){
      a[j+1]=a[j];
      j--;
    }
    a[j+1]=b;
    rep(i,0,n) cout<<a[i]<<(i==n-1?"\n":" ");
  }
}
int main(){
  int a[101],n;
  cin>>n;
  rep(i,0,n) cin>>a[i];
  rep(i,0,n) cout<<a[i]<<(i==n-1?"\n":" ");
  insertionSort(a,n);
  return 0;
}

Measured memory_bytes: 3072
H,W = map(int,input().split())
a = [list(input()) for _ in range(H)]

MOD = 10**9 + 7

# dp[i][j]: (i,j)までの経路の総数
dp = [[0] * W for _ in range(H)]

# 初期条件
dp[0][0] = 1

for i in range(H):
    for j in range(W):
        if i+1 < H and a[i+1][j] == ".":
            dp[i+1][j] += dp[i][j] % MOD
        if j+1 < W and a[i][j+1] == ".":
            dp[i][j+1] += dp[i][j] % MOD

print(dp[-1][-1] % MOD)

Measured memory_bytes: 88688
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<limits.h>

#define rep(i,begin,end) for(int i=begin; i<end; i++)
#define lld long long int

int main(){
    int n;
    lld a, b;
    scanf("%d %lld %lld", &n, &a, &b);
    lld x[n];
    rep(i, 0, n){
        scanf("%lld", &x[i]);
    }
    lld ans = 0;
    rep(i, 1, n){
        lld p = a*(x[i] - x[i-1]);
        if(p < b){
            ans += p;
        }else{
            ans += b;
        }
    }
    printf("%lld", ans);

    return 0;
}

Measured memory_bytes: 896
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();
    int A = sc.nextInt();
    int[] x = new int[N];

    for (int i = 0; i < N; i++) {
      x[i] = sc.nextInt();
    }

    sc.close();

    long[][][] dp = new long[N+1][N+1][2501];

    dp[0][0][0] = 1;

    for (int i = 1; i <= N; i++) {
      for (int j = 0; j <= N; j++) {
        for (int k = 0; k <= 2500; k++) {
          if (j > 0 && (k - x[i-1]) >= 0) {
            dp[i][j][k] = dp[i - 1][j][k] + dp[i - 1][j - 1][k - x[i - 1]];
          } else {
            dp[i][j][k] = dp[i - 1][j][k];
          }
        }
      }
    }

    long sum = 0;
    
		for (int k = 1; k <= N; k++) {
			sum += dp[N][k][k * A];
		}

    System.out.println(sum);

  }

}

Measured memory_bytes: 83536
mod = 10**9+7

# xと最上位bitが同じでx以下のもののスコア足し上げ
def countup(x, y):
    L1 = x.bit_length()
    x -= 1<<(L1-1)
    y -= 1<<(L1-1)
    L = x.bit_length()
    dp = [[[0, 0], [0, 0]] for _ in range(L+1)]
    # 立ってるbitがlこのもの
    dp[0][0][0] = 1
    for i in range(L):
        a = x&(1<<(L-1-i))
        b = y&(1<<(L-1-i))
        if a:
            if b:
                dp[i+1][0][0] = dp[i][0][0]
                dp[i+1][0][1] = 2*dp[i][0][1] % mod
                dp[i+1][1][0] = dp[i][1][0]
                dp[i+1][1][1] = (3*dp[i][1][1] + dp[i][0][1]) % mod
            else:
                dp[i+1][0][0] = dp[i][0][0]
                dp[i+1][0][1] = (dp[i][0][0] + 2*dp[i][0][1]) % mod
                dp[i+1][1][0] = (dp[i][0][0] + 2*dp[i][1][0]) % mod
                dp[i+1][1][1] = (3*dp[i][1][1] + dp[i][0][1] + dp[i][1][0]) % mod 
        else:
            if not b:
                dp[i+1][0][0] = dp[i][0][0]
                dp[i+1][0][1] = dp[i][0][1]
                dp[i+1][1][0] = 2*dp[i][1][0] % mod
                dp[i+1][1][1] = (3*dp[i][1][1] + dp[i][1][0]) % mod
            else:
                dp[i+1][0][1] = dp[i][0][1]
                dp[i+1][1][0] = dp[i][1][0]
                dp[i+1][1][1] = 3*dp[i][1][1] % mod
    return sum(dp[L][0]) + sum(dp[L][1]) % mod


def main():
    Left, Right = map(int, input().split())
    ans = 0
    while True:
        # print(bin(Right))
        bl = Left.bit_length()
        br = Right.bit_length()
        if bl == br:
            ans = (ans + countup(Right, Left)) % mod
            break
        else:
            ans = (ans + countup(Right, (1<<(br-1)))) % mod
            Right = (1<<(br-1))-1
    
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 68120
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf = 1012345678;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

int gcd(int a, int b)
{
  if (a%b==0){
    return(b);
  }
  else{
    return(gcd(b,a%b));
  }
}




int main(){
  int s;
  int v[1000000];
  cin >> v[0];
  int i = 0;
  int ans;
  while(1){
    i++;
    int num = v[i-1];
    if(num % 2 == 0){
      v[i] = num/2;
    }
    else v[i] = num*3+1;
    if(num == 4 || num == 2 || num == 1){
      ans = i+3;
      break;
    }
  }
  // rep(j,i) cout << v[j] << endl;
  cout << ans << endl;
}


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

int main() {
int n,k;
cin>>n>>k;
int a[n];
for(int i=0;i<n;i++) cin>>a[i];
int b[200005];
for(int i=0;i<200005;i++) b[i]=0;
for(int i=0;i<n;i++){
  b[a[i]]++;
}
int div=0;
for(int i=0;i<200005;i++){
  if(b[i]>0) div++;
}
sort(b,b+200005);
int idx=0;
int ans=0;
while(div>k){
  if(b[idx]>0){
    ans+=b[idx];
    div--;
  }
  idx++;
}
cout<<ans<<endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,ans=0;
  string n;
  cin>>a>>n;
  for(int i=0;i<a;i++){
    if(n[i]=='A' && n[i+1]=='B' && n[i+2] =='C')
      ans++;
  }
  cout<<ans<<endl;
  return(0);
}

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

int main(int argc, char **argv) {
  int i;
  int N, D;
  cin >> N >> D;

  vector<vector<int>> X(N, vector<int>(D));
  int ans = 0;

  for (int i = 0; i < N; i++) {
    for (int j = 0; j < D; j++) {
      cin >> X[i][j];
    }
    if (i > 0) {
      for (int k = 0; k < i; k++) {
        double sum = 0;
        for (int l = 0; l < D; l++) {
          sum += pow(X[i][l] - X[k][l], 2);
        }
        double tmp = pow(ceil(sqrt(sum)), 2);
        if (tmp == sum) {
          ans++;
        }
      }
    }
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Mod 998244353
#define Val(x) (((long long)x) % Mod)
#define maxn 3005
using namespace std;
int arr[maxn],dp[maxn];
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,S;
	cin >> n >> S;
	for(int i=1;i<=n;i++)
		cin >> arr[i];
	memset(dp,-1,sizeof dp);
	dp[0] = 0;
	int ans = 0;
	for(int i=1;i<=n;i++) {
		if(arr[i] > S)	continue;
		
		if(arr[i] == S)
			ans = Val(i * (n-i+1) + ans);
		else if(dp[S - arr[i]] != -1)
			ans = Val(dp[S - arr[i]] * (n-i+1) + ans);
			
		for(int j=S;j>arr[i];j--)
			if(dp[j - arr[i]] != -1) {
				if(dp[j] == -1)		dp[j] = 0;
				dp[j] = Val(dp[j] + dp[j - arr[i]]);
			}
		if(dp[arr[i]] == -1)	dp[arr[i]] = 0;
		dp[arr[i]] = Val(dp[arr[i]] + i);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
n, m = [int(i) for i in input().split()]
s = []
c = []
for i in range(m):
    tmp = [int(j) for j in input().split()]
    s.append(tmp[0])
    c.append(tmp[1])

for i in range(10 ** (n - 1) - int(n == 1) ,10 ** n):
    status = True
    for j in range(m):
        if(str(i)[s[j] - 1] != str(c[j])):
            status = False
    if(status):
        print(i)
        exit()
print(-1)


Measured memory_bytes: 3064
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>

using namespace std;

struct Node{
	bool operator<(const struct Node &arg) const{
		return weight < arg.weight;
	};
	int from,to,weight;
};

int parent[10000],height[10000];

int getParent(int id){
	if(parent[id] == id)return id;
	else{
		return parent[id] = getParent(parent[id]);
	}
}

bool isSame(int a, int b){
	return getParent(a) == getParent(b);
}

void unite(int a,int b){
	int a_parent = getParent(a);
	int b_parent = getParent(b);

	if(a_parent == b_parent)return;

	if(height[a_parent] > height[b_parent]){
		parent[b_parent] = a_parent;
	}else{
		if(height[a_parent] == height[b_parent])height[b_parent]++;
		parent[a_parent] = b_parent;
	}
}


int main(){

	int V,E;

	scanf("%d %d",&V,&E);
	Node nodes[E];

	for(int i = 0; i < V; i++){
		parent[i] = i;
		height[i] = 0;
	}

	for(int i = 0; i < E; i++){
		scanf("%d %d %d",&nodes[i].from,&nodes[i].to,&nodes[i].weight);
	}

	sort(nodes,nodes+E);

	int sum = 0;

	for(int i = 0; i < E; i++){
		if(!isSame(nodes[i].from,nodes[i].to)){
			sum += nodes[i].weight;
			unite(nodes[i].from,nodes[i].to);
		}
	}

	printf("%d\n",sum);

	return 0;
}

Measured memory_bytes: 3920
import sys
import fractions
input = lambda: sys.stdin.readline().rstrip()

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


def solve():

    gcd_f = [0] * N
    gcd_b = [0] * N

    gcd_f[0] = A[0]
    for i in range(N - 1):
        gcd_f[i + 1] = fractions.gcd(gcd_f[i], A[i + 1])

    gcd_b[0] = A[-1]
    for i in range(N - 1):
        gcd_b[i + 1] = fractions.gcd(gcd_b[i], A[-i - 2])

    ans = gcd_f[-2]
    ans = max(ans, gcd_b[-2])

    # print(gcd_f)
    # print(gcd_b)

    for i in range(N - 2):
        t = fractions.gcd(gcd_f[i], gcd_b[-3 - i])
        #print(gcd_f[i], gcd_b[- 3 - i])
        ans = max(ans, t)

    print(ans)


if __name__ == '__main__':
    solve()


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

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void print_YES_NO(bool answer){cout<<(answer?"YES":"NO")<<endl;}
void print_Yes_No(bool answer){cout<<(answer?"Yes":"No")<<endl;}
void print_POSSIBLE_IMPOSSIBLE(bool answer){cout<<(answer?"POSSIBLE":"IMPOSSIBLE")<<endl;}

vector<pair<string,pair<int,int> > > v1;

int main(){
	int n;
	int i,j,k;
	int a,b,c;
	string sa;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>sa>>b;
		v1.push_back(make_pair(sa,make_pair(-b,i)));
	}
	sort(v1.begin(),v1.end());
	for(i=0;i<v1.size();i++){
		cout<<v1[i].second.second+1<<endl;
	}
	
}


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

using namespace std;
#define ll long long
const int N=105,W=100005;
int n,w;
ll ar[N],br[N];
ll mem[N][W];
ll solve(int ind,int weight){
    if(weight<0){
        return -1e18;
    }
    if(ind==n){
        return 0;
    }
    if(mem[ind][weight]!=-1){
        return mem[ind][weight];
    }
    ll ret=0;
    ret=max(ret,max(solve(ind+1,weight),solve(ind+1,weight-ar[ind])+br[ind]));
    return mem[ind][weight]=ret;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    memset(mem,-1,sizeof mem);
    cin>>n>>w;
    for(int i=0;i<n;i++){
        cin>>ar[i]>>br[i];
    }
    cout<<solve(0,w)<<endl;
    return 0;
}

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

using ll = long long;

int INF = 1e9;

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

  for(a=0;a<=INF;a++){
    for(b=0;b<=a;b++){
      if(a*a*a*a*a + b*b*b*b*b == x){
        cout << a << " " << (-b) << endl;
        return 0;
      }
      if(a*a*a*a*a - b*b*b*b*b == x){
        cout << a << " " << b << endl;
        return 0;
      }
      //cout << a << ","<< b<<endl;
    }
  }


}


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

using namespace std;

#define gc getchar_unlocked
#define foi(i,n) for(int i=0;i<n;i++)
#define Foi(i,k,n) for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define fol(i,n) for(ll i=0;i<n;i++)
#define Fol(i,k,n) for(ll i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)   scanf("%d",&x)
#define sl(x)   scanf("%lld",&x)
#define ss(s)   scanf("%s",s)
#define pi(x)   printf("%d\n",x)
#define pl(x)   printf("%lld\n",x)
#define ps(s)   printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pl;
typedef vector<int>     vi;
typedef vector<ll>      vl;
typedef vector<pii>     vpii;
typedef vector<pl>      vpl;
typedef vector<vi>      vvi;
typedef vector<vl>      vvl;
int mpow(int base, int exp); 
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

vi g[N];
int a[N];

int mpow(int base, int exp) {
    base %= mod;
    int result = 1;
    while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
    }
    return result;
}

void ipgraph(int n, int m){
    int i, u, v;
    while(m--){
        cin>>u>>v;
        g[u-1].pb(v-1);
        g[v-1].pb(u-1);
    }
}

void dfs(int u, int par){
    for(int v:g[u]){
        if (v == par) continue;
        dfs(v, u);
    }
}


int main() {
    string s,t;
    cin>>s>>t;
    int count=0;
    for(int i=0;i<s.length();i++)   
        if(s[i]!=t[i])
            count++;
    cout<<count<<"\n";
    return 0;
}

Measured memory_bytes: 10952
#include <stdio.h>
int main(void){
        char str[256];
        int i;
        scanf("%s", str);
        for(i = 0; str[i] != '\0'; i++);
        for(i -= 1; i >= 0; i--){
                printf("%c", str[i]);
        }
        printf("\n");
        return 0;
}

Measured memory_bytes: 524
#include<bits/stdc++.h>
using namespace std;
#define int long
#define mod (1000000007)
main(){
  int n;
  string v,w;
  map<string,bool> m;
  cin>>n>>w;
  m[w]=true;
  while(--n){
    v=w;
    cin>>w;
    if(*(v.end()-1)!=w[0]||m[w])cout<<"No",exit(0);
    m[w]=true;
  }
  cout<<"Yes";
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;
#define ll long long
#define FOR(a,b,c) for(int a=b;a<=c;a++)
#define FORD(a,b,c) for(int a=b;a>=c;a--)
#define in(a) a=read()
#define out(a) printf("%lld\n",a)
ll read(){
    ll f=1,x=0;char c=getchar();
    while(c>'9'||c<'0'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();
    return x*f;
}

int main(){
	ll n,m,d;
	in(n);in(m);in(d);
	if(!d)printf("%.10lf",(double)(m-1)/n);
	 else printf("%.10lf",(double)2*(n-d)*(m-1)/n/n);
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
#define DBG(X) cout << #X << "=" << (X) << '\n';
#define SAY(X) cout << (X) << '\n';
#else
#define DBG(X)
#define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

std::string pad(int num)
{
    char buffer[4];
    std::snprintf(buffer, sizeof(buffer), "%03d", num);
    return buffer;
}

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

ll solve()
{
    ll A, B, N;

    std::cin >> A >> B >> N;

    ll x = min(N, B - 1);

    return (A * x) / B - A * (x / B);
}

int main()
{
    std::cout << solve() << std::endl;
//    solve();

    return 0;
}

Measured memory_bytes: 3588
// F - LCS
#include <bits/stdc++.h>
using namespace std;

int dp[3001][3001];

int main(){
	string S,T; cin>>S>>T;
	int N = S.size(), M = T.size();
	S = "*" + S; T = "*" + T;

	for(int s=1; s<=N; s++)
		for(int t=1; t<=M; t++)
			dp[s][t] = max(max(dp[s][t-1], dp[s-1][t]), dp[s-1][t-1] + (S[s]==T[t]));

	string ans;
	while(N>0 && M>0){
		if(dp[N][M]==dp[N-1][M]) N--;
		else if(dp[N][M]==dp[N][M-1]) M--;
		else{
			ans = S[N] + ans;
			N--; M--;
		}
	}
	cout<< ans <<endl;
}


Measured memory_bytes: 35456
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define MOD 1000000007
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define int long long
#define ALL(A) A.begin(),A.end()
using vi=vector<int>;
using vii=vector<vi>;
signed main(){
  int N,K,Q;
  cin>>N>>K;
  rep(i,0,N){
    int X;
    cin>>X;
    if(X==1){
      Q=i+1;
      break;
      }
    }
  int X=(Q-3+K)/(K-1);
  int Y=max(X*(K-1)+1,Q);
  cout<<X+(N-Y+K-2)/(K-1)<<endl;
}


Measured memory_bytes: 256
def productall(a):
    N = len(a)
    if N == 0: return [1]
    A = [1] * N + a[:]
    P = 10 ** 9 + 7
    k = 100
    K = k * 8
    pa1 = (1 << k * 4 + 16) - ((1 << k * 4 + 16) % P)
    pa2 = (1 << k * 2 + 24) - ((1 << k * 2 + 24) % P)
    pa3 = (1 << k + 28) - ((1 << k + 28) % P)
    def modP(x):
        x -= ((x & m1) >> k * 4 + 16) * pa1
        x -= ((x & m2) >> k * 2 + 24) * pa2
        x -= ((x & m3) >> k + 28) * pa3
        return x

    for i in range(N)[::-1]:
        if i == N - 1 or i and 1 << i.bit_length() - 1 == i:
            if i == N - 1:
                c = 2
            else:
                c *= 2
            m1 = int(("1" * (k * 4 - 16) + "0" * (k * 4 + 16)) * c, 2)
            m2 = int(("1" * (k * 6 - 24) + "0" * (k * 2 + 24)) * c, 2)
            m3 = int(("1" * (k * 7 - 28) + "0" * (k + 28)) * c, 2)
        A[i] = modP(A[2*i] * A[2*i+1])

    t = bin(A[1])[2:] + "_"
    return [int(t[-(i+1) * K - 1:-i * K - 1], 2) % P for i in range((len(t)+K-2) // K)]
def par(a):
    L = []
    while P[a] != a:
        L.append(a)
        a = P[a]
    for l in L:
        P[l] = a
    return a
def unite(a, b):
    pa = par(a)
    pb = par(b)
    if pa == pb: return
    if LEN[pa] < LEN[pb]:
        a, b, pa, pb = b, a, pb, pa
    P[pb] = pa
    if LEN[pa] == LEN[pb]: LEN[pa] += 1
    CNT[pa] += CNT[pb]
def cnt(a):
    return CNT[par(a)]

N = int(input())
P = [i for i in range(N)]
LEN = [1] * N
CNT = [1] * N
FULL = [0] * N
A = [int(a) - 1 for a in input().split()]
for i, a in enumerate(A):
    if a < 0: continue
    if par(i) != par(a):
        unite(i, a)
    else:
        FULL[i] = 1
for i in range(N):
    if FULL[i]:
        FULL[par(i)] = 1
X = []
Y = []
for i in range(N):
    if par(i) == i:
        if FULL[i] == 0:
            X.append(CNT[i])
        else:
            Y.append(CNT[i])
M = len(X)
mod = 10 ** 9 + 7
ans = (sum(X) + sum(Y) - len(Y)) * pow(N - 1, M, mod) % mod
L = productall([(a << 800) + 1 for a in X])
if M:
    fa = 1
    ans = (ans + M * pow(N - 1, M - 1, mod)) % mod
    for i, l in enumerate(L):
        if i == 0: continue
        ans = (ans - l * fa * pow(N - 1, M - i, mod)) % mod
        fa = fa * i % mod
print(ans)

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

int main()
{
	int N;
	int h[100000];
	long flog[100000];

	scanf("%d", &N);


	for (int i = 0; i < N; i++) {
		scanf("%d", &h[i]);
	}

	flog[0] = 0;
	flog[1] = abs(h[0] - h[1]);
	int a, b;
	for (int i = 2; i < N; i++) {
		a = flog[i - 1] + abs(h[i - 1] - h[i]);
		b = flog[i - 2] + abs(h[i - 2] - h[i]);

		flog[i] = a < b ? a : b;
	}

	printf("%ld", flog[N - 1]);

	return 0;
}

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

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

    vector<string> s(N);

    for (int i = 0; i < N; i++)
    {
        cin >> s[i];
    }

    vector<int> c(N);
    for (int i = 0; i < N; i++)
    {
        c[i] = 0;
        for (int j = 0; j < N; j++)
        {
            if (j == i) continue;

            if (s[i] > s[j]) c[i]++;
        }
    }

    int count = 0;
    string ans;
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N; j++)
        {
            if (count == c[j]) ans += s[j];
        }
        count++;
    }
    cout << ans;
}

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

typedef long long LL;
typedef long long ll;
#define SZ(a) int((a).size())
#define _REP(_1,_2,_3,_4,name,...) name
#define _REP4(i,b,e,s) for(decltype(e) _b=(b),_e=(e),i=_b+(0<(s)?0:(s));(0<(s)?i<_e:_e<=i);i+=(s))
#define _REP3(i,b,e) for(decltype(e) _b=(b),_e=(e),i=(_b<_e?_b:_b-1);(_b<_e?i<_e:_e<=i);(_b<_e?i++:i--))
#define _REP2(i,n) for(decltype(n) i=0,_n=(n);i<_n;i++)
#define _REP1(n) for(decltype(n) _i=0,_n=(n);_i<_n;_i++)
#define REP(...) _REP(__VA_ARGS__,_REP4,_REP3,_REP2,_REP1)(__VA_ARGS__)
#define FOR(it,c) for(auto&& it=begin(c);it!=end(c);it++)
#define ROF(it,c) for(auto&& it=rbegin(c);it!=rend(c);it++)

#define INT(n) int n;scanf("%d",&n)

int main(){
  LL x = 1LL, y = 1LL;
  function<LL(LL,LL,int,int)> srch = [&](LL l, ll r, int a, int t){
    if (l + 1 == r){
      return r;
    }
    else {
      ll c = (l + r) / 2;
      if (x <= a * c && y <= t * c){
        return srch(l, c, a, t); 
      }
      else {
        return srch(c, r, a, t);
      }
    }
  };
    
  INT(n);
  REP(n){
    INT(t); INT(a);
    LL tmp = srch(0, 1E18 / max(t, a), a, t);
    x = a * tmp; y = t * tmp;
  }
  printf("%lld\n", x + y);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,x) for(int i=0,i##_len=(x);i<i##_len;++i)
#define rep(i,a,b) for(int i=(a),i##_len(b);i<i##_len;++i)
#define All(x) begin(x),end(x)
#define rAll(x) rbegin(x),rend(x)
using namespace std;
using ll = long long;

int main(){
    int K;
    cin>>K;
    ll ans=0;
    rep(a,1,K+1) rep(b,1,K+1) rep(c,1,K+1){
        ans+=gcd(gcd(a,b),c);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3632
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
	int n = sc.nextInt();
    int a;
    int i;
    for(i = 0; i < n; i++){
      a = sc.nextInt();
      if(a % 2 == 0){
        if(a % 3 == 0 || a % 5 == 0){
          
        }
        else
        {
          break;
        }
      }
    }
    if(i == n){
      System.out.println("APPROVED");
    }
    else
    {
      System.out.println("DENIED");
    }
  }
}

Measured memory_bytes: 22868
a, b, c, x = [int(input()) for _ in range(4)]
cnt = 0
for i in range(min(a, int(x/500)) + 1):
    for j in range(min(b, int((x - 500 * i)/100)) + 1):
        if (x - 500 * i - 100 * j) % 50 == 0 and 0 <= (x - 500 * i - 100 * j) / 50 <= c:
            cnt += 1
print(cnt)


Measured memory_bytes: 3060
// 
// 
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define is_in(i, s) (s.find(i) != s.end())
#define all(x) (x).begin(),(x).end()
#define outl(x) cout<<x<<endl
#define outsp(x) cout<<x<<" "
typedef long long ll;
typedef pair<int,int> P;


#define MAX_N 100005
#define MAX_M 200005

vector<int> es[MAX_N];
int ans[MAX_N];
int n,m;



int main() {
	cin >> n>> m;
	rep(i,m){
		int a,b;
		cin >> a >> b;
		a--;b--;
		es[a].push_back(b);
		es[b].push_back(a);
	}	
	memset(ans,-1,sizeof(ans));
	queue<int> que;
	que.push(0);
	while(!que.empty()){
		int v = que.front();que.pop();
		rep(i,es[v].size()){
			if(ans[es[v][i]] == -1){
				ans[es[v][i]] = v;
				que.push(es[v][i]);
			}
		}
	}
	rep(i,n-1){
		if(ans[i+1]==-1){
			outl("No");
			return 0;
		}
	}
	outl("Yes");
	rep(i,n-1){
		outl(ans[i+1]+1);
	}

    return 0;
}



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

int main(){
    long int N;
    cin >> N;
    int rootN = std::pow(N,0.5);

    int c=1;
    for(int i=1; i<=rootN; i++){
        if (N % i == 0){
            c = i;
        }
    }

    cout << c + N/c -2 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using ll = long long;
const int INF = 2147483647;
// const ll INF = 1000000000000000000LL;

int main() {
	double a,v;
	double b,w;
	cin >> a >> v;
	cin >> b >> w;
	double t;
	cin >> t;
	bool can =true;
	if(b>a){
		if(a+t*v>=b+t*w)
			can = false;
	}
	else
		if(a-t*v<=b-t*w)
			can = false;
	if(can) cout << "NO" << endl;
	else cout << "YES" << endl;
	return 0;
}



Measured memory_bytes: 3724
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <map>
#include <stack>
#include <algorithm>
#include <climits>
#include <cmath>
#include <functional>
#include <utility>
#include <numeric>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define FOR(i, m, n) for (int i = (int)m; i < (int)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define REPe(e, mp) for (auto& e : mp)
#define all(x) x.begin(), x.end()
#define MOD 1000000007  // 1e9+7
using namespace std;
using ll = long long int;
using vecint = vector<int>;
using vecll = vector<ll>;
using vec2int = vector<vector<int>>;
using P = pair<int, int>;
////////////////////////////////////////////////
////////////////////////////////////////////////
int main() {
  ////////////////////////////////////////////////
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ////////////////////////////////////////////////
  int n;
  cin >> n;
  // vector<pair<ll, ll>> a(n);
  vecll p2(n + 1, 1LL);
  REP(i, n) {
    p2[i + 1] = p2[i] * 2LL;
    p2[i + 1] %= MOD;
  }
  map<pair<ll, ll>, ll> mp;
  ll cnt = 0;
  REP(i, n) {
    ll a, b;
    cin >> a >> b;
    if (a == 0 && b == 0) {
      cnt++;
      continue;
    }
    ll g = gcd(abs(a), abs(b));
    a /= g;
    b /= g;
    if (a == 0 && b != 0) {
      //(0,1)
      b = 1;
    } else if (b == 0 && a != 0) {
      //(1,0)
      a = 1;
    }
    if ((a < 0 && b > 0) || (a < 0 && b < 0)) {
      // (+a,-b) or (+a, +b)
      a *= -1LL;
      b *= -1LL;
    }
    mp[{a, b}]++;
  }
  ll ans = 1LL;
  map<pair<ll, ll>, int> seen;
  REPvec(itr, mp) {
    pair<ll, ll> p = itr->first;
    if (seen[p] > 0) continue;
    seen[p] = 1;
    pair<ll, ll> q = {p.second, -p.first};
    if (p.second < 0) {
      // p(+,-)->q(+,+)
      q = {-p.second, p.first};
    } else if (p.second == 0) {
      q = {0, 1};
    } else if (p.first == 0) {
      q = {1, 0};
    }

    if (p == q || mp.count(q) == 0) {
      // cout << "(" << p.first << "," << p.second << "), " << (ll)p2[mp[p]]
      //  << endl;
      ans *= (ll)p2[mp[p]];
      ans %= MOD;
    } else {
      seen[q] = 1;
      // cout << "(" << p.first << "," << p.second << "), (" << q.first << ","
      //      << q.second << ")" << endl;
      // cout << (p2[mp[p]] + p2[mp[q]] - 1LL) % MOD << endl;
      ans *= ((p2[mp[p]] + p2[mp[q]] + MOD) - 1LL) % MOD;
      ans %= MOD;
    }
    // cout << ans << endl;
  }
  ans += cnt;
  ans = ((ans + MOD) - 1LL) % MOD;
  cout << ans << endl;
}


Measured memory_bytes: 29808
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const int inf = 999999999;
const double pi = acos(-1);

#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}

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

int main(){
	int w,h,n;
	cin >> w >> h >> n;

	int x = 0,y = 0;

	rep(i,0,n){
        int xx,yy,a;
        cin >> xx >> yy >> a;

        switch(a){
            case 2:
                 w = min(w,xx);
                break;
            case 1:
                x = max(x,xx);
                break;
            case 3:
                y = max(y,yy);
                break;
            case 4:
                h = min(h,yy);
                break;
        }
       // cout << x << " " << y <<" " << w << " " << h <<endl;
	}

	if((w-x) <= 0 || (h-y) <= 0)cout << 0 << endl;
	else cout << (w-x)*(h-y)<< endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
  int r, i, x, d, l;
  scanf("%d%d%d", &r, &d, &x);
  for (i = 1;i <= 10; i++) {
    x=r*x-d;
    printf("%d\n", x);
  }
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }

void _main() {
  string w;
  cin >> w;

  set<char> st;
  fore(i, w) {
    if (st.count(i) == 1) st.erase(i);
    else st.insert(i);
  }

  if (st.size() == 0) cout << "Yes" << "\n";
  else                cout << "No" << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main(){
    string s; cin>>s;
    ll n=s.size();
    ll res=0;
    ll i=0;
    ll before=2;
    while(i<n){
        if(before==1 && s[i]==s[i-1]){
            if(i==n-1) break;
            res++; i+=2; before=2;
        }else if(before==1 && s[i]!=s[i-1]){
            res++; i++;
        }else if(before==2){
            res++; i++; before=1;
        }
    }
    cout<<res<<endl;
    return 0;
}

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

int main(void)
{
    int n, k;
    cin >> n >> k;
    int w = n / k;
    int ans = 1;
    while (w != 0)
    {
        w = w / k;
        ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll=long long;
using vec=vector<ll>;
using vect=vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i,n) for(ll i=0;i<n;i++)
#define Loop(i, m, n) for(ll i = m;i < n;i++)
#define pool(i,n) for(ll i=n;i>=0;i--)
#define Pool(i, m, n) for(ll i=n;i>=m;i--)
#define MAX 99999999999ll
#define MIN -99999999999ll
#define setbit bitset<8>
#define flagcount __builtin_popcount
#define flag(x) (1<<x)
#define flagadd(bit,x) bit|=flag(x)
#define flagpop(bit,x) bit&=~flag(x) 
#define flagon(bit,i) bit&flag(i)
#define flagoff(bit,i) !(bit & (1<<i))
#define all(v) v.begin(),v.end()
#define low2way(v,x) lower_bound(all(v),x)
#define high2way(v,x) upper_bound(all(v),x)
#define count2way(v,x) high2way(v,x)-low2way(v,x)
#define lower(v,x) low2way(v,x)-v.begin() //1番左が0、もし見つから無いならｎを出力
#define higher(v,x) high2way(v,x)-v.begin()-1 //1番左が0、もし見つからないならn-1を出力（注意）
#define putout(a) cout<<a<<endl
#define putout2(a,b) putout(a);putout(b)
#define putout3(a,b,c) putout(a);putout(b);putout(c)
#define putout4(a,b,c,d) putout(a);putout(b);putout(c);putout(d)
#define putout5(a,b,c,d,e) putout(a);putout(b);putout(c);putout(d);putout(e)
#define Gput(a,b) G[a].push_back(b)
#define cin1(a) cin>>a
#define cin2(a,b) cin>>a>>b
#define cin3(a,b,c) cin>>a>>b>>c
#define cin4(a,b,c,d) cin>>a>>b>>c>>d
#define cin5(a,b,c,d,e) cin>>a>>b>>c>>d>>e
#define sum(v) accumulate(all(v), 0ll)
#define gcd(x,y) __gcd(x,y)
ll ctoi(char c){
	if(c>='0'&&c<='9'){
		return c-'0';
	}
	return 0;
}
ll lcm(ll x,ll y){
  ll z=gcd(x,y);
  return x*y/z;
}
ll primejudge(ll n){
  if(n<2)return 0;
  else if(n==2)return 1;
  else if(n%2==0)return 0;
  double sqrtn=sqrt(n);
  Loop(i,3,sqrtn+1){
     if(n%i==0){
        return 0;
     }
     i++;
  }
  return 1;
}
int main() {
  cout << fixed << setprecision(30);
  ll n;
  cin>>n;
  vec a(n);
  loop(i,n)cin>>a[i];
  ll ans=0;
  ll now=a[0];
  loop(i,n){
    if(a[i]<=now)ans++;
    now=min(now,a[i]);
  }
  putout(ans);
}


Measured memory_bytes: 1792