akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pi 3.14159265358979323846264
int main()
{
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)cin>>a[i];
	priority_queue<pair<int,int> >q;
	sort(a,a+n);
	long long com=0;
	q.push(make_pair(a[n-1],1));
	for(int i=n-2;i>=0;i--)
	{
		int x=q.top().first;
		int y=q.top().second;
		com+=x;
		y--;
		if(y==0)q.pop();
		else
		{
			q.pop();
			q.push(make_pair(x,y));
		}
		if(q.top().second==0)q.pop();
		q.push(make_pair(a[i],2));
	}
	cout<<com;
	return 0;
}

Measured memory_bytes: 6104
#include <math.h>

#include <cmath>
#include <iostream>
using namespace std;
int main() {
    int a,b,c,k,l=0;
    cin >> a>>b>>c>>k;
    for (int i = 0; i < 100;i++){
        if(a>=b){
            b = b * 2;
        }else{
            l = l + i;
            break;
        }
    }
    for (int i = 0; i < 100; i++) {
        if (b>=c) {
            c = c * 2;
        } else{
            l = l + i;
            break;}
    }
    if(l<=k){
        cout << "Yes" << endl;
    }else
        cout << "No" << endl;
     return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll n,m;
ll num[] = {0,2,5,5,4,5,6,3,7,6};

int main(){
    cin >> n >> m;
    vector<ll> a(m);
    vector<ll> dp(n+1,-INF);
    dp[0] = 0;
    rep(i,m)cin >> a[i];
    sort(ALL(a));
    reverse(ALL(a));
    rep(i,n){
        ll nxt = i+1;
        rep(j,m){
            if(nxt - num[a[j]] >= 0)dp[nxt] = max(dp[nxt],dp[nxt - num[a[j]]] + 1);
        }
    }
    // rep(i,n){
    //     cout << i+1 << " " << dp[i+1] << endl;
    // }
    ll nn = n;
    string ans;
    while(nn){
        rep(i,m){
            if(nn - num[a[i]] < 0)continue;
            if(dp[nn] == dp[nn - num[a[i]]]+1){
                ans += (char)('0'+a[i]);
                nn -= num[a[i]];
                break;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include<stdio.h>

int main()
{
    int N, max=-1, p[100000], sum=0, i=0;

    scanf("%d", &N);

    while(i != N)
    {
        scanf("%d", &p[i]);
        if(p[i] > max)
            max = p[i];
        sum = sum + p[i];
        i++;
    }

    sum = sum - max + (max/2);

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

    return 0;
}


Measured memory_bytes: 1692
#include <iostream>
#include <stdio.h>
using namespace std;

int main() {
    int sum = 0;
    char ch;
    
    while(true) {
        while((ch = getchar()) != '\n') {
            sum += ch - '0';
        }
        if (sum == 0) break;
        else {
            cout << sum << endl;
            sum = 0;
        }
    }
}


Measured memory_bytes: 3096
#include <stdio.h>

int main () {
	int s;
	scanf ("%d", &s);
	int i, j;
	int a[100000];

	for (i = 0; i < 100000; i++) {
		if (i == 0)
			a[i] = s;
		else {
			if (a[i-1] % 2 == 0)
				a[i] = a[i-1] / 2;
			else
				a[i] = 3 * a[i-1] + 1;

			for (j = 0; j < i; j++) {
				if (a[i] == a[j]) {
					printf ("%d\n", i+1);
					return 0;
				}

			}
		}
	}

	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>

using namespace std;

//Nayeem Shahriar Joy,Applied Physics And Electronic Engineering,University of Rajshahi.

int gcd(int b,int a)
{
    if(a<b){
                    swap(a,b);
                }
    int c=0;
    while(b>0)    {
                    c = a%b;
                    a=b;
                    b=c;
                }
                return a;
}

int main()

{

     int b=0,c=0,d=0,i=0,j=0,a1=0,b1=0,c1=0;

    int n,a,pr=1;

    cin>>n;

    cin>>a;

    for( i=0;i<n-1;i++)

    {
        cin>>b;

        a1=a;

        b1=b;

        c1=(a1*b1)/gcd(a,b);

        a=c1;

    }

    cout<<c1<<endl;

    return 0;
}

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

#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 reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

void yes() { cout << "Yes" << endl; exit(0); }
void no() { cout << "No" << endl; exit(0); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> void amax(T &x, T y) { x = max(x, y); }
template <typename T> void amin(T &x, T y) { x = min(x, y); }
template <typename T> T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

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

void solve() {
  int i, o, j, l, _;
  cin >> i >> o >> _ >> j >> l >> _ >> _;
  i64 ans = 0;
  ans += o;
  vi64 v = {i, j, l};
  sort(all(v));
  int c = 0;
  rep(i, 3) {
    c += v[i] & 1;
  }
  if (c == 3 || c == 0) {
    ans += v[0] + v[1] + v[2];
  }
  if (c == 2) {
    if (v[0] == 0) {
      ans += v[1] / 2 * 2;
      ans += v[2] / 2 * 2;
    } else {
      ans += v[0] + v[1] + v[2] - 1;
    }
  }
  if (c == 1) {
    ans += v[0] + v[1] + v[2] - 1;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
static const int MAX = 100;
static const int INFTY = (1<<21);
static const int WHITH = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[MAX][MAX];

void dijkstra() {
  int minv;
  int d[MAX], color[MAX];

  for (int i = 0; i < n; i++) {
    d[i] = INFTY;
    color[i] = WHITH;
  }

  d[0] = 0;
  color[0] = GRAY;
  while (1) {
    minv = INFTY;
    int u = -1;
    for (int i = 0; i < n; i++) {
      if (minv > d[i] && color[i] != BLACK) {
        u = i;
        minv = d[i];
      }
    }
    if (u == -1) break;
    color[u] = BLACK;
    for (int v = 0; v < n; v++) {
      if (color[v] != BLACK && M[u][v] != INFTY) {
        if (d[v] > d[u] + M[u][v]) {
          d[v] = d[u] + M[u][v];
          color[v] = GRAY;
        }
      }
    }
  }

  for (int i = 0; i < n; i++) {
    cout << i << " " << ( d[i] == INFTY ? -1 : d[i] ) << endl;
  }
}

int main() {
  cin >> n;
  for ( int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      M[i][j] = INFTY;
    }
  }

  int k, c, u, v;
  for (int i = 0; i < n; i++) {
    cin >> u >> k;
    for (int j = 0; j < k; j++) {
      cin >> v >> c;
      M[u][v] = c;
    }
  }
  
  dijkstra();
  
  return 0;
}



Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__",", __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000

int main(){
  int n; long t;
  cin>>n>>t;
  vector<long> vec(n);
  rep(i,n) cin>>vec[i];

  long stop = vec[0] + t;
  long ans = t;
  repl(i,1,n){
    if(vec[i]>stop){
      ans += t;
    }
    else if(vec[i]+t > stop){
      ans += vec[i]+t-stop;
    }
    stop = vec[i]+t;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1792
#include<iostream>
using namespace std;
int main(){
	int H,W;
	while(1){
		cin>>H>>W;
		for(int i=1;i<=H;i++){
			for(int j=1;j<=W;j++){
				cout<<"#";
			}cout<<endl;
		}
		if(H==0&&W==0)break;
		cout<<endl;
	}
	return 0;
}


Measured memory_bytes: 3080
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;


class Program
{
    static void Main(string[] args)
    {
        // 入力
        //var s = Console.ReadLine();
        var n = int.Parse(Console.ReadLine());
        //int[] n = Console.ReadLine().Split().Select(int.Parse).ToArray();

        long ans = 0;
        for (int i = 1; i <= n; i++)
        {
            for (int k = 1; k <= n; k++)
            {
                for (int t = 1; t <= n; t++)
                {
                    var tmp = Gcd(i,k);
                    ans += Gcd(tmp,t);   
                }

            }
        }

        // 出力
        Console.WriteLine(ans);
    }

    public static long Gcd(long a, long b)
    {
        if (a < b)
            // 引数を入替えて自分を呼び出す
            return Gcd(b, a);
        while (b != 0)
        {
            var remainder = a % b;
            a = b;
            b = remainder;
        }
        return a;
    }
}

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

int main() {
	int n, k;
	scanf("%d %d", &n, &k);
	long long res = 0;
	for(int b = 1; b <= n; ++b) {
		res += n / b * max(0, b - k);
		res += max(0, (n % b) - k + 1);
	}
	if(k == 0) res -= n;
	printf("%lld\n", res);
}

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

int main() {
    int n; cin >> n;
    vector<int> a(9, 0);
    int ansm = 0, ansma = 0;
    for (int i=0; i<n; ++i) {
        int num; cin >> num;
        if (num > 3200) num = 3200;
        a[num/400]++;
    }
    for (int i=0; i<8; ++i) {
        if (a[i]) ansm++;
    }
    if (ansm == 0) {
        ansm++;
        ansma--;
    }
    ansma += ansm + a[8];
    cout << ansm << " " << ansma << endl;
}

Measured memory_bytes: 256
#include<cstdio>
int n,f[200005];
long long ans=0;
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&f[i]);
	int l=1,r=0,x=0,y=0;
	for (;l<=n;x=x^f[l],y=y-f[l],l++)
	{
		while ((x^f[r+1])==(y+f[r+1])&&r<n) ++r,x=x^f[r],y=y+f[r];
		ans=ans+(r-l+1);
	}
	printf("%lld\n",ans);
}

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

int main() {

  int N;
  cin >> N;
  
  int sum = 0;
  int tmp = 0;
  vector<int> p(N), c(N-1);
  for (int i=0; i<N; i++) {
    cin >> p.at(i);
  }
  for (int j=0; j<N; j++) {
    cin >> tmp;
    sum+=tmp;
  }
  for (int k=0; k<N-1; k++) {
    cin >> c.at(k);
  }
  for (int l=0; l<N-1; l++) {
    if (p.at(l+1) - p.at(l) == 1) {
      sum +=c.at(p.at(l)-1);
    }
  }
  // 結果の出力
  cout << sum << endl;
}

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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

//↓0-originか1-originでn回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   //0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) //1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;

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

const ld PI = acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
//const int mod = 998244353;

/*FUNCs=================================================*/
int h,w;
vec<string> s;
vii dist;
vi movex = {0,0,1,-1};
vi movey = {1,-1,0,0};

void dist_cul(vec<string> &s, PII k) {
    queue<PII> que;
    que.emplace(k.first, k.second);
    while(que.size()) {
        int x, y;
        tie(x,y) = que.front();que.pop();
        for(int i = 0;i < 4; ++i) {
            int nx = x+movex[i], ny = y + movey[i];
            if(0<=nx&&nx<=h-1&&0<=ny&&y<=w-1) {
                if(s[nx][ny]=='#') continue;
                if(dist[nx][ny]!=inf) continue;    
                dist[nx][ny] = dist[x][y]+1;
                que.emplace(nx,ny);
            }
        }
    }
}
/*MAIN==================================================*/
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    //cout << fixed << setprecision(10);

    cin >> h >> w;
    s.resize(h);
    vii distt(h, vi(w, inf));
    rep(i,h) {
        cin >> s[i];
    }

    int maxx = -1;
    for(int i = 0; i < h; ++i) {
        for(int j = 0; j < w; ++j) {
            if(s[i][j]=='#') continue;
            dist = distt;
            //debug(dist[0][0]);
            PII p = make_pair(i,j);
            //debug(p.first);
            //debug(p.second);
            dist[i][j] = 0;
            dist_cul(s, p);
            int maxxx = -1;
            for(int k = 0; k < h; k++) {
                for(int l = 0; l < w; ++l) {
                    if(dist[k][l]!=inf) {
                        chmax(maxxx, dist[k][l]);
                        //debug(dist[k][l]);
                    }
                }
            }
            //debug(maxxx);
            chmax(maxx, maxxx);
        }
    }
    //for(auto i : movex) cout << i;
    cout << maxx << '\n';
}

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

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  vector<int> v;
  
  v.push_back(a);
  v.push_back(b);
  v.push_back(c);

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

  if(v[2] ==7){
    if(v[1] == v[0] && v[0] ==5)
        cout << "YES" << endl;
    else {
        cout << "NO" << endl;
    }
  }else{
    cout << "NO" << endl;
  }

  

  
  return 0;
}


Measured memory_bytes: 256
<?php
// 入力
fscanf(STDIN, "%d", $n);
$strH = fgets(STDIN);
$hotels = array_map('intval', explode(' ', $strH));

$count = 0;
$max = 0;

foreach ($hotels as $h) {
    if ($max <= $h) {
        $count++;
        $max = $h;
    }
}

echo $count . "\n";


Measured memory_bytes: 4728
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;

  vector<int>h(n);
  
  for(int i=0;i<n;i++){cin>>h[i];}
  
  int cost[n];
  cost[0] = 0;
  cost[1] = abs(h[0]-h[1]);
  
  for(int i=2;i<n;i++){
    
	cost[i] = min( cost[i-1]+abs(h[i]-h[i-1]) , cost[i-2]+abs(h[i]-h[i-2]) );
    

  }
  //for(int i=0;i<n;i++){cout<<cost[i]<<" ";}cout<<endl;
  cout<<cost[n-1];
  return 0;
}

Measured memory_bytes: 1152
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
using namespace std;

#define MAX_N 100

struct edge {
    int from, to;
    int cost;
    edge(int from, int to, int cost) : from(from), to(to), cost(cost) {}
};

struct P {
    int v;
    int cost;
    int ticket;
    P(int v, int cost, int ticket) : v(v), cost(cost), ticket(ticket) {}
    bool operator<(const P& o) const {
        return cost > o.cost;
    }
};

#define INF (1<<28)

int n, m;
vector<edge> graph[MAX_N];
vector<edge> sgraph[MAX_N];
int d[MAX_N][2];

void dijkstra() {
    priority_queue<P> q;
    for (int i = 0; i < n; i++) d[i][0] = d[i][1] = INF;
    d[0][0] = d[0][1] = 0;
    q.push(P(0, 0, 1));

    while (!q.empty()) {
        P p = q.top(); q.pop();
        int v = p.v;
        if (p.ticket) {
            for (int i = 0; i < sgraph[v].size(); i++) {
                edge e = sgraph[v][i];
                if (d[e.to][0] <= d[v][1]) continue;
                d[e.to][0] = d[v][1];
                q.push(P(e.to, d[e.to][0], 0));
            }
        }
        if (d[v][p.ticket] < p.cost) continue;
        for (int i = 0; i < graph[v].size(); i++) {
            edge e = graph[v][i];
            if (d[e.to][p.ticket] <= d[v][p.ticket] + e.cost) continue;
            d[e.to][p.ticket] = d[v][p.ticket] + e.cost;
            q.push(P(e.to, d[e.to][p.ticket], p.ticket));
        }
    }
}

int main() {
    while (scanf("%d %d", &n, &m), n || m) {
        for (int i = 0; i < n; i++) graph[i].clear();
        for (int i = 0; i < n; i++) sgraph[i].clear();
        for (int i = 0; i < m; i++) {
            int a, b, c;
            scanf("%d %d %d", &a, &b, &c);
            a--, b--;
            graph[a].push_back(edge(a, b, c));
            graph[b].push_back(edge(b, a, c));
        }
        for (int i = 0; i < n; i++) 
            for (int j = 0; j < graph[i].size(); j++) {
                int mid = graph[i][j].to;
                for (int k = 0; k < graph[mid].size(); k++) {
                    sgraph[i].push_back(edge(i, graph[mid][k].to , 0));
                }
            }
        dijkstra();
        printf("%d\n", d[n-1][0]);
    }
    return 0;
}

Measured memory_bytes: 1132
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#define _GLIBCXX_DEBUG // check []
#define DIVISOR 1000000007

using namespace std;
typedef pair<int,int> pii;
typedef pair<int64_t, int64_t> pII;

template<typename T>
void cins(vector<T>& arr) { for(T& e: arr) cin >> e; }

#ifdef DEBUG
#define debug(fmt, ...) \
    printf("[debug: %s] " fmt, __func__, __VA_ARGS__)
#else
#define debug(fmt, ...)
#endif

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

int main(void) {
    int64_t a, b;
    cin >> a >> b;
    if(a > b) swap(a, b);
    int64_t mmax = gcd(a,b);
    int64_t mmax_2 = sqrt(0.5 + mmax);
    map<int64_t, int> cnt;
    cnt[1] = 1;
    int prime = 2;
    while(mmax > 1) {
        // mmax itself is prime
        if(prime > mmax_2) {
            cnt[mmax] = 1;
            break;
        }
        if(mmax % prime) { prime++; continue; }
        mmax /= prime;
        cnt[prime] = 1;
    }

    cout << cnt.size() << endl;
    return 0;
}

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

#define MAXK 10000

int main() {
	int K, T;
	int day[MAXK];
	vector<pair<int, int>> C;  // cake count, cake id
	cin >> K >> T;
	bool algflg = false;
	for (int i = 0; i < T; i++) {
		int a;
		cin >> a;
		algflg = algflg || a * 2 > K;
		C.push_back(make_pair(a, i));
	}
    if (!algflg) {
        cout << 0 << endl;
        return 0;
    }
	sort(C.begin(), C.end());
	for (int i = 0; i < K; i += 2) {
		auto c = C.back();
		C.pop_back();
		day[i] = c.second;
		c.first--;
		if (c.first > 0) {
			C.push_back(c);
		}
	}
	for (int i = (K % 2 == 0 ? K - 1 : K - 2); i >= 0; i -= 2) {
		auto c = C.back();
		C.pop_back();
		day[i] = c.second;
		c.first--;
		if (c.first > 0) {
			C.push_back(c);
		}
	}
	int ans = 0;
	for (int i = 1; i < K; i++)
		if (day[i] == day[i - 1]) ans++;
	cout << ans << endl;
	return 0;
}

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

#define FOR(i, l, r) for(ll i = l; i < r; i++)
#define rep(i, N) FOR(i, 0, N)

#define MOD 1000000007
#define INF 1000000000

using ll = long long int;
using namespace std;

typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;

int main() {
    int n; cin >> n;
    vl a(n),b(n);
    rep(i,n){
        cin >> a[i] >> b[i];
    }

    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    ll ans;
    ll lmed, rmed;
    if(n%2 == 1){
        lmed = a[n/2];
        rmed = b[n/2];
        ans = rmed - lmed + 1;
    } else {
        lmed = (a[n/2]+a[n/2-1])/2;
        rmed = (b[n/2]+b[n/2-1])/2;
        ans = (rmed - lmed)*2;
        
        if((((a[n/2]+a[n/2-1])%2)^((b[n/2]+b[n/2-1])%2)) == 0){
            ans++;
        } else {
            if(((b[n/2]+b[n/2-1])%2) == 1) ans += 2;
        }
    }

    cout << ans << "\n";
    return 0;
}


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

int main(){
	int n;
	cin >> n;
	string s[n];
	for(int i = 0; i < n; i++) cin >> s[i];
	int white = 0;
	for(int i = 0; i < n; i++) white += count(s[i].begin(), s[i].end(), '.');
	if(white == n * n){
		cout << -1 << endl;
		return 0;
	}
	int row[n]{}, col[n]{};
	for(int i = 0; i < n; i++) for(int j = 0; j < s[i].size(); j++) if(s[i][j] == '.'){
		row[i]++;
		col[j]++;
	}
	int ans = 1e9;
	for(int i = 0; i < n; i++){
		int cur = row[i];
		for(int j = 0; j < n; j++) if(col[j]) cur++;
		bool f = true;
		for(int j = 0; j < n; j++) f &= s[j][i] == '.';
		if(f) cur++;
		ans = min(ans, cur);
	}
	cout << ans << endl;
}

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

using namespace std;
#define ll long long int
#define X first
#define Y second
const int MAXN = 1e5 + 5;
int n, dp[MAXN][3], a[MAXN], b[MAXN], c[MAXN];


int main()
{
	int k;
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> a[i] >> b[i] >> c[i];

	dp[1][0] = a[1],
	dp[1][1] = b[1],
	dp[1][2] = c[1];

	for (int i = 2; i <= n; i++)
	{
		dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a[i];
		dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + b[i];
		dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c[i];
	}
	cout << max({ dp[n][0], dp[n][1], dp[n][2] }) << endl;
	return 0;
}


Measured memory_bytes: 2560
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
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; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)

struct INIT{
    INIT(){
        std::ios::sync_with_stdio(false);
        std::cin.tie(0);
        cout << fixed << setprecision(13);
    }
}INIT;

int n;

int calc(int a, int b){
    int ret = 0;
    while(((1 << ret)&a) == ((1 << ret)&b))ret++;
    return ret + 1;
}

int main(){
    cin >> n;
    for(int i = 1;i <= n - 1;i++){
        for(int j = i + 1;j <= n;j++){
            if(j != i + 1)cout << " ";
            cout << calc(i, j);
        }
        cout << endl;
    }
}

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

#define ll long long
#define sd(x) scanf("%d", &(x))
#define pii pair<int, int>
#define F first
#define S second
#define all(c) ((c).begin()), ((c).end())
#define sz(x) ((int)(x).size())
#define ld long double

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<", "<<p.second<<")";
	return os;
}

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

#ifdef LOCAL
#define cerr cout
#else
#endif

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
const int N = 5005;

const int mod = 1e9 + 7;
inline int add(int x, int y){ x += y; if(x >= mod) x -= mod; return x;}
inline int sub(int x, int y){ x -= y; if(x < 0) x += mod; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % mod;}
inline int powr(int a, ll b){
	int x = 1 % mod;
	while(b){
		if(b & 1) x = mul(x, a);
		a = mul(a, a);
		b >>= 1;
	}
	return x;
}
inline int inv(int a){ return powr(a, mod - 2);}

int p2[2*N], invp2[2*N];
int dp[N], dp2[N];

void getDp2(){
    dp2[0] = 0;
    for(int r = 1; r < N; r++){
        dp2[r] = add(dp2[r - 1], mul(r, mul(invp2[r + 1], dp[r])));
    }
}
int main(){
    p2[0] = invp2[0] = 1;
    for(int i = 1; i < N; i++) p2[i] = add(p2[i - 1], p2[i - 1]), invp2[i] = inv(p2[i]);
    for(int i = 0; i < N; i++) dp[i] = 1;
    int n, m; cin >> n >> m;
    for(int i = 1; i <= n; i++){
        getDp2();
        for(int j = 1; j <= m; j++){
            dp[j]= mul(dp[j], j + 1);
            dp[j] = add(dp[j], mul(p2[j], dp2[j - 1]));
        }
    }
    cout << dp[m] << endl;
}	

Measured memory_bytes: 3696
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string> //文字列
#include <iomanip> //doubleの桁数指定 setprecision()
#include <list> //前後に数値を入れれる配列
#include <map> //map
#include <vector> //vecror



#define REP(i,m,n) for(ll i = (ll) (m);i < (ll) (n);i++) //forの短縮
#define rep(i,n) REP(i,0,n) //REPが0の時
#define ll long long int

using namespace std;

double PI = acos(-1); //円周率

//常設関数↓

//最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

//最小公倍数
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

//degree → radian
long double chg_DegRad(long double deg) {
	return deg * PI / 180.0;
}

//radian → degree
long double chg_RadDeg(long double rad) {
	return rad * 180.0 / PI;
}
 
//桁数
ll CountDigit(ll n) {
	ll digit = 1;
	while ((n /= 10) != 0) digit++;
	return digit;
}

//距離
double dis(double xa, double ya, double xb, double yb) {
	return pow(pow(xa - xb, 2.0) + pow(ya - yb, 2.0), 0.5);
}

//abs()平均
//pow(,)累乗


//提出コード↓

ll h,c, ans = 1;


int main() {
	cin >> h;
	while (h > 1) {
		h /= 2;
		c++;
		ans += pow(2, c);
	}
	cout << ans << endl;



	return 0;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
int a[100010];
int main(){
    int a, b, c, d, k;
    while(cin>>a>>b>>c>>k){
    	ll ans=min(k, a);
    	k-=ans;
    	int tmp=min(k, b);
    	k-=tmp;
    	ans-=min(k, c);
    	cout<<ans<<endl;
    }
  return 0;
}




Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
const int N=1e5+5;
int n;
ll a,b,c,d,f[N<<1],invf[N<<1];
ll qpow(ll a,ll n)
{
    ll ans=1;
    while(n)
    {
        if(n&1) ans=ans*a%mod;
        a=a*a%mod;
        n>>=1;
    }
    return ans;
}
ll C(ll n,ll m)
{
    return f[n]*invf[n-m]%mod*invf[m]%mod;
}
int main()
{
    f[0]=invf[0]=1;
    for(int i=1;i<N<<1;i++)
        f[i]=f[i-1]*i%mod,invf[i]=qpow(f[i],mod-2);
    scanf("%lld%lld%lld%lld",&n,&a,&b,&c);
    a=a*qpow(100,mod-2)%mod;b=b*qpow(100,mod-2)%mod;d=100*qpow(100-c,mod-2)%mod;
    a=a*d%mod;b=b*d%mod;
    ll ans=0;
    for(int i=n;i<n*2;i++)
        ans=(ans+(qpow(a,n)*qpow(b,i-n)%mod+qpow(b,n)*qpow(a,i-n)%mod)*C(i-1,n-1)%mod*i%mod)%mod;
    printf("%lld\n",ans*d%mod);
}


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

int main(){
    int K, S;
    cin >> K >> S;
    int X, Y, Z, ans=0, sp=0;
    for (X=0; X<=K; X++){ //0 <= Y <= X <= Kの範囲で全探索。X != YであればXとYを交換したものも条件を満たす。
        for (Y=0;Y<=X; Y++){
            Z = S - X - Y;
            if (Z >= 0 && Z <= K){
                ans++;
                if (X == Y){
                    sp++;
                }
            }
        }
    }
    cout << 2 * ans -sp << endl;
    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, q;
    cin >> n >> q;
    vector<vector<int>> g(n);
    for(int i = 0; i < n-1; i++)
    {
        int a, b;
        cin >> a >> b;
        a--;b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    vector<int> add(n, 0);
    for(int i = 0; i < q; i++)
    {
        int p, x;
        cin >> p >> x;
        p--;
        add[p] += x;
    }
    vector<int> ans(n);
    function<void(int, int, int)> dfs = [&](int v, int pre, int sum)
    {
        sum += add[v];
        ans[v] = sum;
        for(int i = 0; i < (int)g[v].size(); i++)
        {
            int nx = g[v][i];
            if(nx != pre)
            {
                dfs(nx, v, sum);
            }
        }
    };
    dfs(0, -1, 0);
    for(int i = 0; i < n; i++)
    {
        cout << ans[i] << " ";
    }
}



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

using namespace std;

typedef long long int ll;

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

typedef pair<int,int> pair;

int main(){
    int h,n; cin >> h >> n;
    vector<int> a(n); for(int i=0;i<n;i++) cin >> a[i];
    int sum=0;
    for(auto v : a) sum+=v;

    if(h<=sum) cout << "Yes" << endl;
    else cout << "No" << endl;

}

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

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

int main(){
  int n,x;
  cin >> n >> x;
  vector<int> a(n+1,x);
  for(int i=0;i<n;i++) cin >> a[i];
  
  int ans=abs(a[0]-x);
  for(int i=1;i<n;i++) ans=gcd(ans,abs(a[i]-a[i-1]));
  
  cout << ans << endl;
}

Measured memory_bytes: 3780
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <set>
#include <map>
#include <queue>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <ctime>

using namespace std;

#define EPS 1e-8

struct Circle
{
    double x, y, r;
};

bool XYorder(Circle P1, Circle P2)
{
	if(P1.x != P2.x) return P1.x < P2.x;
	return P1.y < P2.y;
}
bool YXorder(Circle P1, Circle P2)
{
	if(P1.y != P2.y) return P1.y < P2.y;
	return P1.x < P2.x;
}

double dist(const Circle &A, const Circle &B)
{
	return hypot(A.x - B.x, A.y - B.y) - A.r - B.r;
}

double R;

double closest_recursive(vector <Circle> vx, vector <Circle> vy)
{
	if(vx.size()==1) return 1e20;
	if(vx.size()==2) return dist(vx[0], vx[1]);
	
	Circle cut = vx[vx.size()/2];
	
	vector <Circle> vxL, vxR;
	for(int i=0; i<vx.size(); i++)
		if(vx[i].x < cut.x || (vx[i].x == cut.x && vx[i].y <= cut.y))
			vxL.push_back(vx[i]);
		else vxR.push_back(vx[i]);
	
	vector <Circle> vyL, vyR;
	for(int i=0; i<vy.size(); i++)
		if(vy[i].x < cut.x || (vy[i].x == cut.x && vy[i].y <= cut.y))
			vyL.push_back(vy[i]);
		else vyR.push_back(vy[i]);
	
	double dL = closest_recursive(vxL, vyL);
	double dR = closest_recursive(vxR, vyR);
	double d = min(dL, dR);
	
	vector <Circle> b;
	for(int i=0; i<vy.size(); i++)
		if(abs(vy[i].x - cut.x) <= d + 2*R + EPS)
			b.push_back(vy[i]);
	
	for(int i=0; i<b.size(); i++)
		for(int j=i+1; j<b.size() && (b[j].y - b[i].y) <= d + 2*R + EPS; j++)
			d = min(d, dist(b[i], b[j]));
	
	return d;
}
double closest(vector <Circle> Circles)
{
	vector <Circle> vx = Circles, vy = Circles;
	sort(vx.begin(), vx.end(), XYorder);
	sort(vy.begin(), vy.end(), YXorder);
	return closest_recursive(vx,vy);
}

int main()
{
	int n;
	while(scanf("%d", &n) == 1)
	{
		if(n == 0) break;
		R = 0;
		
		vector <Circle> P(n);
		for(int i=0; i<n; i++){
			scanf("%lf %lf %lf", &P[i].r, &P[i].x, &P[i].y);
			R = max(R, P[i].r);
		}
		printf("%.10lf\n", closest(P));
	}
	
	return 0;
}

Measured memory_bytes: 28000
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <cmath>
#include <set>
#include <stack>
#include <queue>
#include <numeric>
#include <deque>
#include <cstring>
#include <iterator>
#include <map>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <complex>
#include <bitset>
#include <chrono>
#include <random>
using namespace std;

#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define eb emplace_back
#define el '\n'
typedef  long long  ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<bool> vb;


const int mod=1000000007;
//const int mod=998244353;


vvll mul(vvll &a, vvll &b, int n){
    vvll ans(n,vll(n));
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            for(int k=0; k<n; k++){
                ans[i][j]+=a[i][k]*b[k][j];
                ans[i][j]%=mod;
            }
        }
    }
    return ans;
}

vvll binpow(vvll &a, long long b, int n) {
    vvll res(n,vll(n));
    for(int i=0; i<n; i++){
        res[i][i]=1;
    }
    while (b > 0) {
        if (b & 1)
            res = mul(res, a, n) ;
        a = mul(a, a, n);
        b >>= 1;
    }
    return res;
}


int main()
{   ios_base::sync_with_stdio(false);cin.tie(NULL);
    ll t,n,m,k,q,x,a,b,c,d,y,l,r;
    cin >> n >> k;
    vvll v(n,vll(n));
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            cin >> v[i][j];
        }
    }
    v=binpow(v, k, (int)n);
    a=0;
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            a+=v[i][j];
        }
    }
    
    cout << a%mod << el;
    
    return 0;
}


Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cstring>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };
  
