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

typedef long long int ll;
typedef long double ld;
const ll mx=1e9+7;
#define pb push_back

#define all(n) n.begin(),n.end()

void solve()
{
	int n;
	cin>>n;
	int cnt=0;
	for(int i=1;i<n;i++)
	{
	cnt+=(n-1)/i ;
	}
	
	cout<<cnt;
	
}

int main()
{
	
solve();
		
	
	
}

Measured memory_bytes: 3588
#include<stdio.h>
int main(){
	int S,h,m,s;
	scanf("%d",&S);
	h=S/3600;
	S=S-3600*h;
	m=S/60;
	s=S-60*m;
	printf("%d:%d:%d\n",h,m,s);
	return 0;
}

Measured memory_bytes: 592
#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;

ll dp[200][1200];
int main() {
  int n;
  ll w;
  cin >> n >> w;
  vl W(n), V(n);
  rep(i, n) { cin >> W[i] >> V[i]; }
  if (W[0] > w) {
    print(0);
    return 0;
  }
  vector<vl> items(4);
  rep(i, n) {
    int k = W[i] - W[0];
    items[k].push_back(V[i]);
  }
  rep(k,4)items[k].push_back(0);
  ll ans = 0;
  rep(k, 4) sort(rng(items[k]), greater<ll>());
  rep(i, sz(items[0])) {
    rep(j, sz(items[1])) {
      rep(k, sz(items[2])) {
        rep(l, sz(items[3])) {
          ll smV = 0,smW=0,cnt=0;
          rep(m,i){
            smV+=items[0][m];
            if(items[0][m]){
              cnt++;
            }
          }
          rep(m,j){
            smV+=items[1][m];
            if(items[1][m]){
              cnt++;
              smW++;
            }
          }
          rep(m,k){
            smV+=items[2][m];
            if(items[2][m]){
              cnt++;
              smW+=2;
            }
          }
          rep(m,l){
            smV+=items[3][m];
            if(items[3][m]){
              cnt++;
              smW+=3;
            }
          }
          smW += cnt*W[0];
          if(smW>w)continue;
          maxs(ans,smV);
        }
      }
    }
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 256
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <cmath>

auto & in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int32_t N;

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> N;
	out << (N - 2) * 180 << endl;

	return 0;
}
#endif


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

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n, k;
    vector<int> x;
    cin >> n >> k;
    for(int i = 0, tmp; i < n; ++i) {
        cin >> tmp;
        x.push_back(tmp);
    }
    int p = lower_bound(x.begin(), x.end(), 0) - x.begin(); // first non neg
    int ans = INT_MAX;
    for(int i = 0; i <= k; ++i) {
        int j = k - i;
        int l = p - i;
        int r = p + j - 1;
        if(l < 0 || r >= n) continue;
        int mn = min(abs(x[l]), abs(x[r]));
        int mx = max(abs(x[l]), abs(x[r]));
        ans = min(ans, 2 * mn + mx);
    }
    if(p + k - 1 < n) ans = min(ans, abs(x[p + k - 1]));
    if(p - k >= 0) ans = min(ans, abs(x[p - k]));

    cout << ans << endl;
}

Measured memory_bytes: 892
n = int(input())
p = [int(x) for x in input().split()]
ans = 0
for i in range(n-1):
    if p[i] == i + 1:
        ans += 1
        p[i], p[i+1] = p[i+1], p[i]
if p[-1] == n: ans += 1
print(ans)

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

int main() {
    int r, c;
    cin >> r >> c;
    int array[r + 1][c + 1] = {0};
    int sum = 0;
    int i, j;
    for(i = 0; i < r; i++){
        for(j = 0; j < c; j++){
            cin >> array[i][j];
            sum += array[i][j];
        }
        array[i][c] = sum;
        sum = 0;
    }

    for(j = 0; j <= c; j++){
        for(i = 0; i <= r; i++){
            sum += array[i][j];
        }
        array[r][j] = sum;
        sum = 0;
    }
    
    for(i = 0; i <= r; i++){
        for(j = 0; j <= c; j++){
            if(j == c){
                cout << array[i][j] << endl;
            }else{
                cout << array[i][j] << " ";
            }
        }
    }
	return 0;
}



Measured memory_bytes: 3116
package main

import (
	"fmt"
	"io"
	"os"
)

func answer(reader io.Reader, writer io.Writer) {
	var h, w, n, x, y int
	_, _ = fmt.Fscan(reader, &h)
	_, _ = fmt.Fscan(reader, &w)
	_, _ = fmt.Fscan(reader, &n)
	_, _ = fmt.Fscan(reader, &y)
	_, _ = fmt.Fscan(reader, &x)
	var s, t string
	_, _ = fmt.Fscan(reader, &s)
	_, _ = fmt.Fscan(reader, &t)

	xA := x
	xB := x
	yA := y
	yB := y
	f := true
	//fmt.Printf("x:%v, y:%v, w:%v, h:%v\n", x, y, w, h)

	for i := 0; i < n; i++ {
		if string(s[i]) == "L" {
			xA--
		}
		if string(s[i]) == "R" {
			xB++
		}
		if string(s[i]) == "U" {
			yA--
		}
		if string(s[i]) == "D" {
			yB++
		}
		if xA <= 0 || w < xB || yA <= 0 || h < yB {
			f = false
			break
		}
		if string(t[i]) == "R" && xA < w {
			xA++
		}
		if string(t[i]) == "L" && 1 < xB {
			xB--
		}
		if string(t[i]) == "D" && yA < h {
			yA++
		}
		if string(t[i]) == "U" && 1 < yB {
			yB--
		}
		//fmt.Printf("s:%v, t:%v, xA:%v, xB:%v, yA:%v, yB:%v\n", string(s[i]), string(t[i]), xA, xB, yA, yB)
		if xA <= 0 || w < xB || yA <= 0 || h < yB {
			f = false
			break
		}
	}

	if f == true {
		_, _ = fmt.Fprintf(writer, "YES")
	} else {
		_, _ = fmt.Fprintf(writer, "NO")
	}
}

