akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
struct tree{
  int id;
  int left;
  int right;
  int p;
};
struct tree num[25];

//Preorder
void Preorder(int u){
  if(u!=-1){
    printf(" %d",u);
    Preorder(num[u].left);
    Preorder(num[u].right);
  }
}

//Inorder
void Inorder(int u){
  if(u!=-1){
    Inorder(num[u].left);
    printf(" %d",u);
    Inorder(num[u].right);
  }
}

//Postorder
void Postorder(int u){
  if(u!=-1){
    
    Postorder(num[u].left);
    Postorder(num[u].right);
    printf(" %d",u);
  }
}

int main(){
  int in,n,i,si1,si2,pa;

  scanf("%d",&n); //???????????°?????\???

  //????????????????????????????¨??????????
  for(i=0;i<n;i++){
    num[i].p=-1;
  }

 
  //???????????????????¨????
  for(i=0;i<n;i++){
    scanf("%d ",&in);
    num[in].id=in;

    scanf("%d %d",&num[in].left,&num[in].right);
    
    if(num[in].left==-1 && num[in].right==-1) continue;
   
    else if(num[in].left !=-1 && num[in].right==-1){
      si1=num[in].left;
      num[si1].p=in;
    }
    else if(num[in].right!=-1 && num[in].left==-1){
      si2=num[in].right;
      num[si2].p=in;
    }
    else{
      si1=num[in].left;
      num[si1].p=in;
      si2=num[in].right;
      num[si2].p=in;
      }

    //if(num[in].p==-1) pa=in;
  }
  for(i=0;i<n;i++){
    if(num[i].p==-1) pa=i;
  }
  

  //Preorder
  printf("Preorder\n");
  Preorder(pa);
  printf("\n");
  //Inorder
  printf("Inorder\n");
  Inorder(pa);
  printf("\n");

  //Postorder
  printf("Postorder\n");
  Postorder(pa);
  printf("\n");
  return 0;
}

Measured memory_bytes: 616
def selection_sort(a, n):
    number = 0
    for i in range(n):
        min_index = a[i:].index(min(a[i:])) + i
        a[min_index], a[i] = a[i], a[min_index]
        if i != min_index:
            number += 1
    return number


n = int(input())
*ls, = map(int, input().split())
num = selection_sort(ls, n)
print(*ls)
print(num)



Measured memory_bytes: 5616
def main():
    N, K = map(int, input().split())
    SUSHI = []
    for _ in range(N):
        t, d = map(int, input().split())
        SUSHI.append((d, t))
    SUSHI.sort(reverse=True)

    NEW = {i: True for i in range(1, N+1)} ## NEW[i]:=i番目のすしの種類がカウントされたかどうか
    x, y = 0, 0 # xは基礎ポイント、yは種類数,y*yで種類ぽいんと
    A, B = [], [] # Ａはおいしさ順に先頭K個とったときに、新種じゃないもののおいしさ
                  #　Bはおいしさ順にみたときに、Ａ以降のネタでＡに出現しなかったネタの美味しさ

    ## 以下、ＳＵＳＨＩを先頭からみて初期値x, y, A, Bを作成する
    for d, t in SUSHI[:K]:
        if NEW[t]: # 新種のネタ
            x += d
            y += 1 # 種類が増える
            NEW[t] = False
        else:
            x += d
            A.append(d)
    for d, t in SUSHI[K:]:
        if NEW[t]:
            B.append(d)
            NEW[t] = False
    B.sort()
    ### この時点で
    ### Aには先頭K種類のすしで種類ポイントに寄与しないネタ(の美味しさ)が大きい順に入っている。pop()で一番小さい値をとってこれる
    ### Bには先頭K以降のすしで種類ポイントに寄与するネタ(の美味しさ)が小さい順に入っている。pop()で一番大きい値をとってこれる。

    answer = x + y**2
    while A and B: # AかＢが空になるまで続ける
        a, b = A.pop(), B.pop() # A中種類ポイントに寄与せず、一番おいしくないネタとB中種類ポイントに寄与して、一番おいしいネタを交換
        x -= a
        x += b
        y += 1
        if x + y**2 > answer:
            answer = x + y**2
    print(answer)
main()

