akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <iostream>

using namespace std;

#define mod 1e9+7
#define ll long long int
#define epsilon 1e-7

double min(double x, double y){
    if(x<y)return x;
    return y;
}

int t[100];
int v[100];
double realv[20000];
int tsum[101];
int main(void){
    int n;
    scanf("%d", &n);
    int tt = 0;
    tsum[0] = 0;
    for(int i = 0;i < n;i++){
        scanf("%d", &t[i]);
        tt += t[i];
        tsum[i+1] = tt;
    }
    for(int i = 0;i < n;i++){
        scanf("%d", &v[i]);
    }
    double ans = 0;
    for(int i = 0;i < n;i++){
        for(int j = tsum[i];j < tsum[i+1];j++){
            double real = min(j, min(tsum[n]-j, v[i]));
            for(int k = 0;k < n;k++){
                if(k < i){
                    real = min(real, v[k] + j - tsum[k+1]);
                }
                if(k > i){
                    real = min(real, v[k] + tsum[k] - j);
                }
            }
            double half = min((double)j + 0.5, min((double)tsum[n]-(double)j - 0.5, (double)v[i]));
            for(int k = 0;k < n;k++){
                if(k < i){
                    half = min(half, (double)v[k] + (double)j + 0.5 - (double)tsum[k+1]);
                }
                if(k > i){
                    half = min(half, (double)v[k] + (double)tsum[k] - (double)j - 0.5);
                }
            }
            ans += real / 2.0 + half / 2.0;
        }
    }
    printf("%lf\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	int a,b,f=0;
	string s;
	cin>>a>>b>>s;
	if(s[a]!='-')f=1;
	FOR(i,0,a+b+1){
		if(i==a)continue;
		if(s[i]=='-')f=1;
	}

	if(f==1)cout<<"No";
	else cout<<"Yes";
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n, k;
	int l[50];
	int i, j;
	int length = 0;
	int *max;
	
	memset(l, 0, sizeof(l));
	scanf("%d %d", &n, &k);
	for(i=0; i < n; i++) {
		scanf("%d", &l[i]);
	}
	
	for(j = 0; j < k; j++) {
		max = &l[0];
		for(i = 1; i < n; i++) {
			if(*max < l[i]) {
				max = &l[i];
			}
		}
		length += *max;
		*max = 0;
	}
	printf("%d\n", length);
	
	return 0;
}

Measured memory_bytes: 128
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main
{
    public static void process(int test_number)throws IOException
    {
        int n = ni(), w = 0, r = 0;
        char final_config[] = new char[n];

        char arr[] = nln().toCharArray();
        for(int i = 0; i < n; i++){
            if(arr[i] == 'W')
                w++;
            else
                r++;
        }

        for(int i = 0; i < r; i++)
            final_config[i] = 'R';

        for(int i = r; i < n; i++)
            final_config[i] = 'W';

        int res = 0;
        for(int i = 0; i < n; i++)
            if(final_config[i] != arr[i]) res++;

        pn(res / 2);
    }
 
    static final long mod = (long)1e9+7l;
    
    static FastReader sc;
    static PrintWriter out;
    public static void main(String[]args)throws IOException
    {
        out = new PrintWriter(System.out);
        sc = new FastReader();
 
        long s = System.currentTimeMillis();
        int t = 1;
       // t = ni();
        for(int i = 1; i <= t; i++)
            process(i);
 
        out.flush();
        System.err.println(System.currentTimeMillis()-s+"ms");
    }

    static void trace(Object... o){ System.err.println(Arrays.deepToString(o)); };
    static void pn(Object o){ out.println(o); }
    static void p(Object o){ out.print(o); }
    static int ni()throws IOException{ return Integer.parseInt(sc.next()); }
    static long nl()throws IOException{ return Long.parseLong(sc.next()); }
    static double nd()throws IOException{ return Double.parseDouble(sc.next()); }
    static String nln()throws IOException{ return sc.nextLine(); }
    static long gcd(long a, long b)throws IOException{ return (b==0)?a:gcd(b,a%b);}
    static int gcd(int a, int b)throws IOException{ return (b==0)?a:gcd(b,a%b); }
    static int bit(long n)throws IOException{ return (n==0)?0:(1+bit(n&(n-1))); }
    
    static class FastReader{ 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader(){ 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next(){ 
            while (st == null || !st.hasMoreElements()){ 
                try{ st = new StringTokenizer(br.readLine()); } catch (IOException  e){ e.printStackTrace(); } 
            } 
            return st.nextToken(); 
        } 
  
        String nextLine(){ 
            String str = ""; 
            try{ str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } 
            return str; 
        } 
    } 
}


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

void solve() {
    int n;
    cin >> n;
    map<long long, long long> mp;
    mp[0] = 0;
    for (int i = 0; i < n; i++) {
        long long x;
        cin >> x;
        mp[x]++;
    }
    auto i = mp.end();
    vector<long long> ans(3);
    int cnt = 0;
    while(i != mp.begin() && cnt < 2) {
        while(mp[(*i).first] >= 2 && cnt < 2) {
            ans[cnt] = (*i).first;
            cnt++;
            mp[(*i).first] -= 2;
        }
        i--;
    }
    cout << ans[0] * ans[1];
}


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


Measured memory_bytes: 9808
#include <bits/stdc++.h>
using namespace std;
 int main() {
   char A,B,C,D;
   cin >>A>>B;
     if(A =='H' && B=='H') cout << "H" << endl;
else if(A =='H' && B=='D') cout << "D" << endl;
else if(A =='D' && B=='H') cout << "D" << endl;
else if(A =='D' && B=='D') cout << "H" << endl;
 }

Measured memory_bytes: 256
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_s(): return list(input().split())

N = list(input())

if N[1] != N[2]:
	print('No')
else:
	if N[0] == N[1] or N[2] == N[3]:
		print('Yes')
	else:
		print('No')


Measured memory_bytes: 4212
import java.util.Arrays;
import java.util.Scanner;

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

        int N = sc.nextInt();
        int[] A = new int[N];
        for (int i = 0; i < A.length; ++i) {
            A[i] = sc.nextInt();
        }

        System.out.println(solve(A));

        sc.close();
    }

    static int solve(int[] A) {
        return Arrays.stream(A).reduce(Main::gcd).getAsInt();
    }

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

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

int main () {
  int n,m,sum = 0;
  int a[100000];
  
  cin >> n >> m;

  for (int i = 0; i < m; i++){
    cin >> a[i];
    sum += a[i];
  }
  
  if ( n - sum < 0){
 	cout << "-1" << endl;
  }else{
    cout << n - sum << endl;
  }

    return 0;
}

Measured memory_bytes: 3668
#include <iostream>

using namespace std;

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

    int a = A % K;

    if (a == 0)
    {
        cout << "OK" << endl;
        return 0;
    }

    if (A - a + K <= B)
    {
        cout << "OK" << endl;
    }
    else
    {
        cout << "NG" << endl;
    }

    return 0;
}

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

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

	if (n == 1) {
	}
	else {
		n -= 2;
	}
	if (m == 1) {
	}
	else {
		m -= 2;
	}

	cout << n * m << endl;

	return 0;
}

