akhauriyash/Code-Regression huggingface dataset:
console.log((args=>{
  const [HW,...a] = args.trim().split`\n`;
  const [H,W] = HW.split` `.map(v=>v|0);
  const r = new Set(), c = new Set();
  for ( let i = 0; i < H; i++ ) {
    for (let j = 0; j < W; j++) {
      if ( a[i][j] === '#' ) {
        r.add(i);
        c.add(j);
      }
    }
  }
  return a.filter((_,i)=>r.has(i)).map(r=>r.split``.map((v,i)=>c.has(i)?v:'').join``).join`\n`;
})(require('fs').readFileSync('/dev/stdin', 'utf8')));


Measured memory_bytes: 30552
def main():

    # 変数宣言
    m_cnt_tmp = 0
    m_cnt_ans = 0

    # 標準入力からデータの受け取り
    s = input()
    t = input()
    s_len = len(s)
    t_len = len(t)

    # ループを回しながら調べていく
    for s_cnt in range(0, s_len - t_len + 1):
        for t_cnt in range(0, t_len):
            if (t[t_cnt] == s[s_cnt + t_cnt]):
                m_cnt_tmp += 1
        if (m_cnt_ans < m_cnt_tmp):
            m_cnt_ans = m_cnt_tmp
        m_cnt_tmp = 0

    # 結果表示
    print(t_len - m_cnt_ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 9128
/*  ex4_2
    Graku   */
#include <stdio.h>
#include<math.h>
//#define PI = 3.1415926535

int main(void) {
    double len_h, len_m, hour, min;
    scanf("%lf %lf %lf %lf", &len_h, &len_m, &hour, &min);

    double theta_h = 2 * M_PI * (hour + min/60)/12; //angle between 0 and hour hands [rad]
    double theta_m = 2 * M_PI * min/60; //angle between 0 and minute hands [rad]
    double theta = theta_h - theta_m; //angle between hour and minute hands [rad]

    double ans = sqrt(pow(len_h, 2) + pow(len_m, 2) - 2*len_h*len_m * cos(theta)); //cosine theorem

    printf("%.10f\n", ans); //10 decimal places

    return 0;
}

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

using namespace std;
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int N, K, C;
    cin >> N >> K >> C;
    string S;
    cin >> S;
    vector<int> v;
    for (int i = 0; i < N; ++i) {
        if(S[i] == 'o')v.emplace_back(i);
    }
    //前から見たときのやつ
    vector<int> mae(K);
    int sz = v.size();
    int cnt = 0;
    for(int l = 0; l < sz;){
        int r = l+1;
        while(r < sz && v[l] + C + 1 >  v[r]){
            r++;
        }
        mae[cnt] = v[l];
        cnt++;
        if(cnt == K)break;
        l = r;
    }
    vector<int> usi(K);
    cnt = K - 1;
    for(int r = sz-1; r >= 0;){
        int l = r - 1;
        while(l >= 0 && v[l] > v[r] - C - 1){
            l--;
        }
        usi[cnt] = v[r];
        cnt--;
        if(cnt == -1)break;
        r = l;
    }
    for (int i = 0; i < K; ++i) {
        if(mae[i] == usi[i]){
            cout << mae[i]+1 << endl;
        }
    }
}

Measured memory_bytes: 4236
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

#define TRUE 1
#define FALSE 0

typedef struct _card {
	char mark;
	int value;
} card ;

void isstable(card *targetc, card *c, int N) {
	int sw = TRUE;
	for (int i = 0; i < N; i++) {
		for (int j = i + 1; j < N; j++) {
			for (int a = 0; a < N; a++) {
				for (int b = a + 1; b < N; b++) {
					if (c[i].value == c[j].value && c[i].value == targetc[a].value && c[i].value == targetc[b].value
						&& c[i].mark == targetc[b].mark && c[j].mark == targetc[a].mark) {
						sw = FALSE;
					}
				}
			}
		}
	}
	if (sw) {
		printf("\nStable\n");
	}
	else {
		printf("\nNot stable\n");
	}
}

void babblesort(card *c, int N) {
	card babblec[36];
	for (int i = 0; i < N; i++) {
		babblec[i] = c[i];
	}
	for (int i = 0; i < N; i++) {
		for (int j = N - 1; j > i; j--) {
			if (babblec[j].value < babblec[j-1].value) {
				card tmp = babblec[j];
				babblec[j] = babblec[j-1];
				babblec[j - 1] = tmp;
			}
		}
	}
	for (int i = 0; i < N; i++) {
		if (i) {
			printf(" ");
		}
		printf("%c%d", babblec[i].mark, babblec[i].value);
	}
	isstable(babblec, c, N);
}

void selectsort(card *c, int N) {
	card selectc[36];
	for (int i = 0; i < N; i++) {
		selectc[i] = c[i];
	}
	for (int i = 0; i < N; i++) {
		int minj = i;
		for (int j = i + 1; j < N; j++) {
			if (selectc[minj].value > selectc[j].value) {
				minj = j;
			}
		}
		card tmp = selectc[i];
		selectc[i] = selectc[minj];
		selectc[minj] = tmp;
	}
	for (int i = 0; i < N; i++) {
		if (i) {
			printf(" ");
		}
		printf("%c%d", selectc[i].mark, selectc[i].value);
	}
	isstable(selectc, c, N);
}

int main(void) {
	int N;
	card c[36];
	scanf("%d\n", &N);
	for (int i = 0; i < N; i++) {
		if (i) {
			scanf(" ");
		}
		scanf("%c%d", &(c[i].mark), &(c[i].value));
	}
	babblesort(c, N);
	selectsort(c, N);
	return 0;
}


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

