akhauriyash/Code-Regression huggingface dataset:
n = int(input())
V = list(map(int,input().split()))
even = [0] * 100001
odd  = [0] * 100001

for v in V[1::2]:
    even[v] += 1
for v in V[::2]:
    odd[v]  += 1
maxeven = max(even)
maxodd  = max(odd)
if(even.index(maxeven) != odd.index(maxodd)):
    print(n - maxeven - maxodd)
else:
    even.sort()
    odd.sort()
    print(min(n-even[-1]-odd[-2],n-even[-2]-odd[-1]))

Measured memory_bytes: 52816
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    a=[0]*N
    for i in range(N):
        a[i]=I()
        
    used=[0]*N
    used[0]=1
    now=0
    cnt=0
    f=0
    for i in range(N):
        cnt+=1
        now=a[now]-1
        if now==1:
            f=1
            break
        if used[now]==1:
            break
        used[now]=1
        
    if f==1:
        print(cnt)
    else:
        print(-1)

main()


Measured memory_bytes: 41564
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
const ll MOD = 1000000007;

int main() {
  int h, w, ch = 0, cw = 0;
  string s;
  cin >> h >> w;
  while (true) {
    cin >> s;
    if (s == "snuke") {
      cout << (char)(cw + 'A') << ch + 1 << endl;
      return 0;
    }
    if (++cw >= w) {
      cw = 0;
      ch++;
    }
  }
  return 0;
}

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    char c;
    cin >> c;
    if(c >= 'a') cout << "a\n";
    else cout << "A\n";


    return 0;
}


Measured memory_bytes: 3612
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(N: int, L: "List[int]"):
    S = sum(L)
    M = max(L)

    if M < (S-M):
        print(YES)
    else:
        print(NO)


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    L = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, L)

if __name__ == '__main__':
    main()


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

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

Node *root, *NIL;

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

    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;

    while ( x != NIL ) {
        y = x;
        if ( z->key < x->key ) {
            x = x->left;
        } else {
            x = x->right;
        }
    }

    z->parent = y;
    if ( y == NIL ) {
        root = z;
    } else {
        if ( z->key < y->key ) {
            y->left = z;
        } else {
            y->right = z;
        }
    }
}

Node * find(Node *u, int k) {
    while ( u != NIL && k != u->key) {
        if ( k < u->key ) u = u->left;
        else u = u->right;
    }
    return u;
}

void inorder(Node *u) {
    if ( u == NIL ) return;
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
}

void preorder(Node *u) {
    if ( u == NIL) return;
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
}

