akhauriyash/Code-Regression huggingface dataset:
import std.conv, std.functional, std.range, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.complex, std.container, std.math, std.numeric, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }
real readReal() { return readToken.to!real; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }


bool solve(int L, int N, int R, in string S, in string T, char plus, char minus) {
  int now = R;
  foreach (i; 0 .. N) {
    if (S[i] == plus) {
      ++now;
      if (now >= L) {
        return true;
      }
    }
    if (T[i] == minus) {
      if (now > 0) {
        --now;
      }
    }
  }
  return false;
}

void main() {
  try {
    for (; ; ) {
      const H = readInt();
      const W = readInt();
      const N = readInt();
      const RX = readInt() - 1;
      const RY = readInt() - 1;
      const S = readToken();
      const T = readToken();
      
      const resXP = solve(H, N, RX,         S, T, 'D', 'U');
      const resXM = solve(H, N, H - 1 - RX, S, T, 'U', 'D');
      const resYP = solve(W, N, RY,         S, T, 'R', 'L');
      const resYM = solve(W, N, W - 1 - RY, S, T, 'L', 'R');
      writeln((resXP || resXM || resYP || resYM) ? "NO" : "YES");
    }
  } catch (EOFException e) {
  }
}


Measured memory_bytes: 2940
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		sc.close();

		if (b < a)
			System.out.println(a - 1);
		else
			System.out.println(a);
	}
}

Measured memory_bytes: 21844
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		String s = scan.next();
		scan.close();
		if (a >= 3200) {
			System.out.println(s);
		} else {
			System.out.println("red");

		}
	}
}

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

char c[100][101];
int h,w;
void del(int a,int b,char t){
	c[a][b]='.';
	if(a>0&&c[a-1][b]==t)del(a-1,b,t);
	if(b>0&&c[a][b-1]==t)del(a,b-1,t);
	if(a<h-1&&c[a+1][b]==t)del(a+1,b,t);
	if(b<w-1&&c[a][b+1]==t)del(a,b+1,t);
	return;
}
int main(){
	int a,b;
	while(scanf("%d%d",&a,&b),a){
		h=a;
		w=b;
		for(int i=0;i<a;i++){
			scanf("%s",c[i]);
		}
		int ret=0;
		for(int i=0;i<a;i++){
			for(int j=0;j<b;j++){
				if(c[i][j]!='.'){
					ret++;
					del(i,j,c[i][j]);
				}
			}
		}
		printf("%d\n",ret);
	}
}


Measured memory_bytes: 3596
#include <stdio.h>
int main (void){
	int n,a,b,c,d;
	int i,j;
	int e,f;
	scanf("%d %d %d %d %d",&n,&a,&b,&c,&d);
	i=j=0;
	do{
		i+=a;
		j++;
	}while(i<n);
	e=j*b;
	i=j=0;
	do{
		i+=c;
		j++;
	}while(i<n);
	f=j*d;
	if(e>f)e=f;
	printf("%d\n",e);
	return 0;
}



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

int main(void) {

	int K, i;
  	int min, max;
  
  	cin >> K;
  	cin >> min >> max;
  
  	for(i = min; i <= max; i++) {
    	int amari = i % K;
      	if (amari == 0) {
        	cout << "OK";
          	break;
        }
    }
  
  	if (i == max + 1) {
    	cout << "NG";
    }
  
  	return 0;
  	
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define vi vector<int>
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m-1);i>=(int)(n);i--)
#define rev(i, n) revi(i, n, 0)
#define each(i, n) for(auto&& i: n)
#define pb push_back
#define mp make_pair
#define sz(v) ((int)(v).size()) 
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin() , (v).rend()
#define dump(x) cerr << #x << "=" << x <<endl
#define gcd __gcd
#define popcount __builtin_popcountll
int lcm(int a, int b){return a / gcd(a, b) * b;}
const int INF = 1e18;
const int MOD = 1e9 + 7;
const double EPS = 1e-15;
const double PI = acos(-1);

void solve(){
	int N; cin >> N;
	vector<vi> v(N, vi(N, 0));
	vi xx(N), yy(N), hh(N);
	rep(i, N) {
		cin >> xx[i] >> yy[i] >> hh[i];
	}
	int cx = 0, cy = 0, ch = 0, f = 0;
	rep(x, 101) {
		rep(y, 101) {
			int h = 0;
			rep(i, N) {
				if (hh[i]) {
					h = hh[i] + abs(x - xx[i]) + abs(y - yy[i]);
				}
			}
			rep(i, N) {
				if (hh[i]) {
					if (h != hh[i] + abs(x - xx[i]) + abs(y - yy[i])) {
						h = 0;
					}
				}
				else {
					if (h - abs(x - xx[i]) - abs(y - yy[i]) > 0) {
						h = 0;
					}
				}
			}
			if (h) {
				cx = x; cy = y; ch = h;
				f = 1; break;
			}
		}
		if (f) break;
	}
	cout << cx << " " << cy << " " << ch << endl;
}

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

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int N;
int L[110];

