akhauriyash/Code-Regression huggingface dataset:
/*
author: Apoorv Singh
*/
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
 
typedef vector <int> vi;
typedef pair <int, int> pii;
typedef vector <long long> vll;
typedef pair <long long, long long> pll;
#define pb push_back   
#define all(c) c.begin(), c.end()
#define For(i, a, b) for (long long i = a; i < b; ++i)
#define Forr(i, a, b) for (long long i = a; i > b; --i)
#define um unordered_map
#define F first
#define S second
#define ll long long 
#define endl "\n"
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define fast_io() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout << name << " : " << arg1 << endl;  
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

template <class X>
void printarr(X arr[], int n) {
	for (int i = 0; i < n; ++i)
		cout << arr[i] << ' ';
	cout << endl;
}
 
template <class T, class cmp = less<T>> using ordered_set = tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
 
ll modulo = 1e9 + 7;

ll fpow(ll a, ll n) {
	ll ans = 1;
	while (n) {
		if (n&1) ans = (ans*a)%modulo;
		a = (a*a)%modulo; n = n >> 1;
	}
	return ans;
}

void solve() {
	int arr[5];
	int ans = 0;
	for (int i = 0; i < 5; ++i) {
		cin >> arr[i];
		if (arr[i] == 0) {
			ans = i+1;
		}
	}	
	cout << ans << endl;
}

int main() {
	fast_io();
	int t = 1;
	// cin >> t;
	while (t--) solve();
	return 0;
}

Measured memory_bytes: 3600
#define _GLIBCXX_DEBUG
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <chrono>
#include <stack>
#include <string>
#include <bitset>
#include <unordered_map>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <tuple>
#include <iomanip>
#include <random>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <fstream>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define in insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
void solve(){
    ll n;
    cin >> n;
    ll a = sqrt(n);
    while(n % a != 0) a--;
    ll b = n/a;
    cout << a + b - 2;
}
int main(){
    speed;
    int t = 1;
    //cin >> t;
    while(t--) solve();
}

Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons;

void main()
{
    auto ab = readln.split.to!(int[]);
    auto A = ab[0];
    auto B = ab[1];

    writeln(A <= 8 && B <= 8 ? "Yay!" : ":(");
}

Measured memory_bytes: 256
#include<stdio.h>
char tgt[100][100];
int h_offset[4]={1,0,-1,0};
int w_offset[4]={0,1,0,-1};
int main(void){
    int h,w,i,j,k,flg,x,y;
    char tmp;
    scanf("%d %d",&h,&w);
    for(i=0;i<h;i++){
        for(j=0;j<w;j++){
            scanf("%c",&tmp);
            if(tmp!='\n'){
                tgt[i][j]=tmp;
            }else{
                j--;
            }
        }
    }
    flg=0;
    for(i=0;i<h;i++){
        for(j=0;j<w;j++){
            if(tgt[i][j]=='#'){
                flg=1;
                for(k=0;k<4;k++){
                    x=j+w_offset[k];
                    y=i+h_offset[k];
                    if(0<=  x <=100 && 0<= y <=100){
                        if(tgt[y][x]=='#'){
                            flg=0;
                            break;
                        }
                    }
                }
                if(flg==1){
                    printf("No\n");
                    return 0;
                }
            }
        }
    }
    printf("Yes\n");
    return 0;
}

Measured memory_bytes: 128
#import collections
#aa = collections.Counter(a) # list to list
def readInts():
  return list(map(int,input().split()))
mod = 10**9 + 7
def main():
    n,y = readInts()
    wa = 0

    for i in range(n+1):
        for j in range(n+1):
            if i+j > n:
                break
            y1000 = (y - 10000 * i - 5000 * j)//1000
            if i + j + y1000 == n:
                print(i,j,y1000)
                exit()
    print(-1,-1,-1)
    exit()


if __name__ == '__main__':
  main()


Measured memory_bytes: 3060
#include<stdio.h>
int main()
{
    int n,i;
    scanf("%d",&n);
    if(n==25) printf("Christmas\n");
    if(n==24) printf("Christmas Eve\n");
    if(n==23) printf("Christmas Eve Eve\n");
    if(n==22) printf("Christmas Eve Eve Eve\n");
    return 0;
}


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

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);

        int n = in.nextInt(), q = in.nextInt();

        RUpdateQ rUpdateQ = new RUpdateQ(n);

        for (int i = 0; i < q; i++) {
            int cmd = in.nextInt();
            if (cmd == 0) {
                int s = in.nextInt(),
                        t = in.nextInt(),
                        x = in.nextInt();
                rUpdateQ.update(s, t, x);
            }
            if (cmd == 1) {
                int index = in.nextInt();
                System.out.println(rUpdateQ.find(index));
            }
        }


    }
}

class RUpdateQ{
    int[] heap;
    int n;

    static int _heap_size(int n) {
        int pow2 = 1;
        while (pow2 < n) {
            pow2 *= 2;
        }
        return pow2 * 2;
    }

    RUpdateQ(int n) {
        this.n = n;
        heap = new int[_heap_size(n)];
        Arrays.fill(heap, Integer.MAX_VALUE);
    }


    public void update(int s, int t, int x) {
        update(s, t+1, x, 0, n, 1);

    }