func main() {
	answer(os.Stdin, os.Stdout)
}


Measured memory_bytes: 3200
#include<iostream>
using namespace std;
typedef long long int ll;
const ll mod = 998244353; // prime 
ll n, m, k, c[200005]; 

ll quickpower(ll x, ll y, ll z) {//pow(x,y)%z
	ll ans = 1, base = x;
	while (y) {
		if (y & 1) 	ans = base * ans % mod;
		base = base * base % mod;
		y >>= 1;
	}
	return ans;
}
int main()
{
	cin >> n >> m >> k;
	c[0] = 1;ll ans = 0;
	for(int i = 1; i < n; ++i) {
		c[i] = c[i - 1] * (n - i) % mod * quickpower(i, mod - 2, mod) % mod;
	}
	for (int i = 0; i <= k; ++i) {
		ans = (ans + m * (quickpower(m - 1, n - i - 1, mod)) % mod * c[n - i - 1] % mod) % mod;
	}
	cout << ans << endl;
}

Measured memory_bytes: 5184
package main

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

func main() {
	rd := bufio.NewReader(os.Stdin)
	for {
		s, err := rd.ReadString('\n')
		if err == io.EOF {
			return
		}
		arr := strings.Split(strings.TrimSpace(s), " ")
		a, _ := strconv.Atoi(arr[0])
		b, _ := strconv.Atoi(arr[1])
		for i := 0; i < a; i++ {
			for j := 0; j < b; j++ {
				switch {
				case i%2 == 0 && j%2 == 1:
					fmt.Print(".")
				case i%2 == 1 && j%2 == 0:
					fmt.Print(".")
				default:
					fmt.Print("#")
				}
			}
			fmt.Println()
		}
		if a == 0 && b == 0 {
			return
		}
		fmt.Println()
	}
}



Measured memory_bytes: 1100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(v) v.begin(), v.end()

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  
  int max = 0;
  int sum = 0;
  rep(i, 0, n) {
    int l;
    cin >> l;
    sum += l;
    if(l > max)
      max = l;
  }
  sum -= max;
    
  cout << (sum > max ?"Yes" :"No"s) << "\n";

}


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

int main(){
    int n,a;
    cin>>n>>a;
    vector<int> x(n), y(n);
    ll sum=0;
    rep(i,n){
        cin>>x[i];
        y[i]=x[i]-a;
        sum+=x[i];
    }
//    vector<vector<vector<ll>>> dp(n+1, vector<vector<ll>>(n+1, vector<ll>(sum+1)));
    vector<vector<ll>> dp(n+1, vector<ll>(2*sum+1));
    dp[0][sum]=1;
    for(int j=1;j<=n;j++){
        for(int t=0;t<=2*sum;t++){
            if(t-y[j-1]>=0 && t-y[j-1]<=2*sum) dp[j][t]=dp[j-1][t]+dp[j-1][t-y[j-1]];
            else dp[j][t]=dp[j-1][t];
        }
    }
    cout<<dp[n][sum]-1<<endl;
    return 0;
}

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

