akhauriyash/Code-Regression huggingface dataset:
_ = int(input())

def is_even(ls):
    if sum([x%2 for x in ls]) == 0:
        return True
    return False

def check(ls, c):
    if not is_even(ls):
        return c
    else:
        c += 1
        return check([x/2 for x in ls], c)

A = list(map(int, input().split()))
print(check(A, 0))

Measured memory_bytes: 3188
#include <stdio.h>
int main(void)
{

	int n,tmp=0;
	scanf("%d",&n);
	tmp += n / 25;
	n = n % 25;
	tmp += n / 10;
	n = n % 10;
	tmp += n / 5;
	n = n % 5;
	tmp += n / 1;
	printf("%d\n",tmp);
	
	return 0;
}


Measured memory_bytes: 2100
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<limits>
#include<iomanip>
#include<cmath>
#include<climits>
using namespace std;

#define rp(i,n) for(int i=0;i<n;i++)
#define rep(i,m,n) for(int i=m;i<=n;i++)
#define llrp(i,n) for(long long i=0;i<n;i++)
#define llrep(i,m,n) for(long long i=m;i<=n;i++)
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define elif else if
#define vcin(a); rp(i,a.size()){cin>>a[i];}
#define vcout(a); rp(i,a.size()){cout<<a[i]<<endl;}
#define llvcin(a); llrp(i,a.size()){cin>>a[i];}
#define llvcout(a); llrp(i,a.size()){cout<<a[i]<<endl;}
#define allchar(c) for(char c='a';c<='z';c++)
#define mp(a,b) make_pair(a,b)
#define bs(a,n) binary_search(a.begin(),a.end(),n)

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef long long ll;
typedef string S;
typedef pair<int,int> P;
typedef queue<int> qi;

const int mod=1e9+7;

ll modpow(ll a,ll b,ll p){
    if(b==0){
        return 1;
    }elif(b%2==0){
        return modpow((a*a)%p,b/2,p);
    }else{
        return (a*modpow(a,b-1,p))%p;
    }
}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,x;
    cin >> n >> x;
    vll a(n);
    llvcin(a);
    ll ans=LLONG_MAX;
    ll b[n][n];
    llrp(i,n){
        llrp(j,n){
            b[i][j]=LLONG_MAX;
        }
    }
    llrp(i,n){//何回ずらすか
        ll time=0;
        llrp(j,n){
            b[i][j]=min(b[i-1>=0?i-1:n+i-1][j],a[j-i>=0?j-i:n+j-i]);
            time+=b[i][j];
        }
        time+=x*i;
        ans=min(time,ans);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 31488
from math import gcd, sqrt, cos, radians, pi
from collections import defaultdict as d
from itertools import combinations as c

#n = int(input())
a, b = map(int, input().split())
#x, y, z = map(int, input().split())
#a, b, h, m = map(int, input().split())
#arr = list(map(int, input().split()))
#s = input()

#if ():
	#print()
#else:
	#print()
	
print(a * b)

Measured memory_bytes: 9480
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <climits>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
//typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
#define chmin(x, y) x = min(x, y);
#define chmax(x, y) x = max(x, y);
/*
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll max3(ll a, ll b, ll c){return max(a, max(b, c));};
ll min3(ll a, ll b, ll c){return min(a, min(b, c));};
ll max4(ll a, ll b, ll c, ll d){return max(max(a, b), min(c, d));};
ll min4(ll a, ll b, ll c, ll d){return min(min(a, b), min(c, d));};
ll max5(ll a, ll b, ll c, ll d, ll e){return max(max(a, b), max3(c, d, e));};
ll min5(ll a, ll b, ll c, ll d, ll e){return min(min(a, b), min3(c, d, e));};
*/
//const ll INFL = LLONG_MAX;//10^18 = 2^60
const ll INFL = 1LL<<60;
//const int INF = INT_MAX;
const int INF = 1 << 30;//10^9
ll MOD = 1000000007;
//ll MOD = 998244353;

vector<ll> dy = {0, 1, 0, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, 0, -1, 0, 1, -1, 1, -1, 0};

void pres(double A, ll x = 10){cout << fixed << setprecision(x) << A << endl;}
void BinarySay(ll x, ll y = 60){rep(i, y) cout << (x>>(y-1-i) & 1); cout << endl;}
ll cnt_bit(ll x){return __builtin_popcountll(x);}

ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x; k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

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

ll lcm(ll x, ll y){return x / gcd(x, y) * y;};


void solve(){
  int a, b;
  cin >> a >> b;
  if(a > b) swap(a, b);
  if(b == 2) cout << 3 << endl;
  else if(a == 2) cout << 1 << endl;
  else cout << 2 << endl;
}


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


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

using namespace std;

void solve() {
    int n;
    cin >> n;

    vector<int64_t> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }

    sort(a.begin(), a.end());

    vector<int64_t> b;
    for(int i = 0; i < n-1; i++){
        if(a[i] == a[i+1]) {
            b.push_back(a[i]);
            i++;
        }
    }

    int64_t result = 0;
    for(int i = 0; i < b.size(); i++){
        for(int j = i+1; j < b.size(); j++){
            result = max(result, b[i]*b[j]);
        }
    }

    cout << result << endl;
}

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

Measured memory_bytes: 1660
#include<iostream>
#include<cmath>

using namespace std;
int main(){
    int h1,h2,k1,k2,a,b,c,d;
    cin >> h1 >> h2;
    cin >> k1 >> k2;
    cin >> a >> b >> c >> d;
    int hcnt=a*h1+c*(h1/10)+b*h2+d*(h2/20);
    int kcnt=a*k1+c*(k1/10)+b*k2+d*(k2/20);
    if(hcnt>kcnt){
        cout << "hiroshi" << endl;
    }else if(kcnt>hcnt){
        cout << "kenjiro" << endl;
    }else{
        cout << "even" << endl;
    }
}