    private void update(int s, int t, int x, int l, int r, int ih) {
        if (s >= t) {
            return;
        }
        if (s == l && t == r) {
            heap[ih] = x;
            return;
        }
        // else: [s,t) in [l, r)
        if (heap[ih] >= 0) {
            // broadcast to next level
            heap[ih * 2] = heap[ih];
            heap[ih * 2 + 1] = heap[ih];
            // indicate multi val
            heap[ih] = -1;
        }

        int mid = (l + r) / 2;
        update(Math.max(s, l), Math.min(mid, t), x, l, mid, ih * 2);
        update(Math.max(s, mid), Math.min(t, r), x, mid, r, ih * 2 + 1);
    }

    public int find(int index) {
        return find(index, 0, n, 1);
    }

    private int find(int index, int l, int r, int ih) {
        if (heap[ih] >= 0) {
            return heap[ih];
        }else {
            int mid = (l + r) / 2;
            if (index < mid) {
                return find(index, l, mid, ih * 2);
            }else {
                return find(index, mid, r, ih * 2 + 1);
            }
        }
    }
}



Measured memory_bytes: 115192
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		long H = sc.nextLong();
		long W = sc.nextLong();

		if(H == 1 || W == 1) {
			System.out.println(1);
		} else if(H * W % 2 == 0) {
			System.out.println(H * W / 2);
		} else {
			System.out.println((H * W / 2) + 1);
		}
	}
}

Measured memory_bytes: 21716
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <fstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <iomanip>
#include <stdio.h>
#include <string.h>
#include <random>
#include <functional>

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

using std::map;
using std::set;
using std::bitset;
using std::vector;
using std::string;
using std::multimap;
using std::multiset;
using std::deque;
using std::queue;
using std::stack;
using std::pair;
using std::iterator;

using std::sort;
using std::stable_sort;
using std::reverse;
using std::max_element;
using std::min_element;
using std::unique;
using std::ios_base;
using std::swap;
using std::fill;

using std::setprecision;
using std::fixed;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef string S;

ll min(ll a, ll b) {return a < b ? a : b;}
ll min(int a, ll b) {return a < b ? a : b;}
ll min(ll a, int b) {return a < b ? a : b;}
ll min(int a, int b) {return a < b ? a : b;}

ll max(ll a, ll b) {return a > b ? a : b;}
ll max(int a, ll b) {return a > b ? a : b;}
ll max(ll a, int b) {return a > b ? a : b;}
ll max(int a, int b) {return a > b ? a : b;}

namespace MySpace{

};

#define F(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define fi first
#define se second
#define re return
#define all(x) (x).begin(), (x).end()
#define int long long

const int N = 5010;
const int MOD = 1e9 + 7;

int n, m;

int f(int x)
{
    int c = 0;
    while (x % 2 == 0) x /= 2, c++;
    return c;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m;
    n = (1 << n);
    m = (1 << m);
    for (int i = 1; i < n; cout << "\n", i++) for (int j = 1; j < m; j++) cout << (f(i) == f(j));
}


