akhauriyash/Code-Regression huggingface dataset:
fun main(args: Array<String>) {
    val (p, q, r) = readLine()!!.split(" ").map { it.toInt() }

    var ans = Int.MAX_VALUE

    ans = Math.min(ans, p + q)
    ans = Math.min(ans, q + r)
    ans = Math.min(ans, p + r)

    println(ans)
}

Measured memory_bytes: 37744
d,e=[[s for s in input().split()]for _ in range(2)];e[3],e[4]=e[4],e[3]
t=0
for p in('012345','152304','215043','310542','402351','513240'):
 f=[d[int(j)]for j in p];f[3],f[4]=f[4],f[3]
 if f[0]==e[0]:
  f=f[1:5]*2
  for j in range(4):
   if f[j:j+4]==e[1:5]:t=1
print(('No','Yes')[t])


Measured memory_bytes: 5604
use std::cmp;
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

fn uc(l: i64, m: i64) -> i64 {
    let mut l = l;
    let mut m = m;
    while l % m != 0{
        let h = l;
        l = m;
        m = h % m;
    }
    m
}

fn main() {
    input!{
        a: i64,
        b: i64
    }
    let ucs = uc(cmp::max(a, b), cmp::min(a, b));
    
    println!("{}", a * b / ucs);
}


Measured memory_bytes: 4352
use proconio::{fastout, input};
// use proconio::marker::*;

#[fastout]
fn main() {
   input! {
      mut n: usize,
   }
   let mut fl = vec![];
   let mut i = 2;
   while i * i < n {
      if n % i == 0 {
         let mut v = 1;
         n /= i;
         while n % i == 0 {
            v += 1;
            n /= i;
         }
         fl.push(v);
      }
      i += 1;
   }
   if n != 1 {
      fl.push(1);
   }

   let mut ans = 0;
   for &k in fl.iter() {
      let mut x = 0;
      let mut i = 1;
      while k >= x + i {
         ans += 1;
         x += i;
         i += 1;
      }
   }
   println!("{}", ans);
}


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

using namespace std;

int prime(int n) {
  int i, j, r;
  n++;
  vector<int> primes(n);

  for (i = 2; i < n; ++i)
    primes[i] = i;
  for (i = 2; i*i < n; ++i) {
    if (primes[i])
      for (j = i*i; j < n; j += i)
        primes[j] = 0;
  }
  for (i = r = 0; i < n; i++)
    if (primes[i]) r++;
  return r;
}

int main() {
  int n;
  while(cin >> n)
    cout << prime(n) << endl;
  return 0;
}

Measured memory_bytes: 4852
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func next() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() int {
	num, _ := strconv.Atoi(next())
	return num
}

func nextInts(n int) [][]int {
	ints := make([][]int, n)
	for i := range ints {
		ints[i] = make([]int, 2)
	}
	for i := 0; i < n; i++ {
		ints[i][0], ints[i][1] = nextInt(), nextInt()
	}
	return ints
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func main() {

	scanner.Split(bufio.ScanWords)
	n, w := nextInt(), nextInt()
	a := nextInts(n)

	dp := make([]int, w+1)

	for i := 1; i <= n; i++ {
		weight := a[i-1][0]
		value := a[i-1][1]
		for j := w; j >= weight; j-- {
			dontChoose := dp[j]
			choose := 0
			if j-weight >= 0 {
				choose = value + dp[j-weight]
			}
			dp[j] = max(dontChoose, choose)
		}
	}

	fmt.Println(dp[w])
}


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

int main()
{
     string s1,s2;
     cin>>s1>>s2;
     if(!s2.empty())
     {
         s2.pop_back();

     }
     string s3=s2;
   //  cout<<s3;
     if(s3==s1)
        cout<< "Yes"<<endl;

     else
        cout<< "No"<<endl;;



}


Measured memory_bytes: 3632
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <fstream>
#include <array>
#include <map>
#include <queue>
#include <time.h>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <assert.h>
#include <unordered_set>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) (min(a,b) <= (x) && (x) <= max(a,b)) //hei
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 998244353LL 
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589
 
 
#define izryt bool
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
	std::fill((T*)array, (T*)(array + N), val);
}
 
//[a, b)
#define Getsum(ar, a,b) (ar[b] - ar[a])
#define INF 10000000000000000LL
#define chmax(a,b) a = max(a,b)
#define chmin(a,b) a = min(a,b)
 
struct Edge {
	int from, to;
	ll w;
	bool operator<(const Edge& rhs) const {
		return MP(w, MP(from, to)) < MP(rhs.w, MP(rhs.from, rhs.to));
	}
 
};
typedef vector<vector<Edge>> Graph;
typedef unsigned long long ull;
 
 
inline ll ksum(ll n, ll k){
  return k * (2*n - k - 1);
}

pii updtp2(pii p, int nw){
  if(p.first == -1) p.first = nw;
  else if(p.second == -1) p.second = nw;
  else if(p.first >= nw) {
    p.second = p.first;
    p.first = nw;
  }
  else if(p.second >= nw) p.second = nw;
  return p;
}
 
#define isValid(y,x) (y >=0 && y < n && x >= 0 && x < m)

const pii Dir[4] = {{-1,0}, {0,1}, {1,0}, {0,-1}};

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

    cout << s[0] << s[1] << s[2] << endl;
	return 0;
} 

