akhauriyash/Code-Regression huggingface dataset:
import sys
input = sys.stdin.readline
from heapq import heappop, heappush

class UnionFind:
    def __init__(self, n):
        self.parent = [i for i in range(n)]
        self.rank = [0] * n

    def find(self, x):
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.rank[x] < self.rank[y]:
            self.parent[x] = y
        else:
            self.parent[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

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


def main():
    N = int(input())
    X = []
    Y = []
    for i, _ in enumerate(range(N)):
        x, y = map(int, input().split())
        X.append((x, i))
        Y.append((y, i))
    X.sort()
    Y.sort()
    hq = []
    for i in range(N-1):
        x1, x1_ind = X[i]
        x2, x2_ind = X[i+1]
        y1, y1_ind = Y[i]
        y2, y2_ind = Y[i+1]
        heappush(hq, (x2-x1, x1_ind, x2_ind))
        heappush(hq, (y2-y1, y1_ind, y2_ind))
    ans = 0
    union_find = UnionFind(N)
    while hq:
        w, s, t = heappop(hq)
        if not union_find.is_same(s, t):
            union_find.union(s, t)
            ans += w

    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 54356
#include<bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int (i)=0;(i) < (N); (i)++)
#define all(V) V.begin(), V.end()
using i64 = long long;

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

    int ans = B;
    if(6 <= A && A <=12) ans /= 2;
    else if(A < 6) ans = 0;

    cout << ans << endl; 
}


Measured memory_bytes: 256
import java.util.Scanner;
class Main{
    public static void main(String args[]){
        Scanner scan = new Scanner(System.in);
        long a = 100;
        double num = scan.nextDouble();
        int aa = 0;
        while(a < num){
            a = a + a/100;
            aa++;      
        }
        System.out.println(aa);
    }
}


Measured memory_bytes: 37212
#include <stdio.h>
#define MAX 100000

int C[MAX] = {0};

void init() {
  int i;
  for (i = 0; i < MAX; ++i) {
    C[i] = i;
  }
}

int Find(int a) {
  if (a == C[a]) {
    return a;
  }

  return C[a] = Find(C[a]);
}

int Same(int a, int b) {
  if (Find(a) == Find(b)) {
    return 1;
  }
  else {
    return 0;
  }
}

void unite(int a, int b) {
  a = Find(a);
  b = Find(b);
  if (a == b) return;
  C[b] = a;
}

int main() {
  int n, m, q, i, j, k;
  init();
  scanf("%d %d", &n, &m);
  for ( i = 0; i < m; ++i ) {
    scanf("%d %d", &j, &k);
    unite(j, k);
  }
  scanf("%d", &q);

  for ( i = 0; i < q; i++ ) {
    scanf("%d %d", &j, &k);
    if (Same(j, k)) {
      printf("yes\n");
    } else {
      printf("no\n");
    }
  }

  return 0;
}



Measured memory_bytes: 2092
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;
#define int long long
#define all(arr) arr.begin(),arr.end()
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define vi vector<int>
#define vstr vector<string>
#define vbool vector<bool>
#define vvi vector<vector<int> >
#define mii map<int,int>
#define pb push_back
#define pii pair<int,int>
#define vpair vector<pii > 
#define mkp make_pair
#define scan(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) {cout<<a[i]<<' ';}cout<<'\n'
#define mem(a,v) memset(a,v,sizeof(a))
#define loop(i,a,b) for (int i = a; i < b; i++)
#define loope(i,a,b) for (int i = a; i <= b; i++)
#define FastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define PRECISION std::cout.unsetf ( std::ios::fixed );std::cout.precision(9)
#define PI 3.14159265
#define S second
#define F first
#define CHECK cout<<"CHEDEDWB"<<endl
#define br '\n'
/*int mod = 1e9+7;
int inf = 1e18;
int m_inf = INT_MIN;
int MOD = 100001;*/

void solve()
{
	int a;
	cin>>a;
	int ans = a;
	ans += a*a;
	ans += a*a*a;
	cout<<ans<<endl;
}

int32_t main()
{
	FastIO; PRECISION;
	int t = 1;
	//cin>>t;
	while(t--)
		solve();
	return 0;
}

Measured memory_bytes: 3156
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List

main :: IO ()
main = do
  n <- getl toInt
  unless (n == 0) $ do
    print $ solve 0 n
    main

solve :: Int -> Int -> Int
solve c x
  | x == 1 = c
  | otherwise = solve (c + 1) (f x)
  where
    f n | even n = n `div` 2
        | otherwise = 3 * n + 1

toInt :: String -> Int
toInt s = read s

getl :: (String -> a) -> IO a
getl f = f <$> getLine

Measured memory_bytes: 3900
// E - Divisible Substring
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(n);++i)
#define modadd(x,y,m) x=(x+(y))%(m)
#define modmul(x,y,m) x=(x*(y))%(m)
#define c2d(c) ((c)-'0') // char to digit