int main()
{
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        cin >> L[i];
    }

    int count = 0;
    for (int i = 0; i < N; i++)
    {
        for (int j = i; j < N; j++)
        {
            for (int k = j; k < N; k++)
            {
                if (L[i] != L[j] && L[i] != L[k] && L[j] != L[k])
                {
                    vector<int> check = {L[i], L[j], L[k]};
                    sort(check.begin(), check.end());
                    if (check[0] + check[1] > check[2])
                        count++;
                }
            }
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 3588
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int ans = 0;
  int ren = 1;
  int a[n];
  FOR(i,0,n){
    cin >> a[i];
  }
  FOR(i,0,n-1){
    if(a[i] == a[i+1]){
      ren++;
    } else {
      ans += ren / 2;
      ren = 1;
    }
  }
  ans += ren / 2;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
char field[2001][2001];
int left_cnt[2001][2001], right_cnt[2001][2001], up_cnt[2001][2001], down_cnt[2001][2001];
int main()
{
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            cin >> field[i][j];
        }
    }
    for (int i = 0; i < n; ++i)
    {
        int cnt1 = 0;
        for (int j = 0; j < m; ++j)
        {
            if (field[i][j] == '.')
            {
                left_cnt[i][j] = cnt1;
                ++cnt1;
            }
            else
            {
                cnt1 = 0;
            }
        }

        int cnt2 = 0;
        for (int j = m - 1; j >= 0; --j)
        {
            if (field[i][j] == '.')
            {
                right_cnt[i][j] = cnt2;
                ++cnt2;
            }
            else
            {
                cnt2 = 0;
            }
        }
    }

    for (int j = 0; j < m; ++j)
    {
        int cnt1 = 0;
        for (int i = 0; i < n; ++i)
        {
            if (field[i][j] == '.')
            {
                up_cnt[i][j] = cnt1;
                ++cnt1;
            }
            else
            {
                cnt1 = 0;
            }
        }

        int cnt2 = 0;
        for (int i = n - 1; i >= 0; --i)
        {
            if (field[i][j] == '.')
            {
                down_cnt[i][j] = cnt2;
                ++cnt2;
            }
            else
            {
                cnt2 = 0;
            }
        }
    }
    long long mi = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            if (field[i][j] == '.')
            {
                long long x = (left_cnt[i][j] + right_cnt[i][j]) + (up_cnt[i][j] + down_cnt[i][j]);
                mi = max(x, mi);
            }
        }
    }
    cout << mi + 1 << endl;
}

Measured memory_bytes: 66688
#include<iostream>
 #include<fstream>
 #include<utility>

 using namespace std;

 int main(){
     int a, b, c, n, i;
     string str;

     getline(cin,str);
     sscanf(str.c_str(),"%d",&n);
     if(n < 0 || 1000 < n){
         return 0;
     }

     for(i=0;i<n;i++){
         getline(cin,str);
         sscanf(str.c_str(),"%d %d %d",&a,&b,&c);
         if(a < b){
             swap(a,b);
         }
         if(a < c){
             swap(a,c);
         }
         if(a <= 1000 && 1 <= b && 1 <= c){
             if(a*a == b*b + c*c){
                 cout << "YES" << endl;
             }else{
                 cout << "NO" << endl;
             }
         }else{
             cout << "ERROR: wrong type data input" << endl;
         }
     }
     return 0;
 }

Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
int x,t;
int main()
{
	scanf("%d",&x);
	for (int i=1;i<=x;i++)
	 if (i*(i+1)/2>=x) {
	 	t=i; break;
	 }
	for (int i=t;i>=1;i--)
	 if (i*(i-1)/2<x) {
	 	printf("%d\n",i); x-=i;
	 } 
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <memory.h>
 
using namespace std;
const int maxn = 1000005;
const int mod = 998244353;
typedef long long LL;

int fac[maxn],inc[maxn],ans,n,m;
LL fpm(LL p,LL k) {
	LL res=1ll;
	while (k) {
		if (k&1) (res*=p)%=mod;
		(p*=p)%=mod;k>>=1;
	}
	return res;
}
LL calc(int n,int m) {
	return (LL)fac[n+m]*inc[n]%mod*(LL)inc[m]%mod;
}
int main()
{
	#ifdef Amberframe
		freopen("agc019f.in","r",stdin);
		freopen("agc019f.out","w",stdout);
	#endif
	scanf("%d %d",&n,&m);
	if (n<m) swap(n,m);
	fac[0]=inc[0]=1;
	for (int i=1;i<=n+m;i++) fac[i]=(LL)fac[i-1]*i%mod;
	inc[n+m]=fpm(fac[n+m],mod-2);
	for (int i=n+m;i>=2;i--) inc[i-1]=(LL)inc[i]*i%mod;
	
	for (int i=0;i<m-1;i++)
		ans=(ans+calc(i,i+1)*calc(n-1-i,m-i-2)%mod*(LL)(2*i+2))%mod;
	for (int i=0;i<m-1;i++)
		ans=(ans-calc(i,i+2)*calc(n-i-2,m-i-2)%mod*(LL)(2*i+3))%mod;
	ans=(ans+calc(n-1,m)*(n+m))%mod;
	for (int i=0;i<=m-1;i++)
		ans=(ans+calc(i,i)*calc(n-i-1,m-1-i)%mod*(LL)(2*i+1))%mod;
	for (int i=1;i<=m-1;i++)
		ans=(ans-calc(i,i-1)*calc(n-i,m-1-i)%mod*(LL)(2*i))%mod;
	ans=ans*fpm(calc(n,m),mod-2)%mod;
	printf("%lld\n",ans<0?ans+mod:ans);
	return 0;
}

Measured memory_bytes: 8064
#include<stdio.h>
#include<stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main() {
    unsigned short *A, *B;
    
    int C[VMAX + 1];
    int n, i, j;
    scanf("%d", &n);
    
    A = malloc(sizeof(short) * n + 1);
    B = malloc(sizeof(short) * n + 1);
    
    for (i = 0; i <= VMAX; i++) C[i] = 0;
    
    for (i = 0; i < n; i++) {
        scanf("%hu", &A[i + 1]);
        C[A[i + 1]]++;
    }
    
    for (i = 1; i <= VMAX; i++) C[i] = C[i] + C[i - 1];
    
    for (j = 1; j <=n; j++) {
        B[C[A[j]]] = A[j];
        C[A[j]]--;
    }
    
    for (i = 1; i <= n; i++) {
        if (i > 1) printf(" ");
        printf("%d", B[i]);
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 9620
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string.h>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)
int main(void)
{
    int N;
    cin >> N;
    char *s;
    s = new char [N];
    for(int i=0;i<N;i++){
        cin >> s[i];
    }
    int K;
    cin >> K;
    for(int i=0;i<N;i++){
        if(s[i]!=s[K-1]){
            s[i] = '*';
        }
    }
    for(int i=0;i<N;i++){
        cout << s[i];
    }
    return 0;
}

Measured memory_bytes: 256
"use strict";
const main = input => {
    const n = parseInt(input[0],10);
    const p = input[1].split(' ');
    let ans=0;
    for(let i=0; i<n; i++) {
        p[i] = parseInt(p[i], 10);
    }
    for(let i=1; i<n-1; i++) {
        if ((p[i]>p[i-1] && p[i]<p[i+1]) || (p[i]<p[i-1] && p[i]>p[i+1])) {
            ans++;
        }
    }
    console.log(ans);
    
}
main(require("fs").readFileSync("/dev/stdin", "utf8").split('\n'));

Measured memory_bytes: 7500
use std::io;
use std::str::FromStr;
use std::collections::VecDeque;
use std::cmp::max;

fn input<T:FromStr>() -> T {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().parse().ok().unwrap()
}

fn input_tuple() -> (u64, u64) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<u64> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1])
}

