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

int main(void){
    int n;
    cin >> n;
    vector<int> A(n);
    for (int i = 0; i < n; i++) cin >> A[i];
    sort(A.begin(), A.end(), greater<int>());
    int sum = 0;
    for (int i = 1; i < n; i++) sum += A[i];
    if (sum > A[0]) cout << "Yes" << endl;
    else cout << "No" << endl;
    

}

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

int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(max(a,c)-min(a,c)<=d  ||(max(a,b)-min(a,b)<=d &&max(b,c)-min(b,c)<=d)){
    cout<<"Yes"<<endl;
  }
  else  {
    cout<<"No"<<endl;
  }
  
}


Measured memory_bytes: 256
function Main(input) {
  var inputs = input.split("\n");
  var n = parseInt(inputs[0], 10);
  var a = inputs[1].split(" ").map(e => parseInt(e, 10));
  var max = 0;
  var min = 1000000001;
  for(var i = 0; i < n; i++) {
    max = a[i] > max ? a[i]:max;
    min = a[i] < min ? a[i]:min;
  }
  console.log(max - min);
}

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

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

int main()
{
    int N, K;
    cin >> N >> K;
    vector<int> fruits(N);
    for (int i=0; i<N; i++) cin >> fruits[i];
    sort(fruits.begin(), fruits.end());
    int sum=0;
    for (int i=0; i<K; i++) sum+=fruits[i];
    cout << sum << endl;
}

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