int MOD = 1000000007;
 
int main() {
    double r; cin >> r;
    printf("%f %f\n", r * r * M_PI, r * M_PI * 2);
}



Measured memory_bytes: 3204
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int N,M;
    cin >> N >> M;
    
    int ansN = N * (N-1) /2;
    int ansM = M * (M-1) /2;
    
    int ans = ansN + ansM;
    
    
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <cmath>
#include <iomanip>
using namespace std;

#define REP(i, n) for(int i = 0; i < (n); ++i)

int main() {
    int K, X;
    cin >> K >> X;
    int a = X+K-1;
    int b = X-K+1;
    for(int i = b; i <= a; i++) {
        cout << i;
        if(i != a) {
            cout << " ";
        }
    }
    cout << endl;
    return 0;
}

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

int main() {
  int X, N, s, t;
  bool finish = true;
  cin >> X >> N;
  s = X;
  t = X;
  vector<int> p(102);
  for(int i = 0; i < 102; i++){
    p.at(i) = i;
  }
  for(int i = 0; i < N;i++){
    int a;
    cin >> a;
    p.at(a) = -1;
  }
  if(p.at(X)!=-1){
    cout << X;
  }
  else{
    while(finish){
      s--;
      if(p.at(s)!=-1){
        cout << s;
        finish = false;
        break;
      }
      else{
        t++;
        if(p.at(t)!=-1){
          cout << t;
          finish = false;
          break;
        }
      }
    }
  } 
}




Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define INF 1e12