int main() {
  int64_t n,a,b;
  cin>>n>>a>>b;
  if(n%(a+b)<=a){cout<<(n-(n/(a+b))*b)<<endl;}
  if(n%(a+b)>a){cout<<(((n/(a+b))+1)*a)<<endl;}
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

#define N 20
#define Q 200

int A[N], M[Q];

int is(int n, int m) {
    if (m == 0) return 1;
    if (n > N - 1) return 0;
    return is(n + 1, m) || is(n + 1, m - A[n]);
}


int main(void){
    int n, q, i;
    
    scanf("%d", &n);
    
    for (i = 0; i < n; i++) {
        scanf("%d", &A[i]);
    }
    
    scanf("%d", &q);
    
    for (i = 0; i < q; i++) {
        scanf("%d", &M[i]);
    }
    
    for (i = 0; i < q; i++) {
        if (is(0, M[i])) {
            printf("yes\n");
        } else {
            printf("no\n");
        }
    }
    
    return 0;
}


Measured memory_bytes: 2688
function main(arg) {
    let [N,D] = arg.split("\n")[0].split(" ").map(Number)
    let p = arg.split("\n")
    p.shift()
    let x = p.map(x=>Number(x.split(" ")[0]))
    let y = p.map(y=>Number(y.split(" ")[1]))
    
    let counter=0
    for(let i=0; i<N; i++) {
        if(D**2 >= x[i]**2+y[i]**2) {
            counter++
        }
    }
    
    console.log(counter)
    
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 93768
#include <bits/stdc++.h>
using namespace std;
int main() {
    long long N, M;
    cin >> N >> M;
    if(N==1 && M==1) cout << 1 << endl;
    else if(M==1) cout << N-2 << endl;
    else if(N==1) cout << M-2 << endl;
    else if(N==2||M==2) cout << 0 << endl;
    if(N>=3&&M>=3) cout << N*M-(N+N+M+M-4) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
const ll INF=(ll)1e18+10;

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() {
    int N; string S;
    cin>>N>>S;

    if(N%2==1){
        cout<<"No"<<endl;
        return 0;
    }

    if(S.substr(0,N/2)==S.substr(N/2,N/2)){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }


    return 0;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <random>
#include <iterator>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(v) reverse((v).begin(),(v).end())
#define ANS(ans) cout<<(ans)<<endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  for (int i = 0; i < (n); ++i)


int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	int i = 0;
	int l = 0, r = 0;
	string rr, ll;
	while (i < s.length()) {
		if (s[i] == '(') {
			l++;
		}
		else {
			r++;
		}

		if (r > l) {
			ll += '(';
			l++;
		}
		i++;
	}
	if (l != r) {
		REP(i, l - r) {
			rr += ')';
		}
	}
	ANS(ll + s + rr);


	return 0;
}


Measured memory_bytes: 256
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main() {
    ll n;
    string a,b,c;
    std::cin >> n;
    std::cin >> a;
    std::cin >> b;
    std::cin >> c;
    ll result = 0;
    for (int i = 0; i < n; i++) {
        if(a[i] == b[i] && b[i] == c[i]){
            continue;
        }else if(a[i] == b[i] && b[i] != c[i]){
            result++;
        }else if(b[i] == c[i] && c[i] != a[i]){
            result++;
        }else if(c[i] == a[i] && a[i] != b[i]){
            result++;
        }else{
            result+=2;
        }
    }
    std::cout << result << std::endl;
    
}

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

using namespace std;

int N, dp[1000];
const int mod = 1e9 + 7;
char sir[3][1000];

int add (int x, int y) {int ans = x + y; if (ans >= mod) ans -= mod; return ans;}
int subtract (int x, int y) {if (x >= y) return x - y; return x - y + mod;}
int mul (int x, int y) {return 1LL * x * y % mod;}
void adto (int &x, int y) {x += y; if (x >= mod) x -= mod;}

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

scanf ("%d\n", &N);
scanf ("%s", sir[1] + 1);
scanf ("%s", sir[2] + 1);
dp[0] = 1;
for (int i=1; i<=N; i++)
{
    if (sir[1][i] == sir[1][i - 1])
    {
        if (i == 2) dp[i] = 6;
        else
        if (i > 3 && sir[1][i - 2] == sir[1][i - 3]) dp[i] = mul (dp[i - 2], 3);
        else dp[i] = mul (dp[i - 2], 2);
    }
    else
    if (sir[1][i] == sir[1][i + 1]) ;
    else
    {
        if (i > 2 && sir[1][i - 1] == sir[1][i - 2])
            dp[i] = dp[i - 1];
        else
        {
            if (i == 1) dp[i] = 3;
            else dp[i] = mul (dp[i - 1], 2);
        }
    }
}
printf ("%d\n", dp[N]);
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <numeric>
#include <limits>
#include <numeric>
#include <type_traits>
using namespace std;
typedef pair<int, int> P;

typedef long long ll;
const int MOD = 1000000007;

int main(){  
  int N,A[100000],num;
  ll sum = 0, sum2 = 0;
  cin >> N;
  cin >> num;
  sum += num;
  A[0] = num;
  for(int i=1;i<N;i++){
    cin >> num;
    sum += num;
    A[i] = num - A[i-1];
  }
  for(int i=0;i<N;i++){
    sum2 += A[i];
  }
  int a = sum2*2 - sum;
  cout << a << " ";
  for(int i=0;i<N-1;i++){
    if(i%2==0) cout << A[i]*2-a << " ";
    else cout << A[i]*2+a << " ";
  }
}



Measured memory_bytes: 1664
#pragma region header
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#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 rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr int inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------テンプレート------------------ */
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;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a / gcd(a, b) * b ;
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
bool isprime(int n) { //素数判定
    if(n==1)return false;
    if(n==2)return true;
    for(int i = 2;i<=sqrt(n);i++) {
        if(n%i==0) return false;
    }
    return true;
}
/* ----------------------end----------------------- */
#pragma endregion
vi prime_fact (int k) {
    vi v;
    for(int i = 2;i<=sqrt(k);i++) {
        if(k%i==0) {
            while(k%i==0) k/=i;
            v.pb(i);
        }
    }
    if(k!=1) v.pb(k);
    return v;
}
signed main() {
    int g;
    {
        int a,b;cin >> a >> b;
        g=gcd(a,b);
    }
    cout << prime_fact(g).size()+1 << endl;
    return 0;
}

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

#define FOR(i,a,b) for(int (i)=(a);i<(int)(b);i++)
#define rep(i,n) FOR(i,0,n)
#define mset(a,x) memset(a,x,sizeof(a))

struct Circle {
    int x, y, r;
};
Circle read() {
    int x, y, r;
    scanf("%d%d%d", &x, &y, &r);
    return Circle{x, y, r};
}
const double INF = 1145141919810893;
int n;

// O(n^2)
using Dist = double;
Dist cost[1010][1010];
vector<Dist> dijkstra(int s) {
    vector<Dist> d(n, INF); d[s] = 0;
    vector<int> used(n, 0);
    while (1) {
        int v = -1;
        rep(to, n) if (!used[to] && (v == -1 || d[to] < d[v])) v = to;
        if (v == -1) break;
        used[v] = 1;
        rep(to, n) {
            Dist nd = d[v] + cost[v][to];
            d[to] = (nd < d[to] ? nd : d[to]);
        }
    }
    return d;
}

int main() {
    vector<Circle> cs;
    rep(i, 1010) rep(j, 1010) cost[i][j] = INF;
    rep(i, 2) {
        int x, y; cin >> x >> y;
        cs.push_back(Circle{x,y,0});
    }
    cin >> n;
    rep(i, n) cs.push_back(read());
    rep(i, n + 2) rep(j, n + 2) {
        double d = hypot(cs[i].x - cs[j].x, cs[i].y - cs[j].y) - cs[i].r - cs[j].r;
        if (d < 0) d = 0.;
        cost[i][j] = d;
    }
    n += 2;
    auto d = dijkstra(0);
    printf("%.10f\n", d[1]);
    return 0;
}


Measured memory_bytes: 8192
#include <iostream>
#include <queue>
#include <map>
#include <string>
using namespace std;

typedef pair<int,int> P;
int H,W;
int x[4]={0,1,0,-1};
int y[4]={1,0,-1,0};
string F[50];
bool f;

bool check(int a,int b){
    for(int i=0;i<4;i++){
        int nx = a+x[i];
        int ny = b+y[i];
        if(nx>=0&&nx<W&&ny>=0&&ny<H&&F[ny][nx]=='#'){
            return true;
        }
    }
    return false;
}
int main(){
  cin>>H>>W;
  for(int i=0;i<H;i++){
      cin>>F[i];
  }

  for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
          if(F[i][j]=='#'){
             f = check(j,i);
             if(!f) {cout<<"No"<<"\n"; return 0;}
          }
      }
  }
  cout<<"Yes"<<"\n";
  return 0;
}


Measured memory_bytes: 256
#include<iostream>

#define S 16

int run(){
	char s[3][S];
	char out[4];
	std::cin >> s[0] >> s[1] >> s[2];
	for( int i = 0; i < 3; i++ ){
		out[i] = s[i][0] + 'A' - 'a';
	}
	out[3] = '\0';
	std::cout << out << std::endl;
	return 0;
}

int main(){
	run();
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
n=int(input())
mod=10**9+7
l=[[]for i in range(n+1)]
for i in range(n-1):
    a,b=map(int,input().split())
    l[a].append(b)
    l[b].append(a)
def dp(x,par):
    res_w,res_t=1,1
    for y in l[x]:
        if y==par:
            continue
        w,t=dp(y,x)
        res_w=(res_w*w)%mod
        res_t=(res_t*t)%mod
    w,t=res_t,(res_t+res_w)%mod
    return w,t
print(dp(1,0)[1])

Measured memory_bytes: 99736
#include <stdio.h>

int main(void)
{

 int i,n,money=100000;

 scanf("%d",&n);
 for(i=0;i<n;i++)
   {
     money=money*1.05;
     if(money%1000!=0)
       {
         money=((money/1000)+1)*1000;
       }
   }

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

 return 0;
}

Measured memory_bytes: 592
l,r = map(int,input().split())

if l//2019 != r//2019:
    print(0)
elif l%2019 == 0 or r%2019 == 0:
    print(0)
else:
    ans = 10**19
    for i in range(l,r+1):
        for j in range(i+1,r+1):
            if (i*j)%2019 < ans:
                ans = (i*j)%2019
    print(ans)

Measured memory_bytes: 40556
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
a = []
for i in range(n):
    a.append(list(map(int, input().split())))
    
count=0
for j in range(n):
  ans=0
  for i in range(m):
    ans+=a[j][i]*b[i]
  if ans>-c:
    count+=1
  else:
    count+=0
print(count)

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
 
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}

int main()
{
  int N;
  int number;
  char s[1]={};
  int  ans[3]={};
  int i;
//    int k=0;
for(i=0;i<3;i++){
  scanf("%c", s);
//  printf("%s\n",s);
//  scanf("%lld %lld",  &D, &X);
  if('a'==s[0]) ans[0]=1;
  else if('b'==s[0]) ans[1]=1;
  else if('c'==s[0]) ans[2]=1;
//printf("%d%d%d\n",ans[0],ans[1],ans[2]);
}
  if(ans[0]&&ans[1]&&ans[2])  printf("Yes\n");  
  else printf("No\n"); 
return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int N;
    cin >> N;
    
    vector<int> vec(N);
    int sum=0;
    for(int n=0; n<N; n++) {
        cin >> vec[n];
        sum += vec[n];
    }
    
    sort(vec.begin(), vec.end());
    if(sum%10!=0) {
        cout << sum << endl;
    } else {
        bool flag=false;
        for(int n=0; n<N; n++) {
            if(vec[n]%10!=0) {
                sum -= vec[n];
                flag=true;
                break;
            }
        }
        if(flag) {
            cout << sum << endl;
        } else {
            cout << 0 << endl;
        }
    }


    return 0;
    
}

Measured memory_bytes: 256
import math
import bisect
import sys
input = sys.stdin.readline

N,D,A=map(int,input().split())  

XH=[[0,0] for _ in range(N)]
for i in range(N):
    x,h=map(int,input().split())
    XH[i][0]=x
    XH[i][1]=h
    
XH.sort()

X=[0]*N
for i in range(N):
    X[i]=XH[i][0]



ans=0
S=[0]*(N+1)#累積和


for i in range(N):
    if S[i]<XH[i][1]:
        bom=X[i]+D
        Lb=i
        Rb=bisect.bisect_right(X,bom+D)
        num=(XH[i][1]-S[i])//A
        if (XH[i][1]-S[i])%A!=0:
            num+=1
        ans+=num
        dam=num*A
        #imosで遅延
        S[Lb]+=dam
        S[Rb]-=dam
    S[i+1]+=S[i]
        
print(ans)

Measured memory_bytes: 67188
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
using namespace std;

typedef long long ll;
typedef double db;
typedef long double ldb;

template<class T> inline void checkmin(T &a,const T &b){if(b<a) a=b;}
template<class T> inline void checkmax(T &a,const T &b){if(b>a) a=b;}

const int inf=1e9+10;
const int maxn=2e5+10;

int a[maxn],b[maxn],difa[maxn],difb[maxn];
int n;
vector <int> sa,sb,s;

vector <int> build_zfunction(vector <int> &s){
	vector <int> z(s.size(),0);
	z[0]=(int)s.size();
	int j=1;
	for(int i=1;i<(int)s.size();i++){
		int u=max(0,min(j+z[j]-i,z[i-j]));
		while(s[u]==s[i+u]) u++;
		z[i]=u;
		if(i+z[i]>=j+z[j]) j=i;
	}
	return z;
}

int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++) scanf("%d",&a[i]);
	for(int i=0;i<n;i++) scanf("%d",&b[i]);
	for(int i=0;i<n;i++) difa[i]=a[(i+1)%n]^a[i];
	for(int i=0;i<n;i++) difb[i]=b[(i+1)%n]^b[i];
	for(int i=0;i<n;i++){
		sa.pb(difa[i]);
		sb.pb(difb[i]);
	}
	for(int i=0;i<sb.size();i++) s.pb(sb[i]);
	s.pb(inf);
	for(int i=0;i<sa.size();i++) s.pb(sa[i]);
	for(int i=0;i<sa.size();i++) s.pb(sa[i]);
	vector<int> z=build_zfunction(s),ans;
	int k=0;
	for(int i=(int)sb.size()+1;i<z.size();i++,k++){
		if(k>=n) break;
		if(z[i]==n){
			ans.pb(k);
		}
	}
	for(int i=0;i<ans.size();i++){
		int k=ans[i],x=a[i]^b[(i-k+n)%n];
		printf("%d %d\n",k,x);
	}
	return 0;
}


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