int main(){
	ll N,P; string S; cin>>N>>P>>S;
	ll ans = 0;
	if(P==2 || P==5){
		rep(i, N) if(c2d(S[N-1-i]) % P == 0) ans += N - i;
	}
	else{
		reverse(S.begin(), S.end());
		map<int,ll> cnt; // <remainder, count>
		ll r = 0, ten = 1;
		cnt[r]++;
		rep(left, N){
			modadd(r, c2d(S[left])*ten, P);
			modmul(ten, 10, P);
			cnt[r]++;
		}
		rep(r, P) ans += cnt[r] * (cnt[r]-1) / 2;
	}
	cout<< ans <<endl;
}

Measured memory_bytes: 1028
/*
    Mbak Rose Dong
*/
#include<bits/stdc++.h>
using namespace std;
long long int calc(long long int n)
{
    if(n % 4 == 0)
        return n;
    if(n % 4 == 1)
        return 1;
    if(n % 4 == 2)
        return n+1;
    if(n % 4 == 3)
        return 0;
}
int main()
{
    int i,j,x,y,ans,curr=0,n,m,c;
    long long int a,b;
    cin >> a >> b;
    long long int rose = calc(b) ^ calc(a-1);
    cout << rose << endl;
    return 0;
}


Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())

LI = []
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            y = 500*i+100*j+50*k
            LI.append(y)

counter = 0
for l in range(len((LI))):
    if LI[l] == x:
        counter += 1
    
print(counter)

Measured memory_bytes: 8276
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
//ranker
using namespace std;

#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (int i = (a); i >= n; --i)
#define DEP(i, n) DEPS(i, n, 0)

using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using psi = pair<string, int>;
using D = double;

void merge (int *first1, int *last1, int *first2, int *last2){
    int size1 = last1 - first1;
    int size2 = last2 - first2;
    int *result = new int[size1+size2];
    int i = 0;
    int j = 0;
    int index = 0;
    while (true){
        if (i < size1 && (first1[i] <= first2[j] || j >= size2)){
            result[index] = first1[i];
            ++i; ++index;
        }
        if (j < size2 && (first1[i] > first2[j] || i >= size1)){
            result[index] = first2[j];
            ++j; ++index;
        }
        if (i==size1 && j==size2){
            for (i=0; i<size1; ++i) first1[i] = result[i];
            for (j=0; j<size2; ++j) first2[j] = result[j+size1];
            delete[] result;
            return;
        }
    }
}
void MergeSort (int *first, int *last){
    int size = last - first;
    if(size <= 1) return;
    MergeSort(first, first+size/2);
    MergeSort(first+size/2, last);
    merge(first, first+size/2, first+size/2, last);
}


int gcd(int a, int b)
{
    int c;

    if (a < b) {
        a+=b; b=a-b; a-=b;
    }

    while (b != 0) {
        c = a % b;
        a = b;
        b = c;
    }

    return a;
}

int dx[3]={-1, 0, 1};
int dy[3]={-1, 0, 1};
int W, H;
char masu[20][20];
int cnt;

int dfs(int a, int b){
  masu[a][b] = '#';
  cnt++;
  REP(i, 3)REP(j, 3) if(masu[a+dx[i]][b+dy[j]]=='.' && abs(dx[i]+dy[j])==1 && a+dx[i] >= 0 && a+dx[i] < W && b+dx[j] >= 0 && b+dx[j] < H) dfs(a+dx[i], b+dy[j]);
  return cnt;
}


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

  while(1){
    cin >> W >> H;
    if(W == 0 && H == 0) break;
    REP(j, H)REP(i, W) cin >> masu[i][j];

    int i0, j0;
    REP(j, H)REP(i, W) if(masu[i][j] == '@'){
      i0=i;
      j0=j;
      break;
    }

    cnt = 0;
    cnt = dfs(i0, j0);
    cout << cnt << endl;
  }
    return 0;
}

Measured memory_bytes: 3140
#include<iostream>
#include<ctime>
#include<math.h>
using namespace std;

int main(){
    int a, b, c, d, e;
    cin >> a >> b >> c >> d >> e;
    int pasta, juice;
    if(a >= b){
        if(b>=c){
        pasta = c;}
        else{
        pasta = b;
        }}
    else{
        if(a>=c){
            pasta = c;
        }
        else{
            pasta = a;
        }
    }
    
    if(d >=e){
        juice = e;
    }
    else{
        juice = d;
    }
    
    cout << pasta + juice-50<< endl;
    return 0;
}


Measured memory_bytes: 3068
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let n: i32 = read();
    let count = (0..n)
        .filter(|i| {
            let p: i32 = read();
            i + 1 != p
        })
        .count();

    let ans = if count <= 2 { "YES" } else { "NO" };

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

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


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

using namespace std;

const int Nmax = 55, lim = 50, inf = 0x3f3f3f3f, LIM = lim*lim*lim;
typedef long long ll;

int n, X, D, dad, i;
int w[Nmax];
ll c[Nmax], dp[LIM + 2];
vector<int> v[Nmax];

struct thing
{
    int val, cost, cnt;
    bool operator < (const thing &other) const
    {
        return (ll) other.cost * val > (ll) cost * other.val;
    }
};
vector<thing> a, b;

void dfs(int node)
{
    w[node] = 1;
    for(auto it : v[node])
    {
        dfs(it);
        w[node] += w[it];
        c[node] += c[it];
    }

    c[node] = min(c[node], (ll)X+1);
}

