akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
    #include <math.h>
    #include <vector>
    #include <string>
    using namespace std;
    int main() {
        string a;
        cin >> a;
        for(int i=0;i<3;i++){
            if(a[i]=='1') a[i] = '9';
            else if(a[i]=='9') a[i]='1';
        } 
        cout << a << endl;
        return 0;
    }

Measured memory_bytes: 256
import java.util.Scanner;
class Main {
	public static void main(String[] args){
		 Scanner scn = new Scanner(System.in);
		    int W = scn.nextInt();
		    int H = scn.nextInt();
		    int x = scn.nextInt();
		    int y = scn.nextInt();
		    int r = scn.nextInt();

		    int set=0;
		    if(x+r>W) {
		    	set=1;
		    }
		    if(y+r>H) {
		    	set=1;
		    }
		    if(r>x) {
		    	set=1;
		    }
		    if(r>y) {
		    	set=1;
		    }
		    
		    if(set == 0) {
		    	System.out.println("Yes");
		    }else {
		    	System.out.println("No");
		    }

	}
}

Measured memory_bytes: 26308
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map> 
#include <map> 
#include <numeric>
#include <limits>
#include <utility>
#include <queue>
#include <random>
using namespace std;
typedef long long LL;

int main(void) {
	vector<int> v(26, 0);
	string w;
	cin >> w;
	for (int i = 0; i < w.size(); i++) {
		v[w[i] - 97]++;
	}
	for (int i = 0; i < 26; i++) {
		if (v[i] % 2 != 0) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
priority_queue<pair<ll,ll>,vector<pair<ll,ll>>,std::greater<pair<ll,ll>>>q;
ll r,c;
bool vis[1001][1001];
ll dis[1001][1001];
char A[1001][1001];
void go(int i,int j)
{
    q.push(make_pair(i,j));  // put them in queue
    vis[i][j]=1; // this is visited
    dis[i][j]=0; // initially no magic is needed
    while(!q.empty())
    {
        ll u=q.top().first;  // nearest point
        ll v=q.top().second;
        q.pop();
        for(int x=-2; x<=2; x++)  // try 5x5 grid
        {
            for(int y=-2; y<=2; y++)
            {
                if(u+x>r||u+x<1||v+y>c||v+y<1||(x==0&&y==0)) // out of bound
                    continue;
                if(vis[u+x][v+y]==0&&A[u+x][v+y]=='.') // possible to go
                {
                    vis[u+x][v+y]=1;
                    if(abs(x)+abs(y)>1) // if its a magic, OPeration B
                        dis[u+x][v+y]=dis[u][v]+1;
                    else  // operation A
                        dis[u+x][v+y]=dis[u][v];
                    q.push(make_pair(u+x,v+y));
                }
                else if(A[u+x][v+y]=='.') // to find minimum dis
                {
                    if((abs(x)+abs(y)>1)&&dis[u+x][v+y]>dis[u][v]+1) // can be improved
                    {                      // +1 because we are using magic
                        dis[u+x][v+y]=dis[u][v]+1;
                        q.push(make_pair(u+x,v+y));
                    }
                    else if(dis[u][v]<dis[u+x][v+y]&&(abs(x)+abs(y)<=1)) // can be improved
                    {
                        dis[u+x][v+y]=dis[u][v];
                        q.push(make_pair(u+x,v+y));
                    }
                }
            }
        }
    }
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
 
    ll sx,sy,dx,dy;
    string s;
    cin>>r>>c;
    cin>>sx>>sy;
    cin>>dx>>dy;
    for(int i=1; i<=r; i++)
    {
        cin>>s;
        for(int j=1; j<=c; j++)
        {
            A[i][j]=s[j-1];
            dis[i][j]=99999999999999; // fill dis with inf
        }
    }
    go(sx,sy); // start from source
    if(vis[dx][dy]==0) // not possible
    {
        cout<<-1<<endl;
    }
    else
    {
        cout<<dis[dx][dy]<<endl;   // minimum distance
    }
    return 0;
}


Measured memory_bytes: 13488
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int N;
	cin >> N;
	int B[100];
	rep(i, N - 1) cin >> B[i];

	int kotae = B[0] + B[N - 2];
	rep(i, N - 2) {
		kotae += min(B[i], B[i + 1]);
	}
	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 256
s=list(input())
hcheck=0
hicheck=0
for t in s:
    if t=='h':
        hicheck=0
        hcheck=1
    elif t=='i' and hcheck==1:
        hicheck=1
        hcheck=0
    else:
        hicheck=0
        hcheck=0
        break

if hicheck==1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
def main():
    H, W, K = (int(i) for i in input().split())
    A = [input() for i in range(H)]
    ans = [[-1]*W for _ in range(H)]
    p = 1
    for h in range(H):
        flag = False
        cnt = 0
        for w in range(W):
            if A[h][w] == "#":
                flag = True
                cnt += 1
        upper = p + cnt
        if not(flag):
            continue
        for w in range(W):
            ans[h][w] = p
            if A[h][w] == "#":
                if p + 1 < upper:
                    p += 1
        p = upper
    for h in range(H):
        for w in range(W):
            if ans[h][w] != -1:
                continue
            if h != 0:
                ans[h][w] = ans[h-1][w]
    for h in range(H)[::-1]:
        for w in range(W):
            if ans[h][w] != -1:
                continue
            if h != H-1:
                ans[h][w] = ans[h+1][w]
    for a in ans:
        print(*a)


if __name__ == '__main__':
    main()


Measured memory_bytes: 47068
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define rep(i,n) for(int i=0; i<n; i++)
typedef long long ll;
typedef pair<int,int> P;
const ll MOD = (int)1e9+7;
const ll INF = MOD*MOD;
ll n,m,k,ans;
string s,t;
const ll powll = 1LL<<1;

bool cmp(P a, P b){
  return a.first+a.second < b.first+ b.second;
}

int main(void){
  cin >> n;
  vector<P> p(n);
  rep(i,n) cin >> p[i].first >> p[i].second;
  sort(p.begin(),p.end(),cmp);

  ans = 0; int left = p[0].first + p[0].second;
  rep(i,n-1){
    if(left > p[i+1].first-p[i+1].second){
      ans++;
    }else{
      left =  p[i+1].first + p[i+1].second;
    }
  }
  cout << n - ans << "\n";
}

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

#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))
#define X first
#define Y second

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vl = vector<ll>;
using vs = vector<string>;

constexpr int MOD = int(1e9 + 7);
constexpr int INF = int(1e9 + 1);
constexpr ll LLINF = ll(4 * 1e18 + 1);
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1, 0};

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << fixed << setprecision(10);
	int n, k;
	cin >> n >> k;
	vector<int> h(n);
	for(int i = 0; i < n; ++i){
		cin >> h[i];
	}
	sort(begin(h), end(h));
	int mi = INF;
	for(int i = 0; i < n - k + 1; ++i){
		mi = min(mi, h[i + k - 1] - h[i]);
	}
	cout << mi << "\n";
	return 0;
}


