akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;
using ll = long long;

#define MOD 1000000007
template<int mod>
struct ModInt{
   int x;
   ModInt():x(0){}
   ModInt(long long y):x(y>=0?y%mod:(mod-(-y)%mod)%mod){}
   ModInt &operator+=(const ModInt &p){
       if((x+=p.x)>=mod)x-=mod;
       return *this;
   }
   ModInt &operator-=(const ModInt &p){
       if((x+=mod-p.x)>=mod)x-=mod;
       return *this;
   }
   ModInt &operator*=(const ModInt &p){
       x=(int)(1LL*x*p.x%mod);
       return *this;
   }
   ModInt &operator/=(const ModInt &p){
       *this*=p.inverse();
       return *this;
   }
   ModInt &operator^=(long long p){
       ModInt res = 1;
       for (; p; p >>= 1) {
           if (p & 1) res *= *this;
           *this *= *this;
       }
       return *this = res;
   }
   ModInt operator-()const{return ModInt(-x);}
   ModInt operator+(const ModInt &p)const{return ModInt(*this)+=p;}
   ModInt operator-(const ModInt &p)const{return ModInt(*this)-=p;}
   ModInt operator*(const ModInt &p)const{return ModInt(*this)*=p;}
   ModInt operator/(const ModInt &p)const{return ModInt(*this)/=p;}
   ModInt operator^(long long p)const{return ModInt(*this)^=p;}
   bool operator==(const ModInt &p)const{return x==p.x;}
   bool operator!=(const ModInt &p)const{return x!=p.x;}
   explicit operator int() const { return x; }
   ModInt operator=(const int p) {x = p; return ModInt(*this);}
   ModInt inverse()const{
       int a=x,b=mod,u=1,v=0,t;
       while(b>0){
           t=a/b;
           a-=t*b;
           std::swap(a,b);
           u-=t*v;
           std::swap(u,v);
       }
       return ModInt(u);
   }
   friend std::ostream &operator<<(std::ostream &os,const ModInt<mod> &p){
       return os<<p.x;
   }
   friend std::istream &operator>>(std::istream &is,ModInt<mod> &a){
       long long x;
       is>>x;
       a=ModInt<mod>(x);
       return (is);
   }
};
typedef ModInt<MOD> mint;
 
struct MComb {
   std::vector<mint> fact;
   std::vector<mint> inversed;
   MComb(int n) { // O(n+log(mod))
       fact = std::vector<mint>(n+1,1);
       for (int i = 1; i <= n; i++) fact[i] = fact[i-1]*mint(i);
       inversed = std::vector<mint>(n+1);
       inversed[n] = fact[n] ^ (MOD-2);
       for (int i = n - 1; i >= 0; i--) inversed[i]=inversed[i+1]*mint(i+1);
   }
   mint ncr(int n, int r) {
       return (fact[n] * inversed[r] * inversed[n-r]);
   }
   mint npr(int n, int r) {
       return (fact[n] * inversed[n-r]);
   }
   mint nhr(int n, int r) {
       assert(n+r-1 < (int)fact.size());
       return ncr(n+r-1, r);
   }
};


int main()
{
    MComb comb(3000000);
    ll n, k; cin >> n >> k;
    mint res = 0;

    if(k >= n) {
        cout << comb.ncr(n + n - 1, n) << endl;
        return 0;
    }

    //空の部屋の数
    for(int i = 0; i <= k; i++) {
        res += comb.ncr(n, i) * comb.ncr(n - i + i - 1, i);
    }
    cout << res << endl;

}

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

int main() {
  int A, B, H, X, Y;
  cin >> A >> B >> H >> X >> Y;
  int price = 0;
  
  if (A + B <= H * 2) {
    price = A * X + B * Y;
  }
  else {
    int delt = max (X-Y, Y-X);
    int nocori;
    if (X > Y) nocori = A;
    else nocori = B;
    price = min( H * min (X, Y) * 2 + delt * nocori, H * max (X, Y) * 2);
  }
  
  cout << price << endl;
}

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const ll inf = 1e18;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  
  int n, z, w; std::cin >> n >> z >> w;
  vi a(n); rep(i, n) std::cin >> a[i];
  vvl dp(n, vl(2));
  drep(i, n) {
    dp[i][0] = -inf;
    ll y = (i ? a[i-1] : w);
    chmax(dp[i][0], abs(y-a[n-1]));
    srep(j, i+1, n) chmax(dp[i][0], dp[j][1]);
    dp[i][1] = inf;
    ll x = (i ? a[i-1] : z);
    chmin(dp[i][1], abs(x-a[n-1]));
    srep(j, i+1, n) chmin(dp[i][1], dp[j][0]);
  }
  std::cout << dp[0][0] << "\n";
}


Measured memory_bytes: 384
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repe(i,n) for (int i = 0; i <= (n); ++i)
#define repe1(i,n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define eb(k,v) emplace_back(k,v)
#define ct(res) cout << res << "\n";
#define vi vector<int>
#define vl vector<ll>
using namespace std;
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; }
const int INF = 1e9;
const ll MOD = 1000000007;
const double pi = 3.141592653589;
using Graph = vector<vector<int>>;
ll gcd(ll a, ll b) {return (a%b) ? gcd(b, a%b) : b;}
ll modPow(ll x, ll n) {
    if(n==0) return 1;
    ll res = modPow(x*x%MOD, n/2);
    if(n&1) res=res*x%MOD;
    return res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    while(true) {
        int h,w;cin>>h>>w;
        if (h==0 && w==0) {
            return 0;
        }
        rep(i,h) {
            rep(j,w) {
                if ((i+j)%2==0) {
                    cout << '#';
                } else {
                    cout << '.';
                }
            }
            cout << "\n";
        }
        cout << "\n";
    }
}


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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 114514191919;
ll N, M; 