int main(){
  int n,l;cin>>n>>l;//l: 文字列の長さ
  vector <string> word(n);

  for(int i=0;i<n;++i){
    string w;cin >>w;
    word[i]=w;
  }
  sort(word.begin(),word.end());
  for (auto str:word) cout << str;
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll read()
{
	char c;
	ll w=1;
	while((c=getchar())>'9'||c<'0')if(c=='-')w=-1;
	ll ans=c-'0';
	while((c=getchar())>='0'&&c<='9')ans=(ans<<1)+(ans<<3)+c-'0';
	return ans*w;
}
const ll mod=1e9+7;
ll xs1;
ll xs2;
ll n,m;
ll k;
ll jiec[1000005];
ll ksm(ll x,ll y)
{
	ll ans=1;
	while(y)
	{
		if(y&1)ans*=x,ans%=mod;
		x*=x;x%=mod;
		y>>=1;
	}
//	cout<<ans<<endl;
	return ans;
}
ll C(ll x,ll y)//左上 
{
	return jiec[y]*ksm(jiec[x],mod-2)%mod*ksm(jiec[y-x],mod-2)%mod;
}
int main(){
	n=read();
	m=read();
	k=read();
	for(int i=1;i<=n-1;i++)
	{
		xs1+=i*(n-i);
		xs1%=mod;
	}
	xs1*=m;
	xs1%=mod;
	xs1*=m;
	xs1%=mod;
	for(int i=1;i<=m-1;i++)
	{
		xs2+=i*(m-i);
		xs2%=mod;
	}
	xs2*=n;
	xs2%=mod;
	xs2*=n;
	xs2%=mod;
	jiec[0]=1;
//	xs1*=ksm(2,mod-2);
//	xs2*=ksm(2,mod-2);
//	xs1%=mod;
//	xs2%=mod;
//	cout<<xs1<<" "<<xs2<<endl;
	for(int i=1;i<=200000;i++)
	{
		jiec[i]=jiec[i-1]*i;
		jiec[i]%=mod;
	}
	xs1+=xs2;
	xs1%=mod;
	xs1*=C(k-2,n*m-2);
	xs1%=mod;
	cout<<xs1<<endl;
	return 0;
}

Measured memory_bytes: 5164
#include <bits/stdc++.h>
#define fi first
#define se second
#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 srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
  int root(int x) {
        if (data[x] < 0) return x;
        else return data[x] = root(data[x]);
  }
  bool same(int x, int y) {
    return root(x) == root(y);
  }
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};

int main() {
  int n,m;
  cin >> n >> m;
  UnionFind tree(n);  
  rep(i,m){
    int a, b;
    
    cin >> a >> b;
    tree.unite(a-1,b-1);
  }
  int ans = 0;
  for(auto x :tree.data){
    if(x<0)ans++;
  }
  cout<<ans-1<<endl;
  return 0;
}

Measured memory_bytes: 3788
#include <stdio.h>

int main(){
  int num;
  int dig;
  int sum = 0;
  scanf("%d", &num);

  int N = num;
 
  while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
  }
  if(N % sum == 0){
      printf("Yes \n");
  }else{
      printf("No \n");
  }
 
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
using ll = long long;
using namespace std;
const int INF32       = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7        = 1'000'000'007;
const int MOD9        = 1'000'000'009;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

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

    int N, D;
    cin >> N >> D;

    D *= 2;
    D++;
    int ans = (N + D - 1) / D;
    std::cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <utility>
#include <typeinfo>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#define REP(i,n) for(int i=0;i<n;i++)
typedef long long ll;
using namespace std;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;

int main() 
{
	int n,k,m;
	while(cin>>n>>k>>m&&!(n==0&&k==0&&m==0))
	{
		int a[10000];
		REP(i,n)a[i]=i;
		
		int stone(n);//残りの石の数
		int point(m-k);//直前に取った石の位置
		
		while(stone>1)
		{
			point=(point+k-1)%stone;
			//取り除く
			rotate(a+point,a+point+1,a+stone);
			//石を減らす
			stone--;
		}
		cout<<a[0]+1<<endl;
	}
	return 0;
}

Measured memory_bytes: 1216
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    V<int> h(n);
    for (int i = 0; i < n; i++) cin >> h[i];
    V<int> dp(n, INF);
    dp[0] = 0;
    for (int i = 0; i < n; i++) {
        if (i + 1 < n) chmin(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]));
        if (i + 1 < n) chmin(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]));
    }
    cout << dp.back() << '\n';
    return 0;
}


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

signed main() {
    int N;
    cin >> N;
    vector<int> v(N);
    for (int& x : v) cin >> x;

    sort(v.begin(), v.end());
    double ans = v.front();
    for (int x : v) {
        ans = (ans + x) / 2;
    }
    cout << fixed << setprecision(6) << ans << endl;
}


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

int dp[11][331][1024];

int main()
{
	dp[0][0][0] = 1;
	for (int i = 0; i < 10; i++){
		for (int j = 0; j <= 330; j++){
			for (int k = 0; k < 1024; k++){
				if (dp[i][j][k]){
					for (int l = 0; l <= 9; l++){
						if ((~k) & (1 << l)){
							dp[i + 1][j + (i + 1) * l][k | (1 << l)] += dp[i][j][k];
						}
					}
				}
			}
		}
	}
	
	int n, s;
	while (scanf("%d %d", &n, &s) != EOF){
		if (s > 330){
			puts("0");
			continue;
		}
		
		int sum = 0;
		for (int i = 0; i < 1024; i++){
			sum += dp[n][s][i];
		}
		printf("%d\n", sum);
	}
	
	return 0;
}