Measured memory_bytes: 892
#include <iostream>
#include <string>
using namespace std;
int L[1001][1001];
int main(){
  string a,b;
  cin >> a;
  cin >> b;

  for(int i=0;i<=a.size();++i) L[i][0]=i;
  for(int i=0;i<=b.size();++i) L[0][i]=i;
  
  for(int i=1;i<=a.size();++i){
    for(int j=1;j<=b.size();++j){
      int k=0;
      if(a[i-1]==b[j-1]) k=0;
      else k=1;
      L[i][j]=min( L[i-1][j]+1, min( L[i][j-1]+1, L[i-1][j-1]+k ) );
    }
  }
  cout << L[a.size()][b.size()] << endl;
}

Measured memory_bytes: 5096
package main
import (
  "bufio"
  "os"
  "strconv"
  "strings"
  "fmt"
)

const p = 1000000007

func Solve() {
  var N, K int
  NextInt(&N, &K)
  P := make([]int, 0)
  for n := 1; n <= N; n *= 2 {
    P = append(P, 1)
  }
  U := make([]int, 0)
  for n, i := N, 0; n > 0; n, i = n / 2, i + 1 {
    if n % 2 == 1 { U = append(U, i) }
  }
  Pow := func(n int) int {
    P[0] = n % p
    for i := range P[1:] {
      P[i + 1] = P[i] * P[i] % p
    }
    x := 1
    for _, u := range U {
      x = x * P[u] % p
    }
    return x
  }
  S := Pow(K)
  X := make([]int, K + 1)
  for k := K; 1 < k; k-- {
    x := MaxInt(K / k, 1)
    X[k] = Pow(x)
    for j := 2 * k; j <= K; j += k { X[k] = (p + X[k] - X[j]) % p }
    S += (k - 1) * X[k] % p
    S %= p
  }
  Write(S)
}

func main() {
  Solve()
  Output()
}

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt(A ...*int) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.Atoi(L[i])
  }
}
func NextIntVec(A *[]int) {
  L := strings.Split(NextLine(), " ")
  (*A) = make([]int, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.Atoi(l)
  }
}
func NextFloat(A ...*float64) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.ParseFloat(L[i], 64)
  }
}
func NextFloatVec(A *[]float64) {
  L := strings.Split(NextLine(), " ")
  (*A) = make([]float64, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.ParseFloat(l, 64)
  }
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func WriteIntVec(A []int) {
  S := make([]string, len(A))
  for i, a := range A {
    S[i] = strconv.Itoa(a)
  }
  Write(strings.Join(S, " "))
}
func Output() {
  _ = writer.Flush()
}
func MaxInt(A ...int) int {
  max := A[0]
  for _, a := range A {
    if max < a { max = a }
  }
  return max
}
func MinInt(A ...int) int {
  min := A[0]
  for _, a := range A {
    if a < min { min = a }
  }
  return min
}
func SumInt(A ...int) int {
  sum := 0
  for _, a := range A {
    sum += a
  }
  return sum
}
func AbsInt(x int) int {
  if x < 0 { x = -x }
  return x
}

Measured memory_bytes: 2656
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<queue>
#include<cstring>
#include<vector>
#define inf 0x3f3f3f3f
using namespace std;
typedef long long LL;
const int maxn = 1e5+5;

vector<int>vec[maxn];
queue<int>q;
int in[maxn],num[maxn];

int main(){	
	int n,m;
	scanf("%d",&n);
	scanf("%d",&m);
	for(int i = 0; i <= n; i++) in[i] = 0;
	int u,v;
	for(int i = 1; i <= m; i++){
		scanf("%d %d",&u,&v);
		vec[u].push_back(v);
		in[v]++;
	}
	for(int i = 1; i <= n; i++){
		if(in[i] == 0) q.push(i);
	}
	int ans = 0;
	while(!q.empty()){
		int now = q.front(); q.pop();
		int len = vec[now].size();
		for(int i = 0; i < len; i++){
			if(--in[vec[now][i]] == 0){
				q.push(vec[now][i]);
				num[vec[now][i]] = num[now] + 1;
				ans = max(ans, num[vec[now][i]]);
			}
		}
	}
	printf("%d",ans);
}

Measured memory_bytes: 6528
# リストの宣言
A = []

# 入力の最初の行に、数列の長さを表す整数 N が与えられます。
# 2 行目に、N 個の整数が空白区切りで与えられます。
LENGTH =int(input())
A = input().split()

# 変数
N = 0
M = LENGTH - 1
CHANGE = 0

# BubbleSort(A)
#  for i = 0 to A.length-1
while N <= LENGTH -1 :
    M = LENGTH - 1
#    print ('N=',N)
#      for j = A.length-1 downto i+1
    while M >= N + 1:
#       print  ('-M=',M)
#          if A[j] < A[j-1]
        if int(A[M]) < int(A[M-1]) :
            tmp = A[M-1]
            A[M-1] = A[M]
            A[M] = tmp
            CHANGE += 1
        M -= 1
    N += 1

print(" ".join(map(str,A)))
print (CHANGE)


Measured memory_bytes: 5600
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;



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


	int a, b;
	cin >> a >> b;
	cout << a * b << "\n";

	return 0;
}


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

