akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"os"
	"strconv"
	"fmt"
)

func main() {
	in := NewScanner()
	N := in.NextInt()
	count := 0
	d := 0
	for i := 0; i < N; i++ {
		A := in.NextInt()
		if A == 0 {
			d = 0
			continue
		}
		A += d
		count += A / 2
		d = A % 2
	}
	fmt.Println(count)
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r:rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			result = append(result, v)
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	result = append(result, v)

	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 3840
#include <iostream>
#include <string>
#include <vector>
#include <unordered_set>
#include <algorithm>
#include <queue>

using namespace std;
using ll = long long;

void expand(ll input, unordered_set<ll> &target) {

    // right most digit: append suitable digit
    ll digit = input % 10;
    if (digit <= 8) target.insert(input * 10 + digit + 1);
    target.insert(input * 10 + digit);
    if (digit >= 1) target.insert(input * 10 + digit - 1);
    ll previousDigit = digit;

    // middle digits: check both sides.
    ll t = 10;

    while (input >= t) {
        ll front = input / t;
        ll back = input % t;
        digit = front % 10;
        if (digit != previousDigit) {
            // they are "neighbours", only one of them is allowed in the middle
            target.insert((front * 10 + digit) * t + back);
            target.insert((front * 10 + previousDigit) * t + back);
        } else {
            // they are the same, so any +/- 1 (within bounds) is allowd
            if (digit <= 8) target.insert((front * 10 + digit + 1) * t + back);
            target.insert((front * 10 + digit) * t + back);
            if (digit >= 1) target.insert((front * 10 + digit - 1) * t + back);
        }
        previousDigit = digit;
        t *= 10;
    }

    // left most digit: prefix suitable digit
    ll back = input % t;
    if (digit <= 8) target.insert((digit + 1) * t + back);
    target.insert((digit) * t + back);
    if (digit >= 2) target.insert((digit - 1) * t + back);
}

int main(int argc, char **argv) {
    ll K;
    cin >> K;

    unordered_set<ll> all{1, 2, 3, 4, 5, 6, 7, 8, 9};

    while (all.size() <= K) {
        unordered_set<ll> next;
        for (auto n : all) {
            expand(n, next);
        }
        all.insert(next.begin(), next.end());
    }

    vector<ll> v(all.begin(), all.end());
    sort(v.begin(), v.end());

    cout << v[K - 1] << endl;
    return 0;
}


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

using namespace std;

inline double sq(double x) {
  return x * x;
}

int main() {
  int N;
  cin >> N;
  for (int i = 0; i < N; i++) {
    double xa, ya, ra, xb, yb, rb;
    cin >> xa >> ya >> ra >> xb >> yb >> rb;
    double d = sqrt(sq(xb-xa)+sq(yb-ya));
    if (d > ra + rb)
      cout << 0 << endl;
    else if (ra > d + rb)
      cout << 2 << endl;
    else if (rb > d + ra)
      cout << -2 << endl;
    else
      cout << 1 << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define STR string
#define Fst first
#define Snd second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
int n;
string s;
ll d[10010][110];
ll dp[10010][110][2];
ll md=1e9+7;
ll res=0;
int main()
{
	cin >>s>>n;
	for (int i=0;i<s.size();i++) s[i]-='0';
	reverse(s.begin(),s.end());
	for (int i=0;i<10;i++) d[0][i%n]++;
	for (int i=1;i<s.size()-1;i++)
	{
		for (int j=0;j<n;j++)
		{
			for (int k=0;k<10;k++)
			{
				int it=j-k;
				while (it<0) it+=n;
				d[i][j]=(d[i][j]+d[i-1][it])%md;
			}
		}
	}
	if (s.size()>1) res=d[s.size()-2][0]-1;
	for (int i=1;i<s[s.size()-1];i++) dp[s.size()-1][i%n][0]++;
	dp[s.size()-1][s[s.size()-1]%n][1]++;
	for (int i=s.size()-2;i>=0;i--)
	{
		for (int j=0;j<n;j++)
		{
			//cout <<i<<" "<<j<<" ###############\n";
			for (int k=0;k<10;k++)
			{
				int it=j-k;
				while (it<0) it+=n;
				dp[i][j][0]=(dp[i][j][0]+dp[i+1][it][0])%md;
				if (k==s[i]) dp[i][j][1]=(dp[i][j][1]+dp[i+1][it][1])%md;
				if (k<s[i]) dp[i][j][0]=(dp[i][j][0]+dp[i+1][it][1])%md;
				//cout <<k<<" "<<(int)s[i]<<" "<<dp[i][j][0]<<" "<<dp[i][j][1]<<" ##\n"; 
			}
		}
	}
	res=(res+dp[0][0][0]+dp[0][0][1])%md;
	cout <<res;
	return 0;
} 

Measured memory_bytes: 26112
#include<stdio.h>
int main(){
    int H, W, i, j;
    while(1){
        scanf("%d %d\n", &H, &W);
        if(H==0)return 0;
        for(i=0;i<H;i++){
            for(j=0;j<W;j++) putchar((i+j)%2==0 ? '#' : '.');
            putchar('\n');
        }
        putchar('\n');
    }
}


Measured memory_bytes: 2580
#include<stdio.h>
int main(void){
   int a, b, r, key = 1, i = 1;
   scanf("%d %d", &a, &b);
   while ( key ) {
      if ( a < b ) {
         r = a;
         a = b;
         b = r;
      }
      r = a % b;
      while ( r ) {
         a = b;
         b = r;
         r = a % b;
         i++;
      }
      printf("%d %d\n", b, i);
      i = 1;
      scanf("%d %d", &a, &b);
      if ( a == 0 && b == 0 ) key = 0;
   }
   return 0;
}

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


int main() {
    long a,b;
    cin >> a >> b;
    if (a == b) {
        cout << "a == b" <<endl;
    } else if (a > b) {
        cout << "a > b" << endl;
    } else {
        cout << "a < b" <<endl;
    }
}


Measured memory_bytes: 3056
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h> 
#include <time.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
typedef pair<int, int> PII;
typedef long long ll;
template<typename T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;



int p[55], tmp[55], n, cnt;

int main() {

	cin >> n;
	rep(i, n) {
		cin >> p[i];
		tmp[i] = i + 1;
	}

	rep(i, n) {
		if (p[i] != tmp[i])cnt++;
	}

	if (cnt > 2)cout << "NO" << endl;
	else cout << "YES" << endl;

	return 0;
}


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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

const int N_MAX = 2010;
vector<int> adj[N_MAX];
int d[N_MAX][N_MAX];

void dfs(int from, int n, int p) {
  for (auto x: adj[n]) {
    if (x!=p) {
      d[from][x] = d[from][n]+1;
      dfs(from,x,n);
    }
  }
}

int main() {
  int N, K; cin >> N >> K;
  rep(i,N-1) {
    int A, B; cin >> A >> B; A--; B--;
    adj[A].push_back(B);
    adj[B].push_back(A);
  }
  rep(i,N) {
    fill_n(d[i],N,-1); d[i][i] = 0;
    dfs(i,i,-1);
  }
  ll result = INF;
  rep(i,N) {
    if (K%2==0) {
      ll tmp = 0;
      rep(j,N) if (d[i][j]>K/2) tmp++;
      result = min(result, tmp);
    }
    else for (auto j: adj[i]) {
      ll tmp = 0;
      rep(k,N) if (min(d[i][k],d[j][k])>K/2) tmp++;
      result = min(result, tmp);
    }
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 16256
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define RREP(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define RFOR(i, s, n) for (int i = (int)n - 1; i >= s; --i)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
template<class T>inline void out(T t){cout << t << "\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout << t << " ";out(ts...);}
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;}
constexpr int INF = 1e18;

int dp[505][505][505];

signed main(){
	int N;
	cin >> N;
	vector<int>p(N * N);
	REP(i,N * N){
		cin >> p[i];
		--p[i];
	}
	using T = tuple<int,int,int>;
	priority_queue<T,vector<T>,greater<T>>que;
	vector<vector<int>>dist(N,vector<int>(N,INF));
	REP(i,N){
		REP(j,N){
			dist[i][j] = min({i,j,N - i - 1,N - j - 1});
		}
	}
	vector<vector<int>>ans(N,vector<int>(N));
	int dx[] = {1,0,-1,0,1,1,-1,-1};
	int dy[] = {0,1,0,-1,1,-1,1,-1};
	vector<vector<int>>used(N,vector<int>(N));
	REP(_,N * N){
		int i = p[_] / N,j = p[_] % N;
		ans[i][j] = dist[i][j];
		used[i][j] = 1;
		que.push({dist[i][j],i,j});
		while(que.size()){
			auto[cost,i,j] = que.top();
			que.pop();
			if(dist[i][j] != cost)continue;
			REP(k,4){
				int ni = dx[k] + i,nj = dy[k] + j;
				if(!IN(0,ni,N) || !IN(0,nj,N))continue;
				if(CHMIN(dist[ni][nj],cost + !used[i][j])){
					que.push({dist[ni][nj],ni,nj});
				}
			}
		}
	}
	int sum = 0;
	REP(i,N){
		REP(j,N){
			//if(j)cout << " ";
			//cout << ans[i][j];
			sum += ans[i][j];
		}
		//cout << endl;
	}
	out(sum);
}

Measured memory_bytes: 11340
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
//#include <atcoder/all>
//using namespace atcoder;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v){
    if(v.empty()){
        os<<"{ }";
        return os;
    }
    os<<"{"<<v.front();
    for(auto itr=++v.begin();itr!=v.end();itr++){
        os<<", "<<*itr;
    }
    os<<"}";
    return os;
}

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

//戻り値: 負の閉路が存在する場合、Trueを返す。
template<typename T>
bool bellman_ford(const vector<vector<pair<int,T>>>& path,vector<T>& dis,vector<bool>& negative,int start){
    int n=path.size(),is_null=dis[0];
    int to;
    T cost;
    dis[start]=0;
    for(int i=1;i<=n;i++){
        bool update=false;
        rep(j,n)for(auto e:path[j]){
            tie(to,cost)=e;
            if(dis[j]!=is_null && dis[to]>dis[j]+cost){
                dis[to]=dis[j]+cost;
                update=true;
            }
        }
        if(!update) return false;
    }
    //negative更新
    for(int i=1;i<=n;i++){
        rep(j,n)for(auto e:path[j]){
            if(dis[j]==is_null) continue;
            tie(to,cost)=e;
            if(dis[to]>dis[j]+cost){
                dis[to]=dis[j]+cost;
                negative[to]=true;
            }
            if(negative[j]) negative[to]=true;
        }
    }
    return true;
}

int main(){
    int n,m; cin>>n>>m;
    vector<vector<pair<int,ll>>> path(n);
    vector<ll> dis(n,INF);
    vector<bool> negative(n,false);
    rep(i,m){
        int a,b,c; cin>>a>>b>>c;
        a--; b--;
        path[a].push_back(mk(b,-c));
    }
    bellman_ford<ll>(path,dis,negative,0);
    if(negative[n-1]) cout<<"inf"<<endl;
    else cout<<-dis[n-1]<<endl;
}


Measured memory_bytes: 3708
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int a,b,c,i,count=0;
    cin>>a>>b>>c;
    if(a+b+c==0){
      cout << 0 << endl;  
    }else if(b+a>=c){
        cout<< c+b << endl;
    }else{
        cout<< a+2*b+1 <<endl;
    }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        System.out.println((int)Math.ceil((double)(b - 1) / (a - 1)));
    }
}

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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;

const int mod  = 100003;
const int maxn = 1e5+10;

int a[maxn];
int dp[maxn];
int f(int a)
{
	if (a<0)
		a=-a;
	return a;
}
int solve(int n)
{
	if (dp[n]!=-1)
		return dp[n];
	int t1=solve(n-2)+f(a[n]-a[n-2]);
	int t2=solve(n-1)+f(a[n]-a[n-1]);
	dp[n]=min(t1,t2);
	return dp[n];
}
int main()
{
	int n;
	cin>>n;
	for (int i=0;i<=n;i++)
		dp[i]=-1;
	for (int i=1;i<=n;i++)
		cin>>a[i];
	dp[1]=0;
	dp[2]=f(a[1]-a[2]);
	cout<<solve(n);
	return 0;
}


Measured memory_bytes: 6712
#include <stdio.h>
long long cnt=0;
int l;
int a[1000000];
int n=0;
int m=0;
int G[100]={1};


void insertionsort(int a[],int n,int g){
    for(int i=g;i<n;i++){
        int v=a[i];
        int j=i-g;
        while(j>=0&&a[j]>v){
            a[j+g]=a[j];
            j=j-g;
            cnt++;
        }
        a[j+g]=v;
    }
}
void shellsort(int a[], int n){
  
    int i=1;
    
    while(3*G[i-1]+1<n){
        G[i]=G[i-1]*3+1;
        i++;
    }
    m=i;
    
    for(int i=m-1;i>=0;i--)
        insertionsort(a,n,G[i]);
    
}

int main(){
    scanf("%d",&n);
    for(int i=0;i<n;i++) scanf("%d",&a[i]);
    cnt=0;
    
    shellsort(a,n);
    printf("%d\n",m);
    for(int i=1;i<=m;i++){
        if(i!=1)
            printf(" ");
        printf("%d",G[m-i]);
    }
    printf("\n");
    printf("%lld\n",cnt);
    for(int i=0;i<n;i++)
        printf("%d\n",a[i]);
    return 0;
    
    
}



Measured memory_bytes: 5648
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from heapq import heapify, heappop, heappush

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

D, N = MAP()
if N == 100:
    print(100 ** D * N + 100 ** D)
else:
    print(100 ** D * N)


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

#define mod ((ll)(1e9)+7)

vector<ll> v(2*(ll)(1e5+1),0);
vector<ll> v_inv(2*(ll)(1e5+1),0);

ll pmod(ll n, ll p){
	ll m=n%mod;
	if(p==0) return 1;
	ll ans=pmod((m*m)%mod, p/2)%mod;
	if(p%2==1) ans=ans*m%mod;
	return ans;
}

void factorial(ll n){
	v[0]=1;
	for(ll i=1; i<=n; i++){
		v[i]=v[i-1]*i%mod;
	}
	return;
}

void factorial_inv(ll n){
	for(ll i=0; i<=n; i++){
		v_inv[i]=pmod(v[i],mod-2);
	}
}

ll binom(ll n, ll k){
	if(n<k || n<0 || k<0) return 0;
	ll tmp=v_inv[k]*v_inv[n-k]%mod;
	return v[n]*tmp%mod;
}

int main(){
	int n;
	cin >> n;
	factorial(n+1);
	factorial_inv(n+1);

	int c[n+1];
	for(int i=1; i<=n; i++) c[i]=-1;
	int p, q;
	for(int i=0; i<n+1; i++){
		int a;
		cin >> a;
		if(c[a]==-1) c[a]=i;
		else{
			p=c[a];
			q=i;
		}
	}

	for(int k=1; k<=n+1; k++){
		ll ans=(binom(n+1, k)-binom(n-q+p, k-1))%mod;
		if(ans<0) ans+=mod;
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 4736
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int num;
    while(cin>>num)
    {
        set<string> s;
        for(int i=0;i<num;i++)
        {
            string temp;
            cin>>temp;
            s.insert(temp);
        }
        cout<<s.size()<<endl;
    }
}

Measured memory_bytes: 19160
#include<stdio.h>

int main(void){
  double a,b,c,d,e,f;
  double x,y;
  while(scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f)!=EOF){
    x=(c*e-f*b)/(a*e-d*b)+0.0001;
    y=(c*d-f*a)/(b*d-e*a)+0.0001;
    printf("%.3lf %.3lf\n",x,y);
  }
  return 0;
}


Measured memory_bytes: 1732
#include<algorithm>
#include<cstdio>
#include<iostream>
#include<string>
#include<map>

using namespace std;

int main(){
	//freopen("in","r",stdin);
	int n; cin >> n;
	map<string,int> record;
	for(int i = 0;i < n;i++){
		string s; cin >> s;
		record[s]++;
	}
	int cnt = -1;
	for(auto item : record) cnt = max(cnt,item.second);
	for(auto item : record){
		if(item.second == cnt) cout << item.first << endl;
	}
}

Measured memory_bytes: 27136
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder.Abc
{
    //https://atcoder.jp/contests/abc143/tasks/abc143_a
    public class QuestionA
    {
        public static void Main(string[] args)
        {
            var inputIntArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i));

            int a = inputIntArray.ElementAt(0);
            int b = inputIntArray.ElementAt(1);

            var result = a - (2 * b);
            result = result < 0 ? 0 : result;

            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 13268
N = int(input())
W = [input() for _ in range(N)]

from collections import Counter

dic = Counter(W)
flg = 0
for i in range(N):
    if dic[W[i]]!=1:
        flg=1
        

for j in range(N-1):
    if W[j][-1]!=W[j+1][0]:
        flg = 1

if flg!=1:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#include <numeric>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, n) for (int i = (a); i < (n); ++i)
using namespace std;
using ll = long long;
using uint = unsigned int;
const ll mod = (ll)1e9 + 7;

int h, w, k;
char c[6][6];
int main() {
  cin >> h >> w >> k;
  rep(j, h) rep(i, w) cin >> c[j][i];
  int ans = 0;
  rep(jbit, 1 << h) rep(ibit, 1 << w) {
    int count = 0;
    rep(j, h) rep(i, w) if (jbit & (1 << j) && ibit & (1 << i) && c[j][i] == '#') count++;
    if (count == k) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
#define ff first
#define ss second
#define pb push_back
#define debug(val) cerr << "The value of " << #val << " is = " << val << '\n';
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 922337203685477;
const ll mininf = -922337203685477;
const ll nax = 1e5 + 5;
ll n, k, h[200005], ans=0;

bool cmp(int a, int b){
	return a>b;
}

int main(){
	IOS
	cin >> n >> k;
	for(int i=0;i<n;i++){
		cin >> h[i];
	}
	sort(h, h+n, cmp);
	for(int i=0;i<n;i++){
		if(k>0){
			k--;
			continue;
		}
		ans+=h[i];
	}
	cout << ans << '\n';
}


Measured memory_bytes: 5160
import java.util.*;
import java.io.*;

public class Main{

	public static void main(String[] args){
		solve();
	}

	public static void solve(){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long left = 0;
		long right = 0;
		for(int z=0;z<n;z++){
			long a = sc.nextLong();
			String b  = sc.next();
			long c = sc.nextLong();
			if(b.charAt(0)=='('){
				left += c;
			}
			else{
				right += c;
			}
			if(left==right){
				System.out.println("Yes");
			}
			else{
				System.out.println("No");
			}
		}
	}
}

Measured memory_bytes: 55736
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <cmath>
#include <random>
#include <iomanip>
#include <functional>

using namespace std;

typedef long long ll;

int a[100100];

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

	int n, k;
	cin >> n >> k;

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

	k--;
	int min_ops = n;
	for (int l = j; l >= 0 && (l + k >= j); l--)
	{
		const int r = l + k;
		if (r >= n)
			continue;

		const int left_cnt = l;
		const int right_cnt = n - r - 1;

		int ops = 1;
		ops += left_cnt / k + (left_cnt % k > 0);
		ops += right_cnt / k + (right_cnt % k > 0);

		min_ops = min(min_ops, ops);
	}

	cout << min_ops;
}

Measured memory_bytes: 640
/*
        Oink!Oink!!
▂╱▔▔╲╱▔▔▔▔╲╱▔▔╲▂
╲┈▔╲┊╭╮┈┈╭╮┊╱▔┈╱
┊▔╲╱▏┈╱▔▔╲┈▕╲╱▔┊
┊┊┊┃┈┈▏┃┃▕┈┈┃┊┊┊
┊┊┊▏╲┈╲▂▂╱┈╱▕┊┊┊

*/
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#include <stack>
#include <sstream>
#include <cstring>
#include <numeric>
#include <ctime>
#include <cassert>
#include <random>
#include <valarray>
//#include <fstream>
#define re return
#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) ((int)(x).size())
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define y0 y32479
#define y1 y95874
#define next next239
#define prev prev239
#define fill(x, y) memset(x, y, sizeof(x))
#define sqr(x) ((x) * (x))
#define sqrt(x) sqrt(abs(x))
#define unq(x) (x.resize(unique(all(x)) - x.begin()))
#define ba back()
#define popcount __builtin_popcountll
#define fastIO()                 \
    {                            \
        ios::sync_with_stdio(0); \
        cin.tie(0);              \
        cout.tie(0);             \
    }
#define in(x) \
    int x;    \
    cin >> x;
#define in1(x) \
    int x;     \
    cin >> x;  \
    x--;
#define inll(x) \
    ll x;       \
    cin >> x;
#define ins(x) \
    string x;  \
    cin >> x;

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef pair<double, double> pdd;
typedef long double LD;
typedef double D;

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

    vector<long long int> red(a,0);
    vector<long long int> green(b,0);
    vector<long long int> col(c,0);
    
    for(long long int i=0;i<a;i++)
        cin>>red[i];

    for(long long int i=0;i<b;i++)
        cin>>green[i];
    
    for(long long int i=0;i<c;i++)
        cin>>col[i];


    sort(red.rbegin(),red.rend());
    sort(green.rbegin(),green.rend());
    sort(col.rbegin(),col.rend());

    vector<long long int> ans;

   for(long long int i=0;i<x;i++)
    ans.pb(red[i]);

   for(long long int i=0;i<y;i++)
    ans.pb(green[i]);
    
    
    for(long long int i=0;i<min((x+y),c);i++)
    ans.pb(col[i]);
    
    

    long long int j=0;
    sort(ans.rbegin(),ans.rend());
    long long int sum=0;
    for(long long int i=0;i<x+y;i++)
    {       
        sum+=ans[i];
    }
    cout<<sum<<endl;
    return 0;   
}

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

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

	string ans;
	if (C<A || C>B) {
		ans = "No";
	}
	else
	{
		ans = "Yes";
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
int main(){
    std::string input;
    int32_t A, B, C, D;
    std::cin >> input;
    A = input[0] - '0';
    B = input[1] - '0';
    C = input[2] - '0';
    D = input[3] - '0';

    const int32_t first_op[8] =  {1,1,1,1,-1,-1,-1,-1};
    const int32_t second_op[8] = {1,1,-1,-1,1,1,-1,-1};
    const int32_t third_op[8] =  {1,-1,1,-1,1,-1,1,-1};
    for (int32_t i = 0; i < 8; i++) {
        int32_t res = A + first_op[i] * B + second_op[i] * C + third_op[i] * D;
        if (res == 7) {
            std::cout << A << (first_op[i] == 1? "+" : "-")
            << B << (second_op[i] == 1? "+" : "-")
            << C << (third_op[i] == 1? "+" : "-")
            << D << "=" << 7 << std::endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
//#include<CastingInterop.h>
#include<string>
using namespace std;

int main()
{
    char arr[3];
    int arr1[3];
    string y;
    for (int i = 0; i < 3; i++)
    {
        cin >> arr[i];
    }
    string s [1000];
    for (int i = 0; i < 3; i++)
    {
        s[i] =  arr[i];

    }
    for (int i = 0; i < 3; i++)
    {
        s[i] += s[i +1]+s[i+2];
    }

    //cout << s[0];
    string w;
    w = s[0];
    //cout << w;
    int num = stoi(w);
    if (num % 4 == 0)
        cout << "YES";
    else
        cout << "NO"; }

Measured memory_bytes: 3624
#include <iostream>
#include <set>
#include <map>
#include <cstdio>
#include <algorithm>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

#define f first
#define s second
#define mp make_pair



using namespace std;

int n, m;
int a;

// studio tea party ?
// spanning tree protocol ?
int s[100000];
int t[100000];
int p[100000];

int ki[100000];
int gu[100000];

map<int,int> id;

int main(){
  scanf("%d%d", &n, &m);
  REP(i,n) scanf("%d%d", s+i, t+i);
  REP(i,m) scanf("%d", p+i);

  sort(p, p + m);

  for(int i = 1; i < m; i++){
    if(i % 2 == 0){
      gu[i] = gu[i-1] + (p[i] - p[i-1]);
      ki[i] = ki[i-1];
    }else{
      gu[i] = gu[i-1];
      ki[i] = ki[i-1] + (p[i] - p[i-1]);
    }
  }
  
  // printf("ki: "); REP(i,m) printf("%d ", ki[i]); puts("");
  // printf("gu: "); REP(i,m) printf("%d ", gu[i]); puts("");

  long long ans = 0;

  REP(i,n){
    int ss = s[i];
    int tt = t[i];

    int si = (int)(lower_bound(p, p + m, ss) - p);
    int ti = (int)(lower_bound(p, p + m, tt) - p);
    int tmp = 0;

    // printf("si=%d ti=%d\n", si, ti);

    if(si == ti){
      tmp += abs(tt - ss);
    }else if(abs(si - ti) == 1){
      if(si > ti){
	tmp += ss - p[si - 1];
      }else{
	tmp += p[si] - ss;
      }
    }else if(si < ti){
      int kg = si % 2;
      
      if(kg == 0){
	tmp += gu[ti - 1] - gu[si + 1];
      }else{
	tmp += ki[ti - 1] - ki[si + 1];
      }

      // printf("tmp1: %d\n", tmp);
      
      tmp += p[si] - ss;
      if((ti - si + 1) % 2 == 1)
	tmp += tt - p[ti - 1];
    }else{
      int kg = si % 2;

      if(kg == 0){
	tmp += gu[si - 1] - gu[ti];
      }else{
	tmp += ki[si - 1] - ki[ti];
      }

      // printf("tmp1: %d\n", tmp);

      tmp += ss - p[si - 1];
      if((si - ti + 1) % 2 == 1)
	tmp += p[ti] - tt;
    }

    //printf("tmp2: %d\n", tmp);
    ans += tmp;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 0
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    int N,K; R(N,K);
    double an=0;
    FOR(i,1,N){
        int now=i;
        double v=1;
        while(now<K){
            now*=2;
            v*=0.5;
        }
        an+=v;
    }
    W(an/N);
    return 0;
}


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


using namespace std;

int n;
int maxW;
vector<pair<int,int>> vec;
long long meme[105][100007];


long long solve(int index, int remain){
    if(index==n){
        return 0;
    }
    
    if(meme[index][remain]!=-1){
        return meme[index][remain];
    }
    long long res1;
     res1 = solve(index+1,remain);
    long long res2 =0;
    if(remain>=vec[index].first){
        res2 = solve(index+1,remain-vec[index].first) + vec[index].second;
    }
    return meme[index][remain] = max(res1,res2);
}

int main(){
    cin>>n>>maxW;
    memset(meme,-1,sizeof(meme));
    int one,two;
    for(int i = 0 ; i<n ; i++){
        cin>>one>>two;
        vec.push_back(make_pair(one,two));
    }
    long long go = solve(0, maxW);
    cout<<go<<endl;
    return 0;
}

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

int main () {
  int N, D;
  cin >> N >> D;
  vector <vector<int>> point(N,vector<int>(D));
  for (int i = 0; i < N; i++){
    for (int j = 0; j < D; j++){
      cin >> point.at(i).at(j);
    }
  }
  int ans = 0;
  for (int i = 0; i < N; i++){      
    for (int j = i+1; j < N; j++){
      int d = 0;
      for (int k = 0; k < D; k++){
        int diff = point.at(i).at(k) - point.at(j).at(k);
        d += diff*diff;
      }
      for (int k = 1; k*k <= d; k++){
        if (k*k == d) ans ++;
      }
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

n, k = map(int, input().split())
a = list(map(int, input().split()))
m = max(a)
for i in range(1, n):
    a[i] = gcd(a[i], a[i - 1])
print("POSSIBLE" if k % a[n - 1] == 0 and k <= m else "IMPOSSIBLE")

Measured memory_bytes: 14104
#include<bits/stdc++.h>
using namespace std;
const long long maxn=1e5+5;
const long long inf=0x3f3f3f3f;
long long rt[maxn];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
    long long d;
    cin>>d;
    rt[0]=1;
    for(long long i=1;i<30;i++)
    	rt[i]=rt[i-1]*10ll;
    long long ret=0;
    for(long long i=2;i<=20;i++)
    {
    	long long k=i/2;
    	for(long long s=0;s<1<<k;s++)
    	{
    		long long way,zan=d;
    		if(i%2==1)
    			way=10;
    		else
    			way=1;
    		for(long long j=0;j<k;j++)
    		{
    			long long x=abs(zan)%10ll;
    			if(zan<0)
    			{
    				x=10-x;
    				x%=10;
				}
				if(s>>j&1)
				{
					long long nm=10ll-x;
					if(j==0)
						nm--;
					way*=nm;
					zan+=x*rt[i-2*j-1];
					zan-=x;
				}
				else
				{
					long long nm=x;
					if(j==0)
						nm--;
					if(nm<0)
					{
						way=0;
						break;
					}
					way*=nm;
					zan-=(10ll-x)*rt[i-2*j-1];
					zan+=(10ll-x);
				}
				zan/=10ll;
			}
			if(zan==0)
				ret+=way;
		}
	}
	cout<<ret<<endl;
	return 0;
}


Measured memory_bytes: 3612
function main(input){
  var line1 = input[1].split(' ');
  var arr = Array(line1.length);
  for (var i=0; i<line1.length; i++){
    var one, two;
    if (i-1 < 0) one = -1;
    else {
      var h1 = parseInt(line1[i-1]);
      var h2 = parseInt(line1[i]);
      one = Math.abs(h1-h2);
    }
    if (i-2 < 0) two = -1;
    else {
      var h1 = parseInt(line1[i-2]);
      var h2 = parseInt(line1[i]);
      two = Math.abs(h1-h2);
    }
    if (one < 0) two < 0 ? arr[i] = 0 : arr[i] = arr[i-2] + two;
    else if (two < 0) arr[i] = arr[i-1] + one;
    else arr[i] = Math.min(arr[i-2] + two, arr[i-1] + one);
  }

  console.log(arr[line1.length-1]);
}


var input = '';

process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
process.stdin.on('end', function() {
  input = input.split('\n');
  main(input);
});


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

int main(void) {
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  vector<vector<int>> G(3 * N);
  rep(i, M) {
    int u, v;
    cin >> u >> v;
    --u;
    --v;
    G[3 * u + 0].emplace_back(3 * v + 1);
    G[3 * u + 1].emplace_back(3 * v + 2);
    G[3 * u + 2].emplace_back(3 * v + 0);
  }

  int S, T;
  cin >> S >> T;
  --S;
  --T;
  vector<int> visit(3 * N, INT_MAX);
  visit[3 * S] = 0;
  priority_queue<pair<int, int>, vector<pair<int, int>>,
                 greater<pair<int, int>>>
      que;
  que.emplace(0, 3 * S);
  while (!que.empty()) {
    int step, u;
    tie(step, u) = que.top();
    que.pop();
    if (visit[u] < step) continue;
    int nstep = step + 1;
    for (auto v : G[u]) {
      if (visit[v] <= nstep) continue;
      visit[v] = nstep;
      que.emplace(nstep, v);
    }
  }
  if (visit[3 * T] == INT_MAX)
    cout << -1 << endl;
  else
    cout << visit[3 * T] / 3 << endl;
  return 0;
}


Measured memory_bytes: 20892
import java.util.Scanner;

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

		String s = scan.nextLine();

		for(int i = 0;i<s.length();i++) {
			if(s.charAt(i) == 'R') {
				count++;
			}
			if(s.charAt(1) == 'S' && s.charAt(0)=='R') {
				count = 1;
			}
		}

		System.out.println(count);

		scan.close();


	}

}


Measured memory_bytes: 35588
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>

using namespace std;
int A[2000001];
int B[2000001];
long C[10001];
long n;
void CountingSort(int k){
	memset(C, 0, sizeof(C));
	for (long j = 0; j < n; ++j) ++C[A[j]];
	for (long i = 1; i <= k; ++i) C[i] += C[i - 1];
	for (long j = n - 1; j >= 0; --j){
		B[C[A[j]]] = A[j];
		--C[A[j]];
	}
}
int main(){
	scanf("%ld", &n);
	int MAX = -1;
	for (long i = 0; i < n; ++i) scanf("%d", &A[i]);
	for (long i = 0; i < n; ++i){
		MAX = max(MAX, A[i]);
	}
	CountingSort(MAX);
	for (long i = 1; i <= n; ++i){
		if (i != 1) cout << ' ';
		cout << B[i];
	}
	cout << '\n';
}

Measured memory_bytes: 16916
import java.util.*;
//import java.math.BigInteger;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        char[] c = str.toCharArray();
        int A = sc.nextInt();
        char[] ans = new char[1000];
        int count = 0;
        //int[] p = new int[N];
        //a[0] = Character.getNumericValue(str.charAt(0));
        //boolean test = false;
        
        for(int i=0; i<str.length(); i++){
            if(i%A==0){
                ans[i/A] = c[i];
                count++;
                //System.out.println(i+":"+A+":"+ans[i/A]);
            }
            //System.out.println(count);
        }
        for(int i=0; i<count; i++){
            System.out.print(ans[i]);
        }
        System.out.println("");
    }
}


Measured memory_bytes: 36208
//
#define _USE_MATH_DEFINES
#include <vector>
#include <set>
#include <array>
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <numeric>
#include <bitset>
//
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
inline void yes(bool cond) { cond ? puts("Yes") : puts("No"); }
template<typename Type> inline void chmin(Type& a, Type b) { if (a > b) a = b; }
template<typename Type> inline void chmax(Type& a, Type b) { if (a < b) a = b; }
template<typename Type> inline void sort(Type& arr) { std::sort(arr.begin(), arr.end()); }
template<typename Type> inline Type nth(vector<Type>& arr, size_t pos) { std::nth_element(arr.begin(), arr.begin() + pos, arr.end()); return arr[pos]; }
#define BIGP   1000000007
#define INF_I  std::numeric_limits<ll>::max()
#define INF_F  std::numeric_limits<float>::infinity()
#define PI  3.1415926535
//
#include <iomanip>
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    ll iA, iB, iH, iM;
    cin >> iA >> iB >> iH >> iM;
    ld A = ld(iA);
    ld B = ld(iB);
    ld H = ld(iH);
    ld M = ld(iM);
    ld dt = (H / 12.0 + M / (60.0 * 12.0) - M / 60.0) * 2.0 * M_PI;
    ld R2 = A * A + B * B - 2.0 * A * B * cosl(dt);
    ld R = sqrtl(R2);
    printf("%16.16Lf", R);
    return 0;
}

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

const int base = 1e9 + 7;
bool ok(int k) {
    for(int i = 2; i * i <= k; i++) {
        if(k % i == 0) return false;
    }
    return true;
}

int n;
vector< int>  prime() {
    vector< int> rv;
    for(int i = 2; i <= n; i++) {
        if(ok(i)) rv.emplace_back(i);
    }
    return rv;
}

int main() {
    cin >> n;
    vector<int> p = prime();
    vector< int> cnt(p.size());

    int res = 1;
    for (int i = 2; i <= n; ++i) {
        int z = i;
        for(int k = 0; z > 1; ++k) {
            while(z % p[k] == 0) {
                cnt[k]++;
                z /= p[k];
            }
        }
    }

    for(int x: cnt) res = res * 1LL * (x + 1) % base;
    cout << res << endl;
}

Measured memory_bytes: 764
#include <iostream>
#include <vector>

using namespace std;

struct UnionFind {
    vector<int> t;
    UnionFind(int n): t(n+1,-1) { }

    int root(int x) {
        if(t[x]<0) return x;
        else return t[x]=root(t[x]);
    }

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

    int size(int x) {
        return -t[root(x)];
    }

};


int main(int argc, char const *argv[])
{
    int n, m; cin >> n >> m;
    UnionFind uF(n);

    int x,y,z;
    for(int i=0;i<m;++i) {
        cin >> x >> y >> z;
        uF.merge(x, y);
    }
    int c=0;
    for(int i=1;i<=n;++i) {
        if(uF.root(i)==i) ++c;
    }
    cout << c << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main()
{
  long long x,z,v,time;
  cin>>x>>z>>v;
  time=x/v;
  if(x%v!=0){
  time++;
  }
  if(time<=z){
  cout<<"Yes"<<endl;
  }
  else{
  cout<<"No"<<endl;
  }
}

Measured memory_bytes: 3628
//#include<bits/stdc++.h> using namespace std;
#include<iostream>
using namespace std;
#include<algorithm>
#include<map>
#include<vector>
#include<set>
#include<stack>
#include<queue> //priority_queue inside queue
#include<deque>
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define nl '\n'
typedef long long ll;
typedef unsigned long long ull;
#define f(i,start,end) for(i=start;i<=end;i++)
#define min_heap priority_queue<int, vector<int>, greater<int> >
#define max_heap priority_queue<int>

bool isPrime(int n)
{
    for(int i=2; i*i<=n; i++)
    {
        if(n%i==0) return false;
    }
    return true;
} //returns true if prime!


int main()
{
    fast;
//int t=0,tc=0; cin >> tc; f(t,1,tc) //testcases
    {
        ull x; cin >> x;
        ull n=100;
        int ans = 0;
        while(n<x)
        {
            n += (n/100);
            ans++;
        }
        cout << ans << nl;
    }
    return 0;
}
    

Measured memory_bytes: 3620
import java.util.*;
import java.io.*;

public class Main {
    static StringTokenizer st;
    static BufferedReader br;  
    static PrintWriter out;
 
    static int parent[]; 

    public static void main(String[] args) throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
 
        int N = nextInt();
        int M = nextInt();
     
        parent = new int [N+1];
 
           
        ArrayList<Integer> matrix [] = new ArrayList [N+1];

        for (int x=1; x<=N; x++) {
            matrix[x] = new ArrayList<Integer>();
        }

        for (int x=1; x<=M; x++) {
            int one = nextInt();
            int two = nextInt();
            matrix[one].add(two);
            matrix[two].add(one);
        }
    
        bfs(matrix, 1);
        
        boolean flag = true;
        for (int x=1; x<=N; x++) {
            if(parent[x] == 0){
                flag = false;
                break;
            }
        }
        if(flag){
            System.out.println("Yes");
            for (int x=2; x<=N; x++) {
                System.out.println(parent[x]);
            }
        }
        else{
            System.out.println("No");
        }
        
    
    }
        
    public static boolean bfs (ArrayList [] matrix,  int start) {
        Queue <Integer> queue = new LinkedList<Integer>();
        queue.add(start);
        
        while (!queue.isEmpty()) {
            int cur = queue.poll();
            for (int x=0; x<matrix[cur].size(); x++) {
                int now = (int) matrix[cur].get(x);
                if(parent[now]==0){
                    parent[now] = cur;
                    queue.add(now);
                }
            }
        }
        return false;
    }
    
      
    public static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
    public static long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    public static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    static String next() throws IOException {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine().trim());
        return st.nextToken();
    }
}

Measured memory_bytes: 73260
#include<bits/stdc++.h>
#define INF 9223372036854775807LL
#define inf 1000000007
#define SYOU(x) setprecision(x+1)
#define abs(x,y) (max(x,y)-min(x,y))
#define lol long long
#define mp make_pair
#define fi first
#define se second
using namespace std;
lol a,b,c,d;
int i[200010];
int u[100000];
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >>a;
  int ans=0;
  int an=inf;
  for(int n=0;n<a;n++){
    cin >>i[n];
    if(an>i[n]) ans++,an=i[n];
  }
  cout <<ans<<'\n';
  return (0);
}


Measured memory_bytes: 1024
n = gets.to_i
x = gets.split.map(&:to_f)
y = gets.split.map(&:to_f)
max, p1, p2, p3 = 0, 0, 0, 0;
max_array = []
n.times do |i|
  q = (x[i] - y[i]).abs
  max = q if q > max
  p1 += q
  p2 += q ** 2
  p3 += q ** 3
end
puts p1
puts Math.sqrt(p2)
puts p3 ** Rational(1, 3)
puts max

Measured memory_bytes: 6216
#include <iostream>

using namespace std;

int main(void)
{
  int a,b;
  cin>>a>>b;
int max;
  int num1=a+b,num2=a-b,num3=a*b;
  
  cin >> num1;
  cin >> num2;
  cin >> num3;
  
  max = num1;
  if( max < num2 ) {
    max = num2;
  }
  if( max < num3 ) {
    max = num3;
  }
  
  cout << max;
  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int N,M,X[1<<17];
int cnt[1<<17],mcnt[1<<17],p[1<<17];
main()
{
	cin>>N>>M;
	for(int i=0;i<N;i++)
	{
		cin>>X[i];
		cnt[X[i]]++;
	}
	int ans=0;
	for(int i=1;i<1<<17;i++)
	{
		ans+=cnt[i]/2;
		mcnt[i%M]+=cnt[i]%2;
		p[i%M]+=cnt[i]/2;
	}
	for(int i=0;i<=M/2;i++)
	{
		if(i==(M-i)%M)
		{
			ans+=mcnt[i]/2;
			continue;
		}
		int t=min(mcnt[i],mcnt[M-i]);
		ans+=t;
		mcnt[i]-=t;
		mcnt[M-i]-=t;
		ans+=min(p[M-i],mcnt[i]/2);
		ans+=min(p[i],mcnt[M-i]/2);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 1792
s = input()
n = len(s)
ans = 0

for bit in range(1 << n - 1):
    f = s[0]

    for i in range(n - 1):
        if bit & (1 << i):
            f += "+"
        f += s[i + 1]

    ans += sum(map(int, f.split("+")))

print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long

using namespace std;

int
main(void){
	int n; cin >> n;
	string s;
	vector<ll> vec(5, 0);
	for(int i = 0; i < n; i++){
		cin >> s;
		if(s[0] == 'M') vec[0]++;
		else if(s[0] == 'A') vec[1]++;
		else if(s[0] == 'R') vec[2]++;
		else if(s[0] == 'C') vec[3]++;
		else if(s[0] == 'H') vec[4]++;
	}
	ll ans = 0;
	for(int i = 0; i < 5; i++){
		for(int j = i + 1; j < 5; j++){
			for(int k = j + 1; k < 5; k++){
				ans += (vec[i] * vec[j] * vec[k]);	
			}
		}
	}
	cout << ans;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=998244353;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
struct mint{
    using ull=unsigned long long int;
    ull v;
    mint(ll vv=0){s(vv%mod+mod);}
    mint& s(ull vv){
        v=vv<mod?vv:vv-mod;
        return *this;
    }
    //オーバーロード
    mint operator-()const{return mint()-*this;}//符号反転
    mint&operator+=(const mint&val){return s(v+val.v);}
    mint&operator-=(const mint&val){return s(v+mod-val.v);}
    mint&operator*=(const mint&val){
        v=ull(v)*val.v%mod;
        return *this;
    }
    mint&operator/=(const mint&val){return *this*=val.inv();}
    mint operator+(const mint&val){return mint(*this)+=val;}
    mint operator-(const mint&val){return mint(*this)-=val;}
    mint operator*(const mint&val){return mint(*this)*=val;}
    mint operator/(const mint&val){return mint(*this)/=val;}
    mint pow(ll n)const{
        mint res(1),x(*this);
        while(n){
            if(n&1)res*=x;
            x*=x;
            n>>=1;
        }
        return res;
    }
     mint inv()const{return pow(mod-2);}
    //拡張ユークリッドの互除法
    /* mint inv()const{
        int x,y;
        int g=extgcd(v,mod,x,y);
        assert(g==1);
        if(x<0)x+=mod;
        return mint(x);
    }*/
    friend ostream& operator<<(ostream&os,const mint&val){
        return os<<val.v;
    }//出力
    bool operator<(const mint&val)const{return v<val.v;}
    bool operator==(const mint&val)const{return v==val.v;}
    bool operator>(const mint&val)const{return v>val.v;}
};
mint dp[3005][3005];
bool used[3005][3005];
int main(){
 int n,m;
 cin>>n>>m;
 V<ll> a(n);
 for(int i=0;i<n;i++){
     cin>>a[i];
 }
 dp[0][0]=1;
 used[0][0]=true;
 for(int i=0;i<n;i++){
     for(int j=m;j>=0;j--){
         dp[i+1][j]+=dp[i][j]+(j==0?1:0);
         used[i+1][j]|=used[i][j];
         if(used[i][j]&&j+a[i]<=m){
             dp[i+1][j+a[i]]+=dp[i][j];
             used[i+1][j+a[i]]=true;
         }
     }
 }
 mint ans=0;
 ll cnt=0;
 for(int i=1;i<=n;i++){
     ans+=dp[i][m];
 }
 cout<<ans<<"\n";
}

Measured memory_bytes: 79616