fn prime_numbers(limit: u64) -> Vec<u64> {
    let mut is_candidate = vec![true; (limit + 1) as usize];
    let mut prime_numbers: Vec<u64> = Vec::new();
    for i in 2..(limit+1) {
        if is_candidate[i as usize] {
            prime_numbers.push(i);
            let mut j = 2;
            while i * j < limit + 1 {
                is_candidate[(i * j) as usize] = false;
                j += 1;
            }
        }
    }
    prime_numbers
}

fn binary_search<F>(mut ok: i32, mut ng: i32, is_ok: F) -> i32
    where
        F: Fn(usize) -> bool
    {
        while (ok - ng).abs() > 1 {
            let mid = (ok + ng) / 2;
            if is_ok(mid as usize) {
                ok = mid;
            } else {
                ng = mid;
            }
        }
        ok
}

fn main() {
    let q: u64 = input();    
    let prime_nums = prime_numbers(100_000);
    let mut candidates: VecDeque<u64> = VecDeque::new();
    // println!("len = {}", prime_nums.len());
    for p in &prime_nums {
        if *p != 2 && prime_nums.contains(&((p + 1) / 2)) {
            candidates.push_back(*p);
        }
    }
    let mut counts = vec![0; 100_000];
    for i in 1..100_000usize {
        if !candidates.is_empty() && i == *candidates.front().unwrap() as usize {
            candidates.pop_front();
            counts[i] = counts[i - 1] + 1;
        } else {
            counts[i] = counts[i - 1];
        }
    }
    for _ in 0..q {
        let (l, r) = input_tuple();
        println!("{}", counts[r as usize] - counts[l as usize - 1]);
    }
}


Measured memory_bytes: 2520
N = int(input())
INF = int(1e10)
dp = [INF] * N
dp[0] = 1
dp = [0] + dp

bt = set()
for i in range(1, 100):
    if 6**i > N:
        break
    bt.add(6**i)

for i in range(1, 100):
    if 9**i > N:
        break
    bt.add(9**i)

bt = sorted(bt)

for i in range(1, N+1):
    dp[i] = dp[i-1] + 1
    for j in bt:
        if i - j >= 0:
            dp[i] = min(dp[i], dp[i - j] + 1)

print(dp[N])


Measured memory_bytes: 42080
#include <bits/stdc++.h>
#define endl "\n"
#define ll long long int
#define mod 1000000007
#define mem(a,val) memset(a,val,sizeof(a))

using namespace std;
int main()
{
	std::ios::sync_with_stdio(false);
	int a,b,c;
  	cin>>a>>b>>c;
    cout<<c<<" "<<a<<" "<<b;
	return 0;
}


Measured memory_bytes: 256
S = input()
L1 = S[:2]
L2 = S[2:]

if (1<=int(L1)<=12)&(1<=int(L2)<=12):
    print("AMBIGUOUS")
elif (1<=int(L2)<=12):
    print("YYMM")
elif (1<=int(L1)<=12):
    print("MMYY")
else:
    print("NA")

Measured memory_bytes: 3060
#include <stdio.h>

int linear(int a[], int b[], int n, int m) {
  int cnt = 0;
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
      if (b[i] == a[j]){
        cnt++;
        break;
      }
    }
  }
  return cnt;
}

int main() {
  int n;
  scanf("%d", &n);
  int a[n];
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  int m;
  scanf("%d", &m);
  int b[m];
  for (int i = 0; i < m; i++) {
    scanf("%d", &b[i]);
  }
  printf("%d\n", linear(a, b, n, m));
  return 0;
}



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

int main()
{
    ll n,sum=0;
    cin>>n;

    ll arr[1000001]={0};

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

    ll q;
    cin>>q;

    for(ll i=0;i<q;i++)
    {
        ll b,c;
        cin>>b>>c;

        sum+=arr[b]*(c-b);
        arr[c]+=arr[b];
        arr[b]=0;
        cout<<sum<<"\n";
    }


    return 0;
}


