akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <algorithm>
using namespace std;

int n,a[200005],l,r,mid,ans=0;

bool check(){
	int b[200005]={0};
	for(int i=1;i<=n;i++)
	if(a[i]>=mid)b[i]=1;
	else b[i]=0;
	int middle=(n+1)/2;
	int left=middle,right=middle;
	for(int i=0;i<middle;i++){
		if(b[left]==b[left-1]||b[right]==b[right+1])
		return b[left];
		left--;
		right++;
	}
	return b[1];
}

int main(void){
	scanf("%d",&n);
	n=n*2-1;
	l=n;
	r=0;
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		l=min(l,a[i]);
		r=max(r,a[i]);
	}
	while(l<=r){
		mid=(l+r+1)/2;
		if(check())
		l=mid+1,ans=max(ans,mid);
		else r=mid-1;
	}
	printf("%d",ans);
} 

Measured memory_bytes: 1792
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

#define MIN_INT -2147483648
#define MAX_INT 2147483647
#define MIN_LONG -9223372036854775808L
#define MAX_LONG 9223372036854775807L
#define PI 3.141592653589793238462643383279502884L

#define long long long int

using std::vector;
using std::map;
using std::set;
using std::string;
using std::pair;
using std::cin;
using std::cout;
using std::cerr;

// @author: pashka

long MOD;

long sum(long a, long b) { return (a + b) % MOD; }

long mult(long a, long b) { return (a * b) % MOD; }

int main() {
    std::ios::sync_with_stdio(false);

    int N, K;
    cin >> N >> K >> MOD;

    vector<vector<long>> q(N, vector<long>(N));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= i; j++) {
            if (i == j) {
                q[i][j] = 1;
            }
            if (j < i) {
                q[i][j] += q[i - 1][j];
            }
            if (i > 0 && j > 0) {
                q[i][j] += q[i - 1][j - 1];
            }
            q[i][j] %= MOD;
//            cout << q[i][j] << " ";
        }
//        cout << "\n";
    }


    vector<vector<long>> d(N + 1, vector<long>(K + 1));
    for (int n = 0; n <= N; n++) {
        for (int k = 0; k <= K; k++) {
            if (n == 0) {
                d[n][k] = 1;
            } else if (k == 0) {
                d[n][k] = 0;
            } else {
                d[n][k] = d[n][k - 1];
                for (int i = 0; i < n; i++) {
                    d[n][k] = sum(d[n][k],
                                  mult(d[n - i - 1][k],
                                       mult(d[i][k - 1], q[n - 1][i])));
                }
            }
//            cout << n << " " << k << " " << d[n][k] << "\n";
        }
    }
    cout << d[N][K];
    return 0;
}

Measured memory_bytes: 1664
N = int(input())
A = list(map(int,input().split()))
dp = [0] * N
dp[1] = abs(A[1] - A[0])

for i in range(2,N):
    dp[i] = min(dp[i-1] + abs(A[i] - A[i-1]),dp[i-2] + abs(A[i] - A[i-2]))

print(dp[N-1])

Measured memory_bytes: 13980
/***

            Bismillahir Rahmanir Rahim
            Read the name of Allah, who created you!!!
            Author : Shah Newaj Rabbi Shishir
            Department of CSE, City University, Bangladesh.

***/

#include <iostream>
#include <cctype>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <iterator>
#include <sstream>
#include <iomanip>
using namespace std;

#define sf scanf
#define pf printf

int main ()
{
    int a,b,sum;

    while (cin >> a >> b)
    {
        sum = a+b;

        int k = 0;

        while (sum != 0)
        {
            sum /= 10;
            k++;
        }

        cout << k << endl;
    }

    return 0;
}

Measured memory_bytes: 3108
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr = input.trim().split("\n");
while (true) {
   var n = arr.shift() - 0;
   if (n == 0) break;
   var Arr = arr.splice(0, n);
   Arr = Arr.map(function(v) {
      return v.length;
   });
   for (var i = 0; i < Arr.length; i++) {
      var good = [5, 7, 5, 7, 7];
      var sum = 0;
      for (var j = i; j < Arr.length; j++) {
         if (good.length == 0) break;
         sum += Arr[j];
         if (good[0] > sum) continue;
         else if (good[0] < sum) break;
         else if (good[0] == sum) {
            good.shift();
            sum = 0;
         }
      }
      if (good.length == 0) {
         console.log(i + 1);
         break;
      }
   }
}

Measured memory_bytes: 16820
#include<bits/stdc++.h>
using namespace std;
int h,w,d;
char c[4]={'R','Y','G','B'};
int main()
{
	scanf("%d%d%d",&h,&w,&d);
	for(int i=1;i<=h;i++,puts(""))
		for(int j=1;j<=w;j++)
		{
			int x=i+j+w,y=i-j+w;
			putchar(c[((x/d*2)&2)|((y/d)&1)]);
		}
	return 0;
}


Measured memory_bytes: 3768
main2(){
  int x,y,w,h,r,n,a,b;
  scanf("%d%d%d%d",&x,&y,&w,&h);
  for(r=0,scanf("%d",&n);n;n--){
    scanf("%d%d",&a,&b);
    if(x<=a&&a<=x+w && y<=b&&b<=y+h)r++;
  }
  printf("%d\n",r);
}
main(n){for(scanf("%d",&n);n--;)main2();exit(0);}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <cassert>
#include <cstring>
#include <vector>
#include <valarray>
#include <array>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <complex>
#include <random>
#include <bitset>
#include <stack>

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