Measured memory_bytes: 13756
def examA():
    H,A = LI()
    ans = (H-1)//A+1
    print(ans)
    return

def examB():
    ans = 0
    print(ans)
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
alphabet = [chr(ord('a') + i) for i in range(26)]

if __name__ == '__main__':
    examA()

"""

"""

Measured memory_bytes: 3700
#include<bits/stdc++.h>
using namespace std;
pair<int,int>p[6];
int n,x;
int main()
{
    for(int i=1;i<=5;i++){
        cin>>x;
        p[i]={(x%10)==0?0:10-(x%10),x};
    }
    sort(p+1,p+6);
    int ans=0;
    for(int i=1;i<=4;i++){
        for(int j=p[i].second;j<=150;j++){
            if(j%10==0){
                ans+=j;
                break;
            }
        }
    }
    ans+=p[5].second;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vi = vector<ll>;
using vvi = vector<vi>;



int main() {
    int x, y, z, k;
    cin >> x >> y >> z >> k;
    vi a(x), b(y), c(z);
    rep(i, x) {
        cin >> a[i];
    }
    rep(i, y) {
        cin >> b[i];
    }
    rep(i, z) {
        cin >> c[i];
    }

    
    sort(rall(c));

    vi ab;

    rep(i, x) {
        rep(j, y) {
            ab.push_back(a[i] + b[j]);
        }
    }

    sort(rall(ab));

    rep(i, x*y-k) {
        ab.pop_back();
    }

    vi abc;
    rep(i, min(x*y, k)) {
        rep(j, z) {
            abc.push_back(ab[i] + c[j]);
        }
    }

    sort(rall(abc));
    rep(i, k) {
        cout << abc[i] << endl;
    }
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
using P = pair<ll, ll>;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
struct edge {
  ll to, cost;
};

int main() {
  int x; cin >> x;
  cout << !x << endl;
}


Measured memory_bytes: 3588
//27
#include<iostream>
#include<algorithm>
#include<cstdlib>

using namespace std;

int main(){
  int n,m,k;
  cin>>n>>m>>k;
  int t[3001];
  fill(t,t+3001,1<<29);
  int a[100000][2],l[100000];
  for(int i=0;i<m;i++){
    cin>>a[i][0]>>a[i][1]>>l[i];
  }
  for(int i=0;i<k;i++){
    int s;
    cin>>s;
    t[s]=0;
  }
  for(int o=0;o<n;o++){
    for(int i=0;i<m;i++){
      for(int j=0;j<2;j++){
	t[a[i][j]]=min(t[a[i][j]],t[a[i][!j]]+l[i]);
      }
    }
  }
  int ll=0;
  for(int i=0;i<m;i++){
    ll=max(ll,(l[i]-abs(t[a[i][0]]-t[a[i][1]])+1)/2+max(t[a[i][0]],t[a[i][1]]));
  }
  cout<<ll<<endl;
  return 0;
}

Measured memory_bytes: 2344
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val f = IntArray(n) {
        (1..10).map { sc.nextInt() }
                .reduce { acc, i -> acc.shl(1) + i }
    }

    val p = Array(n) { IntArray(11) { sc.nextInt() } }
    
    val max = (1 until (1.shl(10)))
            .map { state ->
                f.map { it and state }
                        .map { Integer.bitCount(it) }
                        .mapIndexed { index, count -> p[index][count] }
                        .sum()
            }.max()

    println(max)
}

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


int main(){
    long long a,b,c,d;
    long long ans1, ans2, ans3, ans4;
    std::cin >> a >> b >> c >> d;
    long long ans;

    ans1 = a * c;
    ans2 = b * c;
    ans3 = a * d;
    ans4 = b * d;

    ans = ans1;

    if(ans2 > ans){
        ans = ans2;
    }
    if(ans3 > ans){
        ans = ans3;
    }
    if(ans4 > ans){
        ans = ans4;
    }

    std::cout << ans;

}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
struct HopcroftKarp {
  vector< vector< int > > graph;
  vector< int > dist, match;
  vector< bool > used, vv;
  HopcroftKarp(int n, int m) : graph(n), match(m, -1), used(n) {}
  void add_edge(int u, int v) {
    graph[u].push_back(v);
  }
  void bfs() {
    dist.assign(graph.size(), -1);
    queue< int > que;
    for(int i = 0; i < graph.size(); i++) {
      if(!used[i]) {
        que.emplace(i);
        dist[i] = 0;
      }
    }
    while(!que.empty()) {
      int a = que.front();
      que.pop();
      for(auto &b : graph[a]) {
        int c = match[b];
        if(c >= 0 && dist[c] == -1) {
          dist[c] = dist[a] + 1;
          que.emplace(c);
        }
      }
    }
  }
  bool dfs(int a) {
    vv[a] = true;
    for(auto &b : graph[a]) {
      int c = match[b];
      if(c < 0 || (!vv[c] && dist[c] == dist[a] + 1 && dfs(c))) {
        match[b] = a;
        used[a] = true;
        return (true);
      }
    }
    return (false);
  }
  int bipartite_matching() {
    int ret = 0;
    while(true) {
      bfs();
      vv.assign(graph.size(), false);
      int flow = 0;
      for(int i = 0; i < graph.size(); i++) {
        if(!used[i] && dfs(i)) ++flow;
      }
      if(flow == 0) return (ret);
      ret += flow;
    }
  }
  void output() {
    for(int i = 0; i < match.size(); i++) {
      if(~match[i]) {
        cout << match[i] << "-" << i << endl;
      }
    }
  }
};
int gcd(int a, int b) {
  if(b == 0) return a;
  else return gcd(b, a%b);
}
int main() {
  cin.tie(0);
  cout << fixed << setprecision(10);
  while(1) {
    int n, m; cin >> n >> m;
    if(n == 0) break;
    vector<int> b(n), r(m);
    for(int i=0;i<n;++i) {
      cin >> b[i];
    }
    for(int i=0;i<m;++i) {
      cin >> r[i];
    }
    HopcroftKarp hk(n, m);
    for(int i=0;i<n;++i) {
      for(int j=0;j<m;++j) {
        if(gcd(b[i], r[j]) != 1) {
          hk.add_edge(i, j);
        }
      }
    }
    cout << hk.bipartite_matching() << endl;
  }
}



Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>

using namespace std;

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

const ll mod = 1000000007;

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

  ll n, m;
  cin >> n >> m;
  vector<ll> a(n);
  for (auto &x: a) cin >> x;

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

  vector<ll> asum(n+1);
  for (int i = 0; i < n; i++) {
    asum[i+1] = asum[i] + a[i];
  }

  ll left = 0;
  ll right = 200000;
  while (left < right) {
    ll center = (left + right + 1) / 2;
    ll count = 0;
    for (int i = 0; i < n; i++) {
      ll target = center - a[i];
      auto lb = lower_bound(a.begin(), a.end(), target);
      ll d = distance(lb, a.end());
      count += d;
    }
    if (count >= m) left = center;
    else right = center - 1;
  }

  ll count = 0;
  ll score = 0;
  for (int i = 0; i < n; i++) {
    ll target = left - a[i];
    auto lb = lower_bound(a.begin(), a.end(), target);
    ll d = distance(lb, a.end());
    count += d;
    score += (asum[n] - asum[n-d]) + (a[i] * d);
  }
  score -= left * (count - m);

  cout << score << endl;

  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  if (A + B < C + D) {
  	cout << "Right" << endl;
  } else if (A + B > C + D) {
  	cout << "Left" << endl;
  } else {
  	cout << "Balanced" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String args[]) {
        
        Scanner sc = new Scanner(System.in);
        
        String s = sc.next();
        
        int counter = 0;
        
        for(int i = 0; i < s.length(); ++i) {
            if(s.charAt(i) != s.charAt(s.length() - i -1)) ++counter;
            else continue;
        }
        
        System.out.println(counter / 2);
    }
}