Measured memory_bytes: 11344
#include <bits/stdc++.h>
#include <chrono>
#include <random>
#include <sstream>
#include <string>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
using namespace std;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
const int N=100001;
bool vis[N];
vector <int> adj[N];
ll gcd(ll a, ll b) { if (a == 0) return b; return gcd(b % a, a); } 
ll lcm(ll a, ll b){return a*b/gcd(a, b);}
// ll binaryNum[8];
// void decToBinary(ll n) 
// { 
//     // binaryNum[8];
//     rep(i,8){
//         binaryNum[i]=0;
//     }
//     int i = 0; 
//     while (n > 0) { 
//         binaryNum[i] = n % 2; 
//         n = n / 2; 
//         i++; 
//     } 
// } 
vl cnt;
vi prnt;
void dfs(ll u, ll parent){
    // vis[u]=true;
    ll a=0;
    if(adj[u].size()==1){
        // cout<<u<<' ';
        cnt[u]=1;
    }
    // cout<<u<<' ';
    for(int v:adj[u]){
        if(v!=parent){
            a++;
            prnt[v]=u;
            dfs(v, u);
            // cnt[u]+=cnt[v];
        }
    }
    if(u!=1){
        cnt[parent]+=cnt[u];
    }

}

void solve(){
    ll n,x,t;
    cin>>n>>x>>t;
    if(n%x==0){
        cout<<(n/x)*t;
    }
    else{
        cout<<(n/x + 1)*t;
    }
    



}


int main()
{
    // cout<<1<<endl;
    #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif
    
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    // cin>>T;
    int t=0;
    while(t++<T)
    {
        // cout<<"Case #"<<t<<":"<<' ';
        solve();
        //cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 6144
#include <iostream>
#include <vector>
#include <string>

using namespace std;

class Tree {
public:
	explicit Tree() {
		nodes.emplace_back(0);
	}
	void add(const string& s){
		int cur = 0;
		for(int i=0;i<s.size();i++){
			int& nextNode = nodes[cur].next[s[i]-'0'];
			if(nextNode == -1){
				nodes.emplace_back(i+1);
				nextNode = nodes.size() - 1;
			}
			cur = nextNode;
		}
	}
	bool solve(long long L) const {
		long long grundy = 0LL;
		for(const auto& node : nodes){
			if(!node.valid()) continue;
			long long level = L - node.depth;
			if(level <= 0) continue;
			for(int i=0;;i++){
				if(level&(1LL<<i)){
					grundy ^= (1LL << i);
					break;
				}
			}
		}
		return grundy != 0LL;
	}
private:
	class Node {
	public:
		explicit Node(int d) : depth(d), next(2, -1) {}
		bool valid() const{
			int cnt = 0;
			for(int t : next) if(t == -1) ++cnt;
			return cnt == 1;
		}
		int depth;
		vector<int> next;
	};
private:
	vector<Node> nodes;
};

int main(){
	int N; long long L;
	while(cin >> N >> L){
		Tree tree;
		for(int i=0;i<N;i++){
			string s; cin >> s;
			tree.add(s);
		}
		cout << (tree.solve(L) ? "Alice" : "Bob") << endl;
	}
}


Measured memory_bytes: 8048
import java.io.*;
import java.util.HashMap;

class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();
        int N = Integer.parseInt(str);
        HashMap<String,Integer> map = new HashMap<>();
        for (int i=0;i<N;i++){
            str = br.readLine();
            if (map.containsKey(str)){
                map.put(str,map.get(str)+1);
            } else {
                map.put(str,1);
            }
        }
        int ans = 0;
        for (String s:map.keySet()){
            if (map.get(s)%2!=0){
                ans++;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 32084
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
	while (1) {
		int h, w;
		cin >> h >> w;
		if (h == 0) {
			break;
		}

		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if ((i + j) % 2 == 0) {
					cout << "#";
				} else {
					cout << ".";
				}
			}
			cout << endl;
		}
		cout << endl;
	}

	return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int a[105];
int main() {
  int n;
  cin >> n;
  for(int i=0;i<n;i++) {
    cin >> a[i];
  }
  sort(a,a+n);
  ll A = 0, B = 0;
  int t = 0;
  for(int i=n-1;i>=0;i--) {
    if(t==0) A += a[i];
    else B += a[i];
    t = 1-t;
  }
  cout << A-B << endl;
  return 0;
}


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

int main() {
	int x;
	string str;

	cin >> x;
	cin >> str;
	for (int i = 0; i < str.length(); i++) {
		str[i] = (str[i] - 'A' + x) % 26 + 'A';
	}

	cout << str;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
const long long mod = 1000000007LL;

int main() {
  ll n, k;
  cin >> n >> k;
  vll a(n);
  rep(i,n) cin >> a[i];
  rep(i,min(k,100LL)) {
    vector<ll> v(n);
    rep(i,n) {
      v[max(0LL,i-a[i])]++;
      ll m = min(n-1,i+a[i]);
      if(m<n-1) v[m+1]--;
    }
    ll cnt = 0;
    rep(i,n) {
      cnt += v[i];
      a[i] = cnt;
    }
  }
  rep(i,n) cout << a[i] << endl;
  return 0;
}

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

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

struct Edge {
    int from, to;
    cost_t cost;
    Edge(int from, int to, cost_t cost) : from(from), to(to), cost(cost) {}
};

using Edges = vector<Edge>;
using Graph = vector<Edges>;

Edges bridgesDetection(Graph& g){
    int n = g.size();
    vector<int> pre(n,-1);
    vector<int> low(n);
    Edges res;
    int k=0;
    function<int(int,int)> dfs=[&](int v,int prev){
        low[v] = pre[v];
        for(auto& e:g[v]){
            if(e.to==prev) continue;
            if(pre[e.to]==-1){
                pre[e.to] = k++;
                low[v] = min(low[v], dfs(e.to,v));
                if(pre[v]<low[e.to]) res.push_back(e);
            }
            else low[v] = min(low[v], pre[e.to]);
        }
        return low[v];
    };
    for(int i=0;i<n;i++){
        if(pre[i]==-1){
            pre[i]=k++;
            dfs(i,-1);
        }
    }
    return res;
}
int main(){
    int V,E;
    cin>>V>>E;
    Graph g(V);
    for(int i=0;i<E;i++){
        int s,t;
        cin>>s>>t;
        g[s].push_back(Edge(s,t,0));
        g[t].push_back(Edge(t,s,0));
    }
    auto res = bridgesDetection(g);
    auto cmp=[&](Edge lhs,Edge rhs){
        auto mP=[&](Edge e){
            return make_pair(min(e.from,e.to),max(e.from,e.to));
        };
        auto lP=mP(lhs),rP=mP(rhs);
        return lP<rP;
    };
    sort(res.begin(),res.end(),cmp);
    for(auto &e:res){
        cout<<min(e.from,e.to)<<" "<<max(e.from,e.to)<<endl;
    }
    return 0;
}



Measured memory_bytes: 5956
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
const double PI = 4*atan(1);
const int INF = 0x3f3f3f3f;
const int MOD = 1e9+7;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-9;
const string YES = "Possible";
const string NO = "Impossible";
#define pb push_back
#define mp make_pair
#define eb emplace_back

const int MAX_N = 1e6+10;
int N;
int A[MAX_N];

void solve()
{
	bool ok = true;
	set<int> seen;
	for(int i=0;i<N;++i){
		int a = A[i];
		for(int x=2;x*x<=a;++x)if(a%x==0){
			if(seen.count(x)){
				ok=false;
				goto out;
			}
			seen.insert(x);
			while(a%x==0) a/=x;
		}
		if(a!=1){
            if(seen.count(a)){
                ok = false;
                goto out;
            }
            seen.insert(a);
		}
	}
  out:
	if(ok){
		cout<<"pairwise coprime\n";
		return;
	}
	int g = 0;
	for(int i=0;i<N;++i) g=__gcd(g,A[i]);
	if(g == 1){
		cout << "setwise coprime\n";
	}else{
		cout<< "not coprime\n";
	}
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	cin >> N;
	for(int i=0;i<N;++i) cin >> A[i];
	solve();
	return 0;
}

Measured memory_bytes: 7600
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringJoiner;
import java.util.StringTokenizer;
import java.util.function.IntUnaryOperator;
import java.util.function.LongUnaryOperator;

public class Main {
    static In in = new In();
    static Out out = new Out();
    static long mod = 1000000007;
    static long inf = 0xfffffffffffffffL;

    void solve() {
        double l = in.nextInt();
        System.out.println((l / 3) * (l / 3) * (l / 3));
    }

    public static void main(String[]$) {
        new Main().solve();
        out.flush();
    }
}

class In {
    private BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 0x10000);
    private StringTokenizer tokenizer;

    String next() {
        try {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                tokenizer = new StringTokenizer(reader.readLine());
            }
        } catch (IOException ignored) {
        }
        return tokenizer.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    char[][] nextCharArray(int n, int m) {
        char[][] a = new char[n][m];
        for (int i = 0; i < n; i++) {
            a[i] = next().toCharArray();
        }
        return a;
    }

    int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextInt();
        }
        return a;
    }

    int[] nextIntArray(int n, IntUnaryOperator op) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsInt(nextInt());
        }
        return a;
    }

    long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextLong();
        }
        return a;
    }

    long[] nextLongArray(int n, LongUnaryOperator op) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsLong(nextLong());
        }
        return a;
    }
}