using P = pair<int, int>;

using T = pair<P, int>;

vector<T> sv, tv;

const int W = 4040;
int dp[W][W][4][2];
bool used[W][W][4][2];

int solve(int i, int j, int k, int f) {
//    printf("%d %d %d %d\n", i, j, k, f);
    if (i == sv.size() and j == tv.size()) return 0;
    if (j == tv.size()) return 1<<28;
    k = min(k, tv[j].first.first+2);
    k = max(k, tv[j].first.first-1);
    int kf = k - (tv[j].first.first-1);
    if (used[i][j][kf][f+1]) return dp[i][j][kf][f+1];
    used[i][j][kf][f+1] = true;
    int &re = dp[i][j][kf][f+1];
    re = 1<<28;
    if (tv[j].second == 1) {
        re = min(re, solve(i, j+1, k, f));
    }
    if (i == sv.size()) return re;
    if (tv[j].first.first < sv[i].first.first) {
        int u = sv[i].first.first - tv[j].first.first;
        if (tv[j].first.first == sv[i-1].first.first && f != -1) {
            u--;
        }
        re = min(re, u + solve(i+1, j+1, sv[i].first.first, -1));
    } else if (sv[i].first.first < tv[j].first.first) {
        int u = tv[j].first.first - sv[i].first.first;
        if (sv[i].first.first == sv[i-1].first.first && f != -1) {
            u--;
        }
        re = min(re, u + solve(i+1, j+1, tv[j].first.first, -1));
    } else {
        if (sv[i].first.second == tv[j].first.second) {
            re = min(re, solve(i+1, j+1, k, -1));
        } else {
            if ((f == -1 || sv[i-1].first.second != sv[i].first.second) && tv[j].first.first <= k) {
                re = min(re, solve(i+1, j+1, k, -1));
            } else {
                re = min(re, 1+solve(i+1, j+1, sv[i].first.first+1, 0));
            }
        }
    }
    return re;
}

int main() {
    int w;
    cin >> w;
    for (int i = 0; i < 2; i++) {
        string s;
        cin >> s;
        for (int j = 0; j < w; j++) {
            if (s[j] == 'o') {
                sv.push_back(T(P(j, i), 0));
            }
        }
    }

    for (int i = 0; i < 2; i++) {
        string s;
        cin >> s;
        for (int j = 0; j < w; j++) {
            if (s[j] == 'o') {
                tv.push_back(T(P(j, i), 0));
            } else if (s[j] == '*') {
                tv.push_back(T(P(j, i), 1));
            }
        }
    }
    sort(sv.begin(), sv.end());
    sort(tv.begin(), tv.end());
//    cout << sv.size() << " " << tv.size() << endl;
    cout << solve(0, 0, -1, -1) << endl;
    return 0;
}

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

