akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

class Main{
    int c1, c5, c10, c50, c100, c500, sum;

    void solve(){
        Scanner sc = new Scanner(System.in);
        c1 = sc.nextInt();
        c5 = sc.nextInt();
        c10 = sc.nextInt();
        c50 = sc.nextInt();
        c100 = sc.nextInt();
        c500 = sc.nextInt();
        long sum = c1 + c5*5 + c10*10 + c50*50 + c100*100 + c500*500;
        if ( sum >= 1000 ){
            System.out.println(1);
        } else {
            System.out.println(0);
        }
    }

    public static void main(String[] a){ new Main().solve(); }
}




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

int main(){
  int n;
  cin >> n;
  vector<ll> l(n+1);
  l[0]=2;
  l[1]=1;
  for(int i=0;i<n-1;i++){
    l[i+2]=l[i+1]+l[i];
  }
  cout << l[n] << endl;
}


Measured memory_bytes: 256
//To do- All bs, b_lift, ads(sa,ft(adv),st(node_adv),sut),gg(sp(multiple_constraints problem_traffic_hackerrank_uva),ffa,scc, dpot(ma,monta)),combinatorics, dpog(1900-2000)
//gauravsinghh
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long int
#define ld long double
#define db double
#define pii pair<int,int>
#define pll pair<long long,long long>
#define sii set<int>
#define sll set<long long>
#define vii vector<int> 
#define vll vector<long long>
#define mii map<int,int>
#define mll map<long long, long long>
#define lob lower_bound
#define upb upper_bound
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define pf push_front
#define ins insert
#define mp make_pair
#define w(t) cin >> t;while(t--)
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define os cout<<" "
#define bitcount __builtin_popcount
#define gcd __gcd
#define endl "\n"
#define present(s,x) (s.find(x) != s.end()) 
#define cpresent(s,x) (find(all(s),x) != s.end()) 
#define ford(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++) 
#define fors(container, it, a, b) for(__typeof(container.begin()) it = a; it != b; it++) 
#define MOD 1000000007
#define EPSILON 1e-9
#define PI 3.14159265358979323846
#define inf 999999999999999999
#define siz 100005
#define fbo find_by_order
#define ook order_of_key
#define sz(s) (int)s.size()
#define mem(n,m) memset(n,m,sizeof(n))
#define rep(i,n) for(ll i = 0; i < n; i++)
#define ren(i,n) for(ll i = n-1; i >= 0; i--)
#define all(x) x.begin(),x.end()
#define fo(i, a, b) for(int i = a; i <= b; i++)
#define ffo(i, a, b) for(int i = a; i >= b; i--)
#define MAX 100005
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")

void io_set() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

signed main(){ 
    IOS
    //io_set();
    string s;
    cin >> s;
    if(sz(s) == 1 && s[0] <= '9'){
        cout << s << endl;
        return 0;
    }
    else{
        ll x = s[0]-'0';
        string a = "";
        rep(i,sz(s)){
            a+=(x+'0');
        }
        if(a >= s){
            cout << a << endl;
        }
        else{
            a="";
            rep(i, sz(s)){
                a += ((x+1)+'0');
            }
            if(a >= s){
                cout << a << endl;
            }
        }
    }
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>


using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll, ll> pll;
int dx[4] = { 1,0,0,-1 };
int dy[4] = { 0,1,-1,0 };

#define ARRAY_MAX 30005

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;


ll dp[65][3];

ll nth_bit(ll num, ll n) {

	return (num >> n) & 1;
}



int main() {

	ll n;
	cin >> n;

	dp[60][0] = 1;

	for (int bit = 59; bit >= 0; bit--)
	{
		//下からiビット目
		for (int s = 0; s <= 2; s++)
		{
			//bitビット目まででnからs*2^bit小さい時に
			for (int k = 0; k <= 2; k++)
			{
				//kはbit+1ビット目でのs
				//次の桁でnから(s2)*2^(bit+1)小さい場合
				int s2 = min(2LL, 2 * s + nth_bit(n, bit) - k);
				if (s2 >= 0)
				{
					dp[bit][s2] += dp[bit + 1][s];
					dp[bit][s2] %= MOD;
				}
			}
		}
	}

	ll ans = (dp[0][0] + dp[0][1] + dp[0][2]) % MOD;
	cout << ans << endl;

	return 0;
}

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

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

template<class T> using v = std::vector<T>;
template<class T> using vv = v<v<T>>;

const int mod = 1000000007;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
//const int mod = 998244353;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


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

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};
double dp[3002][3002];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin >> n;
    dp[0][0] = 1;
    rep(i,n) {
        double p; cin >> p;
        for (int j = 0; j <= i; ++j) {
            dp[j+1][i+1] += dp[j][i] * p;
            dp[j][i+1] += dp[j][i] * (1 - p);
        }
    }

//    rep(i,n+1) {
//        rep(j,n+1) {
//            printf("%.5f ",dp[i][j]);
//        }
//        printf("\n");
//    }

    double ans = 0;
    for (int i = n; i > n/2; --i) {
//        cout << dp[i][n] << endl;
        ans += dp[i][n];
    }
    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}