void knapsack()
{
    int i, to, k;
    ll val, cost;
    for(i=1; i<=LIM; ++i) dp[i] = inf;

    dp[0] = 0;
    for(auto x : a)
    {
        to = x.cnt;
        val = x.val;
        cost = x.cost;

        for(k=0; (1<<k) < to; ++k)
        {
            if((val << k) <= LIM)
            for(i = LIM - (val << k); i >= 0; --i)
                dp[i + (val << k)] = min(dp[i + (val << k)], dp[i] + (cost << k));
            to -= (1<<k);
        }

        if(val*to <= LIM)
        for(i = LIM - val*to; i >= 0; --i)
                dp[i + val*to] = min(dp[i + val*to], dp[i] + cost*to);
    }
}

int main()
{
  //  freopen("input", "r", stdin);
  //  freopen("output", "w", stdout);
    cin.sync_with_stdio(false);

    cin >> n >> X >> D >> c[1];

    for(i=2; i<=n; ++i)
    {
        cin >> c[i] >> dad;
        v[dad].push_back(i);
    }

    dfs(1);

    a.push_back({ w[1], c[1], lim });
    b.push_back({ w[1], c[1], inf });

    for(i=2; i<=n; ++i)
        if(D > lim)
        {
            a.push_back({ w[i], c[i], lim });
            b.push_back({ w[i], c[i], D - lim });
        }
        else a.push_back({ w[i], c[i], D });

    sort(b.begin(), b.end());
    knapsack();

    ll answer = 0;
    for(i=0; i<=LIM; ++i)
        if(dp[i] <= X)
        {
            int rest = X - dp[i], add;

            ll ans = i;
            for(auto x : b)
            {
                add = min(rest / x.cost, x.cnt);
                ans += (ll) add * x.val;
                rest -= add * x.cost;
            }

            answer = max(answer, ans);
        }

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


Measured memory_bytes: 1280
S = input()

N = len(S)
Aflag = -1
Zflag = 0
for i in range(N):
    if Aflag == -1 and S[i] == 'A':
        Aflag = i
    elif S[i] == 'Z':
        Zflag = i

print(Zflag-Aflag+1)


Measured memory_bytes: 9272
package main

import(
	"fmt"
)

func main() {
	var s string
	fmt.Scanf("%s", &s)
	counter := 0
  	for i := 0; i < len(s); i++ {
		if s[i] == '1' {
			counter++
		}
	}
	fmt.Printf("%d", counter)
}

Measured memory_bytes: 512
s, c = map(int, raw_input().rstrip("\n").split(" "))

def calc_scc(s, c):
  answer = 0
  if (s * 2) >= c:
    answer = c / 2
  else:
    answer = s + ((  c - (s * 2) )  / 4 )
  return answer

print calc_scc(s, c)
#print calc_scc(12345, 678901), 175897


Measured memory_bytes: 2568
#include <cstdio>
#include <vector>
#include <stack>
#include <iostream>
#include <string>
#include <tuple>
#include <random>
#include <map>
#include <queue>
#include <set>
#include <complex>
#include <algorithm>
#include <cassert>
#include <iterator>
#include <numeric>
#include <cmath>
#include <stdio.h>
#include <functional>

using namespace std;
using ll = long long;
using ld = double;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>; //(x, y, dx, dy)
const ll INF = 1e17;
const ld eps = 1e-10;
const ll MOD = 1e9 + 7;

const double pi = acos(-1.0);

vector<pair<char, char>> v;
string s;

int check(int x) {
	for (int i = 0;i < v.size();i++) {
		char c, move;
		tie(c, move) = v[i];
		if (s[x] == c && move == 'L')
			x--;
		else if (s[x] == c && move == 'R')
			x++;
		if (x < 0 || x >= s.size())
			break;
	}
	if (x < 0)
		return -1;
	else if (x >= s.size())
		return 1;
	else
		return 0;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	ll N, Q;
	cin >> N >> Q;
	cin >> s;
	v.assign(Q, P('a', 'a'));
	for (int q = 0;q < Q;q++) {
		char a, b;
		cin >> a >> b;
		v[q] = make_pair(a, b);
	}
	ll l_l = -1, l_r = N, r_l = -1, r_r = N;
	while (l_r - l_l > 1) {
		ll m = (l_l + l_r) / 2;
		if (check(m) == -1)
			l_l = m;
		else
			l_r = m;
	}
	while (r_r - r_l > 1) {
		ll m = (r_l + r_r) / 2;
		if (check(m) == 1)
			r_r = m;
		else
			r_l = m;
	}
	cout << N - (l_r + (N - r_r)) << endl;
	return 0;
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define forn(i, a, n) for (int i = a; i < n; ++i)
#define ford(i, a, n) for (int i = n - 1; i >= a; --i)
#define fore(i, a, n) for (int i = a; i <= n; ++i)
#define all(a) (a).begin(), (a).end()
#define fs first
#define sn second
#define trace(a)\
    for (auto i : a) cerr << i << ' ';\
    cerr << '\n'
#define eb emplace_back

#ifndef M_PI
const ld M_PI = acos(-1.0);
#endif

const ld eps = 1e-9;
const int INF = 2000000000;
const ll LINF = 1ll * INF * INF;
const ll MOD = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> w(n);
    forn(i, 0, n) cin >> w[i];
    vector<vector<int>> e(n), rev(n);
    forn(i, 1, n) {
        int u, v;
        cin >> u >> v;
        --u, --v;
        if (w[u] > w[v]) {
            e[u].eb(v);
            rev[v].eb(u);
        }
        if (w[u] < w[v]) {
            e[v].eb(u);
            rev[u].eb(v);
        }
    }
    vector<int> deg(n);
    forn(i, 0, n) deg[i] = e[i].size();
    stack<int> q;
    forn(i, 0, n) if (deg[i] == 0) q.push(i);
    vector<char> ans(n);
    while (!q.empty()) {
        int u = q.top();
        q.pop();
        for (int v : e[u]) if (ans[v] == 0) ans[u] = 1;
        for (int v : rev[u]) {
            --deg[v];
            if (deg[v] == 0) q.push(v);
        }
    }
    forn(i, 0, n) if (ans[i]) cout << i + 1 << ' ';
}


Measured memory_bytes: 512
w = str(input())
H = True
if len(w)%2!=0:
  H = False
else:
  l=[]
  for i in range(len(w)):
    l += w[i]
  l.sort()
  for j in range(0,len(w),2):
    if l[j]!=l[j+1]:
      H =False
print('Yes' if H else 'No')


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

using Graph = vector<vector<int>>;

// 深さ優先探索
vector<int> seen;

void dfs(const Graph &G, int v) {

    // v から行ける各頂点 next_v について
    for (auto next_v : G[v]) { 
        if(seen[next_v] > 0) continue;
        dfs(G, next_v); // 再帰的に探索
    }

    seen[v] = 0; // v を訪問済にする
    for (auto c : G[v]) {
        seen[v] = max(seen[v], seen[c]+1); // 子のサイズを加える
    }

}

int main() {
    // 頂点数と辺数
    int N, M; 
    cin >> N >> M;

    // グラフ入力受取 (ここでは無向グラフを想定)
    Graph G(N);
    vector<int> inn(N,0);
    for (int i = 0; i < M; ++i) {
        int x, y;
        cin >> x >> y;
        --x;
        --y;
        G[x].push_back(y);
        ++inn[y];
    }

    seen.assign(N, -1); // 全頂点を「未訪問」に初期化
    for(int i = 0; i < N; ++i)
    {
        if(inn[i] == 0)
        {
            dfs(G, i);
        }
    }
    
    std::vector<int>::iterator iter = std::max_element(seen.begin(), seen.end());
    cout << *iter << endl;
    
}

Measured memory_bytes: 11136
package main

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

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func main() {
	var N int
	fmt.Scan(&N)
	a := nextSlice()
	for i := 0; i < N; i++ {
		fmt.Printf(string(a[i]))
		fmt.Printf(string(a[i+N+1]))
	}
}

func readLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func nextSlice() []string {
	return strings.Split(readLine(), "")
}

func atoi(a []string) (b []int) {
	b = make([]int, len(a))
	for i := range a {
		b[i], _ = strconv.Atoi(a[i])
	}
	return
}

func atof(a []string) (b []float64) {
	b = make([]float64, len(a))
	for i := range a {
		b[i], _ = strconv.ParseFloat(a[i], 64)
	}
	return
}

func scanSlice2(n int) (a []int, b []int) {
	a = make([]int, n)
	b = make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i], &b[i])
	}
	return
}