int main() {
  int n; cin>>n;
  int ans = 100;
  rep(i, n) {
    int a; cin>>a;
    int d=0;
    while (a%2==0) {
      a/=2;
      d++;
    }
    ans = min(ans, d);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
static const int N = 100;
static const int INFTY = (1<<21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n,M[N][N],d[N];

void dijkstra(int s){
	int color[N],p[N];
	for(int i=0;i<n;i++){
		color[i] = WHITE;
		d[i] = INFTY;
	}
	d[s] = 0;
	p[s] = -1;

	int u;
	while(1){
		int minv = INFTY;
		for(int i=0;i<n;i++){
			if(color[i]!=BLACK&&d[i]!=INFTY){
				if(d[i] < minv){
					minv = d[i];
					u = i;
				}
			}
		}
		if(minv == INFTY)break;
		color[u] = BLACK;
		for(int i=0;i<n;i++){
			if(color[i]!=BLACK&&M[u][i]!=INFTY){
				if(d[u]+M[u][i] < d[i]){
					d[i] = d[u]+M[u][i];
					p[i] = u;
				}
			}
		}
	}
}

int main(){
	cin >> n;
	int e,u,k,c,v;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			M[i][j] = INFTY;
		}
	}
	for(int i=0;i<n;i++){
		cin >> u >> k;
		for(int j=0;j<k;j++){
			cin >> v >> c;
			M[i][v] = c;
		}
	}
	dijkstra(0);
	for(int i=0;i<n;i++){
		cout << i << " " << d[i] << endl;
	}
	return 0;
}



Measured memory_bytes: 3104
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <random>
#include <cmath>
#include <chrono>
#include <cstring>
#include <algorithm>
#include <string>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
using namespace std;
using LL = long long;
#define eps 1e-8
#define fi first
#define se second
#define eb emplace_back
#define close std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define FOR(i, x, y) for (LL i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) for (LL i = (x), _##i = (y); i > _##i; --i)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define CASET int ___T; scanf("%d", &___T); for(int __CS=1;__CS<=___T;__CS++)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
mt19937 dlsrand(random_device{}());
mt19937 mrand(std::chrono::system_clock::now().time_since_epoch().count()); 
int rnd(int x) { return mrand() % x;}
LL bin(LL x, LL n, LL MOD) {LL ret = MOD != 1;for (x %= MOD; n; n >>= 1, x = x * x % MOD)if (n & 1) ret = ret * x % MOD;return ret;}
inline LL get_inv(LL x, LL p) { return bin(x, p - 2, p); }
const int maxn = 1e6+10;
const int INF = 0x3f3f3f3f;
const ll linf = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1.0);
ll mod = 1e9+7;
int a[maxn];
int main()
{
    int n ;
    cin >> n;
    for(int i = 0; i < n ; i++){
        cin >> a[i];
    }
    ll ans = 0;
    int l = 0, val = 0;
    for(int r = 0; r < n ; r++){
        while(val & a[r]){
            val ^= a[l];
            l++;
        }
        val ^= a[r];
        ans += r - l + 1;
    } cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>

using namespace std;

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

long long int INF = 3e18;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←


#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(15)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl


long long int mod = 4294967296;
ll rui(ll number1,ll number2){
    //abcのbed乗を計算する
    if(number2 == 0){return 1;}
    else{
        ll number3 = rui(number1,number2/2);
        number3 *= number3;
        number3 %= mod;
        if(number2 % 2 == 1){number3 *= number1; number3 %= mod;}
        return number3;
    }
}
ll gcd(ll number1,ll number2){
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}

ll n,m,num,sum,ans,a,b,c,d,e,f,g,h,i,j,k,w,ok,ng,res,q;
ll x[500005],y[500005],z[500005];
ll dp[5005][5005][3];
char s[500005];
bool flag,dame;

int main(){
    cin >> n;
	dame = false;
	ll na = 0,nb = 0,nc = 0;
	for(i=0;i<n;i++){
		cin >> c >> a >> b;
		if(abs(na-a) + abs(nb - b) > c - nc)dame = true;
		if((abs(na-a) + abs(nb-b) - (c - nc) + INF) % 2 == 1)dame = true;
		na = a;
		nb = b;
		nc = c;
	}
	Yes(!dame);

	return 0;
}

Measured memory_bytes: 24960
import math


A_B_H_M = input().split(" ")
A = int(A_B_H_M[0])
B = int(A_B_H_M[1])
H = int(A_B_H_M[2])
M = int(A_B_H_M[3])

H_angle = (2 * math.pi) * (60 * H + M) / 720
M_angle = (M / 60) * 2 * math.pi

theta = H_angle - M_angle
if theta >= 180:
  theta = theta - 180
 
ans = math.sqrt((B**2 + A**2) - (2*B*A*math.cos(theta)))
print(ans)  
  
  



Measured memory_bytes: 9504
#include <bits/stdc++.h>
#define FOR(i,s,e) for(int i=(s);i<(e);i++)
#define REP(i,n) FOR(i,0,n)
#define all(v) (v).begin(),(v).end()
#define pb(a) push_back(a)
using namespace std;
typedef long long LL;
typedef pair<int, int> P;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    vector<LL> a(n+1), b(n+1);
    a[0]=0; b[0]=0;
    REP(i, n){
        cin >> a[i+1];
        b[i+1] = (a[i+1]>0 ? a[i+1]:0);
    }
    REP(i, n){
        a[i+1] += a[i];
        b[i+1] += b[i];
    }
    LL ans = -1;
    for(int i=0; i+k<=n; i++){
        ans = max(ans, b[n]-b[i+k]+b[i]+max(0LL, a[i+k]-a[i]));
        // cout << b[i+k]-b[i] << endl;
    }
    cout << ans << endl;
}


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

