akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main{
	static int memo[][];
	static int n;
	static int m; 
	static StringBuilder sb;
	static void dp(String s1,String s2) {
	for(int i=1;i<s1.length();i++) {
	 for(int j=1;j<s2.length();j++) {
		 if(s1.charAt(i)==s2.charAt(j)) {
			 memo[i][j]=1+memo[i-1][j-1];
		 }else {
			 memo[i][j]=Math.max(memo[i-1][j], memo[i][j-1]);
		 }
	 }
	}
	}
	static void trace(String s1,String s2) {
		int i=s1.length()-1;int j=s2.length()-1;
		while(i>0&&j>0) {
			if(memo[i][j]==1+memo[i-1][j-1]&&s1.charAt(i)==s2.charAt(j)) {
				sb.append(s1.charAt(i));
				i--;j--;
						}
			else if(memo[i-1][j]>memo[i][j-1]) 
				i--;
			else j--;
			}
	}
	public static void main(String []args) throws IOException {
 		PrintWriter pw =new PrintWriter(System.out);
 		Scanner sc=new Scanner (System.in);
 		String s1=sc.next();
 		String s2=sc.next();
 		s1=" "+s1;
 		s2=" "+s2;
 		n=s1.length();
 		m=s2.length();
 		
 		sb=new StringBuilder("");
 		if(n<=m) {memo=new int [n][m];
 		dp(s1,s2);
 		trace(s1,s2);}else {memo=new int [m][n];
 			dp(s2,s1);
 			trace(s2,s1);
 		}
 		sb.reverse();
 		pw.println(sb);
 		pw.flush();
 		}
	static class Scanner {

   		StringTokenizer st;
   		BufferedReader br;
    
   		public Scanner(InputStream system) {
   			br = new BufferedReader(new InputStreamReader(system));
   		}
    
   		public Scanner(String file) throws Exception {
   			br = new BufferedReader(new FileReader(file));
   		}
    
   		public String next() throws IOException {
   			while (st == null || !st.hasMoreTokens())
   				st = new StringTokenizer(br.readLine());
   			return st.nextToken();
   		}
    
   		public String nextLine() throws IOException {
   			return br.readLine();
   		}
    
   		public int nextInt() throws IOException {
   			return Integer.parseInt(next());
   		}
    
   		public double nextDouble() throws IOException {
   			return Double.parseDouble(next());
   		}
    
   		public char nextChar() throws IOException {
   			return next().charAt(0);
   		}
    
   		public Long nextLong() throws IOException {
   			return Long.parseLong(next());
   		}
    
   		public boolean ready() throws IOException {
   			return br.ready();
   		}
    
   		public void waitForInput() throws InterruptedException {
   			Thread.sleep(3000);
   		}
	}
}


Measured memory_bytes: 78548
#include <iostream>
#include <string>
using namespace std;
int main(){
    int A, B;
    cin >> A >> B;
    int res=0;
    for(int i = A; i<=B; i++){
        string temp = to_string(i);
        if(temp[4]==temp[0] && temp[3]==temp[1]){
            res++;
        }
    }
    cout << res << endl;
    return 0;
}

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

using namespace std;
using ll =long long;

#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}

const ll INF = 1LL << 60;

//Write From this Line

const int mod = 1e9+7;
int main()
{
	ll h ;
	cin >> h ;
	ll count = 0 ;
	while( h > 1 ){
		count ++ ;
		h /= 2 ;
	}
	//2^count個の1がある
	ll ans = 0 ;
	for(int i = 0 ; i <= count ; i++){
		ans += pow(2,i);
	}
	cout << ans << endl;

}


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

const int N=5e3+5;
string s;
string a[N*5];
int n,k;