Measured memory_bytes: 65460
#include<stdio.h>
int main(void)
{
int k,x,y,z,i;
	scanf("%d %d",&k,&x);
	y=x-k+1;
	z=x+k-1;
	for(i=y;i<=z;i++){
		printf("%d ",i);
	}
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

struct Info{
	int points;
	vector<int> next_SUBJECT;
};

struct Data{
	int sum_points,number,subj_num;
	short in_num[20];
};

int N,need_points,POW[21];
Info info[20];
int first_in_num[20];
bool LOG[1048576];

void copyData(Data& to,Data from){
	for(int i = 0; i < N; i++){
		to.in_num[i] = from.in_num[i];
	}
}

void func(){

	for(int i = 0; i < N; i++)info[i].next_SUBJECT.clear();
	for(int i = 0; i < POW[N]; i++)LOG[i] = false;

	int num,tmp;

	for(int i = 0; i < N; i++){
		scanf("%d %d",&info[i].points,&num);
		first_in_num[i] = num;

		for(int k = 0; k < num; k++){
			scanf("%d",&tmp);
			info[tmp].next_SUBJECT.push_back(i);
		}
	}

	queue<Data> Q;

	for(int i = 0; i < N; i++){
		if(first_in_num[i] == 0){
			Data new_data;
			for(int k = 0; k < N; k++)new_data.in_num[k] = first_in_num[k];
			new_data.subj_num = 1;
			new_data.sum_points = info[i].points;
			new_data.number = POW[i];
			LOG[POW[i]] = true;
			for(int k = 0; k < info[i].next_SUBJECT.size(); k++){
				new_data.in_num[info[i].next_SUBJECT[k]]--;
			}
			Q.push(new_data);
		}
	}

	while(!Q.empty()){

		if(Q.front().sum_points >= need_points){
			printf("%d\n",Q.front().subj_num);
			return;
		}else{

			for(int loop = 0; loop < N; loop++){
				if(Q.front().number & (1 << loop)){
					//Do nothing
				}else{
					if(Q.front().in_num[loop] == 0){
						Data new_data;
						copyData(new_data,Q.front());
						new_data.subj_num = Q.front().subj_num+1;
						new_data.sum_points = Q.front().sum_points+info[loop].points;
						new_data.number = Q.front().number+POW[loop];
						if(LOG[new_data.number])continue;
						LOG[new_data.number] = true;
						for(int k = 0; k < info[loop].next_SUBJECT.size(); k++){
							new_data.in_num[info[loop].next_SUBJECT[k]]--;
						}
						Q.push(new_data);
					}
				}
			}
			Q.pop();
		}
	}
}

int main(){

	for(int i = 0; i <= 20; i++)POW[i] = pow(2,i);

	while(true){
		scanf("%d %d",&N,&need_points);
		if(N == 0 && need_points == 0)break;

		func();
	}

	return 0;
}

Measured memory_bytes: 14740
#include<stdio.h>
#include<algorithm>
#include<iostream>
#include <string.h>
using namespace std;
typedef long long ll;
char a[1000005],ma[1000005],c[1000005],v[1000005],p[1000005];
int main()
{
    ll n,j,k,m,h,i,t,hh,x,x2,y1,y2,z1,z2,f,ans=0,mi;
        scanf("%s",a+1);
        n=strlen(a+1);
       for(i=1;i<=n;i++)
       {
           ans+=(a[i]-'0');
       }
       if(ans%9==0)
        printf("Yes\n");
        else
            printf("No\n");
    return 0;
}


Measured memory_bytes: 3884
N = int(input())
A = list(map(int, input().split()))
even = 0
odd = 0
for a in A:
    if a % 2 == 0:
        even += 1
    else:
        odd += 1
if even == 0 or odd == 0:
    print(0)
elif odd % 2 == 1:
    print(N - 1)
else:
    print(N - 2)



Measured memory_bytes: 27360
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;
ll a[229028], sum = 0, k = 0, ans = 1145141919810000;
int main() {
	int n; cin >> n;
	for (int i = 0; i < n; i++){
		cin >> a[i]; sum += a[i];
	}
	for (int i = 0; i < n - 1; i++){
		k += a[i];
		ans = min(ans, abs(k - (sum - k)));
	}
	cout << ans << endl;
}

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

using namespace std;
#define int long long
#define all(v) v.begin(), v.end()
#define pii pair <int , int>
#define F first
#define S second

int check(int n, int x) {
    while (n % x == 0) n/=x;
    return (n % x == 1);
}
int32_t main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n, ans = 0; cin >> n;
    for (int i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            ans += check(n, i);
            if (n/i != i) ans += check(n, n/i);
        }
    }
    n--;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ans++;
            if (n/i != i) ans++;
        }
    }
    cout << ans << "\n";
}


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

int main() {
  int N;
  long long int M;
  cin >> N;
  M = 0;
  vector<int> A(N);
  for(int i = 0; i<N; i++){
      cin >> A.at(i);
  }

  sort(A.begin(),A.end());
  cout << A.at(0) << " ";

  reverse(A.begin(),A.end());
  cout << A.at(0) << " ";

  for(int i = 0; i < N; i++){
      M += A.at(i);
  }
  cout << M << endl;;

}


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

int main(){
	int purchase, capa;
	
	while(std::cin >> purchase >> capa){
		if(purchase == 0 && capa == 0)
			break;
		
		std::vector<int> vegetable_price;
		vegetable_price.resize(purchase);
		
		//input
		for(int i=0; i<purchase; ++i){
			std::cin >> vegetable_price[i];
		}
		
		std::sort(vegetable_price.begin(), vegetable_price.end(), std::greater<int>());
		
		// 
		for(size_t i=capa-1; i<vegetable_price.size(); i += capa-1){
			vegetable_price.erase(vegetable_price.begin() + i);
		}
		
		int sum_price = 0;
		for(size_t i=0; i<vegetable_price.size(); ++i){
			sum_price += vegetable_price[i];
		}
		
		//show
		std::cout << sum_price << std::endl;
		
	}
	
	return 0;
}

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

int main(){
  int n;cin>>n;
  string s; cin>>s;
  int x=0,ans=0;
  for(int i=0;i<n;i++){
    if(s[i]=='I')x++;
    else x--;
    ans=max(ans,x);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
A, B = map(int, input().split())
if A > B:
    if (A-B)%2 == 0:
        K = A-(A-B)//2
        print(K)
    else:
        print('IMPOSSIBLE')
else:
    if (B-A)%2 == 0:
        K = B-(B-A)//2
        print(K)
    else:
        print('IMPOSSIBLE')

Measured memory_bytes: 3060
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
d = Counter(a)

aa = {}
bb = {}
mx = 0
for k,v in d.items():
    aa[k] = v * (v-1) // 2
    bb[k] = (v-1) * (v-2) // 2
    mx += aa[k]

for i in a:
    print(mx - aa[i] + bb[i])


Measured memory_bytes: 39092
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String args[]) {

		FastScanner sc = new FastScanner();
		int n = sc.nextInt();

		int a[] = new int[n];
		int b[] = new int[n];
		int c[] = new int[n - 1];

		for (int j = 0; j < n; j++) {
			a[j] = sc.nextInt();
		}

		for (int j = 0; j < n; j++) {
			b[j] = sc.nextInt();
		}

		for (int j = 0; j < n - 1; j++) {
			c[j] = sc.nextInt();
		}

		int result = Arrays.stream(b).sum();
		for (int i = 0; i < n - 1; i++) {
			result += (a[i] + 1 == a[i + 1] ? c[a[i] - 1] : 0);
		}

		System.out.println(result);
	}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

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

const int MAXN = 5555;
vector<pair<int,int>> adj[MAXN];
vector<int> radj[MAXN];
int n, m, p;
int dis[MAXN];
int vis[MAXN];

int rel[MAXN], rel2[MAXN];

void dfs(int u) {
  vis[u] = rel[u] = 1;
  for(auto p: adj[u]) {
    int v = p.first;
    if (!vis[v]) dfs(v);
  }
}
void rdfs(int u) {
  vis[u] = rel2[u] = 1;
  for(auto v: radj[u]) {
    if (!vis[v]) rdfs(v);
  }
}
int cntv[MAXN];

int main(){
  cin.tie(0); ios_base::sync_with_stdio(0);
  cin >> n >> m >> p;
  for(int i=0;i<m;i++) {
    int u, v, c;
    cin >> u >> v >> c;
    adj[u].emplace_back(v,p-c);
    radj[v].push_back(u);
  }
  dfs(1);
  memset(vis,0,sizeof vis);
  rdfs(n);
  memset(dis, 0x3f, sizeof dis);
  memset(vis,0,sizeof vis);
  dis[1] = 0;
  vis[1] = 1;
  queue<int> q;
  q.push(1);
  bool pos = true;
  while(!q.empty()) {
    int u = q.front();
    vis[u] = 0;
    cntv[u]++;
    if (cntv[u]>=n) {
      pos = false;
      break;
    }
    q.pop();
    for(auto p: adj[u]) {
      int v=p.first;
      if (!rel[v] || !rel2[v]) continue;
      int dd=p.second;
      if (dis[v] > dd + dis[u]) {
        dis[v] = dd + dis[u];
        if (!vis[v]) {
          vis[v] = 1;
          q.push(v);
        }
      }
    }
  }
  if (pos) cout << max(0,-dis[n]) << endl;
  else cout << -1 <<endl;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a;
  int s1, s2, s3;
  cin >> a;
  s1 = a/100;
  s2 = a/10 - s1*10;
  s3 = a - s2*10 - s1*100;
  cout << s1 + s2 + s3 << endl;
}

Measured memory_bytes: 3604
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);
        
        String C1 = sc.next();
        String C2 = sc.next();
        
        for(int i = 0; i < 3; i++ ){
            if(C1.charAt(i) != C2.charAt(2 - i)){
                System.out.println("NO");
                return;
            }
        }
        System.out.println("YES");
    }
}