int main()
{
  int a, b, d, r;
  double f;
  cin >> a >> b;

  d = a / b;
  r = a % b;
  f = (double)a / (double)b;

  printf("%d %d %lf\n", d, r, f);
  return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
int main() {
  	int n; cin >> n;
	set<char> s;
	for (int i = 0; i < n; ++i) {
		char t; cin >> t;
		s.insert(t);
	}
	cout << (s.size() == 3?"Three":"Four");
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define ll long long
using namespace std;

int main()
{
	ll a, b, k;
	cin >> a >> b >> k;

	ll ra = max(a - k, 0LL);
	ll rb = b;
	if (ra == 0) {
		rb = max(b - (k - a), 0LL);
	}

	cout << ra << " " << rb << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        MyPriorityQueue<Integer> queue = new MyPriorityQueue<>();
        while (true){
            String order = input.next();
            if(order.equals("end")){
                break;
            }else {
                if(order.equals("insert")){
                    int num = input.nextInt();
                   queue.enqueue(num);
                }else {
                    System.out.println(queue.dequeue());
                }
            }
        }
    }
}

class Heap<E extends Comparable<E>> {
    private ArrayList<E> list = new ArrayList<>();

    Heap() {
    }


    void add(E newObject){
        list.add(newObject);  //添加到堆中
        int currentIndex = list.size() - 1;  //获得最后一个节点的下标

        while (currentIndex > 0){
            int parentIndex = (currentIndex - 1) / 2;
            //如果当前节点大于父节点，交换
            if(list.get(currentIndex).compareTo(list.get(parentIndex)) > 0){
                E temp = list.get(currentIndex);
                list.set(currentIndex,list.get(parentIndex));
                list.set(parentIndex,temp);
            }else {
                break;  //二叉堆建立了成功
            }

            currentIndex = parentIndex;
        }
    }

    E remove(){
        if(list.size() == 0){
            return null;
        }

        E removeObject = list.get(0);
        list.set(0,list.get(list.size() - 1));
        list.remove(list.size() - 1);

        int currentIndex = 0;
        while (currentIndex < list.size()){
            int leftChildIndex = 2 * currentIndex + 1;
            int rightChildIndex = 2 * currentIndex + 2;
            //Find the maximum between two children
            if(leftChildIndex >= list.size()){
                break;
            }
            int maxIndex = leftChildIndex;
            if(rightChildIndex < list.size()){
                if(list.get(maxIndex).compareTo(list.get(rightChildIndex)) < 0){
                    maxIndex = rightChildIndex;
                }
            }

            //如果现在的节点小于，交换
            if(list.get(currentIndex).compareTo(list.get(maxIndex)) < 0){
                E temp = list.get(maxIndex);
                list.set(maxIndex,list.get(currentIndex));
                list.set(currentIndex,temp);
                currentIndex = maxIndex;
            }else {
                break;
            }
        }

        return removeObject;
    }

//    int getSize(){
//        return list.size();
//    }
}

class MyPriorityQueue<E extends Comparable<E>>{
    private Heap<E> heap = new Heap<>();

    void enqueue(E newObject){
        heap.add(newObject);
    }

    E dequeue(){
        return heap.remove();
    }

//    public int getSize(){
//        return heap.getSize();
//    }
}



Measured memory_bytes: 582164
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi >
#define vvvi vector<vvi >
#define pii pair<int,int>
#define INF (int)1e9
#define MOD (int)1e9+7
typedef long long llong;
using namespace std;

int main(){
	int n;
	cin>>n;
	
	vector<pii > ba(n);
	
	REP(i,n){
		int a,b;
		cin>>a>>b;
		ba[i]=make_pair(b,a);
	}
	
	sort(ALL(ba));
	//REP(i,n) cout<<ba[i].first<<ba[i].second<<endl;
	
	llong now=0;
	bool jud=true;
	REP(i,n){
		now+=ba[i].second;
		if(now>ba[i].first){
			jud=false;
			break;
		}
	}
	
	if(jud) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 1792
#include<stdio.h>
int main(){
 int X[3000],Y[3000];
 int temp,i,j;

 for(i=0;i<3000;i++){
  scanf("%d %d\n",&X[i],&Y[i]);
  
  if(X[i]>Y[i]){
   temp=X[i];
   X[i]=Y[i];
   Y[i]=temp;
  }

  if(X[i]==0 && Y[i]==0){
   j=i;
   break;
  }
  }

 for(i=0;i<=j-1;i++){
  printf("%d %d\n",X[i],Y[i]);
 }

return 0;
}

  

Measured memory_bytes: 628
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <fstream>
#include <cstdlib>
#include <ctime>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <tuple>
#include <climits>
#include <unordered_map>

using namespace std;

//int X[100000], Y[100000];
//
//void solve() {
//    int P, Q, x, y;
//    char d;
//    cin>>P>>Q;
//    memset(X, 0, sizeof(X));
//    memset(Y, 0, sizeof(Y));
//    for (int i=0; i<P; i++) {
//        cin>>x>>y>>d;
//        if (d == 'N') for (int j= y+1; j<=Q; j++) Y[j]++;
//        if (d == 'S') for (int j= 0; j<y; j++) Y[j]++;
//        if (d == 'E') for (int j= x+1; x<=Q; j++) X[j]++;
//        if (d == 'W') for (int j= 0; j<x; j++) X[j]++;
//    }
//    int ans = 0;
//    for (int i=0; i<=Q; i++) {
//        if (X[i])
//    }
//
//}



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

    int n, a = 0, b = 0, ba = 0, ans = 0;
    string s;
    for (cin>>n; n; n--) {
        cin>>s;
        for (int i=0; i+1<s.length(); i++) {
            if (s.substr(i,2) == "AB") ans++;
        }
        if (s[0] == 'B') b++;
        if (s[s.length()-1] == 'A') a++;
        if (s[0] == 'B' && s[s.length()-1] == 'A') ba++;
    }
    if (a && a == ba && b == ba) ans += a - 1;
    else ans += min(a, b);
    cout<<ans<<endl;

//    int T;
//    cin>>T;
//    for (int t=1; t<=T; t++) {
//        cout<<"Case #"<<t<<": ";
//        solve();
//    }
    return 0;
}

Measured memory_bytes: 256
#define DEBUG 0

#include <bits/stdc++.h>
using namespace std;

#if DEBUG
// basic debugging macros
int __i__,__j__;
#define printLine(l) for(__i__=0;__i__<l;__i__++){cout<<"-";}cout<<endl
#define printLine2(l,c) for(__i__=0;__i__<l;__i__++){cout<<c;}cout<<endl
#define printVar(n) cout<<#n<<": "<<n<<endl
#define printArr(a,l) cout<<#a<<": ";for(__i__=0;__i__<l;__i__++){cout<<a[__i__]<<" ";}cout<<endl
#define print2dArr(a,r,c) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<a[__i__][__j__]<<" ";}cout<<endl;}
#define print2dArr2(a,r,c,l) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<setw(l)<<setfill(' ')<<a[__i__][__j__]<<" ";}cout<<endl;}

// advanced debugging class
// debug 1,2,'A',"test";
class _Debug {
    public:
        template<typename T>
        _Debug& operator,(T val) {
            cout << val << endl;
            return *this;
        }
};
#define debug _Debug(),
#else
#define printLine(l)
#define printLine2(l,c)
#define printVar(n)
#define printArr(a,l)
#define print2dArr(a,r,c)
#define print2dArr2(a,r,c,l)
#define debug
#endif

// define
#define MAX_VAL 999999999
#define MAX_VAL_2 999999999999999999LL
#define EPS 1e-6
#define mp make_pair
#define pb push_back

// typedef
typedef unsigned int UI;
typedef long long int LLI;
typedef unsigned long long int ULLI;
typedef unsigned short int US;
typedef pair<int,int> pii;
typedef pair<LLI,LLI> plli;
typedef vector<int> vi;
typedef vector<LLI> vlli;
typedef vector<pii> vpii;
typedef vector<plli> vplli;

// ---------- END OF TEMPLATE ----------

LLI A[200];
char S[200];

// from https://codeforces.com/blog/entry/68953
const int d = 62;
LLI basis[d]; // basis[i] keeps the mask of the vector whose f value is i

int sz; // Current size of the basis

int insertVector(LLI mask) {
    for (int i = 0; i < d; i++) {
        if ((mask & 1LL << i) == 0) continue; // continue if i != f(mask)

        if (!basis[i]) { // If there is no basis vector with the i'th bit set, then insert this vector into the basis
            basis[i] = mask;
            ++sz;

            return 1;
        }

        mask ^= basis[i]; // Otherwise subtract the basis vector from this vector
    }
    return 0;
}
int main() {
    int i;
    int T,N;
    scanf("%d",&T);
    while (T--) {
        scanf("%d",&N);
        for (i = 0; i < N; i++) scanf("%lld",&A[i]);
        for (i = 0; i < N; i++) scanf(" %c",&S[i]);

        sz = 0;
        int f = 0;
        memset(basis,0,sizeof(basis));
        for (i = N-1; i >= 0; i--) {
            if (S[i] == '0') insertVector(A[i]);
            else if (insertVector(A[i])) {
                f = 1;
                break;
            }
        }
        printf("%d\n",f);
    }

    return 0;
}



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

int main(){
   int a,b,c,d;
   d = 0;
   cin >> a >> b >> c;
   while (a <= b){
      if (c % a == 0){
         d = d+1;
      }
      a = a+1;
   }
   cout << d <<endl;
   return 0;
}

Measured memory_bytes: 3088
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <vector>
using namespace std;
typedef long long ll;
int main() {

	ll n;
	cin>>n;

	if(n%11>6){
		cout<<n/11*2+2<<endl;
	}else if(n%11==0){
		cout<<n/11*2<<endl;
	}else{
		cout<<n/11*2+1<<endl;
	}

	return 0;
}


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

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    char c;
    cin >> c;
    if (c == 'Y') {
      cout << "Four" << endl;
      return 0;
    }
  }
  cout << "Three" << endl;
}