#define PB push_back
#define PF push_front
#define fi first
#define se second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vpi vector<pii>
#define vll vector<ll>
#define vpl vector<pll>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))
#define ios ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pr_d(x) cout << fixed << setprecision(15) << x << endl
#define ud(c, x) distance(c.begin(), upper_bound(all(c), x))
#define ld(c, x) distance(c.begin(), lower_bound(all(c), x))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define rep3(i, n) for (int i = (n - 1); i >= 0; --i)
#define rep4(i, a, b) for (int i = (a); i > (b); --i)
#define pb push_back
#define out(x) cout << x << "\n"
bool odd(int i) { return i % 2; }

#define all(v) v.begin(), v.end()
#define size(x) int(x.size())

int gcd(int a, int b) { return __gcd(a, b); }
int lcm(int a, int b) { return a * (b / gcd(a, b)); }
void Yes_No(bool f) {
  if (f)
    printf("Yes\n");
  else
    printf("No\n");
}

void deb_p(pii p) { printf("pair = %d %d\n", p.fi, p.se); }
void deb_i(int i) { printf("i = %d\n", i); }
void deb_v(vector<int> v) {
  printf("v = ");
  for (auto i : v) printf("%d ", i);
  printf("\n");
}
template <typename T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T& a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
//-------------------ここから回答する-----------------------