Measured memory_bytes: 3088
#![allow(unused_imports)]
#![cfg_attr(feature = "cargo-clippy", allow(redundant_field_names))]

use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::io::{self, BufWriter, Read, Write};
use std::ops::{Add, Div, Mul, Sub};
use std::str::{self, FromStr};
use std::{cmp, fmt};

fn main() {
    let n: u64 = {
        let mut sc = InputScanOnce::new(io::stdin(), 1024);
        sc.next()
    };
    let r = (1..n).map(|a| count(n - a) + count(a)).min().unwrap();
    println!("{}", r);
}

fn count(n: u64) -> u32 {
    n.to_string()
        .as_bytes()
        .iter()
        .map(|&c| (c - b'0') as u32)
        .sum()
}

struct InputScanOnce {
    buf: Vec<u8>,
    pos: usize,
}

#[allow(dead_code)]
impl InputScanOnce {
    fn new<R: Read>(mut reader: R, estimated: usize) -> Self {
        let mut buf = Vec::with_capacity(estimated);
        let _ = io::copy(&mut reader, &mut buf).unwrap();
        InputScanOnce { buf: buf, pos: 0 }
    }

    #[inline]
    fn next<T: FromStr>(&mut self) -> T
    where
        T::Err: fmt::Debug,
    {
        let mut start = None;
        loop {
            match (self.buf[self.pos], start.is_some()) {
                (b' ', true) | (b'\n', true) => break,
                (_, true) | (b' ', false) | (b'\n', false) => self.pos += 1,
                (_, false) => start = Some(self.pos),
            }
        }
        let target = &self.buf[start.unwrap()..self.pos];
        unsafe { str::from_utf8_unchecked(target) }.parse().unwrap()
    }

    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T>
    where
        T::Err: fmt::Debug,
    {
        (0..n).map(|_| self.next()).collect()
    }

    fn pairs<T1: FromStr, T2: FromStr>(&mut self, n: usize) -> Vec<(T1, T2)>
    where
        T1::Err: fmt::Debug,
        T2::Err: fmt::Debug,
    {
        (0..n).map(|_| (self.next(), self.next())).collect()
    }

    fn trios<T1: FromStr, T2: FromStr, T3: FromStr>(&mut self, n: usize) -> Vec<(T1, T2, T3)>
    where
        T1::Err: fmt::Debug,
        T2::Err: fmt::Debug,
        T3::Err: fmt::Debug,
    {
        (0..n)
            .map(|_| (self.next(), self.next(), self.next()))
            .collect()
    }

    fn mat<T: FromStr>(&mut self, m: usize, n: usize) -> Vec<Vec<T>>
    where
        T::Err: fmt::Debug,
    {
        (0..m).map(|_| self.vec(n)).collect()
    }

    fn strings_as_mat<T, F: FnMut(u8) -> T>(&mut self, h: usize, mut f: F) -> Vec<Vec<T>> {
        (0..h)
            .map(|_| {
                let l = self.next::<String>();
                l.as_bytes().iter().cloned().map(&mut f).collect()
            })
            .collect()
    }
}


Measured memory_bytes: 4352
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var N = int.Parse(ReadLine());
        var TA = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        var (T, A) = (TA[0], TA[1]);
        var H = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

        var ans = H.Select((x, i) => (t: T - x * 0.006, i)).OrderBy(x => Math.Abs(A - x.t)).First().i + 1;

        WriteLine(ans);
    }
}


Measured memory_bytes: 28752
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<string>
#include<vector>
#include<tuple>
#include<stack>
#include<iomanip>
#include<map>
using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int x=0;
	if (a == b)x++;
	if (b == c)x++;
	if (a == c) x++;
	if (x == 0)cout << 3;
	else if (x == 1) cout << 2;
	else cout << 1;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define si(x) scanf("%d",&x)
#define sii(x,y) scanf("%d%d",&x,&y)
#define siii(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define sl(x) scanf("%lld",&x)
#define sll(x,y) scanf("%lld%lld",&x,&y)
#define slll(x,y,z) scanf("%lld%lld%lld",&x,&y,&z)
 
#define ll long long
#define mp make_pair
#define pb push_back
#define nl printf("\n");
#define pf printf
#define rep(i,n) for(ll i=0;i<n;i++)
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define vint vector<int>
#define tci int t;scanf("%d",&t);while(t--)
const int maxn=10e6+4;
int n;
void solve()
{
}

int main()
{
    ifstream myFile("task.in");
    if(!myFile.fail())
    {
        assert(freopen("task.in", "r", stdin));
    }

    ll a,b;
    sll(a,b);
    if((a*b)%2==0)
    {
        cout<<"Even";
    }
    else
        cout<<"Odd";

    return 0;
}

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

#define ll long long
#define ull unsigned long long
#define N 100005
#define mod 1000000007
#define boost ios_base::sync_with_stdio(false);cin.tie(0)
#define prec(n) fixed<<setprecision(n)

#define pii pair<int,int> 
#define pll pair<ll,ll> 
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define vi vector<int> 
#define vll vector<ll>
#define all(c) c.begin(),c.end()
#define tr(it,c) for( typeof(c.begin()) it = c.begin() ; it!=c.end() ; it++)
int inf = INT_MAX ;
ll modulo(ll num,ll MOD=mod){ return ((num%MOD)+MOD)%MOD;} // for negative integer
ll power(ll b,ll e,ll MOD=mod){ll ans=1; while(e){if(e%2) ans=(ans*b)%MOD; b=(b*b)%MOD; e/=2;} return ans;}
ll inv(ll num,ll MOD=mod){ return power(modulo(num),MOD-2,MOD); }