Measured memory_bytes: 256
#include <vector> 
#include <list> 
#include <map> 
#include <set> 
#include <deque> 
#include <queue> 
#include <stack> 
#include <bitset> 
#include <algorithm> 
#include <functional> 
#include <numeric> 
#include <utility> 
#include <sstream> 
#include <iostream> 
#include <iomanip> 
#include <cstdio> 
#include <cmath> 
#include <cstdlib> 
#include <cctype> 
#include <string> 
#include <cstring> 
#include <ctime> 

using namespace std;

#define _int64 long long

int p[210000];
vector<int> a[210000];
vector<int> a1[210000];
int cnt[210000];
int v[210000];
int used[210000];

int main()
{
  vector<int> poss;
  int i,j,k,n,now,tmp,last,x;
  vector<int> q;
  scanf("%d",&n);
  for (i=0;i<n;i++)
    a[i].clear();
  memset(cnt,0,sizeof(cnt));
  for (i=0;i<n;i++)
  {
    scanf("%d",&p[i]);
    p[i]--;
    cnt[p[i]]++;
  }
  memset(used,0,sizeof(used));
  q.clear();
  for (i=0;i<n;i++)
    if (cnt[i]==0)
    {
      q.push_back(i);
      used[i]=1;
    }
  for (i=0;i<q.size();i++)
  {
    x=q[i];
    sort(a[x].begin(),a[x].end());
    a[x].erase(unique(a[x].begin(),a[x].end()),a[x].end());
    for (j=0;j<a[x].size();j++)
      if (a[x][j]!=j) break;
    v[x]=j;
    cnt[p[x]]--;
    a[p[x]].push_back(v[x]);
    if (cnt[p[x]]==0)
    {
      q.push_back(p[x]);
      used[p[x]]=1;
    }
  }
  for (i=0;i<n;i++)
    if (used[i]==0)
    {
      //cout<<i<<endl;
      sort(a[i].begin(),a[i].end());
      a[i].erase(unique(a[i].begin(),a[i].end()),a[i].end());
      now=0;
      poss.clear();
      a[i].push_back(2000000000);
      for (j=0;j<a[i].size();j++)
        if (a[i][j]!=now)
        {
          poss.push_back(now);
          now++;
          if (poss.size()==2) break;
          j--;
        }
        else now++;
      for (j=0;j<n;j++)
        a1[j]=a[j];
      //cout<<poss.size()<<endl;
      //cout<<poss[0]<<" "<<poss[1]<<endl;
      for (j=0;j<poss.size();j++)
      {
        for (k=0;k<n;k++)
          a[k]=a1[k];
        v[i]=poss[j];
        a[p[i]].push_back(v[i]);
        tmp=p[i];
        while (tmp!=i)
        {
          sort(a[tmp].begin(),a[tmp].end());
          a[tmp].erase(unique(a[tmp].begin(),a[tmp].end()),a[tmp].end());
          for (k=0;k<a[tmp].size();k++)
            if (a[tmp][k]!=k) break;
          v[tmp]=k;
          a[p[tmp]].push_back(v[tmp]);
          last=v[tmp];
          tmp=p[tmp];
        }
        if ((j==0)&&(last!=poss[j]))
        {
          printf("POSSIBLE\n");
          return 0;
        }
        if ((j==1)&&(last==poss[0]))
        {
          printf("POSSIBLE\n");
          return 0;
        }
      }
      printf("IMPOSSIBLE\n");
      return 0;
    }
  printf("POSSIBLE\n");
  return 0;
}