Measured memory_bytes: 1280
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
    int n,sum=0;
    while(cin>>n)
    {
        int m=n;
        sum=0;
        while(n)
        {
            sum+=n%10;
            n=n/10;
        }
        if(m%sum==0) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long int sum_of_digits(long long int n){
    long long int sum=0;
    long long int dd=0;
while(n!=0){
        dd=n%10;
sum=sum+dd;
    n=n/10;
}
return sum;
}
int main() {
    string s,t;
    cin>>s>>t;
    int count=0;
    for(int i=0;i<3;i++){
        if(s[i]==t[i]){
            count++;
        }
    }
    cout<<count<<endl;



}


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

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

using namespace std;
using ll = long long;
int mod = 1000000007;

void solve();

int main(void){
    ll N, A, B;
    cin >> N >> A >> B;
    if((A < B && N < 2) || A > B) cout << 0 << endl;
    else if(A == B) cout << 1 << endl;
    else{
        ll n = B-A+1;
        ll k = N-2; //答えはk(n-1) + 1
        cout << k*(n-1)+1 << endl;
    }
    return 0;
}

void solve(){}

Measured memory_bytes: 256
S = input()
T = input()
n = len(S)

# Sのi文字目以降で最初に文字Cが登場するindex
res = [[n]*26 for _ in range(n+1)]
for i in reversed(range(n)):
    for j in range(26):
        res[i][j] = res[i+1][j]  # 一旦そのままの値を引き継いだ後に、今みているS[i]については若い番号で更新する
    res[i][ord(S[i])-ord("a")] = i  # 今後ろから見ていて、同じアルファベットが前の方で見つかったらより若い番号で更新されていく

# 与えられているのはindex
# nにはアクセスできないから、今後現れない文字はnで与えられている
# str_list = [chr(i + ord('a')) for i in range(26)]
# str_list = ' '.join(str_list)
# print(str_list)
# for r in res:
#     print(r)
# nに辿り着いたら26で割った余りを足す
set_S = set(list(S))
for i in range(len(T)):
    if T[i] not in set_S:
        print(-1)
        exit()
cnt = 0
tmp = 0
for i in range(len(T)):
    # T[i]を探しにいく
    if tmp == n:
        cnt += n
        tmp = 0
    elif res[tmp % n][ord(T[i])-ord("a")] == n:  # もうそのループでは見つからないなら
        if tmp == 0:
            print(-1)
            exit()
        cnt += n
        tmp = 0
    tmp = res[tmp % n][ord(T[i])-ord("a")]  # 0が手に入る
    tmp += 1
cnt += tmp
print(cnt)


Measured memory_bytes: 36096
#include <stdio.h>
#include <stdlib.h> 
#define MAX 36

typedef struct card{
  char mark;
  int value;
}CARD;
 
void swap(CARD *x,CARD *y){
  CARD temp;
  temp=*x;
  *x=*y;
  *y=temp;
}
 
 
void bubbleSort(CARD *A,int n){
  int i,j;
  for(i=0; i<n-1; i++){
    for(j=n-1; j>i; j--){
      if(A[j].value < A[j-1].value) swap(&A[j],&A[j-1]);
    }
  }
}
 
void selectionSort(CARD *A,int n){
  int i,j,minj,flag;
    for ( i = 0 ; i < n ; i++ ) {
        minj = i;
        flag = 0;
        for ( j = i ; j < n ; j++ ) {
            if ( A[j].value < A[minj].value ) {
                minj = j;
                flag = 1;
            }
        }
        if (flag) {
            swap(&A[i], &A[minj]);
        }
    }
}

void printStable(CARD *A1, CARD *A2, int N)
{
  int i,cnt=0;
  for ( i = 0 ; i < N ; i++ ) {
    if (A1[i].mark == A2[i].mark) {
      cnt++;
    }
  }
  printf("%s\n", ((cnt == N) ? "Stable" : "Not stable"));
}
 
int main(){
  CARD R1[MAX];
  CARD R2[MAX];
  int i,j,n;
  scanf("%d",&n);
  for(i=0; i<n; i++){
    scanf(" %c%d",&R1[i].mark,&R1[i].value);
    R2[i]=R1[i];
  }
  bubbleSort(R1,n);
  for(i=0; i<n; i++){
    printf("%c%d",R1[i].mark,R1[i].value);
    if(i!=n-1)printf(" ");
  }
  printf("\n");
  printf("Stable\n");
  selectionSort(R2,n);
  for(i=0; i<n; i++){
    printf("%c%d",R2[i].mark,R2[i].value);
    if(i!=n-1){
      printf(" ");
    }
  }
  printf("\n");
  printStable(R1, R2, n);
  return 0;
}

Measured memory_bytes: 612
#include<cstdio>
#include<algorithm>

int main() {
    int a,g,s;
    scanf("%d",&a);
    s=a/10;
    g=a%10;
    if(g==9||s==9){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    return 0;

}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<string>


struct square{
    bool road;
    bool up;
    bool down;
    bool right;
    bool left;
    
    void init(){
        road = false;
        up = false;
        down = false;
        right = false;
        left = false;
    }
};

int walk(std::vector< std::vector< square > >& map, std::vector< std::vector< int > >& walk_min, int i, int j, int dist);

int main(){
    int H, W;
    std::cin >> H >> W;
    std::vector< std::vector< square > > map(H, std::vector< square >(W));
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            map[i][j].init();
        }
    }
    std::string S;
    for(int i=0; i<H; i++){
        std::cin >> S;
        for(int j=0; j<W; j++){
            bool tmp = S[j] == '.';
            map[i][j].road = tmp;
            if(i != 0){
                map[i-1][j].down = tmp;
            }
            if(i != H-1){
                map[i+1][j].up = tmp;
            }
            if(j != 0){
                map[i][j-1].right = tmp;
            }
            if(j != W-1){
                map[i][j+1].left = tmp;
            }
        }
    }
    
    int dist_max = 0;
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            if(!map[i][j].road){ continue; }
            std::vector< std::vector< int > > walk_list(H, std::vector< int >(W, 400));
            walk(map, walk_list, i, j, 0);
            for(int a=0; a<H; a++){
                for(int b=0; b<W; b++){
                    if(walk_list[a][b] != 400 && dist_max < walk_list[a][b]){
                        dist_max = walk_list[a][b];
                    }
                }
            }
        }
    }
    std::cout << dist_max << std::endl;
    
    return 0;
    
}