Measured memory_bytes: 3596
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		//		new Main().solveA();
		//		new Main().solveB();
		new Main().solveC();
		// new Main().solveD();
	}

	private void solveA() {
		Scanner scanner = null;
		String s = "";

		try {
			scanner = new Scanner(System.in);
			s = scanner.next();

			char[] wk = s.toCharArray();

			int cntA = 0;
			int cntB = 0;
			int cntC = 0;

			for (int i = 0; i < wk.length; i++) {
				char c = wk[i];
				if (c == 'a' && cntA == 0) {
					cntA++;
				} else if (c == 'b' && cntB == 0) {
					cntB++;
				} else if (c == 'c' && cntC == 0) {
					cntC++;
				}
			}

			System.out.println((cntA + cntB + cntC) == 3 ? "Yes" : "No");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveB() {
		Scanner scanner = null;
		int numA = 0;
		int numB = 0;
		int numK = 0;

		try {
			scanner = new Scanner(System.in);
			numA = scanner.nextInt();
			numB = scanner.nextInt();
			numK = scanner.nextInt();

			List<Integer> wk = new ArrayList<Integer>();
			for (int i = numA; i <= numB; i++) {
				if (i < numA + numK || numB - numK < i) {
					wk.add(i);
				}
			}

			for (int i = 0; i < wk.size(); i++) {
				System.out.println(wk.get(i));
			}

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveC() {
		Scanner scanner = null;

		try {
			scanner = new Scanner(System.in);
			int[] wk = new int[3];
			wk[0] = scanner.nextInt();
			wk[1] = scanner.nextInt();
			wk[2] = scanner.nextInt();

			Arrays.sort(wk);

			int m3 = wk[2] * 3;
			boolean isEqual = (wk[0] + wk[1] + wk[2]) % 2 == m3 % 2;

			int targetNum = 0;
			int res = 0;
			if (isEqual) {
				targetNum = wk[2];
			} else {
				targetNum = wk[2] + 1;
			}

			boolean isPlusOne = false;
			for (int i = 0; i < wk.length; i++) {
				res += (targetNum - wk[i]) / 2;
				if (!isPlusOne) {
					isPlusOne = (targetNum - wk[i]) % 2 != 0;
				}
			}

			if (isPlusOne) {
				res++;
			}

			System.out.println(res);

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private int getMaxKouyaku(int a, int b) {
		int val1 = 0;
		int val2 = 0;
		if (a < b) {
			val1 = b;
			val2 = a;
		} else {
			val1 = a;
			val2 = b;
		}

		int amari = val1 % val2;
		while (amari != 0) {
			val1 = val2;
			val2 = amari;
			amari = val1 % val2;
		}

		return val2;
	}

	private int getMinKoubai(int a, int b) {

		return a * b / getMaxKouyaku(a, b);

	}

	private void solveD() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
typedef vector<int>   vi;
typedef vector<long long> vll;
typedef vector<pair<int,int> > vii;
#define ll long long
#define pb push_back
#define mp  make_pair
#define ff first
#define ss second
#define pq priority_queue
#define sf scanf
int inf = (1e9) + 7;




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

	map<ll,int> occ;
	ll aux;
	for (int i = 0; i < n; ++i)
	{
		sf("%lld",&aux);
		occ[aux]++;
	}

	vll suitable;
	for(auto u: occ)
	{
		if(u.ss >= 4){
			suitable.pb(u.ff);
			suitable.pb(u.ff);
		}
		else if(u.ss >= 2)
		{
			suitable.pb(u.ff);
		}
	}

	sort(suitable.begin(),suitable.end(),greater<ll>());


	if(suitable.size() > 1)
		printf("%lld\n", suitable[0]*suitable[1]);
	else
		printf("0\n");
}	

Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define VI  vector<ll>
#define lf(i,a,b) for(ll i=a;i<=b;i++)
const ll mod=1e9+7;
double pi = 2 * acos(0.0);
#define FASTIO ios_base::sync_with_stdio(false);cout.tie(NULL);cout.tie(NULL);
ll max(ll a, ll b) { return (a > b) ? a : b; }
ll min(ll a, ll b) { return (a < b) ? a : b; }
bool cmp(pair<ll,ll> a,pair<ll,ll> b)
{
    return (a.first)<(b.first);
}
ll power(ll a,ll b)
{
        ll p=1;
        for(ll i=1;i<=b;i++)
        p*=a;

        return p;
}
ll gcd(ll a, ll b){
    if (a == 0)
        return b;
    return gcd(b % a, a);
 }
void bfs(map<ll,vector<ll> > &g,ll src,vector<ll> &c)
{
    queue<ll> q;
    map<ll,ll> p;
    q.push(src);
    p[src]=src;
    c[src]=1;
    while(!q.empty())
    {
        ll u=q.front();
        q.pop();
        ll i=1;
        for(auto v:g[u])
        {
            if(c[v]==-1)
            {
                q.push(v);
                p[v]=u;
                if(i==c[u]||i==c[p[u]])
                    i++;
                if(i==c[u]||i==c[p[u]])
                    i++;
                c[v]=i;
                i++;
            }
        }
    }
}
ll dp[100005];
ll fun(vector<ll> &h,ll n)
{
    if(n==0) return 0;
    if(dp[n]!=-1) return dp[n];
    if(n==1) dp[n]=abs(h[n]-h[n-1]);
    else
    dp[n]=min(abs(h[n]-h[n-1])+fun(h,n-1), abs(h[n]-h[n-2])+fun(h,n-2));
    return dp[n];
}
int main()
{
    FASTIO;
    ll n,i;
    cin>>n;
    memset(dp,-1,sizeof(dp));
    vector<ll> h(n);
    for(i=0;i<n;i++) cin>>h[i];
    cout<<fun(h,n-1)<<endl;
    return 0;
}



Measured memory_bytes: 4224
package main

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

const pi = math.Pi

var mod int = pow(10, 9) + 7
var Umod uint64 = 1000000007
var ans, cnt, sum int = 0, 0, 0

func main() {
	reader.Split(bufio.ScanWords)
	N, _ := strconv.Atoi(read())
	A := make([]int, N)
	mark := make(map[int]int)
	for i := 0; i < N; i++ {
		A[i], _ = strconv.Atoi(read())
		if i%2 == 0 {
			mark[A[i]] = 0
		} else {
			mark[A[i]] = 1
		}
	}
	sort.Ints(A)
	for i := 0; i < N; i++ {
		if mark[A[i]] != i%2 {
			ans++
		}
	}
	fmt.Println(ans / 2)
}

/*  ----------------------------------------  */

var reader = bufio.NewScanner(os.Stdin)

func read() string {
	reader.Scan()
	return reader.Text()
}

func lcm(x, y int) int {
	return (x / gcd(x, y)) * y
}

func gcd(x, y int) int {
	if x%y == 0 {
		return y
	} else {
		r := x % y
		return gcd(y, r)
	}
}

var fac [1000000]int
var finv [1000000]int
var inv [1000000]int

func combination_init() {
	fac[0], fac[1] = 1, 1
	finv[0], finv[1] = 1, 1
	inv[1] = 1

	// invは a^(-1) mod p
	// pをaで割ることを考える

	// p/a*(a) + p%a = p
	// p/a*(a) + p%a = 0          (mod p)
	// -p%a = p/a*(a)             (mod p)
	// -p%a *a^(-1)= p/a          (mod p)
	// a^(-1)= p/a * (-p%a)^(-1)  (mod p)
	// a^(-1) =

	for i := 2; i < 1000000; i++ {
		fac[i] = fac[i-1] * i % mod
		inv[i] = mod - inv[mod%i]*(mod/i)%mod
		finv[i] = finv[i-1] * inv[i] % mod
	}
}

func combination(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[y] * finv[x-y] % mod) % mod
	//return fac[x] / (fac[y] * fac[x-y])
}

func permutation(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[x-y] % mod) % mod
	//return fac[x] / fac[x-y]
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }
func ceil(x int) int   { return int(math.Ceil(float64(x))) }

type SortBy []int

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

type PriorityQueue []int

func (h PriorityQueue) Len() int            { return len(h) }
func (h PriorityQueue) Less(i, j int) bool  { return h[i] < h[j] }
func (h PriorityQueue) Swap(i, j int)       { h[i], h[j] = h[j], h[i] }
func (h *PriorityQueue) Push(x interface{}) { *h = append(*h, x.(int)) }
func (h *PriorityQueue) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}


Measured memory_bytes: 7936
#include<bits/stdc++.h>
using namespace std;
#define T top()
#define E end()
#define PS push
#define Q queue
#define PP pop()
#define L0 (LL)0
#define V vector
#define ST stack
#define FI first
#define MAX 4e18
#define MIN -MAX
#define DQ deque
#define RE rend()
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define SE second
#define DL double
#define G getline
#define IN insert
#define endl "\n"
#define EM empty()
#define RB rbegin()
#define PSB push_back
#define PI acos(-1.00)
#define PPB pop_back()
#define PSF push_front
#define ub upper_bound
#define lb lower_bound
#define MD 1000000007
#define PPF pop_front()
#define LL long long int
#define PQ priority_queue
#define N cout<<"NO"<<endl
#define Y cout<<"YES"<<endl
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)
#define UOSMOY v.C;w.C;ww.C;u.C;uu.C;uo.C;vo.C;vu.C;ab.C;bc.C;cc.C;uuu.C;a.C;b.C;c.C
V<LL>v;
V<LL>w,ab;
set<LL>uo;
map<LL,LL>u;
map<LL,LL>ww,cc,bc;
LL ar[500][500];
LL br[500][500];
LL cr[500][500];
V<pair<LL,LL> >uu;
map<LL,V<LL> >uuu;
map<pair<LL,LL>,LL> vo;
map<pair<LL,LL>,LL> vu;
int main()
{
//  BRR;
//  file;
    FAST;
    char ch;
    string a,b,c;
    DL x,y,d,e,f,g,h;
    LL n,m,i,j,k,p,q,o,l,s,tt=1,t,z,aa,r=0;
//    cin>>tt;
    while(tt--)
    {
        UOSMOY;
        cin>>n>>m;
        for(i=0; i<m; i++)
        {
            cin>>o;
            u[o]++;
        }
        k=MAX;
        for(i=-1000; i<=1000; i++)
        {
            if(u[i]==0)
            {
                o=abs(n-i);
                if(o<k)
                {
                    k=o;
                    l=i;
                }
            }
        }
        cout<<l<<endl;
    }
    return 0;
    //IN
    //AL
}


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

using namespace std;

long long int X;

void load(void);
void output(void);

int main(void){
	load();
	output();
}

void load(void){
	cin >> X;
}

void output(void){
	long long int i = 0, j = 100;
  	for(i = 1;i < 100000000000000000;i++){
      	j = (long long int)(j * 1.01);
  		if(j >= X){
    		break;
    	}
    }
    cout << i;
}

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

using namespace std;
using LL = long long;



int main()
{
    std::cout << std::setprecision(20);

    int N;cin >> N;

    priority_queue<int, vector<int>, greater<int>> que2;
    que2.push(10+1e9);
    priority_queue<int> que1;
    que1.push(-1e9-10);
    LL sum = 0;
    LL L = 0, R = 0;
    for(int i = 0;i < N;i++){
        int q;cin >> q;
        if(1 == q){
            int a,b;cin >> a >> b;
            sum += b;
            if(a < que1.top()){
                que1.push(a);
                L += a;
            }else{
                que2.push(a);
                R += a;
            }

            if(que1.size() - que2.size() >= 2){
                que1.push(que2.top());
                L += que2.top();
                R -= que2.top();
                que2.pop();
            }
            if(que2.size() - que1.size() >= 2){
                que2.push(que1.top());
                R += que1.top();
                L -= que1.top();
                que1.pop();
            }

        }else{
          //  cout<<que1.top()<<" "<<que2.top()<<endl;
          //  cout<<L<<" "<<que1.size()<<endl;
            /*
            if(que1.size() > que2.size()){
                int x = que1.top();

                LL s = 1LL*(que1.size()-1) * x - L + R - (que2.size()-1) * x;
                cout<<x<<" "<<s + sum<<endl;
            }else{
                int x = que2.top();

                LL s = 1LL*(que1.size()-1) * x - L + R - (que2.size()-1)*x;
                cout<<x<<" "<<s + sum<<endl;
            }
            */
            if(que1.size() < que2.size()){
                int x = que2.top();

                LL s = 1LL*(que1.size()-1) * x - L + R - (que2.size()-1)*x;
                cout<<x<<" "<<s + sum<<endl;
            }else{
                int x = que1.top();

                LL s = 1LL*(que1.size()-1) * x - L + R - (que2.size()-1) * x;
                cout<<x<<" "<<s + sum<<endl;
            }
        }
    }
    return 0;
}


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

int main(void){
    int n;cin>>n;
    int res=0;
    int now=1;
    for(int i=0;i<n;i++){
        int a;cin>>a;
        if(a==now)now++;
        else res++;
    }
    if(res==n)cout<<-1<<endl;
    else cout<<res<<endl;
}


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

  
int main()
{
  long long n;
  cin>>n;
  int res=1;
  for(int i=sqrt(n);i>=2;i--)
  {
    if(n%i==0)
    {
      res=i;
      break;
    }
  }
  cout<<res+n/res-2;
}


Measured memory_bytes: 3684
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] k = new int[n];
        int[][] d = new int[n][m];
        for (int i = 0 ; i < n ; i++) {
            k[i] = sc.nextInt();
            for (int j = 0 ; j < k[i] ; j++) {
                int f = sc.nextInt() - 1;
                d[i][f]++;
            }
        }
        int count = 0;
        for (int i = 0 ; i < m ; i++) {
            int temp = 0;
            for (int j = 0 ; j < n ; j++) {
                if (d[j][i] == 1) temp++;
            }
            if (temp == n) count++;
        }
        System.out.println(count);
    }

}


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

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i ,a, b) for (int i = a ; i <= b ; i++)
#define sz(a) int(a.size())
#define cuti(a) cout << a << endl;
#define cutii(a,b) cout << a << " " << b << endl;
#define cutiii(a,b,c) cout << a << " " << b << " " << c << endl;
#define vec(a) vector<int > a;

