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

public class Main {
    int n, k;
    int[] xs, ys;

    public static void main(String args[]) {
        new Main().run();
    }

    void run() {
        FastReader sc = new FastReader();
        n = sc.nextInt();
        k = sc.nextInt();
        xs = new int[n];
        ys = new int[n];
        for (int i = 0; i < n; i++) {
            xs[i] = sc.nextInt();
            ys[i] = sc.nextInt();
        }
        solve();
    }

    void solve() {
        int[] xIndexes = xs.clone();
        int[] yIndexes = ys.clone();
        Arrays.sort(xIndexes);
        Arrays.sort(yIndexes);
        long minArea = Long.MAX_VALUE;
        for (int sx = 0; sx < n; sx++) {
            for (int tx = sx; tx < n; tx++) {
                for (int sy = 0; sy < n; sy++) {
                    for (int ty = 0; ty < n; ty++) {
                        int count = 0;
                        for (int i = 0; i < n; i++) {
                            if (xIndexes[sx] <= xs[i] && xs[i] <= xIndexes[tx] &&
                                    yIndexes[sy] <= ys[i] && ys[i] <= yIndexes[ty]) {
                                count++;
                            }
                        }
                        if (count >= k) {
                            long area = ((long)xIndexes[tx] - xIndexes[sx]) *
                                    ((long)yIndexes[ty] - yIndexes[sy]);
                            if (area < minArea) {
                                minArea = area;
                            }
                        }
                    }
                }
            }
        }
        System.out.println(minArea);
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 22996
import math
N = int(input())
tmp = 1

def digits_in_multiplication(N):
    if N == 1:
        return tmp

    for A in range(1, int(math.sqrt(N) + 1)):
        if N % A == 0:
            B = int(N/A)
            ans = len(str(B))

    return ans

print(digits_in_multiplication(N))

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

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

#define INF (1ll<<60)

vector<int> g[200100];
int n,m,k,s,st[200100];
ll p,q,cs[200100];
queue<int> qu;
priority_queue< pl, vector<pl>, greater<pl> > pq;

int cost(int t){
	if(t == 1 || t == n){
		return 0;
	}else if(st[t] == s){
		return -1;
	}else if(st[t] > 0){
		return q;
	}else{
		return p;
	}
}


int main(void){
	int i,a,b,c,tmp,j,l;
	ll d;
	pl now;
	cin >> n >> m >> k >> s;
	cin >> p >> q;
	fill(st,st+200100,0);
	fill(cs,cs+200100,INF);
	cs[1] = 0;
	pq.push(pl(cs[1],1));
	s++;
	for(i=0; i<k; i++){
		cin >> c;
		st[c]=s;
		qu.push(c);
	}
	for(i=0; i<m; i++){
		cin >> a >> b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	while(!qu.empty()){
		j = qu.front();
		qu.pop();
		if(st[j]!=0){
			for(i=(g[j].size()-1); i>=0; i--){
				tmp = g[j][i];
				if(st[tmp]==0){
					qu.push(tmp);
					st[tmp] = (st[j]-1);
				}
			}
		}
	}
	while(!pq.empty()){
		now = pq.top();
		pq.pop();
		j = now.second;
		d = now.first;
		for(i=(g[j].size()-1); i>=0; i--){
			l = g[j][i];
			if(cost(l)>-1 && (d+cost(l))<cs[l]){
				cs[l] = d+cost(l);
				pq.push(pl(cs[l],l));
			}
		}
	}
	cout << cs[n] << endl;
	return 0;
}

Measured memory_bytes: 14416
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#include<queue>
#define ll long long
#define itn int
#define co(ans) cout<<ans<<endl;
#define COYE cout<<"YES"<<endl;
#define COYe cout<<"Yes"<<endl;
#define COye cout<<"yes"<<endl;
#define CONO cout<<"NO"<<endl;
#define CONo cout<<"No"<<endl;
#define COno cout<<"no"<<endl;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
using namespace std;


int main(){
  string S,T;
  cin>>S>>T;
  T+=S;
  co(T);
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)

	nums := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &nums[i])
	}

	count := 0
	for _, num := range nums {
		if isPrime(num) {
			count += 1
		}
	}

	fmt.Printf("%d\n", count)
}

func isPrime(x int) bool {
	if x == 2 {
		return true
	}

	if x < 2 || x % 2 == 0 {
		return false
	}
	
	for i := 3; float64(i) <= math.Sqrt(float64(x)); i += 2 {
		if x % i == 0 {
			return false
		}
	}

	return  true
}


Measured memory_bytes: 1780
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

const ll MOD = 1000000007;
const ll MAX = 2000001;

ll mod(ll a){
  return a % MOD;
}

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


struct UnionFind {
    //自身が親であれば、その集合に属する頂点数に-1を掛けたもの
    //そうでなければ親のid
    vector<int> r;
 
    UnionFind(int N) {
        r = vector<int>(N, -1);
    }
 
    int root(int x) {
        if (r[x] < 0) return x;
        return r[x] = root(r[x]);
    }
 
    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (r[x] > r[y]) swap(x, y);
        r[x] += r[y];
        r[y] = x;
        return true;
    }
 
    int size(int x) {
        return -r[root(x)];
    }
  
};