int main() {
    int t;
    while (cin >> t, t) {
        int n;
        cin >> n;
        for (int i = 0; i < n; i++) {
            int s, f;
            cin >> s >> f;
            t -= f - s;
        }
        if (t <= 0) {
            cout << "OK" << endl;
        } else {
            cout << t << endl;
        }
    }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define ff first
#define ss second
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define pii pair<int, int>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define sws ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl '\n'
#define teto(a, b) (((a)+(b)-1)/(b))
#define all(x) x.begin(), x.end()
#define forn(i, n) for(int i = 0; i < (int)n; i++)
#define forne(i, a, b) for(int i = a; i <= b; i++)
#define dbg(msg, var) cerr << msg << " " << var << endl;

using namespace std;

const int MAX = 100010;
const int MOD = 123456789;
const int INF = 0x3f3f3f3f;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const ld EPS = 1e-7;

// End Template //

int main()
{sws;

    int n;
    cin >> n;

    ll ans = 0;

    for(int i=1;i<n;i++){
        ans += (n-1)/i;
    }

    cout << ans << endl;




    return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int n,k;
int a[200005];
bool isok(int mid){
	int sum=0;
	for(int i=1;i<=n;i++){
		sum+=(a[i]-1)/mid+1-1;
	}
//	cout<<"mid"<<mid<<" sum:"<<sum<<endl;
	if(sum>k)return false;
	return true;
}
int main(){
	cin>>n>>k;
	int maxn=0;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		maxn=max(a[i],maxn);
	}
	int l=1,r=maxn+1;
	int ans;
	while(l<r){
		int mid=(l+r)>>1;
		if(isok(mid)){
			r=mid;
			ans=mid;
		}else{
			l=mid+1;
		}
	}
	cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 4388
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.StringBuilder
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val s = sc.nextLine()
    val n = s.length
    var ans = 0
    for (i in 0 until n - 1) {
        if (s[i] != s[i + 1]) ans++
    }
    println(ans)
}

fun nextPermutation(array: MutableList<Int>): Boolean {
    var tmp = 0
    for (i in array.size-2 downTo 0) {
        if (array[i] < array[i+1]) {
            for (j in array.size-1 downTo i+1) {
                if (array[j] > array[i]) {
                    tmp = array[i]
                    array[i] = array[j]
                    array[j] = tmp

                    val tmpArray = array.takeLast(array.size-(i+1)).sorted()
                    tmpArray.forEachIndexed { index, e ->
                        array[i+1+index] = e
                    }

                    return true
                }
            }
        }
    }

    return false
}

fun main(args: Array<String>) {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}

Measured memory_bytes: 31012
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

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


	int n, k;
	cin >> n >> k;

	ll res = 0;
	for (int i = 0; i < n; i++)
	{
		int a;
		cin >> a;
		if (a >= k)
		{
			res++;
		}
	}

	cout << res << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main() {
	int n, k;
	static int a[200002] = { 0 };
	static unsigned long long int r[200002] = { 0 };

	scanf("%d%d", &n, &k);

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

	r[k] = 1;
	for (int i = 1; i <= k; i++)
	{
		r[k] += a[k - i];
	}

	for (int i = k + 1; i <= n; i++)
	{
		r[i] = r[i - 1] - a[i - k - 1] + a[i - 1];

		if (r[i] > r[i - 1]) {
			puts("Yes");
		}
		else {
			puts("No");
		}
	}

	return 0;
}


Measured memory_bytes: 3980
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(v) v.begin(), v.end()
    
int main(){
    int n;
    cin >> n;
    vector <long long> h(n);
    rep(i,n) cin >> h[i];

    long long tmp = h[0]-1;
    bool ok = true;
    for(int i=0; i<n; i++){
        if(tmp > h[i]){
            ok = false;
            break;
        }
        else{
            if(tmp == h[i]);
            else{
                tmp = h[i] - 1;
            }
        }
    }

    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;
}


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

const int MAX = 510;
const int INF = 1e9;
const int MOD = 1e9 + 7;
 
int N, K, A[MAX];

bool func(int x){
    vector<int> a;
    rep(i, N) a.push_back(A[i] % x);

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

    vector<int> sum(N + 1, 0);
    rep(i, N) sum[i + 1] = sum[i] + a[i];

    rep(i, N){
        int plus = sum[i] - sum[0];
        int minus = (N - i) * x - (sum[N] - sum[i]);

        if(minus == plus && plus <= K) return true;
    }

    return false;
}

int main(){
    cin >> N >> K;
    rep(i, N) cin >> A[i];

    int sum = accumulate(A, A+N, 0);

    int ans = 1;
    for(int i = 1; i * i <= sum; ++i){
        if(sum % i == 0){
            int x = i;
            if(func(x)) ans = max(ans, x);

            x = sum / i;
            if(func(x)) ans = max(ans, x);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define mod 1000000007
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { cerr << (itr) << " "; }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

int main() {
  int x,y,z;
  cin >> x >> y >> z;
  cout << z << " " << x << " " << y;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		
		int[] t = new int[N + 1];
		int[] x = new int[N + 1];
		int[] y = new int[N + 1];
		
		for(int i = 1; i <= N; i++) {
			t[i] = sc.nextInt();
			x[i] = sc.nextInt();
			y[i] = sc.nextInt();		
		}
		
		int count = 0;
		
		for(int i = 1; i <= N; i++) {
			int check = Math.abs(x[i] - x[i - 1]) + Math.abs(y[i] - y[i - 1]) - (t[i] - t[i - 1]);
			if(check <= 0 && -check % 2 == 0) {
				count++;
			} else {
				System.out.println("No");
				break;
			}
		}
		if(count == N) {
			System.out.println("Yes");
		}
	}
}


Measured memory_bytes: 93364
n = int(input())
h = list(map(int, input().split()))

dp = [0] * n
dp[0] = 0
dp[1] = abs(h[0]-h[1])

for i in range(2, n):
  dp[i] = min(dp[i-1] + abs(h[i] - h[i - 1]), dp[i-2] + abs(h[i] - h[i - 2]))

print(dp[n-1])

Measured memory_bytes: 52208
#include <cstdio>
#include <climits>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <complex>
#include <numeric>
#define _for(i,n) for(int i = 0; i < n; i++)

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

int main() {
  int h,w;
  cin >> h >> w;
  char arr[h][w];
  _for(i,h) _for(j,w) cin >> arr[i][j];
  _for(i,h) _for(j,w) if(arr[i][j]=='.') arr[i][j]='0';
  _for(i,h) _for(j,w) {
    if (arr[i][j]=='#') {
      for(int k=(i==0)?0:-1;i+k<h&&k<=1;k++) for(int l=(j==0)?0:-1;j+l<w&&l<=1;l++) {
        if(arr[i+k][j+l]!='#') arr[i+k][j+l] ++;
      }
    }
  }
  _for(i,h) {
    _for(j,w) {
      cout<<arr[i][j];
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main(){
   int a,b,c;
   std::cin >> a >> b >> c;

   if ((a <= c && b >= c) || (a >= c && b <= c) ){
      std::cout << "Yes" << std::endl; 
   }else{
      std::cout << "No" << std::endl; 
      }
}

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

int main(){
    string s;
    cin>>s;
    long long b=0,sum=0;
    int n=(int)s.size()-1;
    for(int i=n;i>=0;i--){
        if(s[i]=='B'){
            sum+=n;
            sum-=i;
            n--;
        }
    }
    cout<<sum<<endl;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;
typedef vector<vll> vvll;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#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 FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define no cout<<"No"<<endl
#define NO cout<<"NO"<<endl
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  ll n;
  cin>>n;
  n%=10;
  if(n==3)
    cout<<"bon"<<endl;
  else if(n==0||n==1||n==6||n==8)
    cout<<"pon"<<endl;
  else
    cout<<"hon"<<endl;
}



Measured memory_bytes: 3608
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();//整数列Aiの個数を入力
    int [] Ai = new int [N];
    int [] Bi = new int [N-1];
    int sum = 0;
    for(int j=0;j<N-1;j++){
      Bi[j] = scan.nextInt();
    }
    Ai[0] = Bi[0];
    Ai[Ai.length-1] = Bi[Bi.length-1];
    for(int i=1;i<N-1;i++){
      if(Bi[i]>Bi[i-1]){
        Ai[i]=Bi[i-1];
      }
      else if(Bi[i]<Bi[i-1]){
        Ai[i]=Bi[i];
      }
      else{
        Ai[i]=Bi[i];
      }
    }
    for(int x=0;x<N;x++){
      sum += Ai[x];
    }
    System.out.println(sum);
  }
}


Measured memory_bytes: 21844
from sys import exit, setrecursionlimit
from functools import reduce
from itertools import *
from collections import defaultdict
from bisect import bisect

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

setrecursionlimit(1000000)

N = read()
s = []

for i in range(N):
  s.append(read())

S = sum(s)

if S % 10 != 0:
  print(S); exit()

s.sort()

for x in s:
  if x % 10 != 0:
    print(S - x); exit()

print(0)


Measured memory_bytes: 3940
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vec = vector<ll>;
using vect = vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i, n) for (ll i = 0; i < n; i++)
#define Loop(i, m, n) for (ll i = m; i < n; i++)
#define pool(i, n) for (ll i = n; i >= 0; i--)
#define Pool(i, m, n) for (ll i = n; i >= m; i--)
#define mod 1000000007ll
//#define mod 998244353ll
#define flagcount __builtin_popcount
#define flag(x) (1ll << x)
#define flagadd(bit, x) bit |= flag(x)
#define flagpop(bit, x) bit &= ~flag(x)
#define flagon(bit, i) bit &flag(i)
#define flagoff(bit, i) !(bit & (1ll << i))
#define all(v) v.begin(), v.end()
#define low2way(v, x) lower_bound(all(v), x)
#define high2way(v, x) upper_bound(all(v), x)
#define idx_lower(v, x) (distance(v.begin(), low2way(v, x)))  //配列vでx未満の要素数を返す
#define idx_upper(v, x) (distance(v.begin(), high2way(v, x))) //配列vでx以下の要素数を返す
#define idx_lower2(v, x) (v.size() - idx_lower(v, x))         //配列vでx以上の要素数を返す
#define idx_upper2(v, x) (v.size() - idx_upper(v, x))         //配列vでxより大きい要素の数を返す
#define putout(a) cout << a << endl
#define Sum(v) accumulate(all(v), 0ll)
#define gcd(x, y) __gcd(x, y)
ll ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return -1;
}
template <typename T>
T lcm(T x, T y)
{
    T z = gcd(x, y);
    return x * y / z;
}
template <typename T>
bool primejudge(T n)
{
    if (n < 2)
        return false;
    else if (n == 2)
        return true;
    else if (n % 2 == 0)
        return false;
    double sqrtn = sqrt(n);
    for (T i = 3; i < sqrtn + 1; i++)
    {
        if (n % i == 0)
        {
            return false;
        }
        i++;
    }
    return true;
}
//場合によって使い分ける
//const ll dx[4]={1,0,-1,0};
//const ll dy[4]={0,1,0,-1};
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//2次元配列の宣言
//vector<vector<ll>> field(h, vector<ll>(w));
template <typename T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b; // aをbで更新
        return true;
    }
    return false;
}
template <typename T>
bool chmin(T &a, const T &b)
{
    if (a > b)
    {
        a = b; // aをbで更新
        return true;
    }
    return false;
}
int main()
{
    cout << fixed << setprecision(30);
    ll N, T;
    cin >> N >> T;
    vec a(N), b(N);
    loop(i, N) cin >> a[i] >> b[i];
    vector<pair<ll, ll>> pairs(N);
    loop(i, N) pairs[i] = make_pair(a[i], b[i]);
    sort(all(pairs));
    vec A(N), B(N);
    loop(i, N)
    {
        A[i] = pairs[i].first;
        B[i] = pairs[i].second;
    }
    vector<vector<ll>> dp(N + 1, vector<ll>(T));
    //ナップサックdp
    loop(i, N)
    {
        loop(j, T)
        {
            if (j >= A[i])
                chmax(dp[i + 1][j], dp[i][j - A[i]] + B[i]);
            chmax(dp[i + 1][j], dp[i][j]);
        }
    }
    //dp[i][T-1]:1~i番目までの中から選んでT-1以下に時間が収まる時のおいしさの和の最大値
    ll ans = 0;
    loop(i, N - 1)
    {
        chmax(ans, dp[i + 1][T - 1] + B[i + 1]);
    }
    putout(ans);
    return 0;
}


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

