akhauriyash/Code-Regression huggingface dataset:
def root(x):
    i,j = x[0],x[1]
    if (i,j) == p[i][j]:
        return (i,j)
    y = root(p[i][j])
    p[i][j]=y
    return y
def unite(x, y):
    px = root(x); py = root(y)
    if px == py:
        return 0
    pxi,pxj= px[0],px[1];pyi,pyj= py[0],py[1];
    rx = rank[pxi][pxj]; ry = rank[pyi][pyj]
    if ry < rx:
        p[pyi][pyj] = px
    elif rx < ry:
        p[pxi][pxj] = py
    else:
        p[pyi][pyj] = px
        rank[pxi][pxj] += 1
    return 1

h,w = map(int, input().split( ))
s = ["x"*(w+2)]+["x"+input()+"x" for _ in range(h)]+["x"*(w+2)]
p = [[(i,j) for j in range(w+2)] for i in range(h+2)]
rank = [[1]*(w+2) for _ in range(h+2)]

tonari = [(-1,0),(1,0),(0,1),(0,-1)]
for i in range(1,h+1):
    for j in range(1,w+1):
        for di,dj in tonari:
            i2 = i+di;j2 = j+dj
            if (s[i][j],s[i2][j2])==("#",".") or (s[i][j],s[i2][j2])==(".","#") :
                unite((i,j),(i2,j2))
c = [[p[i][j] for j in range(1,w+1)] for i in range(1,h+1)]
ans = 0
####
for i in range(h+2):
    for j in range(w+2):
        root((i,j))
pb = {}
pw = {}
##pb,pwの引数はroot とる
for i in range(h):
    for j in range(w):
        k = c[i][j]
        if s[i+1][j+1] =="#":
            if root(k) in pb:
                pb[root(k)]+=1
            else:
                pb[root(k)]=1
        elif s[i+1][j+1]==".":
            if root(k) in pw:
                pw[root(k)]+=1
            else:
                pw[root(k)]=1
ans = 0
c2 =  set([p[i][j] for j in range(w+2) for i in range(h+2)])

for k in c2:
    if k in pb and k in pw:
        ans += pb[k]*pw[k]
print(ans)


Measured memory_bytes: 141640
package main

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

var (
	n int
	m int
	x int
	c []int
	a [][]int
)

func main() {
	n = readi()
	m = readi()
	x = readi()
	c = make([]int, n)
	a = make([][]int, n)
	for i := 0; i < n; i++ {
		c[i] = readi()
		a[i] = make([]int, m)
		for ii := 0; ii < m; ii++ {
			a[i][ii] = readi()
		}
	}

	ans := INF
	for b := 0; b < (1 << uint64(n)); b++ {
		tmpC := 0
		tmp := make([]int, m)
		for i := 0; i < n; i++ {
			if b>>uint(i)&1 == 1 {
				for ii := 0; ii < m; ii++ {
					tmp[ii] = tmp[ii] + a[i][ii]
				}
				tmpC += c[i]
			}
		}
		f := true
		for i := 0; i < m; i++ {
			if tmp[i] < x {
				f = false
			}
		}
		if f {
			ans = min(ans, tmpC)
		}
	}

	if ans == INF {
		fmt.Println("-1")
		return
	}

	fmt.Println(ans)
}

/*-------------------utilities-------------------*/

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

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func chmin(x *int, y int) bool {
	if *x > y {
		*x = y
		return true
	}
	return false
}

func chmax(x *int, y int) bool {
	if *x < y {
		*x = y
		return true
	}
	return false
}

// 最大公約数
func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

// 最小公倍数
func lcm(a, b int) int {
	return (a * b) / gcd(a, b)
}

func comb(n, k int) int {
	if n < k {
		return 0
	}
	if n < 0 || k < 0 {
		return 0
	}
	return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD
}

/*-------------------init-------------------*/

const (
	INF = 1000000000000000000
	MOD = 1e9 + 7

	COMB_MAX = 510000
)

var (
	readString func() string
)

var (
	fac  = [COMB_MAX]int{}
	finv = [COMB_MAX]int{}
	inv  = [COMB_MAX]int{}
)

func init() {
	readString = newReadString(os.Stdin)
}

func combInit() {
	fac[0] = 1
	fac[1] = 1
	finv[0] = 1
	finv[1] = 1
	inv[1] = 1
	for i := 2; i < COMB_MAX; 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
	}
}

/*-------------------inputs-------------------*/

func readi() int {
	return int(readi64())
}

func readi64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readf() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}


Measured memory_bytes: 2164
#include <cstdio>
#include <cstdlib>
#include <algorithm>
using namespace std;
int dat[1000000];
int max_idx[2*1000000-1];
int size;
void init(int _size) {
	size=1;
	while(_size>size) size*=2;
	for(int i=0;i<size;i++) {
		if(i<_size) dat[i]=0; else dat[i]=-(1<<30);
	}
	for(int i=size*2-2;i>=0;i--) {
		if(i>=size-1) {
			max_idx[i]=i-(size-1);
		}else {
			max_idx[i]=max_idx[i*2+1];
		}
	}
}
void update(int k,int a) {
	dat[k]+=a;
	k+=size-1;
	while(k>0) {
		k=(k-1)/2;
		if(dat[max_idx[k*2+1]]>=dat[max_idx[k*2+2]]) {
			max_idx[k]=max_idx[k*2+1];
		}else {
			max_idx[k]=max_idx[k*2+2];
		}
	}
}
int Time[1000000];
int main() {
	int N,R,L;
	scanf("%d %d %d",&N,&R,&L);
	init(N);
	int cur=0;
	for(int i=0;i<R;i++) {
		int d,t,x;
		scanf("%d %d %d",&d,&t,&x); d--;
		Time[max_idx[0]]+=t-cur;
		update(d,x);
		cur=t;
	}
	Time[max_idx[0]]+=L-cur;
	int max_time=0,max_id=0;
	for(int i=0;i<N;i++) {
		if(Time[i]>max_time) {
			max_time=Time[i];
			max_id=i;
		}
	}
	printf("%d\n",max_id+1);
}