Measured memory_bytes: 21844
#![allow(non_snake_case)]

use std::io::{stdin, Read};
use std::str::FromStr;
fn read_option<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok()
}
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    let K: usize = read();
    let vec = [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];
    println!("{}", vec[K - 1]);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  int A,B,C,D,L,R;
  
  cin >> A >> B >> C >> D;
  
  L=A+B;
  R=C+D;
  
  if (L>R)
  {
    cout << "Left" << endl;
  }
  else if(L<R)
  {
    cout << "Right" << endl;
  }
  else
  {
    cout << "Balanced" << endl;
   }
}


Measured memory_bytes: 256
#include <stdio.h>


int main() {
	int m, f, r, count = 0;
	char b[100] = {};
	for (;;) 
	{
		scanf("%d%d%d", &m, &f, &r);
		if (m == -1 && f == -1 && r == -1)break;
		if(m==-1||f==-1)
		{
			b[count] = 'F';
		}
		else if (m + f > 79) {
			b[count] = 'A';
		}
		else if (m + f > 64) {
			b[count] = 'B';
		}
		else if (m + f > 49) {
			b[count] = 'C';
		}
		else if (m + f > 29) {
			if (r > 49) {
				b[count] = 'C';
			}
			else {
				b[count] = 'D';
			}
		}
		else {
			b[count] = 'F';
		}
		count++;
	}
	
	for (int i = 0; i < count; i++) {
		printf("%c\n", b[i]);
	}

	return 0;
}

Measured memory_bytes: 2728
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _0430_atcoder問題_12
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int a = Convert.ToInt32(input[0]);
            int b = Convert.ToInt32(input[1]);
            int c = Convert.ToInt32(input[2]);
            int d = 0; int e = 0; int f = 0;
            if (a >= b &&a >= c)
            {
                if(b>=c)
                {
                    d = a; e = b; f = c;
                }
                else
                {
                    d = a; e = c; f = b;
                }
            }
            else if (b >= a && b >= c)
            {
                if (a >= c)
                {
                    d = b; e = a;  f = c;
                }
                else
                {
                     d = b; e = c;  f = a;
                }
            }
            else
            {
                if (a >= b)
                {
                    d = c;  e = a;  f = b;
                }
                else
                {
                    d = c; e = b;f = a;
                }
            }
            string hoge = d.ToString() + e.ToString();
            int piyo = int.Parse(hoge);
            Console.WriteLine(piyo + f);
        }
    }
}


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