int main()
{
    boost;
    ll dp[N][105],W,v[105],w[105],i,n,j;
    
    cin>>n>>W;
    for(i=0;i<n;i++) cin>>w[i]>>v[i];
    
    for(j=0;j<n;j++)
    {
        for(i=0;i<=W;i++)
        {
            if(j==0)
            {
                if(i<w[0])
                    dp[i][j] = 0;
                else 
                    dp[i][j] = v[0];
                    continue;
            }
            if(i<w[j]) 
                dp[i][j] = dp[i][j-1];
            else
                dp[i][j] = max(dp[i-w[j]][j-1]+v[j],dp[i][j-1]);
        }
    }
    cout<<dp[W][n-1]<<endl;
    
    return 0;
}

Measured memory_bytes: 82304
#include <atcoder/dsu>
#include <bits/stdc++.h>

#define MOD (long long)(1E9+7)
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace atcoder;
using namespace std;

int main(){
	int n, m;
	cin >> n >> m;
	int a, b;
  	dsu d(n);
  	vector<int> data(n+1);
	rep(i, m) {
    	cin >> a>> b;
      	d.merge(a-1,b-1);
    }
  	auto c = d.groups();
  	cout << c.size() - 1 << endl;
}

Measured memory_bytes: 9336
N = int(input())
S = list(input())
count_E = S.count("E")
count_W = 0
ans = count_E
for i in range(N):
    if S[i] == "E":
        count_E -= 1
    if S[i-1] == "W" and i != 0:
        count_W += 1
    if count_E + count_W < ans :
        ans = count_E + count_W
print(ans)

Measured memory_bytes: 5916
# n = int(input())
N, K = map(int, input().split())
A = list(map(int, input().split()))
# d = [list(map(int, input().split())) for _ in range(n)]
# s = input()

if (N-1)%(K-1):
    ans =(N-1)//(K-1)+1
else:
    ans = (N-1) // (K - 1)


print(ans)


# K = int(input())




Measured memory_bytes: 14008
/************************************
/ AUTHOR : YATHARTH GOSWAMI         /  
/ ALIAS : hacker_yg                 /
/ INSTITUTE : IIT Kanpur            /
************************************/
//          TEMPLATE                //

#include <bits/stdc++.h>

#define ll long long
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define F first
#define S second

using namespace std;

int main(){
    const double pi = 3.14159;
    int n;
    cin >> n;
    cout << 2*pi*n;
    return 0;
}




Measured memory_bytes: 3784
sx, sy, tx, ty = map(int, input().split())

dx = tx - sx
dy = ty - sy

res = ""

res = "R" * dx + "U" * dy + "L" * dx + "D" * (dy + 1) \
      + "R" * (dx + 1) + "U" * (dy + 1) + "L" + "U" \
      + "L" * (dx + 1) + "D" * (dy + 1) + "R"

print(res)


Measured memory_bytes: 9184
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().execute();
	}

	public void execute() {
		Scanner sc = new Scanner(System.in);
		final int N = sc.nextInt();

		int[] rate = new int[N];
		int over = 0;
		int minColors = 0;
		int maxColors = 0;

		boolean[] c = new boolean[8];
		
		for (int i = 0; i < N; i++) {
			rate[i] = sc.nextInt();
			if(rate[i]>=3200) {
				over++;
			}
			else {
				c[(int)(rate[i]/400)] = true;
			}
		}

		for (boolean b: c) {
			if (b) {
				minColors++;
			}
		}
		
		maxColors = minColors + over;
		System.out.printf("%d %d\n", Math.max(minColors, 1), maxColors);
		sc.close();
	}

}


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

const ll mod = 1000000007;

const int MAX = 1000010;

long long inv[MAX];

ll powmod(ll a, int p){
    ll ret = 1;
    while(p){
        if(p & 1) ret = ret * a % mod;
        a = a * a % mod;
        p >>= 1;
    }
    return ret;
}