int main(){
    int n,x;
    int result = 0;

    
    while(1){
        cin >> n >> x;
        if((n == 0)&&(x == 0)){
            return(0);
        }
        for (int i = 1; i <= n; i++)
        {
            for (int j = i+1; j <= n; j++)
            {
                for (int k = j+1; k <= n; k++){
                    if(i+j+k > x){
                        continue;
                    }
                    //cout << i << " ";
                    //cout << j << " ";
                    //cout << k << " ";
                    
                    if((i+j+k) == x){
                        //cout << "+";
                        result++;
                    }
                    //cout << endl;
                }   
            }
        }        
        cout << result << endl;
        result = 0;
    }

    



    return(0);
}


Measured memory_bytes: 3096
#include <stdio.h>

int card[4][14];

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    char ch;
    int num;
    scanf("%c", &ch);
    scanf("%c %d", &ch, &num);
    if (ch == 'S') card[0][num]++; 
    else if (ch == 'H') card[1][num]++;
    else if (ch == 'C') card[2][num]++;
    else card[3][num]++;
  }
  for (int i = 0; i < 4; i++) {
    for (int j = 1; j <= 13; j++) {
      if (!card[i][j]) {
        if (i == 0) {
          printf("S %d\n", j);
        } else if (i == 1) {
          printf("H %d\n", j);
        } else if (i == 2) {
          printf("C %d\n", j);
        } else {
          printf("D %d\n", j);
        }
      }
    }
  }
  return 0;
}



