akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
// #include <sys/types.h> 
// #include <unistd.h> 
using namespace std;
#define int long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
const int MOD = 1e9+7;
int mpow(int a,int b,int p=MOD){a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
const int N=1e7+5;

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

      int n;
      cin>>n;
      string s;
      cin>>s;
      if(n&1) cout<<"No\n";
      else{
        string a="",b="";
        // cin>>a>>b;
        for(int i=0;i<n/2;i++)
        {
          a+=s[i];
        }
        for(int i=n/2;i<n;i++)
        {
          b+=s[i];
        }
        if(a==b) cout<<"Yes\n";
        else cout<<"No\n";
      }
}
// I never lose. I either win or I learn

Measured memory_bytes: 256
#include <stdio.h>

#define PMX ( 1 << 15 )

static
int primes[ PMX ] = { 0 };
static
int primen = 0;

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  int i, j;

  for ( j = 2; j < PMX; ++j )
  {
    if ( primes[ j ] )  continue;

    primes[ primen++ ] = j;
    for ( i = j; i < PMX; i += j )
    {
      primes[ i ] = -1;
    }
  }

  for ( ; ; )
  {
    int n;
    int res = 0;

    scanf ( "%d", &n );
    if ( n == 0 ) break ;

    for ( j = 0; j < primen && primes[ j ] < n; ++j )
    for ( i = j; i < primen; ++i )
    {
      int sum = primes[ j ] + primes[ i ];

      if ( sum >= n )
      {
        res += !!( sum == n );
        break;
      }
    }

    printf ( "%d\n", res );
  }

  return ( 0 );
}