int main(){

    //頂点数と辺の数
    cin >> N;

    vector<vector<ll > > G(N, vector<ll >(N, 0));
    vector<vector<ll > > t_G(N, vector<ll >(N, 0));
    //初期化
    ll ans = 0;
    for(ll i = 0; i < N; i++){
        for(ll j = 0; j < N; j++){
            ll t = 0; cin >> t;
            G[i][j] = t;
            //比較用
            //t_G[i][j] = t;
            ans += t;
        }       
    }

    for(ll reley = 0; reley < N; reley++){
        for(ll from = 0; from < N; from++){
            for(ll to = 0; to < N; to++){
                //中継した方がコストがかからないか否か
                //小さい順からコストが自明に決まっていく
                //cout << "relay" << reley << " " << G[from][to] << ":" << G[from][reley] + G[reley][to] << endl;
                if(reley == from || reley == to || from == to || G[from][reley] == INF || G[reley][to] == INF || G[from][to] == INF){
                    continue;
                }
                //つじつまが合わない距離が出てきたら成り立たない
                if(G[from][to] > G[from][reley] + G[reley][to]){
                    cout << -1 << endl;
                    return 0;
                }
                
                if(G[from][to] == G[from][reley] + G[reley][to])
                {   
                    //cout << G[from][to] << endl;
                    ans -= G[from][to];
                    G[from][to] = INF;
                }
            }
        }
    }

    cout << ans / 2 << endl;

}

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

using namespace std;

int main() {

	int n;
	cin >> n;

	double probs[n];
	for (int i = 0; i < n; i++) {
		cin >> probs[i];
	}

	// The prob of getting x heads from the first y+1 coins
	double result[n+1][n];
	for (int i = 0; i < n+1; i++) {
		for (int j = 0; j < n; j++) {
			result[i][j] = 0;
		}
	}

	result[0][0] = 1.0 - probs[0];
	result[1][0] = probs[0];

	for (int coin = 1; coin < n; coin++) {
		for (int heads = 0; heads < n+1; heads++) {
			if (heads > 0) {
				result[heads][coin] += result[heads - 1][coin - 1] * probs[coin];
			}
			result[heads][coin] += result[heads][coin - 1] * (1.0 - probs[coin]);
		}
	}

	double finalResult = 0;

	for (int heads = n; heads > n/2; heads--) {
		finalResult += result[heads][n-1];
	}

	printf("%.11f\n", finalResult);

	// for (int i = 0; i < n+1; i++) {
	// 	for (int j = 0; j < n; j++) {
	// 		cout << result[i][j] << " ";
	// 	}
	// 	cout << endl;
	// }

}

Measured memory_bytes: 70528
//#define _XCODE_DEBUG

#include <iostream>
#include <math.h>
#include <string>

#ifdef _XCODE_DEBUG
    #include <fstream>
#endif