Measured memory_bytes: 19828
fun main(args:Array<String>) {
    var n = readLine()!!.toInt()
    var a = readLine()!!.split(" ").map {it.toInt()}
 
    var res = 0
 
    for(i in 0..(n-1)) {
        if (a[a[i]-1]-1 == i) {
            res++
        }
    }
 
    println(res/2)
}

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

int main() {
  int n, k, c;
  cin >> n >> k >> c;
  string s;
  cin >> s;
  auto getPositions = [&]() {
    vector<int> res;
    for (int i = 0; i < n && res.size() < k;) {
      if (s[i] == 'o') {
        res.push_back(i);
        i += c+1;
      } else {
        ++i;
      }
    }
    return res;
  };
  vector<int> l, r;
  l = getPositions();
  reverse(s.begin(),s.end());
  r = getPositions();
  rep(i,k) r[i] = n-1-r[i];
  reverse(s.begin(),s.end());

  vector<int> lastL(n+1, -1);
  rep(i,k) lastL[l[i]+1] = i;
  rep(i,n) {
    if (lastL[i+1] == -1) lastL[i+1] = lastL[i];
  }
  vector<int> lastR(n+1, -1);
  rep(i,k) lastR[r[i]] = i;
  for (int i = n-1; i >= 0; --i) {
    if (lastR[i] == -1) lastR[i] = lastR[i+1];
  }

  rep(i,n) {
    if (s[i] == 'x') continue;
    int li = lastL[i];
    int ri = lastR[i+1];
    int cnt = 0;
    if (li != -1) cnt += li+1;
    if (ri != -1) cnt += ri+1;
    if (li != -1 && ri != -1 && r[ri]-l[li] <= c) {
      //--cnt;
    }
    if (cnt >= k) continue;
    printf("%d\n", i+1);
  }
  return 0;
}


Measured memory_bytes: 6556
#include<stdio.h>
#define k 10000
void CountingSort(int*,int*,int);
int main(){

  int i;
  int n;

  scanf("%d",&n);
  int A[n+1],B[n+1];
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  CountingSort(A,B,n);
  for(i=1;i<=n;i++){
    if(i==n) printf("%d\n",B[i]);
    else printf("%d ",B[i]);
  }
  return 0;
}

void CountingSort(int *A,int *B,int n){

  int i;
  int C[k+1];

  for(i=0;i<=k;i++) C[i]=0;
  for(i=0;i<n;i++) C[A[i]]++;
  for(i=1;i<=k;i++) C[i]+=C[i-1];
  for(i=n-1;i>=0;i--){
    B[C[A[i]]]=A[i];
    C[A[i]]--;
  }
}



Measured memory_bytes: 17516
#include<stdio.h>
int main(void)
{


int W,H,x,y,r;

scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);




if(x+r<=W && x-r>=0){

	if(y+r<=H && y-r>=0){

printf("Yes\n");

}

else{

printf("No\n");

}

}
else{

printf("No\n");

}

return 0;
}


Measured memory_bytes: 2108
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            li = []
            while self.parents[x] >= 0:
                li.append(x)
                x = self.parents[x]
            for y in li:
                self.parents[y] = x
            return x

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

import sys
input = sys.stdin.buffer.readline
N,Q = map(int,input().split())
uf = UnionFind(N)
for i in range(Q):
    t,u,v = map(int,input().split())
    if t == 0:
        uf.union(u,v)
    else:
        if uf.same(u,v):
            print(1)
        else:
            print(0)


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

ans = 0
last_a = 0
first_b = 0
cnt = 0

for i in range(n):
    s = input()
    ans += s.count("AB")
    if s[-1] == "A":
        last_a += 1
    if s[0] == "B":
        first_b += 1
    if s[-1] == "A" and s[0] == "B":
        cnt += 1

if last_a == first_b & cnt > 0:
    ans += min(last_a, first_b) - 1
else:
    ans += min(last_a, first_b)

print(ans)

Measured memory_bytes: 3064
import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.regex.*;


public class Main {

    public static void main(String[] args) {
    
    	FastScanner scan = new FastScanner();
    	String str = scan.next();
    	if(str.equals("ABC")) System.out.println("ARC");
    	else System.out.println("ABC");
    }

   
    static class FastScanner{
    	
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    	StringTokenizer st = new StringTokenizer("");
    	String next() {
    		while(!st.hasMoreTokens())
    			try {
    				st = new StringTokenizer(br.readLine());
    			} catch (IOException e){
    				e.printStackTrace();
    			}
    		return st.nextToken();
    	}
    	
    	int nextInt() {
    		return Integer.parseInt(next());
    	}
    	
    	int [] readArray(int n) {
    		int [] a = new int[n];
    		for(int i=0; i<n ; i++) a[i] = nextInt();
    		return a;
    	}
    	
    	long nextLong() {
    		return Long.parseLong(next());
    	}
    	
    	
    }
    
   
}



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

int main(){
  int k,a,b;
  cin>>k>>a>>b;
  for(int i=a;i<=b;i++){
    if(i%k == 0){
      cout << "OK";
      return 0;
    }
  }
  cout << "NG";
}

Measured memory_bytes: 3636
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())