int main()
{
    int n;
    cin>>n;
    string s;
    set<string>st;
    for(int i=0;i<n;i++)
    {
        cin>>s;
        st.insert(s);
    }
    cout<<st.size()<<endl;
    return 0;
}






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

int main(){ 
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  ll res = 0;

  while (1) {
    sort(a.begin(), a.end(), greater<ll>());
    if (a[0] < n) break;
    ll x = a[0] / n;
    a[0] %= n;
    for (int i = 1; i < n; i++) a[i] += x;
    res += x;
  }
  cout << res << endl;
  return 0;  
} 

Measured memory_bytes: 256
package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var n int
	Fscan(in, &n)
	switch n % 10 {
	case 2,4,5,7,9:
		Fprintln(out, "hon")
	case 0,1,6,8:
		Fprintln(out, "pon")
	default:
		Fprintln(out, "bon")
	}
}

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


Measured memory_bytes: 1828
// Author :: <Hitesh_Saini>
#include<bits/stdc++.h>

#define __speed() ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#define dbg(x) cout << "--- " << #x << " = " << x << " ---\n";
#define findmax(v) *max_element(v.begin(), v.end())
#define _sum(a) accumulate(a.begin(), a.end(), 0)
#define tt int t;for(cin>>t; t--; )
#define f0(i, n) for(i = 0; i < int(n); i++)
#define f1(i, n) for(i = 1; i<= int(n); i++)
#define all(x) x.begin(), x.end()
#define EB emplace_back
#define PB push_back
#define F first
#define S second
#define endl "\n"