int main() {
    #ifdef _XCODE_DEBUG
        std::ifstream in("input.txt");
        std::cin.rdbuf(in.rdbuf());
    #endif
    std::string ABCD;
    std::cin >> ABCD;

    for (int i=0; i<pow(3,2); ++i) {
        int sum_v = std::stoi(ABCD.substr(0,1));
        std::string eq = ABCD.substr(0,1);
        for (int j=0; j<3; ++j) {
            if (i & (1<<j)) {
                sum_v += std::stoi(ABCD.substr(j+1,1));
                eq += '+';
                eq += ABCD.substr(j+1,1);
            }
            else {
                sum_v -= std::stoi(ABCD.substr(j+1,1));
                eq += '-';
                eq += ABCD.substr(j+1,1);
            }
        }
        if (sum_v == 7) {
            eq += "=7";
            std::cout << eq << "\n";
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 504
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from math import ceil, floor
from sys import setrecursionlimit

import heapq
import itertools
import operator


inf = float('inf')


# globals
N = 0
X = []


def set_inputs():
    global N, X
    N = get_int()
    X = get_li()
    return


def main():
    setrecursionlimit(100000)
    set_inputs()
    # ----------MAIN----------
    ix = list(sorted(enumerate(X), key=operator.itemgetter(1)))
    l, r = ix[N // 2 - 1][1], ix[N // 2][1]
    ans = [0] * N
    for j, (i, x) in enumerate(ix):
        if j < N // 2:
            ans[i] = r
        else:
            ans[i] = l
    for a in ans:
        print(a)
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def get_data(n, types):
    if len(types) == 1:
        return [types[0](input()) for _ in range(n)]
    return zip(*(
        [t(x) for t, x in zip(types, input().split())]
        for _ in range(n)
    ))


if __name__ == '__main__':
    main()


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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i) os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1) printEoln();
  if (suc == 2) printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U>
void chmax(T &a, U b) {
  if (a < b) a = b;
}

template <class T, class U>
void chmin(T &a, U b) {
  if (b < a) a = b;
}

template <class T>
T Sq(const T &t) {
  return t * t;
}

const int mod = 1e9 + 7;

int dp[100010];
signed main() {
  dp[0] = 0;
  for (int n = 1; n <= 100000; n++) {
    dp[n] = n;
    int power = 1;
    while (power <= n) {
      dp[n] = min(dp[n], dp[n - power] + 1);
      power *= 6;
    }
    power = 1;
    while (power <= n) {
      dp[n] = min(dp[n], dp[n - power] + 1);
      power *= 9;
    }
  }
  int n = read();
  print(dp[n]);
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;

long long mod = 1000000007;



int main() {
  	long long H = 1,W= 1;
    while(true){
        cin >> H >> W;
        if (H == 0){
            break;
        }
  	    for(int i = 0; i < H; i++){
  	        for(int a = 0; a < W; a++){
  	            cout << "#";
   	        }
   	        cout << endl;
  	    }
  	    cout << endl;
    }
}


Measured memory_bytes: 3156
using System;

namespace A
{
	internal class Program
	{
		public static void Main(string[] args)
		{
			var s = int.Parse(Console.ReadLine());
			var result = 0;

			switch (s)
			{
			case 111:
				result = 3;
				break;
			case 1:
			case 10:
			case 100:
				result = 1;
				break;
			case 0:
				result = 0;
				break;
			default:
				result = 2;
				break;
			}

			Console.WriteLine(result);
		}
	}
}

Measured memory_bytes: 11092
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

int main () {
    string s; cin >> s;
    if (s == "SUN") {
        cout << 7 << endl;
    } else if (s == "MON") {
        cout << 6 << endl;
    } else if (s == "TUE") {
        cout << 5 << endl;
    } else if (s == "WED") {
        cout << 4 << endl;
    } else if (s == "THU") {
        cout << 3 << endl;
    } else if (s == "FRI") {
        cout << 2 << endl;
    } else if (s == "SAT") {
        cout << 1 << endl;
    }
}

Measured memory_bytes: 256
fn main() {
    let n = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        let n: f64 = buf.trim_end().parse().unwrap();
        n
    };

    // 可能か判定
    if (2f64 * n).sqrt().floor() * (2f64 * n).sqrt().ceil() != 2f64 * n {
        println!("No");
        return;
    }
    let s_num = (2f64 * n).sqrt().ceil() as usize;

    // 埋めていく
    let mut ss: Vec<Vec<u32>> = (0..s_num).map(|_| vec![]).collect::<Vec<Vec<u32>>>();

    let mut nums: Vec<u32> = Vec::new();
    for i in 1..=(n as usize) {
        nums.push(i as u32);
        nums.push(i as u32);
    }
    for i in 0..s_num {
        for j in i + 1..s_num {
            ss[i].push(nums.pop().unwrap());
            ss[j].push(nums.pop().unwrap());
        }
    }

    if nums.len() > 0 {
        println!("No");
        return;
    }

    println!("Yes");
    println!("{}", s_num);

    for s in ss {
        print!("{} ", s.len());
        println!(
            "{}",
            s.iter()
                .fold(String::new(), |acc, &num| acc + &num.to_string() + " ")
        );
    }
}


Measured memory_bytes: 4220
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define rep(i, j, k) for (auto i = j; i < k; i++)
#define rrep(i, j, k) for (auto i = j; i > k; i--)
using namespace std;

void solve(int &n) {
  ll dp[31][51];
  rep(i, 0, 31) rep(j, 0, 51) dp[i][j] = 0;
  vector<int> v[31];
  rep(i, 0, n) {
    int m; cin >> m;
    rep(j, 0, m) {
      int d; cin >> d;
      v[d].push_back(i);
    }
  }
  rep(i, 0, n) dp[0][i] = (1LL << i);
  rep(i, 1, 31) {
    rep(j, 0, n) dp[i][j] = dp[i - 1][j];
    rep(j, 0, (int)v[i].size()) {
      rep(k, 0, (int)v[i].size()) {
        dp[i][v[i][j]] |= dp[i - 1][v[i][k]];
      }
    }
    rep(j, 0, n) {
      if (dp[i][j] == (1LL << n) - 1) {
        cout << i << endl;
        return;
      }
    }
  }
  cout << -1 << endl;
}

int main() {
  int n;
  while (cin >> n, n) solve(n);
}
//////////////////////////////////////////////////////////////////////////
//NOTE
//////////////////////////////////////////////////////////////////////////
// DPには今持つことが可能な地図の集合を管理してもらう.
// dp[i][j] := i日目にjが持つことが可能な地図の集合
// 0日目に自分の地図だけを持っていることにすると、遷移は
// dp[i][j] = dp[i - 1][j] | dp[i - 1][k] (kはi日目に暇である人)
// dp[i][j] == (1LL << n) - 1　となるjが存在したらi日目に一人に地図を渡すことが可能になる
// これを30日まで繰り返して、無理なら-1
// 
// 感想
// dp自体に集合を持つやつとかあんまり見たことなかった.
// これもbitdpって言うのかね-. それはさておき、こういう問題にもなれておかないとね.
// 参考記事
// http://www.deqnotes.net/acmicpc/p0017/


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

#define rep(i,n) for(ll i=0;i<ll(n);i++)
#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
const double pi = 3.14159265358979;



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

    ll n,c,k;
    cin >> n >> c >> k;
    vector<ll> t(n);
    for (ll i = 0;i < n;i++){
        cin >> t[i];
    }

    sort(t.begin(), t.end());

    ll ans = 0;
    ll ride = 0;
    ll limit = t[0] + k;

    for (ll i = 0; i < n; i++){
        if (ride < c && t[i] <= limit){
            ride++;
        }
        else{
            ans++;
            ride = 1;
            limit = t[i] + k;

        }
    }
    ans++;

    cout << ans << endl;
}

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

struct LowestCommonAncestor {
  LowestCommonAncestor(size_t size) : size(size), MaxlgV(32 - __builtin_clz(size - 1)), G(size), dep(size), par(MaxlgV, vector<int>(size)) {}

  size_t size, MaxlgV;
  int root;
  vector<vector<int>> G, par;
  vector<int> dep;

  void add_edge(int u, int v) {
    G[u].push_back(v);
    G[v].push_back(u);
  }

  void dfs(int v, int u, int d) {
    dep[v] = d;
    par[0][v] = u;
    for (int e : G[v])
      if (e != u) dfs(e, v, d + 1);
  }

  void build(int r) {
    dfs(root = r, -1, 0);
    for (int k = 0; k + 1 < MaxlgV; k++) {
      for (int v = 0; v < size; v++) {
        if (par[k][v] < 0)
          par[k + 1][v] = -1;
        else
          par[k + 1][v] = par[k][par[k][v]];
      }
    }
  }

  int lca(int u, int v) {
    if (dep[u] > dep[v]) swap(u, v);
    for (int k = 0; k < MaxlgV; k++) {
      if ((dep[v] - dep[u]) >> k & 1) {
        v = par[k][v];
      }
    }

    if (u == v) return u;

    for (int k = MaxlgV - 1; k >= 0; k--) {
      if (par[k][u] != par[k][v]) {
        u = par[k][u];
        v = par[k][v];
      }
    }

    return par[0][u];
  }

  int dist(int u, int v) {
    int z = lca(u, v);
    return dep[u] + dep[v] - 2 * dep[z];
  }
};

// https://onlinejudge.u-aizu.ac.jp/#/courses/library/5/GRL/5/GRL_5_C
int main() {
  int N;
  cin >> N;

  LowestCommonAncestor tree(N);
  for (int i = 0; i < N; ++i) {
    int k;
    cin >> k;
    while (k--) {
      int c;
      cin >> c;

      tree.add_edge(i, c);
    }
  }

  tree.build(0);

  int q;
  cin >> q;

  while (q--) {
    int u, v;
    cin >> u >> v;

    cout << tree.lca(u, v) << endl;
  }
}



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

int main(){
    string s;
    cin >> s;
    string ans = "Yes";
    if(s.size()%2==0){
        for(int i=0; i<s.size()-1; i+=2){
            if(!(s[i] == 'h' && s[i+1] == 'i')){
                ans = "No";
            }
        }
    }else{
        ans = "No";
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let n: usize = scan(tokens);
    let k: usize = scan(tokens);
    if k % 2 == 1 || k > n * n / 2 {
        println!("0");
        return;
    }
    let k: usize = k / 2;
    let modulo: usize = 1_000_000_007;
    let mut dp: Vec<Vec<Vec<usize>>> = vec![vec![vec![0; k + 1]; n + 1]; 2];
    dp[0][0][0] = 1;
    for i in 1..n + 1 {
        for j in 0..i + 1 {
            for x in 0..k + 1 {
                let mut tmp: usize = 0;
                if x >= j {
                    if j > 0 {
                        tmp += dp[(i - 1) & 1][j - 1][x - j];
                    }
                    tmp += (2 * j + 1) * dp[(i - 1) & 1][j][x - j];
                    if j < n {
                        tmp += (j + 1) * (j + 1) * dp[(i - 1) & 1][j + 1][x - j];
                    }
                }
                dp[i & 1][j][x] = tmp % modulo;
            }
        }
    }
    println!("{}", dp[n & 1][0][k]);
}


Measured memory_bytes: 4352
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

int main(int argc, char const* argv[])
{
  int n;
  cin >> n;
  vector<ll> a;
  vector<ll> sum;
  for(int i = 0; i < n; i++){
    ll x;
    cin >> x;
    a.pb(x);
  }
  sort(a.begin(), a.end());
  for(int i = 0; i < n; i++){
    if(i == 0)sum.pb(a[i]);
    else sum.pb(a[i] + sum[i - 1]);
  }
  int res = 1;
  for(int i = n - 1; i >= 1; i--){
    if(a[i] > 2 * sum[i - 1]){
      break;
    }
    res++;
  }
  cout << res << endl;
	return 0;
}


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

#define int long long
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define vcopy(v1,v2) copy((v1).begin(), (v1).end(), back_inserter((v2)));
#define pb(n) push_back(n);

int n,a;

main() {
    cin >> n >> a;
    ct(n*n-a)
}

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

int main(){
    int A,B;
    cin >> A >> B;
    if(A+B<24){
        cout << A+B << endl;
    }
    else{
        cout << A+B-24 << endl;
    }
}

Measured memory_bytes: 256
import Control.Monad
import Control.Applicative
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import Data.Foldable (foldMap)
import Data.List.Split
import Data.Char
import Data.Ratio
import Data.Ord
import Data.Array.IO
 
readInt = read :: String -> Int
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
-- end of templete

main = map readDouble . lines <$> getContents >>= \d -> print $ on (-) ($d) maximum minimum

Measured memory_bytes: 3984
while True:
	INPUT = [int(i) for i in input().split()]
	a = INPUT[0]
	b = INPUT[1]
	
	if a == 0 and b == 0:
		break
		
	else:
		for i in range(a):
			if i % 2 == 0:
				print('#.'*int(b/2) + '#'* int(b%2))
			else:
				print('.#'*int(b/2) + '.'* int(b%2)) 
				
		print()


Measured memory_bytes: 5624
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define rep(i,j) for(int i=0;i<j;i++)
int main()
{
	ll N;
	int v[50];
	double ans;
	cin>>N;
	rep(i,N) cin>>v[i];
	sort(v,v+N);
	//reverse(v,v+N);
	ans=v[0];
	for(int i=1;i<N;i++){
		ans=(ans+v[i])/2.0;
	//	cout<<ans<<endl;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
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)];
    }
    bool same(int x, int y){ // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};
int main(){
    int N,M,i,ans = 0,A,B;
    cin >> N >> M;
    UnionFind tree(N);
    for(i = 0;i < M;i++){
        cin >> A >> B;
        tree.unite(A - 1,B - 1);
    }
    for(i = 0;i < N;i++){
        if(!(tree.same(0,i))){
            ans++;
            tree.unite(0,i);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3788
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
ll gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }     //最小公倍数
using Graph = vector<vector<ll>>;
ll inf=300000000000000000;
const double PI = 3.14159265358979323846;
int main(){
  int n,m;
  cin >> n >> m;
  if(m==1){
    cout << n/2 << endl;
    return 0;
  }
  vector<int> k(m,0);
  vector<int> u(m,0);
  map<int,int> o;
  rep(i,n){
    int a;
    cin >> a;
    o[a]++;
  }
  for(pair<int,int> p: o){
    int a=p.first,b=p.second;
    a=a%m;
    k[a]+=b;
    u[a]+=b/2*2;
  }
  int ans=k[0]/2;
  if(m%2==0){
    ans+=k[m/2]/2;
  }
  rep(i,(m-1)/2){
    //cout << ans << endl;
    if(k[i+1]>=k[m-1-i]){
      ans+=k[m-1-i];
      ans+=min(u[i+1]/2,(k[i+1]-k[m-1-i])/2);
    }
    else{
      ans+=k[i+1];
      ans+=min(u[m-i-1]/2,(k[m-i-1]-k[i+1])/2);
    }
  }
  cout << ans << endl;
}


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

int main(){
    // Your code here!
    int n;
    cin>>n;
    int a[n][3];
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            cin>>a[i][j];
        }
    }
    int dp[n][3];
    for(int i=0;i<n;i++)
    {
        if(i==0)
        {
            dp[i][0]=a[i][0];
            dp[i][1]=a[i][1];
            dp[i][2]=a[i][2];
            continue;
        }
        for(int j=0;j<3;j++)
        {
            if(j==0)
            {
                dp[i][j]=a[i][j]+max(dp[i-1][j+1],dp[i-1][j+2]);
            }
            if(j==1)
            {
                dp[i][j]=a[i][j]+max(dp[i-1][j-1],dp[i-1][j+1]);
            }
            if(j==2)
            {
                dp[i][j]=a[i][j]+max(dp[i-1][j-1],dp[i-1][j-2]);
            }
        }
    }
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <string>

using namespace std;

int main()
{
	string str;
	int J_ct, I_ct;

	while (cin >> str){
		J_ct = I_ct = 0;	
		for (int i = 1; i <= str.size(); i++){
			if (str[i] == 'O' && str[i + 1] == 'I'){
				if (str[i - 1] == 'J'){
					J_ct++;
				}
				else if (str[i - 1] == 'I'){
					I_ct++;
				}
			}
		}
		cout << J_ct << endl << I_ct << endl;
	}
	return (0);
}

Measured memory_bytes: 1196
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

constexpr long long MOD = 1000000007;

int main()
{
  long long N, X;
  std::cin >> N >> X;
  std::vector<long long> L(N);
  for (auto& val: L)
    std::cin >> val;
  int ans = 0;
  long long d = 0;
  for (int i = 0; i <= N; ++i)
  {
    if (d <= X)
      ++ans;
    else
      break;
    d += L[i];
  }
  std::cout << ans << std::endl;
  return 0;
}



Measured memory_bytes: 256
k,n = map(int,raw_input().split())
a = map(int,raw_input().split())
b = []
for i in range(n-1):
    b.append(a[i+1]-a[i])
b.append(a[0]+k-a[n-1])
b.sort()
b.pop(n-1)
print sum(b)

Measured memory_bytes: 20056
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

ll f(ll n) {
  ll res = 0;
  ll k = 1;
  while(k <= n) {
    k *= 2;
    ll now = (n + 1) / k * k / 2 + max(0LL, (n + 1) % k - k / 2);
    res += (now % 2) * (k / 2);
  }
  return res;
}

int main() {
  ll a, b;
  cin >> a >> b;
  a--;
  cout << (f(a) ^ f(b)) << endl;
}

Measured memory_bytes: 256
def main
  a, b, c, dist = ARGF.gets.split.map(&:to_i)

  if (a-c).abs <= dist || ((a-b).abs <= dist && (b-c).abs <= dist)
    puts 'Yes'
  else
    puts 'No'
  end
end

if __FILE__ == $0
  main
end


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

//

#define RESIDUE(u,v) (capacity[u][v] - flow[u][v])
#define RCOST(u,v) (cost[u][v] + h[u] - h[v])
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define LL long long

int digit_sum(int a){
  int ret=0;
  while(a>0){
    ret+=a%10;
    a/=10;
  }
  return ret;
}

int main(){
  int n;
  cin>>n;
  int ret = n;
  int a=1,b=n-1;
  REP(i,n-2){
    ret=min(ret,digit_sum(a)+digit_sum(b));
    a++;
    b--;
  }
  cout<<ret<<endl;
  return 0;
}


Measured memory_bytes: 256
def mod(a,k):
    if a>k:
        return a-k
    else:
        return k-a
a,b=input().split()
a=int(a)
b=int(b)
if (a%2==0 and b%2==0) or (a%2==1 and b%2==1):
    print((a+b)//2)
else:
    print("IMPOSSIBLE")

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

int main() {
    while (1) {
        int h, w;
        cin >> h >> w;
        if (h == 0 && w == 0) break;
        for (int i = 0; i < h; i++) {
            for (int j = 0;j < w; j++) {
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
//#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
const int64 INF = 1LL << 58;
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 (a>b) { a=b; return 1; } return 0; }

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

    ll H, W, D; cin >> H >> W >> D;
    vector<l_l> pla(H*W);
    rep(i,H) rep(j,W) {
        ll a; cin >> a;
        pla[a-1] = make_pair(i, j);
    }
    ll Q; cin >> Q;

    vel num(H*W,0);
    for(int i = H*W-1; i >= 0; i--){
        if(i + D > H * W - 1) continue;
        num[i] += num[i + D];
        ll plus = abs( pla[i].fs - pla[i+D].fs ) + abs( pla[i].sc - pla[i+D].sc );
        num[i] += plus;
    }


    rep(i,Q) {
        int L, R; cin >> L >> R;
        cout << num[ L - 1 ] - num[ R - 1 ] << endl;
    }
    return 0;
}



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

typedef long long LL;

const int N=2e5+10,Mod=1e9+7;

struct Edge{ int to,next,cost; }way[N<<1],E[N];

int n,num[N],tot,hed[N],cnt,inv_fact[N],d[N],fact[N];

void Build(int a,int b,int c) { way[++tot]=(Edge){b,num[a],c}; num[a]=tot; } 

void Add(int a,int b) { E[++cnt]=(Edge){b,hed[a]}; hed[a]=cnt; d[b]++; }

void Init() {
	scanf("%d",&n);
	int x,y;
	for (int i=1;i<=2*n;++i) {
		scanf("%d%d",&x,&y);
		Build(x,y+n,x+y);Build(y+n,x,x+y);
	}
}

int que[N],cntedge,cntnode,cirx,ciry,cirw;
bool vis[N];
void Dfs(int x,int fa) {
	vis[x]=1; que[cntnode++]=x;
	for (int i=num[x];i;i=way[i].next) {
		int v=way[i].to;
		if (v==fa) continue;
		cntedge++;
		if (vis[v]==1) { 
			if (!cirx) cirx=x,ciry=v,cirw=way[i].cost; 
			else if (cirx==v && ciry==x) cntedge--;
			continue; 
		}
		Dfs(v,x);
	}
}

bool vis2[N];
void ReBuild(int x,int fa,int cost) {
	vis2[x]=1;
	for (int i=num[x];i;i=way[i].next) {
		int v=way[i].to,c=way[i].cost;
		if (v==fa) continue;
		if (c<cost) 
			Add(x,v);
	}
	for (int i=num[x];i;i=way[i].next) {
		int v=way[i].to;
		if (v==fa || vis2[v]) continue;
		ReBuild(v,x,way[i].cost);
	}
}

int son[N];
LL GetAns(int x,int fa) {
	LL ans=1; son[x]=0;
	for (int i=hed[x];i;i=E[i].next) {
		int v=E[i].to;
		if (v==fa) continue;
		ans=ans*GetAns(v,x)%Mod*inv_fact[son[v]]%Mod;
		son[x]+=son[v];
	}
	ans=ans*fact[son[x]]%Mod;
	son[x]++;
	return ans;
}

LL Work() {
	LL ans,sum=0;
	cnt=0; for (int i=0;i<cntnode;++i) hed[que[i]]=0,d[que[i]]=0,vis2[que[i]]=0;
	ReBuild(cirx,ciry,cirw);
	ans=fact[cntnode];
	for (int i=0;i<cntnode;++i) if (!d[que[i]]) 
		ans=ans*GetAns(que[i],0)%Mod*inv_fact[son[que[i]]]%Mod;
	sum+=ans;
	cnt=0; for (int i=0;i<cntnode;++i) hed[que[i]]=0,d[que[i]]=0,vis2[que[i]]=0;
	ReBuild(ciry,cirx,cirw);
	ans=fact[cntnode];
	for (int i=0;i<cntnode;++i) if (!d[que[i]])
		ans=ans*GetAns(que[i],0)%Mod*inv_fact[son[que[i]]]%Mod;
	sum+=ans;
	return sum%Mod;
}

void Prepare() {
	fact[0]=1; for (int i=1;i<=n*2;++i) fact[i]=1ll*fact[i-1]*i%Mod;
	inv_fact[1]=1; for (int i=2;i<=n*2;++i) inv_fact[i]=1ll*(Mod-Mod/i)*inv_fact[Mod%i]%Mod;
	inv_fact[0]=1; for (int i=2;i<=n*2;++i) inv_fact[i]=1ll*inv_fact[i-1]*inv_fact[i]%Mod;
}

void Solve() {
	Prepare();
	LL ans=1ll;
	for (int i=1;i<=n*2;++i) if (!vis[i]) {
		cntedge=0; cntnode=0; cirx=0; ciry=0;
		Dfs(i,0); 
		if (cntedge!=cntnode) { printf("0\n"); return ; }
		ans=ans*Work()%Mod*inv_fact[cntnode]%Mod;
	}
	printf("%lld\n",ans*fact[n<<1]%Mod);
}

int main() {
	Init();
	Solve();
	return 0;
}

Measured memory_bytes: 15104
#include <bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof(a))
#define inf 0x3f3f3f3f
#define ll long long
#define pb push_back
#define PII pair<int,int>
#define X first
#define Y second
#define MP make_pair
#define PI acos(-1.0)
#define eps 1e-8
const int maxn=3e5+10;
const int maxm=1.5e7+10;
const int mod=1e9+7;
using namespace std;

int k;
int a[35]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int main()
{
    scanf("%d",&k);
    printf("%d",a[k-1]);
    // system("pause");
    return 0;
}

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

ll comb(int n,int r){
    if(n<r)return 0;
    ll ans=1;
    for(int i=1;i<=r;i++){
        ans*=n;
        ans/=i;
        n--;
    }
    return ans;
}

int main(){
    ll n,m;cin>>n>>m;
    ll ans=comb(n,2)+comb(m,2);
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define clr(x,i) memset(x,i,sizeof(x))
using namespace std;
const int N=1000005;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int n,q,f[N],g[N];
char s[N];
LL res,ans;
void solve()
{
	int k=read();
	ans=0;
	LL pr=0,d=0,c=0,m=0;
	for(int i=0;i<k;i++){
		if(s[i]=='D'){
			d++;
		}	
		if(s[i]=='M'){
			m++; pr+=d;
		}
		if(s[i]=='C'){
			ans+=pr;
		}
	}
	for(int i=k;i<n;i++){
		int pos=i-k;
		if(s[pos]=='D'){
			pr-=m; d--;
		}
		if(s[pos]=='M'){
			m--;
		}
		if(s[i]=='D'){
			d++;
		}	
		if(s[i]=='M'){
			m++; pr+=d;
		}
		if(s[i]=='C'){
			ans+=pr;
		}
	}
	cout<<ans<<endl;
}
int main()
{
	n=read(); scanf("%s",s);
	q=read();
	while(q--){
		solve();
	}
}


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

int gcd(int x, int y) { 
  return (x % y)? gcd(y, x % y): y; 
}


int main(){
 int N;
 cin >> N;
 
  long sum = 0;
  
  for (int i=1;i<=N;i++) {
	for (int j=1;j<=N;j++) {
      for (int k=1;k<=N;k++) {
        sum += gcd(i,gcd(j,k));
      }
    }
  }
  
  cout << sum << endl;
}

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

int main(){
	string s1, s2; cin >> s1 >> s2;
	if(s1 == s2) cout << 0 << endl;
	else {
		int s1size = s1.size(), s2size = s2.size();
		int dp[s1size+1][s2size+1];
		memset(dp, 0, sizeof(dp));
		rep(i, s1size+1) dp[i][0] = i;
		rep(i, s2size+1) dp[0][i] = i;
		loop(i, 1, s1size+1)loop(j, 1, s2size+1){
			dp[i][j] = min(dp[i][j-1]+1, dp[i-1][j]+1);
			dp[i][j] = min(dp[i][j], dp[i-1][j-1] + !(s1[i-1] == s2[j-1]));
		}
		cout << dp[s1size][s2size] << endl;
	}
	return 0;
}



Measured memory_bytes: 7068
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int inf = 2e18;
const int mod = 1e9 + 7;

signed main() {
    int N, M;
    cin >> N >> M;
    vector<vector<int>> G(1e5 + 5, vector<int>());
    for (int i = 0; i < M; i++) {
        int X, Y, Z;
        cin >> X >> Y >> Z;
        --X; --Y;
        G[X].push_back(Y);
        G[Y].push_back(X);
    }
    vector<bool> check(1e5 + 5, false);
    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (check[i]) continue;
        queue<int> q;
        q.push(i);
        while (!q.empty()) {
            int v = q.front();
            check[v] = true;
            q.pop();
            for (int nv : G[v]) {
                if (!check[nv]) q.push(nv);
            }
        }
        ++ans;
    }
    cout << ans << endl;

}


Measured memory_bytes: 7284
#include<iostream>
using namespace std;
static const int N = 120;

int main(){
    int M[N][N];
    int n,u,k,v;

    cin >> n;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            M[i][j] = 0;
        }
    }
    for(int i=0;i<n;i++){
        cin >> u >> k;
        u--;
        for(int j=0;j<k;j++){
            cin >> v;
            v--;
            M[u][v] = 1;
        }
    }
  for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
          if(j) cout << " ";
          cout << M[i][j];
      }
      cout << endl;
  }
  
  return 0;  
}


Measured memory_bytes: 3128
use std::collections::HashMap;
#[allow(unused_imports)]
use std::io::Write;

#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

#[allow(non_snake_case)]
fn main() {
    input![N: usize, A: [i32; N]];
    let mut map = HashMap::new();
    for a in &A {
        *map.entry(a).or_insert(0) += 1;
    }
    let ans = map
        .iter()
        .map(|(&k, &v)| if k <= &v { v - k } else { v })
        .sum::<i32>();
    println!("{}", ans);
}


Measured memory_bytes: 12540
from functools import reduce
from fractions import gcd
N = int(input())
T = []
for i in range(N):
    Ti = input()
    if Ti == '':
        break
    else:
        T.append(int(Ti))

# def base(x, y):
#     return (x * y) // gcd(x, y)

# def lcm(*T):
#     return reduce(base, T, 1)

print(reduce(lambda x, y: x * y // gcd(x, y), T, 1))

# print(lcm(*T))

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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; ++i) cin >> A[i];
  sort(A.begin(), A.end());
  for(int i = 1; i < N; ++i){
    if(A[i] == A[i-1]){
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}


Measured memory_bytes: 1024
N = int(input())
ResCnt = 0
for i in range(1, N+1, 2):
    DivCnt = 0
    for j in range(1, i+1):
       if i % j == 0:
           DivCnt += 1
    if DivCnt == 8:
        ResCnt += 1
        
print(ResCnt)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }


int main() {
	IOS;
	int n;
	cin >> n;
	vector<int> x(n), y(n);
	REP(i, n) {
		cin >> x[i] >> y[i];
	}
	double sum = 0;
	REP(i, n) {
		REP(j, n) {
			sum += sqrtl((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]));
		}
	}
	sum /= n;
	cout << setprecision(20) << sum << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
using namespace std;

int main(){
	int ax, ay;
	char f[12][12];
	bool flag = false;

	for(int y=0 ; y<12 ; y++){
		for(int x=0 ; x<12 ; x++){
			f[y][x] = 0;
		}
	}

	while( 1 ){
		for(int i=0 ; i<8 ; i++) {
			if( scanf("%s", f[i]) == EOF ){
				flag = true;
				break;
			}
		}
		if(flag) break;

		for(int i=0 ; i<64 ; i++){
			if(f[i/8][i%8]=='1'){
				ax = i%8;
				ay = i/8;
				//printf("x:%d y:%d\n", ax,ay);
				break;
			}
		}
		//printf("hoge\n");
		if( f[ay+1][ax]=='1' && f[ay][ax+1]=='1' && f[ay+1][ax+1]=='1' ){
			printf("A\n");
		}else if( f[ay+1][ax]=='1' && f[ay+2][ax]=='1' && f[ay+3][ax]=='1' ){
			printf("B\n");
		}else if( f[ay][ax+1]=='1' && f[ay][ax+2]=='1' && f[ay][ax+3]=='1' ){
			printf("C\n");
		}else if( f[ay][ax+1]=='1' && f[ay+1][ax+1]=='1' && f[ay+1][ax+2]=='1' ){
			printf("E\n");
		}else if( f[ay+1][ax]=='1' && f[ay+1][ax+1]=='1' && f[ay+2][ax+1]=='1' ){
			printf("F\n");
		}else if( f[ay][ax+1]=='1' && f[ay+1][ax]=='1' && f[ay+1][ax-1]=='1' ){
			printf("G\n");
		}else if( f[ay+2][ax-1]=='1' && f[ay+1][ax]=='1' && f[ay+1][ax-1]=='1' ){
			printf("D\n");
		}
	}
	

	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <random>
int D;
int c[26];
int l[26][367];
int s[366][26];
int t[366];
long long m = 20000000;
int  p, q, d, k, pp, dd, f;
int ans, bans, pa, pb;
unsigned long long a;
int main() {
	scanf("%d", &D);
	for (int i = 0; i < 26; i++) {
		scanf("%d", c + i);
	}
	for (int i = 1; i <= D; i++) {
		for (int j = 0; j < 26; j++) {
			scanf("%d", s[i] + j);
		}
	}
	std::mt19937_64 rd(468);
	for (int i = 1; i <= D; i++) {
		a = rd();
		t[i] = a % 26;
	}
	for (int i = 1; i <= D; i++) {
		ans += s[i][t[i]];
		for (int j = 0; j < 26; j++) {
			l[j][i] = l[j][i - 1] + 1;
		}
		l[t[i]][i] = 0;
		for (int j = 0; j < 26; j++) {
			ans -= c[j] * l[j][i];
		}
	}
	for (long long i = 0; f == 1 || i < m; i++) {
		a = rd();
		if (f) {
			d = dd;
			q = pp;
		}
		else {
			d = a % D + 1;
			q = a % 26;
		}
		p = t[d];
		if (p != q) {
			bans = ans;
			t[d] = q;
			ans -= s[d][p];
			ans += s[d][q];
			k = d;
			pa = 0;
			pb = 0;
			while (l[q][k]) {
				pa += k - d - l[q][k];
				l[q][k] = k - d;
				k++;
			}
			k = d;
			do {
				pb += (l[p][k] = l[p][k - 1] + 1) - (k - d);
				k++;
			} while (l[p][k]);
			ans -= (c[q] * pa + c[p] * pb);
			a = rd();
			f = 0;
			if (ans < bans && (a % (m * m)) < 2 * m * i - i * i) {
				f = 1;
				pp = p;
				dd = d;
			}
		}
	}
	for (int i = 1; i <= D; i++) {
		printf("%d\n", t[i] + 1);
	}
}

Measured memory_bytes: 1808