Measured memory_bytes: 70016
import sys
input = sys.stdin.readline
a=[list(map(int,input().split()))for _ in range(3)]
n=int(input())
t=[[0]*3 for i in range(3)]
for _ in range(n):
    b=int(input())
    for i in range(3):
        for j in range(3):
            if a[i][j]==b:
                t[i][j]=1
for i in range(3):
    f=True
    for j in range(3):
        if t[i][j]==0:
            f=False
    if f:
        print("Yes")
        exit()

for i in range(3):
    f=True
    for j in range(3):
        if t[j][i]==0:
            f=False
    if f:
        print("Yes")
        exit()
f=True
for i in range(3):
    if t[i][i]==0:
        f=False
if f:
    print("Yes")
    exit()

f=True
for i in range(3):
    if t[i][-i-1]==0:
        f=False
if f:
    print("Yes")
    exit()
print("No")


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main() {
  ll a,b;
  cin>>a>>b;
  if(a>=b){
    cout<<0<<endl;
    
    return 0;
  }
  vector<ll>vec(b);
  for(ll i=0;i<b;i++){
    cin>>vec.at(i);
  }
  sort(vec.begin(),vec.end());
  vector<ll>veco(b-1);
  for(ll i=0;i<b-1;i++){
    veco.at(i)=vec.at(i+1)-vec.at(i);
  }
  sort(veco.begin(),veco.end());
  ll c=0;
  for(ll i=0;i<b-a;i++){
    c+=veco.at(i);
  }
  cout<<c<<endl;
    
  return 0;
}

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

using namespace std;

// Repetitions
#define FOR(i,a,n) for(ll i = ((ll) a); i < ((ll) n); ++i)
#define FORR(i, s, g) for(ll i = ((ll)s - 1); i >= ((ll) g); --i)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) FORR(i, n, 0)

// Container Utils
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define SORTALL(v) sort(ALL(v))
#define SZ(a) int((a).size())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())

// For Debug
#define DMP(x)  cerr << #x << " = " << (x) << endl
#define DBG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

// Aliases
#define PB push_back
#define MP make_pair
using ll = long long;
using ld = long double;
using str = string;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vs = vector<str>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vpii = vector<pii>;
using vpll = vector<pll>;

// Constant variables
const ld PI = (acos(-1));
const ll MOD = 1000000007;

// I/O Asynchronizing
struct __io_async{
    __io_async(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
};

#define MAX_H 500
#define MAX_W 500
int h, w;
int a[MAX_H][MAX_W];
bool is_selected[MAX_H][MAX_W];
int dx[] = { 1, 0 };
int dy[] = { 0, 1 };
queue<pair<pii, pii>> que;

inline bool is_in_range(const int y, const int x) {
    return 0 <= y && y < h && 0 <= x && x < w;
}

void op() {
    REP(j, h) {
        REP(i, w) {
            if(!is_selected[j][i] && a[j][i] % 2 == 1) {
                REP(k, 2) {
                    int ny = j + dy[k], nx = i + dx[k];
                    if(is_in_range(ny, nx)) {
                        // if(i == w - 1 && a[ny][nx] % 2 == 1) {
                            a[j][i]--;
                            a[ny][nx]++;
                            que.push(make_pair(make_pair(j + 1, i + 1), make_pair(ny + 1, nx + 1)));
                            is_selected[j][i] = true;
                            break;
                        // }
                    }
                }
            }
        }
    }
}

int main() {
    cin >> h >> w;
    REP(j, h) {
        REP(i, w) {
            cin >> a[j][i];
        }
    }
    op();
    cout << que.size() << endl;
    while(!que.empty()) {
        int oy = que.front().first.first, ox = que.front().first.second, ny = que.front().second.first, nx = que.front().second.second;
        que.pop();
        cout << oy << " " << ox << " " << ny << " " << nx << endl;
    }
    return 0;
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>   
using namespace std;
#define N 3005   
#define REP(i, n) for(int i=0; i<n; i++)
int n,m;
int k[N];
int a[N][N];
int point[N];
int ans;
int main(){
    scanf("%d%d",&n,&m);
    REP(i,n){
        scanf("%d",&k[i]);
        REP(j,k[i]){
            scanf("%d",&a[i][j]);
            point[a[i][j]-1]++;
        }
    }
    REP(i,m){
        if(point[i]==n)ans++;
    }

    printf("%d",ans);

}



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

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  
  if (N*A<B) {
    cout << N*A << endl;
  }
  
  else if (N*A>B) {
    cout << B << endl;
  }
  
  else {
    cout << B << endl;
  }
}

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

void bubbleSort(int *A,int N);

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

	bubbleSort(A,N);

	return 0;
}

void bubbleSort(int *A,int N)
{
	bool flag = true;
	int count = 0;

	while(flag) {
		flag = false;
		for (int i = N-1; i >= 1; i--) {
			if (A[i] < A[i-1]) {
				swap(A[i],A[i-1]);
				flag = true;
				count++;
			}
		}
	}
	
	for(int i = 0; i < N; i++) {
		cout << A[i];
		if (i == N-1)
			cout << '\n';
		else
			cout << ' ';
	}

	cout << count << '\n';
	return;
}


Measured memory_bytes: 3096
n = int(input())

alphabets = 'zabcdefghijklmnopqrstuvwxyz'
numbers = list(range(0, 26, 1))
alphabet_dict = {}
for i in numbers:
    alphabet_dict[i] = alphabets[i]