Measured memory_bytes: 532
#include <stdio.h>
int main(void)
{
	int a;
	float a1, a2, b1, b2, x, fa, fb;
	scanf("%f %f", &fa, &fb);
	
	a1 = fa * 100 / 8;
	a2 = (fa + 1) * 100 / 8;
	b1 = fb * 10;
	b2 = (fb + 1) * 10;
	
	if((a1 >= b1 && a1 >= b2) || (b1 >= a1 && b1 >= a2)){
		x = -1;
	}
	else{
		if(a1 >= b1){
			x = a1;
		}
		else{
			x = b1;
		}
	}
	
	a = x;
	
	if(x - a > 0){
		a++;
	}
	
	printf("%d", a);
	
	return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
 
////////////// Prewritten code follows. Look down for solution. ////////////////

#define fs first
#define sc second
#define pb push_back
#define len(x) ((int)(x).size())
#define fastio ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);

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

const ll LINF = 1e18;
const int INF = 1e9;
const int MOD = 1e9+7;

/// command for char arrays with spaces -> scanf(" %[^\n]", text);
 
////////////////////////// Solution starts below. //////////////////////////////

int main(){
	fastio;
	int n;
	cin >> n;
	set<string> st;
	while(n--){
		string s;
		cin >> s;
		st.insert(s);
	}	
	cout << len(st) << endl;
	return 0;
}

Measured memory_bytes: 19248
#include <bits/stdc++.h>
#define inf 1000000007
#define mod 1000000007
//#pragma GCC optimize(2)
//#define int long long
using namespace std;
template <typename T> void read(T &x){
	x=0;char ch=getchar();int fh=1;
	while (ch<'0'||ch>'9'){if (ch=='-')fh=-1;ch=getchar();}
	while (ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	x*=fh;
}
template <typename T> void write(T x) {
	if (x<0) x=-x,putchar('-');
	if (x>9) write(x/10);
	putchar(x%10+'0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
signed main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin>>n;
	cout<<(n+1)/2<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;
using ll = int64_t;
using P = pair<ll,ll>;
ll INF = 1000000007;
// ll INF = 9223372036854775807;
// ll INF = 998244353;

int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    ll n;
    cin >> n;
    if(n%1000!=0){
        cout << 1000-(n%1000) << endl;
    }else{
        cout << 0 << endl;
    }
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
ll mod = 1000000007;
ll INF = 1000000099;

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

    vector<pair<string,ll>> v(n);
    map<pair<string,ll>,ll> mp;

    for(ll i=0;i < n;i++)
    {
        cin>>v.at(i).fi>>v.at(i).se;
        mp[{v.at(i).fi,v.at(i).se}]=i+1;
    }

    sort(v.begin(),v.end());
   vector<pair<ll,ll>> u;
   bool flag=false;

    for(int i=0;i < n;i++)
    {
        
        
        ll r=mp[{v.at(i).fi,v.at(i).se}],R;
        if(i+1<n) ll R=mp[{v.at(i+1).fi,v.at(i+1).se}];

        if(i+1<n && v.at(i).fi==v.at(i+1).fi){
            u.pb({v.at(i).se,r});
            flag=true;
        }else if(flag){
            u.pb({v.at(i).se,r});

            sort(u.begin(),u.end());
            reverse(u.begin(),u.end());

            for(int j=0;j < (ll)u.size();j++)
            {
                cout << u.at(j).se << endl;
            }
            u.clear();
            flag=false;
        }else{
            cout << mp[{v.at(i).fi,v.at(i).se}]<< endl;
        }
    }
}

Measured memory_bytes: 256
//2018.11.17

#include <iostream>
using namespace std;

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

    int ascii_start = 97;
    int ascii;
    bool ans = true;
    char ans_c = '0';
    int i=0;
    while(i<26){
        ans = true;
        ascii = ascii_start + i;

        for(int j=0; j<s.size();j++){
            if(s[j]==(char)ascii){ ans = false; }
        }

        if(ans){
            ans_c = ascii;
            break;
        }
        i++;
    }

    if(ans) cout << ans_c << endl;
    else cout << "None" << endl;

}


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

int main() {
    string s;
    cin >> s;
    if(s[0] != 'A'){
        cout << "WA" << endl;
        return 0;
    }

    if(count(s.begin()+2, s.end()-1, 'C') != 1){
        cout << "WA" << endl;
        return 0;
    }

    int len = s.size();
    for(int i = 1; i < len; i++){
        if(s[i] == 'C') continue;
        if(s[i] >= 'a' && s[i] <= 'z'){
            continue;
        }else{
            cout << "WA" << endl;
            return 0;
        }
    }
    cout << "AC" << endl;
    return 0;
}

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

from itertools import accumulate

N = int(input())
T = list(map(int, input().split()))
V = list(map(int, input().split()))

clock = [0] + list(accumulate(T))
t_sum = sum(T)
mn_f = 0
ans = 0
for t in range(2 * t_sum):
    t /= 2
    mn = min(t, t_sum - t)
    for i in range(1, len(clock)):
        v = V[i-1]
        if t < clock[i-1]:
            v_max = v + clock[i-1] - t
        elif clock[i-1] <= t <= clock[i]:
            v_max = v
        else:
            v_max = v + t - clock[i]
        mn = min(mn, v_max)
    ans += (mn_f + mn) * 0.25
    mn_f = mn

ans += mn_f * 0.25

print(ans)


Measured memory_bytes: 43376
#include <iostream>
#include <algorithm>
#include <climits>
#include <vector>
using namespace std;

void test1(){

  int N,K;
  cin >> N;
  cin >> K;
  int result= 0;
  result=(N-1)/(K-1);
  if ((N-1)%(K-1) >0) {
    result++;
  }
  cout << result << "\n";
}
int main(int argc, char *argv[])
{
  test1();
  // int N,K;
  // cin >> N;
  // cin >> K;
  // int A[N];
  // int whereisOne;
  // int right,left;
  // int result;

  // for (int i = 0; i < N; i++) {
  //   cin >> A[i];
  //   if (A[i] == 1) {
  //     whereisOne = i;
  //   }
  // }


  
  

  // right = N-whereisOne-1;
  // left = whereisOne;

  // result = (right/(K-1));
  // if ((right%(K-1)) > 0) {
  //   result++;
  // }
  // result = result+(left/(K-1));

  // if ((left%(K-1)) > 0) {
  //   result++;
  // }

  // if (((left%(K-1))+(right%(K-1)))<(K-1) && (left> (K-1) && right>(K-1))) {
  //   result--;
  // }
  // cout << result << "\n";

  
  return 0;
}



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

int main()
{
	// #ifndef ONLINE_JUDGE
	// 	if (fopen("input.txt", "r"))
	// 	{
	// 		freopen("input.txt", "r", stdin);
	// 		freopen("output.txt", "w", stdout);
	// 	}
	// #endif
	int a, b;
	cin >> a >> b;
	cout << a * b;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll N;
    cin >> N;
    vector<string> S(N);
    rep(i,N){
        cin >> S[i];
    }
    ll cnt = 0;
    rep(i,N){
        rep(j,N){
            rep(k,N){
                if(S[j][k] != S[k][j]){
                    goto gt;
                }
            }
        }
        cnt++;
        gt:
        rep(j,N){
            rotate(S[j].begin(), S[j].begin()+1, S[j].end());
        }
    }
    cout << cnt*N << endl;
}

Measured memory_bytes: 3768
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef vector<pair<ll,ll> > vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
const int MOD = 1000000007;
const int MAX = 510000;

vvll dp(2,vll(1000001));//dp[0]:その桁まで　dp[1]:桁＋１
int main(){
  string s;cin>>s;
  dp[0][0]=0,dp[1][0]=MOD;
  rep(i,0,s.size()){
    int x=s[s.size()-1-i]-'0';
    dp[0][i+1]=min(dp[0][i]+x,dp[1][i]+x);
    dp[1][i+1]=min(dp[0][i]+11-x,dp[1][i]+9-x);
  }
  cout<<min(dp[0][s.size()],dp[1][s.size()])<<endl;
}



Measured memory_bytes: 23680
#include <iostream>
#include <iomanip>
#include <cstring>
#include <algorithm> 
#include <math.h>
#include <queue>
#include <functional>
#include <map>
#include <vector>
#include <string>
#include <set> 
using namespace std;

typedef long long ll;
typedef pair<ll, int> P;
typedef pair<pair<int, int>, int> PP;

const ll INF = 1e15;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };


const ll MAX = 510000;
const ll MOD =1000000007;

ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < 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;
	}
}

//二項係数計算
ll COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int N, K;
bool visit[100010];
vector<int> v[100010];
ll ans;

void dfs(int par) {
	visit[par] = true;
	int child = v[par].size() - 1;
	if (par != 0 && child == 0) return;
	if (par == 0) {
		ans *= (COM(K - 1, child + 1) * fac[child + 1] % MOD) % MOD;
		ans %= MOD;
	}
	else {
		ans *= (COM(K - 2, child)*fac[child] % MOD) % MOD;
		ans %= MOD;
	}
	for (int i = 0; i < v[par].size(); i++) {
		if (!visit[v[par][i]]) dfs(v[par][i]);
	}
	return;
}

int main(void) {
	cin >> N >> K;
	for (int i = 0; i < N - 1; i++) {
		int a, b; cin >> a >> b;
		a--; b--;
		v[a].push_back(b);
		v[b].push_back(a);
		visit[i] = false;
	}
	COMinit();
	ans = K;
	dfs(0);
	cout << ans << endl;
}