int main(){
    int n;
    cin >> n;
    int p[n];
    for(int i=0;i<n;i++){
        cin >> p[i];
    }
    int ans = 0;
    for(int i=1;i<(n-1);i++){
        if(
            (p[i-1] < p[i] && p[i] < p[i+1])||
            (p[i-1] > p[i] && p[i] > p[i+1])
        ){
            ans ++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
###template###
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt, ceil, floor
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
import heapq
INF = float("inf")
sys.setrecursionlimit(10**7)
# 4近傍（右, 下, 左, 上）
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
def inside(y: int, x: int, H: int, W: int) -> bool: return 0 <= y < H and 0 <= x < W
def mi(): return map(int, input().split())
def ii(): return int(input())
###template###

N = ii()
As = list(mi())
minusAs = [-a for a in As]

#下準備。左側0～N-1, 右側2N～3N-1のN要素のheapqを作っておく
#leftQは大きいのを残したい（最小値を取り除く）、rightQは小さいのを残したい（最大値を取り除く）ので、leftQはそのままの配列、rightQは符号反転したminusAsを使用する
leftQ = As[:N]
rightQ = minusAs[-N:]
heapq.heapify(leftQ)
heapq.heapify(rightQ)

#この配列のidxは、右端（左端）から何番目(0スタート)の区切りを採用するかを表す。あとで突き合わせる時に添字でバグらせないよう注意
leftsum = [0]*(N+1)
rightsum = [0]*(N+1) #どうせ最後に引くんだから、マイナスのまま入れちゃう
#つまり、最後に最小値を求める時は、逆に「最も大きい＝マイナス幅が小さいsum」を求めることになるので注意

#初期値はもう入れておく
leftsum[0] = sum(leftQ)
rightsum[0] = sum(rightQ)

for i in range(N, 2*N): #左端（右端）から最低N個（N-1まで）は済んでいる。残りはNまで～2N-1まで)
  #iがNのとき、左側は[:N], 右側は[-N:]
  #iが2Nのとき、左側は[0:2N], 右側は[-2N:]
  if leftQ[0] < As[i]: #大きいのを残したいので、最小値のが小さければ入れ替える
    #入れ替える
    nowmin = heapq.heappop(leftQ)
    leftsum[i-N+1] = leftsum[i-N] - nowmin + As[i]
    heapq.heappush(leftQ,As[i])
  else: leftsum[i-N+1] = leftsum[i-N] #そうでなければ入れ替えない
  if rightQ[0] < minusAs[-1-i]: #小さいのを残したいので、マイナス幅が大きければ入れ替える
    nowmax = heapq.heappop(rightQ)
    rightsum[i-N+1] = rightsum[i-N] - nowmax + minusAs[-1-i]
    heapq.heappush(rightQ,minusAs[-1-i])
  else: rightsum[i-N+1] = rightsum[i-N] #そうでなければ入れ替えない

ans = -INF
for lsum, rsum in zip(leftsum, rightsum[::-1]):
#  print(ans, lsum, rsum)
  ans = max(ans, lsum+rsum)

print(ans)


Measured memory_bytes: 126408
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
using namespace std;

typedef long long LL;
const int MAX = 1e5+10;
LL N;
LL a[MAX], b[MAX], c[MAX];

int main()
{
	cin >> N;
	for (int i = 1; i <= N; i++)
		cin >> a[i];
	for (int i = 1; i <= N; i++)
		cin >> b[i];
	for (int i = 1; i <= N; i++)
		cin >> c[i];
	sort(a + 1, a + 1 + N), sort(b + 1, b + 1 + N), sort(c + 1, c + 1 + N);

	LL sum = 0;
	LL ai = 0, ci = 0;
	for (int i = 1; i <= N; i++) 
	{
		while (a[ai + 1]<b[i] && ai + 1 <= N)
			ai++;
		while (c[ci + 1] <=b[i] && ci + 1 <= N)
			ci++;
		sum += ai * (N-ci);
	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 2560
import sys
readlines = sys.stdin.readlines
write = sys.stdout.write

def solve():
    for line in readlines():
        N, S = map(int, line.split())
        memo = {}
        def dfs(i, state, rest):
            if i == N:
                return +(rest == 0)
            if rest < 0:
                return 0
            key = (state, rest)
            if key in memo:
                return memo[key]
            r = 0
            for k in range(10):
                if state & (1 << k):
                    continue
                r += dfs(i+1, state | (1 << k), rest - k*(i+1))
            memo[key] = r
            return r
        write("%d\n" % dfs(0, 0, S))
solve()


Measured memory_bytes: 12884
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) (x).begin(), (x).end()
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
  #define debug(x) cerr << #x " => " << (x) << endl
#else
  #define debug(x) 0
#endif
using lint = long long;
constexpr int    INF  = 1 << 29;
constexpr lint   INFL = 1LL << 61;
constexpr int    MOD  = (int)1e9 + 7;
constexpr double EPS  = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

int main(void) {
  int n;
  cin >> n;
  vector<int> h(n);
  rep (i, n) cin >> h[i];
  int sum = 0, maxi = 0;
  rep (i, n) {
    if (h[i] >= maxi) {
      maxi = h[i];
      ++sum;
    }
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvld;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

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

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

    int N;
    cin >> N;

    vll x(N), y(N), h(N);
    rep(i, N) cin >> x[i] >> y[i] >> h[i];

    int pos = -1;
    int count = 0;
    rep(i, N)
    {
        if (h[i] == 0) continue;
        pos = i;
        count++;
    }

    if (count == 1)
    {
        cout << x[pos] << " " << y[pos] << " " << h[pos] << endl;
        return 0;
    }

    reple(CX, 0, 100)
    {
        reple(CY, 0, 100)
        {
            bool flg = true;
            ll H = -1;
            rep(i, N)
            {
                if (h[i] == 0) continue;

                //maxを無視したら
                //h[i] = H - abs(x[i] - CX) - abs(y[i] - CY)
                //なので、
                //H = h[i] + abs(x[i] - CX) + abs(y[i] - CY)

                ll tmp = h[i] + abs(x[i] - CX) + abs(y[i] - CY);

                if (H >= 0 && H != tmp)
                {
                    flg = false;
                    break;
                }
                H = tmp;
            }

            if (flg)
            {
                cout << CX << " " << CY << " " << H << endl;
                return 0;
            }
        }
    }

    
    return 0;
}

Measured memory_bytes: 3608
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Streamline solver = new Streamline();
        solver.solve(1, in, out);
        out.close();
    }

    static class Streamline {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();
            int[] x = new int[m];
            int[] distance = new int[m - 1];

            for (int i = 0; i < m; i++) {
                x[i] = in.nextInt();
            }
            Arrays.sort(x);

            for (int i = 1; i < m; i++) {
                distance[i - 1] = Math.abs(x[i] - x[i - 1]);
            }
            Arrays.sort(distance);

            long result = 0;
            for (int i = 0; i < distance.length - n + 1; i++) {
                result += distance[i];
            }
            out.print(result);

        }

    }
}



Measured memory_bytes: 60516
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <tuple>
#include <utility>
#include <set>
#include <numeric>
#include <queue>
#include <sstream>
#include <map>
#include <unordered_map>
#include <cmath>
using namespace std;
using LLI = long long int;

#define Rep(i, N) for (int i = 0; i < N; i++)


int main(int argc, char *argv[])
{
    int N, Q;
    cin >> N >> Q;

    // node iの親はnode r[i][0]またはr[i][1]
    vector<vector<int>> r(N);
    Rep(i, N-1) {
        int a, b;
        cin >> a >> b;
        r[a-1].push_back(b-1);
        r[b-1].push_back(a-1);
    }

    vector<int> P(N);
    Rep(i, Q) {
        int p, x;
        cin >> p >> x;
        P[p-1] += x;
    }

    vector<int> S(N, -1);
    S[0] = P[0];

    queue<pair<int, int>> q; // cur_value, node
    
    q.push(make_pair(P[0], 0));
    while (!q.empty()) {
        pair<int, int> p = q.front();
        q.pop();

        for (int j : r[p.second]) {
            if (S[j] == -1) {
                S[j] = p.first + P[j];
                q.push(make_pair(S[j], j));
            }
        }
    }

    Rep(i, N-1) {
        cout << S[i] << " ";
    }
    cout << S[N-1] << endl;
}

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

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll n,m,i,pr,sol[100005]={0},p[100005]={0},pen=0,ans=0;
	string s;
	cin>>n>>m;
	for(i=0;i<m;i++) {
		cin>>pr>>s;
		if(sol[pr]==0) {
			if(s=="WA" ) p[pr]++;
			else {
				sol[pr]=1;
				pen+=p[pr];
			}
		}
	}
	for(i=1;i<=n;i++) ans+=sol[i];
	cout<<ans<<" "<<pen;
}

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

using namespace std;
using i32 = std::int_fast32_t;
using u64 = std::uint_fast64_t;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string A;
  cin >> A;
  u64 N = static_cast<u64>(A.size());
  vector<u64> cnt(26);
  for (u64 i = 0; i < N; i++) {
    cnt[A[i] - 'a']++;
  }
  u64 res = N * (N - 1) / 2;
  for (i32 i = 0; i < 26; i++) {
    res -= cnt[i] * (cnt[i] - 1) / 2;
  }
  cout << res + 1 << '\n';
  return 0;
}