void solve(void) {
  string x, y;
  cin >> x >> y;
  if (x < y)
    cout << "<" << endl;
  else if (y < x)
    cout << ">" << endl;
  else
    cout << "=" << endl;
}
int main(void) { solve(); }


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

def get_count(S, H, W, i, j):
    num = 0
    start_i = start_j = -1
    end_i = end_j = 2
    if W == 1:
        start_i = 0 
        end_i = 1
    else:
        if i == 0:
            start_i = 0
        elif i == W-1:
            end_i = 1
    if H == 1:
        start_j = 0
        end_j = 1
    else:
        if j == 0:
            start_j = 0
        elif j == H-1:
            end_j = 1

    for y in range(start_j, end_j, 1):
        for x in range(start_i, end_i, 1):
            if S[j+y][i+x] == "#":
                num += 1

    return num


H,W = map(int, input().split())
S = []
for i in range(H):
    S.append(list(input()))

for y in range(H):
    for x in range(W):
        if S[y][x] == ".":
            num = get_count(S, H, W, x, y)
            S[y][x] = str(num)

for y in range(H):
    print("".join(S[y]))            


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

int k;
int cost(int a[], int dp[], int n, int i)
{
	if(i > n-1)
		return 100000;
	if(i == n-1)
		return 0;
	if(dp[i] >= 0 )
		return dp[i];
	else
	{
		int k1 = abs(a[i+1] - a[i]) + cost(a, dp, n, i+1);
		for (int j = 1; j < k; ++j)
		 {
		 	k1 = min(k1, abs(a[i+j+1] - a[i]) + cost(a, dp, n, i+j+1));
		 } 
		// int k2 = abs(a[i+2] - a[i]) + cost(a, dp, n, i+2);
		dp[i] = k1;
		return dp[i]; 
	}
}

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

	cin >> n >> k;

	int a[n+2] = {};
	int dp[n];

	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
		dp[i] = -1;	
	}

	int l = cost(a, dp, n, 0);
	// dp[1] = abs(a[1] - a[0]);
	// dp[0] = 0;

	// int k1, k2;
	// for (int i = 2; i < n; ++i)
	// {
	// 	k1 = dp[i-1] + abs(a[i] - a[i-1]);
	// 	k2 = dp[i-2] + abs(a[i] - a[i-2]);
	// 	dp[i] = k1 < k2 ? k1 : k2; 
	// }

	// cout << dp[n-1]; 

	cout << l;
	return 0;
}