using namespace std;
using mii = map<int, int>;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
const int mod = 1e9+7,mxN = 1e6+5;

template<typename... Args>void print(Args... args){((cout << args << " "), ...);cout << endl;}
ll mod_pow(ll x, ll y){ll res = 1;x = x % mod;while(y>0){if(y&1)res = (res*x) % mod; y = y>>1;x = (x*x) % mod; }return res; }ll mod_inv ( ll n ){ll ans = mod_pow ( n , mod - 2 ) ;return ans ;}ll mul(ll a, ll b){a%=mod, b%=mod;return (a*b)%mod;}ll sub(ll a,ll b){a%=mod, b%=mod;return (a-b+mod)%mod;}ll add(ll a, ll b){a%=mod, b%=mod;return (a+b)%mod;}
bool _prime(ll n){if(n<2)return 0;if(n<4)return 1;if(n%2==0||n%3==0)return 0;for(ll i=5;i*i<=n;i+=6)if(n%i==0||n%(i+2)==0)return 0;return 1;}

/* #include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define iset tree<ll , null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define iof order_of_key
#define findat find_by_order */

int n, cache[mxN], A[mxN];
int f(int pos){
	if(pos<=0)
		return 0;
	if(pos==1)
		return abs(A[0]-A[1]);
	if(cache[pos]!=-1)
		return cache[pos];
	return cache[pos]=min(abs(A[pos]-A[pos-2])+f(pos-2), abs(A[pos]-A[pos-1])+f(pos-1));
}

void solve(){//D
	cin >> n;
	print(n>=30?"Yes":"No");
}

int main(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin); 
		freopen("output.txt", "w", stdout);
	#endif
    __speed();
    solve();
    return 0;
}

Measured memory_bytes: 3624
icase=0
if icase==0:
    n=int(input())  #数値入力 「N」だけの入力のとき
    a=list(map(int, input().split()))
    b=list(map(int, input().split()))
    c=list(map(int, input().split()))
elif icase==1:
    n=2
    a=[1,5]
    b=[2,4]
    c=[3,6]
elif icase==2:
    n=6
    a=[3, 14, 159, 2, 6, 53]
    b=[58, 9, 79, 323, 84, 6]
    c=[2643, 383, 2, 79, 50, 288]
    
a.sort()
b.sort()
c.sort()
   
icnt=0
ast=0
cst=0
for i in range(n):
    if a[n-1]<=b[i]:
        ast=n
#        print("a1:",ast-1,a[ast-1],i,b[i])
    elif a[0]>=b[i]:
        ast=0
