akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define INF 2e9
#define LINF 1e18
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> P;

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

ll gcd(vector<ll>a) {
  ll ans = a[0];
  for (int i=1; i<sz(a); i++) {
    ans = gcd(ans, a[i]);
    if (ans != 1) break;
  }
  return ans;
}

bool IsPrime(ll num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

int main() {
    ll a, b; cin >> a >> b;

    ll GCD = gcd(a, b);
    ll ans = 0;

    bool prime = IsPrime(GCD);
    if (prime) {
        cout << 2 << endl;
        return 0;
    }

    vector<ll> can;
    for (int i=1; i<=(int)sqrt(GCD)+1; i++) {
        if (GCD%i == 0) {
            if (i == 1 || i == 2) {
                can.push_back(i);
                continue;
            }
            bool prime = IsPrime(i);
            if (prime) can.push_back(i);
            if (i >= sqrt(GCD)) continue;
            bool prime2 = IsPrime(GCD/i);
            if (prime2) can.push_back(GCD/i);
            // ll cnt = 0;
            // rep(j, sz(can)) {
            //     ll divi = gcd(i, can[j]);
            //     if (divi != 1) break;
            //     cnt++;
            // }
            // if (cnt == sz(can)) {
            //     can.push_back(i);
            //     bool prime = IsPrime(GCD/i);
            //     if (prime) can.push_back(GCD/i);
            //     //can.push_back(GCD/i);
            // }
        }
    }
    //rep(i, sz(can)) cout << can[i] << endl;
    cout << sz(can) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
#define Int long long int
typedef complex<double> P;
const int MOD = 1000000007;

Int mod_pow(Int x, Int n, Int mod){
  if(n == 0) return 1;
  Int ret = mod_pow(x * x % mod, n / 2, mod);
  if(n & 1) ret = ret * x % mod;
  return ret;
}

int main() {
  Int M, N; cin >>M >>N;
  cout <<mod_pow(M, N, MOD) <<endl;
  return 0;
}

Measured memory_bytes: 1160
hash=Hash.new
while str=gets do
   str=str.chomp.split(' ')
   str[1]=str[1].to_i
   if hash.key?(str[0])
      hash[str[0]].push(str[1])
   else
      hash[str[0]]=Array.new
      hash[str[0]].push(str[1])
   end
end
hash.sort.each do |key,value|
   puts key
   flag=false
   value.sort.each do |out|
      print ' 'if flag
      flag=true
      print out
   end
   puts
end

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

using ll=long long;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DMP(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define ZERO(x) memset(x,0,sizeof(x))

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%lld",&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(int x,int suc=1){
	printf("%lld",x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341919];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341919];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(a>b)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

const int inf=LLONG_MAX/3;

struct SegTree{
	vector<pi> buf;
	int s;
	SegTree(int n){
		s=1;
		while(s<n)s*=2;
		buf.assign(s*2,pi(inf,-1));
	}
	void Update(int i,pi v){
		i+=s;
		buf[i]=v;
		while(i>>=1)
			buf[i]=min(buf[i*2],buf[i*2+1]);
	}
	pi Get(int b,int e,int l,int r,int i){
		if(e<=l||r<=b)return pi(inf,-1);
		if(b<=l&&r<=e)return buf[i];
		return min(Get(b,e,l,(l+r)/2,i*2),Get(b,e,(l+r)/2,r,i*2+1));
	}
	pi Get(int b,int e){
		if(e<=b)return pi(inf,-1);
		return Get(b,e,0,s,1);
	}
};

struct Wafrelka{
	int v1,v2,s1,s2,l,r;
	bool operator<(const Wafrelka&rhs)const{
		return v1>rhs.v1;
	}
};

signed main(){
	int n=read();
	SegTree e(n/2),o(n/2);
	REP(i,n){
		int x=read();
		(i%2==0?e:o).Update(i/2,pi(x,i));
	}
	vi q;
	priority_queue<Wafrelka> pq;
	const auto add=[&](int l,int r){
		if(r<=l)return;
		pi x=(l%2==0?e:o).Get(l/2,r/2);
		pi y=(l%2==0?o:e).Get((x.second+1)/2,(r+1)/2);
		pq.push(Wafrelka{x.first,y.first,x.second,y.second,l,r});
	};
	add(0,n);
	while(!pq.empty()){
		auto x=pq.top();pq.pop();
	//	cerr<<x.v1<<" "<<x.v2<<" "<<x.s1<<" "<<x.s2<<" "<<x.l<<" "<<x.r<<endl;
		q.PB(x.v1);
		q.PB(x.v2);
		add(x.l,x.s1);
		add(x.s1+1,x.s2);
		add(x.s2+1,x.r);
	}
	REP(i,n)
		print(q[i],i==n-1?1:2);
}

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

using namespace std;

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

    int i,j;
    int n,a,b;
    cin>>n>>a>>b;
    cout<<min(n*a,b)<<endl;
    return 0;
}


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

using namespace std;

using ll = long long;

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

    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n);
    for (int i = 0; i < n; ++i) cin >> a[i];
    for (int i = 0; i < n; ++i) cin >> b[i];
    for (int i = 0; i < n; ++i) cin >> c[i];

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

    vector<ll> x(n);
    for (int j = n - 1, k = n; 0 <= j; --j) {
        while (0 < k && b[j] < c[k - 1]) --k;
        x[j] = n - k;
    }
    for (int k = n - 2; 0 <= k; --k)
        x[k] += x[k + 1];

    ll cnt = 0;
    for (int i = n - 1, j = n; 0 <= i; --i) {
        while (0 < j && a[i] < b[j - 1]) --j;
        if (j < n) cnt += x[j];
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 2176
import java.util.*;
 
public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		if(a<b && b<c){System.out.println("Yes");}
    	else{System.out.println("No");}
      
	}
}