Measured memory_bytes: 10368
#include <stdio.h>

void sort(int *X, int *Y) {
    int tmp;
    if (*X > *Y) {
        tmp = *X;
        *X = *Y;
        *Y = tmp;
    }
}

int main() {
    int a, b, c;
    int *A = &a, *B = &b, *C = &c;

    scanf("%d %d %d", &a, &b, &c);

    sort(A, B);
    sort(B, C);
    sort(A, B);

    printf("%d %d %d\n", a, b, c);

    return 0;
}


Measured memory_bytes: 2044
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
using namespace std;
#define FOR(i, a, b) for(int i=(a); i<(b);  i++)
#define REP(i, n)    for(int i=0;   i<(n);  i++)
#define REP1(i, n)   for(int i=1;   i<=(n); i++)
#define pb push_back
#define mp make_pair
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define EPS 1e-7
#define ALL(obj) (obj).begin(), (obj).end()
using ul    = unsigned long;
using ll    = long long;
using ld    = long double;
using vint  = vector<int>;
using vll   = vector<ll>;
using pint  = pair<int, int>;
using pll   = pair<ll, ll>;
using vpint = vector<pint>;
using vpll  = vector<pll>;
const int INF = (int)1e9 + 1;
const int MOD = (int)1e9 + 7;