signed main()
{
	cin>>s>>k,n=0;
	for(register int i=0;i<(int)s.size();i++)	
		for(register int j=1;j<=5;j++)
			a[++n]=s.substr(i,j);
	sort(a+1,a+1+n);
	n=unique(a+1,a+1+n)-a-1;
	cout<<a[k]<<endl;
	return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h> 
typedef long long LL;
typedef long double DL;
const LL maxn=1e6+9,inf=0x3f3f3f3f3f3f3f3f;
//const DL mod=998244353;
LL Read(){
	LL x(0),f(1); char c=getchar();
	while(c<'0' || c>'9'){
		if(c=='-') f=-1; c=getchar();
	}
	while(c>='0' && c<='9'){
		x=(x<<3)+(x<<1)+c-'0'; c=getchar();
	}return x*f;
}
LL N,ans(inf);
int main() {
	N=Read();
	for(LL i=1;i*i<=N;++i){
		if(N%i==0){
			ans=std::min(ans,i+(N/i)-2);
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define        fast        ios_base::sync_with_stdio(false);cin.tie(NULL)
#define        ll          long long int
#define        End         return 0
#define        st          string
#define        sz(x)       (int)x.size()
#define        nl          '\n'
int main()
{
    fast;
    int x;
    cin>>x;
    if(x==1)
        cout<<0;
    else
        cout<<1;
    End;
}



Measured memory_bytes: 3616
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int main()
{
    int a,b,c,d;
    scanf("%d %d",&a,&b);
    if(a==b) printf("Draw\n");
    else if(a==1) printf("Alice\n");
    else if(b==1) printf("Bob\n");
     else if(a<b) printf("Bob\n");
     else if(a>b) printf("Alice\n");



}


Measured memory_bytes: 3024
#include <bits/stdc++.h>
 
#define int long long
#define left left1
#define right right1
 
using namespace std;

int was[77];

 main () {
    //freopen ("deleg.in", "r", stdin);
    //freopen ("deleg.out", "w", stdout);
	ios_base::sync_with_stdio (0);
	cin.tie (0), cout.tie (0);
    int n, m;
    cin >> n >> m;
    for (int i = 1;i <= n;i ++) {
        was[i] = -1;
    }
    for (int i = 1;i <= m;i ++) {
        int x, y ;
        cin >> x >> y;
        if (was[x] == -1 || was[x] == y)
            was[x] = y;
        else {
            cout << -1;
            exit (0);
        }
    }
    if (n > 1 && was[1] == 0) {
        cout << -1;
        exit (0);
    }
    for (int i = 1;i <= n;i ++) {
        if (was[i] == -1) {
            if (i == 1 && n > 1) was[i] = 1;
            else was[i] = 0;
        }
    }
    for (int i = 1;i <= n;i ++) cout << was[i];
	return 0;   
}

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

int main()
{
  int N;
  cin >> N;
  
  int A[210];
  for (int i = 0; i < N; i++)
  {
    cin >> A[i];
  }
  
  int counter = 0;
  bool flag = false;
  while (true)
  {
    for (int i = 0; i < N; i++)
    {
      if (0 != A[i] % 2)
      {
        flag = true;
      }
    }
    
    if (flag)
    {
      break;
    }
    
    for (int i = 0; i < N; i++)
    {
      A[i] /= 2;
    }
    
    counter++;
  }
  
  cout << counter;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<iostream>
using namespace std;
typedef long long ll;

const int N = 100005;
const int INF = 1000000000;
const ll MOD = 1000000007;

int t[N],a[N],l[N],r[N];

int main()
{
    int n;
    while(scanf("%d",&n)+1)
    {
        for(int i=1;i<=n;i++) scanf("%d",&t[i]);
        for(int i=1;i<=n;i++) scanf("%d",&a[i]);
        t[0]=a[n+1]=0;
        for(int i=1;i<=n;i++) l[i]=0,r[i]=INF;
        for(int i=1;i<=n;i++)
        {
            if(t[i]>t[i-1]) {
                l[i]=max(l[i],t[i]);
                r[i]=min(r[i],t[i]);
//                l[i]=r[i]=t[i];
            }else {
                l[i]=max(l[i],1);
                r[i]=min(r[i],t[i]);
            }
        }
        for(int i=n;i>0;i--){
            if(a[i]>a[i+1]) {
                l[i]=max(l[i],a[i]);
                r[i]=min(r[i],a[i]);
            }else {
                l[i]=max(l[i],1);
                r[i]=min(r[i],a[i]);
            }
        }
//        for(int i=1;i<=n;i++) printf("%d    %d==\n",l[i],r[i]);
        ll res=1;
        for(int i=1;i<=n;i++) {
            if(l[i]>r[i]) res=0;
            else res=(res*(r[i]-l[i]+1))%MOD;
        }
        cout<<res<<endl;
//        printf("%lld\n",res);
    }
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X)
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto x:v)cerr<<x<<' ';cerr<<endl;
#define INF 1000000007
#define LINF 1000000000000000007
#define EPS 1e-9
typedef long long ll;

long long TheNumberofWindows(const vector<long long> &v,const long long &S){
  long long n = v.size(),l=0,r=0,ans = 0;
  long long sum = 0;
  while(l < n){
    while(sum+v[r]<=S && r<n){
      sum += v[r];
      r++;
    }
    ans += r-l;
    sum -= v[l];
    l++;
  }
  return ans;
}

signed main(){
  int N,Q;
  cin >> N >> Q;
  vector<ll> a(N),x(Q);
  FOR(i,0,N)scanf("%lld",&a[i]);
  FOR(i,0,Q)scanf("%lld",&x[i]);
  FOR(i,0,Q)cout << TheNumberofWindows(a,x[i]) << endl;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,i,e,f,g,n,m,k,l,q,x;
map <long long,long long> mp,mp1;

int main() {
           cin>>n>>m;
           for(long long i=1;i<=m;i++)
           {
                      cin>>a;
                      b+=a;
           }
           if(b>=n) cout<<"Yes";
           else cout<<"No";
}

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

int main() {
    
    string S, T;
    cin >> S >> T;

    for (int i=0; i<S.size(); i++)
        if (S[i] != T[i])
        {
            cout << "No\n";
            return 0;
        }

    cout << "Yes\n";
    return 0;
}


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

typedef long long ll;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define debug(x) cerr << #x << ": " << x << '\n'

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

    for (int i = 1; i < 10; ++i)
    {
        for (int j = 1; j < 10; ++j)
        {
            if (A == (i * j))
            {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var s, t string
	fmt.Scan(&s, &t)

	ss := []rune(s)
	sort.Slice(ss, func(i, j int) bool { return ss[i] < ss[j] })
	rt := []rune(t)
	sort.Slice(rt, func(i, j int) bool { return rt[i] > rt[j] })
	if string(ss) < string(rt) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 1828
N = int(input())
N_uneven = 0
for i in range(1,N+1):
   if i>0 and i<10:
       N_uneven+=1
   elif i>99 and i<1000:
       N_uneven+=1
   elif i>9999 and i <100000:
       N_uneven+=1
   else:
       pass
print(N_uneven)

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

const int m = 2019;

int main(){
  string s;
  cin >> s;
  int n=s.size();
  reverse(s.begin(),s.end());
  int x=1 ; int tot=0;
  vector<int> count(m);
  ll ans=0;
  for(int i=0; i<n; i++){
    count[tot]++;
    tot+=(s[i]-'0')*x;
    tot%=m;
    ans+=count[tot];
    x=x*10%m;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3708
#include<stdio.h>

main(){
  int n[10], i, last = 9, tmp;

  for(i = 0 ; i < 10 ; i++){
    scanf("%d", &n[i]);
  }

  while(last > 0){
    for(i = 0 ; i < last ; i++){
      if(n[i] < n[i+1]){
        tmp = n[i];
	n[i] = n[i+1];
	n[i+1] = tmp;
      }
    }
  last--;
  }

  printf("%d\n%d\n%d\n", n[0], n[1], n[2]);

  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));
int main(){
	string S; cin >> S;

	int maxN = 0;
	REP(i, S.size()){
		REP(j, S.size()){
			string sub = S.substr(i, j+1);
			REP(k, sub.size()){
				if(sub[k] == 'A' or sub[k] == 'C' or sub[k] == 'G' or sub[k] == 'T'){ 
					if(k+1 == sub.size()) maxN = max(maxN, (int)sub.size()), cerr << sub <<endl;
				}else{
					break;
				}
			}
		}
	}

	cout << maxN << endl;
}


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

vector<int> par, rnk;

void init(int n) {
    for(int i = 0; i < n; ++i) {
        par[i] = -1;
        rnk[i] = 0;
    }
}

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

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

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

void unite(int x, int y) {
    x = root(x);
    y = root(y);
    if(x == y)
        return;
    if(rnk[x] < rnk[y])
        swap(x, y);
    par[x] += par[y];
    par[y] = x;
    if(rnk[x] == rnk[y])
        rnk[x]++;
}

int main() {
    ll N, M, c;
    cin >> N >> M;
    c = N * (N - 1) / 2;
    stack<ll> ans;
    stack<pair<int, int>> ab;
    ans.push(c);
    par.resize(N);
    rnk.resize(N);
    init(N);
    for(int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        ab.push(make_pair(a, b));
    }
    for(int i = 0; i < M - 1; ++i) {
        if(!issame(ab.top().first, ab.top().second)) {
            ans.push(ans.top() - size(ab.top().first) * size(ab.top().second));
            unite(ab.top().first, ab.top().second);
        } else
            ans.push(ans.top());
        ab.pop();
    }
    for(int i = 0; i < M; ++i) {
        cout << ans.top() << endl;
        ans.pop();
    }
    return 0;
}


Measured memory_bytes: 2944
n, m, x0 = list(map(int, input().split()))
c = [0] * n
a = [[0]*m for i in range(n)]
for i in range(n):
    tmp = list(map(int, input().split()))
    c[i] = tmp[0]
    a[i] = tmp[1:]

b = [[0]*m for i in range(2**n)]
money = [0] * (2**n)

list2n = [list(f"{i:0{n}b}") for i in range(2**n)]

for i, x in enumerate(list2n):
    for j in range(n):
        money[i] += c[j] * int(x[j])
        for k in range(m):
            b[i][k] += a[j][k] * int(x[j])
            
ans = 1e10
for i in range(2**n):
    flag = True
    for j in range(m):
        if b[i][j] < x0:
            flag = False
            break
    if flag == True:
        ans = min(ans, money[i])

print(ans) if ans != 1e10 else print(-1)

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

using namespace std;

int main(void) {

	int N;
	int i, v;
	vector<int> vec;

	cin >> N;

	for (i = 0; i < N; i++) {
		cin >> v;
		vec.push_back(v);
	}

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

	/* 0: Alice, 1: Bob */
	int totals[2] = { 0, 0 };

	for (i = 0; i < N; i++) {
		totals[i % 2] += vec[i];
	}

	int result = totals[0] - totals[1];
	cout << result << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,ll>
const ll MOD=998244353;
const int INF=1e9;
const double PI=acos(-1);


int main() {
    ios_base::sync_with_stdio(false);

    ll n;
    cin >> n;
    if (n%2==1) n*=2;
    cout << n << endl; 

    return 0;

}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>

using namespace std;

int main() {
    string S, T;
    cin >> S >> T;

    vector<vector<int>> lett(26),lett_t(26);
    for (int i = 0; i < S.size(); i++) {
        lett[S[i] - 97].push_back(i);
        lett_t[T[i] - 97].push_back(i);
    }

    int flag = 1;
    for (int i = 0; i < 26; i++) {
        if (lett[i].size() >= 1) {
            for (int j = 0; j < lett[i].size() - 1; j++) {
                if (T[lett[i][j]] != T[lett[i][j + 1]]) {
                    flag = 0;
                    break;
                }
            }
        }
        if (flag == 0)break;
    }

    for (int i = 0; i < 26; i++) {
        if (lett_t[i].size() >= 1) {
            for (int j = 0; j < lett_t[i].size() - 1; j++) {
                if (S[lett_t[i][j]] != S[lett_t[i][j + 1]]) {
                    flag = 0;
                    break;
                }
            }
        }
        if (flag == 0)break;
    }
    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 3080
import math

def get_primenumber(number):
    prime_list = []
    #2からnumberまでの数字をsearch_listに入れる
    search_list = list(range(2,number+1))
    while True:
      #search_listの先頭の値が√nの値を超えたら処理終了
      if search_list[0] > math.sqrt(number):
        #prime_listにsearch_listを結合
        prime_list.extend(search_list)
        break
      else:
        #search_listの先頭をprime_listに入れる
        head_num = search_list[0]
        prime_list.append(head_num)
        #search_listの先頭をpopする
        search_list.pop(0)
        #head_numの倍数を取り除く
        search_list = [num for num in search_list if num % head_num != 0]
    return prime_list

X = int(input())
for p in get_primenumber(100003):
    if p >= X:
        print(p)
        break

Measured memory_bytes: 49132
N = gets.to_i
a = gets.split.map(&:to_i)
Q = gets.to_i

hash = a.sort.group_by(&:itself).map { |key, value| [key, value.count]}.to_h
sum = hash.map {|item| item.inject(:*)}.sum

Q.times do
    line = gets.split.map(&:to_i)
    if hash.has_key?(line[0]) then
        count = hash[line[0]]
        sum += - line[0] * count + line[1] * count
        hash.store(line[0], hash[line[0]].to_i - count)
        hash.store(line[1], hash[line[1]].to_i + count)
    end
    puts sum
end


Measured memory_bytes: 32168
#include<iostream>

using namespace std;

int main(){
	for(int n;cin>>n,n;){
		while(n--){
			int m,e,j;	cin>>m>>e>>j;
			if(m==100 || e==100 || j==100)	cout<<'A'<<endl;
			else if(m+e>=180)	cout<<'A'<<endl;
			else if(m+e+j>=240)	cout<<'A'<<endl;
			else if(m+e+j>=210)	cout<<'B'<<endl;
			else if(m+e+j>=150 && (m>=80 || e>=80))	cout<<'B'<<endl;
			else	cout<<'C'<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <cstdio>

int main()
{
	long long x;
	scanf("%lld",&x);
	for (int i = 1; i<=3500; i++)
		for (int j = i; j<=3500; j++)
			if ((i*j*4 - i*x - j*x)!=0 && i*j*x!=0)
				if (((i*j*x)%(i*j*4 - i*x - j*x)) == 0 && (i*j*x)/(i*j*4 - i*x - j*x)>0)
				{
					printf("%d %d %lld",i,j,(i*j*x)/(i*j*4 - i*x - j*x));
					return 0;
				}
}
/*
(i,j,k)

4  8-2-4

i*j*k*4 = i*k*x + j*k*x + i*j*x
*/



Measured memory_bytes: 128
#include"bits/stdc++.h"
using namespace std;

int main() {
	vector<tuple<string, int,int>> score;
	int N,a;
	string s,z="",tmp;
	stack<int> Q;
	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> s >> a;
		score.push_back(make_tuple(s, a,i));
	}
	sort(score.begin(), score.end());
	for (auto p : score) {
		int x, y;
		tmp = z;
		tie(z, x, y) = p;
		if (Q.empty() or tmp == z) {
			Q.push(y);
		}
		else {
			while (!Q.empty()) {
				cout << Q.top() << endl;
				Q.pop();
			}
			Q.push(y);
		}
	}
	while (!Q.empty()) {
		cout << Q.top() << endl;
		Q.pop();
	}
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int matrix[100][100],i,j,input,n,m,matrix1[100],sum=0;
    scanf("%d %d",&n,&m);
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            scanf("%d",&matrix[i][j]);
        }
    }
    for(i=0;i<m;i++){
        scanf("%d",&matrix1[i]);
    }
    for(i=0;i<n;i++){
        sum=0;
        for(j=0;j<m;j++){
            sum+=matrix[i][j]*matrix1[j];
        }
        printf("%d\n",sum);
    }
    return 0;
}



Measured memory_bytes: 2104
#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits>
#include <list>
#include <numeric>
#include <queue>
#include <string>
#include <vector>
#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;
const int ININF = 1000000;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
int main() {
    int N;
    string S;
    cin >> N >> S;
    long long res = 0LL;
    long long r = 0LL;
    long long g = 0LL;
    long long b = 0LL;
    rep(i, 0, N) {
        if(S[i] == 'R') {
            r++;
        }
        if(S[i] == 'G') {
            g++;
        }
        if(S[i] == 'B') {
            b++;
        }
    }
    res = r * g * b;
    //  cout<<res<<endl;
    rep(i, 1, (N + 2) / 2) {
        rep(j, 1, N - 1) {
            if(j - i < 0 || j + i >= N) {
                continue;
            }
            if(S[j - i] != S[j] && S[j] != S[j + i] && S[j - i] != S[j + i]) {
                res--;
            }
        }
    }
    cout << res << endl;
}


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

int main() {
	ll n, h, w;
	cin >> n >> h >> w;
	vector<vector<ll>>ab(n, vector<ll>(2));
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		ll a, b;
		cin >> a >> b;
		if (a >= h && b >= w)ans++;
	}
	cout << ans << endl;


}

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

int main(){
	int N,K,x,a;
  cin >> N >> K;
  for(int i = 0; i < N; i++){
  	cin >> x;
    if(x < K-x) a += x*2; 
    	else a += (K-x)*2;
      }
  cout << a;
}

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

int get_gcd(int a,int b,int c){
    int m = a;
    int n = b;
    int m2 = c;
    int n2 = 0;
    int result = 0;
    while (n != 0){
        n2 = m % n;
        m = n;
        n = n2;
    }
    while (m != 0){
        result = m2 % m;
        m2 = m;
        m = result;
    }
    result = m2;
    return result;
}

int main(){
    int x;
    scanf("%d",&x);
    long result = 0;
    for (int i=1;i<x+1;i++){
        int a = i;
        for (int j=1;j<x+1;j++){
            int b = j;
            for (int k=1;k<x+1;k++){
                int c = k;
                result = result + get_gcd(a,b,c);
            }
        }
    }
    printf("%ld",result);
}

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

using namespace std;

int find_circles_relationship(int x1, int y1, int r1, int x2, int y2, int r2){
	float center_distance = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
	float sum_radius = r1 + r2;
	float min_radius = min(r1, r2);
	float max_radius = max(r1, r2);

	int relationship;
	if(center_distance > sum_radius){
		relationship = 4;
	}else if(center_distance == sum_radius){
		relationship = 3;
	}else{
		if(min_radius + center_distance == max_radius){
			relationship = 1;
		}else if(min_radius + center_distance < max_radius){
			relationship = 0;
		}else{
			relationship = 2;
		}
	}
	return relationship;
}

int main(){
	int x1, y1, r1;
	int x2, y2, r2;
	cin >> x1 >> y1 >> r1;
	cin >> x2 >> y2 >> r2;
	cout << find_circles_relationship(x1, y1, r1, x2, y2, r2) << endl;
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  vector<int> p(4);
  for(int i=0;i<n;i++){
    char s;
    cin>>s;
    if( s=='G'){
      p.at(0)=1;
    }
    else if(s=='W'){
      p.at(1)=1;
    }
    else if(s=='Y'){
      p.at(2)=1;
    }
    else{
      p.at(3)=1;
    }
  }
  int ans=0;
  for(int i:p){
    ans += i;
  }
  if(ans>=4){
    cout << "Four";
  }
  else{
    cout << "Three";
  }
}

Measured memory_bytes: 256
import numpy as np
def resolve():
    n, m, x = map(int, input().split())
    books = np.array([list(map(int, input().split())) for _ in range(n)])

    ans = 10 ** 7
    for i in range(2 ** 12):
        money = 0
        skills = np.zeros(m)
        for j in range(n):
            if ((i >> j) & 1):
                money += books[j][0]
                skills += books[j][1:]
        if (skills >= x).all():
            ans = min(ans, money)

    if ans == 10 ** 7:
        print(-1)
        return
    print(ans)
    
resolve()

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

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

  int a[n];

  for(int i = 0; i <= n -1; i++)
    {cin >> a[i];}

  for(int i = n-1 ; i >= 0; i--)
    {
      if(i == 0)
	{cout << a[0];}
      else
	{cout << a[i] << " ";}
    }
  
  cout << endl;
}


Measured memory_bytes: 3104
#include<stdio.h>
int main()
{
    long long int A,B,R;
    char op;
    scanf("%lld %c %lld",&A,&op,&B);
    if(op=='+')
    {
        R=A+B;
    }
    else if(op=='-')
    {
        R=A-B;
    }
    printf("%lld",R);
    return 0;
}


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

int main(){
    
    for(int i=1;;i++){
        int x;
        cin>>x;
        if(x == 0) break;
        cout<<"Case "<<i<<": "<<x<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 2992
#include <cstdio>
#include <climits>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <complex>
#include <numeric>
#define _for(i,n) for(int i = 0; i < n; i++)

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

template <typename T>
vector<size_t> sort_indexes(const vector<T> &v) {
  vector<size_t> idx(v.size());
  iota(idx.begin(), idx.end(), 0);
  sort(idx.begin(), idx.end(), [&v](size_t i1, size_t i2) {return v[i1] < v[i2];});
  return idx;
}

int main() {
  int n;
  cin >> n;
  int v[n], c[n];
  _for(i,n) cin >> v[i];
  _for(i,n) cin >> c[i];
  int pmax = 0;
  _for(i,n) {
    if(v[i]-c[i]>0) pmax += v[i]-c[i];
  }
  cout << pmax << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
std::mt19937 rnd(time(NULL));
#define rand rnd
#define pr std::pair<int,int>
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
template<class T>void cxk(T&a,T b){a=a>b?a:b;}
template<class T>void cnk(T&a,T b){a=a<b?a:b;}
#ifdef mod
int pow(int x,int y){
	int ret=1;
	while(y){
		if(y&1)ret=1ll*ret*x%mod;
		x=1ll*x*x%mod;y>>=1;
	}
	return ret;
}
template<class Ta,class Tb>void inc(Ta&a,Tb b){a=a+b>=mod?a+b-mod:a+b;}
template<class Ta,class Tb>void dec(Ta&a,Tb b){a=a>=b?a-b:a+mod-b;}
#endif
int A[1000010];
int main(){
#ifdef LOCAL
	freopen("in.in","r",stdin);
	//freopen("out.out","w",stdout);
#endif
	int n=gi(),s=0;
	for(int i=1;i<=n;++i)scanf("%1d",&A[i]),A[i]--,s|=A[i]==1;
	if(!s)for(int i=1;i<=n;++i)A[i]/=2;
	int ans=0;
	for(int i=1;i<=n;++i)if((n-1&i-1)==i-1)ans^=A[i]&1;
	printf("%d\n",ans*(!s+1));
	return 0;
}


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

const ll INF = 1e18;
const int MAXN = 400;
vector<vector<ll>> dp(MAXN,vector<ll>(MAXN));

ll calcdp( int l, int r, vector<ll>& cumsuma ){
	if(l==r) return dp[l][r] = 0;
	if(dp[l][r] > 0) return dp[l][r];
	
	ll res = INF;
	for(int i = l; i < r; i++){
		res = min( res, calcdp(l,i,cumsuma) + calcdp(i+1,r,cumsuma));
	}
	
	if(l==0) res += cumsuma[r];
	else res += cumsuma[r] - cumsuma[l-1];
	
	return dp[l][r] = res;
}

int main(){
	
	int n;
	cin >> n;
	vector<ll> a(n);
	rep(i,n) cin >> a[i];
	
	vector<ll> cumsuma(n);
	cumsuma[0] = a[0];
	rep(i,n-1) cumsuma[i+1] = cumsuma[i] + a[i+1];
	
	
	cout << calcdp(0,n-1,cumsuma) << endl;
	return 0;
}

Measured memory_bytes: 1536
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(), v.end()
#define in(x,y,h,w) if(0<=x&&x<h&&0<=y&&y<w)
#define y0 y12345
#define y1 y54321

#ifdef LOCAL
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;using vvint = vector<vector<int>>;
using vll = vector<ll>;using vvll = vector<vector<ll>>;
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(a>b){a=b;return 1;}return 0;}
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 T>T gcd(T &a, T &b){if(a<b){swap(a,b);} T r = a%b; while(r!=0){a=b;b=r;r=a%b;} return b;}

vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	debug("debug test\n");
   	int n,m;cin>>n;
	string s;cin>>s;
	char now = s[0];
	ll ans = 0;
	for(int i = 1;i < s.size(); i++){
		if(now != s[i]){
			ans++;
			now = s[i];
		}
	}
	ans++;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 512
import sys
sys.setrecursionlimit(10**8)

H, W = map(int,input().split())
S = [input() for _ in range(H)]
#%%
visited = [[False]*W for _ in range(H)]
dx = [1,0,-1,0]
dy = [0,1,0,-1]

group_w = [0]*(H*W)
group_k = [0]*(H*W)

def dfs(x,y,state):
    if S[x][y]=='.':
        group_w[idx] += 1
    else:
        group_k[idx] += 1
    visited[x][y] = True
    
    for i in range(4):
        nx = x+dx[i]
        ny = y+dy[i]
        if nx<0 or nx>=H or ny<0 or ny>=W:
            continue
        if visited[nx][ny]:
            continue
        if state==0 and S[nx][ny]=='#':
            dfs(nx,ny,1)
        elif state==1 and S[nx][ny]=='.':
            dfs(nx,ny,0)
    return 


ans = 0
idx = 0
for i in range(H):
    for j in range(W):
        if not visited[i][j]:
            dfs(i,j,S[i][j]=='#')
            a = group_w[idx]
            b = group_k[idx]
            ans += a*b
            idx += 1
       
print(ans)






# def dfs(x,y,res, numW,numK,state):
#     # print(x,y,res)
#     # state=0: next=Black
#     # state=1: next=White
#     newres = 0
#     flag = True
#     for i in range(4):
#         nx = x+dx[i]
#         ny = y+dy[i]
#         if nx<0 or nx>=H or ny<0 or ny>=W:
#             continue
#         if visited[nx][ny]:
#             continue
#         if state==0 and S[nx][ny]=='#':
#             visited[nx][ny] = True
#             newres += dfs(nx,ny,res+numW,numW,numK+1,1)
#             flag = False
#         elif state==1 and S[nx][ny]=='.':
#             visited[nx][ny] = True
#             newres += dfs(nx,ny,res+numK,numW+1,numK,0)
#             flag = False
    
#     # if flag:
#     #     visited[x][y] = False
#     if S[x][y]=='.':
#         return newres + numK
#     elif S[x][y]=='#':
#         return newres + numW

# ans = 0
# for i in range(H):
#     for j in range(W):
#         if not visited[i][j]:
#             numW = S[i][j]=='.'
#             numK = S[i][j]=='#'
#             visited[i][j] = True
#             ans += dfs(i,j,0,numW,numK,numK)
#             # print('X,Y =',i,j,ans)

# print(ans)

Measured memory_bytes: 318540
#include <iostream>
#include <limits.h>
#include <string>
using namespace std;

int main(void){
    int n, t[100010], x[100010], y[100010], d;
    cin >> n;
    bool ans = true;
    t[0] = x[0] = y[0] = 0;
    for (int i = 1; i <= n; i++) {
      	cin >> t[i] >> x[i] >> y[i];
        if (x[i - 1] > x[i]) {
            if (y[i - 1] > y[i]) d = x[i - 1] - x[i] + y[i - 1] - y[i];
            else d = x[i - 1] - x[i] - y[i - 1] + y[i];
        } else {
            if (y[i - 1] > y[i]) d = x[i] - x[i - 1] + y[i - 1] - y[i];
            else d = x[i] - x[i - 1] - y[i - 1] + y[i];
        }
        if (t[i] - t[i - 1] < d || (t[i] - t[i - 1]) % 2 != d % 2) ans = false;
    }
    if (ans) cout << "Yes";
    else cout << "No";
    return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>
#include<ctime>
#include<cstdlib>
#include<queue>
#define ll long long
using namespace std;
struct node{
	ll x,y;
}e;
queue <node> q;
ll n,m,ans=1,a,b;
ll vis[100][100],f[100][100];
string s;
ll dx[5]={0,1,-1,0, 0};
ll dy[5]={0,0, 0,1,-1};
ll bfs(int x,int y)
{
	ll ans=0; 
	while(!q.empty()) q.pop();
	q.push((node){x,y}); vis[x][y]=1;
	while(!q.empty())
	{
		e=q.front(); q.pop();
		x=e.x; y=e.y;
		ans=max(ans,vis[x][y]);
		for(ll i=1;i<=4;++i)
		{
			e.x=x+dx[i]; e.y=y+dy[i];
			if(vis[e.x][e.y]||f[e.x][e.y]||e.x<1||e.x>n||e.y<1||e.y>m) continue;
			vis[e.x][e.y]=vis[x][y]+1;
			q.push(e);
		}
	}
	return ans;
}
int main()
{
//	freopen("test.in","r",stdin);
//	freopen("test.out","w",stdout);
	cin>>n>>m;
	for(ll i=1;i<=n;++i)
	{
		cin>>s;
		s="*"+s;
		for(ll j=1;j<=m;++j) if(s[j]=='#') f[i][j]=1;
	}
	for(ll i=1;i<=n;++i)
	{
		for(ll j=1;j<=m;++j)
		{
			if(f[i][j]) continue;
			memset(vis,0,sizeof(vis));
			ans=max(ans,bfs(i,j));
		}
	}
	cout<<ans-1;
	return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<cstring>
using namespace std;

const int N=10;

int n,t,l,r,mid,x;

int check(int p){
	cout<<p<<endl;
    char s[N];
	scanf("%s",s);
    if (s[0]=='M') return 0;
    if (s[0]=='F') return 1;
    exit(0);
}

int main(){
	scanf("%d",&n);
	t=check(0);
	l=1; r=n-1;
	while (l<r){
		mid=(l+r)>>1;
		x=check(mid);
		if ((mid-l+1&1)^x^t) r=mid-1;
		else l=mid+1,t=x;
	}
	check(l);
	return 0;
}

Measured memory_bytes: 852
/*
ID: barish21
LANG: C++14
TASK: test
*/

/****Author: Barish Namazov****/
#include <bits/stdc++.h>

using namespace std;

/***TEMPLATE***/
#define intt long long

#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

#define F first
#define S second
#define pb push_back

#define IO ios_base::sync_with_stdio(false);cin.tie();

const intt max4 = 10004;
const intt maxx = 100005;
const intt max6 = 1000006;
const intt max7 = 10000007;

const intt lg4 = 13;
const intt lg5 = 17;
const intt lg6 = 20;

const intt INF = 2LL * 1000000000;
/***************/

/***Additional Functions***/

intt powmod (intt a, intt b, intt mod) {
    intt res = 1;
    a %= mod;
    for (; b; b >>= 1) {
        if (b & 1)
            res = (res * a) % mod;
        a = (a * a) % mod;
    }
    return res;
}

intt gcd (intt a, intt b) {
    while (b > 0) {
        intt t = a % b;
        a = b, b = t;
    }
    return a;
}

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

intt is_prime (intt n) {
    if (n <= 1 || n > 3 && (n % 2 == 0 || n % 3 == 0))
        return 0;
    for (intt i = 5, t = 2; i * i <= n; i += t, t = 6 - t)
        if (n % i == 0)
            return 0;
    return 1;
}

/**************************/

intt arr[maxx];
map <intt, intt> mp;
int main() {
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    IO;
    intt n;
    cin >> n;
    for (intt i = 1; i <= n; i++)
        cin >> arr[i], mp[arr[i]] ++;
    set <intt> s;
    intt res = 0;
    for (intt i = 1; i <= n; i++) {
        if (mp[arr[i]] >= 2)
            s.insert (arr[i]);
        if (mp[arr[i]] >= 4)
            res = max (res, arr[i] * arr[i]);
    }
    if (s.size() >= 2)
        res = max (res, (*s.rbegin()) * (*(++s.rbegin())));
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 7296
#define _USE_MATH_DEFINES
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>
#include <set>   

using namespace std;

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

	if (n >= 889) {
		cout << 999 << endl;
	}else if (n >= 778) 
	{
		cout << 888 << endl;
	}else if (n >= 667) 
	{
		cout << 777 << endl;
	}
	else if (n >= 556) {
		cout << 666 << endl;
	}
	else if (n >= 445) {
		cout << 555 << endl;
	}
	else if (n >= 334) {
		cout << 444 << endl;
	}
	else if (n >= 223) {
		cout << 333 << endl;
	}
	else if (n >= 112) {
		cout << 222 << endl;
	}
	else {
		cout << 111 << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

long long gcd(long long a,long long b){
    if(a<b)swap(a,b);
    while(a%b!=0){
        long long t=a;
        a=b;
        b=t%a;
    }
    return b;
}
int main()
{
    long long dp[105]={0},n,i,j,k,t,a,b,c,m;
    scanf("%lld%lld%lld",&dp[0],&dp[1],&dp[2]);
    sort(dp,dp+3);
    a=dp[0],b=dp[1],c=dp[2];
    long long ans=0;
    if((b-a)&1){
        a++,c++,ans++;
    }
    ans+=(b-a)/2+c-b;
    printf("%lld\n",ans);
    return 0;
}


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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

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

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

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

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

  int x; std::cin >> x;
  int cur_x = 0, dx = 1;
  while (cur_x+dx < x) {
    cur_x += dx;
    dx++;
  }
  std::cout << dx << "\n";
}


Measured memory_bytes: 256
#include <stdio.h>

#define MAX 100000

void calc(float vertex[][2], int deep, int min, int max);

int main() {
	int deep;
	int min, max;
	float vertex[MAX][2];
	int i;
	for (i = 0; i < MAX; i++) {
		vertex[i][0] = -1; //-1??§?????????
	}
	vertex[0][0] = 0;
	vertex[0][1] = 0;
	vertex[MAX - 1][0] = 100;
	vertex[MAX - 1][1] = 0;
	min = 0;
	max = MAX - 1;

	scanf("%d", &deep);

	calc(vertex, deep, min, max);
	
	for (i = 0; i < MAX; i++) {
		if (vertex[i][0] != -1) {
			printf("%lf %lf\n", vertex[i][0], vertex[i][1]);
		}
	}

	return 0;
}

void calc(float vertex[][2], int deep, int min, int max) {
	int s, t, u;
	if (deep <= 0) {
		return;
	}

	s = (max - min) / 3 + min;
	vertex[s][0] = (2 * vertex[min][0] + vertex[max][0]) / 3;
	vertex[s][1] = (2 * vertex[min][1] + vertex[max][1]) / 3;
	t = (max - min) * 2 / 3 + min;
	vertex[t][0] = (vertex[min][0] + 2 * vertex[max][0]) / 3;
	vertex[t][1] = (vertex[min][1] + 2 * vertex[max][1]) / 3;
	u = (max - min) / 2 + min;
	vertex[u][0] = vertex[s][0] + ((vertex[t][0] - vertex[s][0]) / 2 - (vertex[t][1] - vertex[s][1]) * 1.73205080 / 2);
	vertex[u][1] = vertex[s][1] + ((vertex[t][0] - vertex[s][0]) * 1.73205080 / 2 + (vertex[t][1] - vertex[s][1]) / 2);

	calc(vertex, deep - 1, min, s);
	calc(vertex, deep - 1, s, u);
	calc(vertex, deep - 1, u, t);
	calc(vertex, deep - 1, t, max);
}

Measured memory_bytes: 1416
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#define int long long
#define endl '\n'
#define INF 1000000000000000000
#define EPS 1e-10
#define PI 3.141592653589793238
#define all(a) a.begin(),a.end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define pb push_back
#define double long double
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<P, ll> PP;
typedef complex<double> com;
template<class T, class S> bool chmax(T &a, const S &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class S> bool chmin(T &a, const S &b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	//modcalc();

	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	sort(all(a));
	int ng = -1, ok = n;
	while (ok - ng > 1) {
		int mid = (ng + ok) / 2;
		bitset<10010> dp;
		dp[0] = 1;
		rep(i, n) if (i != mid && a[i] <= 5000) dp |= (dp << a[i]);
		bool flag = false;
		for (int i = max(0LL, k - a[mid]); i < k; i++) if (dp[i]) flag = true;
		if (flag) ok = mid;
		else ng = mid;
	}
	cout << ok << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  int N;
  cin >> N;
  vi B(N-1);
  vi A(N,INF);
  rep(i,N-1) {
    cin >> B[i];
  }
  rep(i,N-1) {
    A[i] = min(A[i],B[i]);
    A[i+1] = min(A[i+1],B[i]);
  }
  int sum = 0;
  rep(i,N) {
    sum += A[i];
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
// dile a la jardinera que traigo flores

#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define sz(x) int(x.size())
#define all(v) (v).begin(),(v).end()
#define trace(x) cout << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define FER(i,a,b) for(int i = int(a); i < int(b); ++i)
#define IFR(i,a,b) for(int i = int(a); i >= int(b); i--)
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;

int n,k;
string s;

int main(){	
	fastio;
	cin>>n>>k;
	cin>>s;
	int i=0,j=0;
	int tam=0;
	int num=0,ans=0;
	FER(i,0,n){
		//trace(i);
		//trace(tam);
		if(s[i]=='1')tam++;
		else{
			while(i<n&&s[i]=='0')i++,tam++;
			i--;
			num++;
		}
		if(num>k){
			while(s[j]=='1')tam--,j++;
			while(s[j]=='0')tam--,j++;
			num--;
		}
		ans=max(ans,tam);
	}
	cout<<ans<<endl;
	return 0;
}


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

int main(){
  int H1, M1, H2, M2, K;
  cin >> H1 >> M1 >> H2 >> M2 >> K;
  int a = H1 * 60 + M1, b = H2 * 60 + M2;
  
  cout << (b - K) - a << endl;
}


Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String N = in.next();
        int res = 0;

        for (int i = 1; i <= Integer.parseInt(N); i++)
            if (String.valueOf(i).length() % 2 == 1) res++;
        System.out.println(res);
    }
}


Measured memory_bytes: 28500
//use itertools::Itertools;
use std::cmp;
use std::collections::BTreeMap;
use std::collections::BTreeSet;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;
use std::io::Read;
use std::usize::MAX;

macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($r:tt)*) => {let stdin = std::io::stdin();let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));let mut next = move || -> String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()};input_inner!{next, $($r)*}};}
macro_rules! input_inner {($next:expr) => {};($next:expr, ) => {};($next:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($next, $t);input_inner!{$next $($r)*}};}
macro_rules! read_value {($next:expr, ( $($t:tt),* )) => {( $(read_value!($next, $t)),* )};($next:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()};($next:expr, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, usize1) => {read_value!($next, usize) - 1};($next:expr, [ $t:tt ]) => {{let len = read_value!($next, usize);(0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()}};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

fn solve() {
    input! {
        x: i64,
        k: i64,
        d: i64
    }

    let init_abs = x.abs();
    let pop = init_abs / d;

    let mut min = if x >= 0 { x - pop * d } else { x + pop * d };

    //println!("{} {} {}", init_abs, pop, k_min);

    if pop >= k {
        let k_min = if x >= 0 { x - k * d } else { x + k * d };
        println!("{}", k_min.abs());
    } else {
        let mut rest = (k - pop) % 2;
        if rest == 1 {
            if min > 0 {
                min -= d;
            } else {
                min += d;
            }
        }
        println!("{}", min.abs());
    }
}

fn main() {
    let thd = std::thread::Builder::new().stack_size(104_857_600);
    thd.spawn(|| solve()).unwrap().join().unwrap();

    /*
    // 入力を一括で読み込む場合
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut input = buf.split_whitespace();

    // inputに対しnext()で読み込んでいく
    let q: usize = input.next().unwrap().parse().unwrap();
    */
}

const LARGE_PRIME: u64 = 1_000_000_007;

// @〜でsnippet


Measured memory_bytes: 2244