int main(){
        long long i,n,ans,tmp;
        cin >> n;
        ans = n-1;
        for(i=2;i*i<=n;++i){
                if(n%i!=0) continue;
                ans = n/i+i-2;
        }
        cout << ans << endl;
        return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define lo long
const int lmax=1999999999;
const long long lmx=1999999999999999999;
long long n,m,l;
string s,t;
map<long long, int> x;
int main(){std::ios::sync_with_stdio(false);
cin>>n>>m;
cin>>s>>t;
l=n*m/__gcd(n,m);
for(int i=0;i<=n-1;i++)
{
	x[i*(l/n)+1]=s[i]-'a'+1;
}
for(int i=0;i<=m-1;i++)
{
	if(x[i*(l/m)+1]!=0 &&(x[i*(l/m)+1]!=t[i]-'a'+1))
	{
		cout<<-1<<endl;
		return 0;
	}
}
cout<<l<<endl;
}
/*

                   *         *
                  * *       * *
                 *   *     *   *
                *     *   *     *
               *       * *       *
               *        *        *
                *               *
                 *             *
                  *           *
                   *         *
                    *       *
                     *     *
                      *   *
                       * *
                        *



*/





Measured memory_bytes: 10880
#include<bits/stdc++.h>
using namespace std;
#define ll long long
struct Point
{
    double x,y;
    int dx,dy;
};
double simulate(vector<Point> points,double t)
{
    double maxX=-1e18,maxY=-1e18,minX=1e18,minY=1e18;
    for(int i=0;i<points.size();++i)
    {
        points[i].x += points[i].dx * t;
        points[i].y += points[i].dy * t;
        maxX = max(maxX,points[i].x);
        maxY = max(maxY,points[i].y);
        minX = min(minX,points[i].x);
        minY = min(minY,points[i].y);
    }
    return (maxY-minY)*(maxX-minX);
}
int main()
{
    int n;
    cin>>n;
    vector<Point> points(n);
    for(int i=0;i<n;++i)
    {
        cin>>points[i].x>>points[i].y;
        char ch;
        cin>>ch;
        if(ch == 'U')
        {
            points[i].dx = 0, points[i].dy = 1;
        }else if(ch == 'D')
        {
            points[i].dx = 0, points[i].dy = -1;
        }else if(ch == 'L')
        {
            points[i].dx = -1, points[i].dy = 0;
        }
        else if(ch == 'R')
        {
            points[i].dx = 1, points[i].dy = 0;
        }
    }
    double l = 0, r = 1e8;
    while(l+1e-8<r){
        double m1=l+(r-l)/3;
        double m2=r-(r-l)/3;
        if(-simulate(points, m1)>-simulate(points, m2))
            r=m2;
        else
            l=m1;
    }
    printf("%.9f\n",simulate(points,l));
}

Measured memory_bytes: 7328
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc123C
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = long.Parse(Console.ReadLine());
            var trans = Enumerable.Range(0, 5).Select(x => long.Parse(Console.ReadLine())).ToArray();
            long minval = trans.Min();
            var time = (long)Math.Ceiling((double)n / minval) + 4;
            
            Console.WriteLine(Convert.ToString(time));
            Console.ReadKey();
        }
    }
}



Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define pb push_back
#define pi pair<int, int>
#define l first
#define r second
#define all(x) x.begin(), x.end()
#define fori(a, b, step) for (int i = a; i < b; i += step)
#define forj(a, b, step) for (int j = a; j < b; j += step)

const int maxn = 5e5 + 1, mod = 1e9 + 7;

using namespace std;

bool v[1001][1001];

int main() {
    int n, m, a, b;
    cin >> n >> m >> a >> b;
    for (int i = 0; i < b; i++)
        for (int j = 0; j < a; j++)
            v[i][j] = 1;
    for (int i = b; i < n - b; i++)
        for (int j = a; j < 2 * a; j++)
            v[i][j] = 1;
    for (int i = n - b; i < n; i++)
        for (int j = a; j < m; j++)
            v[i][j] = 1;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++)
            cout << v[i][j];
        cout << '\n';
    }
    return 0;
}


Measured memory_bytes: 4512
import java.util.*;

public class Main {

  public static void main(String args[]) {
    int rep = 1;
    if( args.length > 0 ) { rep = Integer.parseInt(args[0]); }
    (new Main()).__solve(rep);
  }

  void __solve(int rep) {

    try (
      Scanner cin = new Scanner(System.in);
    ) {

      for( int i = 0; i < rep; ++i ) {
        __solve(cin);
      }

    }

  }

  void __solve(Scanner cin) {

	  int N = cin.nextInt();
	  String s = cin.next();
	  
	  int Ecount = 0;
	  
	  for(int i = 0; i < N; ++i ) {
		  Ecount += (s.charAt(i) == 'E' ? 1: 0);
	  }
	  
	  int min = N;
	  
	  int Wcount = 0;
	  for( int i = 0; i < N; ++i ) {
		  if( s.charAt(i) == 'W' ) {
			  min = Math.min(min, Wcount + Ecount);
			  ++Wcount;
		  }
		  else {
			  --Ecount;
			  min = Math.min(min, Wcount + Ecount);
		  }
	  }
	  
	  System.out.println(min);
	  
  }

}


Measured memory_bytes: 28868
#include <stdio.h>
long long a, b, c, d, x, y;
int main() {
	scanf("%lld%lld%lld%lld", &a, &b, &c, &d);
	x = a * c;
	y = a * d;
	if (x < y)x = y;
	y = b * c;
	if (x < y)x = y;
	y = b * d;
	if (x < y)x = y;
	printf("%lld\n", x);
}

Measured memory_bytes: 1732
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod= 1e+9+7;

int main(){
    long double pi=3.1415926535897932;
    long double a,b,x,y,ans; cin>>a>>b>>x;
    cout<<fixed<<setprecision(10);
    y=2*x/(a*b);
    if(y<=a){
        ans=atan(a*b*b/(2*x))/pi*180;
    }
    else{
        ans=90-atan(a*a*a/(2*(a*a*b-x)))/pi*180;
    }
    cout<<ans<<endl;

}



















































Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repp(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)
#define p(s) cout << s << endl;
typedef long long LL;
template <class T>
bool contain(const std::string &s, const T &v)
{
    return s.find(v) != std::string::npos;
}