Measured memory_bytes: 23252
#include <cstdio>
#include <climits>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>

const int MAX = 200005;
const int MOD = 1000000007;

long long fact[MAX], invFact[MAX];

long long qpow(long long a, long long n) {
    long long res = 1;
    for (; n; n >>= 1, a = a * a % MOD) if (n & 1) res = res * a % MOD;
    return res;
}

void init() {
    fact[0] = 1;
    for (int i = 1; i < MAX; i++) fact[i] = fact[i - 1] * i % MOD;
    invFact[MAX - 1] = qpow(fact[MAX - 1], MOD - 2);
    for (int i = MAX - 2; ~i; i--) invFact[i] = invFact[i + 1] * (i + 1) % MOD;
}

long long combi(int n, int m) {
    return fact[n] * invFact[m] % MOD * invFact[n - m] % MOD;
}

int main() {
    init();
    int n, m;
    scanf("%d %d", &n, &m);

    static std::vector<int> vec;
    int t = m;
    for (int i = 2; i * i <= m; i++) if (t % i == 0) {
        int temp = 0;
        while (t % i == 0) {
            ++temp;
            t /= i;
        }
        vec.push_back(temp);
    }

    if (t > 1) vec.push_back(1);

    long long ans = 1;
    for (auto i : vec) ans = ans * combi(i + n - 1, n - 1) % MOD;
    printf("%lld\n", ans);

    return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <map>


void show_arr(const std::vector<int>& vector);

int main() {
	int N;
	std::cin >> N;

	std::map<int, int> sorted_x; // K: xi, V: i
	for (int i = 1; i <= N; ++i) {
		int xi;
		std::cin >> xi;
		sorted_x.emplace(xi - 1, i);
	}

	std::vector<int> arr;
	arr.resize((size_t) (N * N), 0);
	int first = 0;
	for (auto& p : sorted_x) {
		int xi = p.first;
		int i = p.second;
		int needed_before = i - 1;
		for (int j = first; j < xi && needed_before > 0; ++j) {
			if (arr[j] == 0) {
				arr[j] = i;
				needed_before--;
				if (first == j) {
					first++;
				}
			} else {
				first++;
			}
		}
		if (needed_before > 0) {
			std::cout << "No" << std::endl;
			return 0;
		}
		arr[xi] = i;
	}
	int last = N * N - 1;
	for (auto it = sorted_x.rbegin(); it != sorted_x.rend(); ++it) {
		auto& p = *it;
		int xi = p.first;
		int i = p.second;
		int needed_after = N - i;
		for (int j = last; j > xi && needed_after > 0; --j) {
			if (arr[j] == 0) {
				arr[j] = i;
				--needed_after;
				if (last == j) {
					last--;
				}
			} else {
				last--;
			}
		}
		if (needed_after > 0) {
			std::cout << "No" << std::endl;
			return 0;
		}
	}
	std::cout << "Yes" << std::endl;
	show_arr(arr);
}

void show_arr(const std::vector<int>& arr) {
	bool is_first = true;
	for (int x : arr) {
		if (!is_first) {
			std::cout << ' ';
		} else {
			is_first = false;
		}
		std::cout << x;
	}
	std::cout << std::endl;
}


Measured memory_bytes: 2176
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fr first
#define sc second
typedef long long ll;
const long long llinf=LLONG_MAX;
const int inf=INT_MAX;
const int nmax=1e5+5;
const int mod=1e9+7;
using namespace std;
int n,i,j;
ll a[nmax],l;
int main()
{
    //freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
    cin>>n>>l;
    for(i=1;i<=n;i++)cin>>a[i];
    for(i=1;i<n;i++)
     if(a[i]+a[i+1]>=l)
	 {
	 	cout<<"Possible"<<endl;
	 	for(j=1;j<i;j++)cout<<j<<endl;
	 	for(j=n-1;j>=i;j--)cout<<j<<endl;
	 	return 0;
	 }
	rc("Impossible");
}

Measured memory_bytes: 1664
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

    Scanner scan = new Scanner(System.in);
    
   long a = scan.nextInt();
   long total =1;
   for (int i=1;i<=a;i++){
       total =  ((total * i) % 1000000007);
   }
   
   System.out.println(total );
    }
}


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

const int R = 10101010;