words = []
while True:
    if n >= 1:
        cnt = n % 26
        word = alphabet_dict[cnt]
        words.append(word)
        if cnt == 0:
            n = (n//26) - 1
        else:
            n = n//26
    else:
        break

words.reverse()
print(''.join(words))

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

void fnBubbleSort(vector<string> &argvsSortBbl)
{
  int ixSorting = 0;
  bool bSorting = true;

  while (bSorting)
  {
    bSorting = false;
    for (int j = argvsSortBbl.size() - 1; j > ixSorting; j--)
    {
      if (argvsSortBbl[j].at(1) < argvsSortBbl[j - 1].at(1))
      {
        swap(argvsSortBbl[j], argvsSortBbl[j - 1]);
        bSorting = true;
      }
    }
    ixSorting++;
  }
}

void fnOutputBbl(const vector<string> &argvsSortBbl)
{
  for (int i = 0; i < argvsSortBbl.size(); i++)
  {
    if (i) cout << " ";
    cout << argvsSortBbl[i];
  }
  cout << endl;
  cout << "Stable" << endl;
}

void fnSelectionSort(vector<string> &argvsSortSel)
{
  for (int ixSorting = 0; ixSorting < argvsSortSel.size() - 1; ixSorting++)
  {
    int ixMinimum = ixSorting;
    bool bSorting = false;
    for (int j = ixSorting + 1; j < argvsSortSel.size(); j++)
    {
      if (argvsSortSel[j].at(1) < argvsSortSel[ixMinimum].at(1))
      {
        ixMinimum = j;
        bSorting = true;
      }
    }
    if (bSorting == true)  swap(argvsSortSel[ixSorting], argvsSortSel[ixMinimum]);
  }
}

void fnOutputSel(const vector<string> &argvsSortSel, const vector<string> &argvsSortBbl)
{
  string sSortEnd = "Stable";

  for (int i = 0; i < argvsSortSel.size(); i++)
  {
    if (i) cout << " ";
    cout << argvsSortSel[i];
    
    if (argvsSortSel[i] != argvsSortBbl[i]) sSortEnd = "Not stable";
  }
  cout << endl;
  cout << sSortEnd << endl;
}

int main()
{
  vector<string> vsSortBbl, vsSortSel;
  int iMaxSize;
  
  cin >> iMaxSize;
  for (int i = 0; i < iMaxSize; i++)
  {
    string sCard;
    cin >> sCard;
    vsSortBbl.push_back(sCard);
    vsSortSel.push_back(sCard);
  }

  fnBubbleSort(vsSortBbl);
  fnOutputBbl(vsSortBbl); 

  fnSelectionSort(vsSortSel);
  fnOutputSel(vsSortSel, vsSortBbl);

  return 0;
}

Measured memory_bytes: 1216
package main

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

const (
	BUFSIZE   = 10000000
	MOD       = 1000000007
	INF_INT   = math.MaxInt32
	INF_INT64 = math.MaxInt64
)

var rdr *bufio.Reader

func main() {
	rdr = bufio.NewReaderSize(os.Stdin, BUFSIZE)
	solve()
}

func solve() {
	X := readint()
	fmt.Println(8 - int((X-400)/200))
}

func readline() string {
	buf := make([]byte, 0, 16)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			fmt.Println(e.Error())
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func readIntSlice(size int) []int {
	slice := make([]int, size)
	lines := strings.Split(readline(), " ")
	for i, v := range lines {
		slice[i] = s2i(v)
	}
	return slice
}

func readInt64Slice(size int) []int64 {
	slice := make([]int64, size)
	lines := strings.Split(readline(), " ")
	for i, v := range lines {
		slice[i] = s2i64(v)
	}
	return slice
}

func readint() int {
	return s2i(readline())
}

func readint64() int64 {
	return s2i64(readline())
}

// For int64
func b2i64(b bool) int64 {
	if b {
		return 1
	}
	return 0
}

func abs64(v int64) int64 {
	if v < 0 {
		return -v
	}
	return v
}

func min64(values ...int64) int64 {
	ret := int64(INF_INT64)
	for _, v := range values {
		if ret > v {
			ret = v
		}
	}
	return ret
}

func max64(values ...int64) int64 {
	ret := -int64(INF_INT64)
	for _, v := range values {
		if ret < v {
			ret = v
		}
	}
	return ret
}

func s2i64(s string) int64 {
	v, ok := strconv.ParseInt(s, 10, 64)
	if ok != nil {
		panic("Faild : " + s + " can't convert to int64")
	}
	return v
}

// For int
func b2i(b bool) int {
	if b {
		return 1
	}
	return 0
}

func abs(v int) int {
	if v < 0 {
		return -v
	}
	return v
}

func min(values ...int) int {
	ret := INF_INT
	for _, v := range values {
		if ret > v {
			ret = v
		}
	}
	return ret
}

func max(values ...int) int {
	ret := -INF_INT
	for _, v := range values {
		if ret < v {
			ret = v
		}
	}
	return ret
}

func s2i(s string) int {
	v, ok := strconv.Atoi(s)
	if ok != nil {
		panic("Faild : " + s + " can't convert to int")
	}
	return v
}

func lcm(v1, v2 int) int {
	if v1 > v2 {
		v1, v2 = v2, v1
	}
	for v1 != 0 {
		v1, v2 = v2%v1, v1
	}
	return v2
}

func gcd(v1, v2 int) int {
	return v1 * v2 / lcm(v1, v2)
}

func bit(size int) [][]bool {
	bSize := int(math.Pow(2, float64(size)))
	b := make([][]bool, bSize)
	for i := 0; i < bSize; i++ {
		b[i] = make([]bool, size)
		for j := 0; j < size; j++ {
			if i>>j&1 == 1 {
				b[i][j] = true
			} else {
				b[i][j] = false
			}
		}
	}
	return b
}

/* ------------------------------------------------ */
/* Data stracture                                   */
/* ------------------------------------------------ */
type IntHeap []int

func (h *IntHeap) Push(x interface{}) {
	*h = append(*h, x.(int))
}

func (h *IntHeap) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}

func (h IntHeap) Len() int           { return len(h) }
func (h IntHeap) Less(i, j int) bool { return h[i] < h[j] }
func (h IntHeap) Swap(i, j int)      { h[i], h[j] = h[j], h[i] }


Measured memory_bytes: 2160
K = gets.to_i

x = ((4 - K % 4) % 4)
n = (K + x) / 2
a = (1 .. K).to_a

if K == 1
    puts "1","1"
else
    for i in 1..x
        a << K + i - n
    end

    puts n

    for i in 0 .. n - 1
        for j in 0 .. n - 1

            k = n * (i % 2) + (i + j) % n
            printf "#{a[k]}"

            if j == n - 1
                puts ""
                break
            end

            printf " "
        end
    end
end

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

// #define deb(x) cout << #x << " " << x << endl;
#define fo(i, n) for(i=0; i<n; i++)
#define Fo(i, k, n) for(i=k; i<n; i++)
#define w(x)  int x; cin>>x; while(x--)
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define watch2(x,y) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<"\n"

#define ll  long long
#define all(c) (c).begin(),(c).end()
#define nl "\n"

typedef vector<int> vl;
typedef vector< vl > vvl;
typedef pair< int,int> pll;typedef map< int,int> mll;


void c_p_c()
{
#ifndef ONLINE_JUDGE
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}


int main() {
	

	c_p_c();
	

	int n,o=1;
	cin>>n;
	int a,b;
	
	cin>>a>>b;
	for (int i = a; i <= b; ++i)
	{
		if(i%n==0){
			cout<<"OK";
			o=0;
			break;
			
		}

	}
	if(o==1)
	cout<<"NG";













	return 0;

}


Measured memory_bytes: 3636
#include<stdio.h>
#include<iostream>
using namespace std;

int main(){
  char A[3];
  cin >> A[0] >> A[1] >> A[2] ;
  if (A[0] == A[1] && A[1] == A[2]){
    cout << "No" << endl;
  }
 else{
   cout << "Yes" << endl;
 }
  
}

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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		int[] idx = new int[N];
		for(int i=0;i<N;i++) idx[i] = i;
		Array.Sort(idx, (i, j) => A[i].CompareTo(A[j]));
		Console.WriteLine(String.Join(" ",idx.Select(v => v+ 1)));
		
		
	}
	int N;
	int[] A;
	public Sol(){
		N = ri();
		A = ria();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 30812
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i, x, n) for(int i = x; i < (int)(n); ++i)
#define speed ios::sync_with_stdio(0); cin.tie(0);
int const N = 2 * 1e5 + 2;
int a[102];
int main(){
	speed
	int n, mn = 104, mx = -1, sum, ans = 1000000;
	cin >> n;
	f(i, 0, n)cin >> a[i], mn = min(mn, a[i]), mx = max(mx, a[i]);
	f(i, mn, mx + 1){
		sum = 0;
		f(j, 0, n){
			sum += (a[j] - i) * (a[j] - i);
		}
		ans = min(ans, sum);
	}
	cout << ans << endl;
    return 0;
}

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