int n;

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

  int a, b, c;

  scan(a); scan(b); scan(c);
//  vint s(n);
//  REP(i, n) scan(s[i]);
  if( (a<c && c<b)||(a>c && c>b) ) cout << "Yes";
  else  cout << "No";
//  cout <<  << endl;

  return 0;
}


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

int main() {
  long long h;
  cin >> h;
  int n = 0;
  
  for (int i = 0;h > 1;i++){
    h /= 2;
    n++;
  }
  
  long long ans = pow(2,n+1) - 1;

  cout << ans << endl;
}


Measured memory_bytes: 4040
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long lint;
typedef complex<double> point;

template<typename Key, typename Value>
using hash_map = cc_hash_table<Key, Value>;
template<typename T, typename Cmp = less<T>>
using oset = tree<T, null_type, Cmp, rb_tree_tag, tree_order_statistics_node_update>;

const int INF = 0x3f3f3f3f;
const lint INFL = 0x3f3f3f3f3f3f3f3fLL;
const double E = 1e-9, pi = 2 * acos(0);

template<typename T, typename U> void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> void amax(T &x, U y) { if (x < y) x = y; }

bool solve(int testNumber) {
	string str;
	if (!(cin >> str)) {
		return false;
	}
	bool ans = (int)str.find("AC") != -1;
	printf("%s\n", ans ? "Yes" : "No");
	return true;
}