int main()
{
    int n,k;
    cin >>n >>k;
    vector<int> a(n);
    rep(i,n)
    {
        cin >>a[i];
        --a[i];
    }

    vector<int> x(n,-1);
    for(int i=n-1; i>=0; --i)
    {
        // leaf
        if(x[i]==-1) x[i] = k;

        if(a[i]>=0)
        {
            x[a[i]] = max(x[a[i]],max(0,x[i]-1));
        }
        else x[i]=R;
    }

    // rep(i,n) printf("x[%d] =%d\n", i,x[i]);

    int ans = 0;
    rep(i,n) ans += (x[i]>0);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
const double EPS = 1e-9;
using Pt = complex<double>;
// https://vlecomte.github.io/cp-geo.pdf
double sq(Pt p) { return p.real()*p.real() + p.imag()*p.imag(); }
double cross(Pt v, Pt w) { return (conj(v) * w).imag(); }
Pt perp(Pt p) { return {-p.imag(), p.real()}; }
void circumcenter(double x0, double y0, double x1, double y1, double x2, double y2, double *x, double *y) {
    auto a = Pt(x0, y0);
    auto b = Pt(x1, y1);
    auto c = Pt(x2, y2);
    b = b - a, c = c - a;
    auto p = a + perp(b*sq(c) - c*sq(b)) / cross(b, c) / 2.0;
    *x = p.real();
    *y = p.imag();
}
int main() {
    cin.tie(nullptr); ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<int> X(N), Y(N);
    for (int i = 0; i < N; i++) cin >> X[i] >> Y[i];
    auto test = [&](double px, double py, double r) -> bool {
        for (int i = 0; i < N; i++) {
            double d = (px - X[i]) * (px - X[i]) + (py - Y[i]) * (py - Y[i]);
            if (d > r * r + EPS) {
                return false;
            }
        }
        return true;
    };
    double px = 0, py = 0, r = 0;
    double ans = 1e18;
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            px = (X[i] + X[j]) / 2.0;
            py = (Y[i] + Y[j]) / 2.0;
            r = sqrt((px - X[i]) * (px - X[i]) + (py - Y[i]) * (py - Y[i]));
            if (ans > r && test(px, py, r)) {
                ans = r;
            }
        }
    }
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            for (int k = j + 1; k < N; k++) {
                circumcenter(X[i], Y[i], X[j], Y[j], X[k], Y[k], &px, &py);
                r = sqrt((px - X[i]) * (px - X[i]) + (py - Y[i]) * (py - Y[i]));
                if (ans > r && test(px, py, r)) {
                    ans = r;
                }
            }
        }
    }
    cout << fixed << setprecision(9) << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int i,a,b,k,n,cntr=0;
    cin>>a>>b>>k;
    if(a>b){
        n=b;
    }else{
        n=a;
    }
    
    map<int, int>   divis;
    for(i=1; i<=n; i++){
        if(a%i==0 && b%i==0){
            cntr++;
            divis[cntr]=i;
        }
    }
    cout<<divis[cntr-k+1]<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>

using namespace std;