int N, K;
int p[200000];

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


	cin >> N >> K;
	rep(i,N) {
		cin >> p[i];
	}


	double ma = 0, s = 0;
	rep(i, K)s += (p[i] + 1) / 2.0;
	ma = s;

	for (int i = K; i < N;i++) {
		s -= (p[i - K] + 1) / 2.0;
		s += (p[i] + 1) / 2.0;
		ma = max(ma, s);
	}

	printf("%.6f\n", ma);


	return 0;
}

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

#define all(x) x.begin(),x.end()
#define pb(x) emplace_back(x)
#define forn(i,N) for(int i=0;i<N;i++)

using namespace std;
using ll=long long int;
using ld=long double;

int main() {
//freopen("input.txt","rt",stdin);
ios::sync_with_stdio(false);
cin.tie(nullptr);

ll N;
cin>>N;
string arr[4]={"AC","WA","TLE","RE"};
map<string,int> m;
forn(i,N) {
  string s;
  cin>>s;
  m[s]++;
}
forn(i,4) {
  cout<<arr[i]<<" x "<<m[arr[i]]<<endl;
}
return 0;
}


Measured memory_bytes: 3660
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
template <class T> T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T> T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T> T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T> T lcm(T a, T b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll x;
    cin >> x;
    ll res = x / 11 * 2;
    x %= 11;
    if (x > 0) {
        x -= 6;
        res++;
    }
    if (x > 0) {
        x -= 5;
        res++;
    }
    cout << res << endl;
    return 0;
}


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

# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
 
template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

inline void Input_Output () {
	//freopen(".in", "r", stdin);
   //freopen(".out", "w", stdout);
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n, m, k;
int cnt[N];
string s;
int a[N];
vector < int > g[N];
int u[N];
int ans, res;
int cur;



int main () {
	SpeedForce;
	ll x, y;
	cin >> x >> y;
	cout << (abs(x - y) <= 1 ? "Brown\n" : "Alice\n");	
   	return Accepted;
}

// B...a

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

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

int main(){
  vector<int> A;
  A.reserve(100);

  int N, a;
  cin >> N;
  while(N--){
    cin >> a;
    A.push_back(a);
  }

  trace(A);

  for(int i = 1; i < A.size(); i++){
    int v = A[i];
    int j = i - 1;
    while(j >= 0 && A[j] > v){
      A[j + 1] = A[j];
      j--;
    }
    A[j + 1] = v;
    trace(A);
  }
}


Measured memory_bytes: 3096
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>
#include<string.h>
#include<math.h>

typedef int32_t i32;
typedef int64_t i64;

#define MAX(a,b) ((a) > (b) ? (a) : (b))
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#define ABS(a) ((a) > (0) ? (a) : -(a))
#define ALLOC(size,type) ((type*) calloc ((size), sizeof (type)))

#define POS(i, j) ((i) * w + (j))

void run (void) {
  i32 h, w;
  scanf ("%" SCNi32 "%" SCNi32, &h, &w);
  char *s = ALLOC (h * w + 1, char);
  for (i32 i = 0; i < h; ++i) {
    scanf ("%s", s + i * w);
  }
  i32 *q = ALLOC (h * w, i32);
  i32 *d = ALLOC (h * w, i32);
  for (i32 i = 0; i < h * w; ++i) {
    d[i] = h * w;
  }
  i32 front = 0;
  i32 last = 0;
  for (i32 i =0; i < h * w; ++i) {
    if (s[i] == '%') {
      q[last++] = i;
      d[i] = 0;
    }
  }
  while (front < last) {
    i32 v = q[front++];
    i32 x = v / w;
    i32 y = v % w;
    i32 dir[4] = {1, 0, -1, 0};
    for (i32 i = 0; i < 4; ++i) {
      i32 nx = x + dir[i];
      i32 ny = y + dir[i ^ 1];
      if (!(0 <= nx && nx < h && 0 <= ny && ny < w && s[POS(nx, ny)] != '#' && d[POS(nx, ny)] > d[v] + 1)) continue;
      d[POS(nx, ny)] = d[v] + 1;
      q[last++] = POS(nx, ny);
    }
  }
  i32 p = h * w;
  i32 t = h * w;
  for (i32 i = 0; i < h * w; ++i) {
    if (s[i] == '@') {
      p = d[i];
    } else if (s[i] == '$') {
      t = MIN(t, d[i]);
    }
  }
  puts (p < t ? "Yes" : "No");
}

int main (void) {
  run();
  return 0;
}



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

using namespace std;

int gcd(int x, int y) {
    if (x % y == 0) {
        return y;
    }
    return gcd(y, x % y);
}

long long lcm(long long x, long long y) {
    return x/gcd(x, y)*y;
}

long long num_not_div(long long x, int div0, int div1) {
    long long t0 = x / div0;
    long long t1 = x / div1;
    long long t2 = x / lcm(div0, div1);
    return x - (t0 + t1 - t2);
}

int main() {
    long long a, b;
    int c, d;

    cin >> a >> b >> c >> d;

    cout << num_not_div(b, c, d) - num_not_div(a-1, c, d) << endl;
    return 0;
}


Measured memory_bytes: 256
#n桁のるんるん数のrisutoを求める
import sys

sys.setrecursionlimit(10**9)

from functools import lru_cache
@lru_cache(maxsize=None)

def runrun(n):
    if n == 1:
        return [['1','2','3','4','5','6','7','8','9']]
    else:
        li = runrun(n-1)
        li2 = []
        for i in range(len(li[n-2])):
            p = int(li[n-2][i][-1])
            if p == 0:
                li2.append(li[n-2][i]+'0')
                li2.append(li[n-2][i]+'1')
            elif p == 9:
                li2.append(li[n-2][i]+str(8))
                li2.append(li[n-2][i]+'9')
            else:
                li2.append(li[n-2][i]+str(p-1))
                li2.append(li[n-2][i]+str(p))
                li2.append(li[n-2][i]+str(p+1))
        li2 =[li2]
        li.extend(li2)
        return li
    


x = int(input())
t = True
k=1
b = 0
while t:
    a = runrun(k)
    b = 0
    #k桁までに何個るんるん数があるか数えるもの
    for i in range(len(a)):
        b+=(len(a[i]))
        #k桁ということが確定したあと以下の処理を行う
    if x <= b:
        t = False
        if k == 1:
            print(x)
        else:
            tmp = runrun(k-1)
            c = 0
#まずk-1桁までのるんるん数の数を数える
            for i in range(len(tmp)):
                c += (len(tmp[i]))
            s = a[k-1][x-c-1]
            print(int(s))
    else:
        k += 1


Measured memory_bytes: 17820
A,B,C,D,E,F=map(int,input().split())
def solve(a,b):
    return 100*b<=E*a
def contain(a,b):
    return 0<a+b<=F
water = []
for i in range(30):
    for j in range(30):
        if 0 < 100*A*i+100*B*j <= F:
            water.append(100*A*i+100*B*j)
sugar = []
for i in range(3000):
    for j in range(3000):
        if C*i + D*j <= F:
            sugar.append(C*i + D*j)
        else:
            break
sugar.sort()
water.sort()
cand=[]
for s in sugar:
    for w in water:
        if contain(w,s):
            if solve(w,s):
                cand.append((w+s,s))
        else:
            break
cand.sort(key=lambda x:x[1]/x[0],reverse=True)
print(*cand[0])

Measured memory_bytes: 112392
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int LL;
typedef long double dd;
//#define i_7 (ll)(1E9+7)
#define i_7 998244353
#define i_5 i_7-2

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
//template<class T>void max(T a,T b){if(a<b)return b;else return a;}
//template<class T>void min(T a,T b){if(a>b)return b;else return a;}
//template<class T>bool Max(T&a, T b){if(a < b){a = b;return 1;}return 0;}
//template<class T>bool Min(T&a, T b){if(a > b){a = b;return 1;}return 0;}

//////////////////////////

int main(){fastio
    ll n;cin>>n;
    ll a[n+1];memset(a,0,sizeof(a));
    rep(i,2,n){
        ll c;cin>>c;
        a[c]++;
    }
    rep(i,1,n)cout<<a[i]<<endl;
    
    
    
    return 0;
}


Measured memory_bytes: 5208
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 9e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b){a=b; return true;} return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){a=b; return true;} return false; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