int main(){
  ll n,m; cin >> n >> m;
  UnionFind UF(n);
  
  rep(i,m){
    ll x,y; cin >> x >> y; x--; y--;
    
    UF.unite(x,y);
  }
  
  set<ll> parent;
  
  rep(i,n){
    parent.insert(UF.root(i));
  }
  
  cout << parent.size()-1 << endl;
  
  
}


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



int main() 
{
  ll N; cin>>N;
  vector<pair<ll,ll>> vecX(N);
  rep(i,N)
  {
    cin>>vecX.at(i).first;
    vecX.at(i).second=i;
  }
  sort(vecX.begin(),vecX.end());
  map<ll,ll> mapX;
  rep(i,N)
  {
    if(i<N/2) {mapX[vecX.at(i).second]=vecX.at(N/2).first; continue;}
    mapX[vecX.at(i).second]=vecX.at(N/2-1).first;
  }  
  rep(i,N)
  {
    cout<<mapX.at(i)<<endl;
  }  
  return 0;
}

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

/*
エラトステネスの篩
*/
// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

ll N;
ll arr[100000];
vector<ll> prime;
void Eratosthenes(){
	for(int i = 0; i < N; i++){
		arr[i] = 1;
	}
	for(int i = 2; i < sqrt(N); i++){
		if(arr[i]){
			for(int j = 0; i * (j + 2) < N; j++){
				arr[i *(j + 2)] = 0;
			}
		}
	}

	for(int i = 2; i < N; i++){
		if(arr[i]){
			//cout << i << endl;
            prime.push_back(i);
		}
	}
}

int main()
{
    cout << fixed << setprecision(15);
    ll K;
    cin >> K;
    N = 55555;
    
    Eratosthenes();

    ll count = 0;
    for(auto v: prime){
        if(v % 5 == 1){
            count++;
            if(count == K){
                cout << v << endl;
                return 0;
            }
            else{
                cout << v << " ";
            }
        }
    }


    return 0;
}

Measured memory_bytes: 768
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use itertools_num::ItertoolsNum;
#[allow(unused_imports)]
use std::cmp;
#[allow(unused_imports)]
use std::iter;
#[allow(unused_imports)]
use superslice::*;

fn run() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let h: usize = sc.read();
    let w: usize = sc.read();
    let k: usize = sc.read();
    let grid = sc.read_vec::<String>(h);
    let grid = grid
        .into_iter()
        .map(|g| g.chars().collect::<Vec<char>>())
        .collect_vec();

    let mut ans = 0;
    for bit_h in 0..(1 << h) {
        for bit_w in 0..(1 << w) {
            let mut count = 0;
            for i in 0..h {
                for j in 0..w {
                    if bit_h & (1 << i) == 0 && bit_w & (1 << j) > 0 && grid[i][j] == '#' {
                        count += 1;
                    }
                }
            }
            if count == k {
                ans += 1;
            }
        }
    }
    println!("{}", ans);
}

fn main() {
    std::thread::Builder::new()
        .name("run".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(run)
        .unwrap()
        .join()
        .unwrap();
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn read_pairs<T: std::str::FromStr>(&mut self, n: usize) -> Vec<(T, T)> {
        (0..n).map(|_| (self.read(), self.read())).collect()
    }
    pub fn read_pairs_1_indexed(&mut self, n: usize) -> Vec<(usize, usize)> {
        (0..n)
            .map(|_| (self.read::<usize>() - 1, self.read::<usize>() - 1))
            .collect()
    }
    pub fn read_chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    pub fn read_char_grid(&mut self, n: usize) -> Vec<Vec<char>> {
        (0..n).map(|_| self.read_chars()).collect()
    }
    pub fn read_matrix<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n)
            .map(|_| (0..m).map(|_| self.read()).collect())
            .collect()
    }
}


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