Measured memory_bytes: 720
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)

s = 0
for a_i in a:
    s ^= a_i
# print(s)

c = [(~s) & a_i for a_i in a]
base = []
for c_i in c:
    for base_j in base:
        c_i = min(c_i, c_i ^ base_j)
    if c_i != 0:
        for j in range(len(base)):
            base[j] = min(base[j], base[j] ^ c_i)
        base.append(c_i)
        base.sort(reverse=True)

# print(base)
t = 0
for base_j in base:
    t ^= base_j
# print(t)
ans = s + t * 2
print(ans)


Measured memory_bytes: 21820
n,m = map(int,input().split())
li1 = list(map(int,input().split()))

li2 = [0] * (n+1)
memo = {}
ans = 0

for i in range(n):
    li2[i+1] = li2[i] + li1[i]

for i in range(n+1):
    li2[i] %= m
    if li2[i] in memo:
        memo[li2[i]] += 1
    else:
        memo[li2[i]] = 1

for i in memo.values():
    ans +=  i * (i-1) / 2

print(int(ans))


Measured memory_bytes: 16544
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
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; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

int main() {
  ll n, k;
  cin >> n >> k;
  M m;
  rep(i, k) {
    ll d;
    cin >>d;
    rep(i, d) {
      ll a;
      cin >> a;
      a--;
      m[a]++;
    }
  }
  ll ans = 0;

  rep(i, n) {
    if (m[i] == 0) ans++;
  }

  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
#define GETINT(x) int (x); cin >> (x);
#define FOR(i, N) for(int i = 0; i < (N); (i)++)
#define RET cout << endl;
constexpr int _10e(int n) { return n == 0 ? 1 : 10 * _10e(n - 1); }

int main() {
    GETINT(N);
    GETINT(T);
    GETINT(A);

    int H[_10e(5)];
    FOR(i, N) cin >> H[i];

    int besti = 0;
    double bestd = 10000;
    FOR(i, N) {
        double t = (double)T - (double)H[i] * 0.006;
        double d = fabs(t - (double)A);
        if (d < bestd) {
            besti = i;
            bestd = d;
        }
    }
    cout << besti + 1 << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int x[105],i,j,n,r;
	for(;~scanf("%d",&n),n;)
	{
		for(i=r=0;i<n;i++)
			scanf("%d",&x[i]);
		for(i=n-1;i;i--)
			for(j=0;j<i;j++)
				x[j+1]<x[j]?x[j]^=x[j+1]^=x[j]^=x[j+1],r++:0;
		printf("%d\n",r);
	}
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

const int mod = 1000000007;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}

    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 {
        mint res(*this);
        return res += a;
    }

    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }

    mint operator*(const mint a) const {
        mint res(*this);
        return res *= 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 {
        mint res(*this);
        return res /= a;
    }

    friend std::istream &operator>>(std::istream &in, mint &o) {
        ll a;
        in >> a;
        o = a;
        return in;
    }

    friend std::ostream &operator<<(std::ostream &out, const mint &o) {
        out << o.x;
        return out;
    }

};

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

    vector<mint> counts(k + 1, 0);

    rep(i, k + 1) {
        if (i <= 1) continue;
        counts[i] = k / i;
    }


    vector<mint> dp(k + 1);
    for (int i = k; i >= 2; i--) {
        mint all = counts[i].pow(n);

        mint sub = 0;
        for (int j = 2; j * i <= k; j++) {
            sub += dp[i * j];
        }
        mint now = all - sub;
        dp[i] = now;
    }

    mint ans = 0;
    for (int i = 2; i <= k; i++) {
        ans += (dp[i] * i);
    }

    mint one = mint(k).pow(n) - accumulate(dp.begin(), dp.end(), mint(0));

    cout << ans + one << endl;

}



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

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



ll h,w,n;


#define rep(i,s,e) for(int i = (s);i <= (e);i++)

int main()
{
	vector<P> point;
	cin >> h >> w >> n;
	rep(i,0,n - 1)
	{
		ll a,b;
		cin >> a >> b;

		rep(x,max(1LL,a - 2),min(h - 2,a))
		{
			rep(y,max(1LL,b - 2),min(w - 2,b))
			{
				point.push_back(P(x,y));
			}
		}
	}



	vector<int> ans(10,0);
	ll cou = 1;
	ll res = 0;
	if(!point.empty())
	{
		sort(point.begin(),point.end());
		rep(i,1,point.size() - 1)
		{
			if(point[i - 1].first == point[i].first && point[i - 1].second == point[i].second)
			{
				cou++;
			}
			else
			{
				ans[cou]++;
				res++;
				cou = 1;
			}
		}
		ans[cou]++;
		res++;
	}
	ll all = (h - 2) * (w - 2);
	cout << all - res << endl;
	rep(i,1,9)
	{
		cout << ans[i] << endl;
	}
	return 0;
}


	