int walk(std::vector< std::vector< square > >& map, std::vector< std::vector< int > >& walk_list, int i, int j, int dist){
    if(walk_list[i][j] > dist){
        walk_list[i][j] = dist;
        if(map[i][j].up){
            walk(map, walk_list, i-1, j, dist+1);
        }
        if(map[i][j].down){
            walk(map, walk_list, i+1, j, dist+1);
        }
        if(map[i][j].right){
            walk(map, walk_list, i, j+1, dist+1);
        }
        if(map[i][j].left){
            walk(map, walk_list, i, j-1, dist+1);
        }
    }
    return 0;
}
    



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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

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

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

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main(void){
    ll N,M; cin >> N >> M;
    if(N == 1 && M == 1) cout << 1 << endl;
    else if(N == 1) cout << M-2 << endl;
    else if(M == 1) cout << N-2 << endl;
    else cout << (N-2)*(M-2) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <deque>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <fstream>
#define int long long
#define debug(x) cerr << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const ll LINF = 1e18;
const double EPS = 1e-9;


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

  int n[10] = {0};
  rep(i,3) {
    int x,y;
    cin>>x>>y;
    n[x]++;n[y]++;
  }
  string ans = "YES";
  if(!n[1] || !n[2] || !n[3] || !n[4]) {
    ans = "NO";
  } else if (n[1] == 3 || n[2] == 3 || n[3] == 3 || n[4] == 3) {
    ans = "NO";
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
//  A bug is never just a mistake. It represents something bigger. An error of thinking that makes you who you are.
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MAXN 500009
const int INF = 1.01e9;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define db(x) cerr << #x << " = " << x << endl
#define db2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n";
#define db3(x, y, z) cerr << "(" << #x << ", " << #y << ", " << #z << ") = (" << x << ", " << y << ", " << z << ")\n"
#define dbv(a) cerr << #a << " = "; for (auto xxxx: a) cerr << xxxx << " "; cerr << endl


int main(){
		
	ios::sync_with_stdio(false);
    cin.tie(0);
    int x,n;
    cin>>x>>n;
    unordered_map<int,int> p;
    rep(i,0,n){
    	int temp;
    	cin>>temp;
    	p[temp]=1;
    }
    int ans = x;
    for(int i=0;i<=105;++i){
    	if(!p[x-i]){ans = x-i;break;}
    	if(!p[x+i]){ans = x+i;break;}
    }
    cout<<ans<<"\n";
}

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

int N, M;

int main() 
{
    cin >> N;
    map<string, int> m;
    for (int i = 0; i < N; i++) 
    {
        string t; cin >> t;
        m[t]++;
    }

    cin >> M;
    for (int i = 0; i < M; i++)
    {
        string t; cin >> t;
        m[t]--;
    }

    int ans = 0;
    for (auto i = m.begin(); i != m.end(); i++) 
    {
        ans = max(ans, i->second);
    }
    cout << ans << endl;
}

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

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=(n); i--)
#define LREP(lst,itr) for(auto itr = lst.begin(); itr != lst.end(); ++itr)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define P(s) cout<<(s)<<endl
#define P2(a, b) cout<<(a)<<" "<<(b)<<endl
#define P3(a, b, c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl
#define V2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main(){
    int N;
    cin >> N;
    vector<int> vec(N);
    REP(i,0,N){
        cin >> vec[i];
    }
    int min=vec[0], ans=1;
    REP(i,1,N){
        if(min>vec[i]){
            min=vec[i];
            ans++;
        }
    }
    P(ans);
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			
			int N = scan.nextInt();
			int[]a = new int[N];
			int kiko = 0;
			int yon = 0;
			for(int i = 0;i<N;i++) {
				a[i] = scan.nextInt();
				if(a[i]%2==1)kiko++;
				if(a[i]%4==0)yon++;
			}
			
			int kisu = N/2+N%2;//kisu個より多い奇数があったらダメ
			
			if(kiko>kisu) {
				System.out.println("No");
			}else{//限界より小さい奇数の数
				if(kisu==0) {
					System.out.println("Yes");
				}else {
					if(N%2==1&&kiko==N/2+1) {
						if(yon+1==kiko)System.out.println("Yes");
						else System.out.println("No");
					}else{
						if(yon>=kiko)System.out.println("Yes");
						else System.out.println("No");
					}
				}
				
			}
			
		}
		
		
	}
		

}


Measured memory_bytes: 50472
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;

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

int a[30];
int main(void){
	int i, j, n;
	for(;;){
		scanf("%d", &n);
		if(!n)break;
		rep(i, n)scanf("%d", &a[i]);
		j = 0;
		for(int x = 32;x;){
			x -= (x - 1) % 5;
			printf("%d\n", x);
			x = max(0, x - a[j]); j = (j + 1) % n;
			printf("%d\n", x);
		}
	}
}

Measured memory_bytes: 3200
#include<stdio.h>

int A[1000000],n;

/* 二分探索 */
int binarySearch(int key){
  int left = 0, right = n, mid;
  
  while(left < right){
    mid = (left + right) /2;
    if(A[mid] == key) return 1;
    else if(A[mid] < key) left = mid + 1;
    else right = mid;
  }
  
  return 0;
}

int main(){
  int i, q, key, sum=0;
  
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&A[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&key);
    if(binarySearch(key)) sum++;
  }

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

  return 0;
}



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

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

LL a,b,c,k;

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

Measured memory_bytes: 3624
import java.util.Scanner;
 
public class Main {
 
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    int NM = N + M;
    System.out.println((NM * (NM - 1))/2 - (N * M));
  }
}

Measured memory_bytes: 23508
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <vector>

using namespace std;

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

#define PB push_back
#define MP make_pair

#define FOR(prom, a, b) for(int prom = (a); prom < (b); prom++)
#define FORD(prom, a, b) for(int prom = (a); prom > (b); prom--)
#define FORDE(prom, a, b) for(int prom = (a); prom >= (b); prom--)
#define R1(a) do{scanf("%d", &(a));}while(0)
#define R2(a, b) do{scanf("%d%d", &(a), &(b));}while(0)
#define R3(a, b, c) do{scanf("%d%d%d", &(a), &(b), &(c));}while(0)
#define SV(vec) do{int s_v_;scanf("%d", &(s_v_));vec.PB(s_v_);}while(0)
#define MM(co, cim) memset((co), (cim), sizeof((co)))
#define DEB(x) cerr << ">>> " << #x << " : " << x << endl;
#define INF 1000000007