Measured memory_bytes: 26224
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
using namespace std;


int main (int argc, char const *argv[])
{
    int A,B;
    cin>>A>>B;

    
    if (A<=8&&B<=8) {
        cout<<"Yay!"<<endl;
    }
    else
    {
        cout<<":("<<endl;
    }
    
    
    return 0;
}

Measured memory_bytes: 256
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,K;
    cin >> N >> K;
    ll H[200010];
    rep(i,0,N) cin >> H[i];
    sort(H, H+N, greater<ll>());
    ll ans = 0;
    rep(i,K,N) ans += H[i];
    print(ans);    

}

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("atcoderregularcontest");
            //b
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("abcdefghijklmnopqrstuvwxyz");
            //None
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("fajsonlslfepbjtsaayxbymeskptcumtwrmkkinjxnnucagfrg");
            //d
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        string S = InputList[0];

        var CharSet = new HashSet<char>(S);

        for (char I = 'a'; I <= 'z'; I++) {
            if (CharSet.Contains(I) == false) {
                Console.WriteLine(I);
                return;
            }
        }
        Console.WriteLine("None");
    }
}


Measured memory_bytes: 11616
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int H,W;
string S[13];

vector<int> x,y;

void check(){
    string col[13]={};
    for(int i=0;i<x.size();i++){
        for(int j=0;j<W;j++){
            col[j].push_back(S[x[i]][j]);
        }
    }
    for(int i=0;i<y.size();i++){
        for(int j=0;j<W;j++){
            col[j].push_back(S[y[i]][j]);
        }
    }

    bool used[13]={};
    for(int i=0;i<W;i++){
        if(used[i]) continue;
        string nowCol=col[i];
        reverse(nowCol.begin(),nowCol.end());
        for(int j=i+1;j<W;j++){
            if(used[j]) continue;
            if(nowCol==col[j]){
                used[i]=true;
                used[j]=true;
                break;
            }
        }
    }
    int no=0;
    bool suc=false;
    for(int i=0;i<W;i++){
        if(!used[i]) no++;
    }
    if(no==0) suc=true;
    else if(no==1){
        int last=0;
        for(int i=0;i<W;i++){
            if(!used[i]) last=i;
        }
        string rev=col[last];
        reverse(rev.begin(),rev.end());
        if(rev==col[last]) suc=true;
    }

    if(suc){
        cout<<"YES"<<endl;
        exit(0);
    }
    return;
}

void setPair(int now){
    int p=__builtin_popcount(now);
    if(p==H){
        reverse(x.begin(),x.end());
        check();
        reverse(x.begin(),x.end());
        return;
    }

    if(p==0&&H%2){
        for(int i=0;i<H;i++){
            x.push_back(i);
            setPair(now|(1<<i));
            x.pop_back();
        }
    }else{
        vector<int> t;
        for(int i=0;i<H;i++){
            if(now&(1<<i)) continue;
            t.push_back(i);
        }
        for(int i=1;i<t.size();i++){
            x.push_back(t[0]);
            y.push_back(t[i]);
            setPair(now|(1<<t[0])|(1<<t[i]));
            x.pop_back();
            y.pop_back();
        }
    }
    return;
}

int main(){
  cin>>H>>W;
  for(int i=0;i<H;i++){
      cin>>S[i];
  }
  setPair(0);
  cout<<"NO"<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//原因見つかった
int main(){
  int64_t a,b,c;
  cin >> a >> b >> c;
  if(a==b&&b==c&&a%2==0&&b%2==0&&c%2==0){
    cout << -1 << endl;
  }else{
    int64_t p=0,as=a,bs=b,cs=c;
    while(a%2==0&&b%2==0&&c%2==0){
      a=bs/2+cs/2;
      b=as/2+cs/2;
      c=as/2+bs/2;
      as=a;
      bs=b;
      cs=c;
      p++;
    }
  cout << p << endl;
  }
  return 0;
}
  

Measured memory_bytes: 3552
#include <iostream>
 
using namespace std;
 
int GCD(int a, int b)
{
    if(a % b == 0) { return b; }
 
    if(b % a == 0) { return a; }
 
    if(a > b) { return GCD(a % b, b); }
 
    if(a < b) { return GCD(a, b % a); }
}
 
int LCM(int a, int b)
{
    return a / GCD(a, b) * b;
}
 
int main()
{
    int a, b;
 
    while(cin >> a >> b)
    {
        cout << GCD(a, b) << ' ' << LCM(a, b) << endl;
    }
 
    return 0;
}


Measured memory_bytes: 3088
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <numeric>
#include <mutex>
#include <cmath>
#include <set>
#include <climits>

#define mod 1000000007
#define mp make_pair
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG

using namespace std;
using ll = long long;
using lli = long long int;
using pii = pair<int, int>;
 
 int main(){
	 int N, a, b, ans = 0;
	 cin >> N;
	 rep(i, N){
		 cin >> a >> b;
		 ans += b - a + 1;
	 }
	 cout << ans;
	 return 0;
 }

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  map<int, int> MA;
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
    MA[i - A.at(i)]++;
    A.at(i) += i;
  }
  long ans = 0;
  for (auto a : A) ans += MA[a];
  cout << ans << "\n";
}

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