template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }

typedef long long LL;
typedef pair<int ,int > pii;
typedef pair<string ,int > psi;
typedef pair<string ,string > pss;
typedef pair<LL, LL> pLL;

const long long oo = 1e9 + 7;

int n;
int a[20];
long long ans;
long long odd;

int main(){
   // freopen("test.txt","r",stdin);
    cin >> n;
    odd = 1;
    ans = 1;
    for (int i =1 ; i <= n; i++) {
        cin >> a[i];
        if ( a[i] % 2 == 0 ) odd *=2;
        else odd *= 1;
        ans *= 3;
    }
    cout << ans - odd <<endl;
}


Measured memory_bytes: 256
N = int(input())
ans = 0
nums = [int(input()) for _ in range(N)]
for i in range(len(nums)):
    ans += nums[i]//2
    nums[i] %=  2
    if  i + 1 != N and nums[i]  > 0  and nums[i + 1] > 0:
        ans += 1
        nums[i] -= 1
        nums[i + 1] -= 1
print(ans)

Measured memory_bytes: 51928
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
// dfmt on

void main()
{
    long N, D;
    scan(N, D);
    long a = (2 * D + 1);
    writeln((N + a - 1) / a);
}


Measured memory_bytes: 256
n=int(input())
K=int(input())
if K==1:
    counter=0
    for i in range(100):
        for j in range(1,10):
            a="0"*(i)+str(j)+"0"*(99-i)
            if 1<=int(a)<=n:
                counter+=1
    print(counter)