#        print("a1:",ast-1,a[ast-1],i,b[i])
    else:
        while a[ast]<b[i] and ast<n-1:
            ast=ast+1
#            print("a2:",ast-1,a[ast-1],i,b[i])
    if b[i]<c[0]:
        cst=0 
    elif b[i]>=c[n-1]:
        cst=n 
#        print("c1:",cst,c[cst],i,b[i])
    else:
        while b[i]>=c[cst] and cst<n-1:
            cst=cst+1
#            print("c2:",cst-1,c[cst-1],i,b[i])
#    print(ast,i,n-cst)
    icnt=icnt+(ast)*(n-cst)
    
print(icnt)

Measured memory_bytes: 22720
n, k = map(int, input().split())
a = list(map(int, input().split()))
num = [[0, 0] for _ in range(n)]
for i in range(n):
    for j in range(n):
        if a[i] > a[j]:
            if i > j:
                num[i][0] += 1
            num[i][1] += 1
s = [i[1] * (k * (k + 1)) // 2 for i in num]
t = [i[0] * k for i in num]
print((sum(s) - sum(t)) % (10**9 + 7))


Measured memory_bytes: 3536
#include <iostream>
#include <algorithm>
#include <vector>
#include <complex>
#include <cmath>
#include <cstdio>
using namespace std;
typedef complex<double> P;

const double eps = 1e-8;

namespace std {
  bool operator <(const P &a, const P &b) {
    if(a.real() != b.real()) return a.real() < b.real();
    return a.imag() < b.imag();
  }
}

double dot(P a, P b) {
  return a.real()*b.real() + a.imag()*b.imag();
}

double cross(P a, P b) {
  return a.real()*b.imag() - a.imag()*b.real();
}

int ccw(P p, P a, P b) {
  a -= p;
  b -= p;
  if(cross(a,b) > eps) return 1;
  if(cross(a,b) < -eps) return -1;
  if(dot(a,b) < -eps) return 2;
  if(norm(b)-norm(a) > eps) return -2;
  return 0;
}

vector<P> convex_hull(vector<P> ps) {
  int n = ps.size(), k = 0;
  sort(ps.begin(), ps.end());
  vector<P> ch(2*n);
  for(int i = 0; i < n; ch[k++] = ps[i++])
    while(k >= 2 && ccw(ch[k-2], ch[k-1], ps[i]) <= 0) --k;
  for(int i = n-2, t = k+1; i >= 0; ch[k++] = ps[i--])
    while(k >= t && ccw(ch[k-2], ch[k-1], ps[i]) <= 0) --k;
  ch.resize(k-1);
  return ch;
}

int main() {
  int n;
  while(scanf("%d", &n) != EOF && n) {
    vector<P> g(n);
    for(int i = 0; i < n; ++i) {
      P &p = g[i];
      scanf("%lf,%lf", &p.real(), &p.imag());
    }
    printf("%d\n", g.size() - convex_hull(g).size());
  }
  return 0;
}

Measured memory_bytes: 1244
#include <iostream>
#include <algorithm>
#include <string.h>

using namespace std;

int a[100000 + 1];
int s[100000 + 1];

int main() {

	int n, k;
	int i, j, l;
	int sum = 0, asus = 0;

	while (true) {

		memset(s, 0, sizeof(s));
		memset(a, 0, sizeof(a));

		cin >> n >> k;
		if (n == 0 && k == 0) return 0;

		for (i = 0; i < n; ++i) cin >> a[i];

		for (i = 0; i < n-k; ++i) {
			for (j = 0; j < k; ++j) {

				sum += a[i + j];
			}
			asus = max(asus, sum);
			sum = 0;
		}

		cout << asus << endl;
	}
}


Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
const long long M = 1000000007;
long long modpow(long long N, long long A) {
    long long ans = 1;
    for (long long i = 0; i < A; i++) {
        ans *= N;
        ans %= M;
    }
    return ans;
}
int main() {
    long long N; cin >> N;
    long long ans = modpow(10, N) + modpow(8, N) - 2 * modpow(9, N);
    ans %= M;
    if (ans < 0) ans += M;
    cout << ans << endl;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define REP(i,n) for(int i = 0;i < (int)(n);i++)
#define RREP(i,n) for(int i = (int)n-1;i >= 0;i--)
#define FOR(i,s,n) for(int i = s;i < (int)n;i++)
#define RFOR(i,s,n) for(int i = (int)n-1;i >= s;i--)
#define ALL(a) a.begin(),a.end()
#define IN(a, x, b) (a<=x && x<b)
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;}
template<class T>istream&operator >>(istream&is,vector<T>&vec){for(T&x:vec)is>>x;return is;}
template<class T>inline void in(T&t){cin>>t;}
template<class T,class... Ts>inline void in(T&t,Ts&...ts){cin>>t;in(ts...);}
template<class T>inline void out(T t){cout<<t<<endl;}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout<<t<<" ";out(ts...);}
template<typename T=int>vector<T>mv(size_t a){return vector<T>(a);}
template<typename T=int,typename... Ts>auto mv(size_t a,Ts... ts){return vector<decltype(mv<T>(ts...))>(a,mv<T>(ts...));}
template<typename T,typename V>typename enable_if<is_class<T>::value==0>::type fill(T&t,const V&v){t=v;}
template<typename T,typename V>typename enable_if<is_class<T>::value!=0>::type fill(T&t,const V&v){for(auto &e:t)fill(e,v);}
constexpr long long INF = 1e18;

signed main(){
	int N,M;
	in(N,M);
	int t = 1ll << M;
	out(t * (M * 1900 + (N - M) * 100));
}

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


using namespace std;


struct edge{int to;int cost;};

vector<edge> tree[100010];

vector< int> d(100010 , -1e9);