using namespace std;
#define X first
#define Y second
#define pb push_back
typedef double db;
typedef long long ll;
typedef pair<int,int> P;
const int MAXN=5e5+10;
int n,k,a[MAXN],vis[MAXN];

int main()
{
	scanf("%d%d",&n,&k);
	if(k==1||k==2*n-1) return puts("No"),0;
	
	int mid=n;
	if(k==2)
	{
		a[mid]=2;a[mid-1]=3;a[mid+1]=1;a[mid+2]=4;
		vis[1]=vis[2]=vis[3]=vis[4]=1;
	}
	else
	{
		a[mid]=k;a[mid+1]=k+1;a[mid-1]=k-1;a[mid+2]=k-2;
		vis[k]=vis[k+1]=vis[k-1]=vis[k-2]=1;
	}
	for(int x=1,y=1;x<=2*n-1;x++)
		if(a[x]) continue;
		else
		{
			while(vis[y]) y++;
			a[x]=y++;
		}
	puts("Yes");
	for(int i=1;i<=2*n-1;i++)
		printf("%d\n",a[i]);
	return 0;
}

Measured memory_bytes: 2304
N, M = map(int, input().split())
F = [0 for i in range(M)]
for i in range(N):
  K, *A = list(map(int, input().split()))[0:]
  for j in range(K):
    F[A[j] - 1] += 1
ans = 0
for i in range(M):
  if F[i] == N:
    ans += 1
print(ans)

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