elif K==2:
    counter=0
    for i in range(100):
        for j in range(i+1,100):
            for k in range(1,10):
                for l in range(1,10):
                    a="0"*(i)+str(k)+"0"*(j-i-1)+str(l)+"0"*(99-j)
                    if 1<=int(a)<=n:
                        counter+=1
    print(counter)
elif K==3:
    counter=0
    for i in range(100):
        if 100-i>len(str(n)):
            pass
        elif 100-i<len(str(n)):
            for j in range(i+1,100):
                for k in range(j+1,100):
                    counter+=9*9*9
        elif 100-i==len(str(n)):
            for j in range(i+1,100):
                for k in range(j+1,100):

                        for b in range(1,10):
                            for c in range(1,10):
                                P=(str(n)[0])+"0"*(j-i-1)+str(b)+"0"*(k-j-1)+str(c)+"0"*(99-k)
                                if 1<=int(P)<=n:
                                    counter+=1
            counter+=((98-i)*(99-i)//2)*9*9*(int(str(n)[0])-1)
    print(counter)
                    


                    


Measured memory_bytes: 46812
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		// 整数の入力
		//int a = int.Parse(Console.ReadLine());
		// スペース区切りの整数の入力
		List<int> bingo = new List<int>();

		string[] bingo1 = Console.ReadLine().Split(' ');
		bingo.Add(int.Parse(bingo1[0]));
		bingo.Add(int.Parse(bingo1[1]));
		bingo.Add(int.Parse(bingo1[2]));

		bingo1 = Console.ReadLine().Split(' ');
		bingo.Add(int.Parse(bingo1[0]));
		bingo.Add(int.Parse(bingo1[1]));
		bingo.Add(int.Parse(bingo1[2]));

		bingo1 = Console.ReadLine().Split(' ');
		bingo.Add(int.Parse(bingo1[0]));
		bingo.Add(int.Parse(bingo1[1]));
		bingo.Add(int.Parse(bingo1[2]));



		int N = int.Parse(Console.ReadLine());
		for(int i=0; i<N; i++)
		{
			int b = int.Parse(Console.ReadLine());
			// ビンゴ表に数字があるか探す
			for(int j=0; j<bingo.Count; j++)
			{
				if(bingo[j] == b)
				{
					bingo[j] = -1;
				}
			}
		}

		// ビンゴが発生してるか８通り確かめる
		// 123
		bool isBingo = false;
		if(bingo[0] == -1 && bingo[1] == -1 && bingo[2] == -1)
		 isBingo = true;
		// 456
 		if(bingo[3] == -1 && bingo[4] == -1 && bingo[5] == -1)
		 isBingo = true;
		// 789
 		if(bingo[6] == -1 && bingo[7] == -1 && bingo[8] == -1)
		 isBingo = true;
		// 147
 		if(bingo[0] == -1 && bingo[3] == -1 && bingo[6] == -1)
		 isBingo = true;
		// 258
 		if(bingo[1] == -1 && bingo[4] == -1 && bingo[7] == -1)
		 isBingo = true;
		// 369
 		if(bingo[2] == -1 && bingo[5] == -1 && bingo[8] == -1)
		 isBingo = true;
		// 159
 		if(bingo[0] == -1 && bingo[4] == -1 && bingo[8] == -1)
		 isBingo = true;
		// 357
 		if(bingo[2] == -1 && bingo[4] == -1 && bingo[6] == -1)
		 isBingo = true;
		//int b = int.Parse(input[0]);
		//int c = int.Parse(input[1]);
		// 文字列の入力
		//string s = Console.ReadLine();
		//出力
		//Console.WriteLine((a+b+c) + " " + s);
		if(isBingo)
		 Console.WriteLine("Yes");
		else
		 Console.WriteLine("No");
	}
}


