akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define EPS (1e-10)
#define equals(a,b)(fabs((a)-(b))<EPS)
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;

struct Point {
	double x, y;
	Point(double x = 0, double y = 0) :x(x), y(y) {}
	Point operator*(double a) { return Point(a*x, a*y); }
	Point operator-(Point p) { return Point(x - p.x, y - p.y); }
	Point operator+(Point p) { return Point(x + p.x, y + p.y); }
	double norm() { return x*x + y*y; }
};
typedef Point Vector;
typedef vector<Point>Polygon;
struct Segment {
	Point p1, p2;
};
double cross(Point a, Point b) {
	return a.x*b.y - a.y*b.x;
}
double dot(Point a, Point b) {
	return a.x*b.x + a.y*b.y;
}
bool isPrallel(Segment s1, Segment s2) {
	return equals(cross(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0);
}
bool isOrthogonal(Segment s1, Segment s2) {
	return equals(dot(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0);
}
int contains(Polygon g, Point p) {
	int n = g.size();
	bool x = false;
	rep(i, n) {
		Point a = g[i] - p, b = g[(i + 1) % n] - p;
		if (abs(cross(a, b)) < EPS&&dot(a, b) < EPS)return 1;
		if (a.y > b.y)swap(a, b);
		if (a.y < EPS&&EPS<b.y&&cross(a, b)>EPS)x = !x;
	}
	return x ? 2 : 0;
}
int ccw(Point p0, Point p1, Point p2) {
	Point a = p1 - p0;
	Point b = p2 - p0;
	if (cross(a, b) > EPS)return 1;
	if (cross(a, b) < -EPS)return -1;
	if (dot(a, b) < -EPS)return 2;
	if (a.norm() < b.norm())return -2;
	return 0;
}
bool intersect(Point p1, Point p2, Point p3, Point p4) {
	return (ccw(p1, p2, p3)*ccw(p1, p2, p4) <= 0 &&
		ccw(p3, p4, p1)*ccw(p3, p4, p2) <= 0);
}
bool intersect(Segment s1, Segment s2) {
	return intersect(s1.p1, s1.p2, s2.p1, s2.p2);
}
Point project(Segment s, Point p) {
	Point base = s.p2 - s.p1;
	double r = dot(p - s.p1, base) / base.norm();
	return s.p1 + base*r;
}
Point reflect(Segment s, Point p) {
	return p + (project(s, p) - p)*2.0;
}
bool isconvex(Polygon g) {
	int back = 3;
	rep(i, g.size()) {
		int d = ccw(g[(i + g.size() - 1) % g.size()], g[i], g[(i + 1) % g.size()]);
		if (back != 3 && d != back)
			return false;
		else back = d;
	}
	return true;
}
double area(Polygon g) {
	double cnt = 0;
	rep(i, g.size())
		cnt += g[i].x*g[(i + 1) % g.size()].y - g[(i + 1) % g.size()].x*g[i].y;
	return abs(cnt) / 2;
}
int main() {
	int n; scanf("%d", &n);
	rep(i, n) {
		double xp1, yp1, xp2, yp2, xp3, yp3, xk, yk, xs, ys;
		cin >> xp1 >> yp1 >> xp2 >> yp2 >> xp3 >> yp3 >> xk >> yk >> xs >> ys;
		Point a(xp1, yp1), b(xp2, yp2), c(xp3, yp3), k(xk, yk), s(xs, ys);
		Vector AB = b - a, BP = k - b, BC = c - b, CP = k - c, CA = a - c, AP = k - a;
		bool flag = false;
		double c1 = cross(CA, AP), c2 = cross(BC, CP), c3 = cross(AB, BP);
		if ((c1 > 0 && c2 > 0 && c3 > 0) || (c1 < 0 && c2 < 0 && c3 < 0))flag = true;
		BP = s - b, CP = s - c, AP = s - a;
		c1 = cross(CA, AP), c2 = cross(BC, CP), c3 = cross(AB, BP);
		if ((c1 > 0 && c2 > 0 && c3 > 0) || (c1 < 0 && c2 < 0 && c3 < 0))flag ^= true;
		puts(flag ? "OK" : "NG");
	}
}

Measured memory_bytes: 3260
import java.util.Scanner;

public class Main{
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    //一回音を聞くことにかかる費用
    int soundPrice = Integer.parseInt(scan.next());
    //手持ちのお金
    int haveMoney = Integer.parseInt(scan.next());
    //聞きたい回数
    int count = Integer.parseInt(scan.next());

    int result = haveMoney / soundPrice;
    if(result >= count){
      System.out.println(count);
    }else{
      System.out.println(result);
    }
  }
}


Measured memory_bytes: 23636
{-# LANGUAGE BangPatterns #-}

import qualified Data.IntMap as M

main :: IO ()
main = do
    n  <- readLn
    as <- map read . words <$> getLine
    print $ solve n as

solve :: Int -> [Int] -> Int
solve n as = go 0 $ M.fromList $ zip [1 .. n] as
  where
    go !n mp = case M.minViewWithKey mp of
        Nothing -> n
        Just ((k, a), mp') | M.lookup a mp' == Just k -> go (n + 1) mp'
                           | otherwise                -> go n mp'

Measured memory_bytes: 50556
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pint = pair<int, int>;
using vi = vector<int>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

const int MOD = 1000000007;
const int INF = 1 << 30;

lint log_mul(lint base, lint bit) {
    lint res = 0;

    while (bit) {
        if (bit & 1) res = (res + base) % MOD;
        base = (base + base) % MOD;
        bit >>= 1;
    }

    return res;
}

long long modpow(long long a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    int N, K;
    cin >> N >> K;
    vi A(N), F(N, 0), C(N, 0);
    rep(i, N) cin >> A[i];

    rep(i, N) {
        int cl = A[i];
        rep(j, N) {
            if (i == j) continue;

            if (cl > A[j]) {
                if (j < i) F[i]++;
                C[i]++;
            }
        }
    }

    lint res = 0;

    rep(i, N) {
        lint p = log_mul(K, K+1);
        p = log_mul(p, C[i]);
        lint inv = modpow(2, MOD-2);
        res += p * inv;
        res %= MOD;
        res -= log_mul(K, F[i]);
        if (res < 0) res += MOD;
        res %= MOD;
    }

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream> 
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
#include<set>
#include<queue>
#include<deque>
#include<iomanip>
#include<sstream>
#include<cmath>
#include<tuple>
#include<bitset>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define req(i,n) for(ll i = 1;i <=  n; i++)
#define rrep(i,n) for(ll i = n -1;i >= 0;i--)
#define ALL(obj) rbegin(obj), rend(obj)
typedef long long int ll;
typedef long double ld;
const ll INF = 1e9;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
	std::fill((T*)array, (T*)(array + N), val);
}ll n,k,sum = 0,p = 0,m,q; string s;

int main() {
	cin >> n >> q; vector<ll> a(n);
	rep(i, n) cin >> a[i];
	rep(i, q) {
		ll right = 0; p = 0, sum = 0;
		cin >> k;
		rep(left, n) {
			while (right < n && sum + a[right] <= k) {
				sum += a[right];
				right++;
			}
			p += (right - left);
			if (left == right) right++;
			else sum -= a[left];
		}cout << p << endl;
	}
}


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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

string a="AKIHABARA";

int main() {
    string s;
    cin >> s;
    if (s.size() > a.size()) {
        cout << "NO" << endl;
        return 0;
    }
    else if (s == a) {
        cout << "YES" << endl;
        return 0;
    }
    int id=0;
    rep(i, a.size()) {
        if (s[id] != a[i]) {
            if (a[i] == 'A') {
                continue;
            }
            else {
                cout << "NO" << endl;
                return 0;
            }
        }
        else {
            id++;
        }
    }

    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 384
import sys

N, K = map(int, input().split())
num = [0]*N
for x in input().split():
    num[int(x)-1] += 1
val = N-num.count(0)
if K >= val:
    print('0')
else:
    num.sort()
    count = 0
    for i in num:
        if i == 0:
            continue
        else:
            count += i
            val -= 1
            if K >= val:
                print(count)
                sys.exit()



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

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VP vector<pair<int,int>>
#define VPP vector<pair<int,pair<int,int>>>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)
typedef pair <int, int> P;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
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; }

const int  INF = (1 << 30) - 1;
const ll INFL = 1LL << 60;
const ll mod = 998244353;



int main() {
	int n;
	cin >> n;

	n %= 1000;
	n = 1000 - n;
	n %= 1000;
	cout << n << endl;


}

Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    string str;
    int i,l;
    cin>>str;
	if(str[2]==str[3] && str[4]==str[5])
	{
		cout<<"Yes";
	}
	else
	{
		cout<<"No";
	}
	return 0;
    
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
void k(int,int);
int m;
int main(){
  int e,i,j,k;
  while(1){
    m=10000000;
    cin >> e;
    if(e==0) break;
    for(i=0;i<=100;i++){
      for(j=0;j<=1000;j++){
	k=e-j*j-i*i*i;
        if(k>=0&&m>i+j+k){
	  m=i+j+k;
	}
      }
    }
    cout << m << endl;
  }
  return 0;
}

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

int main() {
    int N;
    std::cin >> N;

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

    int min = INT32_MAX;
    for (int i = 1; i <= 100; ++i) {
        int distance = 0;
        for (int j = 0; j < N; ++j) {
            distance += std::pow(i - X[j], 2);
        }
    
        min = std::min(min, distance);
    }

    std::cout << min << std::endl;

    return 0;
}


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

#define pb push_back
#define mp make_pair
#define inf 1000000000
#define mod 1000000007

vector<int> primes;
void sieve()
{
    vector<int> a(1000000,0);
    for(int u=2;u<=1000000;u++)
    {
        if(a[u])continue;
        for(int i=2*u;i<=1000000;i+=u)a[i]=u;
    }
    for(int i=2;i<=1000000;i++)
    {
        if(!a[i])primes.pb(i);
    }
}

int gcd(int a, int b)
{
    while(1)
    {
        if(a==0)return b;
        b%=a;
        if(b==0) return a;
        a%=b;
    }
}
int lcm(int a, int b)
{
    int g=gcd(a,b);
    return ((a*b)/g);
}

int digitCount(int n)
{
    int c=0;
    while(n!=0)
    {
        c+=n%10;
        n/=10;
    }
    return c;
}

int parseInt(string str)
{
    int a=0;
    int l=str.length();
    for(int i=0;i<l;i++)
    {
        a*=10;
        a+=str[i]-48;
    }
    return a;
}

long long parseLong(string str)
{
    long long a=0;
    int l=str.length();
    for(int i=0;i<l;i++)
    {
        a*=10;
        a+=str[i]-48;
    }
    return a;
}

int main()
{
    int n=3;
    vector<int> v;
    while(n--)
    {
        int a;
        cin>>a;
        v.pb(a);
    }
    sort(v.begin(),v.end());
    cout<<v[0]+v[1]<<endl;

}


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

int GCD(int a, int b){
    if(b==0) return a;
    else return (GCD(b,a%b));
}
int main(){
    int n;
    cin >> n;
    int ans = 2*n/GCD(2,n);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <list>
#include <cstdlib>
#include <iomanip>
#include <numeric>
#include <utility>
#include <set>
#include <map>
#include <iterator>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <cmath>
#include <cstring>
#include <sstream>
#include <stack>
#include <random>

using namespace std;

#define vi vector<int> 
#define vvi vector<vi>
#define pi pair<int,int>
#define ll long long
#define pll pair<ll, ll>
#define vll vector<ll>
#define io ios::sync_with_stdio(false)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define sz(a) int((a).size()) 
#define tr(c,i) for(typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define loop(i,b) for (int i = 0; i < b; ++i)
#define present(c,x) ((c).find(x) != (c).end()) 
#define cpresent(c,x) (find(all(c),x) != (c).end()) 
#define INF numeric_limits<int>::max()
#define LLINF numeric_limits<ll>::max()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define F first
#define S second
#define MOD 1000000007
#define cflout(x) cout << fixed << setprecision(8) << x << endl
#define setzero(x) memset(x, 0, sizeof(x))

#ifndef M_PI
    #define M_PI 3.14159265358979323846
#endif

random_device _random_device;
default_random_engine _generator(_random_device());
uniform_int_distribution<long long unsigned> _distribution(0, 0xFFFFFFFFFFFFFFFF);

inline long long unsigned get_random_number() {
    return _distribution(_generator);
}

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

inline ll nxt() {
	ll x;
	cin >> x;
	return x;
}

namespace aux {	
vector<string> split(const string& s, char c) {
	vector<string> v;
	stringstream ss(s);
	string x;
	while (getline(ss, x, c)) {
		v.emplace_back(x);
    }
    return v;
}
}

string s;

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


	return 0;
}


















Measured memory_bytes: 592
//115 B - Christmas Eve Eve 2018/12/08
#include <bits/stdc++.h>
#define rep(i ,n) for(int i=0;i<(int)(n);++i)
using namespace std;
typedef long long int int64;
typedef unsigned long long uint64;

int main(){
    int n; cin >> n;
    vector<int> p(n);
    rep(i ,n) cin >> p[i];
    sort(p.begin(),p.end());
    p[n-1]/=2;
    int sum=0;
    rep(i ,n) sum+=p[i];
    cout << sum << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
typedef long long ll;
int n,k;
ll ans;
int main()
{
    scanf("%d%d",&n,&k);
    ll t=n/k;
    ans=t*t*t;
    if(k%2==0)
    {
        ll t1=(n+k/2)/k;
        ans+=t1*t1*t1;
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 128
import sys; input = sys.stdin.buffer.readline
from collections import defaultdict
con = 10 ** 9 + 7; INF = float("inf")

def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	N, K = getlist()
	D = defaultdict(int)
	for i in range(K):
		d = int(input())
		A = getlist()
		for j in A:
			D[j] += 1

	ans = N - len(D)
	print(ans)

if __name__ == '__main__':
	main()

Measured memory_bytes: 68420
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
#define rep(i, n) for(int i=0; i<n; i++)
#define rep_one(i, n) for(int i=1; i<n; i++)
using namespace std;
typedef long long ll;

int solve(int x, int count){
    if(x == -1) return 0;
    if(x == 0) return count;
    int y = x;
    int pc = 0;
    while(y != 0){
        pc += y%2;
        y /= 2;
    }
    return solve(x%pc, count+1);
}

int main(){
    int n; cin >> n;
    string x; cin >> x;
    ll xp=0, xm=0;
    int pc=0;
    int x_list[n];
    rep(i, n){
        x_list[i] = (int)(x[i]-'0');
        pc += x_list[i];
    }
    rep(i, n){
        xp = (xp*2)%(pc+1);
        xp += x_list[i];
        if(pc-1 > 0){
            xm = (xm*2)%(pc-1);
            xm += x_list[i];
        }
    }
    int xi[n];
    ll pm=1, pp=1;
    for(int i=n-1; i>-1; i--){
        if(x_list[i]){
            if(pc-1 < 1){xi[i]=-1; continue;}
            xi[i] = (xm-pm+pc-1)%(pc-1);
        }else{
            xi[i] = (xp+pp)%(pc+1);
        }
        pp = (2*pp)%(pc+1);
        if(pc-1 > 0) pm = (2*pm)%(pc-1);
    }
    rep(i, n){
        cout << solve(xi[i], 1) << endl;
    }
}

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

int N;
int A[100][14],B[100][15];

int main(){
	cin >> N;

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

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

    int res=INT_MIN;

	for(int b=1;b<(1<<10);b++){
        int cc=0;
        for(int i=0;i<N;i++){
            int c=0;
            for(int j=0;j<10;j++){
                if((b>>j&1) && A[i][j])
                    c++;
            }
            cc+=B[i][c];
        }
        res=max(res,cc); 
    }
    printf ("%d\n",res);

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

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

const int INF = 1 << 29;
const ll LL_INF = 1LL << 60;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
const int MAX_NM = 310;
int N, M;
int A[MAX_NM][MAX_NM];
int indices[MAX_NM];
int deg[MAX_NM];
int main()
{
    
    cin >> N >> M;
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < M; j++)
        {
            cin >> A[i][j];
            A[i][j]--;
        }
        deg[A[i][0]]++;
    }

    set<int> tabooo;
    int result = N;
    while (tabooo.size() < M)
    {
        int max_deg = -1;
        int max_sports = -1;
        //add max sport to tabooo
        for (int i = 0; i < M; i++)
        {
            if (deg[i] > max_deg)
            {
                max_deg = deg[i];
                max_sports = i;
            }
        }
        if (max_sports == -1)
        {
            break;
        }
        // cerr << max_deg << " " << max_sports << " " << deg[max_sports] << endl;
        // assert(tabooo.count(max_sports) == 0);

        result = min(result, max_deg);
        tabooo.insert(max_sports);
        //update
        for (int i = 0; i < N; i++)
        {
            int idx = indices[i];
            int val = A[i][idx];
            while (tabooo.count(val) > 0)
            {
                deg[val]--;
                indices[i]++;
                int idx = indices[i];
                val = A[i][idx];
                deg[val]++;
            }
        }
    }
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>

int main(){
    char n[200010];

    scanf("%s", n);

    int len = strlen(n);
    int ans = 0;
    for(int i = 0; i < len; ++i){
        ans += (n[i] - '0');
    }

    if((ans % 9) == 0) puts("Yes");
    else puts("No");

    return 0;
}


Measured memory_bytes: 1824
#include <bits/stdc++.h>
using namespace std;
using ll = long long ;
#define pb push_back
#define mp make_pair
#define pf push_front
#define FOR(i,a,b)           for(int i = a;   i <  (int)(b); ++i)
#define for_rev(i,a,b)       for(int i = b-1; i >= (int)(a); --i)
#define for_it(it, v) for (auto it = v.begin(); it != v.end(); it++)
#define all(v) v.begin(), v.end()
#define sortv sort(all(v))
#define print(v)     \
    for (auto i : v) \
        cout << i << " ";
#define FAST                     \
    ios::sync_with_stdio(false); \
    cin.tie(NULL);               \
    cout.tie(NULL);
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef unordered_set<int> ust;
typedef set<int> st;
typedef unordered_map<int, int> ump;
typedef map<int, int> mi;
#define F first
#define S second
/*****************************************************************************/
int frogBU(int n , int m , vector<int> &v)
{
    const int INF = 1e9 + 5 ;
	vector<int> dp(n) ;
	dp[0] = 0 ;
	for (int i = 1 ; i < n ; i++)
	{
		dp[i] = INT_MAX;
		for(int j = i-1 ; j >= 0 and (i-j)<=m ; j --) 
		{
			dp[i] = min(dp[i],abs(v[i]-v[j])+dp[j]);
		}
	}
	return dp[n-1];
}
int main()
{

	FAST
	int n , m ; cin >> n >> m ;
	vector<int> v(n) ; 
	for(int i = 0 ; i < n ; i++)
    {
        cin >> v[i];
    }
	cout << frogBU(n,m,v) << endl;
	return 0 ;
}	

Measured memory_bytes: 3984
n = int(input())
h = [int(item) for item in input().split()]

ind = 0
max_cnt = 0
cnt = 0
while ind < n-1:
    if h[ind] >= h[ind+1]:
        cnt += 1
    else:
        max_cnt = max(max_cnt, cnt)
        cnt = 0
    ind += 1
max_cnt = max(max_cnt, cnt)

print(max_cnt)



Measured memory_bytes: 14252
import heapq

n, m = map(int, input().split())
aL = list(map(lambda x: int(x) * (-1), input().split(" ")))

heapq.heapify(aL)

for i in range(m):
    a = heapq.heappop(aL)
    a = int(a / 2)
    heapq.heappush(aL, a)

print(int(sum(aL) * -1))


Measured memory_bytes: 20312
#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <queue>
#include <functional>

using namespace std;
static const int INF = 1e8;
typedef pair<int, int> P;


void solve()
{
	unsigned long long int x;
	cin >> x;
	if (x <= 6)
	{
		cout << 1 << endl;
	}
	else if (x <= 11)
	{
		cout << 2 << endl;
	}
	else
	{
		unsigned long long int cnt = x / 11;
		unsigned long long int num = 0;
		num = cnt * 6 + cnt * 5;
		cnt *= 2;
		bool first = true;
		while (num < x)
		{
			if (first)
			{
				num += 6;
			}
			else
			{
				num += 5;
			}
			first = !first;
			++cnt;
		}
		cout << cnt << endl;
	}
}

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

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

int gcd(int a, int b)
{
    if (b > a) {
        return gcd(b, a);
    }

    int r = a % b;
    if (r == 0) {
        return b;
    }

    return gcd(b, r);
}

int main()
{
    int n;
    int x;
    int a;
    int r;
    std::cin >> n >> x;

    std::cin >> a;
    r = std::abs(a - x);

    for (int i = 1; i < n; i++) {
        std::cin >> a;
        r = gcd(r, abs(a - x));
    }

    std::cout << r << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (((a)%mod) * ((b)%mod)) % mod
#define rollcall cout << "I'm Sucu." << endl;
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define dmt(x, y, z) make_tuple(x, y, z)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// debug
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << "(" << p.first << "," << p.second << ")";return os;
}
template <typename T, typename U, typename V>
ostream &operator<<(ostream &os, const tuple<T, U, V> &t){
  os << "(" << get<0>(t) << "," << get<1>(t) << "," << get<2>(t) << ")";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if(it != v.begin())os << " ";os << *it;
  }return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp){
  for(auto x: mp)os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void PRINTF(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void PRINTF(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
string substr(const string &str, int S1, int S2 = -1){
  if(S2 == -1)return str.substr(S1);
  return str.substr(S1, S2-S1);
}
// typedef
typedef complex<double> Point;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef tuple<int, int, int> TT;
typedef pair<int, TT> PT;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;
// int sum = accumulate(a, a+n, 0LL);
// int mx = max_element(a, a+n);
// int mn = min_element(a, a+n);
// int cnt = count(a, a+n, k);



signed main(){
  int n, k;cin >> n >> k;
  vector<vector<int>> vec(n+1);
  if((n-1)*(n-2)/2 < k){
    cout << -1 << endl;
    return 0;
  }
  
  k = (n-1)*(n-2)/2-k;
  repi(i,2,n+1)vec[1].pb(i);
  int cnt = 0;
  repi(i,2,n+1)repi(j,2,n+1){
    if(j <= i)continue;
    cnt++;
    if(cnt > k)break;
    vec[i].pb(j);
  }
  cout << k + n-1 << endl;
  rrep(i,n)rep(j,vec[i].size()){
    cout << i << " " << vec[i][j] << endl;
  }
  return 0;
}






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

int main()
{
    int n;
    double ans=0;
    cin>>n;
    for(int i=0;i<n;i++){
        double a;
        cin>>a;
        ans += 1/a;
    }
    cout<<1/ans<<endl;
    return 0;
}

Measured memory_bytes: 256
from math import sqrt
n = int(input())
xy = [[int(i) for i in input().split()] for _ in range(n)]
def d(a, b):
    return sqrt((a[0] - b[0])** 2 + (a[1] - b[1])** 2)

s = 0
for i in range(n):
    for j in range(i + 1, n):
        s += d(xy[i], xy[j])
s /= n / 2
print(s)

Measured memory_bytes: 38256
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
#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 <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#define endl "\n";
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int INF = 100100100;
const long long MOD = 1000000007;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}
//Edge.at(i).at(j) = D : ij間の距離がDである辺が張られている。
vector<vector<int>> Edge(20,vector<int>(20));
//dp[S][V] : 既に訪れた頂点集合Sと現在Vから全頂点を通って0に戻る最短経路
int dp[(1 << 15)][15];

//Sは訪問した頂点を表すbit列として考える
//S = {0,0,1,1,0}だと1番目,2番目の頂点を訪れた後である。
int TSP(int S,int now,int Size){
    //既にSの状態でnowが探索済み
    if(dp[S][now] != -1) {
        return dp[S][now];
    }
    //Sが全頂点をカバーしていて、向かう頂点が0 = ゴール
    if(S == (1 << Size)-1 && now == 0){
        return dp[S][now] = 0;
    }
    int nowMiniByNow = INF;
    //nowからuへと進む
    for(int u = 0;u<Size;u++){
        //今まで通った頂点集合Sのなかにuが含まれていたらダメ
        if((S >> u) & 1 == 1) continue;
        nowMiniByNow = min(nowMiniByNow,TSP(S | (1 << u),u,Size)+Edge.at(now).at(u));
    }
    return dp[S][now] = nowMiniByNow;
}

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

    int N,E;cin >> N >> E;
    for(int i = 0;i<20;i++)for(int j = 0;j<20;j++) Edge.at(i).at(j) = INF;
    for(int i = 0;i<E;i++){
        int from,to,dist;cin >> from >> to >> dist;
        Edge.at(from).at(to) = dist;
    }
    for(int i = 0;i<(1 << 15);i++)for(int j = 0;j<15;j++) dp[i][j] = -1;

    int OUTPUT = INF;
    /*始点全探索
    for(int i = 0;i<N;i++){
        OUTPUT = min(OUTPUT,TSP(0,i,N));
    }*/

    OUTPUT = TSP(0,0,N);
    if(OUTPUT == INF) OUTPUT = -1;

    cout << OUTPUT << endl;
}



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

int main() {
  int a,b;
  cin >> a >> b;
  
  for(int i=1;i<4;i++){
    if(i != a && i != b)
      cout << i << endl;
  }
}

Measured memory_bytes: 3632
#include <stdio.h>


int main(){
    int n,d,i;
    int count = 0;

    scanf("%d %d",&n,&d);

    i = 1+d;
    count = 1;
    while(i < n){
        if(i+d+1 > n){
            break;
        }
         if(i + d*2+1 <= n){
           
             i = i + d*2+1;
            count++;
           }else if((n - (i+d) < d*2+1) && i+d+1 <= n){
           
                i = i+d+1;
               count++;
        }else if(i+d+1 > n){
            break;
        }

    }

    /*else if(i <= n && i + d + 1 > n){
            
              count++;
              break;*/


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


    return 0;
}

Measured memory_bytes: 128
n,k=map(int,input().split())
a=[]
for i in range(n):
    a.append(int(input()))
dp=[0]*(300010)

#####segfunc#####
def segfunc(x, y):
    return max(x,y)
#################

#####ide_ele#####
ide_ele =0
#################

class SegTree:
    """
    init(init_val, ide_ele): 配列init_valで初期化 O(N)
    update(k, x): k番目の値をxに更新 O(logN)
    query(l, r): 区間[l, r)をsegfuncしたものを返す O(logN)
    """
    def __init__(self, init_val, segfunc, ide_ele):
        """
        init_val: 配列の初期値
        segfunc: 区間にしたい操作
        ide_ele: 単位元
        n: 要素数
        num: n以上の最小の2のべき乗
        tree: セグメント木(1-index)
        """
        n = len(init_val)
        self.segfunc = segfunc
        self.ide_ele = ide_ele
        self.num = 1 << (n - 1).bit_length()
        self.tree = [ide_ele] * 2 * self.num
        # 配列の値を葉にセット
        for i in range(n):
            self.tree[self.num + i] = init_val[i]
        # 構築していく
        for i in range(self.num - 1, 0, -1):
            self.tree[i] = self.segfunc(self.tree[2 * i], self.tree[2 * i + 1])

    def update(self, k, x):
        """
        k番目の値をxに更新
        k: index(0-index)
        x: update value
        """
        k += self.num
        self.tree[k] = x
        while k > 1:
            self.tree[k >> 1] = self.segfunc(self.tree[k], self.tree[k ^ 1])
            k >>= 1

    def query(self, l, r):
        """
        [l, r)のsegfuncしたものを得る
        l: index(0-index)
        r: index(0-index)
        """
        res = self.ide_ele

        l += self.num
        r += self.num
        while l < r:
            if l & 1:
                res = self.segfunc(res, self.tree[l])
                l += 1
            if r & 1:
                res = self.segfunc(res, self.tree[r - 1])
            l >>= 1
            r >>= 1
        return res

seg=SegTree(dp,segfunc,0)
for i in a:
    l=max(i-k,0)
    r=min(i+k,300005)

    dp[i]=seg.query(l,r+1)+1
    seg.update(i,dp[i])
print(max(dp))






Measured memory_bytes: 104488
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (progn (ql:quickload '(:cl-debug-print :fiveam))
                 (shadow :run)
                 (use-package :fiveam)))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)

;; BEGIN_INSERTED_CONTENTS
(declaim (ftype (function * (values fixnum &optional)) read-fixnum))
(defun read-fixnum (&optional (in *standard-input*))
  (declare #.OPT)
  (macrolet ((%read-byte ()
               `(the (unsigned-byte 8)
                     #+swank (char-code (read-char in nil #\Nul))
                     #-swank (sb-impl::ansi-stream-read-byte in nil #.(char-code #\Nul) nil))))
    (let* ((minus nil)
           (result (loop (let ((byte (%read-byte)))
                           (cond ((<= 48 byte 57)
                                  (return (- byte 48)))
                                 ((zerop byte) ; #\Nul
                                  ;; (return-from read-fixnum 0)
                                  (error "Read EOF or #\Nul."))
                                 ((= byte #.(char-code #\-))
                                  (setf minus t)))))))
      (declare ((integer 0 #.most-positive-fixnum) result))
      (loop
        (let* ((byte (%read-byte)))
          (if (<= 48 byte 57)
              (setq result (+ (- byte 48) (the fixnum (* result 10))))
              (return (if minus (- result) result))))))))

(defmacro dbg (&rest forms)
  #+swank
  (if (= (length forms) 1)
      `(format *error-output* "~A => ~A~%" ',(car forms) ,(car forms))
      `(format *error-output* "~A => ~A~%" ',forms `(,,@forms)))
  #-swank (declare (ignore forms)))

(defmacro define-int-types (&rest bits)
  `(progn
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits)
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits)))
(define-int-types 2 4 7 8 15 16 31 32 62 63 64)

(defmacro println (obj &optional (stream '*standard-output*))
  `(let ((*read-default-float-format* 'double-float))
     (prog1 (princ ,obj ,stream) (terpri ,stream))))

(defconstant +mod+ 1000000007)

;; Body

(defun main ()
  (let* ((n (read))
         (x (read))
         (as (make-array n :element-type 'uint32))
         (res 0))
    (declare (uint31 n x)
             (uint62 res))
    (dotimes (i n) (setf (aref as i) (read-fixnum)))
    (dotimes (i (- n 1))
      (let ((delta (- (+ (aref as i) (aref as (+ i 1))) x)))
        (when (> delta 0)
          (let* ((delta1 (min delta (aref as (+ i 1))))
                 (delta0 (- delta delta1)))
            (decf (aref as i) delta0)
            (decf (aref as (+ i 1)) delta1)
            (incf res delta)))))
    (println res)))

#-swank(main)


Measured memory_bytes: 10600
import os
import sys
from io import BytesIO, IOBase
def main():
    s=input()
    s=list(s)
    for i in range(len(s)):
        if(s[i]=="?"):
                s[i]="D"
            
    print("".join(s))
            

# fast-io region

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)


def input():
    return sys.stdin.readline().rstrip("\r\n")


def write(*args, end="\n"):
    for x in args[:-1]:
        sys.stdout.write(str(x) + " ")
    sys.stdout.write(str(args[-1]))
    sys.stdout.write(end)


def r_array():
    return [int(x) for x in input().split()]


def r_int():
    return int(input())


if __name__ == "__main__":
    main()


Measured memory_bytes: 74756
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int n;
    unsigned long long m,a,r,c,h;
    cin >> n;
    m = a = r = c = h = 0;
    string s[n];
    for(int i = 0; i < n; i++){
        cin >> s[i];
        if(s[i][0] == 'M') m++;
        else if (s[i][0] == 'A') a++;
        else if (s[i][0] == 'R') r++;
        else if (s[i][0] == 'C') c++;
        else if (s[i][0] == 'H') h++;
    }
    cout << m*a*r+m*a*c+m*a*h+m*r*c+m*r*h+m*c*h+a*r*c+a*r*h+a*c*h+r*c*h << endl;


    return 0;
}

Measured memory_bytes: 6144
#include<bits/stdc++.h>
using namespace std;
int a[5005];
int main()
{

    int i,j,k,l,t,z,n,r,m,x,y;
    cin>>n;
    x=n%1000;
    x=(1000-x)%1000;
    cout<<x<<endl;

}


Measured memory_bytes: 3632
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
n = S()
print(n.count('2'))

Measured memory_bytes: 74460
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <fstream>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int p[100005];

int root(int x) {return p[x] < 0 ? x : p[x] = root(p[x]);}

void mer(int x, int y) {
    if ((x = root(x)) == (y = root(y))) return;
    if (p[x] > p[y]) swap(x, y);
    p[x] += p[y];
    p[y] = x;
}

int main() {
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    cout << (n + 1) / 2;
}


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

int main() {
    int k, s;
    cin >> k >> s;
    int ans = 0;
    rep(x, k+1) {
        rep(y, k+1) {
            int z = s - x - y;
            if (z >= 0 && z <= k) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define PI acos(-1)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}

using namespace std;


int main(){
   ll l,r;
   cin>>l>>r;

   ll ml=10000,mr=0;
   for(ll i=l;i<=r;i++){
      ml=min(ml,i%2019);
      mr=max(mr,i%2019);
      if(i-l>5000) break;
   }
   ll ans=10000;
   for(ll i=ml;i<mr+1;i++){
      for(ll j=i+1;j<mr+1;j++){
         ans=min(ans,i*j%2019);
      }
   }

   cout<<ans;
return 0;
}



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

#include <iostream>
using namespace std;

int main()
{
    int n, m,a;
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        cin >> a;

        n -= a;

    }
    
    if (n < 0) {
        cout << -1 << endl;
    }
    else {
        cout << n << endl;
    }

    return 0;
}




Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <cstdio>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;

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

int n;
llong m;

int main(){
	while(1){
		scanf("%d%lld", &n, &m);
		if(n==0 && m==0) return 0;
		n++;
		vector<llong> p(n);
		p[0]=0;
		FOR(i, 1, n) scanf("%lld", &p[i]);
		VSORT(p);
		int size=0;
		vector<llong> v;
		REP(i, n){
			REP(j, n){
				v.push_back(p[i]+p[j]);
			}
		}
		VSORT(v);
		llong ans=0;
		REP(i, v.size()){
			int rem=m-v[i];
			if(rem < 0) continue;
			int l=0, r=v.size();

			while(l<r){
				int mid=(l+r)/2;
				if(rem>v[mid]){
					l=mid+1;
				}
				else if(rem<v[mid]){
					r=mid;
				}
				else {
					break;
				}
			}

			ans = max(ans, v[i]+v[r-1]);
		}

		printf("%d\n",ans);
	}
}

Measured memory_bytes: 17148
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=3e5+13;
int sz[maxn],fa[maxn];
int mx=1;
int find(int x)
{
	return fa[x]==x?x:fa[x]=find(fa[x]);
}
int main()
{
    int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	{
		fa[i]=i;
		sz[i]=1;
	 } 
	int u,v;
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d",&u,&v);
		int fa1=find(u),fa2=find(v);
		if(fa1==fa2) continue;
		else
		{
			fa[fa2]=fa1;
			sz[fa1]+=sz[fa2];
			mx=max(mx,sz[fa1]);
		}
	}
	printf("%d",mx);
 } 

Measured memory_bytes: 5392
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
//using Graph = vector<vector<pair<ll,ll>>>;
const int mod =1e+9+7;

const int dy[4]={0,1,0,-1};
const int dx[4]={1,0,-1,0};
const ll INF=1e10;

int main(){
    ll n; cin>>n;
    vector<vector<ll>>a(n,vector<ll>(3));
    rep(i,n){
        cin>>a[i][1]>>a[i][2]>>a[i][0];
    }
    sort(all(a));
    reverse(all(a));
    ll H,cnt=0;
    for(int i=0;i<=100;i++){
        for(int j=0;j<=100;j++){
            rep(k,n){
                if(a[k][0]==0)continue;
                H=a[k][0]+abs(a[k][1]-i)+abs(a[k][2]-j);
                break;
            }
              cnt=0;
            rep(k,n){
                if((H-abs(a[k][1]-i)-abs(a[k][2]-j))<=0&&a[k][0]==0)cnt++;
                else if((H-abs(a[k][1]-i)-abs(a[k][2]-j))==a[k][0])cnt++;
            }
            if(cnt==n&&H>=1){
                cout<<i<<" "<<j<<" "<<H<<endl;
                return 0;
            }
        }
    }
}











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

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

ll dp[110005];

int main() {
	int n,m;
	cin >> n >>m;
	vector<int> h(m);
	rep(i, 110005) dp[i] = 0;

	rep(i, m) {
		cin >> h[i];
		dp[h[i]] = -1;
	}
	
	dp[0] = 1;

	for(int i = 0;i < n;i++) {
		if (dp[i] == -1) continue;
		rep(u, 2) {
			if (dp[i + u + 1] != -1) {
				dp[i + u + 1] += dp[i];
				dp[i + u + 1] %= 1000000007;
			}
		}
	}
	cout << dp[n] << endl;
}

Measured memory_bytes: 1536
import sys
from collections import defaultdict


def main():
    N, A, *xlst = map(int, sys.stdin.read().split())
    x_p = []
    x_n = []
    x_z = 0
    for i in xlst:
        i = int(i)
        if A < i:
            x_p.append(i - A)
        elif i < A:
            x_n.append(A - i)
        else:
            x_z += 1
    x_p.sort()
    x_n.sort()
    x_p_sum = defaultdict(int, {0: 1})
    x_n_sum = defaultdict(int, {0: 1})
    for i in range(len(x_p)):
        for j in sorted(x_p_sum, reverse=1):
            x_p_sum[j + x_p[i]] += x_p_sum[j]

    for i in range(len(x_n)):
        for j in sorted(x_n_sum, reverse=1):
            x_n_sum[j + x_n[i]] += x_n_sum[j]

    res = 0
    for i in x_n_sum:
        if i in x_p_sum:
            res += (x_n_sum[i] * x_p_sum[i])
    res *= 1 << x_z
    res -= 1
    print(res)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main(){
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i, n) cin >> a.at(i);
    sort(a.begin(), a.end());
    int min = 2000000000;
    rep(i, n-k+1){
        if(a.at(i+k-1) - a.at(i) < min) min = a.at(i+k-1) - a.at(i);
    }
    cout << min << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
using namespace std;
 
int main() {
    fast();
    // ll t;
    // cin>>t;
    // while(t--)
    // {
       
    // }
    ll n;
    cin>>n;
    ll cnt[n+1]={0};
    for(ll i=0;i<n-1;i++)
    {
        ll x;
        cin>>x;
        cnt[x]++;
    }
    for(ll i=1;i<=n;i++)
    cout<<cnt[i]<<endl;
    
}


Measured memory_bytes: 5208
#include <iostream>

using namespace std;

int main(){
	int H, W, d;

	while (true){
		cin >> H >> W;
		if(H==0 && W==0){
			break;
		}
		for(int i=0;i<H;i++){
			if(i%2==0){
				for(int j=0;j<W;j++){
					if(j%2==0){
						cout << "#";
					}
					else if(j%2!=0){
						cout << ".";
					}
				}
			}
			else{
				for(int j=0;j<W;j++){
					if(j%2!=0){
						cout << "#";
					}
					else if(j%2==0){
						cout << ".";
					}
				}
			}
			cout << "\n";
		}
		cout<<"\n";
	}
}


Measured memory_bytes: 3084
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
typedef long long ll;
ll MOD = 1e9+7;

using namespace std;
int a[100001];

int main()
{
	int n;
	int ans=0;
	int index[2];
	int j=0;
	fill(a,a+100001,0);
	cin>>n;
	for(int i=0;i<n;i++)
	{
		int b;
		cin>>b;
		a[b]++;
	}

	//3以上のものを調べる
	for(int i=0;i<100001;i++)
	{
		if(a[i]>2)
		{
			a[i]%=2;
			if(a[i]==0)
				a[i]=2;
		}
	}

	//2のものを調べる
	for(int i=0;i<100001;i++)
	{
		if(a[i]==2)
		{
			index[j]=i;
			j++;
		}
		if(j==2)
		{
			a[index[0]]=1;
			a[index[1]]=1;
			j=0;
		}
	}
	
	//残ったものを合計する
	for(int i=0;i<100001;i++)
	{
		ans+=a[i];
	}
	if(j==1)
		ans-=2;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
// Problem : D - Div Game
// Contest : AtCoder - AtCoder Beginner Contest 169
// URL : https://atcoder.jp/contests/abc169/tasks/abc169_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#define int long long
#define fastio                      \
  ios_base::sync_with_stdio(false); \
  cin.tie(0);                       \
  cout.tie(0);
#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define db1(x) cout << #x << "=" << x << endl
#define db2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z)                                                       \
  cout << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z \
       << endl
#define dbp(x) \
  cout << #x << "= {" << (x.first) << ", " << (x.second) << "}" << endl;
#define dbv(v)                         \
  {                                    \
    cout << #v << " : ";               \
    for (auto x : v) cout << x << ' '; \
    cout << endl;                      \
  }
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define rep2(i, a, b) for (int i = a; i >= b; i--)
#define die(x) return cout << x << '\n', 0;

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

int32_t main() {
  fastio;

  int testcases;
  testcases = 1;
  // cin>>testcases;

  while (testcases--) {
    int n;
    cin >> n;
    if (n == 1) die(0);
    int ans = 0;
    vector<int> sums(45, 0);
    for (int i = 1; i <= 45; i++) {
      sums[i] = sums[i - 1] + i;
    }
    for (int i = 2; i * i <= n; i++) {
      int cnt = 0;
      while (n % i == 0) {
        n = n / i;
        cnt++;
      }
      if (cnt) {
        auto it = lower_bound(sums.begin(), sums.end(), cnt) - sums.begin();
        if (sums[it] != cnt) it--;
        // db3(i, cnt, it);
        // db1(n);
        ans += it;
      }
    }
    if (n > 1) {
      ans++;
    }
    cout << ans;
  }

  return 0;
}


Measured memory_bytes: 3612