int main() {
	int n;
	char k[100][2];
	int m;
	char a;

	while (cin >> n) {
		if (n == 0) {
			break;
		} 
		for (int i = 0; i < n; i++) {
			cin >> k[i][0] >> k[i][1];
		}
		cin >> m;
		for (int i = 0; i < m; i++) {
			cin >> a;
			for (int i = 0; i < n; i++) {
				if (a == k[i][0]) {
					a = k[i][1];
					break;
				}
			}
			cout << a;
		}
		cout << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1152
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>

using namespace std;

//#define ZTDebug
//#define ZTVerbose
//#define ZTRandomTest
#ifdef ZTDebug
#define In scanf_s
#else
#define In scanf
#endif // ZTDebug

#define Ind(d) In("%d", &d)
#define Ind2(a, b) In("%d%d", &a, &b)
#define InD(d) int d; In("%d", &d);
#define InD2(a, b) int a, b; In("%d%d", &a, &b);
#define InDN(n, v) for (auto _i = 0; _i < n; ++_i) In("%d", &v[_i]);
#define OutDNLine(n, v) for (auto _i = 0; _i < n; ++_i) printf("%d%c", *(v + _i), _i + 1 == n ? '\n' : ' ');

typedef double db;
typedef long long LL;
typedef pair<int, int> pii;

const int Max = 2048;

int blues[Max][Max];
int up[Max][Max];
int lt[Max][Max];
char s[Max][Max];

int isBlue(int i, int j, int b) { return s[i][j] == '1' ? b : 0; }
void setS(int b[][Max], int i, int j, int d) {
    b[i][j] = d + b[i - 1][j] + b[i][j - 1] - b[i - 1][j - 1];
}
int getSq(int b[][Max], int i1, int j1, int i2, int j2) {
    return b[i2][j2] - b[i2][j1 - 1] - b[i1 - 1][j2] + b[i1 - 1][j1 - 1];
}
#ifdef ZTVerbose
void out(const char* name, int b[][Max], int n, int m) {
    cout << name << ":" << endl;
    for (auto i = 1; i <= n; ++i) {
        for (auto j = 1; j <= m; ++j) cout << b[i][j] << " ";
        cout << endl;
    }
}
#endif // ZTVerbose
int main() {
#ifdef ZTDebug
    while (true) {
#endif // ZTDebug
        InD2(n, m);
        InD(q);
        for (auto i = 1; i <= n; ++i) In("%s", s[i] + 1);
#ifdef ZTVerbose
        for (auto i = 1; i <= n; ++i) cout << s[i] + 1 << endl;
#endif // ZTVerbose

        for (auto i = 1; i <= n; ++i)
            for (auto j = 1; j <= m; ++j) {
                auto b = isBlue(i, j, 1);
                setS(blues, i, j, b);
                setS(up, i, j, isBlue(i - 1, j, b));
                setS(lt, i, j, isBlue(i, j - 1, b));
            }
#ifdef ZTVerbose
        out("blues", blues, n, m);
        out("up", up, n, m);
        out("lt", lt, n, m);
#endif // ZTVerbose
        for (auto i = 1; i <= q; ++i) {
            InD2(x1, y1);
            InD2(x2, y2);
            auto cn = getSq(blues, x1, y1, x2, y2);
            auto ce = getSq(up, x1 + 1, y1, x2, y2) + getSq(lt, x1, y1 + 1, x2, y2);
            cout << cn - ce << endl;
        }
#ifdef ZTDebug
    }
#endif // ZTDebug
    return 0;
}


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

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

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

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

    vector<ll> lpos, rpos;
    rep(i, s.size()){
        if(s[i] == 'L')lpos.push_back(i);
        else rpos.push_back(i);
    }

    vector<ll> ans(s.size(), 0);
    rep(i, s.size()){
        if(s[i] == 'L'){
            ll pos = lower_bound(ALL(rpos), i) - rpos.begin() - 1;
            
            ll dif = i - rpos[pos];
            if(dif&1)ans[rpos[pos]+1]++;
            else ans[rpos[pos]]++; 
        }
        else {
            ll pos = lower_bound(ALL(lpos), i) - lpos.begin();

            ll dif = lpos[pos] -  i;
            if(dif&1)ans[lpos[pos]-1]++;
            else ans[lpos[pos]]++;
        }
    }

    rep(i, s.size())cout << ans[i] << " ";
}

Measured memory_bytes: 5140
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <numeric>
#include <map>
#include <vector>
#include <string>
#include <vector>
#include <cassert>
#include <cmath>
#include <cctype>
#include <queue>
#include <algorithm>
#include <memory>
#include <memory.h>
using namespace std;
const int INF = 1 << 30;

int main(){
	int n, k;
	while(cin >> n){
		cin >> k;
		int y, x;
		int d;
		for(int i = 0; i < k; i++){
			d = INF;
			cin >> y >> x;
			d = min(d, y-1);
			d = min(d, n-y);
			d = min(d, x-1);
			d = min(d, n-x);
			d %= 3;
			cout << d + 1 << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
N = int(input())
h = list(map(int, input().split()))
list = [float("inf") for _ in range(N)]
# 一般に足場 i までの最小コストを求める関数を作り、それは足場 i-1, i-2 までの最小コストがわかっていればいい
def cost(i):
	if i == 0:
		list[i] = 0
	list[i] = min(list[i], list[i - 1] + abs(h[i] - h[i - 1]))
	if i > 1:
		list[i] = min(list[i], list[i - 2] + abs(h[i] - h[i - 2]))
for i in range(N):
	cost(i)
print(list[N - 1])


Measured memory_bytes: 13980
a,b,q = map(int,input().split())

sl = [-float("inf")]
for _ in range(a):
    sl.append(int(input()))
sl.append(float("inf"))
tl = [-float("inf")]
for _ in range(b):
    tl.append(int(input()))
tl.append(float("inf"))
    
import bisect


for _ in range(q):
    x = int(input())
    index1 = bisect.bisect(sl, x) 
    index2 = bisect.bisect(tl, x)
    rs = abs(sl[index1] - x) 
    ls = abs(sl[index1-1] - x)
    rt = abs(tl[index2] - x)
    lt = abs(tl[index2-1] - x)
    ansl = []
    ansl.append(max(rs,rt))
    ansl.append(max(ls,lt))
    ansl.append(2*min(rs,lt)+max(rs,lt))
    ansl.append(2*min(ls,rt)+max(ls,rt))
    print(min(ansl))
    


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

#define    ll     long long int

int main( )
{
    double mx_percent = 0.0;
    int mx_sugar_water = 0;
    int mx_sugar = 0;

    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;
    int i, j, k, l, mass_water, mass_sugar, need_sugar;
    double percent;

    for (i = 0; i <= 30; i++ ) {
        for (j = 0; j <= 30; j++) {
            mass_water = (i * a + j * b);
            if (mass_water == 0) continue;
            need_sugar = mass_water * e;
            for (k = 0; k <= f; k++) {
                for (l = 0; k * c + l * d <= need_sugar; l++) {
                    mass_sugar = k * c + l * d;
                    if (mass_sugar + mass_water * 100 <= f) {
                        percent = (100.0 * mass_sugar) / (mass_water * 100.0 + mass_sugar);
                        if (percent >= mx_percent) {
                            mx_percent = percent;
                            mx_sugar_water = (mass_sugar + mass_water * 100);
                            mx_sugar = mass_sugar;
                        }
                    }
                    else {
                        break;
                    }
                }
            }
        }
    }
    cout << mx_sugar_water << ' ' << mx_sugar << '\n';
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
using namespace std;
const int MOD=924844033;
vector<int> mp[200001];
int sts[200001];
void calcsts(int k,int p)
{
    sts[k]=1;
    for (auto c:mp[k])
        if (c!=p)
        {
            calcsts(c,k);
            sts[k]+=sts[c];
        }
}
int coef[524288],b[524288],n;
void calccoef(int k,int p)
{
    ++coef[n];
    if (p)
        --coef[n-sts[k]];
    for (auto c:mp[k])
        if (c!=p)
        {
            --coef[sts[c]];
            calccoef(c,k);
        }
}
long long qpow(long long a,int b)
{
    long long ret=1;
    while (b)
    {
        if (b&1)
            (ret*=a)%=MOD;
        (a*=a)%=MOD;
        b>>=1;
    }
    return ret;
}
void dft(int arr[524288],bool rev)
{
    for (int i=0;i<524288;++i)
    {
        int t=i,rev=0;
        for (int j=0;j<19;++j)
        {
            (rev<<=1)^=t&1;
            t>>=1;
        }
        if (rev>i)
            swap(arr[i],arr[rev]);
    }
    for (int i=0;i<19;++i)
    {
        int w=qpow(5,(MOD-1)/(1<<(i+1)));
        if (rev)
            w=qpow(w,MOD-2);
        for (int j=0;j<524288;j+=1<<(i+1))
        {
            int cur=1;
            for (int k=j;k<j+(1<<i);++k)
            {
                int v2=(long long)cur*arr[k+(1<<i)]%MOD;
                arr[k+(1<<i)]=arr[k]-v2;
                if (arr[k+(1<<i)]<0)
                    arr[k+(1<<i)]+=MOD;
                arr[k]+=v2;
                if (arr[k]>=MOD)
                    arr[k]-=MOD;
                cur=(long long)cur*w%MOD;
            }
        }
    }
    if (rev)
    {
        int inv=qpow(524288,MOD-2);
        for (int i=0;i<524288;++i)
            arr[i]=(long long)arr[i]*inv%MOD;
    }
}
int fac[200001],inv[200001];
int main()
{
    scanf("%d",&n);
    for (int i=1;i<n;++i)
    {
        int a,b;
        scanf("%d%d",&a,&b);
        mp[a].push_back(b);
        mp[b].push_back(a);
    }
    calcsts(1,0);
    fac[0]=1;
    for (int i=1;i<=n;++i)
        fac[i]=(long long)fac[i-1]*i%MOD;
    inv[n]=qpow(fac[n],MOD-2);
    for (int i=n-1;i>=0;--i)
        inv[i]=(long long)inv[i+1]*(i+1)%MOD;
    calccoef(1,0);
    for (int i=0;i<=n;++i)
    {
        if (coef[i]<0)
            coef[i]+=MOD;
        coef[i]=(long long)coef[i]*fac[i]%MOD;
        b[i]=inv[n-i];
    }
    dft(coef,false);
    dft(b,false);
    for (int i=0;i<524288;++i)
        coef[i]=(long long)coef[i]*b[i]%MOD;
    dft(coef,true);
    for (int i=1;i<=n;++i)
        printf("%lld\n",(long long)coef[n+i]*inv[i]%MOD);
    return 0;
}


Measured memory_bytes: 30080
# code like professional "write main function"
import math
def main():
	n , p = map(int , input().split())
	i = 2
	if n==1:
		print(p)
		exit()
	ans = 1
# If power of a prime number in the product is greater than n then we can give (power/n) prime to each integer
# and similary for others prime number and multiply the result
	while (i<=math.sqrt(p)):
		if p%i==0:
			cnt = 0
			while p%i==0:
				p = p//i
				cnt = cnt+1
			u = cnt//n
			for j in range(0 , u):
				ans = ans*i
		i = i+1
	print(ans)
if __name__=="__main__":
	main()

Measured memory_bytes: 63008
#include<bits/stdc++.h>
//#pragma GCC optimize("O3")
//#pragma GCC target ("sse4")
using namespace std;
#define PB push_back
#define all(x) (x).begin(),(x).end()
#define MEM(x,a) memset((x),a,sizeof((x)))
#define F first
#define S second
#define imx INT_MAX
#define inI(x) scanf("%d",&x)
#define inI2(x,y) scanf("%d %d",&x,&y)
#define inI3(x,y,z) scanf("%d %d %d",&x,&y,&z)
const long long MOD = (long long)(1e9+7);
const long long MMX = (long long)(1e18);
typedef long long LL;
int n,x,y,a,b;
LL h,w,col[15];
map<pair<int,int>,int>tri;
map<pair<int,int>,bool>mm;
queue<pair<int,int>>q;
int main()
{
    scanf("%d %d %d",&h,&w,&n);
    col[0]=(h-2)*(w-2);
    for(int i=1;i<=n;i++)
    {
        scanf("%d %d",&x,&y);
        mm[{x,y}]=true;
        if(!tri[{x,y}])
        {
            tri[{x,y}]=true;
            q.push({x,y});
        }
        if(!tri[{x-1,y}])
        {
            tri[{x-1,y}]=true;
            q.push({x-1,y});
        }
        if(!tri[{x-2,y}])
        {
            tri[{x-2,y}]=true;
            q.push({x-2,y});
        }
        if(!tri[{x,y-1}])
        {
            tri[{x,y-1}]=true;
            q.push({x,y-1});
        }
        if(!tri[{x-1,y-1}])
        {
            tri[{x-1,y-1}]=true;
            q.push({x-1,y-1});
        }
        if(!tri[{x-2,y-1}])
        {
            tri[{x-2,y-1}]=true;
            q.push({x-2,y-1});
        }
        if(!tri[{x,y-2}])
        {
            tri[{x,y-2}]=true;
            q.push({x,y-2});
        }
        if(!tri[{x-1,y-2}])
        {
            tri[{x-1,y-2}]=true;
            q.push({x-1,y-2});
        }
        if(!tri[{x-2,y-2}])
        {
            tri[{x-2,y-2}]=true;
            q.push({x-2,y-2});
        }
    }
    while(!q.empty())
    {
        a=q.front().F;
        b=q.front().S;
        q.pop();
        if(a<1||b<1||a>h-2||b>w-2)continue;
        //printf("--%d %d\n",a,b);
        col[0]--;
        int cc=0;
        if(mm[{a,b}])cc++;
        if(mm[{a+1,b}])cc++;
        if(mm[{a+2,b}])cc++;
        if(mm[{a,b+1}])cc++;
        if(mm[{a+1,b+1}])cc++;
        if(mm[{a+2,b+1}])cc++;
        if(mm[{a,b+2}])cc++;
        if(mm[{a+1,b+2}])cc++;
        if(mm[{a+2,b+2}])cc++;
        col[cc]++;
    }
    for(int i=0;i<=9;i++)printf("%lld\n",col[i]);
}


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

int main(){
	int N,R;
	
	cin >> N;
	cin >> R;
	
	if(1>N || N>100 || 0>R || N>4111)exit(1);
	
	if(N>=10){
		cout << R << endl;
	}else{
		cout << R+((10-N)*100) << endl;
	}
	
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <algorithm>
#include <map>
#include <fstream>
#include <bitset>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef priority_queue<int> pqi;
typedef priority_queue<ii> pqii;
typedef map<int, int> mii;
typedef map<int, string> mis;
typedef map<string, int> msi;
typedef set<int> si;
typedef set<ll> sl;
typedef map<ll, ll> mll;
typedef queue<int> qi;
typedef queue<ii> qii;
typedef vector<string> vs;
typedef pair<ll, ll> iil;
typedef vector<iil> viil;
typedef vector<vi> vvi;
typedef long double ld;
typedef vector<pair<pair<int,int>,int>> viii;
typedef vector<pair<pair<ll,ll>,ll>> viiil;

#define pb push_back
#define mp make_pair
#define rep(i, n) for (int i = 0 ; i < n ; i++)
#define INF 1000000000
#define MOD 1000000007;

void solve() {
    int n;
    cin >> n;
    if (n < 600) {
        cout << 8 << endl;
    }
    else if (n < 800) {
        cout << 7 << endl;
    }
    else if (n < 1000) {
        cout << 6 << endl;
    }
    else if (n < 1200) {
        cout << 5 << endl;
    }
    else if (n < 1400) {
        cout << 4 << endl;
    }
    else if (n < 1600) {
        cout << 3 << endl;
    }
    else if (n < 1800) {
        cout << 2 << endl;
    }
    else {
        cout << 1 << endl;
    }
}

void querySolve() {
    int n;
    cin >> n;
    while (n--) {
        solve();
    }
}

int main() {
    //querySolve();
    solve();

}


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

int main() {
  int N;
  cin >> N;
  vector<tuple<int, int, int>> V(N);
  for (int i = 0, x, y, p; cin >> x >> y >> p; i++) V.at(i) = {x, y, p};
  
  vector X(1 << N, vector(N, 0));
  auto Y = X;
  for (int bit = 0; bit < 1 << N; bit++) {
    for (int i = 0; i < N; i++) {
      auto [x, y, p] = V.at(i);
      X.at(bit).at(i) = abs(x);
      Y.at(bit).at(i) = abs(y);
      for (int j = 0; j < N; j++) {
        if (bit >> j & 1) {
          auto [x2, y2, p2] = V.at(j);
          X.at(bit).at(i) = min(X.at(bit).at(i), abs(x - x2));
          Y.at(bit).at(i) = min(Y.at(bit).at(i), abs(y - y2));
        }
      }
    }
  }

  vector ans(N + 1, LONG_MAX);
  for (int bit = 0; bit < 1 << N; bit++) {
    int cnt = __builtin_popcount(bit);
    for (int i = bit; i >= 0; i--) {
      i &= bit;
      long tmp = 0;
      for (int j = 0; j < N; j++) {
        if (!(bit >> j & 1)) {
          auto [x, y, p] = V.at(j);
          tmp += (long) min(X.at(i).at(j), Y.at(bit - i).at(j)) * p;
        }
      }
      ans.at(cnt) = min(ans.at(cnt), tmp);
    }
  }
  for (auto a : ans) cout << a << "\n";
}

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

#ifdef NON_SUBMIT
#define TEST(n) (n)
#define tout cerr
#else
#define TEST(n) ((void)0)
#define tout cin
#endif

using namespace std;

int W[101], PS[101];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt","r",stdin));
	TEST(freopen("output.txt","w",stdout));
	TEST(freopen("debug.txt","w",stderr));
	int N, ans=0x7fffffff;
	cin>>N;
	for(int i=1;i<=N;i++) {
		cin>>W[i];
		PS[i]=PS[i-1]+W[i];
	}
	for(int i=1;i<N;i++) ans=min(ans,abs(PS[N]-2*PS[i]));
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int ans[200000];

int cnt = 0; vector<int> to[101010]; bool visited[101010];

void dfs(int a, int b){
  visited[a] = true;
  for(int i:to[a]){
    if(visited[i]) continue;
    dfs(i, a);
  }
}

int main(){
  int N, M; cin >> N >> M; int x[M], y[M], z[M];
  rep(i, M){
    cin >> x[i] >> y[i] >> z[i];
    x[i]--; y[i]--;
    to[x[i]].push_back(y[i]);
    to[y[i]].push_back(x[i]);
  }
  rep(i, N){
    if(!visited[i]){
      dfs(i, -1);cnt++;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 10112
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int r = Integer.parseInt(sc.next());

        // 主処理
        String result = "";
        if (r < 1200) {
            result = "ABC";
        } else if (r < 2800) {
            result = "ARC";
        } else {
            result = "AGC";
        }

        // 出力
        System.out.println(result);
        sc.close();
    }
}


Measured memory_bytes: 21844
n = input()
nums = input()
nums = nums.split()
nums = list(map(int, nums))

cnt = 0
for i in range(int(n)):
    mink = i
    for v in range(i, int(n)):
        if nums[v] < nums[mink]:
            mink = v
    if mink != i:
        nums[i], nums[mink] = nums[mink], nums[i]
        cnt += 1

print(' '.join(map(str, nums)))
print(cnt)



Measured memory_bytes: 5600
import numpy as np
N,K=list(map(int, input().split()))
AA=np.zeros(N)
for i in range(K):
  d,=list(map(int, input().split()))
  A=[]
  A=np.array(list(map(int, input().split())))-1  
  AA[A]+=1  
print(N-np.count_nonzero(AA))


Measured memory_bytes: 27224
from heapq import heapify, heappush, heappop


class AscKeyMappedPriorityQueue(object):

    def __init__(self, arr=None, key_generator=lambda x: x):
        """
        昇順以外のソートをheapqで実現することはできず、昇順になるキーを挿入する値から作る必要がある。
        tupleの扱いやらが面倒なのでオブジェクトとしてpush, pop操作を簡易に行えるようにしている。
        :param arr: ヒープ化する元の配列が存在する場合は指定する
        :param key_generator: 挿入する値から昇順になるようなキーを作る関数
        """
        self.key_generator = key_generator
        if arr:
            self.arr = [(key_generator(e), e) for e in arr]
            heapify(self.arr)
        else:
            self.arr = []

    def push(self, e):
        heappush(self.arr, (self.key_generator(e), e))

    def pop(self):
        return heappop(self.arr)[1]


X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A = sorted(A, reverse=True)
B = sorted(B, reverse=True)
C = sorted(C, reverse=True)

considered = set()

q = AscKeyMappedPriorityQueue(key_generator=lambda v: (-v[0], v[1], v[2], v[3]))
q.push((A[0] + B[0] + C[0], 0, 0, 0))
considered.add((0, 0, 0))

for _ in range(K):
    e, a, b, c = q.pop()
    print(e)
    if not (a + 1, b, c) in considered and len(A) > a + 1:
        q.push((A[a + 1] + B[b] + C[c], a + 1, b, c))
        considered.add((a + 1, b, c))
    if not (a, b + 1, c) in considered and len(B) > b + 1:
        q.push((A[a] + B[b + 1] + C[c], a, b + 1, c))
        considered.add((a, b + 1, c))
    if not (a, b, c + 1) in considered and len(C) > c + 1:
        q.push((A[a] + B[b] + C[c + 1], a, b, c + 1))
        considered.add((a, b, c + 1))


Measured memory_bytes: 5616
import math
n = int(input())
root = math.ceil(math.sqrt(n))
nums = []
for i in range(1,root+1):
  if n % i == 0:
    count_i = len(str(i))
    count_j = len(str(int(n/i)))
    ans = max(count_i,count_j)  
    nums.append(ans) 
print(min(nums))


Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<deque>
#include<string>
#include<map>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>

using namespace std;

int main(void) {
	string s; cin >> s;
	int sum = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == '2') { sum++; }
	}

	cout << sum << endl;


	return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <utility> // pair make_pair
#include <algorithm>

using namespace std;

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

vector<string> field;

/* if bfs

   queue<pair<int, int> > que
   que.push(start x, start y);

   int dist[x][y];
   memset(dist, -1, sizeof(dist));
   dist[start x][start y] = 0;
*/


// int N; cin >> N;
// field.resize(N);


int main() {
  int H, W; cin >> H >> W;
  
  field.resize(H);

  int dist[H][W];
  memset(dist, -1, sizeof(dist));

  queue<pair<int, int> > que;

  for (int i = 0; i < H; i++) {
    cin >> field[i];
  }

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (field[i][j] == '#') {
        dist[i][j] = 0;
        que.push(make_pair(i, j));
      }
    }
  }

  while(!que.empty()) {
    pair<int, int> v = que.front(); que.pop();
    
    for (int i = 0; i < 4; i++) {
      int nx = v.first + dx[i];
      int ny = v.second + dy[i];

      if (nx < 0 || nx >= H || ny < 0 || ny >= W) continue;
      if (field[nx][ny] == '#') continue;
      if (dist[nx][ny] != -1) continue;

      dist[nx][ny] = dist[v.first][v.second] + 1;
      que.push(make_pair(nx, ny));
    }
  }

  int acc = - (1 << 20);
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      acc = max(acc, dist[i][j]);
    }
  }

  cout << acc << endl;
}


Measured memory_bytes: 13456
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import kotlin.math.max

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    val n = readLong()
    val factorCount = LongArray(n.toInt() + 1)
    for (i in 1..n) {
        val f = primeFactor(i)
        for (e in f) {
            factorCount[e.key.toInt()] += e.value
        }
    }

    val mod = 1000000007
    var ans = 1L
    for (f in factorCount) {
        if (f != 0L) {
            ans = (ans * (f + 1)) % mod
        }
    }
    out.println(ans)
}

/**
O(n^(1/2)) // n * n <= Long.MAX_VALUE n <= 10^8 or more
if n == 1, return emptyMap
 */
fun primeFactor(n: Long): Map<Long, Long> {
    val factorMap = mutableMapOf<Long, Long>()
    var target = n
    var i = 2L
    while (i * i <= target) {
        while (target % i == 0L) {
            factorMap[i] = factorMap.getOrElse(i) { 0L } + 1L
            target /= i
        }
        i++
    }

    if (target != 1L) { factorMap[target] = 1 }
    return factorMap
}

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


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

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

const ll mod =  1000000007;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INF = 1152921504606846976

int main()
{
    int a,b,c,d; cin >> a >> b >> c >> d;
    while(a > 0 && c > 0){
        c -= b;
        a -= d;
    }
    if(c > 0){
        cout << "No";
    }else{
        cout << "Yes";
    }
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<vector<int>> g(n);
    for (int i = 0; i < n - 1; i++) {
        int x, y;
        cin >> x >> y;
        x--, y--;
        g[x].emplace_back(y);
        g[y].emplace_back(x);
    }
    ll ans = 0;
    ll s = 0;
    for (int i = 0; i < n; i++) {
        s += i + 1;
        for (int j : g[i]) {
            if (j < i) {
                s -= j + 1;
            }
        }
        ans += s;
    }

    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 15032
#include <iostream>

struct Card {
  char suit;
  char value;
};


void bubble_sort(Card cards[], const int n) {
  bool sorted = false;

  while(!sorted) {
    sorted = true;
    for (int i = n - 1; i > 0; i--) {
      if (cards[i].value < cards[i - 1].value) {
        Card tmp = cards[i];
        cards[i] = cards[i - 1];
	cards[i - 1] = tmp;
        sorted = false;
      }
    }
  }
}

void selection_sort(Card cards[], int n) {
  for (int i = 0; i < n; i++) {
    int min_index = i;
    for (int j = i + 1; j < n; j++) {
      if (cards[j].value < cards[min_index].value) {
        min_index = j;
      }
    }
    if (cards[min_index].value < cards[i].value) {
      Card tmp = cards[i];
      cards[i] = cards[min_index];
      cards[min_index] = tmp;
    }
  }
}

bool is_stable(Card input[], Card sorted[], int n) {
  for (int i = 0; i < n - 1; i++) {
    if (sorted[i].value == sorted[i+1].value) {
      for (int j = 0; j < n; j++) {
        if (input[j].value == sorted[i].value) {
          if (input[j].suit == sorted[i].suit) {
            break;
          } else if (input[j].suit == sorted[i+1].suit) {
            return false;
          }
        }
      }
    }
  }
  return true;
}



int main() {
  const int BUF_SIZE = 36;
  Card input[BUF_SIZE];
  int n;
  Card sorted[BUF_SIZE];
  Card sorted2[BUF_SIZE];
  bool stable = false;

  std::cin >> n;
  for (int i = 0; i < n; i++) {
    std::cin >> input[i].suit >> input[i].value;
  }

  for (int i = 0; i < n; i++) {
    sorted[i] = input[i];
    sorted2[i] = input[i];
  }

  bubble_sort(sorted, n);

  selection_sort(sorted2, n);

  for (int i = 0; i < n; i++) {
    if (i == n - 1) {
      std::cout << sorted[i].suit << sorted[i].value << std::endl;
    }
    else {
      std::cout << sorted[i].suit << sorted[i].value << " ";
    }
  }

  if (is_stable(input, sorted, n)) {
    std::cout << "Stable" << std::endl;
  } else {
    std::cout << "Not stable" << std::endl;
  }

  for (int i = 0; i < n; i++) {
    if (i == n - 1) {
      std::cout << sorted2[i].suit << sorted2[i].value << std::endl;
    }
    else {
      std::cout << sorted2[i].suit << sorted2[i].value << " ";
    }
  }

  if (is_stable(input, sorted2, n)) {
    std::cout << "Stable" << std::endl;
  } else {
    std::cout << "Not stable" << std::endl;
  }

  return 0;
}



Measured memory_bytes: 3104