int main() {
  
  int T, A, B;
  cin >> T >> A >> B;
  int X = T * A;
  
  if (X <= B) {
    cout << X << endl;
  }
  else if (X > B) {
    cout << B << endl;
  }
  
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main(void)
{
    int a, b, c,m;
    scanf("%d %d %d", &a, &b, &c);
 
    if(a>b){
        m = b;
        b = a;
        a = m;
    }
 
    if(b>c){
        m = c;
        c = b;
        b = m;
    }
 
    if(a>b){
        m = b;
        b = a;
        a = m;
    }
 
    printf("%d %d %d\n", a, b, c);
 
    return 0;
}

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

int main() {
	int n,a[100],sum=0;
	cin>>n; 
	for(int i=1;i<=n;i++)
	  cin>>a[i];
	  for(int i=1;i<=n-1;i++)
	    for(int j=i+1;j<=n;j++)
	      sum+=a[i] * a[j];
	      cout<<sum;
	      return 0;
} 

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> v(n);
    int num = 0;
    for (int ni = 0; ni < n; ++ni)
    {
        cin >> v[ni];
        num += v[ni];
    }
    partial_sort(v.begin(), v.begin() + m, v.end(), greater<int>());

    bool res = true;
    double min_votes = static_cast<double>(num) / (4 * m);
    for (int i = 0; i < m; ++i)
    {
        if (v[i] < min_votes)
        {
            res = false;
            break;
        }
    }

    cout << (res ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 256
from collections import namedtuple
from heapq import heappop, heappush


WEIGHT_MAX = 10 ** 10
WeightedEdge = namedtuple('WeightedEdge', ('src', 'dest', 'weight'))


class Digraph:
    def __init__(self, v):
        self.v = v
        self.edges = [[] for _ in range(v)]

    def add(self, edge):
        self.edges[edge.src].append(edge)

    def adj(self, v):
        return self.edges[v]


def sp_dijkstra(graph, s):
    def push_node(v):
        if v in index:
            index[v][2] = False
        node = [dists[v], v, True]
        heappush(nodes, node)
        index[v] = node

    def pop_node():
        while nodes:
            node = heappop(nodes)
            if node[2]:
                return node[1]
        return None

    def relax(edge):
        s, t, w = edge
        if dists[t] > dists[s] + w:
            dists[t] = dists[s] + w
            srcs[t] = s
            push_node(t)

    nodes = []
    index = {}
    dists = [WEIGHT_MAX] * graph.v
    dists[s] = 0
    srcs = [-1] * graph.v

    v = s
    while v is not None:
        for e in graph.adj(v):
            relax(e)
        v = pop_node()

    return [None if dists[v] == WEIGHT_MAX else dists[v]
            for v in range(graph.v)]


def run():
    v, e, r = [int(i) for i in input().split()]

    digraph = Digraph(v)
    for _ in range(e):
        edge = WeightedEdge(*[int(i) for i in input().split()])
        digraph.add(edge)

    for w in sp_dijkstra(digraph, r):
        if w is None:
            print('INF')
        else:
            print(w)


if __name__ == '__main__':
    run()



Measured memory_bytes: 126720
#define DEBUG 0
/**
 * File    : C.cpp
 * Author  : Kazune Takahashi
 * Created : 6/11/2019, 7:13:20 PM
 * Powered by Visual Studio Code
 */
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <functional>
#include <random>
#include <chrono>
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
typedef long long ll;
void Yes()
{
  cout << "Yes" << endl;
  exit(0);
}
void No()
{
  cout << "No" << endl;
  exit(0);
}
const int MAX_SIZE = 1000010;
class mint
{
public:
  static ll MOD;
  ll x;
  mint() : x(0) {}
  mint(ll x) : x(x % MOD) {}
  mint operator-() const { return mint(0) - *this; }
  mint &operator+=(const mint &a)
  {
    if ((x += a.x) >= MOD)
    {
      x -= MOD;
    }
    return *this;
  }
  mint &operator-=(const mint &a) { return *this += -a; }
  mint &operator*=(const mint &a)
  {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint &operator/=(const mint &a) { return (*this *= power(MOD - 2)); }
  mint operator+(const mint &a) const { return mint(*this) += a; }
  mint operator-(const mint &a) const { return mint(*this) -= a; }
  mint operator*(const mint &a) const { return mint(*this) *= a; }
  mint operator/(const mint &a) const { return mint(*this) /= a; }
  bool operator<(const mint &a) const { return x < a.x; }
  bool operator==(const mint &a) const { return x == a.x; }
  const mint power(ll N)
  {
    if (N == 0)
    {
      return 1;
    }
    else if (N % 2 == 1)
    {
      return *this * power(N - 1);
    }
    else
    {
      mint half = power(N / 2);
      return half * half;
    }
  }
};
ll mint::MOD = 1e9 + 7;
istream &operator>>(istream &stream, mint &a) { return stream >> a.x; }
ostream &operator<<(ostream &stream, const mint &a) { return stream << a.x; }
mint inv[MAX_SIZE];
mint fact[MAX_SIZE];
mint factinv[MAX_SIZE];
void init()
{
  inv[1] = 1;
  for (int i = 2; i < MAX_SIZE; i++)
  {
    inv[i] = (-inv[mint::MOD % i]) * (mint::MOD / i);
  }
  fact[0] = factinv[0] = 1;
  for (int i = 1; i < MAX_SIZE; i++)
  {
    fact[i] = mint(i) * fact[i - 1];
    factinv[i] = inv[i] * factinv[i - 1];
  }
}
mint choose(int n, int k)
{
  if (n >= 0 && k >= 0 && n - k >= 0)
  {
    return fact[n] * factinv[k] * factinv[n - k];
  }
  return 0;
}
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
// const double epsilon = 1e-10;
// const ll infty = 1000000000000000LL;
// const int dx[4] = {1, 0, -1, 0};
// const int dy[4] = {0, 1, 0, -1};

ll N, M;
bool ok[100010];
mint dp[100010];

int main()
{
  // init();
  cin >> N >> M;
  fill(ok, ok + 100010, true);
  for (auto i = 0; i < M; i++)
  {
    int a;
    cin >> a;
    ok[a] = false;
  }
  dp[0] = 1;
  for (auto i = 0; i < N; i++)
  {
    if (ok[i + 1])
    {
      dp[i + 1] += dp[i];
    }
    if (ok[i + 2])
    {
      dp[i + 2] += dp[i];
    }
  }
  cout << dp[N] << endl;
}

Measured memory_bytes: 24576
// compil: add warnings to check for overflow
// add function for max on vector *max_element(..)

#include <bits/stdc++.h>

using namespace std;

const int mod = 1e9 + 7;

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

  int h, w;
  cin >> h >> w;

  vector<int> dp(w);
  dp[0] = 1;

  for (int i = 0; i < h; ++i) {
    vector<int> newdp(w);

    for (int j = 0; j < w; ++j) {
      char a; 
      cin >> a;

      if (a == '#') {
        newdp[j] = 0;
      }
      else {
        if (j > 0)
          newdp[j] = (newdp[j-1] + dp[j]) % mod;
        else
          newdp[j] = dp[j];
      }
    }

    swap(dp, newdp);
  }

  cout << dp[w-1] << '\n';


  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pii pair<int,int>
const long long MOD=1e9+7;

int main() {
  int n;
  string s;
  cin>>n>>s;
  bool ans=true;
  if(n%2!=0) ans=false;
  else rep(i,n/2) if(s[i]!=s[n/2+i]) ans=false;
  if(ans) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;cin>>n;
    map<string,int> mp;
    int ma=0;
    while(n--){
        string s;
        cin>>s;
        if(mp.count(s)){
            mp.at(s)++;
        }else mp.insert(pair<string,int>(s,1));
        ma=max(mp.at(s),ma);
    }
    auto it=mp.begin();
    vector<string> v;
    while(it!=mp.end()){
        if(it->second==ma){
            v.push_back(it->first);
        }
        it++;
    }
    sort(v.begin(),v.end());
    for (int i = 0; i < v.size(); ++i) {
        cout<<v[i]<<endl;
    }
}

Measured memory_bytes: 26868
import sys
input = sys.stdin.readline
from collections import *

S = input()[:-1]
K = int(input())

if S==S[0]*len(S):
    print(len(S)*K//2)
    exit()
    
l = []
cnt = 1

for i in range(len(S)-1):
    if S[i]!=S[i+1]:
        l.append((S[i], cnt))
        cnt = 1
    else:
        cnt += 1
    
l.append((S[-1], cnt))

if K==1 or l[0][0]!=l[-1][0]:
    ans = 0
    
    for _, c in l:
        ans += c//2*K
else:
    ans = (l[0][1]+l[-1][1])//2*(K-1)
    ans += l[0][1]//2
    ans += l[-1][1]//2
    
    for _, c in l[1:-1]:
        ans += c//2*K

print(ans)

Measured memory_bytes: 38384
//08-1 ?????????
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
using namespace std;
int main(){
    bool flg = true;
    while(flg){
        int A;
        cin >> A;
        int ans = 0;
        if(A != 0){
            A = 1000 - A;
            while(A>=500){
                A -= 500;
                ans++;
            }
            while(A>=100){
                A -= 100;
                ans++;
            }
            while(A>=50){
                A -= 50;
                ans++;
            }
            while(A>=10){
                A -= 10;
                ans++;
            }
            while(A>=5){
                A -= 5;
                ans++;
            }
            while(A>=1){
                A -= 1;
                ans++;
            }
            cout << ans << endl;
        }
        else{
            flg = false;
        }

    }
    return 0;
}


Measured memory_bytes: 3080
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <map>
#include <utility>
#include <set>
#include <climits>

using namespace std;

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

int main() {
    int n;
    scanf("%d", &n);
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        scanf("%d", &a[i]);
    }

    vector<int> result;
    for (int i = 0; i < n; ++i) {
        int m = a.size();
        for (int j = m - 1; j >= 0; --j) {
            if (a[j] == j + 1) {
                result.push_back(a[j]);
                a.erase(a.begin() + j);
                break;
            }
        }
    }

    int t = result.size();
    if (t != n) {
        printf("-1\n");
    } else {
        for (int i = t - 1; i >= 0; --i) {
            printf("%d\n", result[i]);
        }
    }
    return 0;
}



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

int main(){
  int h,n;
  cin >>h >>n;
  int sum = 0;
  rep(i,n){
    int a;
    cin >>a;
    sum += a;
  }
  if(sum>=h) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll d[100005],par[100005];
vector<vector<ll>> v(100005);
ll dfs(ll i,ll p){
    par[i]=p;
    for(ll j=0;j<v[i].size();j++)
    if(v[i][j]!=p)
    d[i]=max(d[i],dfs(v[i][j],i));
    return d[i]+1;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,a,b;
    cin>>n>>b>>a;
    if(a==b){
        cout<<0;
        exit(0);
    }
    for(ll i=0;i<n-1;i++){
        ll x,y;
        cin>>x>>y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    dfs(a,a);
    ll val=1,p=b;
    while(par[p]!=p){
        p=par[p];
        val++;
    }
    ll sum=ceil(val/2.0)-1,q=val/2-1;
    p=b;
    val=0;
    while(val<q){
        p=par[p];
        val++;
    }
    cout<<(sum+d[p])<<endl;
}

Measured memory_bytes: 11264
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <cmath>

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int count(int N)
{
        int cnt = 0;
        while (N % 2 == 0)
        {
                cnt++;
                N /= 2;
        }
        return cnt;
}

int main()
{
        int K, S;
        cin >> K>> S;
        int ans = 0;

        rep(X, K+1)
        {
                rep(Y, K+1)
                {
                        if (0 <= S - X - Y && S - X - Y <= K)
                        {
                                ans++;
                        }
                }
        }

        cout << ans << endl;

        return 0;
}


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

int main(void){
  long long n; cin>>n;
  int rn=(int)sqrt(n),cnt,cnt2=0;
  for(int i=2; (i<rn)&&(n>1); ++i){
    cnt=0;
    while(n%i==0) n/=i, ++cnt;
    for(int j=1; (cnt-j)>=0; ++j) cnt-=j, ++cnt2;
  }if(n>1) ++cnt2;
  cout << cnt2 << endl;
  return 0;
}


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


int main(){
	char ch,ch2,ch3;
	int num;
	int counter[26] = {0};

	while( cin >> ch ){
		ch2 = tolower(ch);
		num = ch2 - 'a'; 
		
		counter[num]++; 
	}
	
	for(int i = 0; i<26; i++){
		ch3 = 'a' + i;
		cout << ch3 << " : " << counter[i] << endl;
	}
		
		
			
		    return 0;
}

Measured memory_bytes: 2996
// template version 1.7

// varibable settings {{{
using namespace std;
#include <iostream>
#include <bits/stdc++.h>

#define int long long
#define INF 1e18
// #define INF 2147483647
#define MOD 1e9+7
#define infile "../test/sample-1.in"
int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
#define fi first
#define se second

// }}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;
template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;

// dump macro
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;
// }}}

int solve(){
  int a,b;cin>>a>>b;
  if (a==b) cout << a+a << endl;
  else cout << max(a, b) + max(a, b)-1  << endl;
  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

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

int main(){
  int K;
  cin>>K;
  ll ans=0;
  rep(i,K) rep(j,K) rep(l,K) ans+=gcd(gcd(i+1,j+1),l+1);
  cout<<ans<<endl;
}


Measured memory_bytes: 3624
/**************************************************************************
* File Name: AT1.cpp
* Author: lcy
* Created Time: Sun, 21 Jun 2020 20:01:34 +0800�
***************************************************************************/

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

char ch;

int main(){
	scanf("%c",&ch);
	if('a'<=ch && ch<='z') puts("a");
	if('A'<=ch && ch<='Z') puts("A");
    return 0;
}


Measured memory_bytes: 3660
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
signed main()
{
int n;
cin>>n;
vector<int>v;
for(int i=1;i*i<=n;i++)
{
    if(n%i==0)
    {
        v.push_back(i);
        v.push_back(n/i);
    }
}

sort(v.begin(),v.end());
int x=0,y=0;
for(int i=0;i<v.size()-1;i++)
{
    if((n/v[i])==v[i+1])
    {
        x=v[i];
        y=v[i+1];
    }

}
cout<<(x+y-2);
return 0;
}



Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
int main(void){
	char N[5];
  	int cnt;
	char tmp;
	scanf("%s", N);
	for (int i = 0; i < 2; i++) {
		if (N[i]==N[i+1]&&N[i+1]==N[i+2]) cnt++;
	}
	if (cnt >= 1) {
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;

int n;
long long a[105][105];
int in[105][2];

int main()
{
    memset(a,0,sizeof(a));
    cin>>n;
    int i;
    for(i=0;i<n;i++){
        cin>>in[i][0]>>in[i][1];
    }
    for(i=1;i<n;i++){
        int j=0;
        for(j=0;j<n-i;j++){
            int k;
            for(k=0;k<i;k++){
                long long aa=a[j][j+k]+a[j+k+1][j+i]+in[j][0]*in[j+k][1]*in[j+i][1];
                if(a[j][j+i]==0)a[j][j+i]=aa;
                else a[j][j+i]=min(a[j][j+i],aa);
            }
        }
    }
    cout<<a[0][n-1]<<endl;
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
typedef long long ll;

int main() {
    int n; cin >> n;
    map<string, int> res;
    rep(i,n){
        string s; cin >> s;
        res[s]++;
    }
    int cnt = 0;
    for(auto it : res){
        cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 19132
#include<bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define mp make_pair
#define P pair<ll,ll>
#define F first
#define S second
#define vll vector<ll>
#define pb push_back
#define M 1000000007
#define for1(i,n) for(ll i=1;i<=n;i++)
#define f(i,n) for(ll i=0;i<n;i++)
#define forab(i,a,b,c) for(ll i=a;i<=b;i+=c)
using namespace std;
int main()
{
	ios_base:: sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ll t;
	cin >> t;
	ll count1 = 0, count2 = 0, count3 = 0, count4 = 0;
	while (t--)
	{
		string s;
		cin >> s;
		if (s == "AC")
		{
			count1++;
		}
		else if (s == "TLE")
		{
			count3++;
		}
		else if (s == "RE")
		{
			count4++;
		}
		else if (s == "WA")
		{
			count2++;
		}
	}
	cout << "AC x " << count1 << "\n";
	cout << "WA x " << count2 << "\n";
	cout << "TLE x " << count3 << "\n";
	cout << "RE x " << count4 << "\n";

	return 0;
}

Measured memory_bytes: 3640
N = int(input())
if 1 <= N < 10:
  print(N)
elif 10 <= N < 100:
  print(9)
elif 100 <= N < 1000:
  print(9 + N - 99)
elif 1000 <= N < 10000:
  print(909)
elif 10000 <= N < 100000:
  print(N - 9999 + 909)
elif N == 100000:
  print(90909)

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    ll X, Y;
    cin >> X >> Y;
    ll ans = L_INF;
    if (Y == 0) {
        if (X == 0) {
            ans = 0;
        }
        else if (X > 0) {
            ans = X + 1;
        }
        else {
            ans = -X;
        }
    }
    else {
        if (X <= Y) {
            ans = min(ans, Y - X);
        }
        if (-X <= Y) {
            ans = min(ans, Y + X + 1);
        }
        if (X <= -Y) {
            ans = min(ans, -Y - X + 1);
        }
        if (-X <= -Y) {
            ans = min(ans, -Y + X + 2);
        }
    }
    cout << ans << "\n";
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    solve();
    cout << flush;
    return 0;
}

Measured memory_bytes: 3652
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static readonly long Mod = 1000000000 + 7;
        static void Main(string[] args)
        {
            var NM = Sarray();
            var N = NM[0];
            var M = NM[1];
            var A = new long[M];
            var B = new long[M];
            var C = new long[M];
            for (var i = 0; i < M; ++i)
            {
                var t = Sarray();
                A[i] = t[0];
                B[i] = t[1];
                t = Sarray();
                for (var j = 0; j < B[i]; ++j)
                    C[i] |= 1L << (int)(t[j] - 1);
            }
            var snum = (int)Pow(2, N);
            var state = new long[snum].Select(_ => (long)int.MaxValue).ToArray();
            state[0] = 0L;
            for (var k = 0; k < N; ++k)
                for (var i = 0L; i < state.Length; ++i)
                {
                    for (var j = 0L; j < M; ++j)
                        state[i | C[j]] = Min(state[i | C[j]], state[i] + A[j]);
                }

            if (state[state.Length - 1] == int.MaxValue)
                WriteLine(-1);
            else
                WriteLine(state[state.Length - 1]);
        }
    }
}

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

int main() {
    vector<char> v(4);
    for (int i = 0; i < 4; ++i) cin >> v[i];
    sort(v.begin(), v.end());
    cout << (unique(v.begin(), v.end()) - v.begin() == 2 ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
h=list(map(int,input().split()))
c=0
d=[0]*n
for i in range(m):
    a,b=map(int,input().split())
    d[a-1]=max(d[a-1],h[b-1])
    d[b-1]=max(d[b-1],h[a-1])
for i in range(n):
    if h[i]>d[i]:
        c+=1
print(c)

Measured memory_bytes: 19972
n=int(input())
X=[]
for i in range(n-1):
    c,s,f=map(int,input().split())
    X.append([c,s,f])


def dis(i):
    if i<n-2:
        cnt=X[i][1]+X[i][0]
        while i<n-2:
                if cnt<X[i+1][1]:
                    cnt=X[i+1][1]+X[i+1][0]
                else:
                    if cnt%X[i+1][2]!=0:
                        cnt+=X[i+1][2]-(cnt%X[i+1][2])+X[i+1][0]
                    else:
                        cnt+=X[i+1][0]
                i+=1
        return cnt
    elif i==n-2:
        return X[i][1]+X[i][0]
    elif i==n-1:
        return 0
    

for i in range(n):
    print(dis(i))

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


int main()
{
    std::ios_base::sync_with_stdio(0);	
    cin.tie(0);
    cout.tie(0);
    
    string s;
    cin>>s;
    
    ll n = s.size();
    
    for(ll i=0;i<n;i++)cout<<"x";
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
#define ll unsigned long long
#define ld long double
#define ar array
#define mp make_pair
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	ll a=1,b=1;
	while(n--)
	{
		ld x,y;
		cin>>x>>y;
		ll n = max(ceil(a/(x)),ceil(b/(y)));
		a = n*x;
		b = n*y;
	}
	cout<< a+b <<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007;
#define pi 3.14159265358979323846264
using namespace std;
char s[100005];
int main() {
    scanf("%s", s);
    int n = strlen(s), k = n-1;
    while (k>0) {
        if (s[k]=='m'&&s[k-1]=='a'&&s[k-2]=='e'&&s[k-3]=='r'&&s[k-4]=='d') k-=5;
        else if (s[k]=='r'&&s[k-1]=='e'&&s[k-2]=='m'&&s[k-3]=='a'&&s[k-4]=='e'&&s[k-5]=='r'&&s[k-6]=='d') k-=7;
        else if (s[k]=='e'&&s[k-1]=='s'&&s[k-2]=='a'&&s[k-3]=='r'&&s[k-4]=='e') k-=5;
        else if (s[k]=='r'&&s[k-1]=='e'&&s[k-2]=='s'&&s[k-3]=='a'&&s[k-4]=='r'&&s[k-5]=='e') k-=6;
        else break;
    }
    if (k==-1) printf("YES\n");
    else printf("NO\n");
    return 0;
}

Measured memory_bytes: 384
# Author: cr4zjh0bp
# Created: Sat Mar 28 15:38:17 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

m, d = na()
m2, d2 = na()

if d + 1 != d2:
    print(1)
else:
    print(0)

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>

using namespace std;

int n,m;
int a[500];
bool t[500][500] = {};
int dp[2][1<<24] = {};
bool m1[500] = {};
vector<int> aa;

int ns(int k, int b){
  int ret = 0;
  return ret;
}

int main(){
  while(cin >> n >> m && n != 0){
    int ans = 0;
    for(int i = 0; i < n ; i++){
      string s; cin >> s;
      for(int j = 0; j < m ; j++){
        t[i][j] = stoi(s.substr(j,1));
      }
    }
    if(n < 22){
      for(int i = 0; i < (1<<n) ; i++){
        int cnt = 0;
        for(int j = 0; j < m; j++) m1[j] = false;
        for(int j = 0; j < n; j++){
          if(i & (1<<j)){
            cnt++;
            for(int k = 0; k < m ; k++){
              if(t[j][k]) m1[k] = !m1[k];
            }
          }
        }
        bool f = true;
        for(int i = 0; i < m; i++){
          if(m1[i] == true) f = false;
        }
        if(f) ans = max(ans, cnt);
      }
    }
    else{
      for(int i = 0; i < 2; i++){
        for(int j = 0; j < (1<<m); j++){
          dp[i][j] = -1;
        }
      }
      dp[0][0] = 0;
      bool f = 1;
      for(int i = 0; i < n ; i++){
        int tmp = 0;
        for(int k = 0; k < m; k++) if(t[i][k] == 1) tmp += (1<<k);
        for(int j = 0; j < (1<<m) ; j++){
          if(dp[!f][j] >= 0){
            int x = j ^ tmp;
            dp[f][x] = max(dp[!f][j] + 1, dp[f][x]);
            dp[f][j] = max(dp[!f][j], dp[f][j]);
          }
        }
        f = !f;
      }
      ans = dp[!f][0];
    }
    aa.push_back(ans);
//    cout << ans << endl;
  }
  for(int i = 0; i < aa.size(); i++) cout << aa[i] << endl;
}



Measured memory_bytes: 36232
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <string.h>
using namespace std;
typedef long long ll;

int main()
{
    string s;
    cin >> s;
    for (int t = 0; t < (1 << 3); t++)
    {
        int num = s[0] - '0';
        string v;
        v += s[0];
        for (int i = 1; i < 4; i++)
        {
            if ((t >> (i - 1)) & 1){
                num += s[i] - '0';
                v += '+';
                v += s[i];
            }else{
                num -= s[i] - '0';
                v += '-';
                v += s[i];
            }
        }
        if (num == 7){
            cout << v << "=7" << endl;
            return 0;
        }
    }
}

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

typedef long long       ll;
const int MAX=2e5+9;
const int MOD=1000000007;

int n, ans[MAX];
ll fact[MAX], sz[MAX], dp[MAX];
vector<int> adj[MAX];

ll fastPow(ll x, ll y) {
    if (!y) {
        return 1;
    }

    ll sq=fastPow(x, (y>>1LL));
    sq*=sq;

    if (y&1LL) {
        sq%=MOD;
        sq*=x;
    }

    return sq%MOD;
}

ll inv(ll x) {
    return fastPow(x, MOD-2);
}

void precalc() {
    fact[0]=1;
    for (ll i=1; i<MAX; ++i) {
        fact[i]=(i*fact[i-1])%MOD;
    }
}

void dfs1(int cur, int par=-1) {
    sz[cur]=1;
    dp[cur]=1;
    for (int i=0; i<adj[cur].size(); ++i) {
        int child=adj[cur][i];
        if (child==par) {
            continue;
        }

        dfs1(child, cur);
        sz[cur]+=sz[child];
        dp[cur]=(dp[cur]*dp[child])%MOD;
        dp[cur]=(dp[cur]*inv(fact[sz[child]]))%MOD;
    }

    dp[cur]=(dp[cur]*(fact[sz[cur]-1]))%MOD;
}

// add x to children of y
void add(int x, int y) {
    dp[y]=(dp[y]*inv(fact[sz[y]-1]))%MOD;
    sz[y]+=sz[x];
    dp[y]=(dp[y]*fact[sz[y]-1])%MOD;

    dp[y]=(dp[y]*dp[x])%MOD;
    dp[y]=(dp[y]*inv(fact[sz[x]]))%MOD;
}

// remove children x from y
void del(int x, int y) {
    dp[y]=(dp[y]*inv(fact[sz[y]-1]))%MOD;
    sz[y]-=sz[x];
    dp[y]=(dp[y]*fact[sz[y]-1])%MOD;

    dp[y]=(dp[y]*inv(dp[x]))%MOD;
    dp[y]=(dp[y]*fact[sz[x]])%MOD;
}

void dfs2(int cur, int par=-1) {
    ans[cur]=dp[cur];
    for (int i=0; i<adj[cur].size(); ++i) {
        int child=adj[cur][i];
        if (child==par) {
            continue;
        }

        del(child, cur);
        add(cur, child);
        dfs2(child, cur);
        del(cur, child);
        add(child, cur);
    }
}

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

    cin >> n;
    for (int i=1; i<n; ++i) {
        int x, y;
        cin >> x >> y;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }

    precalc();
    dfs1(1);
    dfs2(1);

    for (int i=1; i<=n; ++i) {
        cout << ans[i] << "\n";
    }

    return 0;
}


Measured memory_bytes: 19444
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Linq;
using System.Diagnostics;
using System.Globalization;
using static System.Console;
using static System.Math;

namespace abc106_b
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int sum=0;

            for(int i=1; i<=n; i+=2){
                int cnt=0;
                for(int j=1; j<=i; j++){
                    if(i%j == 0)cnt++;
                }
                if(cnt == 8)sum++;
            }
            WriteLine(sum);
        }
    }
}

Measured memory_bytes: 11092
n = int(input())
a = list(map(int, input().split()))

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

b = []
start = n // 2 + 1
end = n
num = [0] * n
while True:
    if start > end:
        break
    else:
        for i in range(end, start - 1, -1):
            if a[i - 1] != num[i - 1]:
                b.append(i)
                divisors = make_divisors(i)
                for j in divisors:
                    a[j - 1] += 1
                    a[j - 1] %= 2
        end = start - 1
        start = end // 2 + 1
b.sort()
print(len(b))
if len(b) >= 2:
    print(" ".join(map(str, b)))
elif len(b) == 1:
    print(b[0])
else:
    pass

Measured memory_bytes: 88176
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
char a[801][801];
queue<pair<int, int> >p;
	int x, y, k;
	int z;
	int c, d;
	void tansaku(int q){
		int s;
		s = p.size();
		for (int i = 0; i <s; i++){
			int xx = p.front().first;
			int yy = p.front().second;
		if (xx > 0){
			if (a[xx - 1][yy] == '.'){
				a[xx - 1][yy] = 'V';
				p.push(make_pair(xx - 1, yy));
			}
		}
		if (xx < x-1){
			if (a[xx + 1][yy] == '.'){
				a[xx + 1][yy] = 'V';
				p.push(make_pair(xx + 1, yy));
			}
		}
		if (yy > 0){
			if (a[xx][yy - 1] == '.'){
				a[xx][yy-1] = 'V';
				p.push(make_pair(xx, yy - 1));
			}
		}
		if (yy < y-1){
			if (a[xx][yy + 1] == '.'){
				a[xx][yy + 1] = 'V';
				p.push(make_pair(xx, yy + 1));
			}
		}
		p.pop();
		}
		if (q > 0)tansaku(q - 1);
		return;
	}
int main(void){


	scanf("%d %d %d", &x,&y,&k);

	for (int i = 0; i < x; i++){
		scanf("%s", a[i]);
	}

	for (int i = 0; i < x; i++){
		for (int j = 0; j < y; j++){
			if (a[i][j] == 'S'){
				a[i][j] = 'V';
				p.push(make_pair(i,j));
				tansaku(k-1);
			}
		}
	}
	d = 1000;
	for (int i = 0; i < x; i++){
		for (int j = 0; j < y; j++){
			if (a[i][j] == 'V'){
				c = i;
				if (x - i - 1 < c)c = x - i - 1;
				if (j < c)c = j;
				if (y - j - 1 < c)c = y - j - 1;
				if (c < d)d = c;
			}
		}
	}
		if (d == 0)z = 1;
		else{
			z = (d - 1) / k;
			z = z + 2;
		}
	printf("%d\n", z);

	return 0;
}



Measured memory_bytes: 40832
#include<stdio.h>
#include<math.h>
int main(){
int a, b, c, i, cnt;
cnt = 0;
scanf("%d %d %d", &a, &b, &c);
for(i = a; i <= b; i++){
if(c % i == 0){
cnt = cnt + 1;
}
}
printf("%d\n", cnt);
return 0;
}

Measured memory_bytes: 1852
#include<bits/stdc++.h>
 
using namespace std;
using S = set<long long>;
using D = deque<long long>;
using L = vector<long long>;
using M = map<int,long long>;
using A = vector<vector<long long>>;
using Q = priority_queue<long long>;
using U = unordered_map<int,long long>; //mapとの違いはkeyの順番を保持していない

#define sorted(vector) sort(vector.begin(),vector.end()) //O(nlongn)
#define vmin(vector) *min_element(vector.begin(),vector.end()) //O(N)
#define vmax(vector) *max_element(vector.begin(),vector.end()) //O(N)
#define vsum(vector) accumulate(vector.begin(),vector.end(),0) //O(N)
#define vcount(vector,a) count(vector.begin(), vector.end(),a) //O(N)
#define bisect_left(vector,a) (lower_bound(vector.begin(),vector.end(),a)-vector.begin())
#define bisect_right(vector,a) (upper_bound(vector.begin(),vector.end(),a)-vector.begin())
#define vfind(vector,a) find(vector.begin(), vector.end(), a) != vector.end() //遅いからあんまり使うな
//存在確認はmap!!!!!!!!!!!!!
//__gcd(a,b)はコンパイラがGCC時のみ

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    long long n;
    cin>>n;
    A a;
    string s;
    L l;
    unordered_map<string,long long> u;
    long long ans=0;
    for(int i=0  ;i<n  ;i++){
        cin>>s;
        sorted(s);
        u[s]+=1;
        ans+=u[s]-1;
    }
    cout<<ans<<endl;
    
}
    

Measured memory_bytes: 10660
#include <iostream>
#include <set>
#include <map>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <climits>
#include <math.h>
#include <cassert>
#include <unordered_map>
using namespace std;
#pragma warning(disable : 4996)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;





int main() {
#ifdef _DEBUG
	freopen("input1.txt", "r", stdin);
	freopen("output2.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n, k;
	cin >> n >> k;
	vector<int> cnt(n + 1, 0);
	for (int i = 0; i < k; i++) {
		int d;
		cin >> d;
		for (int j = 0; j < d; j++) {
			int x;
			cin >> x;
			cnt[x]++;
		}
	}
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		if (!cnt[i])ans++;
	}
	cout << ans;
}

Measured memory_bytes: 3656