Measured memory_bytes: 10476
#include <bits/stdc++.h>
        using namespace std;
        int main(){
			long long n,c,k,t[100005],ans=0;
			cin>>n>>c>>k;
			for(int i=0;i<n;i++){
				cin>>t[i];
			}
			sort(t,t+n);
			int time=0,now=1;
			for(int i=1;i<n;i++){
				if(now==c){
					ans++;
					now=0;
					time=i;
				}
				if(t[time]+k<t[i]){
					ans++;
					now=0;
					time=i;
				}
				now++;
			}
			ans++;
			cout<<ans<<endl;
    		return(0);
        }

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	int date;
	cin>>s;
	if(s=="MON")
		date=1;
	else if(s=="TUE")
		date=2;
	else if(s=="WED")
		date=3;
	else if(s=="THU")
		date=4;
	else if(s=="SAT")
		date=6;
	else if(s=="FRI")
		date=5;
	else if(s=="SUN")
		date=0;
	cout<<7-date;
	return 0;
}

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

#define CIN_ONLY if(1)
struct cww{cww(){
    CIN_ONLY{
        ios::sync_with_stdio(false);cin.tie(0);
    }
}}star;
#ifdef BTK
#define DEBUG if(1)
#else
#define DEBUG if(0)
#endif

#define fin "\n"
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l,T r)
{bool a=l>r;if(a)l=r;return a;}
template <typename T>inline bool chmax(T &l,T r)
{bool a=l<r;if(a)l=r;return a;}
template <typename T>
istream& operator>>(istream &is,vector<T> &v){
    for(auto &it:v)is>>it;
    return is;
}
    
int main(){
    LL Q,H,S,D,N;
    cin>>Q>>H>>S>>D>>N;
    N*=4;
    H=min({H,Q*2});
    S=min({S,H*2,Q*4});
    D=min({D,S*2,H*4,Q*8});
    LL ret=0;
    ret+=(N/8)*D;N-=(N/8)*8;
    ret+=(N/4)*S;N-=(N/4)*4;
    ret+=(N/2)*H;N-=(N/2)*2;
    ret+=(N/1)*Q;N-=(N/1)*1;
    cout<<ret<<endl;
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

#define INF 1<<30
#define LINF 1ll<<60ll
#define MOD 1000000007
#define pb(a) push_back(a)

#define _overload3(_1,_2,_3,_4,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a, i##_len=(b); i<i##_len; ++i)
#define _repis(i,a,b,s) for(int i=a, i##_len(b); i<i##_len; i+=s)
#define REP(...) _overload3(__VA_ARGS__,_repis,_repi,_rep,)(__VA_ARGS__)

#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REPARR(i, v) for(int i = 0;i < sz(v);++i)

#define all(vec) (vec.begin()),(vec.end())
#define sz(x) ((int)(x).size())
#define bit(n) (1ll<<(n))

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(a>b){a=b;return true;}return false;}

#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"possible":"impossible")<<endl
#define Poss(n) cout<<((n)?"Possible":"Impossible")<<endl
#define POSS(n) cout<<((n)?"POSSIBLE":"IMPOSSIBLE")<<endl