func scanFloatSlice2(n int) (a []float64, b []float64) {
	a = make([]float64, n)
	b = make([]float64, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i], &b[i])
	}
	return
}

// ---------------------------------------------------

func abs(a int) int {
	if a > 0 {
		return a
	}
	return -a
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func larger(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func largest(a, b, c int) (lgst int) {
	if a > b {
		lgst = a
	} else {
		lgst = b
	}
	if c > lgst {
		lgst = c
	}
	return
}

func smaller(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func smallest(a, b, c int) (slst int) {
	if a < b {
		slst = a
	} else {
		slst = b
	}
	if c < slst {
		slst = c
	}
	return
}

func sum(a []int) (ans int) {
	for i := range a {
		ans += a[i]
	}
	return
}

// ---------------------------------------------------

func yesOrNo(b bool) {
	if b {
		fmt.Println("Yes")
		return
	}
	fmt.Println("No")
}

func yesorNO(b bool) {
	if b {
		fmt.Println("YES")
		return
	}
	fmt.Println("NO")
}

Measured memory_bytes: 768
import java.util.*;
     
    public class Main{
        public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        long a[] = new long[3];
    long t;
        for(int i=0;i<3;i++)
        {
              a[i] = sc.nextLong();
              if(a[i]%2==0)
              {
                 System.out.print("0");
                  System.exit(0);
              };
       };
      if(a[0]>=a[2] && a[0]>=a[1])
      {
           System.out.print(a[2]*a[1]);
      }else if(a[1]>=a[2] && a[0]<=a[1])
       System.out.print(a[0]*a[2]);
       else
        System.out.print(a[0]*a[1]);
     
    }
     
     
     
    }

Measured memory_bytes: 8788
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practice
{
    class Program
    {
        const int WHITE = -10;
        const int GRAY = -9;
        const int BLACK = -8;
        const int NOEDGE = int.MaxValue;
        static void Main(string[] args)
        {
            SolveA(args);
            //SolveB(args);
            //SolveC(args);
            //SolveD(args);


        }
        static void SolveA(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[,] m = new int[n, n];
            for(int i=0;i<n;++i)
            {
                for(int j=0;j<n;++j)
                {
                    m[i, j] = NOEDGE;
                }
            }
            for(int i = 0; i < n; ++i)
            {
                var szarr = Console.ReadLine().Split(' ');
                int U = int.Parse(szarr[0]);
                int k = int.Parse(szarr[1]);
                for(int j=0;j<k;++j)
                {
                    int v = int.Parse(szarr[j * 2 + 2]);
                    int c = int.Parse(szarr[j * 2 + 3]);
                    m[U, v] = c;
                }
            }

            int[] color = new int[n];
            int[] d = new int[n];
            int[] p = new int[n];

            dijkstra(0, n, m, color, d, p);

            
            for(int i=0;i<d.Length;++i)
            {
                string sz = i + " " + d[i];
                Console.WriteLine(sz);
            }
        }
        static void dijkstra(int s ,int n ,int[,] m, int [] color, int[] d, int[] p)
        {
            for(int i = 0; i < color.Length; ++i) { color[i] = WHITE; }
            for(int i = 0; i < d.Length; ++i) { d[i] = int.MaxValue; }
            d[s] = 0;
            p[s] = -1;
            while(true)
            {
                int u = -1;
                int mincost = int.MaxValue;
                for(int i=0;i<n;++i)
                {
                    if( color[i] != BLACK && d[i] < mincost)
                    {
                        mincost = d[i];
                        u = i;
                    }
                }
                if( mincost == int.MaxValue) { break; }
                color[u] = BLACK;
                for(int v = 0;v<n;++v)
                {
                    if( color[v] != BLACK && m[u,v] != NOEDGE)
                    {
                        if(d[u] + m[u,v] < d[v])
                        {
                            d[v] = d[u] + m[u, v];
                            p[v] = u;
                            color[v] = GRAY;
                        }
                    }
                }
            }
        }
    }

}



Measured memory_bytes: 15964
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
 
int main(){
    int n;
    float m, tmp;
    int s[1000]={};
    while(true){
        cin >> n;
        if(n==0) break;
        m = 0;
        for(int i=0;i<n;i++){
            cin >> s[i];
            m += s[i];
        }
        m /= n;
        tmp=0;
        for(int i=0; i<n;i++){
            tmp += (s[i]-m)*(s[i]-m);
        }
        cout << sqrt(tmp/n) << endl;
    }

}


Measured memory_bytes: 3268
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define FILE_IO freopen("input.txt","r",stdin)
#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

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

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for(auto &it : t)cout<<it<<" ";}
inline int powerexp(int a, int b, int m = MOD){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 

void print_vector(vector<int> v){
  for(int i = 0; i < (int)v.size(); i++){
	  if (i == (int)v.size() - 1) cout << v[i];
	  else cout << v[i] << " ";  
	}
  cout << endl;	
}

//char grid[100][100];
void solve(){
  int h, w;
  cin >> h >> w;
  vector < vector<char> > grid(h + 2, vector<char> (w + 2, '#'));
   for(int i = 1; i < h + 1; i++){
	 for(int j = 1; j < w + 1; j++){
		  cin >> grid[i][j]; 
		}  
	 }
   for(int i = 0; i < h + 2; i++){
	for(int j = 0; j < w + 2; j++){
		 cout << grid[i][j];
	  }
	 cout << endl;  
	}
}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}


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

#define infint 0x7fffffff //32-bit int
#define ninfint 0x80000000
#define EPS 1e-9
#define mp(A,B) make_pair(A,B)
#define sdf(n) scanf("%d",&n)
#define ssf(a) scanf(" %s ", a)
#define pdf(n) printf("%d",n)
#define pcf(c) printf("%c",c)
#define pdfn(n) printf("%d\n",n)
#define pb push_back
#define pendl() printf("\n")

#define isOn(S, j) (S & (1 << j))
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define lowBit(S) (S & (-S))
#define setAll(S, n) (S = (1 << n) - 1)
#define pque priority_queue

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;

#define endl '\n'


int N, CAP;
int W[105], V[105];
ll dp[105][100005]; // ~ 4*10^1 MBytes

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

    cin >> N >> CAP;
    for (int i = 0; i < N; ++i) {
        cin >> W[i] >> V[i];
    }

    for (int cap = 0; cap <= CAP; ++cap) {
        dp[0][cap] = (cap-W[0]) >= 0? V[0] : 0;
    }

// dp[cap][item_considered] = max(dp[cap-item_considered_weight][item_considered-1]+item_considered_weight),
//                             dp[cap][item_considered-1])
    for (int item = 1; item < N; ++item) {
        for (int cap = 0; cap <= CAP; ++cap) {
            if (cap > W[item]) {
                dp[item][cap] = max(dp[item-1][cap-W[item]]+ V[item], dp[item-1][cap]);
            } else {
                dp[item][cap] = dp[item-1][cap];
            }
        }
    }

    cout << dp[N-1][CAP] << endl;

    return 0;
}