void init(const char *in = nullptr, const char *out = nullptr) {
	if (in) freopen(in, "r", stdin);
	if (out) freopen(out, "w", stdout);
}

int main() {
	ios_base :: sync_with_stdio(false);
	cin.tie(nullptr);
	init();
	for (int i=1; solve(i); i++);
	return 0;
}

Measured memory_bytes: 256
dic = {}
ans = 0
N = int(input())
for i in range(N):
    x = sorted(input())
    x = "".join(x)
    if x in dic:
        dic[x] += 1
    else:
        dic[x] = 1

for i in dic:
    x = dic[i]
    if x > 1:
        ans += x*(x-1) // 2
print(ans)


Measured memory_bytes: 60504
using System;
class abc145_b{
  public static void Main(){
    int n = int.Parse(Console.ReadLine());
    String str = Console.ReadLine();
    if(n%2 == 1){
      Console.WriteLine("No");
    }
    else{
      if(check(n,str)){
        Console.WriteLine("Yes");
      }
      else{
        Console.WriteLine("No");
      }
    }
  }
  public static bool check(int n, String s){
    for(int i=0; i<n/2; i++){
      if(s[i] != s[i+n/2]){
        return false;
      }
    }
    return true;
  }
}


Measured memory_bytes: 13140
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cassert>
#include <queue>