Measured memory_bytes: 13268
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.nextLine());
    int[] val = new int[N];
    for(int i = 0; i < N; i++){
      val[i] = Integer.parseInt(sc.next());
    }
    Arrays.sort(val);
    int a = 0;
    int b = 0;
    for(int i = 0; i < N; i++){
      if(i%2==0){
        a += val[i];
      }else{
        b += val[i];
      }
    }
    System.out.println(Math.abs(a-b));
  }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)

using namespace std;

int main(){
    int n,k;
    string s,ans;
    cin >> n >> k >>s;
    if(s[k-1]=='A'){
        s[k-1]='a';
    }
    if(s[k-1]=='B'){
        s[k-1]='b';
    }
    if(s[k-1]=='C'){
        s[k-1]='c';
    }

    cout<< s<< endl;
    
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define printYes() cout << "Yes" << endl;
#define printNo() cout << "No" << endl;
#define printVector(v) rep(i, v.size()) cout << v[i] << endl;

int main()
{
  int D, G;
  cin >> D >> G;
  vector<pair<int, int>> problem(D);
  G /= 100;

  rep(i, D)
  {
    cin >> problem[i].first >> problem[i].second;
    problem[i].second /= 100;
  }

  int ans = INT32_MAX;
  for (int bit = 0; bit < (1 << D); bit++)
  {
    int score = 0;
    int problem_num = 0;
    int max_i = 0;
    for (int i = 0; i < D; i++)
    {
      if (bit & (1 << i))
      { // 列挙に i が含まれるか
        score += (i + 1) * problem[i].first + problem[i].second;
        problem_num += problem[i].first;
      }
      else
        max_i = i;
    }

    int rest = G - score;
    if (rest <= 0)
    {
      ans = min(ans, problem_num);
      continue;
    }
    else if (rest > problem[max_i].first * (max_i + 1))
      continue;
    problem_num += (rest + max_i) / (max_i + 1);
    ans = min(ans, problem_num);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
<?php
  list($n) = explode(" ", trim(fgets(STDIN)));
  $a = array_map('intval', explode(" ", trim(fgets(STDIN))));

  $ans=0;
  while(1){
    for ($i=0; $i<$n; $i++) {
      if($a[$i]%2==0){
        $a[$i]=$a[$i]/2;
      }else{
        echo $ans;
        exit;
      }
    }
    $ans++;
  }

Measured memory_bytes: 16180
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

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; }
mint fact(int n) {
  if(n == 1 || n == 0) return 1;
  mint res = n;
  return res * fact(n - 1);
}

int main() {
  ll n, s;
  cin >> n >> s;
  vl a(n);
  rep(i, n) cin >> a[i];
  mint dp[n + 1][s + 1] = {};
  dp[0][0] = 1;
  rep(i, n) {
    dp[i + 1][0] = 1;
    rep(j, s + 1) {
      int nj = j + a[i];
      if(nj <= s) dp[i + 1][nj] += dp[i][j];
      dp[i + 1][j] += dp[i][j];
    }
  }
  mint ans = 0;
  rep(i, n + 1) ans += dp[i][s];
  cout << ans << endl;
}

Measured memory_bytes: 70656
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<map>
#include<algorithm>

using namespace std;

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

    vector<int> h(n, 0);
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }

    if (n <= 1 + k) {
        cout << abs(h[n - 1] - h[0]) << endl;
        return 0;
    }

    vector<long long> dp(n, 0);
    dp[0] = 0;
    for (int i = 0; i < k + 1; i++) {
        dp[i] = abs(h[i] - h[0]);
    }

    for (int i = k + 1; i < n; i++) {
        dp[i] = dp[i - 1] + abs(h[i] - h[i - 1]);
        for (int j = 2; j <= k; j++) {
            dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
        }
    }

    cout << dp[n - 1] << endl;

    return 0;
}