Measured memory_bytes: 256
# coding: utf-8


def main():
    A, B, C, X, Y = map(int, input().split())
    ans = 0
    min_p = min(X, Y)
    d = X - Y

    if A + B > 2 * C:
        ans += 2 * C * min_p
    else:
        ans += (A + B) * min_p

    if d > 0:
        if A > 2 * C:
            ans += 2 * C * d
        else:
            ans += A * d
    elif d < 0:
        if B > 2 * C:
            ans += 2 * C * -d
        else:
            ans += B * -d

    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 9152
n,l=input().split()
n=int(n)
l=int(l)
taste=[]
abs_list=[]
for i in range(n):
  taste.append(l+i)
for j in range(len(taste)):
  abs_list.append(abs(taste[j]))
taste.pop(abs_list.index(min(abs_list)))
print(sum(taste))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define pb push_back
#define pll pair <ll, ll>
#define mp make_pair
#define pyshnapyshnakaa ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define x first
#define y second
#pragma GCC optimize("O3")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
#define plll pair <ll, pair <ll, ll>>
#define pllll pair <pair <ll, ll>, pair <ll, ll> >
#define psl pair <string, ll>
#define pld pair <ld, ld>
#define all(a) a.begin(), a.end()
#define vvl vector <vector <ll> >
 
typedef long long ll;
 
typedef long double ld;
 
using namespace std;
 
const ll maxn = 1e6 + 100;
const ll inf = 1e15;

ll n, m, k, t;

void no() {
    cout << "No";
    exit(0);
}

void yes() {
    cout << "Yes";
    exit(0);
}

int main() {
    pyshnapyshnakaa;
    ll q, w, e, a, b;
    map <ll, ll> M;
    cin >> n;
    ll xr = 0;
    for (q = 0; q < n; q++) {
        cin >> a;
        xr ^= a;
        M[a]++;
    }
    if (xr != 0) {
        no();
    }
    if (M.size() > 3) {
        no();
    }
    if (M.size() == 1 && a == 0) {
        yes();
    }
    if (n % 3 != 0) {
        no();
    }
    for (auto p : M) {
        if (p.second % (n / 3) != 0) {
            no();
        }
    }
    yes();
    return 0;
}

Measured memory_bytes: 8328
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str(); }
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX / 10;
const int MOD = 1000000007;

void show_route(int dx, int dy) {
	if (dx < 0) {
		REP(i, -dx) {
			cout << 'L';
		}
	}
	else {
		REP(i, dx) {
			cout << 'R';
		}
	}

	if (dy < 0) {
		REP(i, -dy) {
			cout << 'D';
		}
	}
	else {
		REP(i, dy) {
			cout << 'U';
		}
	}
}

int main() {
	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;
	int dx = tx - sx, dy = ty - sy;
	
	show_route(dx, dy);
	show_route(-dx, -dy);

	cout << 'D';
	show_route(dx + 1, dy + 1);
	cout << "LU";
	show_route(-dx - 1, -dy - 1);
	cout << 'R' << endl;

	return 0;
}

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

int f(int a){
	int ans = 0;
	while(0 < a){
		ans += a%10;
		a /= 10;
	}
	return ans;
}