class Out {
    private PrintWriter out = new PrintWriter(System.out);
    boolean autoFlush = false;

    void println(Object... a) {
        StringJoiner joiner = new StringJoiner(" ");
        for (Object obj : a) {
            joiner.add(String.valueOf(obj));
        }
        out.println(joiner);
        if (autoFlush) {
            out.flush();
        }
    }

    void println(int[] a) {
        StringJoiner joiner = new StringJoiner(" ");
        for (int i : a) {
            joiner.add(Integer.toString(i));
        }
        out.println(joiner);
        if (autoFlush) {
            out.flush();
        }
    }

    void println(long[] a) {
        StringJoiner joiner = new StringJoiner(" ");
        for (long i : a) {
            joiner.add(Long.toString(i));
        }
        out.println(joiner);
        if (autoFlush) {
            out.flush();
        }
    }

    void flush() {
        out.flush();
    }
}


Measured memory_bytes: 21460
//
#include <vector>
#include <set>
#include <map>
#include <array>
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <numeric>
#include <bitset>
#include <iomanip>
//
using ll = long long;
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
#define outD(fpv) cout << setprecision(20) << fpv << endl;
inline void yes(bool cond) { cond ? puts("Yes") : puts("No"); }
inline void YES(bool cond) { cond ? puts("YES") : puts("NO"); }
template<typename Type> inline void chmin(Type& a, Type b) { if (a > b) a = b; }
template<typename Type> inline void chmax(Type& a, Type b) { if (a < b) a = b; }
template<typename Arr, typename Type> inline void fill(Arr& arr, Type v) { std::fill(arr.begin(), arr.end(), v); }
template<typename Type> inline void sort(Type& arr) { std::sort(arr.begin(), arr.end()); }
template<typename Type> inline void reverse(Type& arr) { reverse(arr.begin(), arr.end()); }
template<typename Type> inline Type nth(vector<Type>& arr, size_t pos) { std::nth_element(arr.begin(), arr.begin() + pos, arr.end()); return arr[pos]; }
template<typename Type> inline void unique(Type& arr) { sort(arr); arr.erase(unique(arr.begin(), arr.end()), arr.end()); }
constexpr ll INF_I = std::numeric_limits<ll>::max();
constexpr ll BIGP = 1e9 + 7;
constexpr double INF_F = std::numeric_limits<float>::infinity();
constexpr double PI = 3.14159265358979323846L;
using P = pair<ll, ll>;
//
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<ll> V(N), C(N);
    rep(i, N) cin >> V[i];
    rep(i, N) cin >> C[i];
    //
    ll ans = 0;
    rep(i, N) ans += max(V[i] - C[i], 0LL);
    cout << ans;

    return 0;
}

Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 5;
int main()
{
    long long int n; cin>>n;
    long long int k; cin>>k;
    vector<long long int> arr;
    for(int i=0;i<n;i++)
    {
        long long int x; cin>>x;
        arr.push_back(x);
    }
    vector<int> dp(n, INF);
    dp[0] = 0;
    for(int i = 0; i < n; ++i) {
        for(int j = i + 1; j <= i + k; ++j) {
            if(j < n) {
                int cost = dp[i] + abs(arr[i] - arr[j]);
                dp[j] = min(dp[j], cost);
            }
        }
    }

    cout<<dp[n-1]<<endl;
}

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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define show(x) cout << #x << " = " << x ln
#define dbg(x) cout<<#x"="<<x ln

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

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n, s[100], sum, p;