Measured memory_bytes: 20096
#include <bits/stdc++.h>
using namespace std;
#define int long long
//ask the right questions.		

int dp[101][100001];  //declare outside in heap!!!!!!!

int32_t main() 
{
	int N, W;
	cin >> N >>W;
	int weights[N];
	int value[N];

	int x;
	for(int i=0;i<2*N;i++)
	{
		cin >> x;
		if(i%2==0)
		{
			weights[i/2]=x;
		}
		else
		{
			value[(i-1)/2]=x;
		}
	}

	// let dp[i][value] be the minimum capacity when deciding upon i th item that achieves  
	// [value] quantity


	//trivial case
	for(int i=0;i<=100000;i++)
 	{
 		dp[0][i]=INT_MAX;
 	}

 	//base case
 	for(int i=0;i<=N;i++)
 	{
 		dp[i][0]=0;
 	}

 	for(int i=1;i<=N;i++)
 	{
 		for(int j=1;j<=100000;j++)
 		{
 			if(j>=value[i-1])
 				dp[i][j] = min(dp[i-1][j], dp[i-1][j-value[i-1]] + weights[i-1]);
 			else
 				dp[i][j] = dp[i-1][j];
 		}
 	}
 	int ans=0;
 	for(int i=0;i<=100000;i++)
 	{
 		if(dp[N][i]<=W)
 		{
 			ans = max(ans,i);
 		}
 	}
 	cout << ans <<endl;


	return 0;
	
}

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


#define ll unsigned long long
#define ALL(x) x.begin(),x.end()

#define FASTIO ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;
const int MOD = 1e9+7;
const int maxn = static_cast<int>(1e5+3);


ll power(ll x, ll int y){
    int res = 1; // Initialize result

    while (y > 0) {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res * x + MOD)%MOD;

        // n must be even now
        y = y >> 1; // y = y/2
        x = (x * x)%MOD; // Change x to x^2
    }
    return res;
}
int arr[maxn];

int main(){

    int n;cin >> n;
    int x;
    for(int i=0;i<n;i++){
        cin >> x;
        arr[x]++;
    }

    ll ans = 1;
    for(int i = (n%2==0 ? 1 : 0);i < n;i += 2){

        if((i != 0 && arr[i] != 2) || (i == 0 && arr[0] != 1)){
            ans = 0;
            break;
        }
        ans = (ans*arr[i])%MOD;
    }
    cout << ans;
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;

namespace NTL1D
{
    class Program
    {
        static void Main(string[] args)
        {
            var prime = new Prime(100000);
            Console.WriteLine(prime.EulersTotient(int.Parse(Console.ReadLine())));
        }
    }

    public class Prime
    {
        readonly List<int> primes;
        public List<int> List { get { return primes.ToList(); } }

        public Prime(int max)
        {
            primes = new List<int>();

            var sieve = new bool[max + 1];
            for (var i = 2; i <= max; i++)
            {
                if (sieve[i]) continue;
                primes.Add(i);
                for (var j = i * 2; j <= max; j += i) sieve[j] = true;
            }
        }

        public bool Is(int n)
        {
            return n > 1 && primes.TakeWhile(p => p * p <= n).All(p => n % p != 0);
        }

        public IEnumerable<int> Factorize(int n)
        {
            foreach (var p in primes.TakeWhile(p => p * p <= n))
            {
                while (n % p == 0)
                {
                    n /= p;
                    yield return p;
                }
            }
            if (n != 1) yield return n;
        }

        public int EulersTotient(int n)
        {
            return Factorize(n).Distinct().Aggregate(n, (ret, x) => ret / x * (x - 1));
        }
    }
}



Measured memory_bytes: 10304
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.TreeSet;
 
 
 
public class Main {
  public static void main(String[] args) {
    InputReader sc = new InputReader(System.in);
 
    int n = sc.nextInt();
    int[] heights = new int[n];
    for(int i = 0; i < n; i++){
      heights[i] = sc.nextInt();
    }

    int count = 0;
    for(;; count++){
      boolean check = true;
      int startind = 0;
      for(int i = 0; i < n; i++){
        if(check && heights[i] > 0){
          check = false;
          startind = i;
        }
      }
      if(check){
        System.out.println(count);
        break;
      }else{
        check = true;
        for(int i = startind; i < n; i++){
          if(heights[i] == 0){
            break;
          }
          heights[i]--;
        }
      }
    }
 
  }
 
 //ここからテンプレ
  static class InputReader {
      private InputStream stream;
      private byte[] buf = new byte[1024];
      private int curChar;
      private int numChars;
      private SpaceCharFilter filter;
 
      public InputReader(InputStream stream) {
          this.stream = stream;
      }
 
      public int next() {
          if (numChars == -1)
              throw new InputMismatchException();
          if (curChar >= numChars) {
              curChar = 0;
              try {
                  numChars = stream.read(buf);
              } catch (IOException e) {
                  throw new InputMismatchException();
              }
              if (numChars <= 0)
                  return -1;
          }
          return buf[curChar++];
      }
 
      public String nextStr() {
        int c = next();
        while(isSpaceChar(c)){c = next();}
        StringBuffer str = new StringBuffer();
        do{
          str.append((char)c);
          c = next();
        }while(!isSpaceChar(c));
        return str.toString();
      }
 
      public char nextChar() {
        int c = next();
        while(isSpaceChar(c)){c = next();}
        char ret;
        do{
          ret = (char)c;
          c = next();
        }while(!isSpaceChar(c));
        return ret;
      }
 
      public int nextInt() {
          int c = next();
          while (isSpaceChar(c))
              c = next();
          int sgn = 1;
          if (c == '-') {
              sgn = -1;
              c = next();
          }
          int res = 0;
          do {
              if (c < '0' || c > '9')
                  throw new InputMismatchException();
              res *= 10;
              res += c - '0';
              c = next();
          } while (!isSpaceChar(c));
          return res * sgn;
      }
 
      public boolean isSpaceChar(int c) {
          if (filter != null)
              return filter.isSpaceChar(c);
          return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
      }
 
      public interface SpaceCharFilter {
          public boolean isSpaceChar(int ch);
      }
  }
}

Measured memory_bytes: 23124
#include<stdio.h>
int main()
{
    long long int n;
    while(scanf("%d",&n)==1)
    {
        long long int a[200000],i,low,temp;
        for(i=0;i<n;i++)
        {
            scanf("%lld",&a[i]);
            if(i)
            {
                a[i]+=a[i-1];
            }
        }
        for(i=0;i<n-1;i++)
        {
            if(!(i))
            {
                low=(a[n-1]-a[i])-a[i];
                if(low<1)low=low*(-1);
            }
            else
            {
                temp=(a[n-1]-a[i])-a[i];
                if(temp<1)temp=temp*(-1);
                if(temp<low)low=temp;
            }
        }
        printf("%lld\n",low);
    }
    return 0;
}


Measured memory_bytes: 1664
package main

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

var sc *bufio.Scanner

func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, 0), 1000000001*3)
	sc.Split(bufio.ScanWords)
	n := nextInt()
	for i := 1; i < 10; i++ {
		if n % i == 0 && n / i < 10 {
			fmt.Println("Yes")
			return
		}
	}
	fmt.Println("No")
}