Measured memory_bytes: 80128
import java.io.IOException;
import java.io.InputStream;
import java.util.InputMismatchException;

public class Main {
	public static void main(String[] args) {
		FastScannerA sc = new FastScannerA(System.in);

		String s = sc.next();
		
		int count = 0;
		char cur = 'T';
		for(char c : s.toCharArray()){
			if(c != cur){
				count++;
				cur = c;
			}
		}
		
		System.out.println(count - 1);
	}
}

class FastScannerA {
	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	public FastScannerA(InputStream stream) {
		this.stream = stream;
	}

	public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	public int nextInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public String next() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	public String nextLine() {
		int c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isLineEndChar(c));
		return res.toString();
	}

	public double nextDouble() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		double res = 0;
		while (!isSpaceChar(c) && c != '.') {
			if (c == 'e' || c == 'E')
				return res * Math.pow(10, nextInt());
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		}
		if (c == '.') {
			c = read();
			double m = 1;
			while (!isSpaceChar(c)) {
				if (c == 'e' || c == 'E')
					return res * Math.pow(10, nextInt());
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				m /= 10;
				res += (c - '0') * m;
				c = read();
			}
		}
		return res * sgn;
	}

	public long nextLong() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	public boolean isLineEndChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return c == '\n' || c == '\r' || c == -1;
	}

	public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}