int main() {
	cin >> n;
	rep(i,n) cin >> s[i], sum += s[i];
	if (sum%10!=0) {
		cout << sum << ln;
		return 0;
	} else {
		sort(s, s+n);
		rep(i,n) {
			if (s[i]%10!=0) {
				cout << sum-s[i] << ln;
				return 0;
			}
		}
		cout << 0 << ln;
	}
}

Measured memory_bytes: 256
#!/usr/bin/env python3



# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    # Failed to predict input format
    S = input().replace('?', '.')
    T = input()

    import re
    import sys

    for i in range(len(S)-len(T),-1,-1):
        if(re.match(S[i:i+len(T)],T)):
            S = S.replace('.', 'a')
            print(S[:i]+T+S[i+len(T):])
            exit()
    else:
        print("UNRESTORABLE")
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
#include<iostream>
#include <algorithm>
#include<string>
#include <bitset>
#include <vector>
#include <functional>
#include <climits>
#include <iomanip>
#include <utility>
#include <stack>
#include <queue>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <numeric>
#include <stack>
#include <map> // pair
#include <cstdlib>  // abs() for integer
#include <cmath>    // abs() for float, and fabs()
typedef std::stack<int> IntStack;
typedef std::stack<char> charStack;
#define START 0
#define FORWARD 1
#define BACK 2
using namespace std;
using ll = long long;
typedef pair <ll, ll > pll;
bool comp(const pll &a, const pll &b) {
	return a.first < b.first;
}
//*********************************************************
// 最大公約数（Greatest Common Divisor）を返す。
// 引数に０がある場合は０を返す。
//*********************************************************
ll gcd(ll a, ll b)
{
	ll tmp, r;
	if (a < b) {
		tmp = a;
		a = b;
		b = tmp;
	}

	/* ユークリッドの互除法 */
	r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}
	return b;
	//// 引数に０がある場合は０を返す
	//if ((0 == m) || (0 == n))
	//	return 0;

	//// ユークリッドの方法
	//while (m != n)
	//{
	//	if (m > n) m = m - n;
	//	else         n = n - m;
	//}
	//return m;
}//gcd

int main()
{
	ll a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, ans = 0;
	ll x[200004] = {};
	ll y[200004] = {};
	ll z[2003][2003] = { {} };
	vector<tuple<ll, ll>> vec;
	string s;
	string t;
	//IntStack yStack;
	//charStack Stack;
	//vector<pair<int, int> > pairs(a);
	//cout << LLONG_MAX<< endl;

	cin >> s;
	for (int i = 0; i < 4; i++)
	{
		x[s[i] - 'A']++;
	}
	for (int i = 0; i < 30; i++)
	{
		if (x[i]==2)
		{
			ans++;
		}
	}
	if (ans==2)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}


	//cout << ans << endl;


	////std::cout << std::fixed;
	//cout << std::setprecision(20) << << endl;
	//cout << d+1 << endl;
	//cout << "" << endl;

	return 0;
}
//sort(x, x + a, std::greater<ll>());

//char型の文字数字は、-'0'で数値に変換できる
//accumulate(x, x + a, 0);//int型までの配列の合計
//memcpy(x, visited, sizeof(ll)*n);
//void kansuu(ll num, ll visited[10]) {}
//kansuu(1, zz);
//cout << setprecision(15) << v << endl;
//cout << char(z - 'a');
//log10(i) + 1 //10進数の桁数を取得
//
//int temp;
//for (int i = 0; i < n - 1; i++) {
//	for (int j = n - 1; j > i; j--) {
//		if (w[j - 1] < w[j]) {  /* 前の要素の方が大きかったら */
//			temp = w[j];        /* 交換する */
//			w[j] = w[j - 1];
//			w[j - 1] = temp;
//		}
//	}
//}
//
//最小公倍数
//ll x = a * b;
//ll tmp;
///* 自然数 a > b を確認・入替 */
//if (a<b) {
//	tmp = a;
//	a = b;
//	b = tmp;
//}
///* ユークリッドの互除法 */
//ll r = a % b;
//while (r != 0) {
//	a = b;
//	b = r;
//	r = a % b;
//}
//a = x / b;//答え