bool f;
void bfs(int s){
  queue<int> q;
  q.push(s);
  d[s]=0;
  while(!q.empty()){
    
    int p=q.front();
    
    q.pop();
    for(auto x:tree[p]){
      
      int u=x.to,v=x.cost;
      
      if(d[u]==-1e9){
        d[u]=d[p]+v;
        q.push(u);
      }
      else{
        if(d[u]!=d[p]+v){
          f=false;
        }
      }
    }
  }
}

int main(){
  int n,m;
  
  cin >> n >> m;
  
  for(int i=0;i<m;i++){
    int l,r,d;
    
    cin >> l >> r >> d;
    l--,r--;
    
    tree[l].push_back({r,d});
    tree[r].push_back({l,-d});
  }
  
  f=true;
  for(int i=0;i<n;i++){
    if(d[i]!=-1e9){
      continue;
    }
    bfs(i);
    
    if(!f){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 9344
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#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 <bits/stdc++.h>
#include<queue>
#include <numeric>
#include<stdio.h>
using namespace std;
 
//conversion
//------------------------------------------
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();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 

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

LL lcm(LL a, LL b){
    LL g = gcd(a,b);
    return a/g *b;
}

int main(){
    int A,P;
    cin >> A >> P;
    P+=A*3;
    int num=0;
    while(P>=2){
        P-=2;
        ++num;
    }
    cout << num;
    }

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;

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


static mint bik[200001];
static vector<int> e[200000];
static set<int> mada[200000];
static map<int, int> ev[200000];
static map<int, mint> ep[200000];

int main(){
	bik[0]=1;
	for(int i=1; i<=200000; i++) bik[i]=bik[i-1]*i;

	int n;
	cin>>n;
	rep(i, n-1){
		int a, b;
		cin>>a>>b; a--; b--;
		e[a].push_back(b);
		e[b].push_back(a);
	}

	queue<int> q;
	rep(i, n) if(e[i].size()==1) q.push(i);

	rep(i, n) for(int j : e[i]) mada[i].insert(j);

	while(!q.empty()){
		int v=q.front(); q.pop();
		if(mada[v].size()==1){
			int u=*(mada[v].begin());
			int tv=0;
			mint tp=1, cb=1;
			for(int w : e[v]) if(u!=w){
				tv+=ev[v][w];
				cb*=bik[ev[v][w]];
				tp*=ep[v][w];
			}
			if(mada[u].find(v)!=mada[u].end()){
				ev[u][v]=tv+1;
				ep[u][v]=tp*bik[tv]/cb;
				mada[u].erase(v);
				if(mada[u].size()<=1) q.push(u);
			}
		}
		else if(mada[v].size()==0){
			int tv=0;
			mint tp=1, cb=1;
			for(int w : e[v]){
				tv+=ev[v][w];
				cb*=bik[ev[v][w]];
				tp*=ep[v][w];
			}
			for(int u : e[v]) if(mada[u].find(v)!=mada[u].end()){
				ev[u][v]=1+tv-ev[v][u];
				ep[u][v]=tp/ep[v][u] * (bik[tv-ev[v][u]]/(cb/bik[ev[v][u]]));
				mada[u].erase(v);
				if(mada[u].size()<=1) q.push(u);
			}
		}
	}

	rep(v, n){
		int tv=0;
		mint tp=1, cb=1;
		for(int w : e[v]){
			tv+=ev[v][w];
			cb*=bik[ev[v][w]];
			tp*=ep[v][w];
		}
		mint ans=tp * (bik[tv]/cb);
		cout<<ans<<endl;
	}

	return 0;
}


Measured memory_bytes: 89336
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define inf = 1e9+5;
#define dbg(vari) cerr<<#vari<<" = "<<(vari)<<endl;



void solve(long long N, std::vector<long long> v){
    sort(v.begin(), v.end());
    double res = v[0];
    for (int i = 1; i < N; i++) {
	res = (res+v[i])/2;
    }
    cout << res << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> v(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&v[i]);
    }
    solve(N, std::move(v));
    return 0;
}


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

int main() {
    
    int A, B, C, K, cnt = 0;
    cin >> A >> B >> C >> K;
    
    while (A >= B) { cnt += 1; B *= 2; }
    while (B >= C) { cnt += 1; C *= 2; }
    
    if (cnt <= K) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    
    
    
    return 0;
    
    
    
}


Measured memory_bytes: 3600
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      long a = sc.nextLong();
      long b = sc.nextLong();
      long[] list = new long[n];
      for(int i=0;i<n;i++){
        list[i] = sc.nextInt();
      }
      long count = 0;
      for(int i=0;i<n-1;i++){
        if((list[i+1]-list[i])*a < b ){
          count += (list[i+1]-list[i])*a;
        }else{
          count += b;
        }        
      }
      System.out.println(count);
	}
}

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