using lli = long long int;
using Vint = vector<int>;
using Vlli = vector<lli>;
using Wint = vector<Vint>;
using Wlli = vector<Vlli>;
using pii = pair<int, int>;
using pll = pair<lli, lli>;

const int MOD = 1e9 + 7;
const int INFi = 2e9 + 1;
const lli INFl = (lli)(9e18) + 1;
// const vector<pii> DXDY = {make_pair(1, 0), make_pair(-1, 0), make_pair(0, 1), make_pair(0, -1)};

#define FOR(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define FOReq(i, a, b) for(int (i) = (a); (i) <= (b); (i)++)
#define rFOR(i, a, b) for(int (i) = (b); (i) >= (a); i--)
#define REP(i, n) FOR(i, 0, n)
#define rREP(i, n) rFOR(i, 0, (n-1))
#define vREP(i, vec) for(auto &(i) : (vec))

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

inline void update(Vint &DP, Vint &A, int i, int j){
  int cost = abs(A.at(i) - A.at(j));
  DP.at(i) = min(DP.at(i), DP.at(j) + cost);
}

int main(void){
  int n; cin >> n;
  Vint A(n), DP(n + 2, INFi); vREP(ele, A) cin >> ele;
  // DP[i] := i までの最小値
  DP.at(0) = 0;
  FOR(i, 0, n - 2){
    update(DP, A, i + 1, i);
    update(DP, A, i + 2, i);
  }
  update(DP, A, n - 1, n - 2);
  cout << DP.at(n - 1) << "\n";
  return 0;
}

Measured memory_bytes: 1024
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	a := make([][]int, 4)
	a[0] = []int{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
	a[1] = []int{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
	a[2] = []int{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
	a[3] = []int{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}

	suite2num := map[string]int{
		"S": 0,
		"H": 1,
		"C": 2,
		"D": 3,
	}

	num2suite := map[int]string{
		0: "S",
		1: "H",
		2: "C",
		3: "D",
	}

	for i := 0; i < n; i++ {
		var suite string
		fmt.Scan(&suite)

		var r int
		fmt.Scan(&r)

		a[suite2num[suite]][r-1] = 1
	}

	for i := 0; i < 4; i++ {
		for j := 0; j < 13; j++ {
			if a[i][j] == 0 {
				fmt.Printf("%s %d\n", num2suite[i], j+1)
			}
		}
	}
}



Measured memory_bytes: 1136
fn func(input_str: &str) {
    let mut iter = input_str.split_whitespace();
    let n: usize = iter.next().unwrap().parse().unwrap();
    let mut data_s = Vec::new();
    for _ in 0..n {
        let x: i32 = iter.next().unwrap().parse().unwrap();
        let y: i32 = iter.next().unwrap().parse().unwrap();
        let h: i32 = iter.next().unwrap().parse().unwrap();
        data_s.push((x, y, h));
    }
    data_s.sort_by(|x, y| y.2.cmp(&x.2));
    for cx in 0..101 {
        'a: for cy in 0..101 {
            let (x, y, h) = data_s[0];
            let ans = (cx - x).abs() + (cy - y).abs() + h;
            for &(x, y, h) in &data_s[1..] {
                if h != std::cmp::max(ans - (cx - x).abs() - (cy - y).abs(), 0) {
                    continue 'a;
                }
            }
            println!("{} {} {}", cx, cy, ans);
            return;
        }
    }
}

use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    func(&buf[..]);
}

Measured memory_bytes: 4352
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <bits/stdc++.h>
using namespace std;
using i32 = int32_t; using i64 = int64_t; using f64 = double_t; using str = string;
template <typename T> using vec = vector<T>;
template <typename T> using heap = priority_queue<T, vec<T>, greater<T>>;
#define times(n, i) for (i32 i = 0; i < (n); ++i)
#define range(n, m, i) for (i32 i = (n); i < (m); ++i)
#define upto(n, m, i) for (i32 i = (n); i <= (m); ++i)
#define downto(n, m, i) for (i32 i = (n); i >= (m); --i)
#define foreach(xs, x) for (auto &x : (xs))
#define all(xs) (xs).begin(), (xs).end()
#define sortall(xs) sort(all(xs))
#define reverseall(xs) reverse(all(xs))
#define uniqueall(xs) (xs).erase(unique(all(xs)), (xs).end())
#define maximum(xs) (*max_element(all(xs)))
#define minimum(xs) (*min_element(all(xs)))
#define even(x) (((x) & 1) == 0)
#define odd(x) (((x) & 1) == 1)
#define append emplace_back
const i64 MOD = 1000000007;

i64 x;