int main(){
	int n,a,b;
	cin >> n >> a >> b;
	
	int ans = 0;
	rep(i, n+1){
		int num = f(i);
		if(a <= num && num <= b){
			ans += i;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

# 入力を整数に変換して受け取る
def input_int():
    return int(input())


# マイナス1した値を返却
def int1(x):
    return int(x) - 1


# 半角スペース区切り入力をIntに変換してMapで受け取る
def input_to_int_map():
    return map(int, input().split())


# 半角スペース区切り入力をIntに変換して受け取る
def input_to_int_tuple():
    return tuple(map(int, input().split()))


# 半角スペース区切り入力をIntに変換してマイナス1した値を受け取る
def input_to_int_tuple_minus1():
    return tuple(map(int1, input().split()))


MOD = 10 ** 9 + 7


from operator import mul
from functools import reduce


def cmb(n, r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    return over // under


def main():
    n, k = input_to_int_map()

    all_n = n + 1
    ret = 0
    all_list_sum = [0]
    pre = 0
    for i in range(0, all_n):
        all_list_sum.append(i + pre)
        pre = i + pre

    for choice_cnt in range(k, all_n + 1):
        ret = (ret + (all_list_sum[n + 1] - all_list_sum[n + 1 - choice_cnt] - all_list_sum[choice_cnt] + 1)) % MOD

    return ret


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 19640
using System;
using System.Text.RegularExpressions;
using System.Text;
using System.Linq;


namespace aizu
{
	public class EntryPoint
	{
		public static int[] Split(string line)
		{
			return Regex.Split(line, " ").Select(x => int.Parse(x)).ToArray();
		}
		public static void Main()
		{
			var line = Console.ReadLine();
			
			var v = Split(line);
			
			Console.WriteLine(string.Join(" ", v.OrderBy(x => x).Select(x => x.ToString()).ToArray()));
			
			
			
		}
	}


}

Measured memory_bytes: 7540
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;

int main(void){
  int n,a;
  cin >> n >> a;
  if(n%500 <= a){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

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

int main(){
    int h,h2,w,w2;
    cin >> h >> w;
    cin >> h2 >> w2;
    int ans;
    ans=h*w-h2*w-h*w2+h2*w2;
    cout << ans << endl;
    

    return 0;
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


int main() {
    int N; cin >> N;
    vector<int> s(N);
    int sum = 0;
    REP(i,N){
        cin >> s[i];
        sum += s[i];
    }
    sort(ALL(s));
    if(sum%10 != 0){
        cout << sum << endl;
        return 0;
    }else{
        REP(i,N){
            if(s[i]%10 != 0){
                cout << sum - s[i] << endl;
                return 0;
            }
        }
    }
    cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 3556
N = int(input())

A = [1] * (N+1)
for i in range(2,N+1):
  a = i
  while a < N+1:
    A[a] += 1
    a += i

#print(A)
ans = 0
for i in range(N+1):
  ans += i * A[i]
  
print(ans)

Measured memory_bytes: 151420
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,c;
    cin>>n>>m>>c;
    int arr[m];
    
    for(int i=0; i<m; i++)
        cin>>arr[i];
        
    int cnt = 0;
    while(n--)
    {
        int a[m];
        int ans = 0;
        for(int i=0; i<m; i++)
        {
            cin>>a[i];
            ans += a[i]*arr[i];
        }
        // cout<<ans<<" "<<ans+c<<"\n";
        if(ans + c>0)
            cnt++;
    }
    cout<<cnt;
}

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

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using vvb = vector<vb>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

int INF = 1ll << 30;
int Parent[200010];

void init(){
  rep(i, 0, 200010)
    Parent[i] = -1;
}
int root(int A) {
     if (Parent[A] < 0) return A;  // マイナスならそれはroot
     return Parent[A] = root(Parent[A]);
   }
 
   // rootの値をプラスに戻して返す(サイズ)
   int size(int A) {
     return -Parent[root(A)];
   }
 
   // くっつける関数
   bool connect(int A, int B) {
     // AとBのroot同士をくっつける
     A = root(A);  // ここのAは、"rootの場所"の意味
     B = root(B);
     if (A == B) return false;  // 既にくっついている
     if (size(A) < size(B))
       swap(A, B);            // 大きい方にくっつけるために中身交換
     Parent[A] += Parent[B];  // 中身更新
     Parent[B] = A;
     return true;
   }

void chmax(int &a, int b){
  if(a < b)
    a = b;
}

int main(){
  int n, m;
  cin >> n >> m;
  init();
  rep(i, 0, m){
    int a, b;
    cin >> a >> b;
    a--;b--;
    connect(a, b);
  }
  int ans = 0;
  
  rep(i, 0, n){
    chmax(ans, size(i));
  }
  
  cout << ans << endl;
  
  return 0;
  
}

Measured memory_bytes: 4436
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x);i<=(y);i++)
#define per(i,x,y) for (int i=(x);i>=(y);i--)
#define ll long long
#define ull unsigned long long
#define ld long double
#define inf 1000000001
#define INF 1000000000000000001ll
#define pii pair<int,int>
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define sqr(x) ((x)*(x))
#define y1 y1_
#define mset(x,y) memset((x),(y),sizeof(x))
#define mcpy(x,y) memcpy((x),(y),sizeof(y))
using namespace std;
const ld pi=acos(-1);
const ld eps=1e-8;
template<typename T> void cmin(T &x,T y){x=y<x?y:x;}
template<typename T> void cmax(T &x,T y){x=y>x?y:x;}
//////////////////////// header files ////////////////////////
ll read(){
	char ch=getchar();ll x=0;int op=1;
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') op=-1;
	for (;isdigit(ch);ch=getchar()) x=(x<<1)+(x<<3)+ch-'0';
	return x*op;
}
void write(ll a){
	if (a<0) putchar('-'),a=-a;
	if (a>=10) write(a/10);putchar(a%10+'0');
}
////////////////////////// fast i/o //////////////////////////
#ifdef mod
ll ksm(ll x,ll p){
	ll ret=1;
	for (;p;p>>=1,x=x*x%mod) if (p&1) ret=ret*x%mod;
	return ret;
}
ll getinv(ll x){return ksm(x,mod-2);}
#else
ll ksm(ll x,ll p){
	ll ret=1;
	for (;p;p>>=1,x=x*x) if (p&1) ret=ret*x;
	return ret;
}
#endif
//////////////////////////// qpow ////////////////////////////
#define N 200005
int n,a[N],sum,Xor;ll ans=0;
//#define local
int main(){
#ifdef local
	freopen("test.in","r",stdin);freopen("test.out","w",stdout);
#endif
	n=read();
	rep (i,1,n) a[i]=read();
	int l=1,r=0;ll sum=0,Xor=0;
	while (r<n){
		r++;
		while (l<=r&&sum+a[r]!=(Xor^a[r])){
			sum-=a[l];Xor^=a[l++];
		}
		sum+=a[r];Xor^=a[r];
//		cerr<<l<<' '<<r<<'\n';
		ans+=r-l+1;
	}
	cout<<ans<<'\n';
	return 0;
}
// sample data:
/*

*/

// rest:
/*

*/

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

int main()
{
    int n;
    cin >> n;
    vector<pair<ll, ll>> p(n);
    rep(i, n)
    {
        ll t, a;
        cin >> t >> a;
        p[i] = make_pair(t, a);
    }
    ll x = 1, y = 1;
    for (int i = 0; i < n; i++)
    {
        ll s = max((x - 1) / p[i].first, (y - 1) / p[i].second);
        s++;
        p[i].first *= s;
        p[i].second *= s;
        x = p[i].first;
        y = p[i].second;
    }
    cout << x + y << endl;
    return 0;
}

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

int main() {
  int H, W;
  cin >> H >> W;
  
  vector<vector<char>> field(H, vector<char>(W));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> field[i][j];
    }
  }
  
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      int count = 0;
      if (field[i][j] == '#') continue;
      else {
        if (i > 0 && field[i-1][j] == '#') count++;
        if (i > 0 && j < W - 1 && field[i-1][j+1] == '#') count++;
        if (j < W - 1 && field[i][j+1] == '#') count++;
        if (i < H - 1 && j < W - 1 && field[i+1][j+1] == '#') count++;
        if (i < H - 1 && field[i+1][j] == '#') count++;
        if (i < H - 1 && j > 0 && field[i+1][j-1] == '#') count++;
        if (j > 0 && field[i][j-1] == '#') count++;
        if (i > 0 && j > 0 && field[i-1][j-1] == '#') count++;
      }
      
      field[i][j] = '0' + count;
    }
  }
  
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cout << field[i][j];
      if (j == W - 1) cout << endl;
    }
  }
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define l long long
int main()
{
    l n,m,a,sum=0;
    cin>>n>>m;
    while(m--)
    {
        cin>>a;
        sum+=a;
    }
    if(sum>n)
    {
        cout<<-1<<endl;
    }
    else if(sum==n)
    {
        cout<<0<<endl;
    }
    else
    {
        cout<<n-sum<<endl;
    }
    return 0;
}