int n;

int main ()
{
  bool res = false;
  R1(n);
  while (n)
  {
    if ((n % 10) == 7) res = true;
    n /= 10;
  }
  printf("%s\n", res ? "Yes" : "No");
  return 0;
}


Measured memory_bytes: 3760
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,d=0;
	cin>>a;
	for(int i=1;i<=a;i++)
	{
		cin>>b;
		cin>>c;
		if(b==c)
		{
			d++;
		}
		else
		{
			d=0;
		}
		if(d==3)
		{
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
	return 0;
}


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

using namespace std;

const long long INF = 1e18;
const int N = 3e5;
const int MOD = 998244353;
const double EPS = 1e-9;

const double PI = acos(-1);


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int n;
    cin >> n;
    long long sum = 0;
    for (int i = 1; i <= n; i++)
        sum += i;
    for (int i = 3; i <= n; i += 3)
        sum -= i;
    for (int i = 5; i <= n; i += 5)
        sum -= i;
    for (int i = 15; i <= n; i+= 15)
        sum += i;
    cout << sum;
}

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

#define MOD 1000000007
#define fastio std::ios_base::sync_with_stdio(false);
#define ll long long
#define matrix vector <vector <ll> >

int A[210];
int dp[100010][210];

int ans(int X, int n) {
    if(n == 1) 
        return X%A[n-1];

    if(dp[X][n] != -1)  return dp[X][n];
    
    return dp[X][n] = (ans(X%A[n-1], n-1) + (1LL*ans(X, n-1)*(n-1))%MOD)%MOD;
}

int main(){

    fastio;
    
    int n, X;
    cin >> n >> X;
    for(int i = 0; i < n; i++) {
        cin >> A[i];
    }
    sort(A, A+n);

    for(int i = 0; i < 100010; i++) {
        for(int j = 0; j < 210; j++) {
            dp[i][j] = -1;
        }
    }

    cout << ans(X, n);

    return 0;
}