Measured memory_bytes: 9172
S1 = list(input().strip())
T = list(input().strip())
n = len(S1)
k = len(T)
G = []
for i in range(n-k+1):
    flag = 0
    for j in range(i,i+k):
        if S1[j]!="?" and S1[j]!=T[j-i]:
            flag = 1
            break
    if flag==0:
        A = S1[:]
        A[i:i+k] = T[:]
        for j in range(n):
            if A[j]=="?":
                A[j] = "a"
        G.append(A)
G = sorted(G)
if len(G)>0:
    print("".join(G[0]))
else:
    print("UNRESTORABLE")

Measured memory_bytes: 38768
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    int n;
    cin >> n;
    ll m = 1, pt, pa;
    for (ll i = 0, t, a; i < n; i++) {
        cin >> t >> a;
        if (i == 0) {
            pt = t, pa = a;
            continue;
        }
        m = max((pt * m + t - 1) / t, (pa * m + a - 1) / a);
        pt = t, pa = a;
    }
    cout << pt * m + pa * m << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<iostream> 
#include<algorithm>
#include<queue>
#include<vector>
#include<map>
#define ll long long
#define ull unsigned long long
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define lowbit(x) (x& -x)
#define mod 1000000007
#define inf 0x3f3f3f3f
#define eps 1e-18
#define maxn 100010
inline ll read(){ll tmp=0; char c=getchar(),f=1; for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1; for(;'0'<=c&&c<='9';c=getchar())tmp=(tmp<<3)+(tmp<<1)+c-'0'; return tmp*f;}
inline ll power(ll a,ll b){ll ans=1; for(;b;b>>=1){if(b&1)ans=ans*a%mod; a=a*a%mod;} return ans;}
inline ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
inline void swap(int &a,int &b){int tmp=a; a=b; b=tmp;}
using namespace std;
int a[100010];
int n,x;
int main()
{
	n=read(); x=read();
	for(int i=1;i<=n;i++)
		a[i]=abs(read()-x);
	int ans=a[1];
	for(int i=2;i<=n;i++)
		ans=gcd(ans,a[i]);
	printf("%d\n",ans);
}

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define step(i,s,n,c) for(int i=(s);i<(n);i+=(c))
#define REP(i,s,n) for(int i=(s);i<(n);++i)
#define each(i,vec) for(auto i:vec)
#define cinv(n,vec) VL vec(n);for(auto&v:vec)cin>>v;
#define int long long
#define itn int
#define pb push_back
#define eb emplace_back
#define m_p make_pair
#define m_t make_tuple
#define p_p(a,b) pb(m_p(a,b))
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(all(a),greater<>())
#define UNIQUE(a) a.erase(unique(all(a)),a.end())
#define SZ(a) (signed)(a.size())
#define debg(a) cout<<#a<<" "<<a<<endl;
#define debgp(a) cout<<#a<<" "<<a.fi<<" : "<<a.se<<endl
#define call(a) for(auto i:a)cout<<i<<" ";cout<<endl
#define callp(a) for(auto [k,v]:a)cout<<k<<":"<<v<<endl
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define out(a) cout<<(a)<<endl
#define ENDL cout<<endl
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define fi first
#define se second
#define V vector
#define P pair
#define T tuple
#define PQ priority_queue
#define cont const auto
#define VV(type,name,y,x,a) vector<vector<type>> name = vector<vector<type>>(y,vector<type>(x,a))
typedef long long ll;
typedef double D;
typedef long double LD;
typedef string str;
typedef vector<ll> VL;
typedef pair<ll,ll> PL;
typedef vector<pair<ll,ll>> VP;
typedef tuple<ll,ll,ll> T3;
typedef tuple<ll,ll,ll,ll> T4;
const signed INF = (1LL<<30);
const long long MOD = (1e9+7);
const long long LINF = (1LL<<60);
const long long LMAX = LLONG_MAX;
void YN(bool b){cout<<(b?"Yes":"No")<<endl;}
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T>inline bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(10);
  
  D h,w,x,y;
  cin>>w>>h>>x>>y;
  
  cout<<(h*w/2)<<" "<<(h==y+y&&w==x+x)<<endl;
  
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define For(i,a,b) for (int i=(a); i<=(b); ++i)
char s[10005];
int main(void)
{
	int n;
	cin>>n;
	scanf("%s",s);
	int len=strlen(s);
	For(i,0,len-1)
	{
		s[i]+=n;
		if (s[i]>'Z')
			s[i]-=26;
	}
	printf("%s",s);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

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

    while(a>0&&c>0){
        c = c-b;
        if(c <= 0){
            cout << "Yes" << endl;
            return 0;
        }
        a = a-d;
        if(a <= 0){
            cout << "No" <<endl;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 3096
#include <iostream>

using namespace std;

bool solve(double dist, double t, double s)
{
    if (dist / s <= t)
        return true;
    return false;
}
int main()
{
    double dist, t, s;
    cin >> dist >> t >> s;
    bool res = solve(dist, t, s);
    if (res)
        cout << "Yes";
    else
        cout << "No";

    return 0;
}

Measured memory_bytes: 3716
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}


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

  
  ll N , H; cin >> N >> H;
  vector<ll> kn;
  ll ma = 0 ; //複数回攻撃のできる最大攻撃力
  
  rep(i,N){
    ll a,b; cin>> a >> b;
    ma = max(ma, a);
    kn.pb(b);
  }

  sort(rall(kn));
  
  rep(i,kn.size()){
    if(kn[i] < ma)kn[i] = 0 ; 
  }

  ll ans = 0;
  rep(i,kn.size()){
    if(kn[i]==0) break;
    if(H <=0)break;

    ans++;
    H-=kn[i];
  }

  if(H<=0) cout << ans << endl;
  else{
    if(H%ma !=0) cout << ans + 1 + H/ma << endl;
    else cout << ans + H/ma << endl;
  }
  
  
  return 0;
}


Measured memory_bytes: 1400
import itertools
n=int(input())
dic={}
l=[]
for i in range(n):
  x,y=[int(x) for x in input().rstrip().split()]
  if i!=0:
    for j in range(len(l)):
      s=l[j][0]
      t=l[j][1]

      dist=((s-x)**2+(y-t)**2)**(0.5)
      dic[(i,j)]=dist
      dic[(j,i)]=dist
  l.append([x,y])

ans=0
cnt=0
nl=[i for i in range(n)]
for i in itertools.permutations(nl,n):
  cnt+=1
  for j in range(len(i)-1):
    ans+=dic[(i[j],i[j+1])]
print(ans/cnt)
  


Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;

int main()
{
  int a, b, c; cin >> a >> b >> c;
  if(a == c) cout << b;
  else if(a == b) cout << c;
  else cout << a;
  return 0;
}

Measured memory_bytes: 256
// atcoder/abc148/F/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

const int N = 1e5 + 5;
vector<int> g[N];

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n, a, b;
  while (cin >> n >> a >> b) {
    --a;
    --b;
    fill(g, g + N, vector<int>());
    for (int i = 0; i < n - 1; ++i) {
      int x, y;
      cin >> x >> y;
      --x;
      --y;
      g[x].push_back(y);
      g[y].push_back(x);
    }

    const int inf = 1 << 29;
    int A[N];
    int B[N];
    fill(A, A + N, inf);
    fill(B, B + N, inf);
    A[a] = 0;
    B[b] = 0;
    {
      queue<int> q;
      for (q.push(b); q.size(); q.pop()) {
        int curr = q.front();
        each (next, g[curr]) {
          if (B[next] == inf) {
            B[next] = B[curr] + 1;
            q.push(next);
          }
        }
      }
    }
    int mx = 0;
    {
      queue<int> q;
      for (q.push(a); q.size(); q.pop()) {
        int curr = q.front();
        setmax(mx, B[curr] - 1);
        // cout << curr << endl;
        each (next, g[curr]) {
          if (A[next] == inf && A[curr] + 1 <= B[next]) {
            A[next] = A[curr] + 1;
            q.push(next);
          }
        }
      }
    }
    cout << mx << endl;
    // cout << endl;
  }


  return 0;
}