Measured memory_bytes: 1408
object Main extends App {
	val Array(a,b,c,k) = scala.io.StdIn.readLine.split(" ").map(_.toLong)

	var ans = 0L

	if(k%2 == 0){
		ans = a - b	
	}else{
		ans = b - a
	}

	if(ans.abs > 1000000000000000000L){
		println("Unfair")
	}else{
		println(ans)
	}

}

Measured memory_bytes: 25524
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	int maxn=0;
	int k=0;
	scanf("%d",&n);
	int a[n];
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		if(a[i]>=maxn)
		maxn=a[i];
		else if(a[i]<maxn-1){
			k=1;
		}
	}
	if(k==1)
	printf("No\n");
	else
	printf("Yes\n");
  return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
int main()
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if(a<b){
		if(b<c){
			printf("Yes");
		}
		else
			printf("No");
	}
	else
		printf("No");
	putchar('\n');

	return 0;
}

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

int main()
{
    int n ;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    if( n==1 )
    {
        cout<<1<<" "<<1;
        return 0;
    }
    int * b = new int[9]();
    for(int i=0;i<n;i++)
    {
        if( a[i] >=1 && a[i ]<= 399)
            b[0]++;
        if( a[i] >=400 && a[i ]<= 799)
            b[1]++;
        if( a[i] >=800 && a[i ]<= 1199)
            b[2]++;
        if( a[i] >=1200 && a[i ]<= 1599)
            b[3]++;
        if( a[i] >=1600 && a[i ]<= 1999)
            b[4]++;
        if( a[i] >=2000 && a[i ]<= 2399)
            b[5]++;
        if( a[i] >=2400 && a[i ]<= 2799)
            b[6]++;
        if( a[i] >=2800 && a[i ]<= 3199)
            b[7]++;
        if( a[i] >=3200 )
            b[8]++;
    }
    int min =0, max =0;
    for(int i=0;i<8;i++)
    {
        if( b[i] >0)
            min++;
    }
    max = min + b[8];
    if( min ==0)
    {
        cout<<1<<" "<<max;
    }
    else cout<<min<<" "<<max;

}

Measured memory_bytes: 3624
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<assert.h>
#define rep(i,N) for(int i=0;i<(int)N;i++)
int N,x,y,z,sw,pw3[13]={1},A[531441]={0},trit[13][531441]={0};
char T[200001];
void OUT(int x){if(x<0)putchar('-'),x=-x;if(x>=10)OUT(x/10);putchar(x%10+48);}
char* replace(char* s,const char* before,const char* after)
{
  assert(s!=(char*)NULL);assert(before!=(char*)NULL);assert(after!=(char*)NULL);
  const size_t szb=strlen(before),sza=strlen(after);
  char* pt=s;
  if(szb==0)return s;
  for(;;)
  {
    pt=strstr(pt,before);if(pt==(char*)NULL)break;const char* remain=pt+szb;
    memmove(pt+sza,remain,strlen(remain)+1);
    memcpy(pt,after,sza);
    pt+=sza;
  }
  return s;
}
signed main(void)
{
  x=scanf("%d %s",&N,T+1);
  replace(T+1,"SS","");if(T[0]=='\n')return 0;
  rep(i,N)pw3[i+1]=3*pw3[i];
  rep(i,strlen(T+1))
  {
    if(T[i+1]=='S'){sw^=1;continue;}
    x=0;
    rep(j,N)
    {
      if(sw)z=1;else z=2;
      y=x+pw3[j]*((trit[j][x]+z)%3);
      trit[j][x]=(trit[j][x]+z)%3;
      x=y;
    }
  }
  rep(i,N)
  {
    rep(j,pw3[N])
    {
      x=((j/pw3[i])%3-trit[i][j%pw3[i]]+3)%3;
      if(sw)x=(3-x)%3;
      A[j]+=x*pw3[i];
    }
  }
  rep(i,pw3[N])OUT(A[i]),putchar(' ');
}

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

#define ll long long