int main()
{
    int n; cin>>n;
    cout << 800*n - (n/15*200) << endl;
}

Measured memory_bytes: 256
import sys
input=sys.stdin.readline
h,w=map(int,input().split())
S=[list(input().strip()) for _ in range(h)]
A=[[0]*(w+2) for _ in range(h+2)]
for i,s in enumerate(S):
    for j,t in enumerate(s):
        if t=='.':
            A[i+1][j+1]=A[i+1][j]+1
    for k in reversed(range(w+1)):
        if A[i+1][k]==0:
            continue
        A[i+1][k]=max(A[i+1][k],A[i+1][k+1])
St=list(map(list,zip(*S)))
B=[[0]*(h+2) for _ in range(w+2)]
for i,s in enumerate(St):
    for j,t in enumerate(s):
        if t=='.':
            B[i+1][j+1]=B[i+1][j]+1
    for k in reversed(range(h+1)):
        if B[i+1][k]==0:
            continue
        B[i+1][k]=max(B[i+1][k],B[i+1][k+1])
B=list(map(list,zip(*B)))
ans=0
for i in range(h+2):
    for j in range(w+2):
        ans=max(ans,A[i][j]+B[i][j]-1)
print(ans)

Measured memory_bytes: 313864
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <cmath>

#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;

int main(int argc, char const* argv[])
{
  int n;
  cin >> n;
  if(n == 1){
    int a;
    cin >> a;
    cout << a << endl;
    return 0;
  }
  vector<int> top[2];
  vector<int> a;
  for(int i = 0; i < n; i++){
    int x;
    cin >> x;
    a.pb(x);
  }
  for(int i = a.size() - 1; i >= 0; i--){
    top[(a.size() - 1 - i) % 2].pb(a[i]);
  }
  for(int c: top[0]){
    cout << c << " ";
  }
  for(int i = top[1].size() - 1; i >= 0; i--){
    cout << top[1][i];
    if(i == 0)cout << endl;
    else cout << " ";
  }
	return 0;
}


Measured memory_bytes: 4212
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MOD 1000000007


void solve()
{
	ll n;
	cin>>n;
	vector<ll> a(n),b(n),c(n);
	for(ll i=0;i<n;i++)
		cin>>a[i];
	for(ll i=0;i<n;i++)
		cin>>b[i];
	for(ll i=0;i<n;i++)
		cin>>c[i];
	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	sort(c.begin(),c.end());
	
	ll ans=0;
	for(ll i=0;i<n;i++)
	{
		vector<ll>::iterator lower,upper;
    	lower = lower_bound (a.begin(), a.end(),b[i]);  
    	upper = upper_bound (c.begin(), c.end(),b[i]);
		ans+=(lower-a.begin())*(n-(upper-c.begin()));
	
	}
	cout<<ans;

    return;
}

int main()
{
        fast;
        ll q;
        q=1;
        // cin>>q;
        while(q--)
        	solve();
        
        return 0;
}


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

int main() {
  int A, B;
  cin >> A >> B;
  
//エラー処理
  if(A < 10000 || A > 99999 || B < 10000 || B > 99999){
    cout << "error" << endl;
    return 0;
  }
  
//変数設定  
  int count = 0;//回文数
  const int digit = 5;
  int keta[digit];//各桁の数字
  
//CをA~Bの数に設定し、回文数か判定 
  for(int C = A; C <= B; C++){
    //各桁の数字を求める
    int D = C;
    for(int i = 0 ; i < digit ; i++){
      keta[i] = D / pow(10, (digit-i-1));
      D -= keta[i] * pow(10, (digit-i-1));
    }
    
    //回文数かの判定
    if(keta[0] == keta[4] && keta[1] == keta[3])
      count += 1;
  }
  
  cout << count << endl;
}

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

int main(){
    long long int n;
    cin >> n;

    if(n % 2 == 1){
        cout << 0 << endl;
        return 0;
    }

    long long int ans = 0;
    long long int div = 10;
    while(n / div > 0){
        ans += n / div;
        div *= 5;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  int a;
  cin>>a;
  int b=a%10;
  if(b==3){
    cout<<"bon"<<endl;
  }
  else if(b==0||b==1||b==6||b==8){
    cout<<"pon"<<endl;
  }
  else{
    cout<<"hon"<<endl;
  }
}

Measured memory_bytes: 3632
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

type pair struct {
	fi int
	se int
}

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	//予備
	n := iScan()
	d := make([]int, n)
	for i := 0; i < n; i++ {
		d[i] = iScan()
	}
	sort.Slice(d, func(i int, j int) bool {
		return d[i] < d[j]
	})
	if n%2 == 0 {
		if d[n/2-1] != d[n/2] {
			fmt.Println(d[n/2] - d[n/2-1])
		} else {
			fmt.Println(0)
		}
	} else {
		fmt.Println(0)
	}
}

Measured memory_bytes: 3200
#include<iostream>
#include<vector>
#include<math.h>
 
using namespace std;
 