Measured memory_bytes: 6656
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,cnt[26];
	string s;
	cin>>n;
	fill(cnt,cnt+26,100);
	while(cin>>s)
		for(char c='a';c<='z';c++)
			cnt[c-'a']=min(cnt[c-'a'],(int)count(s.begin(),s.end(),c));
	for(char c='a';c<='z';c++)
		cout<<string(cnt[c-'a'],c);
	cout<<endl;
}


Measured memory_bytes: 256
h, w = map(int, input().split())
grid = [list(input()) for _ in range(h)]
for y in range(h):
    for x in range(w):
        if grid[y][x] == '#':
            for dy in range(max(0,y-1),min(y+2,h)):
                for dx in range(max(0,x-1),min(x + 2,w)):
                    if grid[dy][dx] =='.' or grid[dy][dx] =='0':
                        grid[dy][dx] = '1'
                    elif grid[dy][dx] =='#':
                        continue
                    else:
                        grid[dy][dx] = str(1 + int(grid[dy][dx]))
        elif grid[y][x] == '.':
            grid[y][x] = '0'
for i in range(h):
    print(''.join(grid[i]))

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  int N;
  cin >> N;
  vector<int> a(N);
  vector<int> cnt(8);

  for(int i = 0; i < N; i++) cin >> a[i];

  int numover = 0;
  for(int i = 0; i < N; i++){
    if(a[i] < 3200){
      cnt[a[i]/400] = 1;
    }else{
      numover++;
    }
  }

  int ans = 0;
  for(int i = 0; i < 8; i++){
    ans += cnt[i];
  }

  
  cout << max(ans, 1) << " " << ans + numover << endl;

  return 0;
}


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

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }

const int INF = 1 << 30;
const ll INFL = 1LL << 60;


const ll MOD =1000000000+7;

ll ModPow(ll a,ll n){
  if(n==0)return 1;
  if(n%2==1)return a*ModPow(a, n-1)%MOD;
  ll t=ModPow(a, n/2);
  return t*t%MOD;
}

class Solver {
  public:
    bool solve() {
        int N; cin >> N;
        vector<int> A(N); cin >> A;
        vector<int> cnt((N - 1) / 2 + 1);
        for(int a : A) cnt[a / 2]++;
        if(N % 2 and cnt[0] != 1) {
            cout << 0 << endl;
            return 0;
        }
        for(int i = N % 2; i < cnt.size(); i++) if(cnt[i] != 2) {
                cout << 0 << endl;
                return 0;
            }
        cout << ModPow(2, N / 2) << endl;
        return 0;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Solver s;
    s.solve();
    return 0;
}


Measured memory_bytes: 896
N, C=map(int, input().split())
D=[list(map(int, input().split())) for _ in range(C)]
c=[list(map(int, input().split())) for _ in range(N)]

grid=[[0]*C for _ in range(3)]

for i in range(N):
  for j in range(N):
    tmp=(i+j)%3
    
    for d in range(C):
      grid[tmp][d]+=D[c[i][j]-1][d]
      
print(min([grid[0][x]+grid[1][y]+grid[2][z] for x in range(C) for y in range(C) for z in range(C) if x!=y and y!=z and z!=x]))

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

int main() {
    int A;
    int B;
    int C;
	cin >> A;
	cin >> B;
	cin >> C;
	int sum = 0;
	if (A >= B && A >= C) {
	    sum = 10 * A + B + C;
	} else if (B >= C && B >= A) {
	    sum = 10 * B + A + C;
	} else {
	    sum = 10 * C + A + B;
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
	int main(){
	int x, y, z, A, B, C ;
	cin >> x >> y >> z ;
	A = z;
	B = x;
	C = y;
	cout <<  A  << " " <<  B  << " " <<  C  << endl;
	}

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

int main(void){
    string str;
    cin >> str;
    
    for(int i = 1 ; i <= str.size() - 2; i++) {
        if (str[i-1] == str[i]) {
            cout << i << " " << i+1 << endl;
            return 0;
        }
        if (str[i-1] == str[i+1]) {
            cout << i << " " << i+2 << endl;
            return 0;
        }
    }
    if (str[str.size() -2] == str[str.size()-1]) {
        cout << str.size()-1 << " " << str.size() << endl;
        return 0;
    }
    cout << "-1 -1" << endl;
}


Measured memory_bytes: 512
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef map<char,int> mci;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vii;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define in insert
#define sz(v) v.size()
#define mina(a,b) (a)=min((a),(b));
#define maxa(a,b) (a)=max((a),(b));
const int INF = 1e9 + 5;
void solve(){
    int n; cin>>n;
    vector<double> v;
    for(int i = 0; i < n; i++){
        double t; cin>>t;
        v.pb(t);
    } 
    while(v.size()!=1){
        sort(all(v));
        v[0]=(v[0]+v[1])/2;
        v.erase(v.begin()+1);
    }
    cout<<fixed<<setprecision(15)<<v[0];
}
int main(){
    int T=1;
    //cin>>T;
    for(int i = 0; i < T; i++) solve(); 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define MAX 1000000000000000
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll,ll>
#define MP make_pair
#define pb push_back
#define fi first
#define se second
#define ll long long int
#define vi vector<ll>
ll modexp(ll a,ll b){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a);  a = (a * a);  b/=2;  }  return res; }
#define rs resize
long long readLI(){  register char c;  for(c = getchar(); !(c>='0' && c<='9'); c = getchar());  register long long a=c-'0';
    for(c = getchar(); c>='0' && c<='9'; c = getchar())
        a = (a<<3)+(a<<1)+c-'0';
    return a;
}
const ll N = 100009;
ll d,a,b;
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin>>a>>b;
    if((a + b)&1)
        d = (a + b)/2 + 1;
    else
        d = (a + b)/2;
    cout<<d;
    return 0;
}

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

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

	if (c == "a" || c == "i" || c == "u" || c == "e" || c == "o") {
		cout << "vowel" << endl;
	}

	else {
		cout << "consonant" << endl;
	}

	return 0;
}

Measured memory_bytes: 256