int main(){

    int X,X_hold,sum_x = 0;
    double i=100000000;

    cin >> X;
    X_hold = X;

    while(i >= 1){
        sum_x += (int)(X/i) % 10;
        i *= 0.1;
    }

    if(X_hold % sum_x == 0)cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int s[33];
int main()
{
    string a;
    cin>>a;
    for(int i=0;i<a.length();i++)
    {
        if(s[a[i]-'a']){puts("no");return 0;};
        s[a[i]-'a']=1;
    }
    puts("yes");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <set>

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

using namespace std;

int main(){
    string s; cin >> s;
    int k; cin >> k;
    priority_queue<string, vector<string>, greater<string> > pq;
    set<string> set;
    for(int l = 0; l < s.size(); l++){
        for(int r = l; r < s.size() && r-l+1 <= 5; r++) {
            string str = s.substr(l,r-l+1);
            if(set.find(str) == set.end()) {
                set.insert(str);
                pq.push(str);
            }
        }
    }
    for(int i = 0; i < k-1; i++){
        pq.pop();
    }
    cout << pq.top() << endl;
}



Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#define N 55
using namespace std;

int n, mx, mi = 1, a[N];

int abs(int p) {return p > 0 ? p : -p;}

int main()
{
	int i;
	cin >> n;
	for (i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
		if (abs(a[i]) > mx) mx = abs(a[i]), mi = i;
	}
	printf("%d\n", n * 2 - 1);
	for (i = 1; i <= n; i++) a[i] += a[mi], printf("%d %d\n", mi, i);
	if (a[mi] > 0)
		for (i = 2; i <= n; i++) a[i] += a[i - 1], printf("%d %d\n", i - 1, i);
	else
		for (i = n - 1; i > 0; i--) a[i] += a[i + 1], printf("%d %d\n", i + 1, i);
    return 0;
}

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

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

def main():
    mod=10**9+7
    N=I()
    ans=N
    
    M=10**6+5
    for i in range(1,M):
        if N%i==0:
            j=N//i
            temp=i+j-2
            ans=min(ans,temp)
            
    print(ans)
            
        

main()


Measured memory_bytes: 63868
main = do
    s <- fmap (map (map read) . map words . lines) getContents
    mapM_ (mapM_ putStrLn . rect) $ takeWhile (\(a:b:_) -> a /= 0 && b /= 0) s
    where rect (h:w:_) = [(replicate w '#')] ++ (replicate (h-2) ("#" ++ (replicate (w-2) '.') ++ "#")) ++  [(replicate w '#')] ++ [""]



Measured memory_bytes: 4072
import std.stdio, std.conv, std.string, std.algorithm,
       std.math, std.array, std.container, std.typecons;

int[] maps = new int[256];
int[] mapt = new int[256];
int sn = 1, tn = 1;

bool check(char sc, char tc) {
  if(maps[sc]==0) maps[sc] = sn++;
  if(mapt[tc]==0) mapt[tc] = tn++;
  return maps[sc]==mapt[tc];
}

bool solve() {
  auto s = readln.chomp;
  auto t = readln.chomp;
  for(int i=0; i<s.length; i++) if(!check(s[i], t[i])) return false;
  return true;
}

void main() {
  if(solve()) writeln("Yes");
  else writeln("No");
}


Measured memory_bytes: 2872
#include<iostream>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<map>
#include<utility>
#include<cmath>
#include<tuple>
#include<string>
#include<bitset>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
using namespace std;
typedef long long ll;

int main(){
    double n,m; cin>>n>>m;
    vector<double> a(n);
    double sum=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
    }
    
    int cnt=0;
    for(int i=0;i<n;i++){
        if(a[i]>=sum/4/m) cnt++;
    }
    if(cnt>=m) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
/* -----KAUN_MEET--------*/

#include <bits/stdc++.h>
using namespace std;
#define int long long int
int mod = 1000000007;
#define P get<0>
#define D get<1>
#define T get<2>
#define C get<3>
#define PB push_back
#define MP make_pair
#define BS binary_search
#define LB lower_bound
#define UB upper_bound
#define F first
#define S second
#define gcd __gcd
#define fastio               \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);

void __print(int x)
{
    cerr << x;
}
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template <typename Th, typename V>
void __print(const pair<Th, V> &x)
{
    cerr << '{';
    __print(x.first);
    cerr << ',';
    __print(x.second);
    cerr << '}';
}
template <typename Th>
void __print(const Th &x)
{
    int f = 0;
    cerr << '{';
    for (auto &i : x)
        cerr << (f++ ? "," : ""), __print(i);
    cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename Th, typename... V>
void _print(Th t, V... v)
{
    __print(t);
    if (sizeof...(v))
        cerr << ", ";
    _print(v...);
}
#ifndef ONLINE_JUDGE
#define debug(x...)               \
    cerr << "[" << #x << "] = ["; \
    _print(x)
#else
#define debug(x...)
#endif
void binary_rock()
{
    int n;
    cin>>n;
    int i,j,k,l;
    vector <int> a(n);
    for(i=0;i<n;i++) cin>>a[i];

    int cost[n];
    cost[0]=0;
    cost[1]=(abs(a[1]-a[0]));
    for(i=2;i<n;i++){
        int xx=cost[i-1]+(abs(a[i]-a[i-1]));
        int yy=cost[i-2]+((abs(a[i]-a[i-2])));
        cost[i]=min(xx,yy);
    }
    cout<<cost[n-1]<<endl;
}

signed main()
{
    fastio
        clock_t t1 = clock();

    int t = 1;
    // cin >> t;
    while (t--)
    {
        binary_rock();
    }

    clock_t t2 = clock();
    // cout << "Time-Taken: " << ((t2 - t1) / (double)CLOCKS_PER_SEC) << endl;
    // cout << CLOCKS_PER_SEC << endl;
    return 0;
}

Measured memory_bytes: 1920
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	int N, K;
	int ans = 0;
	cin >> N >> K;

	vector<int> L(N);
	for (int i = 0; i < N; i++)
	{
		cin >> L[i];
	}

	sort(L.begin(), L.end());

	int count = 0;
	for (int i = N - 1; i >= 0; i--)
	{
		if (count >= K)
			break;

		ans += L[i];
		count++;
	}

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


Measured memory_bytes: 256
#include<stdio.h>

int main() {
	int S;
	int h,m,s;
	scanf("%d",&S);
	h = S/3600;
	S = S-(h*3600);
	m = S/60;
	S = S-(m*60);
	s = S;
	printf("%d:%d:%d\n",h,m,s);

	return 0;
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n; cin >> n;
	string a; cin >> a;

	ll i = 0, j = n-1, res = 0;
	while (i < j) {
		if (a[i] == 'R') {
			i++;
		} else if (a[j] == 'W') {
			j--;
		} else {
			res++, i++, j--;
		}
	}
	cout << res << endl;
}



Measured memory_bytes: 3732
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int r,g,b,n,i,j,k=0;
    cin>>r>>g>>b>>n;
    for(i=0;i*r<=n;i++)
        for(j=0;j*g+i*r<=n;j++)
            if((n-i*r-j*g)%b==0)
                k++;
    cout<<k;
    return 0;
}


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

#define LL long long int
#define inp_s ios::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)
#define mod 1000000007

LL f[27];
LL n;

int main(){
      inp_s;
      string s, res;
      cin >> s;
      n = s.size();
      for(LL i=0 ; i<n ; i++){
            f[s[i] - 'a']++;
      }
      LL ans = ((n*(n-1)) / 2);
      for(int i=0 ; i<=25 ; i++){
            ans -= ((f[i]*(f[i]-1))/2);
      }
      cout << ans + 1;
      return 0;
}

Measured memory_bytes: 720
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

#include <bits/stdc++.h>

using namespace std;

struct UnionFind {
    vector<int> par;

    UnionFind(int n): par(n, -1) {}
    void init(int n) { par.assign(n, -1); }

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

    int issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);

        if (x == y) return false;

        // merge by size
        // y must be bigger than x
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;

        return true;
    }

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

int NMAX = 100100;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N;
    cin >> N;

    UnionFind uf(NMAX * 2);
    vi X(N), Y(N);
    REP(i, N) cin >> X[i] >> Y[i], uf.merge(X[i], Y[i] + NMAX);

    map<ll, ll> mx, my;
    REP(i, NMAX) mx[uf.root(i)]++;
    REP(i, NMAX) my[uf.root(i + NMAX)]++;

    ll res = 0;
    REP(i, 2 * NMAX) res += mx[i] * my[i];

    print(res - N);
}