Measured memory_bytes: 3568
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		System.out.println("?a");
		ArrayList<String> list = new ArrayList<String>();
		list.add("a");
		while(true){
			String s = sc.next();
			if(list.contains(s)==true || s.length()==1 || s.charAt(0)!='a'){
				System.out.println("!OUT");
				break;
			}
			list.add(s);
			if(s.compareTo("aa")==0) System.out.println("?aaa");
			else System.out.println("?" + s.charAt(1) + "a");
		}	
	}	
}

Measured memory_bytes: 17268
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

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

template<class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template<class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template<class T, class V>
typename enable_if<is_class<T>::value == 0>::type fill(T &t, const V &v) {
    t = v;
}
template<class T, class V>
typename enable_if<is_class<T>::value != 0>::type fill(T &t, const V &v){
    for (auto &e : t) fill(e, v);
}

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }

#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }



int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string S;
    while (cin >> S) {
        int con = 0;
        for (auto c : S) if (c == 'o') ++con;
        con += (15 - (int)S.size());
        if (con >= 8) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
}
















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

int main(void) {
	int i, j;
	int tmp = 0;
	char str[26];
	
    scanf("%s", str);
	
	for (i = 0; i < strlen(str); i++) {
		for (j = i + 1; j < strlen(str); j++) {
			if (str[i] == str[j]) {
				tmp = 1;
			}
		}
	}
	
	if (tmp == 1) {
		printf("no\n");
	} else {
		printf("yes\n");
	}
    
	return 0;
}

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

#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())
#define endl "\n"

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
void initialize( void );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;
template <typename T, typename K> struct P {
	T a; K b;
};
int main( void ){
	// initialize();
	int H, W;
	cin >> H >> W;
	vector<vector<int>> dp(H, vector<int>(W, k_mod));
	vector<vector<bool>> maze(H, vector<bool>(W, 0));

	rep(i,0,H){
		rep(j,0,W){
			char input; cin >> input;
			maze[i][j] = (input == '.');
		}
	}
	dp[0][0] = !maze[0][0];
	rep(i,0,H){
		rep(j,0,W){
			if (i != 0){
				int cost = maze[i-1][j] && !maze[i][j];
				dp[i][j] = min(dp[i][j], dp[i-1][j]+cost);
			}
			if (j != 0){
				int cost = maze[i][j-1] && !maze[i][j];
				dp[i][j] = min(dp[i][j], dp[i][j-1]+cost);
			}
		}
	}
	cout << dp[H-1][W-1] << endl;
}