/*vector<pair<ll, ll> > hoges(a);
for (int i = 0; i < a; i++)
{
cin >> x[i];
cin >> y[i];
hoges[i] = make_pair(x[i], y[i]);
}
sort(hoges.begin(),hoges.end(),comp);
for (int i = 0; i < a; i++)
{
if (hoges[i].second>=b)
{
ans += hoges[i].first*b;
break;
}
else
{
ans += hoges[i].first*hoges[i].second;
b -= hoges[i].second;

}
}*/

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
using namespace std;
typedef long long ll;

const int INF = 1001001001;
const int MOD = 1e9+7;

int main() {
    int n; cin >> n;
    ll k; cin >> k;
    vector<ll> a(n), f(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++)
    {
        cin >> f[i];
    }
    sort(a.begin(), a.end());
    sort(f.begin(), f.end());
    reverse(f.begin(), f.end());

    ll left = -1, right = 1e12;
    while (left+1 < right) {
        ll mid = (left+right)/2;
        ll cnt = 0;
        for (int i = 0; i < n; i++)
        {
            cnt += max(0ll, a[i]-mid/f[i]);
        }
        if(cnt <= k) {
            right = mid;
        } else {
            left = mid;
        }
    }
    
    cout << right << endl;

    return 0;
}

Measured memory_bytes: 3456
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    int N, M;
    cin >> N >> M;
    vector<int> A(M, 0);
    int sum = 0;
    for (int i = 0; i < M; ++i) {
        cin >> A[i];
        sum += A[i];
    }
    if (sum <= N) cout << N - sum << endl;
    else cout << -1 << endl;
}


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

#define rep(i, N) for(int i = 0;i < N;i++)

typedef long long ll;

const int mod = 1e9 + 7;

using namespace std;



int main(void) {
	int D; cin >> D;
	vector<int> c(26, 0);
	rep(i, 26)cin >> c[i];
	vector<vector<int>> s(D, vector<int>(26, 0));
	rep(i, D)rep(j, 26)cin >> s[i][j];
	
	vector<int> t(D);
	rep(i, D) {
		cin >> t[i];
		t[i]--;
	}
	vector<int> last(26, 0);

	int v = 0;
	rep(i, D) {
		v += s[i][t[i]];
		last[t[i]] = i+1;
		rep(j, 26) {
			v -= c[j] * (i + 1 - last[j]);
		}
		cout << v << endl;
	}

	return 0;
}

Measured memory_bytes: 3648
s = gets.chomp.split('')
check = 0
s.size.times do |i|
  if i.even? || i == 0
    check += 1 if s[i] == 'h'
  else
    check += 1 if s[i] == 'i'
  end
end
if check == s.size && s.size.even?
  puts :Yes
else
  puts :No
end

Measured memory_bytes: 1788
from __future__ import print_function

from functools import reduce
from operator import mul
from collections import Counter
from collections import deque
from itertools import accumulate
from queue import Queue
from queue import PriorityQueue as pq
from heapq import heapreplace
from heapq import heapify
from heapq import heappushpop
from heapq import heappop
from heapq import heappush
import heapq
import time
import random
import bisect
import itertools
import collections
from fractions import Fraction
import fractions
import string
import math
import operator
import functools
import copy
import array
import re
import sys
sys.setrecursionlimit(500000)


input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return

# from fractions import gcd
# from math import gcd

# def lcm(n, m):
#     return int(n * m / gcd(n, m))


# def coprimize(p, q):
#     common = gcd(p, q)
#     return (p // common, q // common)


# def find_gcd(list_l):
#     x = reduce(gcd, list_l)
#     return x


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


mod = 1000000007


def combinations_count_mod(n, r):
    r = min(r, n - r)
    numer = reduce(lambda x, y: x * y % mod, range(n, n - r, -1), 1)
    denom = pow(reduce(lambda x, y: x * y % mod, range(1, r + 1), 1), mod - 2, mod)
    return numer * denom % mod


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:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[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())

def solve():
    pass


def main():
    n, m = map(int, input().strip().split())

    uf = UnionFind(n)

    ans = 1
    for i in range(m):
        a, b = map(lambda x: int(x)-1, input().strip().split())
        if a > b:
            c = a
            a = b
            b = c
        uf.union(a,b)
        ans = max(ans,uf.size(a))
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 88668
import java.util.*;
public class Main
{
	public static void main(String[] args) 
	{
		Scanner in=new Scanner(System.in);
		int a[]={1,4,9,16,25,36,49,64,81,100,121,144,169,196,225,256,289};//a.length=17
		int dp[]=new int[301];
		dp[0]=1;
		for(int i=0;i<a.length;i++)//使える数字
			for(int j=a[i];j<=300;j++)//テーブルを埋めていく
				dp[j]+=dp[j-a[i]];
		for(;;)
		{
			int n=in.nextInt();
			if(n==0)
				return;
			System.out.println(dp[n]);
		}
	}


	static public void debug(Object... o)
	{
		System.out.println(Arrays.deepToString(o));
	}
}

Measured memory_bytes: 17176
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

pub fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

pub fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn main() {
    let n: usize = read();
    let a: Vec<u64> = read_vec();

    let mut xor = 0;
    let mut sum = 0;
    let mut l = 0;
    let mut ans = 0;
    for r in 0..n {
        xor = xor ^ a[r];
        sum += a[r];
        while sum != xor {
            xor = xor ^ a[l];
            sum -= a[l];
            l += 1;
        }
        ans += r - l + 1;
    }

    println!("{}", ans);
}