Measured memory_bytes: 2140
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
#define sz(a) int(a.size())

int gi() {
	int x=0,o=1;char ch=getchar();
	while(!isdigit(ch)&&ch!='-') ch=getchar();
	if(ch=='-') o=-1,ch=getchar();
	while(isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	return x*o;
}

int n,mx,p,fa[N],st[N],tp=0,cnt[N];
bool vis[N];
vector<int> E[N],ans;

void dfs(int u,int ff,int dis) {
	fa[u]=ff;
	if(dis>mx) mx=dis,p=u;
	for(auto v:E[u]) if(v!=ff) dfs(v,u,dis+1);
}

vector<int> rev(const vector<int> &a) {
	vector<int> ret(n);
	for(int i=0;i<n;i++) ret[a[i]]=i;
	return ret;
}

bool cmp(const vector<int> &a,const vector<int> &b) {
	for(int i=0;i<n;i++) if(a[i]!=b[i]) return a[i]<b[i];
	return 0;
}

void dfs2(int u,int ff,int dep) {
	++cnt[dep];
	for(auto v:E[u]) if(v^ff) dfs2(v,u,dep+1);
}

void work(int rt) {
	memset(cnt,0,sizeof(cnt));
	dfs2(rt,0,0);
	int s=0,fl=1;vector<int> now;
	for(int i=1;fl;i++) {
		if(!cnt[i]) ++cnt[i],fl=0;
		s+=cnt[i];now.push_back(s-1);
		for(int j=cnt[i];j>1;j--) now.push_back(s-j);
	}
	now=rev(now);
	if(ans.empty()||cmp(now,ans)) ans=now;
}

int main() {
	cin>>n;
	for(int i=1,u,v;i<n;i++) u=gi(),v=gi(),E[u].push_back(v),E[v].push_back(u);
	dfs(1,0,0);mx=0;dfs(p,0,0);
	for(int i=p;i;i=fa[i]) vis[st[++tp]=i]=1;
	for(int i=1;i<=tp;i++)
		for(auto j:E[st[i]])
			if(!vis[j]&&sz(E[j])!=1) return cout<<-1,0;
	work(st[1]);work(st[2]);
	work(st[tp-1]);work(st[tp]);
	for(auto j:E[st[2]])
		if(!vis[j]) { work(j);break; }
	for(auto j:E[st[tp-1]])
		if(!vis[j]) { work(j);break; }
	for(auto x:ans) cout<<x+1<<' ';
	return 0;
}


Measured memory_bytes: 13020
package main

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

func main() {

	for {
		n := ScanedLinetoIntSlice()
		//H, W
		H := n[0]
		W := n[1]

		//var H, W int

		//fmt.Scanln(&H, &W)

		if H == 0 && W == 0 {
			break
		}
		for i := 0; i < H; i++ {
			for j := 0; j < W; j++ {
				if (i+j)%2 == 0 {
					fmt.Printf("#")
				} else {
					fmt.Printf(".")
				}
			}
			fmt.Printf("\n")
		}
		fmt.Printf("\n")
	}

}

func ScanedLinetoIntSlice() []int {

	//var sc = bufio.NewScanner(os.Stdin)
	//sc.Scan()
	line := readLine()

	words := strings.Fields(line)

	var numbers []int

	for _, v := range words {
		number, _ := strconv.Atoi(v)
		numbers = append(numbers, number)
	}

	return numbers
}

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

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



Measured memory_bytes: 5600
// Given is an integer N. Find the number of digits that N has in base K.

#include<bits/stdc++.h>

using namespace std;

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

	int count= 0;
	while(n!=0){	
		n = n/k;
		count++;
	}
	cout<<count;


}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <cassert>
#include <queue>
#include <ctime>
#include <string>
#include <cstring>
#define mp make_pair
#define pb push_back
#define NAME ""
#define y1 y1_423
#define list lista

using namespace std;

typedef long long ll;
typedef long double ld;

template<typename T>
ostream& operator << (ostream& cout, const vector<T> &a) {
	if ((int)a.size() == 0) {
		return (cout << "()");
	}
	cout << "(" << a[0];
	for (int i = 1; i < (int)a.size(); i++) {
		cout << "; " << a[i];
	}
	return (cout << ")");
}

template<typename T>
ostream& operator << (ostream& cout, const set<T> &a) {
	if ((int)a.size() == 0) {
		return (cout << "{}");
	}
	auto it = a.begin();
	cout << "{" << *it;
	++it;
	for (; it != a.end(); ++it) {
		cout << "; " << *it;
	}
	return (cout << "}");
}