template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}
void initialize( void ){
	cout << fixed << setprecision( 10 );
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>
#include <map>
#include <cmath>
#include <string>
#include <queue>
#include <stack>

using namespace std;

const int maxn = 2e5+10;

typedef long long ll;

ll a[maxn];

map<ll,int> col;

int main()
{
    int n;
    scanf("%d",&n);
    a[0] = 0LL;
    col[0]++;
    ll temp;
    for(int i=1;i<=n;i++)
    {
        scanf("%lld",&temp);
        a[i] = a[i-1] + temp;
        col[a[i]]++;
    }
    map<ll,int> :: iterator it;
    ll sum = 0LL;
    for(it = col.begin();it != col.end();it++)
    {
        ll now = it->second;
        sum += now * (now-1LL) / 2LL;
    }
    printf("%lld\n",sum);
    //cout <<col.size()<<"*"<< col[0] << "*" << col[1]  << "*" << col.size()<<endl;
    return 0;
}


Measured memory_bytes: 14336
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

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

    int h,w,k;cin>>h>>w>>k;
    string s[h];
    rep(i,h) cin>>s[i];
    int g[h][w];
    rep(i,h)rep(j,w) g[i][j]=(s[i][j]-'0');

    int ans=INF;

    for(int bit=0;bit<(1<<(h-1));bit++){
        int cut=__builtin_popcount(bit)+1;
        int x[cut][w]={};
        int idx=0;
        rep(i,h){
            rep(j,w){
                x[idx][j]+=g[i][j];
            }
            if((bit>>i)&1) idx++;
        }
        // cout<<bitset<2>(bit)<<endl;
        // rep(i,cut){
        //     rep(j,w){
        //         cout<<x[i][j]<<" ";
        //     }cout<<endl;
        // }


        bool ff=true;
        rep(i,cut){
            rep(j,w){
                if(x[i][j]>k) ff=false;
            }
        }
        if(!ff) continue;

        int cnt[cut]={};
        int tmp=0;
        rep(j,w){
            rep(i,cut){
                cnt[i]+=x[i][j];
            }
            bool f=true;
            rep(i,cut){
                if(cnt[i]>k) f=false;
            }
            if(f) continue;
            tmp++;
            rep(i,cut){
                cnt[i]=x[i][j];
            }
        }
        // cout<<"zantei "<<tmp<<endl;
        chmin(ans,cut-1+tmp);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>

int main() {
  int m, f, r;

  while (true) {
    std::cin >> m >> f >> r;

    if (m == -1 && f == -1 && r == -1) {
      break;
    }

    if (m == -1 || f == -1) {
      std::cout << "F" << std::endl;
    } else if (m + f >= 80) {
      std::cout << "A" << std::endl;
    } else if (m + f >= 65) {
      std::cout << "B" << std::endl;
    } else if (m + f >= 50 || r >= 50) {
      std::cout << "C" << std::endl;
    } else if (m + f >= 30) {
      std::cout << "D" << std::endl;
    } else {
      std::cout << "F" << std::endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3088
#include<iostream>
using namespace std;
int main()
{
    // 整数の入力
    string a;
    cin >> a;
    // スペース区切りの整数の入力
    // 出力
    if("ABC" == a) {
        cout << "ARC";
    } else {
        cout << "ABC";
    }
    return 0;
}


Measured memory_bytes: 3592
#include <stdio.h>

int main(){
	int y,m,d,day;
	while(scanf("%d %d %d",&y,&m,&d) != EOF){
		day = y * 10000 + m * 100 + d;
		if(day >= 19890108) printf("heisei %d %d %d\n",y - 1988,m,d);
		else if(day >= 19261225) printf("showa %d %d %d\n",y - 1925,m,d);
		else if(day >= 19120730) printf("taisho %d %d %d\n",y - 1911,m,d);
		else if(day >= 18680908) printf("meiji %d %d %d\n",y - 1867,m,d);
		else puts("pre-meiji");
	}
	return 0;
}

Measured memory_bytes: 608
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iterator>
#include <functional>
#include <numeric>
#include <cmath>
#include <stack>
#include <limits>

using namespace std;

#define ll long long
#define f0(i,n)for(i=0;i<n;i++)
#define f1(i,n)for(i=1;i<=n;i++)
#define fc(i,c,n)for(i=c;i<=n;i++)
#define f0r(i,n)for(i=n-1;i>=0;i--)
#define f1r(i,n)for(i=n;i>0;i--)
#define fcr(i,c,n)for(i=n;i>=c;i--)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef list<ll> LST;
typedef vector<ll> VEC;
typedef map<ll, ll> MAP;

long long i, j, q;

int main() {
	IO;
	ll mod = 1000000007;
	//ifstream cin("In.txt");
	ll n, ans=0, tmp;
	string s;
	cin >> n;
	cin >> s;
	vector<ll> cnt(30);
	f0(i,n) {		
		cnt[s[i]-'a']++;
		tmp = 1;
		f0(j, 26) {
			if (j != s[i] - 'a' && cnt[j]) {
				tmp *= (cnt[j]+1);
				tmp %= mod;
			}
		}
		ans += tmp;
		ans%=mod;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
    int h,w,a,b;
    cin>>h>>w>>a>>b;
    int ans[h][w]={};
    for(int i=0;i<h-b;i++){
        for(int j=0;j<a;j++){
            ans[i][j]=1;
        }
    }
    for(int i=h-b;i<h;i++){
        for(int j=a;j<w;j++){
            ans[i][j]=1;
        }
    }
    rep(i,h){
        rep(j,w){
            cout<<ans[i][j];
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 5120
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <stack>
#include <cstdio>
#include <cmath>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using P1 = pair<int, P>;
#define FOR(t, a, b) for (int t = (a); t < (b); ++t)
#define REP(t, n) FOR(t, 0, n)

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    int def[3] = {abs(a - b), abs(a - c), abs(b - c)};
    sort(def, def + 3);
    cout << def[0] + def[1] << endl;

    return 0;
}


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

using namespace std;

int P[15][15];

int main(){
	int N, D;
	scanf("%d%d", &N, &D);
	
	for(int i = 0; i < N; i ++){
		for(int j = 0; j < D; j ++){
			scanf("%d", &P[i][j]);
		}
	}
	
	int ans = 0;
	for(int i = 0; i < N; i ++){
		for(int j = i+1; j < N; j ++){
			int sum = 0;
			for(int k = 0; k < D; k ++){
				sum += (P[i][k]-P[j][k])*(P[i][k]-P[j][k]);
			}
			int sqrt1 = (int)(sqrt(sum)+1e-11);
			ans += (sqrt1*sqrt1 == sum);
		}
	}
	printf("%d", ans);
}


Measured memory_bytes: 256
N,K=map(int, input().split())
td=[list(map(int,input().split())) for i in range(N)]
best=[0]*(N+1)
other=[]
from heapq import heappop,heappush
td.sort(key=lambda x: x[1],reverse=True)
shurui=0
for i in range(K):
    if best[td[i][0]]==0:
        best[td[i][0]]=td[i][1]
        shurui+=1
    elif best[td[i][0]]<td[i][1]:
        heappush(other,best[td[i][0]])
        best[td[i][0]]=td[i][1]
    else:
        heappush(other,td[i][1])

sumbest=sum(best)
sumother=sum(other)
ans=sumbest+sumother+shurui**2

for i in range(K,N):
    if best[td[i][0]]==0 and len(other)>0:
        best[td[i][0]]=td[i][1]
        shurui+=1
        sumbest+=td[i][1]
        sumother-=heappop(other)
        ans=max(ans,sumbest+sumother+shurui**2)

print(ans)


Measured memory_bytes: 29996
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }




int main() {
    string S;
    while (cin >> S) {
        deque<char> dS(S.size());
        for (int i = 0; i < S.size(); ++i) dS[i] = S[i];
        int Q; cin >> Q;
        int rev = 0;
        for (int i = 0; i < Q; ++i) {
            int type; cin >> type;
            if (type == 2) {
                int f;
                char c;
                cin >> f >> c;
                if (rev) f = 3 - f;
                if (f == 1) dS.push_front(c);
                else dS.push_back(c);
            }
            else rev = 1 - rev;
        }
        if (rev) reverse(dS.begin(), dS.end());
        for (auto c : dS) cout << c;
        cout << endl;
    }
}


















Measured memory_bytes: 896
#include<bits/stdc++.h>
#define N 505000
using namespace std;

int n,k,a[N],L[N],R[N],mn[N],an[N],pos[N],sz=500,tot,ans[N];
int now,res,p;

void RE(int w){
	now=res=1e8;
	for (int i=L[w];i<=R[w];++i){
		if (now-a[i]>=k) res=a[i],p=i;
		now=min(now,a[i]);
	}
	mn[w]=now, an[w]=res, pos[w]=p;
}

int doit(){
	now=res=1e8;
	for (int i=1;i<=tot;++i){
		if (now-an[i]>=k) res=an[i],p=i;
		now=min(now,mn[i]);
	}
	return pos[p];
}

int main(){
	cin>>n>>k; for (int i=1,x;i<=n;++i) scanf("%d",&x), a[x]=i; tot=(n-1)/sz+1;
	for (int i=1;i<=tot;++i) L[i]=i*sz-sz+1, R[i]=min(n,i*sz), RE(i);
	for (int i=1,p;i<=n;++i) ans[a[p=doit()]]=i, a[p]=1e8, RE((p-1)/sz+1);
	for (int i=1;i<=n;++i) printf("%d\n",ans[i]);
}

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

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const int MOD = 1000000007;

// Lib
//
ll calc(ll N) {
    ll ret = 0;
    while (N > 0) {
        ret += N % 10;
        N /= 10;
    }
    return ret;
}


int main(){
#ifdef MYLOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif
    ll N; cin >> N;
    long long ans = INF64;
    for (ll i = 1; i < N; ++i) {
        ll j = N - i;
        ll tmp = calc(i) + calc(j);
        ans = min(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <cstdio>
#include <queue>
#define N_MAX 105
#define X_MAX 10010
#define INF (1e9)
using namespace std;
typedef pair<int,int> P;
typedef pair<double,P > P1;
void dijkstra();
double Cal(int,int);
int n,a[N_MAX],r;
double b,v,e,f,dp[X_MAX][N_MAX];

int main(){
  while(1){
    cin>>n;
    if(!n) break;
    for(int i=0;i<n;i++) cin>>a[i];
    cin>>b>>r>>v>>e>>f;
    dijkstra();
  }
  return 0;
}

void dijkstra(){
  for(int i=0;i<X_MAX;i++)
    for(int j=0;j<n;j++) dp[i][j]=INF;
  priority_queue<P1,vector<P1>,greater<P1> > Q;
  dp[0][0]=Cal(0,a[0]);
  if(n!=1) Q.push(make_pair(dp[0][0],make_pair(a[0],1)));
  while(!Q.empty()){
    P1 v=Q.top();
    Q.pop();
    double t=v.first;
    int uy=v.second.first,ux=v.second.second;
    int ncny=uy+a[ux]-a[ux-1];
    double nccal=Cal(uy,ncny);
    if(dp[ncny][ux]>t+nccal){
      dp[ncny][ux]=t+nccal;
      if(ux!=n-1) Q.push(make_pair(dp[ncny][ux],make_pair(ncny,ux+1)));
    }
    int cny=a[ux]-a[ux-1];
    double ccal=Cal(0,cny)+b;
    if(dp[cny][ux]>t+ccal){
      dp[cny][ux]=t+ccal;
      if(ux!=n-1) Q.push(make_pair(dp[cny][ux],make_pair(cny,ux+1)));
    }
  }
  double mincost=INF;
  for(int i=0;i<=a[n-1];i++) mincost=min(mincost,dp[i][n-1]);
  printf("%.4f\n",mincost);
}

double Cal(int begin,int end){
  double ret=0;
  for(int i=begin;i<end;i++){
    if(i>=r) ret+=1.0/(1.0*v-1.0*e*(1.0*i-1.0*r));
    else ret+=1.0/(1.0*v-1.0*f*(1.0*r-1.0*i));
  }
  return ret;
}

Measured memory_bytes: 9468
/**
 *    author:  yoseph
 *    created: 18.07.2020 22:14:04      
**/
#include <bits/stdc++.h>
using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string pt = "Christmas";
	int d;
	cin >> d;
	for (int i = 0; i < 25 - d; ++i)
		pt = pt + " Eve";
	cout << pt << "\n";
	return 0;
}


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

//const long double PIL = 3.141592653589793238462643383279502884L;
//const double PI = 3.14159265358979323846;

#define sz(a) (int)((a).size())
#define all(c) (c).begin(), (c).end()
#define debug(v) {for (auto z : v) {cerr << z << ' ';} cerr << endl;}

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vll = vector<long long>;
using vii = vector<pair<int,int>>;

const int N = 1e5 + 5;
vi frd[N], blk[N];
int comp[N];

void dfs(int u, int c) {
	comp[u] = c;
	for (int v : frd[u])
		if (comp[v] == 0) dfs(v, c);
}

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);
	int n, m, k;
	scanf("%d%d%d", &n, &m, &k);
	for (int i = 0; i < m; i++) {
		int u, v;
		scanf("%d%d", &u, &v);
		frd[u].push_back(v);
		frd[v].push_back(u);
	}
	for (int i = 0; i < k; i++) {
		int u, v;
		scanf("%d%d", &u, &v);
		blk[u].push_back(v);
		blk[v].push_back(u);
	}

	for (int u = 1; u <= n; u++)
		if (comp[u] == 0) dfs(u, u);
	//for (int u = 1; u <= n; u++) {printf("%d ", comp[u]);} puts("");
	map<int,int> cnt;
	for (int u = 1; u <= n; u++) cnt[comp[u]]++;
	//for (auto x : cnt) printf("%d: %d\n", x.first, x.second);

	for (int u = 1; u <= n; u++) {
		int ex = 0, c = comp[u];
		for (int v : frd[u])
			if (comp[v] == c) ex++;
		for (int v : blk[u])
			if (comp[v] == c) ex++;
		printf("%d ", cnt[c] - 1 - ex);
	}
	puts("");
}


Measured memory_bytes: 12928
#include<iostream>
#include<map>
#include<cassert>
#include<cstdlib>
#include<algorithm>
#include<numeric>
#include<vector>
#include<queue>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)

const int N = 5;
const int NODE=120;

struct PMA{
  PMA *next[N];
  int ac;
  PMA(){fill(next,next+N,(PMA*)0);ac=0;}
};

map<PMA*,int> M;
PMA *buildPMA(string *in,int size){
  PMA *root=new PMA;
  M[root]=0;
  rep(i,size){
    PMA *t = root;
    rep(j,in[i].size()){
      char c=in[i][j];
      if (t->next[c] == NULL){
	int ind=M.size();
	t->next[c]=new PMA;
	M[t->next[c]]=ind;
      }
      t=t->next[c];
    }
    t->ac++;
  }

  queue<PMA*> Q;
  REP(i,1,N){
    char c=i;
    if (root->next[c]){
      root->next[c]->next[0]=root;
      Q.push(root->next[c]);
    }else root->next[c]=root;
  }

  while(!Q.empty()){
    PMA *t=Q.front();Q.pop();
    REP(c,1,N){
      if (t->next[c]){
	Q.push(t->next[c]);
	PMA *r=t->next[0];
	while(!r->next[c])r=r->next[0];
	t->next[c]->next[0]=r->next[c];
	t->next[c]->ac+=r->next[c]->ac;
      }
    }
  }
  return root;
}

PMA* match(PMA *r,char in){
  while(!r->next[in])r=r->next[0];
  r=r->next[in];
  return r;
}

struct Edge{int dir,node;};
const string dir="DURL";
const int dx[]={0,0,1,-1};
const int dy[]={1,-1,0,0};


vector<Edge> edge[NODE];

void makegraph(PMA *now,PMA* root){
  //rep(i,4){
  REP(i,1,N){
    PMA* next=now;
    next=match(next,i);
    if (next->ac != 0)continue;
    edge[M[now]].push_back((Edge){i-1,M[next]});
  }
}

void travarse(PMA *t,PMA *root){
  makegraph(t,root);
  REP(i,1,N){
    if (t->next[i] != NULL && t->next[i] != root)travarse(t->next[i],root);
  }
}

char m[50][50];
struct st{
  int y,x,node,cost;
};

int cost[50][50][NODE];
int solve(int r,int c,int sy,int sx){
  rep(i,r)rep(j,c)rep(k,M.size())cost[i][j][k]=-1;
  queue<st> Q;
  Q.push((st){sy,sx,0,0});
  cost[sy][sx][0]=0;
  while(!Q.empty()){
    st now=Q.front();Q.pop();
    //cout << now.y <<" " << now.x <<" " << now.node <<" " << now.cost << endl;
    rep(i,edge[now.node].size()){
      int dir=edge[now.node][i].dir;
      int next=edge[now.node][i].node;
      int ney=now.y+dy[dir],nex=now.x+dx[dir];
      if (ney == -1 || nex == -1 || ney == r || nex == c||
	  m[ney][nex] == '#' || cost[ney][nex][next] != -1)continue;
      cost[ney][nex][next]=now.cost+1;
      if (m[ney][nex] == 'G')return now.cost+1;
      Q.push((st){ney,nex,next,now.cost+1});
    }
  }
  return -1;
}

main(){
  int r,c;
  int n;
  string in[10];
  while(cin>>r>>c && r){
    M.clear();
    rep(i,NODE)edge[i].clear();
    rep(i,r)cin>>m[i];
    cin>>n;
    rep(i,n){
      cin>>in[i];
      rep(j,in[i].size()){
	rep(k,dir.size())if (in[i][j] == dir[k])in[i][j]=k+1;
      }
    }
    PMA* root=buildPMA(in,n);
    travarse(root,root);
    int sy,sx;
    rep(i,r)rep(j,c)if (m[i][j] == 'S')sy=i,sx=j;
    cout << solve(r,c,sy,sx) << endl;
  }
  return false;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <bitset>
typedef long long ll;
using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;
const int MAX_N = 200000;

int ctoi(const char c){
  switch(c){
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
    default : return -1;
  }
}

ll dp[200][200000];
ll w[200];
ll v[200];

int main(int argc, const char * argv[]) {
    ll N,W; cin >> N >> W;
    for(ll i=1;i<=N;i++){
        cin >> w[i] >> v[i];
    }
    
    for(ll i=0;i<W+1;i++){
        dp[0][i]=0;
    }
    
    for(ll i=1;i<=N;i++){
        for(ll j=0;j<=W; j++){
            if(j-w[i]<0){
                dp[i][j]=dp[i-1][j];
            }else{
               dp[i][j] = max(dp[i-1][j-w[i]] + v[i], dp[i-1][j]) ;
            }
        }
    }

    cout << dp[N][W] << endl;
    
    
    return 0;
}


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

using namespace std;

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

	int h,r;
	cin>> h>> r;
	if(h<-1*r)cout<< -1<< endl;
	else if(h>-1*r)cout<< 1<< endl;
	else cout<< 0<< endl;

	return 0;
}



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

const int maxn = 50;
int n, cnt[maxn][30], ans[30];
string s[maxn];

int main(){
	cin >> n;

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

		for(char c : s[i]){
			cnt[i][c - 'a']++;
		}
	}

	for(char i = 'a'; i <= 'z'; i++){
		ans[i - 'a'] = 1e9;

		for(int j = 0; j < n; j++){
			ans[i - 'a'] = min(ans[i - 'a'], cnt[j][i - 'a']);
		}

		for(int j = 0; j < ans[i - 'a']; j++){
			cout << i;
		}
	}

	cout << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fo(i,m,n) for(int i = m; i <= n; i++)
#define fod(i,m,n) for(int i = m; i >= n; i--)
#define fov(i,x) for(auto &i : x)
using namespace std;
typedef int64_t i64;
typedef pair<int,int> _ii;
i64 f[2007],S,mod = 1e9+7;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	cin >> S;
	f[0] = 1;
    fo(i,3,S)
    {
        fod(j,i-3,0)
        {
            f[i] += f[j];
            f[i] %= mod;
        }
    }
    cout << f[S] << '\n';
    return 0;
}


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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main(void){
    int N,K; cin >> N >> K;
    int ans = K;
    REP(i,N-1) ans *= K-1;
    cout << ans << endl;
    return 0;
}

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

int main(){
    int a,b,C;
    double a2,b2,S,L,h,c,rad,PI = acos(-1);
    cin >> a >> b >> C;
    rad = C * PI / 180;
    S = ((a*b*sin(rad))/2);
    a2 = pow(a,2);b2 = pow(b,2);
    c = sqrt((a2+b2)-(2*a*b*cos(rad)));
    L = a + b + c;
    h = (S * 2)/a;
    printf("%lf\n%lf\n%lf",S,L,h);
return 0;
}


Measured memory_bytes: 3576