// テーブルを作る前処理
void COMinit() {
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
    }
}
int main(){
    COMinit();
    int n; cin >> n;
    vector<ll> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    map<ll, int> mp;
    for(int i = 0; i < n; i++){
        ll tmp = a[i];
        for(int j = 2; j*j <= tmp; j++){
            int p = 0;
            while(tmp % j == 0){
                tmp /= j;
                p++;
            }
            if(p > 0) mp[j] = max(mp[j], p);
        }
        if(tmp != 1) mp[tmp] = max(mp[tmp], 1);
    }
    ll lcm = 1;
    for(auto p: mp){
        lcm *= powmod(p.first, p.second);
        lcm %= mod;
    }
    ll ans = 0;
    for(int i = 0; i < n; i++){
        ans += lcm * inv[a[i]];
        ans %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 11924
from collections import Counter

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

c = Counter(a)
s = list(set(a))
l = len(s)

if l == 1 and a[0] == 0:
    print('Yes')
    exit()
if len(a) % 3 == 0:
    if l == 2 and c[0] == n // 3:
        print('Yes')
        exit()
    if l == 3 and s[0] ^ s[1] ^ s[2] == 0:
        tmp = n//3
        if all(x == tmp for x in c.values()):
            print('Yes')
            exit()

print('No')


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

int main(){
    int n,d,x;
    cin>>n>>d>>x;
    int ans=x;
    for(int i=0;i<n;i++){
        int a; cin>>a;
        for(int j=1;j<=d;j+=a)ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
# Author: cr4zjh0bp
# Created: Thu Mar 12 19:50:26 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
nf = lambda: float(ns())
nfn = lambda y: [nf() for _ in range(y)]
nfa = lambda: list(map(float, stdin.readline().split()))
nfan = lambda y: [nfa() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

A, B, C, X = nin(4)

ans = 0
for i in range(A + 1):
    for j in range(B + 1):
        for k in range(C + 1):
            if i * 500 + j * 100 + k * 50 == X:
                ans += 1

print(ans)

Measured memory_bytes: 3064
#ifndef int
#define int char
#endif

printf (
  const char *,
  ...
  );

main ( void )
{
  int i, j;

  for ( j = 1; j <= 9; ++j )
  for ( i = 1; i <= 9; ++i )
  {
    printf ( "%dx%d=%d\n", j, i, j * i );
  }

  return ( 0 );
}

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

char T[52] = {0};
char S[52] = {0};

int mymatch(char *s, char *t){
	int len1 = strlen(s);
	int len2 = strlen(t);
	if(len1 < len2) return 0;

	int match = 0;
	int i, j;
	for(i = (len1 - len2); i >= 0; i--){
		int b = 1;
		for(j = i; j < i + len2; j++){
			if(s[j] == '?' || s[j] == t[j-i]){
				continue;
			}
			else{
				b = 0;
				break;
			}
		}
		if(b == 1){
			match = 1;
			break;
		}
	}
	if(match == 1){
		strncpy(s + i, t, len2);
	}
	return match;
}

int main(int argc, char* argv[]){
	scanf("%s", S);
	scanf("%s", T);

	int ret = mymatch(S, T);
	if(ret == 0){
		printf("UNRESTORABLE\n");
	}
	else{
		for(int i=0; i<50; i++){
			if(S[i] == '?'){ S[i] = 'a'; }
		}
		printf("%s\n", S);
	}
	return 0;
}

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// ====================================================================

int main() {
  int a, b, t;
  cin >> a >> b >> t;
  cout << t / a * b << endl;
}


Measured memory_bytes: 256
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>

#define int long long
#define REP(i,l,r) REPEAT(i,l,r,true) //[l, r)
#define rep(i,n) REP(i,0,n)           //[0, n)
#define REPEAT(i,l,r,condition) for(int i=(condition)?l:r-1;(condition)?i<r:i>=l;(condition)?++i:--i) // false<-[l, r)->true
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define fs first
#define sc second
#define show(...) cerr<<#__VA_ARGS__<<" = ";_DEBUG(__VA_ARGS__)
#define shows(n) for(auto z:n){cerr<<z<<", ";}cerr<<endl
#define showslr(n,l,r) cerr<<#n<<" = ";for(int i=l;i<r;i++){cerr<<n[i];}cerr<<endl //[l, r))

#define yes puts("Yes")
#define no puts("No")
#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

inline void io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}

void _DEBUG(){cerr<<endl;}
template<typename H,typename... T> void _DEBUG(H a,T...b){cerr<<a<<",";_DEBUG(b...);}

template<typename T> inline void in(T &e){cin>>e;}
template<typename H,typename... T>void in(H &a, T&... b){in(a);in(b...);}
template<typename T> inline void out(T e){cout<<e<<endl;}
template<typename H,typename... T> void out(H a, T... b){out(a);out(b...);}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;

const int MAX_H=100,MAX_W=100;

int h,w;
char grid[MAX_W][MAX_H];

vector<bool> contY,contX;

signed main(){
    io();
    in(h,w);
    contY.resize(h,false);
    contX.resize(w,false);
    rep(y,h){
        rep(x,w) in(grid[x][y]);
    }
    bool f;
    rep(y,h){
        f=true;
        rep(x,w){
            if(grid[x][y]=='#'){
                f=false;
                break;
            }
        }
        contY[y]=f;
    }

    rep(x,w){
        f=true;
        rep(y,h){
            if(grid[x][y]=='#'){
                f=false;
                break;
            }
        }
        contX[x]=f;
    }

    rep(y,h){
        rep(x,w){
            if(!contX[x] && !contY[y]){
                printf("%c",grid[x][y]);
            }
        }
        if(!contY[y]) puts("");
    }

    return 0;
}


Measured memory_bytes: 888
#include "iostream"
#include "algorithm"
#include "vector"
#include "string"
#include "cmath"

int main(int argc, char const *argv[]) {

  int NN, MM, X, Y;

  std::cin >> NN>>MM>>X>>Y;

  std::vector<int> x(NN+1);
  std::vector<int> y(MM+1);

  for (size_t i = 0; i < NN; i++) {
    std::cin >> x[i];
  }
  for (size_t i = 0; i < MM; i++) {
    std::cin >> y[i];
  }

  x[NN] = X;
  y[MM] = Y;

  sort(x.begin(), x.end());
  sort(y.begin(), y.end());

  // for (size_t i = 0; i < NN; i++) {
  //   std::cout <<"x" <<i << ":: "<<x[i] << '\n';
  // }
  // for (size_t i = 0; i < MM; i++) {
  //   std::cout <<"y" <<i << ":: "<< y[i] << '\n';
  // }



  // int x_max = x[NN-1];
  int x_max = x[NN];

  int y_min = y[0];
  //
  // std::cout << "x_max"<<x_max << '\n';
  // std::cout << "y_min"<<y_min << '\n';

  if (x_max >= y_min) {
    std::cout << "War" << '\n';
  }else{
    // int flag = 0;
    // for (size_t i = x_max+1; i <= y_min; i++) {
    //   if (i > X && i <= Y) {
    //     flag = 1;
    //     // break;
    //   }
    // }
    // if (flag == 1) {
    //   std::cout << "No War" << '\n';
    // }else{
    //   std::cout << "War" << '\n';
    // }

    std::cout << "No War" << '\n';
  }

  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.SortedSet;
import java.util.TreeSet;

public class Main {

  public static void main(String[] args) throws Exception {
    try (final var stdin = new InputStreamReader(System.in);
         final var br = new BufferedReader(stdin)) {
      br.readLine();
      final var c = br.readLine().toCharArray();

      final var rList = new TreeSet<Integer>();
      final var wList = new TreeSet<Integer>();
      for (int i = 0; i < c.length; i++) {
        if (c[i] == 'W') wList.add(i);
        if (c[i] == 'R') rList.add(i);
      }
      final var rSize = rList.size();
      final var wSize = wList.size();

      int count = 0;
      while (!rList.isEmpty() && !wList.isEmpty() && rList.last() > wList.first()) {
        int last = rList.last();
        int first = wList.first();
        rList.remove(last);
        wList.add(last);
        rList.add(first);
        wList.remove(first);
        count++;
      }

      System.out.println(Math.min(Math.min(count, rSize), wSize));
    }
  }
}


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

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  // ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n, m;
  cin >> n >> m;

  vP lst(n);
  rep(i, n) {
    ll a, b;
    cin >> a >> b;
    lst[i] = {a, b};
  }
  Sort(lst);

  priority_queue<ll> pq;
  ll ans = 0;
  ll j = 0;
  repLRE(i, 1, m) {
    while(lst[j].first <= i && j < n){
      pq.push(lst[j].second);
      j++;
    }
    if (pq.empty()) continue;
    ans += pq.top();
    pq.pop();
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 5864
#include <bits/stdc++.h>
#define For(i, begin, end) for(int i=begin;i<end;i++)
#define Rep(i, n) For(i,0,n)
#define Sort(v) sort(v.begin(),v.end())
using namespace std;

int main(){
  int r,g,b;
  cin>>r>>g>>b;
  if((10*g+b)%4==0)cout<<"YES";
  else cout<<"NO";

  return 0;
}

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

int main(){
  int n, l, c, s;
  string str, ans;
  map<int, string> m;
  m[1] = ".,!? ";
  m[2] = "abc";
  m[3] = "def";
  m[4] = "ghi";
  m[5] = "jkl";
  m[6] = "mno";
  m[7] = "pqrs";
  m[8] = "tuv";
  m[9] = "wxyz";
  cin >> n;
  for (int i = 0; i < n; ++i){
    cin >> str;
    c = 0;
    l = str.length();
    ans = "";
    s = 0;
    for (int j = 0; j < l; ++j){
      int S = str[j] - 48;
      if (s == S) c++;
      else  if (S == 0){
	c %= m[s].length();
	ans += m[s][c];
	c = -1;
	s = S;
      }else{
	s = S;
	c = 0;
      }
    }
    cout << ans << endl;
  }
  return 0;
}

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

using namespace std;
typedef long long ll;
priority_queue<ll, vector<ll>, greater<ll>> q;

int main(){
    ll K;
    cin >> K;
    for(int i=1;i<10;i++) q.push(i);
    for(int i=1;i<=K;i++){
        ll s = q.top();
        q.pop();
        if(i==K){
            cout << s << endl;
            break;
        }
        int n = s % 10;
        for(int j=-1;j<=1;j++){
            if(n + j >= 0 && n + j <= 9){
                q.push(n+j + s*10);
            }
        }
    }
    return 0;
}

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

int main(){
    string s, t; cin >> s >> t;
    int n = s.size();
    int m = t.size();
    s = ' ' + s;
    t = ' ' + t;
    int dp[n+1][m+1];
    memset(dp, 0, sizeof(dp));
    loop(i, 1, n+1){
        loop(j, 1, m+1){
            if(s[i] == t[j]) {
                dp[i][j] = dp[i-1][j-1] + 1;
            } else {
                dp[i][j] = (dp[i-1][j] >= dp[i][j-1]) ? dp[i-1][j] : dp[i][j-1];
            }
        }
    }

    int alen = dp[n][m];
    string ans = "";
    while(alen > 0){
        if(s[n] == t[m]){
            ans += s[n];
            n--; m--; alen--;
        } else if(dp[n][m] == dp[n-1][m]) n--;
        else m--;
    }
    reverse(all(ans));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 35456
import java.util.Scanner;
public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int d,cou=0,minj;
        int n = sc.nextInt();
        int arr[] = new int[n];
        for(int i=0;i<n;i++){
            arr[i]=sc.nextInt();
        }

        for(int i=0;i<=n-1;i++){
            minj=i;
            for(int j=i;j<=n-1;j++){
                if(arr[j] < arr[minj]){
                    minj=j;
                }
            }
            if(minj != i){
                d=arr[i];
                arr[i]=arr[minj];
                arr[minj]=d;
                cou++;
            }
        }

        for(int k=0;k<n;k++){
            System.out.print(arr[k]);
            if(k!=n-1){
                System.out.print(" ");
            }
        }
        System.out.println("\n"+cou);
        sc.close();
    }
}


Measured memory_bytes: 26360
#include<bits/stdc++.h>
#define ll long long int
#define pragi(a,b) for(ll i = a;i<b;i++)
#define pragj(a,b) for(ll j = a;j<b;j++)
#define pragk(a,b) for(ll k = a;k>=b;k--)
#define all(v) (v.begin(),v.end())
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define MP make_pair
#define MT make_tuple
#define F first
#define S second
#define KAKA ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
const int mod = 1e9 + 7;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef long double ld;
typedef pair<int, int> pii;
//typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef pair<ll, ll> pll;

void Compute(ll n)
{
    KAKA
    vl a(n),b(n),c(n);
    pragi(0,n)
    {
        cin>>a[i]>>b[i]>>c[i];
    }
    ll dp[n][3];
    tie(dp[n-1][0],dp[n-1][1],dp[n-1][2]) = MT(a[n-1],b[n-1],c[n-1]);
    pragk(n-2,0)
    {
        dp[k][0] = a[k] + max(dp[k+1][1],dp[k+1][2]);
        dp[k][1] = b[k] + max(dp[k+1][0],dp[k+1][2]);
        dp[k][2] = c[k] + max(dp[k+1][0],dp[k+1][1]);
    }
    cout<<max(dp[0][0],max(dp[0][1],dp[0][2]));



}
int main()
{
    KAKA
    ll n;
    cin>>n;
    Compute(n);
}

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

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	n %= 10;
	auto pronounce = [] (int n) {
		if (n == 3) {
			cout << "bon";
		} else if ((n >= 2 && n <= 4) || (n > 4 && n % 2)) {
			cout << "hon";
		} else {
			cout << "pon";
		}
	};
	pronounce(n);
}


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

#define fi first
#define se second

const int N = 505;

using namespace std;

int n;
int a[N * N];
int d[N * N];
vector < int > v[N * N];

int f(int x, int y)
{
        return (x - 1) * n + y;
}

int main()
{
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);

        ios_base::sync_with_stdio(false);

        cin >> n;
        for(int i = 1; i <= n; i++){
                for(int j = 1; j <= n; j++){
                        int x = f(i, j);
                        a[x] = 1;
                        if(i < n){
                                int y = f(i + 1, j);
                                v[x].push_back(y);
                                v[y].push_back(x);
                        }
                        if(j < n){
                                int y = f(i, j + 1);
                                v[x].push_back(y);
                                v[y].push_back(x);
                        }
                        d[x] = min(min(i - 1, n - i), min(j - 1, n - j));
                }
        }
        int res = 0;
        queue < int > q;
        for(int i = 1; i <= n * n; i++){
                int x;
                cin >> x;
                a[x] = 0;
                q.push(x);
                res += d[x];
                while(!q.empty()){
                        x = q.front();
                        q.pop();
                        for(int y: v[x]) if(d[x] + a[x] < d[y]){
                                d[y] = d[x] + a[x];
                                q.push(y);
                        }
                }
        }
        cout << res << "\n";
}


Measured memory_bytes: 19360
n = int(input())
list_original = [int(input()) for i in range(n)]
check = 101
count = 0

list_mid = sorted(list_original)
list = []

for j in range(1, n+1):
    list.append(list_mid[-j])

for k in list:
    if k < check:
        count += 1
        check = k

print(count)

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

int main()
{
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int ans;
    ans = 0;
    if (k >= a)
    {
        ans = a;
        k = k - a;
    }
    else
    {
        ans = k;
        k = 0;
    }
    if (k >= b)
    {
        k = k - b;
    }
    else
    {
        k = 0;
    }
    if (k >= c)
    {
        ans = ans - c;
    }
    else
    {
        ans = ans - k;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int x,a;
    cin >> x >> a;
    if (x < a) cout << 0 << endl;
    else cout << 10 << endl;
}

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

Measured memory_bytes: 256
#include<stdio.h>
int main(){

	int data[10000];

	int i = 1,n;

	while(1){

		scanf("%d",&data[i-1]);

		if(data[i-1] == 0){
			break;
		}

		i++;
	}

	for (n = 1;n < i; n++)
	{
		printf("Case %d: %d\n",n,data[n-1] );
	}



return 0;
}

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

typedef long long LL;

int main() {
    LL A, B, C;
    cin >> A >> B >> C;

    if (C > A + B + 1)
        cout << 2*B + A + 1;
    else
        cout << B + C;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,b,c,d,total;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    if(a>b){
        total=b*c+(a-b)*d;
        printf("%d\n",total);
    }
    else{
        total=a*c;
        printf("%d\n",total);
    }
    return 0;

}


Measured memory_bytes: 1708
#include <bits/stdc++.h>
using namespace std;
int n,A,B,depth,dep[100005],p[100005],T[100005];
vector < int > v[100005];
void Dfs(int x,int y) {
	p[x]=y,dep[x]=++depth,T[x]=0;
	for (int i=0; i<v[x].size(); i++) {
		if (v[x][i]==p[x]) continue;
		Dfs(v[x][i],x);
		T[x]=max(T[x],T[v[x][i]]);
	}
	T[x]++;
	--depth;
}
main () {
	cin>>n>>A>>B;
	for (int i=1; i<n; i++) {
		int x,y;
		cin>>x>>y;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	
	Dfs(B,B);
	
	int len=dep[A],ans=0,cur=0;
	while (A!=B) {
		ans=max(ans,len-cur-2+max(0,T[A]-1));
		cur++;
		A=p[A];
		if (len-cur<1+cur) break;
		if (len-cur==1+cur) {
			ans=max(ans,cur);
			break;
		}	
	}
	
	cout<<ans<<endl;
}

Measured memory_bytes: 10752
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a,b;
cin>>a>>b;
if(a%3==0||b%3==0||(a+b)%3==0)
{
cout<<"Possible"<<endl;
}
else
{
cout<<"Impossible"<<endl;
}
return 0;
}


Measured memory_bytes: 256
<?php
list($a,$b,$C)=explode(' ',trim(fgets(STDIN)));
$c=$C*pi()/180;
$h=$b*sin($c);
 
echo $a*$h/2
,PHP_EOL
,$a+$b+sqrt(pow($a-$b*cos($c),2)+pow($h,2))
,PHP_EOL
,$h
;

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

using namespace std;

struct DSU {
    int n;
    vector<int> ps;
    DSU(int n): n(n), ps(n) {
        for (int i = 0; i < n; ++i) {
            ps[i] = i;
        }
    }
    int get_parent(int i) {
        if (ps[i] == i) return i;
        return ps[i] = get_parent(ps[i]);
    }
    void merge(int i, int j) {
        i = get_parent(i);
        j = get_parent(j);
        ps[i] = j;
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<pair<int, int>> points(n);
    for (auto& point : points) {
        int x, y;
        cin >> x >> y;
        point.first = x;
        point.second = y;
    }
    int max_y = max_element(points.begin(), points.end(), [](auto p1, auto p2) { return p1.second < p2.second; })->second;
    DSU lines(max_y+1);
    sort(points.begin(), points.end());
    for (int i = 1; i < n; ++i) {
        if (points[i].first == points[i-1].first) {
            lines.merge(points[i].second, points[i-1].second);
        }
    }
    vector<int> line_count(max_y+1);
    vector<set<int>> parent_lines(max_y+1);
    for (auto point : points) {
        lines.get_parent(point.second);
        ++line_count[point.second];
        parent_lines[lines.get_parent(point.second)].insert(point.first);
    }
    long long sum = 0;
    for (int i = 0; i <= max_y; ++i) {
        sum += (int) parent_lines[lines.get_parent(i)].size() - line_count[i];
    }
    cout << sum << endl;
    return 0;
}


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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define fst first
#define snd second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define EPS (1e-9)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

const string YES = "";
const string NO  = "";

typedef long long ll;
typedef pair<int,int> ii;

#define MAX 200010
int n;
ll A[MAX], B[MAX];

set<ll> S;

ll getMed(vector<ll> vec) {
  sort(ALL(vec));
  if( (int)vec.size() % 2 == 0 ) {
    ll v1 = vec[(int)vec.size()/2];
    ll v2 = vec[(int)vec.size()/2-1];
    return v1+v2;      
  } else {
    return vec[(int)vec.size()/2] * 2LL;
  }
}

void dfs(int cur, deque<ll> &x) {
  if( cur >= n ) {
    vector<ll> vec;
    rep(i,(int)x.size()) vec.pb(x[i]);
    sort(ALL(vec));
    if( (int)vec.size() % 2 == 0 ) {
      ll v1 = vec[(int)vec.size()/2];
      ll v2 = vec[(int)vec.size()/2-1];
      S.insert(v1+v2);      
    } else {
      S.insert(vec[(int)vec.size()/2] * 2LL);
    }
    return;
  }
  for(ll v = A[cur]; v <= B[cur]; ++v) {
    x.pb(v);
    dfs(cur+1,x);
    x.pop_back();
  }
}

void bf() {
  deque<ll> deq;
  S.clear();
  dfs(0,deq);
  cout << "Answer: " << S.size() << endl;
  for(auto v : S) {
    //cout << "  " << v/2.0 << endl;
    cout << "  " << v << endl;
  }
}

ll fuckMini() {
  vector<ll> vec;
  rep(i,n) vec.pb(A[i]);
  return getMed(vec);
}

ll fuckMaxi() {
  vector<ll> vec;
  rep(i,n) vec.pb(B[i]);
  return getMed(vec);
}

void solve() {
  ll mini = fuckMini();
  ll maxi = fuckMaxi();
  ll diff = maxi - mini;
  if( n % 2 == 0 ) {
    cout << diff + 1LL << endl;
  } else {
    diff /= 2LL;
    cout << diff + 1LL << endl;
  }
  
  //bf();
}

int main() {
  cin >> n;
  rep(i,n) cin >> A[i] >> B[i];
  solve();
  return 0;
}


Measured memory_bytes: 10028
N, Y = map(int, input().split())
for n10k in range(N + 1):
    for n5k in range(N - n10k + 1):
        n1k = (N - n5k - n10k)
        if n10k * 10000 + n5k * 5000 + n1k * 1000 == Y:
            print(n10k, n5k, n1k)
            quit()
else:
    print(-1, -1, -1)


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <list>
#include <iomanip>
#include <vector>
#include <functional>
#include <algorithm>
#include <cstdio>
#include <random>
#include <ctime>
#include <cstdlib>
#include <unordered_map>
#include <string.h>
#include <iostream>

using namespace std;
typedef long long ll;
typedef pair<int, int> Pint;
typedef pair<ll, ll> Pll;
#define rep(begin, i, end) for (ll i = begin; i < (ll)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    ll N, K, A;
    cin >> N >> K;
    vector<ll> count(N);
    rep(0, i, N)
    {
        cin >> A;
        count.at(A - 1)++;
    }
    sort(all(count));
    int ans = 0;
    rep(0, i, count.size() - K)
    {
        ans += count.at(i);
    }
    cout << ans << endl;
}

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

int main(){
    int N;
    cin >> N;
    string n = to_string(N);
    int tmp = 0;
    for(char c:n) tmp += c - '0';
    if (N%tmp) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 256
from collections import deque

N = int(input())
tree =   [[] for _ in range(N)]
color = [-1] * N
color[0] = 0
for n in range(N-1):
  u, v, w = map(int,input().split())
  tree[u-1].append([v-1,w])
  tree[v-1].append([u-1,w])

q = deque()
q.append((0,-1))

while q:
  index, parent = q.pop()
  for target, d in tree[index]:
    if target == parent: continue
    if d%2 == 0:
      color[target] = color[index]
    else:
      color[target] = (color[index] + 1)%2
    q.append((target,index))
print(*color, sep="\n")

Measured memory_bytes: 46896
/*G - Longest Path*/
#include <bits/stdc++.h>

using namespace std;

int longestRoad(const vector <vector <int> >& grafo, int nodoIni);

int memo[100001];

int main(){
	
	int vertices;
	int aristas;

	cin >> vertices >> aristas;

	vector <vector <int> > grafo(vertices);

	int u, v;

	for (int i = 0; i < aristas; ++i)
	{
		cin >> u >> v;

		u--;
		v--;

		grafo[u].push_back(v);
	}

	int maximo = -1;

	memset(memo, -1, sizeof memo);

	for (int i = 0; i < vertices; ++i)
	{
		if(memo[i] != -1){
			maximo = max(maximo, memo[i]);
		}
		else{
			maximo = max( maximo, longestRoad(grafo, i) );
		}
	}

	cout << maximo;

	return 0;
}


int longestRoad(const vector <vector <int> >& grafo, int nodoIni){
	
	if(memo[nodoIni] != -1){
		return memo[nodoIni];
	}
		
	int maximo = 0;
	
	for (int i = 0; i < grafo[nodoIni].size() ; ++i)
	{
		maximo = max(maximo, 1 + longestRoad(grafo, grafo[nodoIni][i]));
	}
		
	memo[nodoIni] = maximo;

	return maximo;
}


Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)

const ll MOD = (ll)1e9 + 7;
const ll HIGHINF = (ll)1e18;

int main() {
  ll n, c; cin >> n >> c;
  vvll dmap(c, vll(c));
  REP(i, c) REP(j, c) cin >> dmap.at(i).at(j);
  vvll cmap(n, vll(n));
  REP(i, n) REP(j, n) cin >> cmap.at(i).at(j);
  vvll cc(3, vll(c));
  REP(i, n) REP(j, n) cc.at((i+j)%3).at(cmap.at(i).at(j)-1)++;
  ll ans = HIGHINF;
  REP(i, c) {
    REP(j, c) {
      if (i == j) continue;
      REP(k, c) {
        if (k==i || k==j) continue;
        ll tmp = 0;
        REP(l, c) tmp += cc.at(0).at(l) * dmap.at(l).at(i);
        REP(l, c) tmp += cc.at(1).at(l) * dmap.at(l).at(j);
        REP(l, c) tmp += cc.at(2).at(l) * dmap.at(l).at(k);
        ans = min(tmp, ans);
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2176
n = int(input())

ans = 0

for i in range(1, n + 1, 2):
    cnt = 0
    for j in range(1,n+1):
        if i % j == 0:
            cnt += 1
            if cnt > 8:
                break
    if cnt == 8:
        ans +=1
        

print(ans)


Measured memory_bytes: 2940
#define DivertaPC2019_C
#ifdef DivertaPC2019_C

#pragma comment (linker, "/STACK:256000000")
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define BUGAVOID(x) x
#define rep(...) BUGAVOID(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll;
typedef vector<int> vi; typedef vector<ll> vll; template<class T>using vv = vector<vector<T>>;
template<class T>vv<T> vvec(size_t n, size_t m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T>bool chmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
template<class T>bool chmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 28, MOD = 1e9 + 7; constexpr ll LINF = 1ll << 60; constexpr double EPS = 1e-6;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;

int N;
vector<string> S;
int ans = 0;
int Bstart = 0;
int Aend = 0;
int BstartAend = 0;

int main() {
    cin >> N;
    S.resize(N);
    rep(i, N) {
        cin >> S[i];

        rep(j, 1, S[i].size()) {
            if (S[i][j - 1] == 'A' && S[i][j] == 'B') ans++;
        }

        if (S[i][0] == 'B' && S[i].back() != 'A') Bstart++;
        if (S[i].back() == 'A' && S[i][0] != 'B') Aend++;
        if (S[i][0] == 'B' && S[i].back() == 'A') BstartAend++;
    }

    if (BstartAend > 0) {
        ans += BstartAend - 1;

        if (Bstart > 0) {
            ans++;
            Bstart--;
        }
        if (Aend > 0) {
            ans++;
            Aend--;
        }

        ans += min(Bstart, Aend);
    }
    else {
        ans += min(Bstart, Aend);
    }

    write(ans);
}

#endif

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

using ll = long long;
using vi = vector<int>;
using vi2 = vector<vector<int>>;
#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;

#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl;

#define sz(x) (int)(x).size()
#define HOGE cout << "hoge" << endl;
using P = pair<ll,ll>;

template<typename T>inline istream& operator>>(istream&i,vector<T>&v)
{REP(j,sz(v))i>>v[j];return i;}

const int INF = 1e9;

int main(){
    int n;
    cin >> n;
    vector<ll> l(n);
    REP(i,n) cin >> l[i];
    int ans = 0;
    for(int i = 0; i<n-2; i++){
        for(int j = i+1; j<n-1; j++){
            for(int k = j+1; k<n; k++){
                ll a, b, c;
                a = l[i];
                b = l[j];
                c = l[k];
                if(a+b>c && b+c>a && c+a>b && a!=b && b!=c && c!=a) ans++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3604
using System;

namespace atcoderA
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int X = Convert.ToInt32(input[0], 16);
            int Y = Convert.ToInt32(input[1], 16);
           
            if (X < Y)
            {
                Console.WriteLine("<");
            }
            else if (X > Y)
            {
                Console.WriteLine(">");
            }
            else
            {
                Console.WriteLine("=");
            }
        }
    }
}

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

bool isprime(int x) {
  if (x == 2) return true;
  else if(x < 2 || x % 2 == 0) return false;
  int i = 3;
  while(i <= sqrt(x)) {
    if( x % i == 0 ) return false;
    i = i + 2;
  }

  return true;
}

int main() {
  int a, d, n;
  while(cin >> a >> d >> n){
    if(a == 0 && d == 0 && n == 0) break;
    int i = 0, j = 0;
    int sum;
    while(true) {
      sum = a + i * d;
      if(isprime(sum))j++;
      if(j == n) {
        cout << sum << endl;
        break;
      }
      i++;
    }
  }

  return 0;
}

Measured memory_bytes: 3064