Measured memory_bytes: 10492
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

int A[4];

int main()
{
	cin >> A[0] >> A[1] >> A[2];
	sort(A, A + 3);
	if (A[0] == 5 && A[1] == 5 && A[2] == 7)
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long int m,n,sum=0;
	cin>>n>>m;
	m-=2*n;
	if(m>=0){
		sum+=n;
		sum+=m/4;
	}
	else{
		m+=2*n;
		sum+=m/2;
	}
	cout<<sum;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
 
using namespace std;
typedef long long ll;
 
int main(){
  int N,Q;
  cin >> N >> Q;

  vector<vector<int> > t(N);

  int a,b;
  for(int i=0;i<N-1;i++){
    cin >> a >> b;
    t[a-1].push_back(b-1);
    t[b-1].push_back(a-1);
  }

  vector<int> w(N,0);
  int p,x;
  for(int i=0;i<Q;i++){
    cin >> p >> x;
    w[p-1]+=x;
  }

  vector<int> r(N,0);
  vector<bool> visited(N,false);
  deque<int> stk;

  stk.push_back(0);
  int cp=0;
  r[0]=w[0];
  visited[0]=true;
  
  while(!stk.empty()){
    cp=stk.back();
    stk.pop_back();
    for(auto np: t[cp]){
      if(!visited[np]){
	visited[np]=true;
	stk.push_back(np);
	r[np]=w[np]+r[cp];
      }
    }
  }

  for(int i=0;i<N;i++){
    cout << r[i] << " ";
  }
  cout << endl;
  
}


Measured memory_bytes: 16372
#include <stdio.h>

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

	int i;
	int max = 0;
	int sum = 0;
	int num;
	for (i = 0; i < n; i++) {
		scanf("%d", &num);

		if (num > max)
			max = num;
		sum += num;
	}

	if ((sum - max) > max)
		printf("Yes\n");
	else
		printf("No\n");

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
int main(void){
	int n,i,j;
	cin>>n;
	string s[n];
	int p[n],b[n];
	for(i=0;i<n;i++){
		cin>>s[i]>>p[i];
		b[i]=i;
	}
	for(i=0;i<n;i++){
		for(j=i+1;j<n;j++){
			if(s[i]>s[j]){
				swap(s[i],s[j]);
				swap(p[i],p[j]);
				swap(b[i],b[j]);
			}else if(s[i]==s[j]&&p[i]<p[j]){
				swap(s[i],s[j]);
				swap(p[i],p[j]);
				swap(b[i],b[j]);
			}
		}
	}
	for(i=0;i<n;i++)cout<<b[i]+1<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#define MAX 1000000

int main(void){
  int i,c;
  int a,d,n;
  char p[MAX];
	
  p[0]=0;
  p[1]=0;                       //1ÍfÅÈ¢
  p[2]=1;                       //2ÍfÅ é
  for(i=3;i<MAX;i+=2)p[i]=1;    //ïÍfÌÂ\«ª é
  for(i=4;i<MAX;i+=2)p[i]=0;    //ôÍfÌÂ\«ªÈ¢

  c = 3;  
  while(1){
    for(i=2*c;i<MAX;i+=c)p[i] = 0;   //©gÌ{ÌcheckðÍ¸·
    while(!p[++c]);                    //
    if(c>1000)break;
  }
  
  while(1){
    scanf("%d %d %d ",&a,&d,&n);
    if(!a && !d && !n)break;
    c = 0;
    i = 0;
    while(1){
      if(p[a+i*d])c++;
      if(n==c){
	printf("%d\n",a+i*d);
	break;
      }
      i++;
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll d,g,p,c,ans=1e9,ans_,tmp,lastdig;cin>>d>>g;
  vector<P> v(d);rep(i,d) {cin>>p>>c;v[i]=P(p,c);}
  ll l=1<<d;
  rep(bit,l) {
    tmp=0,ans_=0;
    rep(dig,d) {
      if((bit>>dig)&1) {
        tmp+=100*(dig+1)*v[dig].first+v[dig].second;
        ans_+=v[dig].first;
        if(tmp>=g) break;
      }
      else lastdig=dig;
    }
    if(g>tmp) {
      rep(i,v[lastdig].first) {
        tmp+=100*(lastdig+1);ans_++;
        if(tmp>=g) break;
      }
    }
    if(tmp>=g) ans=min(ans,ans_);
  }
  print(ans);
  return 0;
}

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

int main() {
    int a, b; cin >> a >> b;
    int res = 1;
    if (b == 1) {
        cout << 0 << endl;
        return 0;
    } else {
        while (b > a * res - (res - 1)) res++;
    }

    cout << res << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    int from1=(n-1)*(n-2)/2;
    if(from1<k){
        cout<<"-1"<<endl;
        return 0;
    }
    cout<<n+from1-k-1<<endl;
    k=from1-k;
    for(int i=2;i<=n;i++)cout<<1<<" "<<i<<endl;
    bool br=0;
    for(int i=2;i<n;i++){
        for(int j=i+1;j<=n;j++){
            if(k==0){
                br=1;
                break;
            }
            cout<<i<<" "<<j<<endl;
            k--;
        }
        if(br)break;
    }
    return 0;
}

Measured memory_bytes: 256
n=gets.to_i
l=[0]*100
n.times do |mm|
  m=mm+1
  k=m.to_s[0].to_i*10+m%10
  l[k]+=1
end
c=0
100.times do |i|
  c+=l[i]*l[i%10*10+i/10]
end
puts c


Measured memory_bytes: 3836