template<typename T>
ostream& operator << (ostream& cout, const multiset<T> &a) {
	if ((int)a.size() == 0) {
		return (cout << "{}");
	}
	auto it = a.begin();
	cout << "{" << *it;
	++it;
	for (; it != a.end(); ++it) {
		cout << "; " << *it;
	}
	return (cout << "}");
}

template<typename T1, typename T2>
ostream& operator << (ostream& cout, const pair<T1, T2> &a) {
	return cout << "(" << a.first << "; " << a.second << ")";
}

const int nmax = 2000 * 1000;
const int inf = 2000 * 1000 * 1000;
const ll infl = 1000ll * 1000ll * 1000ll * 1000ll * 1000ll * 1000ll;
const int mod = 1000 * 1000 * 1000 + 7;
const ld pi = acos(-1.0);

int main() {
	//freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
	//freopen(NAME".in", "r", stdin);freopen(NAME".out", "w", stdout);
	char c;
	scanf(" %c", &c);
	if (c == 'a' || c == 'o' || c == 'i' || c == 'u' || c == 'e') {
		cout << "vowel";
	} else {
		cout << "consonant";
	}
	return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)
#define Yes(condition) if(condition) cout << "Yes" << '\n'; else{ cout << "No" << '\n'; }
#define YES(condition) if(condition) cout << "YES" << '\n'; else{ cout << "NO" << '\n'; }
#define yes(condition) if(condition) cout << "yes" << '\n'; else{ cout << "no" << '\n'; }




int main() {
    ll n;
    cin >> n;
    set<ll> wheson;
    REP(i, n){
        ll d;
        cin >> d;
        wheson.insert(d);
    }
    cout << wheson.size() << endl;
}


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