Measured memory_bytes: 7556
n = gets.to_i
sum = (n * (2 * 1 + (n - 1) * 1)) / 2

div_3 = n / 3
sum_3 = (div_3 * (2 * 3 + (div_3 - 1) * 3)) / 2

div_5 = n / 5
sum_5 = (div_5 * (2 * 5 + (div_5 - 1) * 5)) / 2

div_15 = n / 15
sum_15 = (div_15 * (2 * 15 + (div_15 - 1) * 15)) / 2

puts sum - sum_3 - sum_5 + sum_15

Measured memory_bytes: 14388
S = input()
m, n = S[0:2], S[2:4]

if S[0] == '0':
  m = int(S[1])
else:
  m = int(m)
if S[2] == '0':
  n = int(S[3])
else:
  n = int(n)

if 0 < m <= 12 and 0 < n <= 12:
  print('AMBIGUOUS')
elif (m == 0 or m > 12) and 0 < n <= 12:
  print('YYMM')
elif 0 < m <= 12 and (n == 0 or n > 12):
  print('MMYY')
else:
  print('NA')

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

#define         eps         10e-9
#define         pi          2*acos(0)
#define         P1          1e9+7
#define         P2          1e9+9
#define         lli         long long int

using namespace std;

///ISNNJB

/**int fx[]={+1,-1,+0,+0};
int fy[]={+0,+0,+1,-1};
int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};
int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};*/

int main()
{
    /***freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);*/

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int ara[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51},n;
    cin>>n;
    cout<<ara[n-1]<<"\n";

    return 0;
}



Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
S = [0]
for i in range(N):
        S.append(S[i]+A[i])
a = 1
c = 3
ans = S[N]
for b in range(2,N-1):
        while abs(S[b]-S[a]-S[a]) > abs(S[b]-S[a+1]-S[a+1]):
                a += 1
        while abs((S[N]-S[c]) - (S[c]-S[b])) > abs((S[N]-S[c+1]) - (S[c+1]-S[b])):
                c += 1
        ans = min(ans,(max(S[N]-S[c],S[c]-S[b],S[b]-S[a],S[a]-S[0])-min(S[N]-S[c],S[c]-S[b],S[b]-S[a],S[a]-S[0])))
print(ans)


Measured memory_bytes: 25068
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
	int n,t,a[100],b[100],ans=1000,k=0;
	cin>>n>>t;
	for(int i=0;i<n;i++){
		cin>>a[i]>>b[i];
	}
	
	for(int i=0;i<n;i++){
		if(b[i]<=t){
			if(ans>a[i]){
				ans=a[i];
			}
		}
		
		if(b[i]>t){
			k++;
		}
	}
	
	if(k==n){
		cout<<"TLE"<<endl;
	}
	
	else cout<<ans<<endl;
	
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<unordered_map>
#include<map>
#include<queue>
#include<math.h>
using namespace std;


int main(){
  int sx,sy,tx,ty;
  cin >> sx >> sy >> tx >> ty;
  int dx = tx-sx;
  int dy = ty-sy;
  for (int i = 0; i < dx; i++) cout << "R";
  for (int i = 0; i < dy; i++) cout << "U";
  for (int i = 0; i < dx; i++) cout << "L";
  for (int i = 0; i < dy; i++) cout << "D";
  cout << "D";
  for (int i = 0; i < dx+1; i++) cout << "R";
  for (int i = 0; i < dy+1; i++) cout << "U";
  cout << "L";
  cout << "U";
  for (int i = 0; i < dx+1; i++) cout << "L";
  for (int i = 0; i < dy+1; i++) cout << "D";
  cout << "R";
  cout <<endl;
  return 0;
}


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

int main() {

	int n, k; cin >> n >> k;
	vector<double> e(n);
	for (int i = 0; i < n; i++) {
		int p; cin >> p;
		e[i] = (double)(p + 1) / 2;
	}
	double sum = 0;
	int tmp_k = k;
	for (int i = 0; i < k; i++) {
		sum += e[i];
	}
	double ans = sum;
	for (int i = k ; i < n; i++) {
		sum += e[i];
		sum -= e[i - k];
		ans = max(ans, sum);
	}
	cout << fixed << setprecision(11) << ans << endl;
    return 0;
}

Measured memory_bytes: 4836
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#define INPUT(X) cin >> X
#define OUTPUT(X) cout << X << endl

using namespace std;