Measured memory_bytes: 82432
#include <bits/stdc++.h>
using namespace std;
#define int long long
int xorupto(int x){
    if (x%4==0){
        return x;
    }
    else if (x%4==1){
        return 1;
    }
    else if (x%4==2){
        return x+1;
    }
    return 0;
}
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int A;
    int B;
    cin >> A >> B;
    int C = xorupto(B);
    int D = xorupto(A-1);
    cout << (C^D);
}


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

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define FORR(i, a, b) for(int i = (a); i > (b); --i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef priority_queue<int> PQ;
typedef priority_queue<int, V, greater<int>> PQG;

const int INF = 1e9;
const int MOD = 998244353;
const ll LINF = 1e18;

ll x[5], N;

int main() {
    cin >> N;
    REP(i, 5) cin >> x[i];
    sort(x, x + 5);
    ll ans = N / x[0] + 4;
    if(N % x[0]) ans++;
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std; 
int main(){
    string S;
    cin >> S;
    int L = S.size();
    string ans = "AC";
    if(S[0] != 'A'){
ans = "WA"; }
    int cnt = 0;
    for(int i = 1; i < L; ++i){
        if(isupper(S[i])){
            if(i == 1 || i == L - 1 || S[i] != 'C'){
ans = "WA"; }
++cnt; }
    }
    if(cnt != 1){
ans = "WA"; }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int N = sc.nextInt();
   int[] Ai = new int[N];
   for(int i = 0;i<N;i++) Ai[i] = sc.nextInt(); 

   Arrays.sort(Ai);
   
   System.out.println(Ai[N-1]-Ai[0]);
 }
}

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

int main(){
  int height, list[10];

  for(int i=0; i<10; i++){
    cin >> height;
    list[i] = height;
  }

  for(int i=0; i<9; i++){
    for(int j=9; j>i; j--){
      if(list[j]>list[j-1]){
	swap(list[j], list[j-1]);
      }
    }
  }

  for(int i=0; i<3; i++){
    cout<<list[i]<<endl;
  }
}

Measured memory_bytes: 1164
#include <iostream>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;

int main() {
    int n, h;
    cin >> n;
    int ans = 0, mx = 0;
    rep(i,n) {
        cin >> h;
        if (mx <= h) {
            mx = h;
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3144
a,b=(int(x) for x in input().split())
c,d=(int(x) for x in input().split())
e,f=(int(x) for x in input().split())
g,h=(int(x) for x in input().split())
i,j=(int(x) for x in input().split())
k,l=(int(x) for x in input().split())
m,n=(int(x) for x in input().split())

if a<b:
    print(b-a)
else:
    print(a-b)
    
if c<d:
    print(d-c)
else:
    print(c-d)
    
if e<f:
    print(f-e)
else:
    print(e-f)
    
if g<h:
    print(h-g)
else:
    print(g-h)
    
if i<j:
    print(j-i)
else:
    print(i-j)
    
if k<l:
    print(l-k)
else:
    print(k-l)
    
if m<n:
    print(n-m)
else:
    print(m-n)


Measured memory_bytes: 5612
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <limits>
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define pint_INF 2000000000
#define ll_INF 	9223372036854775807
#define MOD 1000000007
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvll vector<vector<long long>>
#define vvc vector<vector<char>>
#define vll vector<long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
#define sysp system("PAUSE")
#define pno cout << "no" << endl
#define pyes cout << "yes" << endl
#define pYes cout << "Yes" << endl
#define pNo cout << "No" << endl
#define pNO cout << "NO" << endl
#define pYES cout << "YES" << endl
#define endl "\n"
#define pi 3.14159265358979
using namespace std;
using ll = long long;
#define int ll

signed main(){
    int H,W,M;
    cin >> H >> W >> M;
    vvi bombs(M);
    vi row_wise(H);
    vi column_wise(W);
    rep(i,M){
        int h,w; cin >> h >> w;
        --h; --w;
        row_wise[h]++;
        column_wise[w]++;
        bombs[i] = {h,w};
    }
    int rowmax = *max_element(ALL(row_wise));
    int rowmax_cnt = 0;
    int colmax = *max_element(ALL(column_wise));
    int colmax_cnt=  0;
    set<int> row_wise_boolean;
    set<int> column_wise_boolean;
    for(int i = 0; i < H; i++){
        if(row_wise[i] == rowmax){
            row_wise_boolean.insert(i);
            rowmax_cnt++;
        }
    }

    for(int j = 0; j < W; j++){
        if(column_wise[j] == colmax){
            column_wise_boolean.insert(j);
            colmax_cnt++;
        }
    }

    int max_total = rowmax_cnt * colmax_cnt;
    int Nbombs_in_premises = 0;
    for(auto coor : bombs){
        bool row_flag = row_wise_boolean.find(coor[0]) != row_wise_boolean.end();
        bool col_flag = column_wise_boolean.find(coor[1]) != column_wise_boolean.end();
        if(row_flag && col_flag){
            Nbombs_in_premises++;
        }
    }

    int ans = rowmax + colmax;
    if(Nbombs_in_premises == max_total){
        ans--;
    }

    cout << ans << endl;
    sysp;
}

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

int main(){
    int n,t;
    cin >> n >> t;
    vector<int> c(n),u(n);
    for(int i=0;i<n;i++){
        cin >> c[i] >> u[i];
    }
    int ans = 1001;
    for(int i=0;i<n;i++){
        if(u[i]<=t){
            ans = min(ans,c[i]);
        }
    }

    if(ans == 1001) cout << "TLE" << endl;
    else cout << ans << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
queue<pair<int,int> > q;
queue<int> dist;
int n,m,maxx=0;
char w[21][21];
char t[21][21];
int dx[] = {0, -1, +0, +1, +0};
int dy[] = {0, +0, +1, +0, -1};
int check(int x,int y)
{
    if(x<=0 || x>n || y<=0 || y>m || (w[x][y]=='#') || t[x][y]==1)
        return -1;
    return 1;
}
int lee(int x1,int y1)
{
    int a,b,l,max2=0;
    while(!q.empty())
        q.pop();
    while(!dist.empty())
        dist.pop();
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
            t[i][j]=0;
    }
    q.push({x1,y1});
    t[x1][y1]=1;
    dist.push(0);
    while(!q.empty())
    {
        if(dist.front()>max2) max2=dist.front();
        for(int i=1;i<=4;i++)
        {
            a=q.front().first+dx[i];
            b=q.front().second+dy[i];
            l=dist.front();
            if(check(a,b)==1)
            {
                q.push({a,b});
                dist.push(l+1);
                t[a][b]=1;
            }

        }
        q.pop();
        dist.pop();
    }
    return max2;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
            cin>>w[i][j];
    }
    int maxx=0;
    for(int x1=1;x1<=n;x1++)
    {
        for(int y1=1;y1<=m;y1++)
        {
            if(w[x1][y1]=='#') continue;
            int val=lee(x1,y1);
            if(val>maxx)
                maxx=val;
        }
    }
    cout<<maxx;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll ; 
typedef long double ld ;
typedef pair<ll , ll> pll ;

const ll N = 2e3 + 30 , Mod = 1e9 + 7 ;
const ll SQ = 330 ;

ll n , k ;
vector<ll> G[N] ;
vector<pll> E ;
ll d[N][N] , d2[N] ;
void bfs(ll x) {
	d[x][x] = 0 ;
	queue<ll> q ;
	q.push(x) ;
	while (q.size()) {
		ll v = q.front() ;
		q.pop() ;
		for (auto u : G[v]) {
			if (d[x][u] > d[x][v] + 1) {
				d[x][u] = d[x][v] + 1 ;
				q.push(u) ;
			}
		}
	}
	
}
void solve1() {
	ll ans = 1e18 ;
	for (int i = 0 ; i < n - 1  ; i ++) {
		memset(d2 , 63, sizeof(d2)) ;
		queue<ll> q ;
		d2[E[i].F] = d2[E[i].S] = 0 ;
		q.push(E[i].F) ;
		q.push(E[i].S) ;
		while (q.size()) {
			ll v = q.front() ;
			q.pop() ;
			for (auto u : G[v]) {
				if (d2[u] > d2[v] + 1) {
					d2[u] = d2[v] + 1 ;
					q.push(u) ;
				}
			}
		}
		ll cur = 0 ;
		for (int i =  1 ; i <= n ; i ++) if (d2[i] > (k - 1) / 2) cur ++ ;
		ans = min(ans , cur ) ; 
	}
	cout << ans ;
	exit(0) ;
}
void solve2() {
	ll ans = 1e18 ;
	for (int i = 1 ; i <= n ; i ++) {
		ll cur = 0 ;
		for (int j = 1 ; j <= n ; j ++) {
			if (d[i][j] > (k / 2)) cur ++ ;
		}
		ans = min(ans , cur) ;
	}
	cout << ans ;
	exit(0) ;
}
int main () {
    ios::sync_with_stdio(0), cin.tie(0) ;
    cin >> n >> k ;
    for (int i = 0 ; i < n  - 1; i ++) {
    	ll v , u ;
    	cin >> v >> u ;
    	G[v].pb(u) ;
    	G[u].pb(v) ;
    	E.pb({v , u}) ;
	}
	memset(d , 63 , sizeof(d)) ;
	for (int i = 1  ; i <= n ; i ++) bfs(i) ;
	if (k & 1) solve1() ;
	else solve2() ;
    
    return (0) ;
}

Measured memory_bytes: 32640
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <cstdlib>
#include <algorithm>
using namespace std;

int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { 
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main(){
int N;
cin >> N;
if(N % findSumOfDigits(N) == 0)cout << "Yes" << endl;
else cout << "No" << endl; 

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
            int m;
            cin>>m;
            long long sum=0,ans=0;
            long long a[m+1],b[m+1];
            memset(b,0,sizeof(b));
            for(int j=1;j<=m;j++)
            {
                cin>>b[j];
                sum+=b[j];

            }
         //   cout<<sum<<endl;

               printf("%lld\n",sum-m);

}


Measured memory_bytes: 3744
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
using ll = long long;
#define rep(i, j, n) for(int i = (j); i < (n); ++i)
#define rrep(i, j, n) for(int i = (n) - 1; (j) <= i; --i)
constexpr ll MOD = 1000000007;
constexpr ll INF = 1LL << 60;

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

	int a[17], x[17][17], y[17][17];
	rep(i, 0, n) {
		cin >> a[i];
		rep(j, 0, a[i]) {
			cin >> x[i][j] >> y[i][j];
			--x[i][j];
		}
	}

	// 矛盾・真偽不明なのに正直
	int ans = 0;
	rep(bit, 0, 1 << n) {
		vector<int> st(n, 2);
		bool ok = true;
		rep(i, 0, n) {
			if (bit >> i & 1) {
				if (st[i] == 0) ok = false;
				rep(j, 0, a[i]) {
					if (st[x[i][j]] != 2 && st[x[i][j]] != y[i][j]) ok = false;
					else st[x[i][j]] = y[i][j];
				}
			}
		}

		rep(i, 0, n) {
			if ((bit >> i & 1) == 0 && st[i] == 1) {
				ok = false;
			}
          	if (bit >> i & 1 && st[i] == 0) {
              ok = false;
            }
		}

		if (ok) ans = max(ans, __builtin_popcount(bit));
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 3656
#import math
#import itertools
import numpy as np
#from collections import deque

INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))

def do():
    n,m=INTM()
    ls=[]
    rs=[]
    for i in range(m):
        l,r=INTM()
        ls.append(l)
        rs.append(r)
    
    ans=min(rs)-max(ls)+1
    if ans<=0:
        ans=0
    print(ans)



    
if __name__=='__main__':
    do()

Measured memory_bytes: 34656
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::{i32, i64, u32, u64, usize, f64};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{VecDeque, HashMap, BTreeMap, HashSet, BTreeSet};
#[allow(unused_imports)]
use std::io::{stdout, Write, BufWriter};
#[allow(unused_imports)]
use std::mem::{swap};

fn main() {
    input! {
        n: usize,
        k: usize,
        balls: [i32; n],
    }
    let mut counters: Vec<i32> = Vec::new();
    let mut ltable = HashMap::new();
    let mut j = 0;
    for ball in balls {
        match ltable.get(&ball) {
            Some(&i) => counters[i] += 1,
            None => {
                ltable.insert(ball, j);
                counters.push(1);
                j += 1;
            },
        }
    }
    let mut to_rm = 0;
    let mut kinds = counters.len();
    let mut counters = {
        counters.sort();
        counters.into_iter()
    };
    while k < kinds {
        to_rm += counters.next().unwrap();
        kinds -= 1;
    }
    println!("{}", to_rm);
}


Measured memory_bytes: 19572
#include<bits/stdc++.h>
using namespace std;
  
int main(){
  
  long long N, K, i, j;
  cin >> N >> K;
  long long d, A;
  
  vector<int> Hantei(N, 0);
  
  for (i = 0; i < N; i++){
    cin >> d;
    for (j = 0; j < d; j++){
      
      cin >> A;
      Hantei.at(A - 1) = 1;
    }
  }
  
  long long goukei = 0;
  for (i = 0; i < N; i++){
    
    goukei += Hantei.at(i);
  }
  
  cout << N - goukei << endl;
  return 0;
}

Measured memory_bytes: 3604
#include<iostream>
#include<string>
using namespace std;
int x[21][21],ans=0,w,h;
string d[21];
void f(int i,int j){
	ans++;
	x[i][j]=1;
	if(i+1<h){
		if(x[i+1][j]==0 && d[i+1][j]=='.')
		f(i+1,j);
	}
	if(i-1>=0){
		if(x[i-1][j]==0 && d[i-1][j]=='.')
		f(i-1,j);
	}
	if(j+1<w){
		if(x[i][j+1]==0 && d[i][j+1]=='.')
		f(i,j+1);
	}
	if(j-1>=0){
		if(x[i][j-1]==0 && d[i][j-1]=='.')
		f(i,j-1);
	}
}
int main(){
	while(cin>>w>>h,w){
		int a,b;
		ans=0;
		for(int i=0;i<21;i++){
			for(int j=0;j<21;j++){
				x[i][j]=0;
			}
		}
		for(int i=0;i<h;i++){
			cin>>d[i];
			for(int j=0;j<w;j++){
				if(d[i][j]=='@'){
					a=j;
					b=i;
				}
			}
		}
		f(b,a);
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1228
from sys import stdin, stdout
n = int(stdin.readline())
nums = list(map(int, stdin.readline().strip().split()))

for num in nums:
    if num == 0:
        print(0)
        exit()
        
if max(nums)>10**18:
    print(-1)
else:
    nums.sort(reverse=True)

    ans = 1
    for num in nums:
        ans*=num
        if ans > 10**18:
            ans = -1
            break
    
    print(ans)

Measured memory_bytes: 84632
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;


int main(){
    int n, m;
    cin >> n >> m;
    string s;
    cin >> s;
    set<int> data;
    rep(i, n+1) {
        if (s[i]=='0') data.insert(i);
    }
    vector<int> ans;
    int now = n;
    while (now!=0) {
        auto it = data.lower_bound(now-m);
        if (now-*it==0) {
            cout << "-1" << endl;
            return 0;
        } 
        ans.push_back(now-*it);
        now = *it;
    }
    
    rep(i, ans.size()) {
        cout << ans[ans.size()-1-i] << " ";
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 5752
#include <iostream>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <time.h>
#include <stdio.h>
#include <vector>
#define int long long
using namespace std;
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
int mypow(int x, int y) {
	if (y == 0)return 1;
	if (y % 2)return mypow(x, y - 1)*x;
	else return mypow(x, y / 2)*mypow(x, y / 2);
}
int Max(int x, int y) {
	if (x > y)return x;
	else return y;
}
int Min(int x, int y) {
	if (x < y)return x;
	else return y;
}
int kai(int x) {
	int cnt = 1;
	if (x == 0)return 1;
	cnt = kai(x - 1);
	return x * cnt;
}
inline void shoki()
{
	srand((unsigned int)time(NULL));
}

/*Library End!*/

signed main() {
	int a, b;
	cin >> a >> b;
	cout << a + b / 2 << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		//整数値を入力
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		int sum = 0;

		for(int i = 1 ; i <= n ; i++) {
			if(i >= k + 1) {
				sum += y;
				continue;
			}
			sum += x;
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 22868
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#define EPS 1e-9
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define LL long long
const int MOD = 1E9+7;
const int N = 1000000+5;
const int dx[] = {0,0,-1,1,-1,-1,1,1};
const int dy[] = {-1,1,0,0,-1,1,-1,1};
using namespace std;

LL a[21]= {1, 2, 4, 5, 8, 10, 13, 14, 18, 21, 26, 28, 33, 36, 40,
            41, 46, 50, 57, 60, 68};
map<LL,LL> mp;
LL cal(LL x) {
    if(x<=20)
        return a[x];
    if(mp[x])
        return mp[x];
    if(x%2)
        return mp[x]=(2*cal(x/2)%MOD+cal(x/2-1)%MOD)%MOD;
    else
        return mp[x]=(2*cal(x/2-1)%MOD+cal(x/2)%MOD)%MOD;
}
int main() {
    LL n;
    scanf("%lld",&n);
    printf("%lld\n",cal(n));
    return 0;
}


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

template<class T>
void print(std::vector<T> &vector){
    for(const auto &v : vector){
        std::cout << v << " ";
    }
    std::cout << std::endl;
}

int main(int argc, char *argv[]){
    constexpr long int m= 1000000000 + 7;
    long int N, K;
    std::cin >> N >> K;
    std::vector<long int>A(N);
    for(auto &a : A){
        std::cin >> a;
    }
    
    std::vector<long int> ASorted(A);
    std::sort(ASorted.begin(),ASorted.end());
    std::map<long int, long int>rank;
    long int r=0;
    auto left = ASorted.begin();
    auto right = std::upper_bound(ASorted.begin(),ASorted.end(),*left);
    rank[*left] = r;
    while(left < ASorted.end()){
        for(auto iter=left; iter < right; ++iter){
            ++r;
        }
        left = right;
        right = std::upper_bound(ASorted.begin(),ASorted.end(),*left);
        rank[*left] = r;
    }
    
    long int sum = 0;
    for(long int i=0; i<N; ++i){
        std::vector<long int> B(A.begin()+i+1,A.end());
        std::sort(B.begin(),B.end());
        auto boundIter = std::lower_bound(B.begin(),B.end(),A[i]);
        sum += (boundIter - B.begin())*K;
        sum %= m;
        sum += (rank[A[i]] % m)*((K-1)*K/2 % m);
        sum %= m;
    }

    std::cout << sum << std::endl;

    return 0;
}


Measured memory_bytes: 384