int main()
{
    long long a, v, b, w, t;
    cin >> a >> v >> b >> w >> t;
    if (t * (v - w) >= abs(a - b))
    {
        puts("YES");
    }
    else
    {
        puts("NO");
    }
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <cmath>

using namespace std;

int main(){
  int n, k;
  double tmp;

  cin>> n >> k;
  
  tmp=log10(n);
  //cout<< tmp <<endl;
  tmp/=log10(k);
  //cout<< tmp <<endl;

  cout<< (int)floor(tmp+1.0) <<endl;

  return 0;
}


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

int main() {
	char str;
	char s[] = "abcdefghijklmnopqrstuvwxyz";
	
	cin >> str;
	for (int i = 0;i < 26;i++) {
		if (str==s[25]) {
			cout<<"a"<<endl;
			break;
		}
		else if (str==s[i]) {
			cout << s[i + 1] << endl;
			break;
		}
	}
	
}

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

int main()
{
  int h,w;
  for(;cin>>h>>w,h||w;)
    {
      int tmp=999999;
      int x=h,y;
      for(int i=1;i<200;i++)
	for(int j=i+1;j<200;j++)
	  {
	    if(((i*i+j*j > h*h+w*w || h<i) && (i*i+j*j >= h*h+w*w) )&&
	       (i*i+j*j <tmp) ||
	       (i*i+j*j == tmp && x>i))
	      {
		
		tmp=i*i+j*j;
		x=i;
		y=j;
		//	cout<<"tmp:"<<tmp<<" "<<i<<" "<<j<<endl;
	      }
	    
	  }
      cout<<x<<" "<<y<<endl;
    }
}

Measured memory_bytes: 1160
#include<stdio.h>
#include<string.h>
int main()
{
  char s[5];
  char s1[5]="BBB";
  char s2[5]="AAA";
  scanf("%s",s);
  if((strcmp(s,s2)==0)||(strcmp(s,s1)==0))
  {
    printf("No");
  }
  else
  {
    printf("Yes");
  }
  return 0;
}

Measured memory_bytes: 128
package main

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

var sc = bufio.NewScanner(os.Stdin)

const inf = 1 << 60
const mod int = 1e9 + 7

func ri() (n int) {
	sc.Scan()
	for _, v := range sc.Bytes() {
		n = n*10 + int(v-48)
	}
	return
}

type pair struct{ cost, limit int }

type byLimit []pair

func (p byLimit) Len() int           { return len(p) }
func (p byLimit) Swap(i, j int)      { p[i], p[j] = p[j], p[i] }
func (p byLimit) Less(i, j int) bool { return p[i].limit < p[j].limit }

func main() {
	sc.Split(bufio.ScanWords)
	n := ri()

	a := make([]pair, n)
	for i := 0; i < n; i++ {
		a[i] = pair{cost: ri(), limit: ri()}
	}
	sort.Sort(byLimit(a))

	time := 0
	ok := true
	for _, aa := range a {
		time += aa.cost
		if time > aa.limit {
			ok = false
			break
		}
	}

	if ok {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 4352
N=int(input())
a=list(map(int,input().split()))
x = 0
i = 0
while i<N-1:
    j=1
    while i<N-1 and a[i]==a[i+1]:
        j=j+1
        i=i+1
    i=i+1
    if j%2==1:
        x=x+(j-1)//2
    else:
        x=x+j//2
print(x)

Measured memory_bytes: 3060
using System;

namespace Ex160424_1{
    public class Program{
        public static void Main(string[] args){
            var input = Console.ReadLine().Split(' ');
            var a = int.Parse(input[0]);
            var b = int.Parse(input[1]);
            var c = int.Parse(input[2]);

            var cnt = 0;
            for(var i = a; i <= b; i++){
                if(c % i == 0) cnt++;
            }
            Console.WriteLine(cnt);
        }
    }
}

Measured memory_bytes: 9088
#include<stdio.h>
#define NIL -1
void setDepth(int ,int );
int setHeight(int );
int getSibling(int );

typedef struct{
  int p,l,r;/* 親、左、右 */
}Node;

Node T[10000];
int n,D[10000],H[10000]; /* D：深さ、H：高さ*/

int main()
{
  int i,v,l,r;
  int root=0;
  int degree;
  
  scanf("%d",&n);

  for(i=0;i<n;i++){
    T[i].p = NIL;
  }

  for(i=0;i<n;i++){
    scanf("%d%d%d",&v,&l,&r);
    T[v].l=l;
    T[v].r=r;
    if(l!=NIL) T[l].p = v;
    if(r!=NIL) T[r].p = v;
  }

  for(i=0;i<n;i++){
    if(T[i].p == NIL) root = i;
  }
  setDepth(root,0);
  setHeight(root);

  for(i=0;i<n;i++){
    printf("node %d: ",i); /* 節点番号 */ 
    printf("parent = %d, ",T[i].p); /* 親 */ 
    printf("sibling = %d, ",getSibling(i)); /* 兄弟 */

    degree = 0; // 子を０に初期化
    if(T[i].l != NIL) degree++; //左がいたら子としてカウント
    if(T[i].r != NIL) degree++; //右がいたら子としてカウント
    printf("degree = %d, ",degree);/* 子の数  */
    
    printf("depth = %d, ",D[i]); /* 深さ */ 
    printf("height = %d, ",H[i]); /* 高さ */

    if(T[i].p == NIL) printf("root\n");
    else if(T[i].l == NIL && T[i].r == NIL) printf("leaf\n");
    else printf("internal node\n");
  }
  return 0;
}

/* 深さ調べ */ 
void setDepth(int u,int p){
  if(u == NIL) return;
 D[u]=p;
 setDepth(T[u].l,p+1);
 setDepth(T[u].r,p+1);
}

/* 高さ調べ */
int setHeight(int u){
  int h1=0,h2=0;
  if(T[u].l != NIL) h1 = setHeight(T[u].l)+1;
   if(T[u].r != NIL) h2 = setHeight(T[u].r)+1;
   if(h1>h2) H[u] = h1;
   else H[u] = h2;
   return H[u];
}

/* 兄弟調べ */
int getSibling(int u){
  if(T[u].p == NIL) return NIL;
  if(T[T[u].p].l != u && T[T[u].p].l != NIL) return T[T[u].p].l;
  if(T[T[u].p].r != u && T[T[u].p].r != NIL) return T[T[u].p].r;
  return NIL;
}
  

  



Measured memory_bytes: 2108
x = int(input())
if(400 <= x <= 599):
  print(8)
elif(600 <= x <= 799):
  print(7)
elif(800 <= x <= 999):
  print(6)
elif(1000 <= x <= 1199):
  print(5)
elif(1200 <= x <= 1399):
  print(4)
elif(1400 <= x <= 1599):
  print(3)
elif(1600 <= x <= 1799):
  print(2)
else:
  print(1)

Measured memory_bytes: 9048