Measured memory_bytes: 640
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1000000007;
constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;
const long double PI = acos((long double)(-1));

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

using Real = double;
const Real EPS = 1e-8;

Real scan() {
    int x; scanf("%d", &x);
    return (Real)x;
}

Real dist(Real x1, Real y1, Real z1, Real x2, Real y2, Real z2) {
    x1 -= x2;
    y1 -= y2;
    z1 -= z2;
    return sqrt(x1 * x1 + y1 * y1 + z1 * z1);
}
void solve() {
    int n, kkt; scanf("%d %d", &n, &kkt);
    vector<Real> x(n), y(n), z(n), r(n);
    vector<ll> l(n);
    for (int i = 0; i < n; i++) {
        x[i] = scan(); y[i] = scan(); z[i] = scan(); r[i] = scan();
        scanf("%lld", &l[i]);
    }

    while (kkt--) {
        ll res = 0;
        Real sx = scan(), sy = scan(), sz = scan(), tx = scan(), ty = scan(), tz = scan();
        for (int i = 0; i < n; i++) {
            Real lf = 0;
            Real rg = 1;
            Real d = inf;
            for (int jupi = 0; jupi < 120; jupi++) {
                Real lmid = (lf * 2 + rg) / 3.0;
                Real rmid = (lf + rg * 2) / 3.0;
                Real lx = sx + (tx - sx) * lmid;
                Real rx = sx + (tx - sx) * rmid;
                Real ly = sy + (ty - sy) * lmid;
                Real ry = sy + (ty - sy) * rmid;
                Real lz = sz + (tz - sz) * lmid;
                Real rz = sz + (tz - sz) * rmid;
                Real ld = dist(lx, ly, lz, x[i], y[i], z[i]);
                Real rd = dist(rx, ry, rz, x[i], y[i], z[i]);
                chmin(d, ld);
                chmin(d, rd);
                if (ld < rd) rg = rmid;
                else lf = lmid;
            }
            if (d <= r[i] + EPS) {
                res += l[i];
            }
        }
        printf("%lld\n", res);
    }

}

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

	int kkt = 89;
	while (kkt) {
		solve();
        break;
	}
    return 0;
}


Measured memory_bytes: 3224
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <algorithm>

using namespace std;

#define all(v) 			((v).begin()), ((v).end())
#define sz(v) 			((int)((v).size()))
#define endl			"\n"
#define MOD             1000000007

typedef long long ll;

void File()
{
	//freopen("output.txt", "w", stdout);
	freopen("coffee.in", "r", stdin);
}
void fast()
{
	ios::sync_with_stdio(NULL);
	cout.tie(NULL);
	cin.tie(NULL);
}
const double pi = 2 * acos(0.0);
const int nn = 1e5 + 5;
const int oo = 0x3f3f3f3f;