int main(){
  string s;
  cin >> s;
  if (s.at(0) == s.at(1) || s.at(1) == s.at(2) || s.at(2) == s.at(0)){
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 256
// StringEquivalance
// Problem link : 
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <set>
#include <unordered_map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <deque>
#include <bitset>
using namespace std;

#define ll long long int
#define F(a,n) for(int i=0;i<n;i++){cin>>a[i];}
#define F1(a,n) for(int i=1;i<=n;i++){cin>>a[i];}
#define P(a,n) for(int i=0;i<n;i++){cout<<a[i]<<' ';}cout<<endl;
#define P1(a,n) for(int i=1;i<=n;i++){cout<<a[i]<<' ';}cout<<endl;
#define NF(a,n,m) for(int i=0;i<n;i++){for(int j=0;j<m;j++){cin>>a[i][j];}}
#define NF1(a,n,m) for(int i=1;i<=n;i++){for(int j=1;j<=m;j++){cin>>a[i][j];}}
#define PNF(a,n,m) for(int i=0;i<n;i++){for(int j=0;j<m;j++){cout<<a[i][j]<<' ';}cout<<endl;}cout<<endl;
#define PNF1(a,n,m) for(int i=1;i<=n;i++){for(int j=1;j<=m;j++){cout<<a[i][j]<<' ';}cout<<endl;}cout<<endl;
#define AS 200001
int N;

void StringEquivalance(char *a,int i,char c){
	// base case
	if(i == N){
		a[i] = '\0';
		cout<<a<<endl;
		return;
	}

	// Recursive case
	for(char ch = 'a';ch<=c;ch++){
		a[i] = ch;
		if(ch == c){
			StringEquivalance(a,i+1,c+1);
		}
		else{
			StringEquivalance(a,i+1,c);
		}
	}
}


int main(){
	cin>>N;
	char a[100];
	StringEquivalance(a,0,'a');


	return 0;
}

Measured memory_bytes: 1536
import sys
sys.setrecursionlimit(100000)

def intinput(): return map(int,sys.stdin.readline().split())


n=int(input())
p=[]
for _ in range(n):
    p.append(tuple(intinput()))
s={}
for x,y in p:
    for x1,y1 in p:
        if x==x1 and y==y1:
            continue
        if (x-x1,y-y1) in s:
            s[(x-x1,y-y1)]+=1
        else:
            s[(x-x1,y-y1)]=1
if n==1:
    print(1)
else:
    print(n-max(s.values()))

Measured memory_bytes: 39536
from collections import defaultdict
import math

N = int(input())
li = [input() for i in range(N)]
d = defaultdict(int)

def combinations_count(n, r):
  return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

count = 0

for i in li:
  s = sorted(list(i))
  t = "".join(s)

  d[t] += 1

for i in d:
  if d[i] > 1:
    count += combinations_count(d[i], 2)
    
print(count)

Measured memory_bytes: 25328
#include <stdio.h>

int main(void) {
	int a,i,j;
	int b,f,r,v,n;
	
	int house[4][3][10];
	
	scanf("%d",&n);


	for(i=0;i<4;i++){
		for(j=0;j<3;j++){
			for(a=0;a<10;a++){
				house[i][j][a] = 0;

			}
		}
	}

	
	for(i = 0;i < n; i++){
		
		scanf("%d",&b);
	 
		scanf("%d",&f);
		
		scanf("%d",&r);	
		
		scanf("%d",&v);
		
		house[b-1][f-1][r-1] += v;
		
		
		
	}
	for(i=0;i<4;i++){
		for(j=0;j<3;j++){
			for(a=0;a<10;a++){
			
				printf(" %d",house[i][j][a]);
				
			}

				printf("\n");

		}
		if(i != 3)
			printf("####################\n");	
	
	}
	
	return 0;
}

Measured memory_bytes: 612
#[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)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $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 {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_imports)]
use std::io::Write;

fn main() {
    input!{
      n: usize,
      c: usize,
      k: usize,
      mut ts: [usize; n],
    }
    ts.sort();

    let mut next = ts[0] + k;
    let mut ans = 0;
    let mut num = 0;
    for cur in 0..n {
        if ts[cur] > next {
            ans += 1;
            next = ts[cur] + k;
            num = 1;
        } else {
            num += 1;
            if num == c {
                ans += 1;
                num = 0;
                if cur+1 < n {
                    next = ts[cur+1] + k;
                }
            }
        }
    }
    if num > 0 {
        ans += 1;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
fun main(args: Array<String>) {
  var x = readLine()!!.toLong()
  var count = x / 11 * 2
  val amari = x % 11

  if (amari == 0L) {
    // do nothing
  } else if (amari <= 6) {
    count += 1
  } else if (amari <= 11) {
    count += 2
  }
  println(count)
}

Measured memory_bytes: 31688
import sys
sys.setrecursionlimit(10**8)
input = sys.stdin.readline

def solve():
    N = int(input())
    AB = [tuple(map(int,input().split())) for i in range(N-1)]
    es = [[] for i in range(N)]
    for i,(a,b) in enumerate(AB):
        a,b = a-1,b-1
        es[a].append((b,i))
        es[b].append((a,i))
    MOD = 10**9+7

    size = [-1] * N
    def calc_size(v,p=-1):
        ret = 1
        for to,_ in es[v]:
            if to==p: continue
            ret += calc_size(to,v)
        size[v] = ret
        return ret
    calc_size(0)

    MAXN = N+5
    fac = [1,1] + [0]*MAXN
    finv = [1,1] + [0]*MAXN
    inv = [0,1] + [0]*MAXN
    for i in range(2,MAXN+2):
        fac[i] = fac[i-1] * i % MOD
        inv[i] = -inv[MOD%i] * (MOD // i) % MOD
        finv[i] = finv[i-1] * inv[i] % MOD

    dpdn = [0] * (N-1)
    dn = set()
    def dfs(v,p=-1):
        ret = fac[size[v]-1]
        for to,i in es[v]:
            if to==p: continue
            dn.add((v,to))
            dpdn[i] = dfs(to,v)
            ret *= finv[size[to]] * dpdn[i]
        ret %= MOD
        return ret
    dfs(0)

    dpup = [0] * (N-1)
    from collections import deque
    q = deque([(0,-1)])
    while q:
        v,p = q.popleft()
        whole = 1
        for to,i in es[v]:
            if to != p:
                whole *= finv[size[to]] * dpdn[i]
            else:
                whole *= finv[N-size[v]] * dpup[i]
        whole %= MOD
        for to,i in es[v]:
            if to==p: continue
            dpup[i] = (whole * fac[N-size[to]-1] * fac[size[to]] * pow(dpdn[i], MOD-2, MOD)) % MOD
            q.append((to,v))

    ans = []
    for v in range(N):
        a = 1
        s = 0
        for to,i in es[v]:
            if (v,to) in dn:
                s += size[to]
                a *= finv[size[to]] * dpdn[i]
            else:
                s += N-size[v]
                a *= finv[N-size[v]] * dpup[i]
            a %= MOD
        a *= fac[s]
        ans.append(a%MOD)
    print(*ans, sep='\n')

solve()

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

int main()
{
	int n,m;
	cin >> n >> m;
	int a,ans = n;
	for (int i = 0; i < m; i++) {
		cin >> a;
		ans -= a;
	}
	if (ans < 0) {
		cout << -1;
	}
	else {
		cout << ans;
	}
}

Measured memory_bytes: 3632
import java.util.Scanner;
public class Main {

    public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
    	// 入力
    	int k = sc.nextInt();
    	int s = sc.nextInt();

    	int cnt = 0;

    	for (int x = 0; x <= k; x++){
        	for (int y = 0; y <= k; y++){
        		if((s - (x + y)) >= 0 && (s - (x + y)) <= k){
            		cnt++;
            	}
        	}
    	}

    	// 出力
    	System.out.println(cnt);
    }
}

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

int main(){
	double a, s[10], sum;
	
	
	while(scanf("%lf", &a) != EOF){
		sum = s[0] = a;
		for(int i = 1; i < 10; i++){
			if(i % 2 != 0){
				s[i] = s[i-1] * 2;
			}else {
				s[i] = s[i-1] / 3;
			}
			sum += s[i];
		}
	
		printf("%.8f\n", sum);
	}
	
	return 0;
}	

Measured memory_bytes: 1236
// #pragma GCC optimize("Ofast,unroll-all-loops")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define all(v) v.begin(), v.end()
#define len(v) ((int)(v).size())
#define pb push_back
#define kek pop_back
#define pii pair<int, int>
#define mp make_pair
#define int ll

#define debug(x) cout << #x << " = " << x << endl;

const int INF = (is_same<int, ll>::value ? 1e18 + 666 : 1e9 + 666);

// const int MEM_SIZE = 1e8;
// char mem[MEM_SIZE];
// int cur_mem_ptr = 0;

// void* operator new(size_t n) {
//     cur_mem_ptr += n;
//     return mem + cur_mem_ptr - n;
// }

// void operator delete(void*) noexcept {}
// void operator delete(void*, size_t) noexcept {}

template<class t1, class t2>
bool cmin(t1 &a, const t2 &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<class t1, class t2>
bool cmax(t1 &a, const t2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

#ifndef LOCAL
void UseFiles(const string &s) {
    freopen((s + ".in").c_str(), "r", stdin);
    freopen((s + ".out").c_str(), "w", stdout);
}
#else
void UseFiles(const string&) {}
#endif

void run();

signed main() {
    // UseFiles("squads");
    iostream::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    run();
}

void run() {
    int n, m;
    cin >> n >> m;
    vector<int> h(n);
    for (auto &x : h) {
        cin >> x;
    }
    vector<char> cool(n, 1);
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        if (h[a] >= h[b]) {
            cool[b] = 0;
        }
        if (h[a] <= h[b]) {
            cool[a] = 0;
        }
    }
    cout << accumulate(all(cool), 0) << endl;
}

Measured memory_bytes: 4320
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i < n; i++)
#define rep3(i, x, n) for(int i = x; i > n; i--)
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const ll INF = 1e15;

int main(){
    int N, M;
    cin >> N >> M;
    vector<P> edge[N+1];
    int A[M], B[M];
    rep(i, M){
        cin >> A[i] >> B[i];
        edge[A[i]].push_back(P(B[i], i));
        edge[B[i]].push_back(P(A[i], i));
    }
    if(M % 2 != 0){
        cout << -1 << endl;
        exit(0);
    }
    bool uedge[M];
    fill_n(uedge, M, false);
    bool unode[N+1];
    fill_n(unode, N+1, false);
    queue<int> que;
    vector<int> vec;
    int par[N+1];
    que.push(1);
    unode[1] = true;
    while(!que.empty()){
        int i = que.front();
        que.pop();
        vec.push_back(i);
        rep(j, edge[i].size()){
            P p = edge[i][j];
            if(!unode[p.first]){
                que.push(p.first);
                unode[p.first] = true;
                par[p.first] = i;
                uedge[p.second] = true;
            }
        }
    }
    int count[N+1];
    fill_n(count, N+1, 0);
    rep(i, M){
        if(!uedge[i]){
            count[A[i]]++;
            cout << A[i] << ' ' << B[i] << endl;
        }
    }
    rep3(i, N-1, 0){
        int j = vec[i];
        int k = par[j];
        if(count[j]%2 == 0){
            cout << k << ' ' << j << endl;
            count[k]++;
        }
        else{
            cout << j << ' ' << k << endl;
            count[j]++;
        }
    }
}

Measured memory_bytes: 11256
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
value = min(a) + min(b)
for i in range(M):
    x,y,c = list(map(int, input().split()))
    if a[x-1] + b[y-1] - c < value:
        value = a[x-1] + b[y-1] - c

print(value)


Measured memory_bytes: 18684
N = int(input())
P = list(map(int, input().split()))

flg = None
for i, p in enumerate(P):
    index = i+1
    if index != p:
        if P[p-1] == index and ((not flg) or index==flg):
            flg = p
        else:
            print('NO')
            break
else:
    print('YES')

Measured memory_bytes: 38384
#include<cstdio> 
#include<cctype>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
const int N = 1e5 + 3;
int n,m;
inline int read(){
	int v = 0,c = 1;char ch = getchar();
	while(!isdigit(ch)){
		if(ch == '-') c = -1;
		ch = getchar();	
	}
	while(isdigit(ch)){
		v = v * 10 + ch - 48;
		ch = getchar();	
	}
	return v * c;	
}
int form[5],to[5],d[5]; 
bool book[5],vis[5],flag;
int main(){
	for(int i = 1;i < 4;++i){
		int x,y;
		cin >> x >> y;
		d[x]++,d[y]++;	
	}
	for(int i = 1;i <= 4;++i)
	if(d[i] > 2) flag = 1; 
	if(flag) cout << "NO";
	else cout << "YES"; 
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int,int>;
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define MOD 1000000007

int n,m;
vector<pii> tree[25];
int cnt[1<<19];
pii dp[1<<19];
int ppc[1<<19];

int dfs(int s, int t, int bef, int msk){
    if(s==t)return msk;
    for(pii P : tree[s]){
        int to = P.first;
        if(to==bef)continue;
        int ret = dfs(to,t,s,msk | (1<<P.second));
        if(ret != -1)return ret;
    }
    return -1;
}

int main(){
    scanf("%d%d",&n,&m);
    n--;
    REP(i,m){
        int a,b;
        scanf("%d%d",&a,&b);
        --a;--b;
        if(i<n){
            tree[a].push_back(pii(b,i));
            tree[b].push_back(pii(a,i));
        }else{
            int msk = dfs(a,b,-1,0);
            cnt[msk]++;
        }
    }
    REP(j,n)REP(i,1<<n)if(i&(1<<j))cnt[i]+=cnt[i^(1<<j)];
    REP(i,1<<n)ppc[i] = __builtin_popcount(i);
    dp[0] = pii(1,0);
    REP(j,m-n+1){
        REP(msk,1<<n)if(dp[msk] != pii(0,0)){
            int v = ppc[msk] + j + 1;
            int rmsk = ~msk & ((1<<n)-1);
            int add = (dp[msk].second + 1ll*dp[msk].first*v) % MOD;
            for(int x=rmsk&-rmsk; x; x=rmsk&(~rmsk+(x<<1))){
                (dp[msk | x].first += dp[msk].first) %= MOD;
                (dp[msk | x].second += add) %= MOD;
            }
        }
        if(j==m-n)break;
        REP(msk,1<<n)if(dp[msk] != pii(0,0)){
            dp[msk].first = 1ll*dp[msk].first *(cnt[msk]-j) % MOD;
            dp[msk].second= 1ll*dp[msk].second*(cnt[msk]-j) % MOD;
        }
    }
    printf("%d\n",dp[(1<<n)-1].second);
    return 0;
}


Measured memory_bytes: 8448
#include <iostream>
#include <vector>

using namespace std;

int main() {
	vector <vector <int>> a;
	vector <int> b;
	vector <int> c;
	vector <int> pusher;
	int n = 0;
	int m = 0;
	int sum = 0;
	int num = 0;

	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		for (int a = 0; a < m; a++) {
			cin >> num;
			pusher.push_back(num);
		}
		a.push_back(pusher);
		pusher.clear();
	}
	for (int i = 0; i < m; i++) {
		cin >> num;
		b.push_back(num);
	}
	for (int i = 0; i < n; i++) {
		sum = 0;
		for (int j = 0; j < m; j++) {
			sum += a[i][j]*b[j];
		}
		c.push_back(sum);
	}
	for (int i = 0; i < n; i++) {
		cout << c[i] << endl;
	}
}



Measured memory_bytes: 3164
let n = Scanf.scanf " %d" (+) 0
let a_s = Array.init n @@ fun _ -> Scanf.scanf " %d" (+) 0
let cs = Array.make 100001 0
let ans = ref 0
let _ = Array.iter (fun a -> cs.(a) <- cs.(a) + 1) a_s;
  for x = 1 to 100000 - 1 do ans := max !ans @@ cs.(x - 1) + cs.(x) + cs.(x + 1) done;
  Printf.printf "%d\n" !ans

Measured memory_bytes: 6272