Measured memory_bytes: 29876
#include<cstdio>

int main() {
  int height, width;

  while(true) {
    scanf("%d %d", &height, &width);

    if(height == 0 && width == 0) {
      break;
    }

    for(int i = 0; i < height; i++) {
      for(int j = 0; j < width; j++) {
        bool isTop = i == 0;
        bool isRight = j == width - 1;
        bool isBottom = i == height - 1;
        bool isLeft = j == 0;

        if(isTop || isRight || isBottom || isLeft) {
          printf("#");
        } else {
          printf(".");
        }
      }

      printf("\n");
    };

    printf("\n");
  }
}



Measured memory_bytes: 2612
s = list(input())
Q = int(input())
query = [list(input().split()) for _ in range(Q)]

a = []
b = []
d = 1

for q in query:
    if q[0] == '1':
        d *= -1
    else:
        if q[1] == '1':
            if d == 1:
                a.append(q[2])
            else:
                b.append(q[2])
        else:
            if d == 1:
                b.append(q[2])
            else:
                a.append(q[2])

if d == 1:
    ans = list(reversed(a)) + s + b
else:
    ans = list(reversed(b)) + list(reversed(s)) + a

print(''.join(ans))

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

class Work implements Comparable<Work>{
	int A, B;
	public Work(int _A, int _B) {
		A = _A; B = _B;
	}
	public int compareTo(Work o) {
		if(B - o.B != 0) return B - o.B;
		return A - o.A;
	}
}

public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		while(sc.hasNext()) {
			int N = sc.nextInt();
			Work[] works = new Work[N];
			for(int i = 0; i < N; i++) works[i] = new Work(sc.nextInt(), sc.nextInt());
			Arrays.sort(works);
			int time = 0;
			boolean canWork = true;
			for(int i = 0; i < N; i++) {
				time += works[i].A;
				if(time > works[i].B) {
					canWork = false;
					break;
				}
			}
			System.out.println(canWork ? "Yes" : "No");
		}
	}
}

Measured memory_bytes: 103336
n = int(input())
a = list(map(int, input().split()))

e = 10**18
ans = a[0]
if 0 in a:
    print(0)
    exit()

for i in range(1, n):
    ans = ans * a[i]
    if ans > e:
        print(-1)
        exit()
print(ans)


Measured memory_bytes: 21652
N, W = map(int, input().split())
wv = []
w0 = []
w1 = []
w2 = []
w3 = []
for i in range(N):
    wv.append(list(map(int, input().split())))
wv.sort(key=lambda x:(x[0], -x[1]))

wbase = wv[0][0]
for w, v in wv:
    if(w == wbase):
        w0.append(v)
    elif(w == wbase+1):
        w1.append(v)
    elif(w == wbase+2):
        w2.append(v)
    else:
        w3.append(v)
        
sw0, sw1, sw2, sw3 = [0], [0], [0], [0]
s = 0
for v in w0:
    s += v
    sw0.append(s)
s = 0
for v in w1:
    s += v
    sw1.append(s)
s = 0
for v in w2:
    s += v
    sw2.append(s)
s = 0
for v in w3:
    s += v
    sw3.append(s)
    
value = 0
ans = 0
for i in range(len(sw0)):
    if(wbase*i > W):
        break
    for j in range(len(sw1)):
        if(wbase*i+(wbase+1)*j > W):
            break
        for k in range(len(sw2)):
            if(wbase*i+(wbase+1)*j+(wbase+2)*k > W):
                break
            for l in range(len(sw3)):
                if(wbase*i+(wbase+1)*j+(wbase+2)*k+(wbase+3)*l > W):
                    break
                value = sw0[i]+sw1[j]+sw2[k]+sw3[l]
                ans = max(ans, value)        
print(ans)          

Measured memory_bytes: 9304
#include <stdio.h>
int main(){
 long int max,min,g,n,i,j;
 max=-1000001;min=1000001;g=0;
 scanf("%ld",&n);
 for(i=0;i<n;i++){
  scanf("%ld",&j);
  if(max<j)
   max=j;
  if(min>j)
   min=j;
  g+=j;}
 printf("%ld %ld %ld\n",min,max,g);
 return 0;
}


Measured memory_bytes: 2104