int main()
{
	long long int N,K,x;
	cin>>K>>N;
	vector <long long int> A(N,0),B(N);
	for(long long int i=0;i<N;i++)
	{
		cin>>x;
		A[i]=x;
	}
	
	sort(A.begin(),A.end());
	
	for(long long int i=0;i<N-1;i++)
	B[i]=A[i+1]-A[i];
	B[N-1]=K-A[N-1]+A[0];
	
/*	for(long long int i=0;i<N;i++)
	cout<<B[i]<<" ";*/
	
	
	sort(B.begin(),B.end());
	x=0;
	for(long long int i=0;i<N-1;i++)
	x+=B[i];
	
	cout<<x<<"\n";
	
	
	return 0;
}


Measured memory_bytes: 3456
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

int main(){
    vector<int> v(3);
    rep(i,3)cin>>v[i];
    sort(all(v));
    int ans = v[0]+v[1]+v[2]*10;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j,k;
  string s;
  cin>>s;
  int n=s.size();
  int ans=INF;
  rep(i,26){
    string tmp=s;
    rep(j,n){
      bool c=true;
      rep(k,n-j)if(tmp[k]!='a'+i)c=false;
      if(c)break;
      rep(k,n-j)if(tmp[k+1]=='a'+i)tmp[k]=tmp[k+1];
    }
    ans=min(ans,j);

  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#define pb push_back
#define mp make_pair
#define ll long long
using namespace std;
const int N = 5e3 + 5;

int n, k;
int a[N];

bool have[N];
bool check(int id)
{
    if(id == 0)
        return true;

    vector <int> sums = {0};
    memset(have, 0, sizeof(have));
    have[0] = true;
    for(int i = 1; i <= n; i++)
    {
        if(i == id)
            continue;
        int sz = (int)sums.size();
        for(int j = 0; j < sz; j++)
        {
            if(sums[j] + a[i] < k && !have[sums[j] + a[i]])
            {
                sums.pb(sums[j] + a[i]);
                have[sums[j] + a[i]] = true;
            }
        }
    }
    for(int x: sums)
        if(x < k && x + a[id] >= k)
            return false;
    return true;
}



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    cin >> n >> k;
    for(int i = 1; i <= n; i++)
    {
        cin >> a[i];
        a[i] = min(a[i], k);
    }

    sort(a + 1, a + n + 1);
    int low = 0, high = n;
    while(low <= high)
    {
        int mid = (low + high) / 2;
        if(check(mid))
            low = mid + 1;
        else
            high = mid - 1;
    }

    cout << low - 1 << endl;

    return 0;
}


Measured memory_bytes: 384
# -*- coding: utf-8 -*-


def main():
    n, y = map(int, input().split())

    a, b, c = -1, -1, -1
    loop_max = int(y / 10000)
    for ia in range(loop_max + 1):
        if ia * 10000 > y:
            continue

        second_loop_max = min(int(y - (ia * 10000) / 5000), n - ia)
        for ib in range(second_loop_max + 1):
            ic = n - ia - ib
            total = ia * 10000 + ib * 5000 + ic * 1000
            if total == y and (ia + ib + ic) == n:
                a = ia
                b = ib
                c = ic
                break

    print(" ".join(map(str, (a, b, c))))


if __name__ == '__main__':
    main()


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

using namespace std;

typedef pair<int, int> P;

int main()
{
  int n; int t = 0;
  while(cin >> n, n) {
    t++;
    double x[101], y[101], r[101];
    vector<double> X, Y;
    for(int i = 0; i < n; i++) {
      cin >> x[i] >> y[i] >> r[i];
      X.push_back(x[i]-r[i]); X.push_back(x[i]+r[i]);
      Y.push_back(y[i]-r[i]); Y.push_back(y[i]+r[i]);
    }
    sort(X.begin(), X.end());
    sort(Y.begin(), Y.end());
    X.erase(unique(X.begin(), X.end()), X.end());
    Y.erase(unique(Y.begin(), Y.end()), Y.end());    
    vector<P> xx(n), yy(n);
    for(int i = 0; i < n; i++) {
      xx[i].first  = find(X.begin(), X.end(), x[i]-r[i]) - X.begin();
      xx[i].second = find(X.begin(), X.end(), x[i]+r[i]) - X.begin();
      yy[i].first  = find(Y.begin(), Y.end(), y[i]-r[i]) - Y.begin();
      yy[i].second = find(Y.begin(), Y.end(), y[i]+r[i]) - Y.begin();
    }
    bool mas[202][202] = {{false}};
    for(int i = 0; i < n; i++) {
      for(int j = yy[i].first; j < yy[i].second; j++) {
	for(int k = xx[i].first; k < xx[i].second; k++) mas[j][k] = true;
      }
    }
    double ans = 0.0;
    for(int i = 0; i < (int)Y.size()-1; i++) {
      for(int j = 0; j < (int)X.size()-1; j++) {
	if(mas[i][j])  ans += (X[j+1]-X[j])*(Y[i+1]-Y[i]);
      }
    }
    printf("%d %.2f\n", t, ans);
  }
  return 0;
}

Measured memory_bytes: 3120
/*********************************************JMD**********************************************/
//                                  |\  |     | |   |   /\                                   //
    //                              | \ |     | |---|  /--\                              //
        //                          |  \| |___| |   | /    \1999                     //
/*******************************************************************************************/
#include <bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;

#define mp make_pair
#define pb push_back
#define pf push_front
#define ss second
#define ff first
#define mem(x,val) memset(x,val,sizeof(x))
#define forr(i,a,b) for(ll i=a;i<b;i++)
#define f(i,n) forr(i,0,n)
#define sz(x) ll((x).size())
#define all(x) ((x).begin(),(x).end())
#define asc(x) ((int)(x))
#define precision(x) cout<<fixed<<setprecision((x));

const ll mod=1e9 + 7;

/*******************************************************************************************/
vector<vector<ll> > g;
vector<ll> vis;

void dfs(ll x)
{
    vis[x]=1;
    f(i,g[x].size())
    {
        if(!vis[g[x][i]]) dfs(g[x][i]);
    }
}
void solve()
{
    ll n,m;
    cin>>n>>m;
    g.resize(n);
    vis.resize(n);

    f(i,m)
    {
        ll x,y,z;
        cin>>x>>y>>z;
        x--,y--;

        g[x].pb(y);
        g[y].pb(x);
    }

    ll ans=0;

    f(i,n)
    {
        if(!vis[i]) dfs(i),ans++;
    }

    cout<<ans<<"\n";
    return;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll t=1;
    //cin>>t;
    clock_t launch=clock();

    while(t--)
    {
        solve();
    }

    clog<<((long double)(clock()-launch)/CLOCKS_PER_SEC)<<"\n";
}


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

using namespace std;

int main(){
    long long S;
    cin >> S;

    long long S_real = S;
    int S_n = 0;

    while (S > 0){
        S = S / 10;
        S_n = S_n + 1;
    }
    
    //cout << "S_n=" << S_n << endl;

    vector <int> S_dig(S_n);

    for(int i = 0; i < S_n; i++)
    {
        S_dig[i] = S_real % 10;
        S_real = S_real / 10;
    }
/*
    for(int i = 0; i < S_n; i++)
    {
        cout << "S_dig[" << i << "]=" << S_dig[i] << endl;
    }
*/

    int min = 999;
    for(int i = 0; i < S_n; i++)
    {
        int n = S_dig[i] + S_dig[i + 1] * 10 + S_dig[i + 2] * 100;
        int m = n - 753;
        m = std::abs(m);

        if (m < min) {
            min = m;
        }
    }
    
    cout << min << endl;


    return 0;
}

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

const int INF = 1001001001;
vector<int> path[100005];

int main() {
  int n, m;

  cin >> n >> m;
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    path[a].push_back(b);
    path[b].push_back(a);
  }

  queue<int> q;
  vector<int> dist(n, INF);
  vector<int> pre(n, -1);
  dist[0] = 0;
  q.push(0);

  while (!q.empty()) {
    int tmp = q.front();
    q.pop();
    for (int tmpb : path[tmp]) {
      if (pre[tmpb] != -1) {
        continue;
      } else {
        pre[tmpb] = tmp;
        q.push(tmpb);
      }
    }
  }

  int flag = true;
  rep(i, n) {
    if (i != 0 && pre[i] == -1) {
      flag = false;
    }
  }
  if (flag == true) {
    cout << "Yes" << endl;
    rep(i, n) {
      if (i == 0) continue;
      int tmpa = pre[i];
      ++tmpa;
      cout << tmpa << endl;
    }
  } else {
    cout << "No" << endl;
  }

  return 0;
}

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