class ATakAndHotelsABCEdit {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    int n, k, x, y;
	    in >> n >> k >> x >> y;
	    int res = 0;
	    if(k <= n){
            res = k*x + (n-k)*y;
	    }else{
	        res = n*x;
	    }

	    out << res << endl;
	}
};


int main() {
	ATakAndHotelsABCEdit solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
from operator import mul
 
n = int(input())
cof = [1 << x for x in range(10)]

fs = [sum(map(mul, map(int, input().split()), cof)) for _ in range(n)]
ps = [list(map(int, input().split())) for _ in range(n)]
ans = float('-inf')
for g in range(1, 1024):
    sum=0
    for f, p in zip(fs, ps):
        tmp2=bin(f & g).count('1')
        sum+=p[tmp2]
  
    #tmp=sum(p[bin(f & g).count('1')] for f, p in zip(fs, ps))
    #ans = max(ans, tmp)
    ans = max(ans, sum)

print(ans)

Measured memory_bytes: 3188
import sys

# バリデーション
# ルール１：同じ桁数に複数の値を割り当てることはできない
# ルール２：一桁目に０は入れることができない
def check_sets():
  check_lists = {}
  if [1, 0] in sets and N > 1:
    return True
  for a,b in sets:
    if a not in check_lists:
      check_lists[a] = b
    else:
      if check_lists[a] != b:
        return True
  return False

N, M = list(map(lambda x: int(x), input().split()))
ans_strs = ['0' for _ in range(N)]
if N != 1 :
  ans_strs[0] = '1'

sets = []
for _ in range(M):
  sets.append(list(map(lambda x: int(x), input().split())))

is_bad = check_sets()
if is_bad:
  print(-1)
  sys.exit()

for index,number in sets:
  ans_strs[index - 1] = str(number)

answer = int(''.join(ans_strs))
print(answer)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep2(i,a,n) for(int i = (a);i < (n);i++)
#define rep(i,n) rep2(i,0,n)
#define INF (1LL << 60)

int main(void){
    int n;
    cin >> n;
    string s[n];
    map<string,int> mp;
    rep(i,n){
        cin >> s[i];
        sort(s[i].begin(),s[i].end());
        mp[s[i]]++;
    }
    
    ll ans = 0;
    for(auto p:mp){
        if(p.second <= 0)continue;
        for(int i = 1;i < p.second;i++)ans += i; 
    }
    
    cout << ans << endl;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  sort(A.begin(), A.end());
  cout << A[N - 1] - A[0] << endl;
  return 0;
}


Measured memory_bytes: 256