int main(){
    int a,b,h;
    cin>>a>>b>>h;
    cout<<(a+b)*h/2<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    int a; cin>>a;
    int ans=a+a*a+a*a*a;
    cout<<ans<<endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
int main() {
    string S;
    cin >> S;
    
    if(S.at(2) == S.at(3) && S.at(4) == S.at(5)){
        cout << "Yes" << endl;
    }
    
    else{
        cout << "No" << endl;
    }
    
}

Measured memory_bytes: 3636
N,M=list(map(int,input().split()))

path=[]
for i in range(M):
    a,b=list(map(int,input().split()))
    path.append([a-1,b-1])
    
class UnionFind():
    #負の値はルートで集合の個数
    #正の値は次の要素を返す
    def __init__(self,size):
        self.table = [-1 for _  in range(size)]
        self.member_num = [1 for _ in range(size)]

    #集合の代表を求める
    def find(self,x):
        while self.table[x] >= 0:
            #根に来た時,self.table[根のindex]は負の値なのでx = 根のindexで値が返される。
            x = self.table[x]
        return x

    #併合
    def union(self,x,y):
        s1 = self.find(x)#根のindex,table[s1]がグラフの高さ
        s2 = self.find(y)
        m1=self.member_num[s1]
        m2=self.member_num[s2]
        if s1 != s2:#根が異なる場合
            if m1 != m2:#グラフの高さが異なる場合
                if m1 < m2:
                    self.table[s1] = s2
                    self.member_num[s2]=m1+m2
                    return [m1,m2]
                else:
                    self.table[s2] = s1
                    self.member_num[s1]=m1+m2
                    return [m1,m2]
            else:
                #グラフの長さが同じ場合,どちらを根にしても変わらない
                #その際,グラフが1長くなることを考慮する
                self.table[s1] = -1
                self.table[s2] = s1
                self.member_num[s1] = m1+m2
                return [m1,m2]
        return [0,0]
    
uf=UnionFind(N)

path=path[::-1]
count = 0
ans = [N*(N-1)//2]
for i in range(M):
    a,b=path[i]
    m1,m2 = uf.union(a,b)
    count+=m1*m2
    ans.append(N*(N-1)//2 - count)

ans=ans[:-1]
ans=ans[::-1]

for i in range(M):
    print(ans[i])

Measured memory_bytes: 27448
N = int(input())
Ds = [list(map(int, input().split())) for _ in range(N)]

count = 0
for D in Ds:
    if D[0] == D[1]:
        count+=1
        if count == 3:
            break
    else:
        count = 0

if count == 3:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 62348
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
    int N, i, ans, min, max;
    int answers[10010];
    bool hid = false;
    string S[10010];
    string T;

    cin >> N;

    for (i = 0; i < N; i++)
    {
        cin >> S[i];
        hid = (S[i].find("?") != string::npos);
    }

    cin >> T;

    ans = 0;

    if (hid)
    {

        min = 0, max = N;

        for (i = 0; i < N; i++)
        {
            string tmp = S[i];
            replace(tmp.begin(), tmp.end(), '?', 'a');
            if (tmp > T)
                max--;

            tmp = S[i];
            replace(tmp.begin(), tmp.end(), '?', 'z');
            if (T > tmp)
                min++;
        }

        for (i = min; i <= max; i++)
        {
            cout << i + 1;
            if (i < max)
                cout << " ";
        }

        cout << endl;
    }
    else
    {
        sort(S, S + N);

        for (i = 0; i < N; i++)
        {
            if (S[i] == T ||
                (S[i] > T && (T >= S[i - 1] || i == 0)))
            {
                answers[ans] = i;
                ans++;
            }
        }

        if (S[N - 1] == T)
        {
            answers[ans] = N;
            ans++;
        }

        for (i = 0; i < ans; i++)
        {
            cout << answers[i] + 1;
            if (i < ans - 1)
                cout << " ";
        }
        cout << endl;
    }

    return 0;
}

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

using namespace std;
typedef long long ll;
const int MAXN = 200100;

int N, M;
string s, t;
int nval[MAXN][26];

int main()
{
    ios_base::sync_with_stdio(0);
    
    cin >> s >> t;
    N = s.length();
    M = t.length();

    s += s;
    for (int i = 0; i < 26; i++)
        nval[2*N][i] = -1;
    for (int i = 2 * N - 1; i >= 0; i--)
    {
        for (int j = 0; j < 26; j++)
            nval[i][j] = nval[i+1][j];
        nval[i][s[i]-'a'] = i;
    }

    ll cloc = 0;
    for (int i = 0; i < M; i++)
    {
        int cv = t[i] - 'a';
        int cpos = cloc % N;
        if (nval[cpos][cv] == -1)
        {
            cloc = -1;
            break;
        }
        cloc += nval[cpos][cv] - cpos + 1;
    }
    cout << cloc << "\n";
}

Measured memory_bytes: 20972
//
// Created by Myabu on 2020/01/12.
//

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <math.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <numeric>

using namespace std;


int main(void){
    int A, B, C;

    cin>>A>>B>>C;

    cout<<max(max(10*A+B+C, A+10*B+C), A+B+C*10)<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define X ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FIXED_FLOAT(x) std::fixed <<std::setprecision(2)<<(x)


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif


// long long p = 1e9+7;

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<bool> VB;

typedef pair<ll, ll> pi;
typedef unordered_map<ll, ll> UMP;
#define FOR(i,b) for(i=0;i<b;i++)
#define pb push_back
// typedef  unordered_set<ll>;


void printa(VI &x,ll n){
    ll i;
    FOR(i, n){
        cout<<x[i]<<" ";
    }
    cout<<endl;
}


/////GLOABLS VARS
ll MOD = 1e9+7;
ll gmx = 2e6+7;
ll mod = 1e9+7;
VL fact(gmx, 1);
//////FUNCTIONS
// ll pow(ll val, ll deg)
// {
//     if (!deg)
//         return 1 % mod;
//     if (deg & 1)
//         return pow(val, deg - 1) * val % mod;
//     ll res = pow(val, deg >> 1);
//     return (res * res) % mod;
// }
ll powm(ll a, ll p) {
    ll res = 1;
    while(p) {
        if(p & 1) {res = (res * a) % mod;}
        p /= 2;
        a = (a * a) % mod;
    }
    return res;
}
ll inv(ll r){
    return powm(r, MOD-2)%MOD;
}
ll nCr(ll n, ll r){
    ll tmp = fact[n-r]*fact[r];
    tmp = tmp%MOD;
	return (fact[n]*inv(tmp))%MOD;
}

// ll mx = 1e5+7;
int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
        #define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
    #endif
    fact[0] = 1;
    for(ll i=1;i<gmx;i++){
    	fact[i] = (fact[i-1]*i)%MOD;
    }
    ll k;
    string s;
    cin>>k;
    cin>>s;
    ll n = s.length();
    ll ans=0;
    // debug(fact[5], nCr(3,0), pow(25,33));
    for(ll i=0;i<n;i++){
    	ll tmp = nCr(n+k, i)*powm(25, n+k-i);
    	tmp = tmp%MOD;
    	ans+=tmp;
        // debug(ans, nCr(n+k, i),pow(25, n+k-i));
    	ans%=MOD;
    }
    ll a = powm(26, n+k)%MOD;
    ans = a-ans;
    while (ans < 0) ans += MOD;
    cout<<ans;

}

Measured memory_bytes: 20976
#include<iostream>
#include<string>
#include<cstring>
#include <cstdio>
#include<utility>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<bitset>
#include<queue>
#include<stack>
#include<set>
#include <limits>
#include <climits>
#include <numeric>
#include <cassert>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<int>VI;
typedef pair<int,int>P;
typedef pair<double,double>P_D;
//const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define reprev(i, n) for (ll i = (ll)n - 1; i >= 0; i--)
#define ALL(a)  (a).begin(),(a).end()
#define C_MAX(a, b) ((a)>(b)?(a):(b))
#define fi first
#define se second
#define MAX 100100//5
#define MAX_N 200100
#define MAX_B 1001001//6
#define MAX_S 10010010//7
#define SENTINEL 2000000000//9
#define NIL -1
#define MOD 1000000007
#define INF 1 << 29
#define INFTY 1000000000000000000LL
#define MAX_INT INT_MAX

int main(){
    int n,m;cin>>n>>m;
    map<int,int,std::greater<int>>M;
    rep(i,n){
        int t;cin>>t;
        M[t]++;
    }
    rep(i,m){
        int s,u;cin>>s>>u;
        M[u]+=s;
    }
    ll ans=0;
    auto it=M.begin();
    rep(i,n){
        ans+=it->fi;
        it->se--;
        if(it->se<=0)it++;
    }
    
    cout<<ans<<endl;
}

Measured memory_bytes: 9600
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <map>
#define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
#define INF numeric_limits<double>::infinity()
constexpr long MOD = 1e9 + 7;
using namespace std;

long color[202020];
vector<long> adj[202020];

bool dfs(long n, long c){
    color[n] = c;
    for (long i: adj[n]) {
        if(color[i] == c) return false;
        else if(color[i] == 0 && !dfs(i, -c)) return false;
    }
    return true;
}

int main() {
    long n, m, a, b;
    cin >> n >> m;
    color[0] = 1;
    
    REP(i,m) {
        cin >> a >> b;
        adj[a-1].push_back(b-1);
        adj[b-1].push_back(a-1);
    }
    
    bool fl = dfs(0,1);
    if (fl) {
        long c = 0;
        REP(i,202020) {
            if (color[i] == 1) c++;
        }
        cout << c * (n - c) - m << endl;
    } else {
        cout << n * (n - 1) / 2 - m << endl;
    }
}


Measured memory_bytes: 10496
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for(int i=0; i<n; ++i)
        cin >> a[i] >> b[i];

    vector<vector<int> > cost(n, vector<int>(n, INT_MAX));
    for(int i=0; i<n; ++i)
        cost[i][i] = 0;
    for(int i=1; i<n; ++i){
        for(int j=0; j+i<n; ++j){
            for(int k=j; k<j+i; ++k){
                int c = cost[j][k] + cost[k+1][j+i] + a[j] * b[k] * a[k+1] * b[j+i];
                cost[j][j+i] = min(cost[j][j+i], c);
            }
        }
    }
    cout << cost[0][n-1] << endl;

    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  int count;
  cin >> S;
  for (int i = 0; i<4;i++){
  if(S.at(i) == '+'){
  count += 1;
  }else if(S.at(i) == '-'){
  count += -1;
  }
  }
  cout << count;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <deque>

int main(){
  int N;
  scanf("%d", &N);
  std::vector<int > A(N);
  for (int i=0; i<N; i++){
    scanf("%d", &A[i]);
  }
  std::sort(A.begin(), A.end(), std::greater<int>());
  long long ans = 0;
  if (N%2==1){
    long long temp=0;
    for (int i=0; i<N/2; i++){
      temp+=2*(long long)A[i];
    }
    for (int i=0; i<N/2-1; i++){
      temp-=2*(long long)A[N-1-i];
    }
    temp-=A[N/2];
    temp-=A[N/2+1];
    ans = std::max(ans, temp);
    temp = 0;
    for (int i=0; i<N/2-1; i++){
      temp+=2*(long long)A[i];
    }
    for (int i=0; i<N/2; i++){
      temp-=2*(long long)A[N-1-i];
    }
    temp+=A[N/2-1];
    temp+=A[N/2];
    ans = std::max(ans, temp);
  } else {
    long long temp = 0;
    for (int i=0; i<N/2-1; i++){
      temp += 2*(long long)A[i];
    }
    for (int i=0; i<N/2-1; i++){
      temp -= 2*(long long)A[N-1-i];
    }
    temp += A[N/2-1];
    temp -= A[N/2];
    ans = temp;
  }
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 640
# coding: utf-8
# Your code here!
"""
int #整数
float #小数

#標準入力
a=input()
a,b=map(int,input().split()) #入力は行ごと
#標準出力
print(a)
ptrint("Hello")
#for
for name in fruits: #fruitの頭から操作
    print(name)
#リスト
list0 = [] #リスト生成
list0 = [1,2,3,4] #初期化
list0 = [0]*10 #[0,0,0,0,0,0,0,0,0,0]
list1 = list(map(int, input().split()))　# 複数の入力をリストに入れる
list1 = list1 + [6, 7, 8] #リストの追加
list2.append(34) #リストの追加　最後に（）内が足される
list.insert(3,10) #リストの追加　任意の位置（追加したい位置,追加したい値）
len(list4) #リストの要素数
max(sa) #list saの最小値
list5.count(2) #リスト内の2の数
abs(a) #aの絶対値
max(a,b) min(a,b) #最大値　最小値

extension_1 = []
for i in range(10):
    extension_1.append(i)
extension_1
#>>> [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

comprehension_1= [i for i in range(10)]
comprehension_1
#>>> [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
"""
a = input()
if a=="a" or a=="e" or a=="i" or a=="o" or a=="u":
    print("vowel")
else:
    print("consonant")
     

Measured memory_bytes: 2940
N, Y = map(int,input().split())

for i in range(Y // 10000 + 1):
    for k in range((Y - i*10000) // 5000 + 1):
        if i*10000 + k*5000 + (N - i - k)*1000 == Y:
            print(i,k,(N - i - k))
            quit()
print("-1 -1 -1")

Measured memory_bytes: 2940
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include<string>
#include<stack>
using namespace std;
//#define int long long
typedef pair<int, int> pii;
typedef priority_queue<pii, vector<pii>, greater<pii> > RPQ;
#define mk make_pair
#define INF (1 << 30)
#define INFL (1ll << 60ll)
#define mod 1000000007

int N, Q;
queue<pair<string, int> > que;

signed main(){
    cin >> N >> Q;
    for(int i = 0; i < N; i++){
        string s;
        int a;
        cin >> s >> a;
        que.push(mk(s, a));
    }
    int sec = 0;
    while(!que.empty()){
        pair<string, int> p = que.front();
        que.pop();
        if(p.second <= Q){
            cout << p.first << " " << sec + p.second << endl;
            sec += p.second;
        }
        else {
            p.second -= Q;
            que.push(p);
            sec += Q;
        }
    }


    return 0;
}

/*

*/


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

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

const int INF = 1e9;
const int mod = 1e9+7;

int main()
{
    int n;
    cin >> n;
    vector<int> x(n),y(n),h(n);
    int tmp;
    for(int i = 0; i < n; i++){
        cin >> x[i] >> y[i] >> h[i];
        if(h[i] > 0) tmp = i; 
    }

    for(int i = 0; i <= 100; i++){
        for(int j = 0; j <= 100; j++){
            int H = h[tmp] + abs(x[tmp]-i) + abs(y[tmp]-j);
            int flag = 1;
            for(int k = 0; k < n; k++){
                if(max(H-abs(x[k]-i)-abs(y[k]-j),0) != h[k]){
                    flag = 0;
                    break;
                }
            }
            if(flag){
                cout << i << ' ' << j << ' ' << H << endl;
                return 0;
            }
       }
    }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    static int mod = 1_000_000_007;
    static long pow(long a,int n) {
        long res=1;
        while (n>0) {
            if ((n-n/2*2)==1) {
                res=res*a%mod;
            }
            a=a*a%mod;
            n>>=1;
        }
        return res;
    }

    static long modinv(long n) {
        return pow(n, mod-2);
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        long[] C = new long[N];
        for (int i=0;i<N;i++) {
            C[i] = Integer.parseInt(sc.next());
        }
        long[] val = new long[N];
        long a = pow(2, N-1);
        long b = pow(2, N-2);
        for (int i=0;i<N;i++) {
            val[i] = (a+b*i%mod)%mod;
        }
        Arrays.sort(C);
        long ans = 0L;
        for (int i=0;i<N;i++) {
            ans = (ans+C[i]*val[N-1-i]%mod)%mod;
        }
        System.out.println(ans*pow(2, N)%mod);
    }
}

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

using namespace std;

int main(int argc, char *argv[]) {
    int64_t N;
    cin >> N;
    vector<pair<int64_t, int64_t>> parr;
    int64_t from, to;
    for (int i = 0; i < N; i++) {
        cin >> from >> to;
        parr.push_back(make_pair(from, to));
    }

    sort(parr.begin(), parr.end(), greater<pair<int64_t, int64_t>>());
    int64_t ans = parr[0].first + parr[0].second;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2420
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<iomanip>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
#define LINF (long long)4e18

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;



int main(){
   int H,W;
   cin >> H >> W;
   vector<vector<char>> F(H,vector<char>(W));
   rep(i,H)rep(j,W) cin >> F[i][j];

   int dir1[] = {-1,0,1,0,-1,-1,1,1};
   int dir2[] = {0,-1,0,1,-1,1,-1,1};

   rep(i,H){
       rep(j,W){
            if(F[i][j] == '.'){
                int cnt = 0;
                rep(k,8){
                    if(i+dir1[k] >= 0 && i+dir1[k] < H && j+dir2[k] >= 0 && j+dir2[k] < W){
                        if(F[i+dir1[k]][j+dir2[k]] == '#') cnt++;
                    }
                }
                F[i][j] = cnt + '0';
            }
            cout << F[i][j];
       }
       cout << endl;
   }
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
	
	int a, b;
	
	scanf("%d %d" ,&a ,&b);
	
	if(a < b){
		
		printf("a < b\n");
		
	}
	
	else if(a > b){
		
		printf("a > b\n");
		
	}
	
	else{
		
		printf("a == b\n");
		
	}
	return 0;
	
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
#define all(a) (a).begin(),(a).end()
#define rep(i,n) for(ll i=0,i##_len=(n);i<i##_len;i++)
#define rep2(i,a,b) for(ll i=(a),i##_len=(b);i<=i##_len;i++)
#define rrep(i,n) ll i=(n);ll now=-1;while(i--&&(now++||1))
#define Yes(n) cout<<((n)?Yes:No)
#define pb push_back
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vbl = vector<bool>;
using vint = vector<int>;
using vstr = vector<string>;
const string Yes = "Yes\n";
const string No = "No\n";
static inline void ignore_ret(int x) {x++;}
template<class T> inline bool chmax(T&a,const T&b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T&a,const T&b){if(a>b){a=b;return true;}return false;}
template<class T> inline T gcd_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=gcd(r,v.at(i));return r;}
template<class T> inline T lcm_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=lcm(r,v.at(i));return r;}
template<class T> inline T factorial(T n){if(n==0)return 1;T r=1;for(T i=2;i<=n;i++)r*=i;return r;}
template<class T> inline T nCr(T n,T k){if(n<k||n<0||k<0)return 0;T r=1;k=min(k,n-k);for(T i=n-k+1;i<=n;i++)r*=i;return r/factorial(k);}
template<class T> inline T dot_product(vector<T>u,vector<T>v){T r=0;for(T i=0;i<u.size();i++)r+=u.at(i)*v.at(i);return r;}
template<class T> inline T sum(vector<T>v){return reduce(all(v),0LL);}

void solve(ll A, ll B, ll C, ll D) {
  bool turn = 0;
  while(A > 0 && C > 0) {
    if (turn) {
      A -= D;
    } else {
      C -= B;
    }
    turn ^= 1;
  }
  Yes(turn);
}

int main() {
  ll A;
  ignore_ret(scanf("%lld",&A));
  ll B;
  ignore_ret(scanf("%lld",&B));
  ll C;
  ignore_ret(scanf("%lld",&C));
  ll D;
  ignore_ret(scanf("%lld",&D));
  solve(A, B, C, D);
  return 0;
}


Measured memory_bytes: 3676
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

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

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let s = get!(String);
    let mut srem = Vec::new();
    
    for c in s.chars() {
        if c != 'x' {
            srem.push(c);
        }
    }
    
    let len = srem.len();
    for i in 0..len/2 {
        if srem[i] != srem[len-i-1] {
            println!("-1");
            return;
        }
    }

    let mut s = s.chars().collect::<VecDeque<_>>();
    let mut count = 0usize;
    loop {
        let front = match s.pop_front() {
            Some(v) => v,
            None => break,
        };
        let back = match s.pop_back() {
            Some(v) => v,
            None => break,
        };
        if front == back {
            continue;
        }
        count += 1;
        if front == 'x' {
            s.push_back(back);
        } else {
            s.push_front(front);
        }
    }
    println!("{}", count);
}


Measured memory_bytes: 8572
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string s, t;
    cin >> s >> t;
    int count = 0;
    for(int i = 0; i < s.size(); i++){
        if(s.at(i) != t.at(i)) count++;
    }
    cout << count << endl;
}


Measured memory_bytes: 3916
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

S=get_nsp
N=S.size
cnt=[]
cnt.push(S.count("a"))
cnt.push(S.count("b"))
cnt.push(N-cnt.inject(:+))
cnt.sort!{|x,y| y<=>x}
cnt[0]-=cnt[2]
cnt[1]-=cnt[2]
if cnt[0]<=1
    puts "YES"
else
    puts "NO"
end


Measured memory_bytes: 6908
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int waru = n / 100;
        int x = waru * 100;
        int y = waru * 10;
        int z = waru * 1;
        int w = x + y + z;
        if(n <= w){
            System.out.println(w);
        }
        else {
            System.out.println(w + 111);
        }
    }
}


Measured memory_bytes: 20948
package main

// ABC161D - Lunlun Number (解説PDF実装)
// https://atcoder.jp/contests/abc161/tasks/abc161_d

import "fmt"

type container struct {
	data []int
}

func (c *container) queue(v int) {
	c.data = append(c.data, v)
}
func (c *container) dequeue(v *int) bool {
	if len(c.data) == 0 {
		return false
	}
	*v = c.data[0]
	c.data = c.data[1:]
	return true
}

func main() {
	var K int
	fmt.Scan(&K)
	var q container
	for i := 1; i < 10; i++ {
		q.queue(i) // 1~9をqueueにいれる
	}
	var v int
	ans := make([]int, 0)
	for q.dequeue(&v) {
		ans = append(ans, v)
		for i := 0; i < 10; i++ {
			if abs(v%10-i) <= 1 {
				q.queue(v*10 + i)
			}
		}
		if len(ans) >= K {
			break
		}
	}
	fmt.Println(ans[K-1])
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}


Measured memory_bytes: 10752