using namespace std;

using ll = long long;

int main() {
  ll A, B;
  cin >> A  >> B;

  if (A <= 5) cout << 0 << endl;
  else 
  if (A >=6  && A<=12) cout << B/2 << endl;
  else cout << B << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cassert>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repd(i, n) for (int i = n; i >= 1; i--)
#define mod 1000000007
#define MOD 998244353
#define inf 1e20
typedef long long int ll;
typedef pair<ll, ll> p;


int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << min(a, b) + min(c, d) << endl;
	return 0;
}

//Ctrl+Aを使わない

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

#define INF 1234567890
#define ll long long

int N;
string s;

int pw(int a, int n, int mod)
{
	int ret = 1;
	while(n)
	{
		if (n&1) ret=(int)((ll)ret*a%mod); //
		a=(int)((ll)a*a%mod); //
		n >>= 1;
	}
	return ret;
}

int f(int n)
{
	if (n == 0) return 0;
	return f(n%__builtin_popcount(n)) + 1;
}

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> N >> s;
	int m = 0, r1 = 0, r2 = 0, r3 = 0;
	for(int i=0; i<s.size(); i++)
		if (s[i] == '1')
			m++;

	if (m-1 > 0)
	{
		for(int i=0; i<s.size(); i++)
			if (s[i] == '1')
			{
				r1 += pw(2, (int)s.size()-1-i, m-1);
				r1 %= m-1;
			}
	}
	for(int i=0; i<s.size(); i++)
		if (s[i] == '1')
		{
			r2 += pw(2, (int)s.size()-1-i, m);
			r2 %= m;
		}
	for(int i=0; i<s.size(); i++)
		if (s[i] == '1')
		{
			r3 += pw(2, (int)s.size()-1-i, m+1);
			r3 %= m+1;
		}
	for(int i=0; i<s.size(); i++)
	{
		int mod = 0;
		if (s[i] == '1') mod = m-1;
		else mod = m+1;

		if (mod == 0) // 예외
		{
			cout << 0 << "\n";
			continue;
		}

		int val = -1;
		if (mod == m-1) val = r1 - pw(2, (int)s.size()-1-i, mod);
		else val = r3 + pw(2, (int)s.size()-1-i, mod);

		val %= mod; val += mod; val %= mod;
		cout << f(val) + 1 << "\n";
	}
	return 0;
}

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

typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;

int main(){
    int n;  cin >> n;
    vector<int> a;

    int ans(0),t(1);
    rep(i,n){
        int x;  cin >> x;
        if(x==t){
            t++;
            a.push_back(x);
        }else{
            ans++;
        }
    }

    if(a.size()==0){
        cout << -1 << endl;
    }else{
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 4308
# https://atcoder.jp/contests/abc123/tasks/abc123_b

dish = []
for _ in range(5):
    dish.append(int(input()))

ans = float('inf')
for i in range(5):
    t = dish[i]
    for j in range(5):
        if i == j:
            continue
        if dish[j] % 10 == 0:
            t += dish[j]
        else:
            t += 10 * (dish[j] // 10 + 1)
    ans = min(ans, t)
print(ans)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
// (setq-default c-basic-offset 2)

int main() {
  long long a, b;
  cin >> a >> b;
  if (a < b) {
    swap(a, b);
  }
  long long ret = a * b / __gcd(a, b);
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 3592