int main()
{
  int N, D;
  
  // 標準入力から点の数、次元数を受け取る
  cin >> N >> D;
  
  // N,Dの範囲チェック
  if( ( 2 <= N ) && ( N <= 10 ) &&
      ( 1 <= D ) && ( D <= 10 ))
  {
    vector<vector<int>> X;
    X.resize(N);
    for( int i = 0 ; i < N ; i++ )
    {
      X[i].resize(D);
      for( int j = 0 ; j < D ; j++ )
      {
        cin >> X[i][j];
      }
    }
    
    int count = 0;
    for( int a = 0 ; a < (N - 1) ; a++ )
    {
      for( int b = (a + 1) ; b < N ; b++ )
      {
        double distance = 0.0;
        // 距離を計算
        for( int j = 0 ; j < D ; j++ )
        {
          distance += (X[a][j] - X[b][j]) * (X[a][j] - X[b][j]);
        }
        distance  = sqrt(distance);
        if( ceil(distance) == floor(distance) )
        {
          count++;
        }
      }
    }
    
    // 結果を出力
    cout << count << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int A, B, C;
  scanf("%d%d%d", &A, &B, &C);
  
  if (A + B >= C) {
    printf("%d", B + C);
  } else {
    printf("%d", A + 2 * B + 1);
  }
  
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<string.h>
#define LEN 1000005

typedef struct pp{
	char name[100];
	int t;
} P;

P Q[LEN];
int head, tail;

void enqueue(P x){
	Q[tail] = x;
	tail=(tail+1)%LEN;
}

P dequeue(){
	P x = Q[head];
	head = (head+1)%LEN;
	return x;
}

int min(int a, int b){return a>b?b:a;}

int main(){
	int elaps=0, i, q, c, n;
	scanf("%d %d",&n,&q);
	for(i=1;i<=n;i++){
		scanf("%s",Q[i].name);
		scanf("%d",&Q[i].t);
	}
	head=1;
	tail=n+1;
	while (head != tail){
		P u = dequeue();
		elaps+=min(u.t,q);
		if(u.t > q){
			u.t -= q;
			enqueue(u);
		}else{
			printf("%s %d\n",u.name,elaps);
		}
	}
	return 0;
}



Measured memory_bytes: 21912
package main

import "fmt"

func main() {
	var n, k int
	fmt.Scan(&n, &k)

	if k == 0 {
		fmt.Println(n * n)
		return
	}

	ans := 0
	for a := k; a <= n; a++ {
		ans += n / a * (a - k)
		ans += max(0, n%a-k+1)
	}
	fmt.Println(ans)
}

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


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(){
long long n,k,q;
  cin >>n>>k>>q;
  vector<long long>data(n);
  for (long long i=0;i<n;i++){
   data.at(i)=k;
  
  }
  for (long long i=0;i<q;i++){
    long long a;
    cin>> a;
    --a;
    data.at(a)+=1;   
  }
 for (long long i=0;i<n;i++){
 if (data.at(i)<=q){
   cout <<"No"<<endl;
 }
   else{
   cout <<"Yes"<<endl;
   }
 
 }
  
  
}

Measured memory_bytes: 1408
#include <cstdio>
#include <algorithm>

#define INF 1000000000

using namespace std;

int n, m, R, r[8] = {}, a, b, c, d[200][200] = {};
bool z[8] = {};

int dfs(int x, int k, int s);

int main()
{
	int i, j, k, f = INF, sum = INF;

	scanf("%d %d %d", &n, &m, &R);
	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			if (i == j) {
				d[i][j] = 0;
			}
			else {
				d[i][j] = INF;
			}
		}
	}
	for (i = 0; i < R; i++) {
		scanf("%d", &r[i]);
		r[i]--;
	}
	for (i = 0; i < m; i++) {
		scanf("%d %d %d", &a, &b, &c);
		d[a - 1][b - 1] = c;
		d[b - 1][a - 1] = c;
	}

	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			for (k = 0; k < n; k++) {
				d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
			}
		}
	}

	for (i = 0; i < R; i++) {
		z[i] = true;
		f = dfs(r[i], 0, 1);
		z[i] = false;
		if (sum > f) {
			sum = f;
		}
	}

	printf("%d\n", sum);

	return 0;
}