int main() {
    int n, i, x;
    string com;

    scanf("%d", &n);

    for ( i = 0; i < n; i++) {
        cin >> com;
        if ( com[0] == 'f' ) {
            scanf("%d", &x);
            Node *t = find(root, x);
            if ( t != NIL ) printf("yes\n");
            else printf("no\n");
        } else if( com == "insert" ) {
            scanf("%d", &x);
            insert(x);
        } else if ( com == "print" ) {
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }

    return 0;
}


Measured memory_bytes: 22028
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 998244353;
const int inf = (1 << 30) - 1;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

ll mod_pow(ll a, ll n) {
	if(n == 0) return 1;
	ll res = mod_pow(a, n / 2);
	if(n % 2 == 0) return res * res % mod;
	else return a * res % mod * res % mod;
}

int N;
ll A[MAX_N];

void solve() {
	cin >> N;
	int mv = 0;
	rep(i, 0, N) {
		int a; cin >> a;
		if(i == 0 && a != 0) {
			cout << 0 << "\n";
			return;
		}
		A[a]++;
		MAX(mv, a);
	}
	if(A[0] != 1) {
		cout << 0 << "\n";
	}
	else {
		ll res = 1;
		for(int i = 2; i <= mv; i++) {
			MUL(res, mod_pow(A[i - 1], A[i]));
		}
		cout << res << "\n";
	}
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
using namespace std;
int main() {
	string s, t;
	char x;
	int count = 0;
	cin >> s >> t;
	while(s!= t) {
		if (count >= s.size()) {
			cout << "No" << endl;
			exit(0);
		}
		x = s[s.size() - 1];
		for (int i = s.size()-1; i >0; i--) {
			s[i] = s[i - 1];
		}
		s[0] = x;
		//cout << s << endl;
		count++;
	}
	
	cout<<"Yes" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <cstring>
#include <climits>
#include <string.h>
#include <stdio.h>
#define LL long long
#define pii pair<int,int>
#define piii pair<int, pii >
#define REP(i,n) for (int (i)=0;(i)<(n);(i)++)
#define vi vector<int>
#define vpi vector< pii >
#define INF 2147483647
#define big 20160116
#define pb push_back
#define mp make_pair
using namespace std;
const int Maxk=1005;
string mul(string a,string b){
	int res[Maxk];
	memset(res,0,sizeof(res));
	reverse(a.begin(),a.end());
	reverse(b.begin(),b.end());
	for (int i=0;i<a.length();i++){
		for (int j=0;j<b.length();j++){
			res[i+j]+=(a[i]-'0')*(b[j]-'0');
		}
	}
	for (int i=0;i<Maxk;i++){
		if (res[i]>=10) {
			res[i+1]+=(res[i]/10);
			res[i]%=10;
		}
	}
	string ret;
	bool flag=false;
	for (int i=Maxk-1;i>=0;i--){
		if (flag || res[i]){
			flag=true;
			ret=ret+(char)(res[i]+'0');
		}
	}
	if (ret=="") ret="0";
	return ret;
}
string add(string a,string b){
	if (a.length()<b.length()) swap(a,b);
	while (a.length()!=b.length()){
		b='0'+b;
	}
	for (int i=a.length()-1;i>=0;i--){
		a[i]+=(b[i]-'0');
		if (a[i]>'9' && i){
			a[i]-=10;
			a[i-1]++;
		}
	}
	if (a[0]>'9'){
		a[0]-=10;
		a='1'+a;
	}
	return a;
}
const int Maxn=100005;
LL h[Maxn];
int n;
LL A,B;
LL tmp[Maxn];
bool check(LL tm){
	for (int i=0;i<n;i++) tmp[i]=h[i]-B*tm;
	LL rm=0LL;
	for (int i=0;i<n;i++) {
		if (tmp[i]<=0) continue;
		LL val=tmp[i];
		val--;
		val/=(A-B);
		val++;
		rm+=val;
	}
//	cout<<rm<<endl;
	//if (A==B) return true;
	return rm<=tm;
}
int main(){

	scanf("%d %lld %lld",&n,&A,&B);
	for (int i=0;i<n;i++){
		scanf("%lld",&h[i]);
	}
	sort(h,h+n);
	LL l=0LL,r=1000000000LL;
	while (r-l>1){
		LL mid=(l+r)>>1;
		if (check(mid)){
			r=mid;
		}
		else{
			l=mid;
		}
	}
	if (check(l)){
		printf("%lld\n",l);
	}
	else{
		printf("%lld\n",r);
	}
	return 0;
} 
/*
1 2 1
1000000000
*/

Measured memory_bytes: 1792
S = input()
T = input()

s_to_t = [None for _ in range(ord("z")-ord("a")+1)]
t_to_s = [None for _ in range(ord("z")-ord("a")+1)]

a = ord("a")
for s, t in zip(S, T):
    s = ord(s) - a
    t = ord(t) - a

    if s_to_t[s] is None:
        s_to_t[s] = t
    else:
        if s_to_t[s] != t:
            print("No")
            exit()
    
    if t_to_s[t] is None:
        t_to_s[t] = s
    else:
        if t_to_s[t] != s:
            print("No")
            exit()

print("Yes")

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ll long long
#define P pair<int,int>
#define fast_io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const int MOD = 1000000007;
const int INF = 2002002002;
const ll LLINF = 9009009009009009009;
using namespace std;

class UnionFind {
    // 各ノードが根である時の高さ
    // ノードが根でないときは意味をなさない
    vector<int> rank;
    // 各ノードが属する木の根
    // findSetするときのみ更新される
    vector<int> p;
    // 二つの根を結合
    void link(int rx, int ry) {
        if (rx == ry) return;
        if (rank[rx] > rank[ry]) p[ry] = rx;
        else p[rx] = ry;
        if (rank[rx] == rank[ry]) rank[ry]++;
    }
public:
    //　根を作成
    // その木の高さは0
    void makeSet(int x) {
        p[x] = x;
        rank[x] = 0;
    }
    // 初期化
    // 入力サイズ分のノードを確保
    // それらのノードをそれぞれ根とする木を作成
    // ノードの値は 0 ~ size-1
    UnionFind(int size) {
        rank.resize(size, 0);
        p.resize(size, 0);
        rep(i,size) makeSet(i);
    }
    // あるノードの属する木の根を返す
    // 根を探す過程で途中のノードの親も更新
    int findSet(int x) {
        if (x != p[x]) p[x] = findSet(p[x]);
        return p[x];
    }
    // 二つのノードが同じ木にあるか判定
    bool same(int x, int y) {return findSet(x) == findSet(y);}
    // 二つのノードの属する木を結合
    void unite(int x, int y) {link(findSet(x), findSet(y));}
};


int main() {
    // fast_io
    int n, m;
    cin >> n >> m;
    vector<int> p(n);
    rep(i,n) {
        cin >> p[i];
        p[i]--;
    }
    UnionFind u(n);
    int x, y;
    rep(i,m) {
        cin >> x >> y;
        u.unite(x-1, y-1);
    }
    int ans = 0;
    rep(i,n) {
        if (u.same(i, p[i])) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1408
#include<iostream>
using namespace std;
int main() {
	int n, m;
	while (cin >> n >> m&&n != 0 && m != 0) {
		int sum = 0;
		if (n > m) swap(n, m);
		while ((m % n) != 0) {
			m = m%n;
			swap(n, m);
			sum++;
		}
		cout << n << " " << ++sum << endl;
	}
}

Measured memory_bytes: 3092
#include<iostream>
using namespace std;
int main(){
	string s;
	cin >> s;
	int ans=1e9;
	for(int i=0;i<s.length()-2;i++){
		ans=min(ans,abs(753-stoi(s.substr(i,3))));
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc=new Scanner(System.in);
		int n,k,q;
		n=sc.nextInt();
		k=sc.nextInt();
		q=sc.nextInt();
		int p[]=new int[n];
		for(int i=0;i<n;i++) {
			p[i]=k-q;
		}
		for(int i=0;i<q;i++) {
			int a=sc.nextInt()-1;
			p[a]++;
		}
		for(int i=0;i<n;i++) {
			if(p[i]>0)System.out.println("Yes");
			else System.out.println("No");
		}
	}

}


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

#define times(n, i)      uptil(0, n, i)
#define upto(f, t, i)    for(decltype(t) _##i = (t), i = (f); i <= _##i; i++)
#define uptil(f, t, i)   for(decltype(t) _##i = (t), i = (f); i < _##i; i++)
#define downto(f, t, i)  for(decltype(t) _##i = (t), i = (f); i >= _##i; i--)
#define downtil(f, t, i) for(decltype(t) _##i = (t), i = (f); i > _##i; i--)
#define unless(c) if(!(c))
#define until(c) while(!(c))
#define loop while(true)

#define all(v) v.begin(), v.end()
#define ln << "\n"

struct line{};

template<class T> istream& operator>>(istream& in, vector<T>& v) {
    times(v.capacity(), i) in >> v[i];
    return in;
}

template<class T> const ostream& operator<<(ostream& out, const vector<T>& v) {
    times(v.size(), i) out << (i ? " " : "") << v[i];
    return out;
}

template<class T, class...U> typename enable_if<is_same<T, line>::value, string>::type next(istream& in, const U&... args) {
    string s;
    getline(in, s, args...);
    return move(s);
}

template<class T, class...U> typename enable_if<!is_same<T, line>::value, T>::type next(istream& in, const U&... args) {
    T t(args...);
    in >> t;
    return move(t);
}
template<class T, class...U> auto next(const U&... args) -> decltype(next<T>(cin)) {
    return next<T>(cin, args...);
}

template<class T> T sum(const vector<T>& v) {
    T ans = T();
    for(const T& t : v) ans += t;
    return ans;
}

template<class T> T sum(const typename vector<T>::iterator& begin, const typename vector<T>::iterator& end) {
    T ans = T();
    for(typename vector<T>::iterator t = begin; t != end; t++) ans += *t;
    return ans;
}

template<class T> T min(const vector<T>& v) {
    return *min_element(v.begin(), v.end());
}

template<class T> T min(const typename vector<T>::iterator& begin, const typename vector<T>::iterator& end) {
    return *min_element(begin, end);
}

template<class T> T max(const vector<T>& v) {
    return *max_element(v.begin(), v.end());
}

template<class T> T max(const typename vector<T>::iterator& begin, const typename vector<T>::iterator& end) {
    return *max_element(begin, end);
}

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

    loop {
        int N = next<int>(), K = next<int>();
        if(!N && !K) break;
        auto A = next<vector<int>>(N);
        int ans, now = 0;
        times(K, i) {
            now += A[i];
        }
        ans = now;
        times(N - K, i) {
            now += A[K + i] - A[i];
            ans = max(ans, now);
        }
        cout << ans ln;
    }

    return 0;
}

Measured memory_bytes: 1524
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        long n = Long.parseLong(sc.next());
        long a = Long.parseLong(sc.next());
        long b = Long.parseLong(sc.next());
        
        long x = n / (a+b);
        long y = n % (a+b);
        System.out.println(a*x + Math.min(y, a));
    }
}

Measured memory_bytes: 25044
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str;
        StringBuilder sb = new StringBuilder();
        while(!(str = br.readLine()).equals("-")){
            int m = Integer.parseInt(br.readLine());
            while(m-->0){
                int h = Integer.parseInt(br.readLine());
                str = str.substring(h) + str.substring(0,h);
            }
            sb.append(str).append("\n");
        }
        System.out.print(sb);
    }
}