int main(){
  long long int n, b, r, ans, rem;
  cin >> n >> b >> r;
  ans=n/(r+b)*b;
  rem=n%(r+b);
  ans+=min(rem,b);
  cout << ans << endl;;

  return 0;
}


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

int main(){
	int p, q;
	map<int, bool> used;
	vector<int> nums;
	while(cin >> p >> q){
		used.clear();
		nums.clear();
		p %= q;
		p *= 10;
		int i = 0;
		while(p != 0){
			used[p] = true;
			nums.push_back(p);
			cout << p / q;
			p %= q;
			p *= 10;
			if(used[p]){
				while(i < nums.size() && nums[i] != p) i++;
				break;
			}
		}
		cout << endl;
		if(p != 0){
			for(int j = 0; j < i; j++) cout << " ";
			for(int j = i; j < nums.size(); j++) cout << "^";
			cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.*;

public class Main {
	int n, h, w;
	boolean[] hc, wc;
	
	void run(){
		Scanner sc = new Scanner(System.in);
		
		n = sc.nextInt();
		w = sc.nextInt();
		h = sc.nextInt();
		wc = new boolean[w];
		hc = new boolean[h];
		
		for(int i=0;i<n;i++){
			int x = sc.nextInt();
			int y = sc.nextInt();
			int ww = sc.nextInt();
			
			int stx = Math.max(0, x-ww);
			int edx = Math.min(w-1, x-1+ww);
			for(int j=stx;j<=edx;j++) wc[j] = true;
			
			int sty = Math.max(0, y-ww);
			int edy = Math.min(h-1, y-1+ww);
			for(int j=sty;j<=edy;j++) hc[j] = true;
		}
		if(checkWc() || checkHc()) System.out.println("Yes");
		else System.out.println("No");
		
		sc.close();
	}
	
	boolean checkWc(){
		for(int j=0;j<w;j++){
			if(!wc[j]) return false;
		}
		return true;
	}
	
	boolean checkHc(){
		for(int i=0;i<h;i++){
			if(!hc[i]) return false;
		}
		return true;
	}
	
	public static void main(String[] args) {
		new Main().run();
	}

}

Measured memory_bytes: 96708
import sys
N=int(input())
D=list(map(int,input().split()))
M=int(input())
T=list(map(int,input().split()))
D.sort()
T.sort()
for i in range(M-1,-1,-1):
  while D:
    q=D.pop()
    if T[i]==q:
      #print(i)
      break
    elif T[i]>q:
      print("NO")
      sys.exit()
  else:
    print("NO")
    sys.exit()
print("YES")

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

using namespace std;

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

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

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

int c[510];
int d[510];

bool route[1010];

int main(void){
	int n,m;
	cin >> n >> m;
	rep(i,m){
		cin >> c[i];
		cin >> d[i];
		for(int j=c[i];j<d[i];++j)
			route[j]=true;
	}

	int ans=n+1;

	rep(i,n+1)
		if(route[i])
			ans+=2;
		
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1168
N,K=map(int,input().split())
h=list(map(int,input().split()))

dp=[100000 for i in range(N)]
dp[0]=0

for i,h_now in enumerate(h):
    if i==0:
        continue
    x=max(0,i-K)
    dp[i]=min([dp_i+abs(h_now-h_i) for dp_i,h_i in zip(dp[x:i],h[x:i])])

print(dp[N-1])

Measured memory_bytes: 13980
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<map>
#include<numeric>
#include<set>
#include<sstream>
#include<string>
#include<utility>
#include<vector>

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MAX 1000000000+7
using namespace std;
typedef long long ll;

int main(){
  string S; cin >> S;
  cout << (S <= "2019/04/30" ? "Heisei" : "TBD") << endl;
  return 0;
}


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

#define FOR(i,a,b)  for(ll i=a;(i)<(b);++(i))
#define RFOR(i,a,b) for(ll i=a;(i)>=(b);--(i))
#define REP(i,n)    FOR(i,0,n)
#define RREP(i,n)   RFOR(i,n,0)
#define ALL(v)      v.begin(), v.end()
#define UNIQ(v)     sort(ALL(v)); v.erase(unique(ALL(v)), v.end())
#define BIT(n)      (1LL<<(n))
#define DEBUG(a)    cout << #a << " = " << a << endl

const int inf = 1001001001;
const int mod = (int)1e9+7;
//const ll inf = 1e15;
//const ll mod = 1e9+7;

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

int main() {
    int X;
    cin >> X;
    //RFOR(i, 0, -1*inf) {
    //    A = i;
    //    B = A - 1;
    //    int X = pow(A, 5) - pow(B, 5);
    //    if (X > 1000000001) break;
    //}
    //DEBUG(A);

    int A, B;
    FOR(i, -120, 120) {
        FOR(j, -120, 120) {
            if(pow(i, 5) - pow(j, 5) == X) {
                A = i;
                B = j;
            }
        }
    }

    cout << A << " " << B << endl;
}


Measured memory_bytes: 4060
#include<bits/stdc++.h>
using namespace std;
int n;
int dfs(int m,int d,int x){
    int ans=0;
  if(m==n)return 1;
  if(d==4)return 0;
   if(x*x+m<=n)for(int i=x;i*i<=n;i++) ans+=dfs(m+i*i,d+1,i);
   return ans;
}

int main(){
  while(1){
  cin>>n;
  if(n==0)break;
  cout<<dfs(0,0,1)<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>

int linearSearch(int *,int *,int,int);

int main(){
  int s[10000];
  int t[500];
  int n,q,i,j;

  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&s[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++) scanf("%d",&t[i]);
  printf("%d\n",linearSearch(s,t,n,q));
  return 0;
}
int linearSearch(int *s,int *t,int n,int q){
  int i,j,kazu=0;

  for(j=0;j<q;j++){
    for(i=0;i<n;i++){
      if(t[j]==s[i]){
	kazu++;
	break;
      }
    }
  }
  return kazu;
}



Measured memory_bytes: 2048
#include <iostream>

using ll=long long int;

constexpr int MAX_K=(int)1e5;

constexpr ll INF=(ll)1e18;

int k;
ll a[MAX_K];

int main() {

    std::cin>>k;

    for(int i=k-1;i>=0;--i)
        std::cin>>a[i];

    ll min=2,max=2;

    for(int i=0;i<k;++i){
        if(max/a[i]*a[i]>=min||(min+a[i]-1)/a[i]*a[i]<=max){
            max=max/a[i]*a[i]+a[i]-1;
            min=(min+a[i]-1)/a[i]*a[i];
        }
        else{
            std::cout<<-1<<std::endl;
            return 0;
        }
    }

    std::cout<<min<<' '<<max<<std::endl;

    return 0;
}

Measured memory_bytes: 1024
use std::io;
use std::cmp;


/// https://beta.atcoder.jp/contests/arc059/tasks/arc059_a
fn main() {
    let _ = read_one::<usize>();
    let an = read::<isize>();
    let mut ans = 10000 * 10000;
    for i in 0..201 {
        let sum = an.iter().fold(0, |s, x| s + (x - (i - 100)) * (x - (i - 100)));
        ans = cmp::min(ans, sum);
    }
    println!("{}", ans);

}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

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

inline long fact(long N, long x, long ans){
	if(x > N){
		return ans;
	}else{
		ans += N/(2*x);
		return fact(N, x*5, ans);
	}
}

int main(){
	long N;
	std::cin >> N;
	if(N%2!=0){
		std::cout << 0 << std::endl;
	} else {
		std::cout << fact(N, 5, 0) << std::endl;
	}
}


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

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

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  double n,m,d;
  cin>>n>>m>>d;
  if(d==0)cout<<setprecision(20)<<(1./n)*(m-1)<<endl;
   else cout<<setprecision(20)<<(2*(n-d)/(n*n))*(m-1)<<endl;
  return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<set>
#include <bitset>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
#include <limits>
#include <numeric>
#include <type_traits>
#define int long long
#define ll long long
#define mod  1000000007
#define MOD  1000000007
#define inf 1e17
#define rep(i,j,n) for(int i=j;i<n;i++)
#define P pair<int,int>
#define ps push_back
#define all(x) x.begin(),x.end()
double pi = 3.141592653589793;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//ここから始めよう
string s,t;
int dp[3333][3333];

signed main(){
    cin>>s>>t;
for (int i = 0; i < s.size(); ++i) {
        for (int j = 0; j < t.size(); ++j) {
            if (s[i] == t[j]) chmax(dp[i+1][j+1], dp[i][j] + 1);
            chmax(dp[i+1][j+1], dp[i+1][j]);
            chmax(dp[i+1][j+1], dp[i][j+1]);
        }
    }

    // 復元
    string res = "";
    int i = (int)s.size(), j = (int)t.size();
    while (i > 0 && j > 0)
    {
        // (i-1, j) -> (i, j) と更新されていた場合
        if (dp[i][j] == dp[i-1][j]) {
            --i; // DP の遷移を遡る
        }

        // (i, j-1) -> (i, j) と更新されていた場合
        else if (dp[i][j] == dp[i][j-1]) {
            --j; // DP の遷移を遡る
        }

        // (i-1, j-1) -> (i, j) と更新されていた場合
        else {
            res = s[i-1] + res; // このとき s[i-1] == t[j-1] なので、t[j-1] + res でも OK
            --i, --j; // DP の遷移を遡る
        }
    }
    cout << res << endl;
}

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

#define dump(...) do{print_vars(cout<<"# "<<#__VA_ARGS__<<'=',__VA_ARGS__);cout<<endl;}while(0)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

void print_vars(ostream&){}
template<typename Car,typename... Cdr>
void print_vars(ostream& os,const Car& car,const Cdr&... cdr){
	print_vars(os<<car<<(sizeof...(cdr)?",":""),cdr...);
}

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<int I,typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<int I,typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	os<<get<I>(t)<<(sizeof...(Cdr)?",":"");
	print_tuple<I+1,Cdr...>(os,t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<0,Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

int main()
{
	#ifndef _GLIBCXX_DEBUG
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	constexpr char endl='\n';
	#endif

	for(int h,w;cin>>h>>w&&h|w;){
		vs grid(h);
		rep(i,h) cin>>grid[i];

		vi f(26);
		rep(i,h) rep(j,w) f[grid[i][j]-'a']++;

		int zero=0,odd=0;
		rep(i,26){
			f[i]%=4;
			if(f[i]==0) zero++;
			if(f[i]&1) odd++;
		}

		if(h%2==1&&w%2==1){
			if(odd>1)
				cout<<"No"<<endl;
			else{
				int rest=2*(26-zero-odd);
				cout<<(rest<=(h+w-1)?"Yes":"No")<<endl;
			}
		}
		else if(h%2==1||w%2==1){
			if(odd>0)
				cout<<"No"<<endl;
			else{
				int rest=2*(26-zero);
				cout<<(rest<=(h%2==0?h:w)?"Yes":"No")<<endl;
			}
		}
		else
			cout<<(zero==26?"Yes":"No")<<endl;
	}
}


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

using namespace std;

int a,s[1000001],d,cnt;

int main (){
	cin >> a >> d;
	for (int i = 1 ; i <= a; i++){
		cin >> s[i];
		if (s[i] >= d){
			cnt++;
		}
	}
	cout << cnt;
	return 0;
}

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

int main() {
	int n,x,t;
	cin >> n >> x >> t;
	if(n%x>0)
	{
		cout << (n/x + 1) * t << endl;
	}
	else
	{
		cout << (n/x) * t << endl;
	}
	return 0;
}


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

using namespace std;
#define DBG(x)                         \
    (void)(cout << "L" << __LINE__     \
                << ": " << #x << " = " \
                << (x) << '\n')
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
typedef long long ll;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;
const int INF = 0x3f3f3f3f;
const int maxn = 1100000;

void run_case()
{
    int ans = 0;
    string s;
    cin >> s;
    string t;
    cin >> t;
    for (int i = 0; i < s.size(); i++)
    {
        if (s[i] != t[i])
            ans++;
    }
    cout << ans << "\n";
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    run_case();
    cout.flush();
    return 0;
}

Measured memory_bytes: 3780
import Data.IORef
import Control.Monad
import qualified Data.ByteString.Char8 as BC
import Data.Maybe(fromJust)
  
main :: IO()
main = BC.getLine >> BC.getContents >>= solve.map (fst.fromJust.BC.readInt).BC.lines >>= print
  
solve :: [Int] -> IO Int
solve (x : y : xs) = do
                a <- newIORef (y - x)
                b <- newIORef (if x < y then x else y)
                forM_ xs $ \z -> do
                    a' <- readIORef a
                    b' <- readIORef b
                    when (z - b' > a') $ writeIORef a (z - b')
                    when (z < b')      $ writeIORef b z
                readIORef a

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

#define ll long long
#define INF 99999999
#define INF_LL 1LL << 60
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

int main()
{
    string N;
    cin >> N;

    if( N[0] == '7' || N[1] == '7' ||N[2] == '7') cout << "Yes" << endl;
    else cout << "No" << endl;

}


Measured memory_bytes: 3596
#include<stdio.h>
#include<stdlib.h>

struct edge {
  int a;
  int b;
  int weight;
};
int *ufp, *ufr;
struct edge *ed;

void downheap(int, int);
int UF_find(int);
void UF_union(int, int);
int Kruskal(int, int);

int main(void)
{
  int i, j, v, e, s, t, w, cost;
  scanf("%d %d", &v, &e);
  ufp = (int*)malloc(sizeof(int) * v);
  ufr = (int*)malloc(sizeof(int) * v);
  ed = (struct edge*)malloc(sizeof(struct edge) * e);
  for (i = 0; i < v; i++) {
    ufp[i] = i;
    ufr[i] = 0;
  }
  for (i = 0; i < e; i++) {
    scanf("%d %d %d", &s, &t, &w);
    ed[i].weight = w;
    ed[i].a = s;
    ed[i].b = t;
  }
  cost = Kruskal(v, e);
  printf("%d\n", cost);
  free(ufp);
  free(ufr);
  free(ed);
}

void downheap(int left, int right)
{
  int parent, child;
  struct edge root = ed[left];
  for (parent = left; parent < (right + 1) / 2; parent = child) {
    int l = 2 * parent + 1;
    if (ed[l].weight > ed[l + 1].weight && l + 1 <= right) child = l+1;
    else child = l;
    if (root.weight <= ed[child].weight) break;
    ed[parent] = ed[child];
  }
  ed[parent] = root;
}

int UF_find(int a)
{
  if (ufp[a] == a) return a;
  else {
    ufp[a] = UF_find(ufp[a]);
    return ufp[a];
  }
}

void UF_union(int a, int b)
{
  if (ufr[a] < ufr[b]) ufp[a] = b;
  else {
    ufp[b] = a;
    if (ufr[a] == ufr[b]) ufr[a]++;
  }
}

int Kruskal(int size, int esize)
{
  int i, selected = 0, cost = 0;
  for (i = esize / 2 - 1; i >= 0; i--) downheap(i, esize - 1);
  while (selected < size - 1) {
    int ea = UF_find(ed[0].a), eb = UF_find(ed[0].b);
    struct edge tmp = ed[0];
    if (ea != eb) {
      UF_union(ea, eb);
      cost += ed[0].weight;
      selected++;
    }
    ed[0] = ed[esize - 1];
    ed[esize - 1] = tmp;
    esize--;
    if (esize) downheap(0, esize - 1);
  }
  return cost;
}


Measured memory_bytes: 2984
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
    int n;
    cin >> n ;
    vector<int>A(n+1) , B(n);
    for(int i=0;i<=n;i++){
        cin >> A[i];
    }
    for(int i=0;i<n;i++){
        cin >> B[i];
    }
    int ans = 0;
    for(int i=0;i<n;i++){
        if(B[i] <= A[i]){
            ans += B[i];
        }
        else if(B[i] > A[i]){
            ans+=A[i];
            B[i] -= A[i];
            
            if(B[i] <= A[i+1]){
                ans+=B[i];
                A[i+1] -= B[i];
            }
            else if(B[i] > A[i+1]){
                ans += A[i+1];
                A[i+1] = 0;
            }
        }
    }

    cout << ans << '\n';
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <math.h>
using namespace std;

#define ll long long

void solve()
{
    // 入力の処理
    ll A, B;
    cin >> A >> B;
    if (1 <= A && A <= 9 &&
        1 <= B && B <= 9)
    {
        printf("%d\n", A * B);
    }
    else
    {
        printf("-1\n");
    }

    return;
}

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


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.IO;

public class Sample8{

	public static void Main(){

		int week = int.Parse(Console.ReadLine ());

		double result = debutResult (week);

		Console.WriteLine (result);

	}

	public static double debutResult (int week){

		double debut = 100000;

		for (int i = 0; i < week; i++){
		
			debut = debut * 1.05;


			debut *= 0.001;

			debut = Math.Ceiling (debut);

			debut *= 1000;
		}
			

		return debut;
	}
}

Measured memory_bytes: 5612
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using ull = uint64_t;
using P = pair<int, int>;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

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

    int N, C;
    cin >> N >> C;
    vector<vector<int>> d(C, vector<int>(C));
    for(int i = 0; i < C; ++i){
        for(int j = 0; j < C; ++j){
            cin >> d[i][j];
        }
    }
    vector<vector<int>> c(3, vector<int>(C, 0));
    for(int i = 0; i < N; ++i){
        for(int j = 0; j < N; ++j){
            int foo;
            cin >> foo;
            --foo;
            ++c[(i + j) % 3][foo];
        }
    }
    int ans = INF;
    for(int x = 0; x < C; ++x){
        int S = 0;
        for(int i = 0; i < C; ++i){
            S += d[i][x] * c[0][i];
        }
        for(int y = 0; y < C; ++y){
            if(x == y)  continue;
            int a1 = 0;
            for(int i = 0; i < C; ++i){
                a1 += d[i][y] * c[1][i];
            }
            S += a1;
            for(int z = 0; z < C; ++z){
                if(x == z || y == z)    continue;
                int a2 = 0;
                for(int i = 0; i < C; ++i){
                    a2 += d[i][z] * c[2][i];
                }
                S += a2;
                chmin(ans, S);
                S -= a2;
            }
            S -= a1;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3612
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
    public static boolean areDistinct(Integer arr[])
    {
        // Put all array elements in a HashSet 
        Set<Integer> s =
                new HashSet<Integer>(Arrays.asList(arr));

        // If all elements are distinct, size of 
        // HashSet should be same array. 
        return (s.size() == arr.length);
    }

    // Driver code 
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        Integer[] arr = new Integer[x];
        int i = 0;
        while (i < arr.length) {
           arr[i]  = sc.nextInt();
           i++;
        }

        if (areDistinct(arr))
            System.out.println("YES");
        else
            System.out.println("NO");
    }
} 

Measured memory_bytes: 94240
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#define maxn 105
using namespace std;
int n=100,a,b;
char s[maxn][maxn];
int main()
{
	scanf("%d%d",&a,&b);
	a--; b--;

	for(int i=1;i<=50;i++)
		for(int j=1;j<=n;j++)
			s[i][j]='.';

	for(int i=51;i<=n;i++)
		for(int j=1;j<=n;j++)
			s[i][j]='#';


	for(int i=1;i<=50;i++)
	{
		for(int j=1;j<=n;j++)
		{
			if(((i&1)|(j&1))==0 &&  b)
			{
				s[i][j]='#';
				b--;
			}
		}
	}

	for(int i=52;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		if(((i&1)|(j&1))==0 && a)
		{
			s[i][j]='.';
			a--;
		}
	}

	printf("%d %d\n",n,n);
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
			printf("%c",s[i][j]);
		printf("\n");
	}
}


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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define for_each(e, v) for (auto &e : v)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
const int MOD = 1e9 + 7;
const int INF = __INT_MAX__;               // 2^31 - 1
const long long INFLL = __LONG_LONG_MAX__; // 2^61 - 1
const int MAX_N = 1e5 + 5;
const double PI = acos(-1);

double dp[305][305][305];
int n;

double f(int c1, int c2, int c3) {
    int sum = c1 + c2 + c3;
    if (dp[c1][c2][c3] || sum == 0) return dp[c1][c2][c3];

    dp[c1][c2][c3] += 1.0 * n / sum;
    if (c1 > 0) dp[c1][c2][c3] += f(c1 - 1, c2, c3) * c1 / sum;
    if (c2 > 0) dp[c1][c2][c3] += f(c1 + 1, c2 - 1, c3) * c2 / sum;
    if (c3 > 0) dp[c1][c2][c3] += f(c1, c2 + 1, c3 - 1) * c3 / sum;

    return dp[c1][c2][c3];
}

int main() {
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    int cnt_1, cnt_2, cnt_3;
    cnt_1 = cnt_2 = cnt_3 = 0;
    SPC(10);
    rep(i, n) {
        if (a[i] == 1) cnt_1++;
        if (a[i] == 2) cnt_2++;
        if (a[i] == 3) cnt_3++;
    }

    out(f(cnt_1, cnt_2, cnt_3));
    return 0;
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int main(void){
	ll n,a,b;
	cin >> n >> a >> b;
	vector<ll> x(n);
	rep(i,n) cin >> x[i];

	ll ans=0LL;
	rep(i,1,n) ans+=min(1LL*a*(x[i]-x[i-1]),b);
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 1024