int main()
{
	fast();
	int d;
	cin >> d;
	if (d == 25)
		cout << "Christmas\n";
	else if (d == 24)
		cout << "Christmas Eve\n";
	else if (d == 23)
		cout << "Christmas Eve Eve\n";
	else
		cout << "Christmas Eve Eve Eve\n";
#if _DEBUG
	system("pause");
#endif
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include<cstring>
#include<map>
#include<set>
#include<cstdlib>
#include<bitset> 
using namespace std;
typedef long long ll;
const ll mod=998244353;
ll njie[200005];
ll qupow(ll a,ll b)
{
	if(b==0) return 1;
	ll c=qupow(a,b/2);
	if(b%2==1) return c*c%mod*a%mod;
	else return c*c%mod;
}
ll cnm(ll n,ll m)
{
	ll ans=njie[n]%mod;
	ll b=njie[n-m]*njie[m]%mod;
	return ans*qupow(b,mod-2)%mod;
}
int main(void)
{
	ll n,m,k;
	scanf("%lld%lld%lld",&n,&m,&k);
	njie[0]=1;
	for(ll i=1;i<=n;i++) njie[i]=njie[i-1]*i%mod;
	ll sum=0;
	for(ll i=0;i<=k;i++)
	{
		sum+=cnm(n-1,n-1-i)*m%mod*qupow(m-1,n-1-i)%mod;
	}
	sum%=mod;
	printf("%lld\n",sum);
}

Measured memory_bytes: 5320
/*Stay true to yourself, yet always be open to learn. Work hard, and never give up on your dreams, 
even when nobody else believes they can come true but you. These are not cliches but real tools you 
need no matter what you do in life to stay focused on your path.
*/
 
 /*Pppppppp    UU      UU     CCCCCCCC    CCCCCCCC     HH     HH     UU      UU
   pp    pp    UU      UU     CC          CC           HH     HH     UU      UU
   pp    pp    UU      UU     CC          CC           HHHHHHHHH     UU      UU
   pppppppp    UU      UU     CC          CC           HHHHHHHHH     UU      UU
   pp          UU      UU     CC          CC           HH     HH     UU      UU
   pp          UUUUUUUUUU     CCCCCCCC    CCCCCCCC     HH     HH     UUUUUUUUUU
   */
 
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
typedef long long ll;
#define loop(i,n)  for(int i=0;i<n;i++)
#define ford(i,a,b) for(int i=b;i>=a;i--)
#define read(a) int a; cin >>a;
#define readarr(a,n) int a[n] ; for(int i=0;i<n;i++) cin >> a[i];
#define readmat(a,n,m) int a[n][m]; for(int i=0;i<n;i++) for(j=0;j<m;j++) cin >> a[i][j];
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define pi pair<int,int>
#define vii vector<vector<int>>
#define sti set<int>
#define vpi vector<pair<int,int>>
#define print(a,n) for(int i=0;i<n;i++) cout<<a[i]<<" "; cout<<endl;
#define printmat(a,n,m) for(int i=0;i<n;i++) {for(j=0;j<m;j++) cout<<a[i][j]<<" "; cout<<endl;}
#define fast ios_base::sync_with_stdio(false);  cin.tie(NULL);
#define endl "\n"
#define mp make_pair
const ll inf = 1e18;
const ll mod = 1e9 + 7;
 
signed main()
{
 
    fast;
    string s;
    cin >> s;
    if(s[2]==s[3] && s[4]==s[5])
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;
    return 0;
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	string S=in<string>(),T=in<string>();
	int A=in(),B=in();
	string U=in<string>();

	if(U==S) A--;
	else B--;
	
	out(A,B);
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for(int i = 0 ; i < n ; i++) a[i] = sc.nextInt();
		int ans = 1001001001;
		for(int i = -100 ; i <= 100 ; i++) {
			int temp = 0;
			for(int j = 0 ; j < n ; j++) {
				temp += (a[j] - i) * (a[j] - i);
			}
			ans = Math.min(ans, temp);
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const ll inf=1e9+7;
const ll INF=1e18;

int main(){
    int n;cin>>n;
    string s;cin>>s;
    //sheep:0,wolf:1
    bool can;
    vin a(n+1);
    rep(i,4){
        bitset<2> tmp(i);
        a[0]=tmp[0];a[1]=tmp[1];
        can=false;
        rep2(j,1,n){
            if(a[j]==0&&a[j-1]==0&&s[j]=='o')a[j+1]=0;
            else if(a[j]==0&&a[j-1]==0&&s[j]=='x')a[j+1]=1;
            else if(a[j]==0&&a[j-1]==1&&s[j]=='o')a[j+1]=1;
            else if(a[j]==0&&a[j-1]==1&&s[j]=='x')a[j+1]=0;
            else if(a[j]==1&&a[j-1]==0&&s[j]=='o')a[j+1]=1;
            else if(a[j]==1&&a[j-1]==0&&s[j]=='x')a[j+1]=0;
            else if(a[j]==1&&a[j-1]==1&&s[j]=='o')a[j+1]=0;
            else if(a[j]==1&&a[j-1]==1&&s[j]=='x')a[j+1]=1;
        }
        if(a[n]==a[0]){
            if(a[0]==0&&a[n-1]==0&&s[0]=='o'&&a[1]==0)can=true;
            else if(a[0]==0&&a[n-1]==0&&s[0]=='x'&&a[1]==1)can=true;
            else if(a[0]==0&&a[n-1]==1&&s[0]=='o'&&a[1]==1)can=true;
            else if(a[0]==0&&a[n-1]==1&&s[0]=='x'&&a[1]==0)can=true;
            else if(a[0]==1&&a[n-1]==0&&s[0]=='o'&&a[1]==1)can=true;
            else if(a[0]==1&&a[n-1]==0&&s[0]=='x'&&a[1]==0)can=true;
            else if(a[0]==1&&a[n-1]==1&&s[0]=='o'&&a[1]==0)can=true;
            else if(a[0]==1&&a[n-1]==1&&s[0]=='x'&&a[1]==1)can=true;
            if(can)break;
        }
    }
    if(can){
        rep(i,n){
            if(a[i])cout<<'W';
            else cout<<'S';
        }
        cout<<endl;
    }
    else cout<<-1<<endl;
}

Measured memory_bytes: 3784
n, m = map(int, input().split())
a = [0] * n
food = [0] * (m+1)
for i in range(n):
    a = list(map(int, input().split()))
    for j in a[1:]:
        food[j] += 1

sum = 0
for i in range(1,m+1):
    if food[i] == n:
        sum += 1

print(sum)

Measured memory_bytes: 3064
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>

using namespace std;

int n, m;
int x[111111];
vector<int> y[111111];
int z[111111];

int test() {
  /*
  vector<int> v;
  
  for (int i = 0; i < n; i++) {
    v.push_back(x[i]);
  }

  int res = 0;
  do {
  for (int i = 0; i < n-1; i++) {
  }
  } while(next_permutation(v.begin(), v.end()));
  */
}

int main(void) {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%d", x+i);
    y[x[i]%m].push_back(x[i]);
  }

  int res = 0;
  memset(z, -1, sizeof(z));
  for (int i = 0; i < m; i++) {
    if (z[i] >= 0) continue;
    int p = i;
    int q = (m-i)%m;
    if (p == q) {
      z[p] = y[p].size();
      res += z[p]/2;
    } else {
      z[p] = z[q] = min(y[p].size(), y[q].size());
      res += z[p];
    }
  }

  for (int i = 0; i < m; i++) {
    sort(y[i].begin(), y[i].end());
    // printf("%d/%zd\n", z[i], y[i].size());
    for (int j = 0; j < int(y[i].size())-1; j++) {
      if (y[i][j] == y[i][j+1] && z[i]+2 <= int(y[i].size())) {
        z[i] += 2;
        res += 1;
        j++;
      }
    }
  }
  
  printf("%d\n", res);
  return 0;
}


Measured memory_bytes: 6784
import java.util.Scanner;
 
public class Main {
  public static void main (String[] args){
    
   int a,b;
   int tmp=0,cnt=0; 
 
   Scanner sc = new Scanner (System.in);
   a=sc.nextInt();
   b=sc.nextInt();

   for(int i=a;i<=b;i++){
     tmp=i%10;
     if(i/10000 == tmp){
      tmp=(i/10)%10;
      if((i/1000)%10 == tmp){
       cnt=cnt+1;
      }
    }
   }

   System.out.println(cnt);
  }
}

Measured memory_bytes: 23636
A1 = [int(a) for a in input().split()]
A2 = [int(a) for a in input().split()]
A3 = [int(a) for a in input().split()]
N = int(input())
b = []
for _ in range(N):
    b.append(int(input()))
b_set = set(b)

set_list = [set(A1),
            set(A2),
            set(A3),
            set([A1[0], A2[0], A3[0]]),
            set([A1[1], A2[1], A3[1]]),
            set([A1[2], A2[2], A3[2]]),
            set([A1[0], A2[1], A3[2]]),
            set([A1[2], A2[1], A3[0]])]

f = False
for s in set_list:
    if len(s - b_set)==0:
        f = True
        print('Yes')
        break
if not f:
    print('No')   

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

#define INF 100100100
#define MOD 1000000007

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

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

struct edge{ll to,cost;};

int main(int argc, char const* argv[]){
   ios::sync_with_stdio(false);
   cin.tie(0);
   string s;
   cin >> s;

   ll stock=0;
   ll ans = 0;
   for(int i=0;i<s.size();i++){
      if(s[i] == 'g'){
         if(stock == 0){
            stock++;
         }
         else{
            stock--;
            ans++;
         }
      }
      else{
         if(stock == 0){
            stock++;
            ans--;
         }
         else{
            stock--;
         }
      }
   }
   cout << ans << endl;
   return 0;
}


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

template< typename T >
T mod_pow(T x, T n, const T &p) {
    T ret = 1;
    while(n > 0) {
        if(n & 1) (ret *= x) %= p;
        (x *= x) %= p;
        n >>= 1;
    }
    return ret;
}

template<class T>
void printIter(const T &a, string delimiter) {
    if (a.size() == 0) return;
    auto it = a.begin();
    cout << *it;
    it++;
    while (it != a.end()) {
        cout << delimiter << *it;
        it++;
    }
    cout << endl;
}

int main() {
    int H, W, K;
    cin >> H >> W >> K;
    vector<string> s(H);
    for (int i = 0; i < H; ++i) {
        cin >> s[i];
    }

    int h = mod_pow(2, H, 10000);
    int w = mod_pow(2, W, 10000);
//    cout << h << endl;
//    cout << w << endl;
    int cnt = 0;
    for (int i = 0; i < w; ++i) {
        for (int j = 0; j < h; ++j) {
            vector<string> ss = s;
            bitset<6> a = i;
            bitset<6> b = j;

            for (int x = 0; x < W; ++x) {
                if(!a[x]) continue;
                for (int y = 0; y < H; ++y) {
                    ss[y][x] = 'x';
                }
            }

            for (int y = 0; y < H; ++y) {
                if(!b[y]) continue;
                for (int x = 0; x < W; ++x) {
                    ss[y][x] = 'x';
                }
            }
            int black = 0;
//            printIter(ss, "\n");
//            cout << endl;
            for (int y = 0; y < H; ++y) {
                for (int x = 0; x < W; ++x) {
                    if (ss[y][x] == '#') black++;
                }
            }
            if (black == K) cnt++;
        }

    }
    cout << cnt << endl;
}


Measured memory_bytes: 3620
#include<stdio.h>
#define N 2000005
int A[N],B[N],C[N];
int main(){
  int i,j,n,max=0;
  //int A[N];
  scanf("%d",&n);
  //int B[n],C[n];
  for(i=1 ; i<=n ; i++){
    scanf("%d",&A[i]);
    if(max<A[i]) max=A[i];
  }

  for(i=0 ; i<=max ; i++) C[i]=0;
  for(j=1 ; j<=n ; j++) C[A[j]]++;     //C[i]にはiの出現数を記録
  
  for(i=1 ; i<=max ; i++) C[i] = C[i] + C[i-1]; //C[i]にはi以下の出現数を記録

  for(j=n ; j>=1 ; j--){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }

  for(i=1 ; i<n ; i++){
    printf("%d ",B[i]);
  }
  printf("%d\n",B[i]);
  return 0;
  
}

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

int main(){
  int L;
  cin >> L;
  int ans_seisu = L*L*L/27;
  int ans_amari = (L*L*L)%27;
  double ans_shousu = ans_amari/27.0;
  printf("%.8lf\n", ans_seisu+ans_shousu);
  return 0;
}

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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(0);
    
    int n;
    cin >> n;
    n = n % 10;
    if(n == 2 || n == 4 || n == 5 || n == 7 || n == 9){
    	cout << "hon";
    }
    else if(n == 0 || n == 1 || n == 6 || n == 8){
    	cout << "pon";
    }
    else if(n == 3){
    	cout << "bon";
    }

    return 0;
}

Measured memory_bytes: 3584
#include<stdio.h>

  int main(void){
    int A ,B, C;
    scanf("%d%d%d",&A,&B,&C);

    if( -100<=A && A <= 100 && -100<=B && B <= 100 && -100<=C && C <= 100 ){
      if( A<=C && B>=C ){
        printf("Yes");
      }
      else{
        printf("No");   
      }
    }else{
      printf("error"); 
    }
  
   
  }

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {  
    int h, w;
    cin >> h >> w;
    vector<string> vs;
    for (int i = 0; i < h; i++) {
        string s;
        cin >> s;
        vs.push_back(s);
    }
    int white = 0;
    for (auto r : vs) {
        for (auto c : r) {
            if (c == '.') white++;
        }
    }
    vector<pair<int, int>> vp1, vp2;
    vp1.push_back(make_pair(0, 0));
    int d = 1;
    vs[0][0] = '#';
    vector<vector<int>> dir{{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
    while (vp1.size() > 0) {
        vp2.clear();
        for (auto node : vp1) {
            if (node.first == h - 1 && node.second == w - 1) {
                cout << white - d << endl;
                return 0;
            }
            for (auto d : dir) {
                int x = d[0] + node.first, y = d[1] + node.second;
                if (x < 0 || y < 0 || x >= h || y >= w) continue;
                if (vs[x][y] == '.') {
                    vs[x][y] = '#';
                    vp2.push_back(make_pair(x, y));
                }
            }
        }
        d++;
        vp1 = vp2;
    }
    cout << -1 << endl;
}




Measured memory_bytes: 3640
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
ll a;
double b;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> a >> b;
  b = b * 1000.0;
  cout << (a * ((ll)b/10)) / 100 << endl;
}


Measured memory_bytes: 3740
#include <bits/stdc++.h>
#define vsort(v) sort(v.begin(), v.end())
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main()
{
	ll N, K; cin >> N >> K;
  	ll cnt[3000][3000] = {};
  	for (int i = 0; i <= 2005; i++) {
    	cnt[i][0] = 1;
      	for (int j = 1; j <= i; j++) {
        	cnt[i][j] = (cnt[i - 1][j - 1] + cnt[i - 1][j]) % MOD;
        }
    }
  	for (ll i = 1; i <= K; i++){
    	cout << cnt[K - 1][i - 1] * cnt[N - K + 1][i] % MOD << endl;
    }
}


Measured memory_bytes: 70528
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <iomanip>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <sstream>
#include <complex>

using namespace std;

using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
using vvi = vector<vi>;
using iii = pair<int, ii>;
using viii = vector<iii>;

using ll = long long int;
using vc = vector<char>;
using vb = vector<bool>;
using ib = pair<int, bool>;
using vib = vector<ib>;

#define MOD 1000 * 1000 * 1000 + 7
#define INF 1000 * 1000 * 1000
#define EMPTY -10
#define mp(a, b) make_pair(a,b)

bool resuelveCaso() {
	int n;
	cin >> n;
	if (!cin) return false;
	string s;
	cin >> s;

	int numbl = 0, numneg = 0;
	for (int i = 0; i < n; ++i) {
		if (s[i] == '.') ++numbl;
		else ++numneg;
	}

	if (numbl == n || numneg == n) {
		cout << "0\n";
		return true;
	}

	int minc = INT_MAX, bl = 0, neg = 0;
	int cont = 0;
	while (cont < n && s[cont] == '.') {
		++cont;
		++bl;
	}
	minc = min(minc, neg + numbl - bl);


	while (cont < n) {
		if (s[cont] == '.') ++bl;
		else ++neg;

		minc = min(minc, neg + numbl - bl);
		++cont;
	}

	cout << minc << '\n';

	return true;
}

int main() {
	while (resuelveCaso()) {}
	return 0;
}

Measured memory_bytes: 640
import heapq
N,M=(int(i) for i in input().split())



tasks=[[] for i in range(10**5+1)]
for i in range(N):
    a,b=(int(i) for i in input().split())
    tasks[a-1].append(b)

pq=[]
ans=0
for i in range(M):
    for b in tasks[i]:
        heapq.heappush(pq,-b)
    if len(pq)!=0:
        temp=heapq.heappop(pq)
        ans-=temp

print(ans)



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

string s;

int dfs(int l, int r){
  if(s[l] != '[') return atoi(s.substr(l, r - l).c_str()) / 2 + 1;
  int cnt = 0, nl = l + 1;
  vector<int> v;
  FOR(i, l, r){
    if(s[i] == '[') ++cnt;
    else if(s[i] == ']'){
      --cnt;
      if(cnt == 0){
        int tmp = dfs(nl, i);
        nl = i + 2;
        v.push_back(tmp);
      }
    }
  }
  int ans = 0;
  SORT(v);
  REP(i, (int)(v.size()) / 2 + 1) ans += v[i];
  return ans;
}

int main() {
  int T; cin >>T;
  REP(t, T){
    cin >>s;
    cout <<dfs(1, (int)s.length() - 1) <<endl;
  }
  return 0;
}

Measured memory_bytes: 1292
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string a,b;
    cin>>a>>b;
    a+=b;
    int n=stoi(a);
    rep(i,10001){
        if(i*i==n)return yes,0;
    }
    no;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF 100100100100
#define MOD 1000000007
#define ALL(x) begin(x),end(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vii;
typedef vector<ll> vll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int n, a[201], b[201], c[201];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> n;
    rep(i, 0, n) cin >> a[i] >> b[i] >> c[i];
    vii ans;
    rep(i, 0, n) {
      int sum_a = a[i], sum_b = b[i], sum_c = c[i];
      rep(j, 0, n) {
        if (j == i) continue;
        if (a[i] == a[j]) {
          sum_a = 0;
          break;
        }
      }
      rep(j, 0, n) {
        if (j == i) continue;
        if (b[i] == b[j]) {
          sum_b = 0;
          break;
        }
      }
      rep(j, 0, n) {
        if (j == i) continue;
        if (c[i] == c[j]) {
          sum_c = 0;
          break;
        }
      }
      ans.pb(sum_a + sum_b + sum_c);
    }
    rep(i, 0, n) {
      cout << ans[i] << endl; 
    }
    return 0;
}




Measured memory_bytes: 3128
#pragma GCC positionimize(3,"Otrst","inline")
//#include "emplace.hpp"
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
const int N=1e7+10;
const int INF=0x3f3f3f;
const double pi = 3.141592653;
const double E = 2.71828182846;
const ll mod=1e9+7;
const int M=1e3+5;
const double eps=1e-8;
#define ci(x) scanf("%d",&x)
#define co(x) printf("%d\n",x)
inline int read()
{
    int f=1,x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
        if(c=='-')
            f=-1;
        c=getchar();
    }
    while(c>='0' && c<='9')
    {
        x=x*10+c-'0';
        c=getchar();
    }
    return f*x;
}
int prime(ll num)
{
    if(num == 1)
        return 0;
    if(num ==2|| num==3 )
        return 1 ;
    if(num %6!= 1&&num %6!= 5)
        return 0 ;
    int tmp =sqrt( num);
    for(int i= 5; i <=tmp; i+=6 )
        if(num %i== 0||num %(i+ 2)==0 )
            return 0 ;
    return 1 ;

}
string s,t;
int a[30];
int b[30];
int main()
{
    cin>>s>>t;
    memset(a,0,sizeof(a));
    memset(b,0,sizeof(b));
    for(int i=0;i<s.size();i++)
    {
        int res=s[i]-'a';
        a[res]++;
    }
    for(int i=0;i<t.size();i++)
    {
        int res=t[i]-'a';
        b[res]++;
    }
    sort(a,a+26);
    sort(b,b+26);
    for(int i=0;i<26;i++)
    {
        if( a[i]!=b[i] )
        {
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");
    return 0;
}


Measured memory_bytes: 776
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

ll memo[5050][5050];
bool done[5050][5050];

ll com(int n, int k){
	if(n<k){
		return 0ll;
	}
	if(done[n][k]){
		return memo[n][k];
	}
	done[n][k] = true;
	if(k==0 || k==n){
		return memo[n][k] = 1ll;
	}
	memo[n][k] = com(n-1,k);
	add_mod(memo[n][k],com(n-1,k-1));
	return memo[n][k];
}

ll rwpw(ll a, int p){
	ll ret = 1ll;
	while(p){
		if(p&1){
			mul_mod(ret,a);
		}
		mul_mod(a,a);
		p >>= 1;
	}
	return ret;
}

int main(void){
	int n,m,i,j,k,a,b,c;
	ll ans=0ll,tmp;
	cin >> n >> a >> b >> c;
	if(b%2){
		cout << 0 << endl;
		return 0;
	}
	b /= 2;
	for(i=0; i<=c; ++i){
		for(j=0; j<=c; ++j){
			if(i+j>c){
				continue;
			}
			if(j>a){
				continue;
			}
			k = c - i - j;
			if(k%3){
				continue;
			}
			k /= 3;
			m = b + a + k;
			tmp = com(m,b);
			mul_mod(tmp,com(m-b,a));
			mul_mod(tmp,com(a,j));
			if(i+b>0){
				mul_mod(tmp,com(i+b-1,i));
			}
			add_mod(ans,tmp);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 223360
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <numeric>
#include <unordered_map>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <memory>
#include <iomanip>
#include <type_traits>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
constexpr long long MOD = 1e9 + 7;
constexpr long long MAX = 1000000;

//long long MOD = 998244353;
constexpr ll INF = 1e17;
constexpr double PI = 3.141592653589793;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

ll h, w;
vector<ll> dx = { -1, 0, 1, 0 };
vector<ll> dy = { 0, -1, 0, 1 };


bool isInField(ll x, ll y) {
    bool f = x >= 0 && x < w && y >= 0 && y < h;
    return f;
}

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

    ll h;
    cin >> h;

    ll cnt = 0;
    ll leaf = 1;
    while (h != 1ll) {
        h /= 2ll;
        leaf *= 2ll;
        cnt++;
    }

    ll ans = 0;
    ll current = 1;
    for (ll i = 0; i < cnt; i++)
    {
        ans += current;
        current *= 2ll;
    }

    cout <<  ans + leaf << "\n";

    return 0;
}



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

using namespace std;



int main() {
	
	string s; cin >> s;
	for(int i = 0; i < s.size(); ++i)
		if (s[i] == '7') {
			cout << "Yes" << '\n';
			return 0;
		}	

		cout << "No" << '\n';
 
	return 0;	
}

Measured memory_bytes: 3624