Measured memory_bytes: 24324
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

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()
{	
	int N;
	cin >> N;

	vector<pair<int, int>> P(N);
	rep(i, N) cin >> P[i].first >> P[i].second;

	sort(all(P));

	map<int, map<int, int>> counts;

	rep(i, N)
	{
		repl(j, i + 1, N)
		{
			counts[P[j].first - P[i].first][P[j].second - P[i].second]++;
		}
	}


	int count = 0;

	for (auto p : counts)
	{
		for (auto q : p.second)
		{
			chmax(count, q.second);
		}
	}


	cout << N - count << endl;


	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int>d(n);rep(i,n)cin>>d[i];
    set<int>values;
    rep(i,n)values.insert(d[i]);
    cout<<values.size()<<endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int ans = 0;
		
		if (N%2==0) {
			ans = N/2;
		} else {
			ans = N/2+1;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 21716
#include<iostream>


using namespace std;

int main()
{
    int N,H,W,r;
    r=0;
    cin >> H >>  W >> N;
    if(H>W){
        for(int i=1;i<=H;i++){
            r++;
            if(i*H>=N){
                cout << r <<endl;
                break;
            }
        }
    }else {
        for(int i=1;i<=W;i++){
            r++;
            if(i*W>=N){
                cout << r <<endl;
                break;
            }
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long a, b, n; cin >> a >> b >> n;
  if(b == 1){
    cout << a / b - a << endl;
  }
  else {
    if(n < b) cout << (a * n) / b << endl;
    else cout << (a * (b - 1)) / b << endl;
  }
}

Measured memory_bytes: 3632
#include <iostream>
using namespace std;
int main(void){
    int n,m,l; // Your code here!
    long long A[100][100],B[100][100],C[100][100];
    
    cin>>n>>m>>l;
    
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            cin>>A[i][j];
        }
    }
    for(int i=0; i<m; i++){
        for(int j=0; j<l; j++){
            cin>>B[i][j];
        }
    }
    
    for(int i=0; i<n; i++){
        for(int j=0; j<l; j++){
            C[i][j]=0;
            for(int k=0; k<m; k++){
                C[i][j]+=A[i][k]*B[k][j];
            }
        }
    }
    for(int i=0; i<n; i++){
        for(int j=0; j<l; j++){
            if(j) cout<<" ";
            cout<<C[i][j];
        }
        cout<<endl;
    }
    return 0;
    
}



Measured memory_bytes: 3332
//By Tushar Gautam
#include <bits/stdc++.h>
using namespace std;
#define printint(v) copy(begin(v), end(v), ostream_iterator<int>(cout," "))
#define printintv(s,e) copy(s,e, ostream_iterator<int>(cout," "))
#define forstl(i,v) for(auto &i: v)
#define forn(i,e) for(int i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(int i = s; i >= 0; i--)
#define rforsn(i,s,e) for(int i = s; i >= e; i--)
#define clz(a) __builtin_clz(a) // count leading zeroes
#define ctz(a) __builtin_ctz(a) // count trailing zeroes
#define popc(a) __builtin_popcount(a) // count set bits (for ints only diff for ll)
//https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html for other in built
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int> p32; 
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
typedef map<int,int> m32;
#pragma GCC optimize ("-O2")
const int LIM = 5e5+5, MOD = 1e9+7;
int t,n,m,k,x,y;
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    cin>>n;
    forn(i,n){
        cin>>t;
        while(!(t&1)){
            x++; t/=2;
        }
    }
    cout<<x;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)

#define int long long
//using ll = long long;
using P = pair<int,int>;

ostream &operator<<(ostream &os,const P &p){ return os << "(" << p.first << "," << p.second << ")"; }

template<class T> T &chmin(T &a,const T &b){ return a = min(a,b); }
template<class T> T &chmax(T &a,const T &b){ return a = max(a,b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

template<class T>
struct Edge{
	int from,to;
	T cost;
	Edge(int to,T cost) : to(to),cost(cost){}
	Edge(int from,int to,T cost) : from(from),to(to),cost(cost){}
	operator int() const noexcept { return to; }
};

template<class T>
using WeightedGraph = vector<vector<Edge<T>>>;
using Graph = vector<vector<int>>;
template<class T>
using Matrix = vector<vector<T>>;

using Float = double;
using Point = complex<Float>;

struct UnionFind{
	vector<int> rnk,par;

	UnionFind(int sz) : rnk(sz,0),par(sz){
		for(int i = 0;i < sz;i++) par[i] = i;
	}

	int find(int x){
		if(par[x] == x) return x;
		return par[x] = find(par[x]);
	}

	void unite(int x,int y){
		x = find(x);
		y = find(y);
		if(x == y) return;
		if(rnk[x] < rnk[y]) swap(x,y);
		par[y] = x;
		if(rnk[x] == rnk[y]) rnk[x]++;
	}
	
	bool same(int x,int y){
		return (find(x) == find(y));
	}
};

template <class T>
T kruskal(int n,vector<Edge<T>> &edges){
	T ret = 0;
	sort(edges.begin(),edges.end(),[](const Edge<T> &e1,const Edge<T> &e2){
		return e1.cost < e2.cost;
	});
	UnionFind uf(n);
	for(const Edge<T> &e : edges){
		if(!uf.same(e.from,e.to)){
			ret += e.cost;
			uf.unite(e.from,e.to);
		}
	}
	return ret;
}

signed main(){
	int n,m;
	cin >> n >> m;
	Point ps[10010];
	vector<Edge<double>> es;
	for(int i = 0;i < n;i++){
		double x,y;
		cin >> x >> y;
		ps[i] = Point(x,y);
	}
	double sum = 0;
	for(int i = 0;i < m;i++){
		int p,q;
		cin >> p >> q; p--;q--;
		es.emplace_back(p,q,-abs(ps[p] - ps[q]));
		sum += abs(ps[p] - ps[q]);
	}
	printf("%.14lf\n",sum + kruskal(n,es));
}


Measured memory_bytes: 4168
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MMOD 998244353
#define MAX 2010101
using namespace std;
using Edge=pair<ll,ll>;
using Graph=vector<vector<int>>;
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>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  ll N,ans=0;
  cin>>N;
  
  ll cnt10=1;
  REP(i,N) cnt10=cnt10*10%MOD;
  
  ll cnt9=2;
  REP(i,N) cnt9=cnt9*9%MOD;
  
  ll cnt8=1;
  REP(i,N) cnt8=cnt8*8%MOD;
  
  ans=(cnt10-cnt9+cnt8)%MOD;
  ans=(ans%MOD+MOD)%MOD;
  co(ans);
  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int back(string i) {
	string j = i;
	reverse(j.begin(), j.end());
    if(i == j){
		return 1;
	}
}
int main(){
	string in , P, Q, R;
	cin >> in;
	int Wa, Wb, Wc;
	int size = in.size(), Pi, Qi, Ri;
	Pi = size, Qi = (size - 1) / 2, Ri = (size - 1) / 2;
	P = in, Q = in, Q.erase(Qi), R = in,R.erase(0, size - Ri);
	Wa = back(P),Wb = back(Q),Wc = back(R);
	if(Wa + Wb + Wc == 3){
		cout << "Yes";
	}else {
		cout << "No";
	}
}

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

typedef long long ll;

int main(){
    int N,K;
    cin >> N >> K;
    string S;
    cin >> S;
    vector<int> dist;
    // 01001001001001
    // 1回ひっくり返せるとき、1箇所の1-0-1区間がつなげられる
    // 2回ひっくり返せるとき、２か所の1-0-1-0-1区間がつなげられる
    // 3回ひっくり返せるとき、３か所の1-0-1-0-1-0-1区間がつなげられる
    // 1-0-1-0-1-0-1の数を求めてやる
    // 1から2K+1この数の和が最大になるような区間を求めればよい
    if (S[0] == '0') dist.push_back(0);
    int len = 1;
    for (int i=0;i<N;i++){
        if (i == N -1) {
            dist.push_back(len);
            break;
        }
        if (S[i] != S[i+1]){
            dist.push_back(len);
            len = 1;
        } else {
            len++;
        }
    }
    if (S[N-1] == '0') dist.push_back(0);

    int ans = 0;
    if (2*K+1 <= dist.size()){
        int initial = 0;
        for (int i=0;i<2*K+1;i++){
            initial += dist[i];
        }
        ans = initial;
        int d = initial;
        for (int i=2;i<dist.size() - 2*K + 1;i=i+2){
            d = d - dist[i-2] - dist[i-1] + dist[i+2*K-1] + dist[i+2*K];
            ans = max(ans, d);
        }
    } else {
        for (int i=0;i<dist.size();i++){
            ans += dist[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1020
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n, d;
    cin >> n >> d;
    cout << (n+2*d)/(2*d+1) << "\n";
    return 0;
}

Measured memory_bytes: 256
N=int(input())

AB=[]
sum_A=0
max_B=0
for _ in range(N):
  a,b=[int(x) for x in input().split()]
  AB.append((a,b))
  sum_A+=a
  max_B=max(max_B,b)
  
if max_B<sum_A:
  print("No")
else:
  sortedAB=sorted(AB,key=lambda x:(x[1],x[0]),reverse=True)
  t=sortedAB[0][1]
  for ab in sortedAB:
    if t > ab[1]:
      t=ab[1]
    t-=ab[0]
    if t < 0:
      print("No")
      break
  else:
    print("Yes")

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

int main(){
  int n,ans=0;cin>>n;
  for(int i=1;i<=n;++i){
    int cnt=0;
    for(int j=1;j<=i;++j){
      if(j%2==0) continue;
      if (i%j==0) ++cnt;
    }
    if(cnt==8) ++ans;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		scan.close();
		if(a%3==0||b%3==0||(a+b)%3==0)System.out.println("Possible");
		else System.out.println("Impossible");
	}
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> TUP;
#define rep(i,n) for(int i=0;i<n;i++)
#define mp(a,b) make_pair(a,b)
const ll MOD=1000000007;

ll maxx(ll x,ll y,ll z){
	return max(max(x,y),z);
}
ll minn(ll x,ll y,ll z){
	return min(min(x,y),z);
}
ll gcd(ll x,ll y){
	if(x%y==0) return y;
  else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
	return x*y/gcd(x,y);
}

int main(){
	int A,B,K; cin>>A>>B>>K;
  int cnt=1;
  if(K==1) printf("%lld",gcd(A,B));
  else{
     for(int i=gcd(A,B)-1;i>=1;i--){
      if(gcd(A,B)%i==0){
          cnt++;
      }
       if(cnt==K){
         printf("%d",i);
         break;
       }
     }
  }
}

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

typedef long long ll;
const long long LINF = 1LL << 60;
const long long LMINF = 1LL << 63;
const int INF = 1 << 30;

#define REP(i,n) for(int i = 0;i < n;++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 PB push_back
#define F first
#define S second
#define MP make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << ": " << x << "\n"

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



int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    unsigned short a[3][3];
    bool cnt[3][3];
    REP(i,3){
        REP(j,3){
            cin >> a[i][j];
            cnt[i][j] = false;
        }
    }
    unsigned short n;
    cin >> n;
    vector<unsigned short> b(n);
    REP(i,n)cin >> b[i];

    REP(i,3){
        REP(j,3){
            auto result = find(ALL(b), a[i][j]);
	        if (result != b.end()) {cnt[i][j] = true;}   
        }
    }

    short ix = 0,iy = 0;
    bool flg = false;
    REP(i,3){
        if((cnt[0][i] == true && cnt[1][i] == true && cnt[2][i] == true) ||
         (cnt[i][0] == true && cnt[i][1] == true && cnt[i][2] == true)){
            flg = true;
        }
    }
    if((cnt[0][0] == true && cnt[1][1] == true && cnt[2][2] == true) ||
    (cnt[2][0] == true && cnt[1][1] == true && cnt[0][2] == true)){
        flg = true;
    }
    if(flg == true){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3656
import Control.Applicative
main = do
  [n,a,b] <- map read . words <$> getLine :: IO [Int]
  print $
    if a > b then 0
    else if a == b then 1
    else if n == 1 then 0 else (b*(n-1)+a) - (a*(n-1)+b) + 1


Measured memory_bytes: 508
W, H, N = map(int, input().split())
grid = [[0 for i in range(W)] for j in range(H)]
for i in range(N):
    x, y, a = map(int, input().split())
    if a == 1:
        for j in range(H):
            for k in range(x):
                grid[j][k] = 1
    elif a == 2:
        for j in range(H):
            for k in range(x, W):
                grid[j][k] = 1
    elif a == 3:
        for j in range(W):
            for k in range(y):
                grid[k][j] = 1
    else:
        for j in range(W):
            for k in range(y, H):
                grid[k][j] = 1

ans = 0
for i in range(H):
    for j in range(W):
        ans += grid[i][j]
print(H * W - ans)

Measured memory_bytes: 9184
#include<iostream>
#include<algorithm>
using namespace std;
int judge(int a){
  int i=0,j=0,k=0,b;
  while(a){
    b=a%10;
    if(b==7)i=1;
    else if(b==5)j=1;
    else if(b==3)k=1;
    else return 0;
    a/=10;
  }
  return i*j*k;
}
int main(){
  int n;
  cin >> n;
  n=min(777777753,n);
  int ans=0;
  for(int i=357;i<=n;i+=2){
    ans+=judge(i);
    if(i%10==7)i+=14;
  }
  cout << ans <<endl;
}

Measured memory_bytes: 256
// A1.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>

using namespace std;
int main()
{
    int a, b;
    cin >> a >> b;

    int sum = a + b;

    if (sum % 2 == 0) {
        cout << sum / 2 << endl;
    }
    else {
        cout << "IMPOSSIBLE" << endl;
    }

    return 0;
}



Measured memory_bytes: 3632
require 'pp'
# IS_DEBUG = true
IS_DEBUG = false
def dputs str
	if(IS_DEBUG)
		puts str
	end
end
def dpp str
	if(IS_DEBUG)
		pp str
	end
end

def gcd(a,b)
	if(a>b)
		return gcd(b,a)
	end
	if(b%a == 0)
		return a
	else
		return gcd(a,b%a)
	end
end
def lcm(a,b)
	a/gcd(a,b)*b
end
def nlcm(arr)
	if(arr.size==1)
		return arr[0]
	end
	lcm = arr[0]
	1.upto(arr.size-1){|i|
		lcm = lcm(lcm, arr[i])
	}
	lcm
end

N,d=gets.chomp.split(' ').map{|n| n.to_i}
A = Array.new(N)
0.upto(N-1){|d|
	A[d],dum=gets.chomp.split(' ').map{|n| n.to_i}
}
puts nlcm(A)


Measured memory_bytes: 2044
import java.util.Scanner;

public class Main {

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

		int n = scan.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = scan.nextInt();

		System.out.println(run(a));
		scan.close();
		System.exit(0);
	}

	private static long run(int[] a) {
		if (a.length == 0)
			return (long) 1;
		if (a.length == 1)
			return (long) a[0];

		long result = 1;
		for (int i = 2; i <= a[0];)
			if (a[0] % i == 0) {
				result *= i;
				a[0] /= i;
				for (int k = 1; k < a.length; k++)
					if (a[k] % i == 0)
						a[k] /= i;
			} else
				i++;
		int[] b = new int[a.length - 1];
		for (int i = 1, j = 0; i < a.length; i++, j++)
			b[j] = a[i];
		return result * run(b);
	}

}

Measured memory_bytes: 26380
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
const int INF = 1e9 + 5;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n , k;
    cin >> n >> k;
    vector<int> h(n) ,v(n,INF);
    for(auto &it : h) cin >> it;
    
    v[0] = 0;

    for(int i = 1 ; i < n ; ++i){
        for(int j = 1 ; i-j >= 0 && j <= k; ++j){
            v[i] = min(v[i],abs(h[i] - h[i-j]) + v[i-j]);
        }
    }
    cout << v[n-1] << endl ;
    return 0;
}

Measured memory_bytes: 1024
import math
n = int(input())
for i in range(n):
  ans = 0
  a,b = map(int,input().split())
  c = a*b
  d = int(math.sqrt(c))
  if d *d == c:
    d -= 1
  ans += d*2
  if d >= a:
    ans -= 1
  if d >= b:
    ans -= 1
  if (d * (d+1)) >= c:
    ans -= 1
  print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
main(){
	int MAX_N = 100;
	int a[MAX_N];
	int n;
	int i;

	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%d",&a[n-i]);
	}

	for(i=0;i<n;i++){
		if(i) printf(" ");
		printf("%d",a[i]);
	}

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

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

#define mod 1000000007

int main()
{
    int h,w;
    cin>>h>>w;
    char ch[h+5][w+5];
    long long dp[h+5][w+5];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++)
            cin>>ch[i][j];
    }
    memset(dp,0,sizeof(dp));
    dp[0][0]=1;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(ch[i][j]=='#')continue;
            if(i>0)
                dp[i][j]=(dp[i][j]%mod+dp[i-1][j]%mod)%mod;
            if(j>0)
                dp[i][j]=(dp[i][j]%mod+dp[i][j-1]%mod)%mod;
        }
    }
    cout<<dp[h-1][w-1]<<endl;
}


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

public class Main {

	private static Scanner in;
	private static int n;
	private static int[] a;
	private static int[] b;
	private static int[] c;
	private static long[][] dp;
	
	public static void main(String[] args) {
		in = new Scanner(System.in);
		n = in.nextInt();
		a = new int[n];
		b = new int[n];
		c = new int[n];
		
		for(int i=0; i<n; i++) {
			a[i] = in.nextInt();
			b[i] = in.nextInt();
			c[i] = in.nextInt();
		}
		dp = new long[n+1][3];
		
		for(int i=0; i<dp.length; i++) {
			Arrays.fill(dp[i], -1);
		}
		
		long ans = solve(1, 0)+a[0];
		ans = Math.max(ans, solve(1, 1)+b[0]);
		ans = Math.max(ans, solve(1, 2)+c[0]);
		System.out.println(ans);

	}
	
	private static long solve(int i, int f) {
//		System.out.println(i+" "+f);
		if (i==n) return 0;
		
		if (dp[i][f]!=-1) return dp[i][f];
		
		long ans = 0;
		
		switch(f) {
		case 0:
			ans = Math.max(ans, b[i]+solve(i+1, 1));
			ans = Math.max(ans, c[i]+solve(i+1, 2));
			break;
		case 1:
			ans = Math.max(ans, a[i]+solve(i+1, 0));
			ans = Math.max(ans, c[i]+solve(i+1, 2));
			break;
		case 2:
			ans = Math.max(ans, a[i]+solve(i+1, 0));
			ans = Math.max(ans, b[i]+solve(i+1, 1));
			break;
		}
		
		return dp[i][f]=ans;
	}

}


Measured memory_bytes: 114032
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;

#define MP make_pair
#define PB push_back
#define FF first
#define SS second

#define FORN(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)(n) - 1; i >= 0; i--)

#define DEBUG(X) { cout << #X << " = " << (X) << endl; }
#define PR0(A,n) { cout << #A << " = "; FORN(_,n) cout << A[_] << ' '; cout << endl; }

#define MOD 1000000007
#define INF 2000000000

int GLL(LL& x) {
    return scanf("%lld", &x);
}

int GI(int& x) {
    return scanf("%d", &x);
}

int n, m;

const int MAXN = 100005;
int cnt[MAXN];

int main() {
    GI(n);
    GI(m);

    memset(cnt, 0, sizeof cnt);

    int a, b;

    FOR1(i, m) {
        GI(a);
        GI(b);

        cnt[a]++;
        cnt[b]++;
    }

    FOR1(i, n) {
        if (cnt[i] % 2) {
            printf("NO\n");
            return 0;
        }
    }

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


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

using namespace std;

int main() {
  long n, a[10000], sum = 0;
  scanf("%ld", &n);
  for (long i = 0; i < n; i++) {
    scanf("%ld", &a[i]);
    sum += a[i];
  }
  sort(a, a + n);
  printf("%ld %ld %ld\n", a[0], a[n - 1], sum);
  return 0;
}



Measured memory_bytes: 3260
#[allow(unused_imports)]
use proconio::{fastout, input};

#[fastout]
fn main() {
    input!(a: usize, b: usize);

    let mut aa;
    let mut bb;

    if a < b {
        aa = a;
        bb = b;
    } else {
        aa = b;
        bb = a;
    }

    let mut r = aa % bb;
    while r != 0 {
        aa = bb;
        bb = r;

        r = aa % bb;
    }

    println!("{}", (a * b) / bb);
}


Measured memory_bytes: 2168
#include<bits/stdc++.h>
using namespace std;
typedef		long long       ll;
typedef         long double      dl;
#define		pb              push_back
#define		PB              pop_back
#define		nn              "\n"
#define     O_O             ios_base::sync_with_stdio(false); cin.tie(NULL)
#define		all(p)          p.begin(),p.end()
#define		zz(v)           (ll)v.size()
#define		ss              ' '
#define         arrsize(a)      (sizeof(a)/sizeof(a[0]))
//#define       arrsize(a)      (sizeof(a)/sizeof(*a))
#define 	S(a)            scanf("%lld",&a)
#define 	SS(a,b)         scanf("%lld %lld",&a,&b)
#define 	SSS(a,b,c)      scanf("%lld %lld %lld",&a,&b,&c)
#define		gcd(a,b)        __gcd(a,b)
#define		lcm(a,b)        (a*b)/gcd(a,b)
#define		pi              acos(-1.0)
typedef        pair <int, int>   pii;
typedef       pair <ll, ll>      pll;
typedef      vector< pair <ll, ll>>      vpll;
typedef		vector<ll>      vll;


int main()
{
 //O_O ;
   ll n,k,ans=0;
   cin>>n>>k;
   vll a;
   for(ll i=0;i<n;i++){
    ll x;
    cin>>x;
    a.pb(x);
   }
   sort(a.begin(),a.end());
   if(n<=k)
    cout<<"0"<<nn;
   else{
      ll temp=n-k;
      for(ll i=0;i<temp;i++){
         ans+=a[i];
      }
      cout<<ans<<nn;

   }


    return 0;
}


Measured memory_bytes: 2420
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> vec(n);
    int count =0;
    for(int i=0; i < n; i++){
        cin >> vec[i];
    }

    for(int i=1; i< n-1; i++){
        if ((vec[i] != max(vec[i-1],max(vec[i],vec[i+1]))) &&
            (vec[i] != min(vec[i-1],min(vec[i],vec[i+1])))){
                count++;
            }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int m, d;
    cin >> m >> d;
    int ans = 0;
    for(int i = 1; i <= m; ++i){
        for(int j = 1; j <= d; ++j){
            int d1 = j%10;
            int d10 = j/10;
            if(d1 >= 2 && d10 >= 2 && d1 * d10 == i) ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<pair<string, pair<int, int>>> rst(n);
    for(int i = 0; i < n; i++)
    {
        cin >> (rst[i]).first >> (rst[i]).second.first;
        (rst[i]).second.first = -(rst[i]).second.first;
        (rst[i]).second.second = i + 1;
    }
    sort(rst.begin(), rst.end());
    for(int i = 0; i < n; i++)
    {
        cout << (rst[i]).second.second << endl;
    }
    return 0;
}

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

int main()
{

    int N, maxv, tmp;
    int ans;
    while(1) {
        std::scanf("%d %d", &N, &maxv);
        if (N == 0 && maxv == 0) break;
        std::vector<int> nums;
        nums.reserve(MAX);
        ans = 0;

        int arr[N+1];
        arr[0] = 0;

        for (int i = 1; i <= N; i++) {
            std::scanf("%d", &arr[i]);
            for (int j = 0; j <= i; j++) {
                tmp = arr[i] + arr[j];
                if (tmp < maxv) nums.push_back(tmp);
            }
        }
        std::sort(nums.begin(), nums.end());

        for (unsigned long i = 0; i < nums.size(); i++) {
            tmp = nums[i] + nums[std::upper_bound(nums.begin(), nums.end(), maxv-nums[i]) - nums.begin() - 1];
            if (tmp > ans) ans = tmp;
            if (ans == maxv) break;
        }
        std::cout << ans << std::endl;
    }

    return 0;
}



Measured memory_bytes: 4952
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll INF = 1LL<<30;

int main(){
    ll N,L;
    cin >> N >> L;
    ll mi = INF;
    ll sum = 0;
    for(int i=1;i<=N;++i){
        ll taste = L + i - 1;
        sum += taste;
        if(taste >= 0 && mi >= 0) mi = min(mi,taste);
        else if (abs(mi) > abs(taste)) mi = taste;
        //cout << mi << endl;
    }
    cout << sum - mi << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
typedef pair<int, int> P;

template <typename T>
struct Edge
{
    int to;
    T cost;
};

template <typename T>
struct WeightedGraph
{
    int n;
    vector<vector<Edge<T>>> g;
    
    WeightedGraph(int n) : n(n){
        g.resize(n);
    }
    
    void init(int n_){
        n = n_;
        g.resize(n_);
    }
    
    void add_edge(int from, int to, T cost){
        g[from].push_back((Edge<T>){to, cost});
    }
};

int main()
{
    int n, m;
    cin >> n >> m;
    int d[100002];
    P p[100002];
    for(int i = 0; i < n; i++){
        cin >> d[i];
        p[i] = P(d[i], i);
    }
    sort(p, p + n);
    WeightedGraph<int> g(n);
    for(int i = 0; i < m; i++){
        int u, v;
        cin >> u >> v;
        u--; v--;
        g.add_edge(u, v, i);
        g.add_edge(v, u, i);
    }
    char c[100002];
    for(int i = 0; i < n; i++) c[i] = 'N';
    int l[200002];
    for(int i = 0; i < n; i++){
        int u = p[i].second;
        int les = 1000000000;
        bool b = false, w = false;
        for(Edge<int> e : g.g[u]){
            int v = e.to;
            les = min(les, d[v]);
            if(c[v] == 'B') b = true;
            if(c[v] == 'W') w = true;
        }
        if(!b && !w && les > d[u]){
            cout << -1 << endl;
            return 0;
        }
        les = 1000000000;
        for(Edge<int> e : g.g[u]){
            int v = e.to;
            if(c[v] != 'N') les = min(les, d[v]);
        }
        if(!b && (!w || (w && les == d[u]))) c[u] = 'B';
        else c[u] = 'W';
        for(Edge<int> e : g.g[u]){
            int v = e.to;
            if(c[v] == 'N') continue;
            if(c[v] == c[u]) l[e.cost] = max(d[u] - d[v], 1);
            else l[e.cost] = d[u];
        }
    }
    for(int i = 0; i < n; i++) cout << c[i];
    cout << endl;
    for(int i = 0; i < m; i++) cout << l[i] << endl;
}

Measured memory_bytes: 12160
#include<stdio.h>
int main(void)
{
	int n,a,b;
	scanf("%d",&n);
	if(n==1){
		printf("Hello World\n");
	}
	else{
	scanf("%d %d",&a,&b);
	printf("%d\n",a+b);
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
using namespace std;

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

int n, k, s;

ll solve(int c, int dk, int sum) {
	if(dk == k) {
		if(sum == s) {
			return 1LL;
		} else {
			return 0LL;
		}
	}
	ll res = 0;
	for(int i=c; i<=n && i<=s-sum; i++) {
		res += solve(i+1, dk+1, sum+i);
	}
	return res;
}

int main() {
	while(cin >> n >> k >> s, n || k || s) {
		cout << solve(1, 0, 0) << endl;
	}
	return 0;
}

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

template<typename T>
ostream& operator<<(ostream &os, vector<T> &v){
	string sep = " ";
	if(v.size()) os << v[0];
	for(int i=1; i<v.size(); i++) os << sep << v[i];
	return os;
}

template<typename T>
istream& operator>>(istream &is, vector<T> &v){
	for(int i=0; i<v.size(); i++) is >> v[i];
	return is;
}

#ifdef DBG
void debug_(){ cout << endl; }
template<typename T, typename... Args>
void debug_(T&& x, Args&&... xs){
	cout << x << " "; debug_(forward<Args>(xs)...);
}
#define dbg(...) debug_(__VA_ARGS__)
#else
#define dbg(...)
#endif

ll gcd(ll x, ll y){
	if(y==0) return x;
	else return gcd(y, x%y);
}

int main() {
	ios_base::sync_with_stdio(false);
	cout << setprecision(20) << fixed;

	int x; cin >> x;

	ll g = gcd(x, 360);
	cout << 360 / g << endl;

	return 0;
}


Measured memory_bytes: 3608
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
}
const ll MAX = 1e6;
signed main(){
  init_io();
  ll n,k;
  cin >> n >> k;
  vector<string> p(n);
  vector<ll> cnt(26,0),prob(MAX,0);
  for(int i=0;i<n;i++){
    cin >> p[i];
    cnt[p[i][0]-'A']++;
  }
  ll ans = 0;
  while(true){
    bool can =true;
    sort(cnt.begin(),cnt.end(),greater<ll>());
    for(int i=0;i<k;i++){
      cnt[i]--;
      if(cnt[i]<0){
        can = false;
        break;
      }
    }
    if(!can) break;
    ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 8704