int main(void) {

	int A,B;
	int X = 0;


	INPUT(A);
	INPUT(B);

	for(int i = 0 ; i < 2 ; i++){
		X += max(A,B);
		if(A>B){
			A--;
		}else{
			B--;
		}
	}


	OUTPUT(X);

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define dcout cout << fixed << setprecision(15)
#define rep(i, a) for(int i = 0; i < a; i++)
#define arep(i, x) for(auto i : x)
#define all(v) v.begin(), v.end()
#define int long long
#define F first
#define S second
#define VE vector<int>
#define MOD 1000000007
#define INF 10000000000
#define pb(x) push_back(x)
using namespace std;
signed main() {
    string s;
    cin >> s;
    int ans = 0;
    rep(i, (int)s.size()) {
        if(s[i] == '+') ans++;
        if(s[i] == '-') ans--;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

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

long long int lcd(long long int a, long long int b) {
    return (a * b) / gcd(a, b);
}

long long int fact(long long int N) {
    long long int result = 1;
    while(N > 0) {
        result = result * N % MOD;
        N--;
    }
    return result;
}

long long int cnk(long long int n, long long int k) {
    return fact(n) / (fact(k) * fact(n - k));
}

long long int binpow(long long int a, long long int n) {
    long long int result = 1;
    while(n != 0) {
        if(n % 2 == 1) {
            result = result * a % MOD;
        }
        a = a * a % MOD;
        n /= 2;
    }
    return result;
}

long long int powermod(long long int base, long long int power) {
    if (power == 0) {
        return 1;
    }
    else {
        long long int cur = powermod(base, power / 2);
        cur = cur * cur;
        cur = cur % MOD;
        if (power % 2 == 1)
            cur = cur * base;
        cur = cur % MOD;
        return cur;
    }
}

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

    long long int n, di, dj, mini = 2 * 1000000000000;
    cin >> n;
    for(long long int i = 1; i * i <= n; i++) {
        if(n % i == 0) {
            di = i - 1;
            dj = n/i - 1;
            if((di + dj) < mini) {
                mini = di + dj;
            }
        }
    }
    cout << mini;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        
        int l = a + b;
        int r = c + d;
        
        if(l == r) {
            System.out.println("Balanced");
        }
        else if(l > r) {
            System.out.println("Left");
        }
        else {
            System.out.println("Right");
        }
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define ll unsigned long long int
#define pp long long int
#define pb push_back
#define mp make_pair
#define eb emplace_back

int binaryExponentiation(int x,int n)//function to calculate x raise to power n
{
    int result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=result * x;
        x=x*x;
        n=n/2;
    }
    return result;
}

int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   int x,y,z;
   cin>>x>>y>>z;
   swap(x,y);
   swap(x,z);
   cout<<x<<" "<<y<<" "<<z<<endl;
  return 0;
}


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

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

  int N, K;
  cin >> N >> K;
  cout << N-K+1 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main()
{
  string s,t;
  int count=0;
  
  cin>>s;
  cin>>t;
  for(int i=0;i<s.size();i++)
  {
    if(s[i]==t[i])
    {
      int count=0;
    }
    else{
      count++;
    }
  }
  cout<<count<<endl;
  return 0;
}

Measured memory_bytes: 3860
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define ll long long 
int ctoi(char c) {return c-'0';}/*char to int*/
int gcd(ll a,ll b){return b?gcd(b,a%b):a;}/*MAX*/
int lcm(ll a,ll b){return a*b/gcd(a,b);}/*MIN*/
bool primecheck(ll n){/*sosuu*/if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
int  main(){
ll n;
cin >> n;
vector<ll>a(n);
vector<ll>che(n+1);
che.at(0)=0;
for(int i=0;i<n;i++){
    cin >> a.at(i);
   che.at(i+1)=che.at(i)+a.at(i);
}
ll ans = 10e17;
for(int i=0;i<n;i++){
    ans =min(ans,abs(che.at(i)+che.at(i)-che.at(n)));
}
cout << ans << endl;
}





Measured memory_bytes: 3328
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;

const ll MOD  = 1e9 + 7;
const ll LINF = 1LL << 62;
const int INF = 1e9 + 7;

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

    ll ans = 0;
    ll back = 0;
    rep(i, n){
        ll h;
        cin >> h;

        ans += max((ll)0, h-back);
        back = h;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <complex>
#include <queue>
#include <set>
#include <list>
#include <chrono>
#include <random>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <stack>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
ll MOD = 1e9+7;
#define forn(i,e) for(ll i = 0; i < e; i++)
#define forsn(i,s,e) for(ll i = s; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF LLONG_MAX/2e5

vv64 gr;
v64 deg;

ll mpow(ll a, ll b){
	if(b==0) return 1;
	ll t1 = mpow(a,b/2);
	t1 *= t1;
	t1 %= MOD;
	if(b%2) t1 *= a;
	t1 %= MOD;
	return t1;
}

void solve(ll in){
	ll n,k;
	cin >> n >> k;
	if(k!=1) cout << n-k << ln;
	else cout << 0 << ln;
}


int main()
{
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll t=1;
    // cin >> t;
    forn(i,t) {
    	solve(i+1);
    }
    return 0;
}

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

const int N = 1e5+3;
int a[N];
multiset<int> mp;
int main(){
	int n; cin >> n;
	for (int i = 0; i < n; i++) {
		scanf("%d",&a[i]);
		mp.insert(a[i]);
	}
	int mx = 0;
	for (int i = 0; i < N; i++){
		mx = max(mx, (int)mp.count(i) + (int)mp.count(i-1) + (int)mp.count(i+1));
	}
	cout << mx << endl;

}

Measured memory_bytes: 5376
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>

typedef long long int ll;

ll powLL(ll a, ll b){
    return (ll)pow((double)a, (double)b);
}

int main(void){
    char s[101];
    scanf("%s", s);
    ll k;
    scanf("%lld", &k);

    //1~9のそれぞれxの、x^y>=kとなるyを見つける
    ll tmp;
    ll y;
    ll arr[9];
    arr[0] = 1;
    for(ll num = 2; num <= 9; num++){
        tmp = 1;
        y = 0;
        while(tmp <= k){
            y++;
            tmp = powLL(num, y);
        }
        arr[num-1] = tmp;
    }
    /*
    for(int i = 0; i < 9; i++){
        printf("%lld ", arr[i]);
    }printf("\n");
    */
   //ここまではうまくいく
   ll cnt = 0;
   ll target;
   ll idx = 0;
   ll slength = strlen(s);
   while(cnt < k && idx < slength){
       //printf("-----");printf("cnt:%lld ", cnt);
       target = s[idx] - '0';
       cnt += arr[target-1];//printf("cnt:%lld target:%lld\n", cnt, target);
       idx++;
   }
    printf("%lld\n", target);
    return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
#define LL long long
#define PB push_back
#define MP make_pair

#define MOD (LL)(1e9+7)

int main(){
	int N, M;
	vector<pair<int, int>> v;
	cin >> N >> M;
	for(int i=0; i<M; i++){
		int a, b;
		cin >> a >> b;
		a--; b--;
		v.PB(MP(a, b-1));
	}
	sort(v.begin(), v.end());
	int ng = INT_MAX;
	int ans = 0;
	for(int i=0; i<M; i++){
		if(ng < v[i].first){
			ans++;
			ng = v[i].second;
		}
		else{
			ng = min(ng, v[i].second);
		}
	}
	if(ng != INT_MAX) ans++;
	cout << ans << endl;
}

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

int main() {
    // 制約見て！！！デカかったらlong longにすること！
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i], a[i]--;
    int ans = 0;
    rep(i, n) {
        if(i == a[a[i]]) {
            ans++;
        }
    }
    cout << ans/2 << endl;
}

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

int main()
{
	int nNum=0;
	cin>>nNum;
	int nIn[3]={0};
	while(nNum--)
	{
		cin>>nIn[0]>>nIn[1]>>nIn[2];
		int nMax=max(max(nIn[0],nIn[1]),nIn[2]);
		if(nMax==nIn[2])
		{
			swap(nIn[2],nIn[0]);
		}
		else if (nMax==nIn[1])
		{
			swap(nIn[1],nIn[0]);
		}
		if(nIn[0]*nIn[0]==nIn[1]*nIn[1]+nIn[2]*nIn[2])
		{
			cout<<"YES"<<endl;
		}
		else
		{
			cout<<"NO"<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3080
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp4
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());

            int b = (int)Math.Floor(a/1.08);
            double d = a / 1.08;
            if (a == (int)Math.Floor(b * 1.08))
            {
                Console.WriteLine(b);
            }
            else if(a == (int)Math.Floor((b-1) * 1.08))
            {
                Console.WriteLine((b-1));
            }
            else if (a == (int)Math.Floor((b + 1) * 1.08))
            {
                Console.WriteLine(b+1);
            }
            else
            {
                Console.WriteLine(":(");
            }
        }
    }
}


Measured memory_bytes: 13140
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;

#define ll long long
#define ull unsigned long long
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define vt vector
#define vll vt<ll>
#define pll pair<ll,ll>
#define vpll vt<pll>
#define vvll vt<vll>
#define all(v) v.begin(),v.end()
#define FOR(i,n) for(ll i=0;i<n;i++)
#define ffo(i,a,b) for(ll i=a;i<=b;i++)
#define rfo(i,a,b) for(ll i=a;i>=b;i--)
#define space cout<<"\n\n";
#define endl "\n"
#define pqmx priority_queue<ll>
#define pqmn priority_queue<ll,vll,greater<ll>>
#define fps(x,y) fixed<<setprecision(y)<<x
#define merg(a,b,c) set_union(a.begin(),a.end(),b.begin(),b.end(),inserter(c,c.begin()))
#define set_ar(arr,v) memset(arr,v,sizeof(arr))
#define go_t int testcases; cin>>testcases; ffo(caseno,1,testcases)

#define ctime auto start = high_resolution_clock::now()
#define etime auto stop = high_resolution_clock::now()
#define ptime auto z1z = duration_cast<microseconds>(stop-start); cout<<"Time elapsed : "<<z1z.count()<<" microseconds\n"

#define dbg1(x)             cout <<#x<<": "<<x<<'\n';
#define dbg2(x, y)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<'\n';
#define dbg3(x, y, z)       cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<'\n';
#define dbg4(a, b, c, d)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<'\n';
#define dbg5(a, b, c, d, e) cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<'\n';

const ll mod = 1e9 + 7;
const ll N = 6e4 + 6;
const ll maxN = 1e5 + 5;
const ll MAX_SIZE = 2e6 + 6;
const ll INF = 0x3f3f3f3f3f3f3f3fll;
const double PI = 3.14159265359;

int dx[4] = { -1, 0, 1, 0};
int dy[4] = {0, 1, 0, -1};
// up, right, down, left

ll powerM(ll x, ll y, ll M = mod) { // default argument
	ll v = 1; x = x % M; while (y > 0) {if (y & 1)v = (v * x) % M; y = y >> 1; x = (x * x) % M;} return v;
}

ll power(ll x, ll y) {
	ll v = 1; while (y > 0) {if (y & 1)v = v * x; y = y >> 1; x = x * x;} return v;
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("in4.txt", "r", stdin);
	freopen("out1.txt", "w", stdout);
#endif
	FIO
	ll n, m, k, c, a, b, i, j;
	ll x, t;
	string s;
	cin >> s;
	ll sum = 0;
	for (auto& ch : s) {
		sum += (ch - '0');
	}
	if (sum % 9 == 0)
		cout << "Yes";
	else
		cout << "No";
	return 0;
}


Measured memory_bytes: 3736
### main

first = true

loop do
  pn, sn = gets.split.map(&:to_i)
  break if pn == 0

  tbl = (pn + 1).times.map{[]}
  vars = []

  hnvs = [0] * (pn + 1)
  vnvs = [0] * (sn + 1)

  for y in (0..pn)
    vals = gets.strip.split
    for x in (0..sn)
      if vals[x] == '?'
        tbl[y][x] = nil
        vars << [x, y]
        hnvs[y] += 1
        vnvs[x] += 1
      else
        tbl[y][x] = vals[x].to_i
      end
    end
  end
  #p tbl
  #p vars
  #p hnvs
  #p vnvs

  gets

  nv = vars.length
  changed = true

  while nv > 0 && changed
    changed = false

    for var in vars
      x, y = var

      if hnvs[y] == 1 && tbl[y][x].nil?
        sum = 0
        for x0 in (0...sn)
          if x0 != x
            sum += tbl[y][x0]
          end
        end

        if x == sn
          tbl[y][x] = sum
        else
          tbl[y][x] = tbl[y][sn] - sum
        end

        nv -= 1
        hnvs[y] -= 1
        vnvs[x] -= 1
        changed = true
      end

      if vnvs[x] == 1 && tbl[y][x].nil?
        sum = 0
        for y0 in (0...pn)
          if y0 != y
            sum += tbl[y0][x]
          end
        end

        if y == pn
          tbl[y][x] = sum
        else
          tbl[y][x] = tbl[pn][x] - sum
        end

        nv -= 1
        hnvs[y] -= 1
        vnvs[x] -= 1
        changed = true
      end
    end
  end

  puts "" if ! first
  first = false

  if nv > 0
    puts 'NO'
  else
    for var in vars
      x, y = var
      puts tbl[y][x]
    end
  end
end

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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

const int mod=1000000007;

int dp[4010][4010];
int N;
int A[222222],B[222222];

inline void add(int &a,int b){a+=b;if(a>=mod)a-=mod;}

int mpow(int n,int m){
    int ret=1;
    while(m){
        if(m&1)ret=ret*n%mod;
        n=n*n%mod;
        m>>=1;
    }
    return ret;
}
int fact[8888],inv[8888];

signed main(){
    cin>>N;
    rep(i,N)cin>>A[i]>>B[i];

    rep(i,N)dp[2000-A[i]][2000-B[i]]++;
    for(int i=0;i<=4000;i++){
        for(int j=0;j<=4000;j++){
            add(dp[i+1][j],dp[i][j]);
            add(dp[i][j+1],dp[i][j]);
        }
    }
    fact[0]=1;
    for(int i=1;i<=8000;i++)fact[i]=fact[i-1]*i%mod;
    inv[8000]=mpow(fact[8000],mod-2);
    for(int i=7999;i>=0;i--)inv[i]=inv[i+1]*(i+1)%mod;

    int ans=0;
    rep(i,N)add(ans,dp[2000+A[i]][2000+B[i]]);
    rep(i,N)ans=(ans-fact[(A[i]+B[i])*2]*inv[A[i]*2]%mod*inv[B[i]*2]%mod+mod)%mod;
    cout<<ans*inv[2]%mod<<endl;
    return 0;
}


Measured memory_bytes: 128896
n, m = map(int, input().split())
h = list(map(int, input().split()))

li = [[] for i in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    li[a-1].append(b-1)
    li[b-1].append(a-1)

skip = [0 for i in range(n)]

# print(li)
ans = []
for i in range(n):
    flg = 0
    hi = h[i]
    dd = li[i]
    if len(dd) == 0:
        ans.append(i)
        continue
    if skip[i] == -1:
        continue
    for d in dd:
        if hi <= h[d]:
            flg = 1
            break
        else:
            skip[d] = -1
    if flg == 0:
        ans.append(i)
print(len(ans))
# print(ans)


Measured memory_bytes: 33396
import numpy as np
def main():
    N,W=map(int,input().split())
    dp=np.zeros((N+1,W+1),dtype=int)
    for i in range(1,N+1):
        w,v=map(int,input().split())
        dp[i][w:]=np.maximum(dp[i-1][w:],dp[i-1][:-w]+v)
        dp[i][:w]=dp[i-1][:w]
    print(dp[N][W])
main()

Measured memory_bytes: 92304
import sys
from io import StringIO
import unittest

def resolve():
    n = int(input())
    x = list(map(int, input().split()))
    p1 = int(sum(x)/n)
    p2 = p1 + 1

    ans1 = [(x_-p1)**2 for x_ in x]
    ans2 = [(x_-p2)**2 for x_ in x]

    print(min(sum(ans1), sum(ans2)))
    


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """2
1 4"""
        output = """5"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """7
14 14 2 13 56 2 37"""
        output = """2354"""
        self.assertIO(input, output)


if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 5872
import collections
N = int(input())
v = list(map(int,input().split()))
v1,v2 = v[::2],v[1::2]
A1 = collections.Counter(v1)
A2 = collections.Counter(v2)
B = list(A1.values())
C = list(A2.values())
B.sort(reverse=True)
C.sort(reverse=True)

if A1.most_common()[0][0] == A2.most_common()[0][0]:
    if len(A1) == 1:
        ans = N//2
    else:
        if B[1] > C[1]: ans = N//2 - B[0] + N//2 - B[1]
        else: ans = N//2 - B[0] + N//2 - C[1]

else:
    ans = N//2 - B[0] + N//2 - C[0]
print(ans)

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

int main()
{
  int w, p;
  while(1)
  {
    cin >> w;
    if(w < 0)
      break;
    if(w > 30)
      p = 160 * (w - 30) + 1400 + 1250 + 1150;
    else if(w > 20)
      p = 140 * (w - 20) + 1250 + 1150;
    else if(w > 10)
      p = 125 * (w - 10) + 1150;
    else
      p = 1150;
    cout << 4280 - p << endl;
  }
}

Measured memory_bytes: 1160
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
static const int MAX=10000;
static const int INF=1<<20;
static const int WHITE=0;
static const int GRAY=1;
static const int BLACK=2;

int n;
vector<pair<int,int> > adj[MAX];

void dijkstra(){
	int color[n];
	int d[n];
	for(int i=0;i<n;i++){
		color[i]=WHITE;
		d[i]=INF;
	}

	d[0]=0;
	priority_queue<pair<int,int> > pq;
	pq.push(make_pair(0,0));
	
	while(!pq.empty()){
		pair<int,int> f=pq.top();pq.pop();
		int u=f.second;
		color[u]=BLACK;
		
		int size=adj[u].size();
		for(int j=0;j<size;j++){
			int v=adj[u][j].first;
			if(color[v]==BLACK) continue;
			int w=adj[u][j].second;
			if(d[v]>d[u]+w){
				d[v]=d[u]+w;
				pq.push(make_pair(d[v]*-1,v));
			}
		}
	}

	for(int i=0;i<n;i++){
		cout << i << " ";
		cout << (d[i]==INF?-1:d[i]) << endl;
	}
}

int main(){
	cin >> n;
	for(int i=0;i<n;i++){
		int u,k;
		cin >> u >> k;
		for(int j=0;j<k;j++){
			int v,c;
			cin >> v >> c;
			pair<int,int> p;
			p=make_pair(v,c);
			adj[u].push_back(p);
		}
	}
	dijkstra();
    return 0;
}



Measured memory_bytes: 8068
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(input()) #整数読み込み
def ifn(): return float(input()) #浮動小数点読み込み
def isn(): return input().split() #文字列読み込み
def imn(): return map(int, input().split()) #整数map取得
def fmn(): return map(float, input().split()) #浮動小数点map取得
def iln(): return list(map(int, input().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, input().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD

MAX_N = 110000

N = iin()

dp = [10**10 for _ in range(MAX_N)]
dp[0] = 0

for i in range(0, N):
    pow6 = 1
    while i + pow6 <= N:
        dp[i+pow6] = min(dp[i+pow6], dp[i]+1)
        pow6 *= 6
    pow9 = 1
    while i + pow9 <= N:
        dp[i+pow9] = min(dp[i+pow9], dp[i]+1)
        pow9 *= 9
print(dp[N])


Measured memory_bytes: 73964
D,G = map(int,input().split())
l = list(list(map(int, input().split())) for _ in range(D))

#得点の大きい順に並び替えておく
l = l[::-1]

ans = float("inf")
for i in range(2**D):
    total = 0
    cnt = 0
    for j in range(D):
        if (i>>j)&1:
            total += 100*(D-j)*l[j][0] + l[j][1]
            cnt += l[j][0]
    if total >= G:
        ans = min(ans,cnt)
        continue
    for j in range(D):
        if (i>>j)&1 == False:
            for k in range(l[j][0]):
                total += 100*(D-j)
                cnt+=1
                if total >= G:
                    ans = min(ans,cnt)
                    break
            else:
                continue
            break

print(ans)

Measured memory_bytes: 42992
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int N1 = sc.nextInt();
   int N2 = sc.nextInt();
   int N3 = sc.nextInt();
   
   if(N1+N2+N3 >=22)System.out.println("bust");
   else System.out.println("win");
 }
}

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

int main( )
{
    string a, b;
    cin >> a >> b;
    int la = (int) a.size();
    int lb = (int) b.size();
    if (la > lb) {
        cout << "GREATER\n";
    }
    else if (la < lb) {
        cout << "LESS\n";
    }
    else {
        for (int i = 0; i < la; i++) {
            if (a[i] > b[i]) {
                cout << "GREATER\n";
                return 0;
            }
            else if (a[i] < b[i]) {
                cout << "LESS\n";
                return 0;
            }
        }
        cout << "EQUAL\n";
    }
    return 0;
}



Measured memory_bytes: 256
s = input()
n = len(s)
one = s + s
two = s[:(n-1)//2] 
theree = s[(n+3)//2 -1:] 

if s == s[::-1] and two == two[::-1] and theree == theree[::-1]:
    print("Yes")
else:
    print("No")



Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define int                     long long   
#define double                  long double
#define endl                    "\n"
#define pb                      push_back
#define PI                      3.1415926535897932384626433832795l
#define F                       first
#define S                       second
#define mp                      make_pair
#define f(i,n)                  for(int i=0;i<n;i++)
#define fastio                  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v)                  (v).begin(),(v).end()
#define rall(v)                 (v).rbegin(),(v).rend()
#define gcd(a,b)                __gcd((a),(b))
#define fill(a,value)           memset(a,value,sizeof(a));
#define minn(v)                 *min_element(v.begin(), v.end());
#define maxx(v)                 *max_element(v.begin(), v.end());
#define print(x)                cout<<(x)<<endl;
#define sum(v)+x                accumulate(v.begin(), v.end(),x);
#define debug(x)                cout<<#x<<'='<<(x)<<endl;
typedef pair<int,int>           pii;
typedef vector<int>             vi;

signed main() 
{
    fastio;
    cout << fixed << setprecision(12);
    int x;
    cin>>x;
    set<int> s;
    for(int i=1;i<=100;i++)
    {
        
        for(int j=2;j<30;j++)
        {
            int cur=1;
            for(int k=0;k<j;k++)
            {
                cur*=i;
            }
            if(cur<=x)s.insert(cur);
            else break;
        }
    }
    
    print(*s.rbegin())
    return 0;
}


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

//#if __cplusplus >= 201103L
//#include <array>
//#include <tuple>
//#include <initializer_list>
//#include <forward_list>
//
//#define cauto const auto&
//#else

//#endif

using namespace std;


typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif
#define LDcout(x,n) fixed<<setprecision(n)<<x

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
    int n;
    while(cin>>n,n){
        n=1000-n;
        vint v={500,100,50,10,5,1};
        int ans=0;
        rep(i,v.size()){
            while(n>=v[i]){
                ans++;
                n-=v[i];
            }
        }
        cout<<ans<<endl;
    }
}


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

Measured memory_bytes: 1192
#include <iostream>
#include <algorithm>
#include <array>
#include <utility>
#include <vector>
#include <tuple>
#include <queue>

constexpr int MAX_N = 200'000;
std::array<std::array<int, 2>, MAX_N + 1> L;
std::array<std::array<int, 2>, MAX_N + 1> R;

void solve(void){
    int n; std::cin >> n;
    long long int sum = 0;
    int len_l = 0, len_r = 0;
    for(int i = 0; i < n; ++i){
        int a, l, r; std::cin >> a >> l >> r;
        if(l > r){ L[len_l++] = {a, l - r}; sum += r; }
        else if(l < r){ R[len_r++] = {n - a, r - l}; sum += l; }
        else sum += l;
    }
    std::sort(L.begin(), L.begin() + len_l);
    std::sort(R.begin(), R.begin() + len_r);
    std::priority_queue<int, std::vector<int>, std::greater<int>> PQ;

    long long int addr = 0;
    for(int x = 0, i = 0; x <= len_l; ++x){
        if(x == len_l) for(; i < len_l; ++i) addr += L[i][1];
        else while(i < len_l and L[i][0] == x){ PQ.push(L[i][1]); addr += L[i][1]; ++i;  }
        while(PQ.size() > x){ addr -= PQ.top(); PQ.pop(); }
    }
    while(not PQ.empty()) PQ.pop();

    for(int x = 0, i = 0; x <= len_r; ++x){
        if(x == len_r) for(; i < len_r; ++i) addr += R[i][1];
        else while(i < len_r and R[i][0] == x){ PQ.push(R[i][1]); addr += R[i][1]; ++i; }
        while(PQ.size() > x ){ addr -= PQ.top(); PQ.pop(); }
    }
    std::cout << (addr + sum) << '\n';
}


int main(void){
    std::cin.tie(nullptr); std::cin.sync_with_stdio(false);
    int Q; std::cin >> Q;
    while(Q--) solve();
    return 0;
}

Measured memory_bytes: 5392
# coding: utf-8
import bisect
n = int(input().rstrip())
dic = {}
for i in range(n):
    line = input().rstrip().split()
    if line[0] == "insert":
        dic[line[1]] = True
    else:
        if line[1] in dic:
            print("yes")
        else:
            print("no")


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

int n, k;
vector<ll> h;

int main(int argc, char **argv)
{
	cin >> n >> k;
	h.resize(n+1);
	for (int i = 0; i < n; ++i) cin >> h[i];

	k = min(k, n);

	sort(h.begin(), h.end(), greater<ll>());
	for (int i = 0; i < k; ++i)
		h[i] = 0;

	ll sum = accumulate(h.begin(), h.end(), 0ll);
	std::cout << sum << std::endl;
}

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

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define DEBUG(x) cout << #x"=" << x << endl

#define INFTY INT_MAX/3

#define MAX_N 

int main(void){

	int a, b, c;

	cin >> a >> b >> c;

	if(a == 5 && b == 5 && c == 7) cout << "YES" << endl;
	else if(a == 5 && b == 7 && c == 5) cout << "YES" << endl;
	else if(a == 7 && b == 5 && c == 5) cout << "YES" << endl;
	else cout << "NO" << endl;

	return 0;

}

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

int main(){
    i64 n;
    cin>>n;
    vector<i64> a(n);
    for(int i=1;i<n;i++){
        int b;
        cin>>b;
        a[b-1]++;
    } 
    for(int i=0;i<n;i++) cout<<a[i]<<endl;
    return 0;
}


Measured memory_bytes: 4844
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
#include <sstream>
#include<queue>
#include<set>
#include<iomanip>
#define rep(i,n) for(ll i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,ll>P;

int main()
{
    int n;
    cin>>n;
    vector<int> v(n,0);
    rep(i,n)
    {
        cin>>v[i];
    }
    sort(v.begin(),v.end());
    double rev=(v[0]+v[1])/2.0;
    for(int i=2;i<n;i++)
    {
        rev=(rev+(double)v[i])/2.0;
    }
    cout<<rev;
       
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline bool chmin(A &a,const B &b){if(a>b){a=b;return true;}else{return false;}}
template<typename A,typename B>inline bool chmax(A &a,const B &b){if(a<b){a=b;return true;}else{return false;}}

int main()
{
    ll N,K;
    cin >> N >> K;
    ll ans = 1LL;
    REP(i,N){
        if(0 == i){
            ans *= K;
        }else{
            ans *= K-1;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3604
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
const ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;
V ans;

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

  cin >> n >> m >> s;
  ll now = Size(s) - 1;
  while (1) {
    if (now == 0) break;
    ll want = now - m;
    want = max(want, 0LL);
    if (s[want] == '0') {
      ans.p_b(abs(now - want));
      now = want;
    } else {
      int ok = 0;
      ll cost = abs(now - want);
      rrep(i, want + 1, now) {
        cost--;
        if (s[i] == '0') {
          ok = 1;
          now = i;
          ans.p_b(cost);
          break;
        }
      }
      if (!ok) {
        Cout(-1);
        return 0;
      }
    }
    // Cout(now);
  }
  reverse(all(ans));
  rep(i, Size(ans)) {
    if (i != Size(ans) - 1)
      cout << ans[i] << " ";
    else
      Cout(ans[i]);
  }
  return 0;
}

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    while(cin>>n)
    {
        vector<double> arr;
        for(int i=0;i<n;i++)
        {
            double x;
            cin>>x;
            arr.push_back(x);
        }
        sort(arr.begin(),arr.end());
        double sum=arr[0];
        for(int i=1;i<n;i++)
        {
            sum += arr[i];
            sum =sum/2.0;
        }
        cout<<sum<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define F first
#define S second
using namespace std;
int main()
{
    ll n,x,t; cin>>n>>x>>t;
    ll s=t;
    for(ll i=1;i<=n;i++)
    {
        if(i>x && ((i-1)%x==0)) s+=t;
    }
    cout<<s;
}



Measured memory_bytes: 3540
// -----------------------------------------------
// Framework <https://github.com/vain0x/procon>
//
// See the bottom of file for solution.
// -----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let (_, K) = read!(usize, usize);
    let A = read![[usize]];

    let mut dp = vec![false; K + 1];

    for k in 0..K + 1 {
        let mut win = false;

        for &a in &A {
            win = win || (k >= a && !dp[k - a]);
        }

        dp[k] = win;
    }

    println!("{}", if dp[K] { "First" } else { "Second" })
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define INF 1000000007
#define mod 1005
#define ll long long int
const double mx = 2e6 + 5 ;
void solve()
{
	ll n;
	cin>>n;
	ll maxPos = 1;
	for(ll i=2; i*i<=n; i++)
	{
		ll num = i*i;
		if(num<=n)
		{
			while(num*i<=n)
				num*=i;
			maxPos = max(num, maxPos);
		}
	}
	cout<<maxPos<<"\n";
}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int t = 1;
//	cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<string> st(3);
  vector<int> left(3);
  cin >> st[0] >> st[1] >> st[2];
  left[0] = st[0].size();
  left[1] = st[1].size(); 
  left[2] = st[2].size();
  int turn = 0;
  int subturn = 0;
  while (0 == 0) {
    left[turn] -= 1;
    if (left[turn] == -1) break;
    if (st[turn][0] == 'a') subturn = 0;
    else if (st[turn][0] == 'b') subturn = 1;
    else subturn = 2;

    st[turn] =st[turn].substr(1,st[turn].size() - 1);
    turn = subturn;
  }
  string ans = "";
  if (left[0] == -1) ans = "A";
  else if (left[1] == -1) ans = "B";
  else ans = "C";
  cout << ans << endl;
  return 0;
}

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

using namespace std;
using LL = long long;

int main(){
    LL r,D,x;
    cin >> r >> D >> x;
    for(int a = 1;a <= 10;a++){
        x = (x*r)-D;
        cout<<x<<endl;
    }
    return 0;
}


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


using namespace std;

using ll   = long long;
using ii   = pair   < int , int >;
using i3   = pair   < int , ii  >;
using li   = pair   < ll  , int >;
using lii  = pair   < ll  , ii  >;
using pll  = pair   < ll  , ll  >;
using vi   = vector < int       >;
using vl   = vector < ll        >;
using vii  = vector < ii        >;
using vli  = vector < li        >;
using vpll = vector < pll       >;
using vi3  = vector < i3        >;
using vlii = vector < lii       >;


const int N = 2e5 + 5;
const ll INF = 1e17 + 7;
const double eps = 1e-9 , PI = acos(-1);



int n , m;
int a[N];

void solve(int testCase){

    scanf("%d" , &n);
    for(int i = 1 ; i <= n ; i ++){
            scanf("%d" , &a[i]);
    }

    int brk = 0;
    int curr = 1;

    for(int i = 1 ; i <= n ; i ++){
            if(a[i] != curr){
                    brk ++;
            }
            else {
                    curr ++;
            }
    }

    if(brk >= n){
            printf("-1\n");
    }
    else {
            printf("%d\n" , brk);
    }

}

main(){

    int t = 1;
    // scanf("%d" , &t);

    for(int testCase = 1 ; testCase <= t ; testCase ++){
            solve(testCase);
    }

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.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>;

int main() {
  int a,b,x;
  cin >> a >> b >> x;
  bool ok = a<=x && x<=a+b;
  cout << (ok?"YES":"NO") << endl;
}


Measured memory_bytes: 256