i32 main()
{
    cin >> x;
    i64 ans = (x / 11) * 2;
    if (x % 11 == 0) {
        ans += 0;
    } else if (x % 11 <= 6) {
        ans += 1;
    } else {
        ans += 2;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE cout << -1 << endl;return 0
#define Endl endl


signed main(void){
    int N,M;
    int A[114514];
    vector<PP> BC;
    cin >> N >> M;
    REP(i,N){
        cin >> A[i];
    }
    sort(A,A+N);
    REP(i,M){
        int b,c;
        cin >> b >> c;
        BC.push_back(make_pair(c,b));
    }
    sort(BC.begin(),BC.end(),greater<>());
    
    //REP(i,M){cout << BC[i].first <<" " << BC[i].second << endl;}
    int l=0,r=N-1;
    REP(j,M){
        int ln=l,rn=r;
        for(int i=rn;i>=0;i--){
            if(A[i]>=BC[j].first){
                r--;
            }else{
                break;
            }
        }
        if(r<l)break;
        for(int i=0;i<BC[j].second;i++){
            A[l]=BC[j].first;
            l++;
            if(r<l)break;
        }
        if(r<l)break;
    }
    int Ans=0;
    REP(i,N){
        Ans+=A[i];
    }
    cout << Ans << endl;
    /*REP(i,N){
        cout << A[i] << " ";
    }*/
    return 0;
}



Measured memory_bytes: 2168
s=input()
k=int(input())

if len(s) == 1:
    print(k // 2)
else: 
    x = 0
    if s[0] == s[-1]:
        # head
        h = 1
        for i in range(1,len(s)):
            if s[0] == s[i]:
                h += 1
            else:
                break
        # tail
        t = 1
        for i in range(len(s)-2, -1, -1):
            if s[-1] == s[i]:
                t += 1
            else:
                break
        if h == len(s):
            # s only consists of the same letter
            x = (h * k) // 2
            k = 1
        else:
            #x = ((h + t) // 2) * ((k + 1) // 2)
            x = (h // 2) + (t // 2) + ((h + t) // 2) * (k - 1)
        #print(111,s,k,h,t,x)
    else:
        h = t = 0
    #print(222,s,k,h,t)
    y = 0
    if (h + t) < len(s):
        m = s[h]
        n = 1
        for i in range(h+1, len(s)-t):
            if m == s[i]:
                n += 1
                if n == 2:
                    y += 1
                    #print(234,n,y)
                    n = 0
            else:
                m = s[i]
                n = 1
    #print(333,m,n,y,k)
    y *= k
    print(x + y)

Measured memory_bytes: 38448
#include<stdio.h>

int main()
{
    long long int a,b,c,d,x1,x2,y1,y2,ans;
    scanf("%lld%lld%lld%lld",&a,&b,&c,&d);

    x1=a*c;
    x2=a*d;
    y1=b*c;
    y2=b*d;

    if(x1>=x2&&x1>=y1&&x1>=y2)
        ans=x1;
    else if(x2>=x1&&x2>=y1&&x2>=y2)
        ans=x2;
    else if(y1>=x1&&y1>=x2&&y1>=y2)
        ans=y1;
    else if(y2>=x1&&y2>=x2&&y2>=y1)
        ans=y2;

    printf("%lld",ans);

}


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

int main() {
    int a, b, c;
    int k;

    cin >> a >> b >> c;
    cin >> k;

    int m = max(a, max(b, c));
    int mm = m;

    for (int i = 0; i < k; i++) {
        mm *= 2;
    }

    if (m == a) {
        mm += b;
        mm += c;
    } else if (m == b) {
        mm += a;
        mm += c;
    } else {
        mm += a;
        mm += b;
    }

    cout << mm << endl;

    return 0;
}


Measured memory_bytes: 256
N, Q = map(int, input().rstrip().split())
S = [i for i in input()]

list_lr = [list(map(int, input().rstrip().split())) for i in range(Q)]

t = [0]
ct = 0
for i in range(len(S)-1):
    if S[i] == 'A' and S[i+1] == 'C':
        ct += 1
    t.append(ct)

for i in list_lr:
    l, r = i[0], i[1]
    print(t[r-1]-t[l-1])


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

int main(){   
    using board = vector<vector<int>>;
    board complete = {{0, 1, 2, 3} ,{4, 5, 6, 7}};
    map<board, int> dp;

    queue<pair<board,int>> que;
    que.push({complete, 0}); 
    const int d[4] = {1, -1, 0, 0};
    while(!que.empty()){
        board now;
        int moves;
        int y, x;
        tie(now, moves) = que.front(); 
        que.pop();
        rep(i, 2) rep(k, 4) {
            if(now[i][k] == 0) y = i, x = k;
        } 
        for(int i = 0; i < 4; i++){
            int ny = y + d[i];
            int nx = x + d[i ^ 2];
            if(ny < 0 || ny >= 2 || nx < 0 || nx >= 4) continue;
            swap(now[y][x], now[ny][nx]);
            if(!dp.count(now)){
                dp[now] = moves + 1;
                que.push({now, moves + 1});
            } 
            swap(now[ny][nx], now[y][x]);
        }
    }

    board p(2, vector<int>(4));
    while(cin >> p[0][0] >> p[0][1] >> p[0][2] >> p[0][3] >> p[1][0] >> p[1][1] >> p[1][2] >> p[1][3]){
        cout << dp[p] << endl;
    }                                                                                                                                                                                                                                                                                                                                   
}



Measured memory_bytes: 7244
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
/*
struct Edge
{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w) {}
};
using Graph = vector<vector<Edge>>;
*/
using Graph = vector<vector<int>>;

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N;
    cin >> N;
    ll ans = 0;
    for (ll A = 1; A <= N; A++)
    {
        ans += (N - 1) / A;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main(void){
	string s;
	int ans = 0;
	cin >> s;
	for(int i=0; i< s.length(); i++){
		if(s[i] == 'o') ans++;
	}
	if(ans >= 8 - (15 - int(s.length())))cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	vector<int>V(3);
	rep(i, 3) {
		cin >> V[i];
	}
	sort(V);
	if (V[0] == V[1]) {
		cout << V[2] << endl;
	}
	else {
		cout << V[0] << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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;
}

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

ll lcm(ll a, ll b)
{
    return a / gcd(a, b) * b;
}

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

//----------------------------------------------------------------

int main()
{
    ll n;
    cin >> n;
    vector<ll> x(n), y(n);
    for (int i = 0; i < n; i++)
    {
        cin >> x[i] >> y[i];
    }
    double dist = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            dist += sqrt(pow(x[i] - x[j], 2) + pow(y[i] - y[j], 2));
        }
    }
    double distavr = dist / (n * (n - 1));
    cout << fixed << setprecision(10) << distavr * (n - 1) << endl;
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}
struct edge {
  ll to, cost;
};

ll oddsolve(ll n) {
  return (n + 1) / 2 % 2;
}
ll judge(ll n) {
  if(n % 2 == 1) {
    return oddsolve(n);
  } else {
    return oddsolve(n + 1) ^ (n + 1);
  }
}

int main() {
  ll A, B; cin >> A >> B;
  cout << (judge(B) ^ judge(A - 1)) << endl;
}

Measured memory_bytes: 3600
#include <iostream>
#include <stdio.h>

#define MAX 100000

int n, H[MAX];

int parent (int i) { return int(i/2); }
int left (int i) { return i * 2; }
int right (int i) { return i * 2 + 1; }

int main() {
    int key;
    
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &key);
        H[i] = key;
    }
    
    for (int i = 1; i <= n; i++) {
        printf("node %d: ", i);
        printf("key = %d, ", H[i]);
        if (i != 1) printf("parent key = %d, ", H[parent(i)]);
        if (left(i) <= n) printf("left key = %d, ", H[left(i)]);
        if (right(i) <= n) printf("right key = %d, ", H[right(i)]);
        printf("\n");
    }
    
    return 0;
}



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

int main() {
  int N,K,d,s;
  
  cin>>N>>K;
  vector<int> vec(N);
  rep(i,N){
    vec.at(i)=i+1;
  }

  rep(i,K){
    cin>>d;
    rep(i,d){
      cin>>s;
      vec.erase(remove(vec.begin(), vec.end(), s),vec.end());
    }
  }
  
  cout<<vec.size()<<endl;
}


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

using namespace std;

int main()
{
	int n, m;
	cin >> n >> m;
	if (abs(n - m) > 1) {
		cout << 0 << endl;

		return 0;
	}

	int mod = 1000000007;
	long long ans = 1;
	for (int i = 1; i <= n; i++) {
		ans *= i;
		ans %= mod;
	}
	for (int i = 1; i <= m; i++) {
		ans *= i;
		ans %= mod;
	}

	if (n == m) {
		ans *= 2;
		ans %= mod;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
class UnionFind():
    # 作りたい要素数nで初期化
    # 使用するインスタンス変数の初期化
    def __init__(self, n):
        self.n = n
        # root[x]<0ならそのノードが根かつその値が木の要素数
        # rootノードでその木の要素数を記録する
        self.root = [-1]*(n+1)
        # 木をくっつける時にアンバランスにならないように調整する
        self.rnk = [0]*(n+1)

    # ノードxのrootノードを見つける
    def Find_Root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            # ここで代入しておくことで、後の繰り返しを避ける
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]
    # 木の併合、入力は併合したい各ノード
    def Unite(self, x, y):
        # 入力ノードのrootノードを見つける
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        # すでに同じ木に属していた場合
        if(x == y):
            return 
        # 違う木に属していた場合rnkを見てくっつける方を決める
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x

        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            # rnkが同じ（深さに差がない場合）は1増やす
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
    # xとyが同じグループに属するか判断
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)

    # ノードxが属する木のサイズを返す
    def Count(self, x):
        return -self.root[self.Find_Root(x)]



H,W=map(int,input().split())
tree=UnionFind(H*W)
s=[input() for i in range(H)]

for i in range(H):
    for j in range(W):
        x=i*W+j+1
        if i>0 and s[i][j]!=s[i-1][j]: tree.Unite(x,x-W)
        if i<H-1 and s[i][j]!=s[i+1][j]: tree.Unite(x,x+W)
        if j>0 and s[i][j]!=s[i][j-1]: tree.Unite(x,x-1)
        if j<W-1 and s[i][j]!=s[i][j+1]: tree.Unite(x,x+1)

dicw={}


for i in range(H):
    for j in range(W):
        p=tree.Find_Root(i*W+j+1)
        if not p in dicw:
            dicw[p]=0
        if s[i][j]==".":
            dicw[p]+=1

ans=0
for i in dicw:
    n=tree.Count(i)

    ans+=dicw[i]*(n-dicw[i])
print(ans)

Measured memory_bytes: 17468
x = input().split()
a = int(x[0])
b = int(x[1])
c = int(x[2])
d = int(x[3])
while a > 0 and c > 0:
  c = c - b
  a = a - d
if c <= 0:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 9176
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    int n, val;
    map<int, int> cnt;
    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> val;
        cnt[i+1] += val;
    }
    ll ans = 0;
    for(auto& p: cnt) {
        ans += p.second / 2;
        p.second %= 2;
        if (cnt.count(p.first+1) > 0) {
            int mn = min(p.second, cnt[p.first+1]);
            ans += mn;
            p.second -= mn;
            cnt[p.first+1] -= mn;
        }

    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 8336
@num = 1
loop do
  w = gets.to_i
  break if w == 0

  n = gets.to_i
  tab = n.times.map{ gets.chomp.split(',').map(&:to_i) }

  dp = Array.new(n+1){Array.new(w+1)}
  dp[0][0] = 0

  mw, mv = w, 0
  tab.each_with_index do |p, i|
    (0..w).reject{|wi| dp[i][wi].nil? }.each do |wi|
      t = dp[i+1][wi] = [dp[i+1][wi]||0, dp[i][wi]].max
      mw, mv = wi, t if ((t > mv) || (mv == t && mw > wi))
      if wi+p[1] <= w
        t = dp[i+1][wi+p[1]] = [dp[i+1][wi+p[1]]||0, dp[i][wi]+p[0]].max
        mw, mv = (wi+p[1]), t if ((t > mv) || (mv == t && mw > (wi+p[1])))
      end
    end
  end
  puts "Case #{@num}:", mv, mw
  @num += 1
end

Measured memory_bytes: 13856
// reference: https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

use std::cmp::Ordering;
#[derive(Eq, PartialEq, Clone, Debug)]
pub struct Rev<T>(pub T);

impl<T: PartialOrd> PartialOrd for Rev<T> {
    fn partial_cmp(&self, other: &Rev<T>) -> Option<Ordering> {
        other.0.partial_cmp(&self.0)
    }
}

impl<T: Ord> Ord for Rev<T> {
    fn cmp(&self, other: &Rev<T>) -> Ordering {
        other.0.cmp(&self.0)
    }
}

impl<T: Copy> Copy for Rev<T> {}

fn main() {
    input! {
        n: usize,
        a: [usize; n]
    }

    let l = a
        .iter()
        .cloned()
        .scan(0, |max, x| {
            let m = *max;
            *max = std::cmp::max(*max, x);
            Some(m)
        })
        .collect::<Vec<_>>();

    let mut r = a
        .iter()
        .rev()
        .cloned()
        .scan(0, |max, x| {
            let m = *max;
            *max = std::cmp::max(*max, x);
            Some(m)
        })
        .collect::<Vec<_>>();
    r.reverse();

    for i in 0..a.len() {
        println!("{}", std::cmp::max(l[i], r[i]));
    }
}


Measured memory_bytes: 14316
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;
using static MyBinarySearch;


public class D
{
	public static void Main()
	{
		int A = GetInt();
		int B = GetInt();
		int Q = GetInt();

		List<long> s = new List<long>(A + 2);
		s.Add(-1000000000000);
		s.Add(1000000000000);
		for(int i = 0; i < A; i++)
			s.Add(GetLong());
		s.Sort();

		List<long> t = new List<long>(B + 2);
		t.Add(-1000000000000);
		t.Add(1000000000000);
		for(int i = 0; i < B; i++)
			t.Add(GetLong());
		t.Sort();

		long[] x = new long[Q];
		for(int i = 0; i < Q; i++)
			x[i] = GetLong();

		for(int i = 0; i < Q; i++)
		{
			int isl = s.LowerBound(x[i]) - 1;
			long sl = s[isl];
			long sr = s[isl + 1];

			int itl = t.LowerBound(x[i]) - 1;
			long tl = t[itl];
			long tr = t[itl + 1];

			long ans = distance(x[i], sl, tl);
			ans = Math.Min(ans, distance(x[i], sl, tr));
			ans = Math.Min(ans, distance(x[i], sr, tl));
			ans = Math.Min(ans, distance(x[i], sr, tr));
			ans = Math.Min(ans, distance(x[i], tl, sl));
			ans = Math.Min(ans, distance(x[i], tl, sr));
			ans = Math.Min(ans, distance(x[i], tr, sl));
			ans = Math.Min(ans, distance(x[i], tr, sr));

			Console.WriteLine(ans);
		}
	}

	private static long distance(long p1, long p2, long p3)
	{
		return Math.Abs(p2 - p1) + Math.Abs(p3 - p2);
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}


public static class MyBinarySearch
{
	public static int LowerBound<T>(
		this List<T> list, int first, int end, T value, IComparer<T> comparer)
	{
		int low = first;
		int high = end;
		while(low < high)
		{
			int mid = ((high - low) >> 1) + low;
			if(comparer.Compare(list[mid], value) < 0)
				low = mid + 1;
			else
				high = mid;
		}
		return low;
	}

	public static int LowerBound<T>(this List<T> list, T value)
	{
		return list.LowerBound(0, list.Count, value, Comparer<T>.Default);
	}

	public static int UpperBound<T>(
		this List<T> list, int first, int end, T value, IComparer<T> comparer)
	{
		int low = first;
		int high = end;
		while(low < high)
		{
			int mid = ((high - low) >> 1) + low;
			if(comparer.Compare(list[mid], value) <= 0)
				low = mid + 1;
			else
				high = mid;
		}
		return low;
	}

	public static int UpperBound<T>(this List<T> list, T value)
	{
		return list.UpperBound(0, list.Count, value, Comparer<T>.Default);
	}
}




Measured memory_bytes: 20644