int dfs(int x, int k, int s) {
	int i, f = INF, sum = INF;

	if (s == R) {
		return k;
	}

	for (i = 0; i < R; i++) {
		if (!z[i]) {
			z[i] = true;
			f = dfs(r[i], k + d[x][r[i]], s + 1);
			z[i] = false;
		}
		if (sum > f) {
			sum = f;
		}
	}

	return sum;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    print(700+input().count('o')*100)

if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#include<iostream>
#include<string>
#include<stdio.h>
#include<vector>
using namespace std;

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

  vector<string> S(N);
  vector<int> P(N);
  vector<int> No(N);
  for(int i = 0; i < N; i++)
  {
    /* code */
    cin >> S[i];
    cin >> P[i];
    No[i] = i;
    
  }
  string strTmp = "";
  int pTmp = 0;
  int noTmp = 0;
  for(int i = 0; i < N; i++)
  {
    /* code */
    for(int j = N-1; j > i; j--)
    {
      /* code */
       if(S[j-1] > S[j]){
       strTmp = S[j];
       pTmp =  P[j];
       noTmp = No[j]; 

        S[j] = S[j-1];
        P[j] = P[j-1];
       No[j] = No[j-1];

       S[j-1] = strTmp;
       P[j-1] = pTmp;
       No[j-1] = noTmp;
       }
    }     
  }
    for(int i = 0; i < N; i++)
  {
    /* code */
    for(int j = N-1; j > i; j--)
    {
      /* code */
       if(S[j-1] == S[j] && P[j-1] < P[j]){
       strTmp = S[j];
       pTmp =  P[j];
       noTmp = No[j]; 

        S[j] = S[j-1];
        P[j] = P[j-1];
       No[j] = No[j-1];

       S[j-1] = strTmp;
       P[j-1] = pTmp;
       No[j-1] = noTmp;
       }
    }     
  }
  for(int i = 0; i < N; i++)
  {
    /* code */
//    cout << S[i] << endl;
//    cout << P[i] << endl;
    cout << No[i] + 1 << endl;
  }

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define All(v) (v).begin(),(v).end()
typedef long long ll;

int main(){
    int N,K,Q;
    cin >> N >> K >> Q;
    vector<int> a(Q);
    vector<int> point(N),last(N,K);
    rep(i,Q){
        int b;
        cin >> b;
        b--;
        point[b]++; 
    }
    rep(i,N){
        last[i]-=Q-point[i];
    }
    rep(i,N){
        //cout << last[i] << endl;
        if(last[i]>0)cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <math.h>
using namespace std;

int main ()
{
  int N, M;
  int x, y;

  scanf("%d", &N);
  scanf("%d", &M);

  x = pow(2, M);
  y = (1900 * M + (N - M) * 100) * x;

  printf("%d\n", y);

  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define rep(i, n) rep2(i, 0, n)
using ll = long long;
using V = vector<int>;
using Vll = vector<ll>;
using VV = vector<V>;
using VVll = vector<Vll>;

char s[1000000];
ll t[3][1000001];

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

  VV pos(3, V());
  char dmc[3] = {'D', 'M', 'C'};

  rep(i, n) rep(j, 3) {
    t[j][i+1] = t[j][i];
    if (s[i] == dmc[j]) {
      ++t[j][i+1];
      pos[j].push_back(i);
    }
  }

  rep(_, q) {
    int k; 
    scanf("%d", &k);
    ll ans = 0;
    for (auto &c : pos[2]) ans += t[1][c] * (t[0][c] - t[0][max(c-k+1, 0)]);
    for (auto &a : pos[0]) ans -= t[1][a+1] * (t[2][min(a+k, n)] - t[2][a+1]);
    printf("%lld\n", ans);
  }
  return 0;
}


Measured memory_bytes: 28884
import sys
sys.setrecursionlimit(10**7)
def lmi(): return list(map(int, input().split()))

n = int(input())
e = []
tree = [[] for i in range(n)]
w = [-1] * n
for i in range(n-1):
    a, b = lmi()
    a -= 1; b -= 1
    e.append([a, b])
    tree[a].append(b)
    tree[b].append(a)

c = lmi()
c.sort()

def dfs(x):
    if len(c) == 0:
        return
    if w[x] == -1:
        w[x] = c.pop()
        for i in tree[x]:
            dfs(i)

dfs(0)

print(sum([min(w[i],w[j]) for i, j in e]))
print(' '.join(map(str, w)))


Measured memory_bytes: 14820
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.math;

long n, m;

void main() {
    scan(n, m);

    auto cmb = new long[][](n + 1, n + 1);
    auto dp = new long[][](n + 1, n + 1);
    foreach (i ; 0 .. n + 1) {
        cmb[i][0] = cmb[i][i] = 1;
        dp[i][0] = dp[i][i] = 1;
    }
    foreach (i ; 0 .. n + 1) {
        foreach (j ; 1 .. i) {
            cmb[i][j] = (cmb[i-1][j] + cmb[i-1][j-1]);
            if (cmb[i][j] >= m) cmb[i][j] -= m;
            dp[i][j] = (dp[i-1][j-1] + (j + 1) * dp[i-1][j] % m);
            if (dp[i][j] >= m) dp[i][j] -= m;
        }
    }

    debug {
        //writeln(cmb);
        //writeln(dp);
    }

    auto tpm = new long[](n*n + 1);
    auto tpm1 = new long[](n*n + 1);
    tpm[0] = tpm1[0] = 1;
    foreach (i ; 1 .. n*n + 1) {
        tpm[i] = tpm[i-1] * 2 % m;
        tpm1[i] = tpm1[i-1] * 2 % (m-1);
    }

    long f(int k) {
        long res;
        auto t = powmod(2, tpm1[n - k], m);

        foreach (x ; 0 .. k + 1) {
            //res += powmod(2, powmod(2, n - k, m - 1), m) * dp[k][x] % m * powmod(2, (n - k) * x, m) % m;
            res += t * dp[k][x] % m * tpm[(n-k)*x] % m;
            if (res >= m) res -= m;
        }

        return res;
    }

    long ans;

    foreach (int k ; 0 .. n.to!int + 1) {
        if (k & 1) {
            ans -= cmb[n][k] * f(k) % m;
            if (ans < 0) ans += m;
        }
        else {
            ans += cmb[n][k] * f(k) % m;
            if (ans >= m) ans -= m;
        }
    }

    writeln(ans);
}



// x^y % mod
long powmod(long x, long y, long mod) {
    return y > 0 ? powmod(x, y>>1, mod)^^2 % mod * x^^(y&1) % mod : 1L;
}



void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 288636
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define endl '\n'
#define pii pair<ll, ll>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define traceloop(x,a) {for(ll i=0;i<x;i++) cerr<<a[i]<<" "; cerr<<endl;}
ll ab(ll x) {return x>0LL?x:-x;}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	ll a,b;
	cin>>a>>b;
	cout<<max(0LL,a-2*b);
	return 0;
}
	

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int ans = 0;
    for(int i = 0;i < n;i++)
    {
        int l,r;
        cin >> l >> r;
        ans += (r - l) + 1;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256