akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
long long Comb(int a,int b){
 	if(a<b||b<0)return 0;
 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
}
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
long long pw(long long a,long long b){
	long long ret=1;
	while(b){
		if(b%2)ret=ret*a%mod;
		a=a*a%mod;
		b/=2;
	}
	return ret;
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
// ここから編集しろ
int p[110000];
int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++)scanf("%d",p+i);
	std::sort(p,p+a);
	int ret=mod;
	for(int i=0;i+b-1<a;i++){
		ret=min(ret,p[i+b-1]-p[i]);
	}
	printf("%d\n",ret);
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

int main(){
    ll h, w;
    cin >> h >> w;
    if(h*w%3==0){
        cout << 0 << endl;
    }else{
        ll total = h * w, ideal = total / 3L;
        ll hcut = ideal / w, wcut = ideal / h;
        ll sum[3], res=INT64_MAX, rem;
        if(hcut!=0){
            sum[0] = (hcut+1) * w;
            rem = total - sum[0];
            if (rem % 2) {
              ll remh = h - hcut - 1;
              sum[1] = max(rem / 2 / w * w, rem / 2 / remh * remh);
              sum[2] = rem - sum[1];
            } else {
              sum[1] = rem / 2;
              sum[2] = rem / 2;
            }
            sort(sum, sum + 3);
            res = sum[2] - sum[0];
        }else{
            hcut = 1;
        }
        sum[0] = hcut * w;
        rem = total - sum[0];
        if (rem % 2) {
          ll remh = h - hcut;
          sum[1] = max(rem / 2 / w * w, rem / 2 / remh * remh);
          sum[2] = rem - sum[1];
        } else {
          sum[1] = rem / 2;
          sum[2] = rem / 2;
        }
        sort(sum, sum + 3);
        res = min(res, sum[2] - sum[0]);

        if (wcut != 0) {
          sum[0] = (wcut + 1) * h;
          rem = total - sum[0];
          if (rem % 2) {
            ll remw = w - wcut - 1;
            sum[1] = max(rem / 2 / remw * remw, rem / 2 / h * h);
            sum[2] = rem - sum[1];
          } else {
            sum[1] = rem / 2;
            sum[2] = rem / 2;
          }
          sort(sum, sum + 3);
          res = min(res, sum[2] - sum[0]);
        } else {
          wcut = 1;
        }
        sum[0] = wcut * h;
        rem = total - sum[0];
        if (rem % 2) {
          ll remw = w - wcut;
          sum[1] = max(rem / 2 / remw * remw, rem / 2 / h * h);
          sum[2] = rem - sum[1];
        } else {
          sum[1] = rem / 2;
          sum[2] = rem / 2;
        }
        sort(sum, sum + 3);
        res = min(res, sum[2] - sum[0]);
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
N = int(input())
src = list(map(int, input().split()))

sum1 = sum2 = src[0]
op1 = op2 = 0
if sum1 < 1:
    op1 += (1 - sum1)
    sum1 = 1
if sum2 > -1:
    op2 += (sum2 + 1)
    sum2 = -1

for i in range(1,N):
    if i%2 == 1:
        if sum1 + src[i] > -1:
            op1 += (sum1 + src[i] + 1)
            sum1 = -1
        else:
            sum1 += src[i]
        if sum2 + src[i] < 1:
            op2 += (1 - sum2 - src[i])
            sum2 = 1
        else:
            sum2 += src[i]
    else:
        if sum2 + src[i] > -1:
            op2 += (sum2 + src[i] + 1)
            sum2 = -1
        else:
            sum2 += src[i]
        if sum1 + src[i] < 1:
            op1 += (1 - sum1 - src[i])
            sum1 = 1
        else:
            sum1 += src[i]

print(min(op1,op2))


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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

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


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll m,K;
  cin >> m >> K;
  if (K >= (1<<m)) {
        cout << -1 << endl;
        return 0;
  }
  if(K==0){
    rep(i,(1LL<<m)){
      if(((1LL<<m) - 1) != i) cout << i << ' ' << i << ' ';
      else cout << i << ' ' << i << endl;
    }
  }
  else if(m == 1 && K != 0){
    cout << -1 << endl;
    return 0;
  }
  else{

    VLL ans;
    bool used[(ll)(1<<m)];
    memset(used,0,sizeof(used));
    vector<PII> v;
    rep(i,(1<<m)){
      if(used[i]) continue;
      v.push_back(make_pair( min(i,K^i) , max(i,K^i) ));
      used[i] = true;
      used[K^i] = true;
    }
    for(ll i = 0; i < v.size(); i+=2){
      cout << v[i].first << ' ' << v[i].second << ' ' <<
              v[i+1].first << ' ' << v[i+1].second << ' ' <<
              v[i].second << ' ' << v[i].first << ' ' <<
              v[i+1].second << ' ' << v[i+1].first << ' ';
    }
    cout << endl;
  }


  return 0;
}


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

int main() {
    int h, a; cin >> h >> a;
    int ans = 0;
    while (h > 0) {
        h -= a;
        ans++;
    }
    cout << ans << endl;
}

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

using namespace std;
typedef long long ll;

int main(void)
{
    int n;
    cin >> n;
    vector<int> num(n);
    bool flag = true;
    for (int i = 0; i < n; i++)
    {
        cin >> num.at(i);
        if(num.at(i)%2==0){
            if (num.at(i) % 3 != 0 && num.at(i) % 5 != 0)
                flag = false;
        }
    }
    if(flag)
        cout << "APPROVED" << endl;
    else
        cout << "DENIED" << endl;

            return 0;
}

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



int main() 
{
  ll N,M; cin>>N>>M;
  ll T=(N-M)*100+1900*M;
  cout<<T*pow(2,M)<<endl;
  return 0;
}

Measured memory_bytes: 512
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
int gcd(int a, int b)
{
	if (a%b == 0)return b;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	int n; cin >> n;
	vector<ll> a(3 * n); rep(i, 3 * n)cin >> a[i];
	vector<ll> l(n + 1), r(n + 1);
	priority_queue<ll, vector<ll>, greater<ll>> lq;
	priority_queue<ll> rq;
	rep(i, n)
	{
		l[0] += a[i];
		lq.push(a[i]);
		r[n] += a[3 * n - 1 - i];
		rq.push(a[3 * n - 1 - i]);
	}
	rep(i, n)
	{
		l[i + 1] = l[i];
		ll mn = lq.top();
		if (mn < a[i + n])
		{
			l[i + 1] -= mn;
			l[i + 1] += a[i + n];
			lq.pop();
			lq.push(a[i + n]);
		}
	}
	rrep(i, n)
	{
		r[i] = r[i + 1];
		ll mx = rq.top();
		if (mx > a[n + i])
		{
			r[i] -= mx;
			r[i] += a[n + i];
			rq.pop();
			rq.push(a[n + i]);
		}
	}
	ll res = -1e18;
	rep(i, n + 1)chmax(res, l[i] - r[i]);
	cout << res << endl;
}

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

int main() {
    ll n,k,i,l,sum=0; cin>>n>>k; vector<ll>a;
    if (k>=n) {cout<<0; return 0;}
    for(i=0;i<n;i++) 
    { cin>>l; a.pb(l); }
    sort(a.begin(),a.end());
    for(i=0;i<n-k;i++) {sum+=a[i];}
    cout<<sum;
	return 0;
}

Measured memory_bytes: 5348
#include <cstdio>

const int MAX_N = 30;\
const int MAX_M = 30;

int N, M, idx;
int K[MAX_N];
int A[MAX_M];

int main() {
  scanf("%d %d", &N, &M);
  
  for (int i = 0; i < N; i++){
  	scanf("%d", &K[i]);
    for (int j = 0; j < K[i]; j++) {
      scanf("%d", &idx);
      A[idx-1] += 1;
    }
  }
  
  int count = 0;
  
  for (int i = 0; i < M; i ++){
  	if (A[i] == N) {
    	count += 1;
    }
  }
  printf("%d\n", count);
}

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

//https://atcoder.jp/contests/dp/tasks
vector<vector<int>> G;
int N,M;
vector<int> dp;
int  rec(int v){
    if(dp[v] != -1) return dp[v];
    int res = 0;
    for(auto nv : G[v]){
        res = max(res,rec(nv)+1);
    }
    return dp[v] = res;
}

int main(){
    cin >> N >> M;
    G.assign(N,vector<int>());//必要
    rep(i,M){
        int a,b;
        cin >> a >> b;
        --a;--b;
        G[a].push_back(b);
    }

    dp.assign(N+100,-1);
    int res = 0;
    for(int v = 0;v < N;v++){
        res = max(res,rec(v));
    }

    cout << res << endl;

}

Measured memory_bytes: 10976
#include <stdio.h>
#define INF (1<<28)
 
int n;
int g[101][101];
 
int mst() {
  int i, res, mini, id;
  int cost[101], vis[101];
  for(i = 0; i < 101; ++i) {
    cost[i] = INF;
    vis[i] = 0;
  }
  cost[0] = 0;
  res = 0;
  while(1) {
    mini = INF;
    id = -1;
    for(i = 0; i < n; ++i) {
      if(vis[i]) continue;
      if(cost[i] < mini) {
        mini = cost[i];
        id = i;
      }
    }
    if(id == -1) break;
    vis[id] = 1;
    res += cost[id];
    for(i = 0; i < n; ++i) {
      if(vis[i]) continue;
      if(g[id][i] < cost[i]) {
        cost[i] = g[id][i];
      }
    }
  }
  return res;
}
 
int main() {
  int i, j;
  scanf("%d", &n);
  for(i = 0; i < n; ++i) {
    for(j = 0; j < n; ++j) {
      scanf("%d", &g[i][j]);
      if(g[i][j] == -1) g[i][j] = INF;
    }
  }
  printf("%d\n", mst());
  return 0;
}


Measured memory_bytes: 2112
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template < typename T > string tost( const T& n ) { ostringstream stm; stm << n; return stm.str();}
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;}
int const INF = 1001001001;


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

int a,b,c; cin >> a >> b >> c;
if(a + b == c || b + c == a || c + a == b) cout << "Yes" << endl;
else cout << "No" << endl;

return 0;
}

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

void dfs(int,int);
char map[12][12];
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int main(){
    int cnt;
    while(1){
        cnt = 0;
        for(int i=0;i<12;i++){
            for(int j=0;j<12;j++){
                cin >> map[i][j];
            }
        }
        if(cin.eof()) break;
        for(int i=0;i<12;i++){
            for(int j=0;j<12;j++){
                if(map[i][j] == '1'){
                    cnt++;
                    dfs(j,i);
                }
            }
        }
        cout << cnt << endl;
    }
}

void dfs(int x,int y){
    map[y][x] = '0';
    for(int i=0;i<4;i++){
        int nx = x + dx[i];
        int ny = y + dy[i];
        if(nx >= 0 && nx < 12 && ny >= 0 && ny < 12 && map[ny][nx] == '1'){
            dfs(nx,ny);
        }
    }
}

Measured memory_bytes: 1140
#include <bits/stdc++.h>
using namespace std;
int main(){
int N,M;
cin >> N >> M;
int W = 0;
for(int i=0; i<M; i++){
  int A = 0;
  cin >> A;
  W += A;
}
if(W > N){
  cout << -1 << endl;
}
else{
  cout << N-W << endl;
}
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main() {
  int64_t n,a,b,i,s=0;
  map<int64_t,int64_t> m;
  string ans="Yes";
  cin>>n;
  for(i=0;i<n;i++){
    cin>>a>>b;
    if(m.count(b)) m.at(b)+=a;
    else m[b]=a;
  }
  for(auto z:m){
    s+=z.second;
    if(s>z.first){
      ans="No";
      break;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 12800
#include<iostream>
using namespace std;
int main() {
	int x,y;
	cin >> x >> y;
	if (x < y) {
		cout << "a < b" << endl;
	}
	else if (x > y) {
		cout << "a > b" << endl;
	}
	else if (x == y) {
		cout << "a == b" << endl;
	}
}


Measured memory_bytes: 3084
//#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<queue>
using namespace std;

#define INF 1e9

int main(){
  int N,M;
  cin >> N >> M;
  int a[M],b[M];
  int k;
  vector<int> c[M];
  for(int i=0;i<M;i++){
    cin >> a[i] >> b[i];
    for(int j=0;j<b[i];j++){
      cin >> k;
      c[i].push_back(k);
    }
  }
  int dp[M][5000];

  for(int i=0;i<M;i++){
    for(int j=0;j<5000;j++){
      dp[i][j] = INF;
    }
  }

  for(int i=0;i<M;i++){
    int now = 0;

    for(int j=0;j<b[i];j++){
      now |= (1 << (c[i][j]-1));
    }

    if(i == 0){
      dp[i][0] = 0;
      dp[i][now] = a[i];
    }

    else{
      for(int j=0;j<(1<<N);j++){
        dp[i][j] = dp[i-1][j];
      }

      for(int j=0;j<(1<<N);j++){
        if(dp[i][j|now] > min(dp[i-1][j|now],dp[i-1][j]+a[i])){
          dp[i][j|now] = min(dp[i-1][j|now],dp[i-1][j]+a[i]);
        }
      }
    }

  }

  if(dp[M-1][(1<<N)-1] == INF) cout << -1 << endl;
  else cout << dp[M-1][(1<<N)-1] << endl;


  return 0;
}


Measured memory_bytes: 19840
import java.util.*;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		String s = scan.next();
		char ans = s.charAt(s.length()-1);
		int n = (int)ans-48;
		
		while(true) {
			if(n>=10) {
				n -= 1;
			}else {
				break;
			}
		}
		
		if(n == 2 || n == 4 || n==5 || n== 7 || n==9) {
			System.out.println("hon");
		}else if(n==0 || n==1 || n== 6 || n==8) {
			System.out.println("pon");
		}else {
			System.out.println("bon");
		}
		
	}	
	
	
	//�ŏ�����
	/*
	static int gcd (int a, int b) {
		int temp;
		while((temp = a%b)!=0) {
			a = b;
			b = temp;
		}
		return b;
	}
	*/
	
	//����ւ�
	/*
	static int swap (int a, int b) {
		int swap_arr[] = new int[2];
		
		swap[0] = b;
		swap[1] = a;
		
		return swap_arr;
	}
	*/
	
}



Measured memory_bytes: 35696
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  cout << (n+999)/1000*1000-n << "\n";
  return 0;
}


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

using namespace std;

const int N = 1e5+1;

int n;
int a[N];
map<int, int> cnt;

int main(){
    ios_base::sync_with_stdio(false);
    cout.tie(0);
    cin.tie(0);
    cin >> n;
    for(int i = 0; i < n; ++i){
        cin >> a[i];
        ++cnt[a[i]];
    }
    if(cnt.size() == 1)
        cout << (a[0] ? "No" : "Yes") << '\n';
    else if(cnt.size() == 2){
        if(n%3){
            cout << "No\n";
            return 0;
        }
        int a = cnt.begin()->first,
            b = next(cnt.begin())->first;
        if(cnt[a] > cnt[b])
            swap(a, b);
        if(cnt[a] != n/3){
            cout << "No\n";
            return 0;
        }
        cout << (a ? "No" : "Yes") << '\n';
    }
    else if(cnt.size() == 3){
        if(n%3){
            cout << "No\n";
            return 0;
        }
        int a = cnt.begin()->first,
            b = next(cnt.begin())->first,
            c = next(next(cnt.begin()))->first;
        if(cnt[a] != n/3 || cnt[b] != n/3){
            cout << "No\n";
            return 0;
        }
        cout << (a^b^c ? "No" : "Yes") << '\n';
    }
    else cout << "No\n";
}


Measured memory_bytes: 4224
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons;

void main()
{
    auto abc = readln.split.to!(int[]);
    writeln(abc[0] == abc[1] ? abc[2] : abc[0] == abc[2] ? abc[1] : abc[0]);
}

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

int main(){

    queue<int> que;
    int num;

    while(1){
       cin >> num;
       if(num == 0){
           break;
       }
       que.push(num); 
    }
    
    int que_size = que.size();

    for(int i=1; i <= que_size; i++){
        cout << "Case " << i << ": " << que.front() << endl;
        que.pop();
    }

    return 0;
}

Measured memory_bytes: 3064
/// kAAzuki Hoshino
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}

int n;

signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
	
	cin >> n;
	// vi v;
	// for(int i=1;i<=n;i++){
	// 	v.pb(i);
	// }
	// int ans = 0;
	// do{
	// 	int cur = 0;
	// 	for(int i=0;i<n;i++){
	// 		cur+= v[i]%(i+1);
	// 	}
	// 	ans = max(ans, cur);

	// }while(next_permutation(all(v)));
	int ans = (n*(n-1))/2;
	cout << ans << endl;

return 0;
}
///....


Measured memory_bytes: 256
const [meta,a,b,c] = require('fs').readFileSync('/dev/stdin', 'utf-8').split('\n');

const [X,Y,Z,K] = meta.trim().split(' ').map(i => parseInt(i));
const A = a.trim().split(' ').map(i => parseInt(i)).slice(0,X).sort((a,b)=>b-a);
const B = b.trim().split(' ').map(i => parseInt(i)).slice(0,Y).sort((a,b)=>b-a);
const C = c.trim().split(' ').map(i => parseInt(i)).slice(0,Z).sort((a,b)=>b-a);

const result = [];
const queue = [{
    p: A[0]+B[0]+C[0],
    x: 0,
    y: 0,
    z: 0
}];

const addToQueue = (p,x,y,z) => {
    if (!queue.find(v => v.p === p && v.x === x && v.y === y && v.z === z)
    && !result.find(v => v.p === p && v.x === x && v.y === y && v.z === z)) {
        queue.push({p,x,y,z});
    }
}

const min = (i,arr) => Math.min(i,arr.length - 1);

Array.from(Array(K)).forEach(() => {
    const largest = queue.sort((a,b)=>a.p-b.p).pop();
    result.push(largest);
    const {x,y,z} = largest;
    addToQueue(A[min(x+1,A)]+B[y]+C[z],min(x+1,A),y,z);
    addToQueue(A[x]+B[min(y+1,B)]+C[z],x,min(y+1,B),z);
    addToQueue(A[x]+B[y]+C[min(z+1,C)],x,y,min(z+1,C));
});

console.log(result.map(v => v.p).join('\n'));

Measured memory_bytes: 17580
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
int r,c,n;
int x,y,px,py,ck[100007],cnt=0,in[100007];
vector <int> pt[5];
map < pair<int,int> ,int > col;
stack <int> st;
void check(int x,int y){
	if(x==0) pt[1].pb(y);
	else if(y==c) pt[2].pb(x);
	else if(x==r) pt[3].pb(y);
	else if(y==0) pt[4].pb(x);
	else cnt--;
}
int main(){
	ios_base::sync_with_stdio(0);
	cin>>r>>c>>n;
	for(int i=1;i<=n;i++){
		cin>>x>>y>>px>>py;
		col[mp(x,y)]=i;
		col[mp(px,py)]=i;
		cnt=0;
		check(x,y);
		check(px,py);
		if(cnt==0) ck[i]=1;
		//cout<<ck[i]<<endl;
	}
	for(int i=1;i<=2;i++) sort(pt[i].begin(),pt[i].end());
	for(int i=3;i<=4;i++) sort(pt[i].begin(),pt[i].end(),greater<int>());
	for(int y:pt[1]){
		x=0;
		//cout<<x<<" "<<y<<endl;
		int cl=col[mp(x,y)];
		if(!ck[cl]) continue;
		if(!st.empty()){
			if(in[cl] && st.top()!=cl) return cout<<"NO", 0;
			else if(in[cl] && st.top()==cl) st.pop(), in[cl]=0;
			else st.push(cl), in[cl]=1;
		}
		else{
			st.push(cl), in[cl]=1;
		}
	}
	for(int x:pt[2]){
		y=c;
		//cout<<x<<" "<<y<<endl;
		int cl=col[mp(x,y)];
		if(!ck[cl]) continue;
		if(!st.empty()){
			if(in[cl] && st.top()!=cl) return cout<<"NO", 0;
			else if(in[cl] && st.top()==cl) st.pop(), in[cl]=0;
			else st.push(cl), in[cl]=1;
		}
		else{
			st.push(cl), in[cl]=1;;
		}
	}
	for(int y:pt[3]){
		x=r;
		//cout<<x<<" "<<y<<endl;
		int cl=col[mp(x,y)];
		if(!ck[cl]) continue;
		if(!st.empty()){
			if(in[cl] && st.top()!=cl) return cout<<"NO", 0;
			else if(in[cl] && st.top()==cl) st.pop(), in[cl]=0;
			else st.push(cl), in[cl]=1;
		}
		else{
			st.push(cl), in[cl]=1;
		}
	}
	for(int x:pt[4]){
		y=0;
		//cout<<x<<" "<<y<<endl;
		int cl=col[mp(x,y)];
		if(!ck[cl]) continue;
		if(!st.empty()){
			if(in[cl] && st.top()!=cl) return cout<<"NO", 0;
			else if(in[cl] && st.top()==cl) st.pop(), in[cl]=0;
			else st.push(cl), in[cl]=1;
		}
		else{
			st.push(cl), in[cl]=1;
		}
	}
	cout<<"YES";
}


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

int main() {
    int A1, A2, A3;
    cin >> A1 >> A2 >> A3;
    cout << min({abs(A1 - A2) + abs(A1 - A3), abs(A1-A2) + abs(A2 - A3), abs(A2 - A3) + abs(A1 - A3)}) << endl;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n, y int
	fmt.Scan(&n, &y)
	fmt.Println(calcMoney(n, y))
}

func calcMoney(n int, yen int) (str string) {
	for x := 0; x <= n; x++ {
		for y := 0; y <= n-x; y++ {
			z := n - x - y
			if 0 <= z {
				if yen == 10000*x+5000*y+1000*z {
					return fmt.Sprintf("%d %d %d", x, y, z)
				}
			}
		}
	}
	return "-1 -1 -1"
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
						
#define fast_cin() ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define endl '\n'
#define int long long

const int N = 2e5 + 5;

vector<int> g[2][N];

void testcase() {
	int n; cin >> n;
	int ans = 0;
	for (int i = 0; i < n; ++i) {
		int k, l, r; cin >> k >> l >> r;
		if (l >= r) {
			g[0][k].push_back(l - r);
		} else {
			g[1][n - k].push_back({r - l});
		}
		ans += min(l, r);
	}
	for (int u : {0, 1}) {
		multiset<int> now;
		for (int k = 1; k <= n; ++k) {
			for (int &profit : g[u][k]) {
				now.insert(profit);
				ans += profit;
			}
			while ((int)now.size() > k) {
				ans -= *now.begin();
				now.erase(now.find(*now.begin()));
			}
		}
	}
	cout << ans << endl;
	for (int i = 1; i <= n; ++i) {
		g[0][i].clear(), g[1][i].clear();
	}
}
				
int32_t main() {
	fast_cin();  
	int T; cin >> T;
	while (T--) {
		testcase();
	}
	return 0;
}

Measured memory_bytes: 22484
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#define InfL 1000000000
#define InfLL 1000000000000000000LL
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=(n-1);(i)>=(0);(i)--)
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;

int main() {
	int N, K, C;
	cin >> N >> K >> C;
	C++;
	string S;
	cin >> S;
	vi L(N + 2), R(N + 2);
	L[0] = 0;
	R[N + 1] = 0;
	rep(i, N) {
		if (S[i] == 'o')
			L[i + 1] = L[max(i + 1 - C, 0)] + 1;
		else
			L[i + 1] = L[i];
	}
	rrep(i, N) {
		if (S[i] == 'o')
			R[i + 1] = R[min(i  + 1 + C, N + 1)] + 1;
		else
			R[i + 1] = R[i + 2];
	}
	L[N + 1] = L[N];
	R[0] = R[1];
	vi anslist;
	rep(i, N) {
		if (S[i] == 'o' && L[i] + R[i + 2] < K) {
			anslist.push_back(i + 1);
		}
	}

	rep(i, anslist.size())
		cout << anslist[i] << endl;
	return 0;
}

Measured memory_bytes: 4216
#include<stdio.h>

int main()
{
    int n,d,x,k,a[200];
    scanf("%d%d%d",&k,&d,&x);
    n=k;
    while(n--)
        scanf("%d",&a[n]);
    int i,j,s=0;
    for(i=0;i<k;i++)
    {
        for(j=0;;j++)
        {
            if(a[i]*j+1<=d)
                s++;
            else
                break;
        }
    }
    printf("%d\n",s+x);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto itr : x) { debug(itr); }

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

// 素因数分解
/*
 * [2]-> 5, [3] -> 5のとき N = 2^5 * 3^5
 */
template<typename T>
map<T, long long> factorize(T x) {
  map<T, long long> res;
  for (long long i = 2; i * i <= x; ++i) {
    while (x % i == 0) {
      x /= i;
      res[i] += 1;
    }
  }
  if (x != 1) res[x]++;
  return res;
}

int main() {
  ll n, p;
  cin >> n >> p;

  ll total = 0, ans = 1;
  if (p == 1) {
    cout << 1 << endl;
    return 0;
  }
  auto mp = factorize(p);
  bool flag = true;
  for (auto itr : mp) {
    total += itr.second;
    auto pp = itr.second;
    if (itr.second >= n) {
      while (pp >= n) {
        ans *= itr.first;
        pp -= n;
      }
    }
  }

  

  if (flag) cout << ans << endl;
  else cout << 1 << endl;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
nl = [ 0 for i in range(0,n+1)]
ans = 0
for i in a:
    nl[i] += 1
temp = [int(i*(i-1)/2) for i in nl if i >= 2 ]
all = sum(temp)
for i in a:
  if nl[i] < 2:
      print(all)
      continue
  if nl[i] == 2:
      ans = all -1
  else:
      ans = all - (nl[i]-1)
  print(ans)
    


Measured memory_bytes: 26140
#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: 256
#include <bits/stdc++.h>

using namespace std;

int main()
{
    string s;
    cin >> s;
    int l = s.length();
    int ans = 0;
    for(int i = 0; i < l; i++)
    {
        if(s[i] != 'A' && s[i] != 'T' && s[i] != 'G' && s[i] != 'C') continue;
        int j = i;
        while(1)
        {
            if(i+1 >= l) break;
            if(s[i+1] != 'A' && s[i+1] != 'T' && s[i+1] != 'G' && s[i+1] != 'C') break;
            i++;
        }
        ans = max(ans,i-j+1);
        i++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3560
import java.util.Scanner

fun main() {
	val scn = Scanner(System.`in`)
	var n = scn.nextLong()
	var s = ""
	var d = 1
	var dk = 26L
	val pw = mutableListOf(26L)
	while (n>dk){
		pw.add(pw.last()*26)
		dk += pw.last()
		d++
	}
	n -= dk-pw.last() + 1
	val a = 'a'.toInt()
	repeat(d){
		val r = (n%26).toInt()
		s = (a+r).toChar() + s
		n /= 26
	}
	println(s)
}

Measured memory_bytes: 37548
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

typedef struct{
	int parent;
	int left,right;
}NODE;

int calc_sibling(NODE *node,int x){
	if(node[x].parent==-1){
		return -1;
	}
	int parent=node[x].parent;
	if(node[parent].left==x){
		return node[parent].right;
	}else{
		return node[parent].left;
	}
}

int calc_degree(NODE *node,int x){
	int count=0;
	if(node[x].left!=-1){
		count++;
	}
	if(node[x].right!=-1){
		count++;
	}
	return count;
}

int calc_depth(NODE *node,int x){
	int depth=0;
	while(node[x].parent!=-1){
		x=node[x].parent;
		depth++;
	}
	return depth;
}

int calc_high(NODE *node,int x,int high){
	int L=0,R=0;

	if(node[x].left==-1 && node[x].right==-1){
		return high;
	}
	
	if(node[x].left!=-1){
		L=calc_high(node,node[x].left,high+1);
	}
	if(node[x].right!=-1){
		R=calc_high(node,node[x].right,high+1);
	}
	if(L<R){
		return R;
	}else{
		return L;
	}
}

char *calc_type(NODE *node,int x){
	if(node[x].parent==-1){
		return "root";
	}
	if(node[x].left==-1 && node[x].right==-1){
		return "leaf";
	}
	return "internal node";
}

int main(){
	int N;
	NODE *node;
	int number,left,right;

	scanf("%d",&N);
	node=(NODE*)malloc(sizeof(NODE)*N);

	for(int i=0;i<N;i++){
		node[i].parent=-1;
		node[i].left=-1;
		node[i].right=-1;
	}
	for(int i=0;i<N;i++){
		scanf("%d %d %d",&number,&left,&right);
		node[number].left=left;
		node[number].right=right;
		if(left!=-1){
			node[left].parent=number;
		}
		if(right!=-1){
			node[right].parent=number;
		}
	}

	for(int i=0;i<N;i++){
		printf("node %d: parent = %d, ",i,node[i].parent);
		printf("sibling = %d, ",calc_sibling(node,i));
		printf("degree = %d, ",calc_degree(node,i));
		printf("depth = %d, ",calc_depth(node,i));
		printf("height = %d, ",calc_high(node,i,0));
		printf("%s",calc_type(node,i));
		printf("\n");
	}

	return 0;
}


Measured memory_bytes: 2100
#include "bits/stdc++.h"

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define ll1 1ll
#define ONE 1ll
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
	is >> p.first >> p.second;
	return is;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> &p) {
	os << p.first << " " << p.second;
	return os;
}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}
/*
typedef __int128_t Int;
std::ostream &operator<<(std::ostream &dest, __int128_t value) {
std::ostream::sentry s(dest);
  if (s) {
	__uint128_t tmp = value < 0 ? -value : value;
	char buffer[128];
	char *d = std::end(buffer);
	do {
	  --d;
	  *d = "0123456789"[tmp % 10];
	  tmp /= 10;
	} while (tmp != 0);
	if (value < 0) {
	  --d;
	  *d = '-';
	}
	int len = std::end(buffer) - d;
	if (dest.rdbuf()->sputn(d, len) != len) {
	  dest.setstate(std::ios_base::badbit);
	}
  }
  return dest;
}

__int128 parse(string &s) {
  __int128 ret = 0;
  for (int i = 0; i < s.length(); i++)
	if ('0' <= s[i] && s[i] <= '9')
	  ret = 10 * ret + s[i] - '0';
  return ret;
}
*/

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
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;
}

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	vector<int>v(4);
	loop(3) {
		int a, b; cin >> a >> b;
		a--, b--;
		v[a]++;
		v[b]++;
	}
	sort(all(v));
	vector<int>w = { 1,1,2,2 };
	YES(v == w);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);


int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll> trans(n+1, 0);
    for(int i = 1; i <= n; i++)
        cin >> trans[i];
    vector<ll> visit(n+1, -1);
    visit[1] = 0;
    ll idx = 0, pos = 1, cycle;
    while(true) {
        ll nxt = trans[pos];
        if (visit[nxt] == -1) {
            visit[nxt] = ++idx;
            if (idx == k) {
                cout << nxt << endl;
                return 0;
            }
            pos = nxt;
        } else {
            cycle = idx+1-visit[nxt];
            // cout << "nxt " << nxt << endl;
            // cout << idx+1 << ", prev " << visit[nxt] << endl;
            idx++;
            k = (k-idx) % cycle;
            pos = nxt;
            break;
        }
    }
    // cout << "cycle " << cycle << endl;
    while(k-- > 0) {
        pos = trans[pos];
    }
    cout << pos << endl;
    return 0;
}



Measured memory_bytes: 6376
#include <stdlib.h>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <string>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
using namespace std;
using ll = long long;

#define INF 1000000

int main(){
  string S,T;
  cin >> S >> T;

  int ans=INF;
  int T_size=T.size();
  for(int i=0;i<S.size();++i){
    if(i+T_size>S.size()) break;
    string temp=S.substr(i,T_size);
    int temp_a=0;
    for(int j=0;j<T.size();++j){
      if(temp.at(j)!=T.at(j)) ++temp_a;
    }
    ans=min(ans,temp_a);
  }

  if(ans!=INF) cout << ans << endl;
  else cout << T.size() << endl;
  
  return 0;
}


Measured memory_bytes: 3608
import math
a,b,C = map(int,input().split())
S = 0.5*a*b*math.sin(C*math.pi/180)
c = math.sqrt(a**2+b**2-2*a*b*math.cos(C*math.pi/180))
L = a+b+c
h = 2*S/a
print("%.4f"%S)
print("%.4f"%L)
print("%.4f"%h)


Measured memory_bytes: 5708
#include<stdio.h>
int main(void)
{
  int sum,i,value,count=0;
  while(1) {
    //printf("sum:");
    scanf("%d",&sum);
    if(sum==0) break;
    for(i=0;i<9;i++)
    {
      scanf("%d",&value);
      sum-=value;
    }
    printf("%d\n",sum);
  }
  return 0;
}



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

typedef    long long          ll;
typedef    vector<long long>    vi; 
typedef    vector<vi>         vvi; 
typedef    pair<long,long>      ii; 
#define    sz(a)              long((a).size()) 
#define    pb                 push_back 
#define    mp                   make_pair
#define    all(c)             (c).begin(),(c).end() 
#define    tr(c,i)            for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++) 
#define    present(c,x)       ((c).find(x) != (c).end()) 
#define    cpresent(c,x)      (find(all(c),x) != (c).end())  
#define    input(v,n)           for(ll i = 0 ; i<n ; i++) cin>>v[i]
#define    output(v,n)          for(ll i = 0 ; i<n ; i++) cout<<v[i]<<" "


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

  ll n,i,j,k;
  cin>>n>>k;
  ll a[n+1];


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

  for(i=n-2;i>=0;i--)
  {dp[i]=1e15;
    for(j=1;j<=k && i+j < n;j++)
    {
    dp[i]=min((ll)abs(a[i+j]-a[i])+dp[i+j],dp[i]);
}
  }

  cout<<dp[0];

  return 0;
 }

Measured memory_bytes: 1792
#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 <math.h>
using namespace std;
#define int long long


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

    int h,w; cin >> h >> w;
    vector<string> s(h);
    for(int i = 0;i < h;i ++) cin >> s.at(i);

    vector<int> x(8),y(8);
    x.at(0)=-1;x.at(1)=-1;x.at(2)=-1;x.at(3)=0;x.at(4)=0;x.at(5)=1;x.at(6)=1;x.at(7)=1;
    y.at(0)=-1;y.at(1)=0;y.at(2)=1;y.at(3)=-1;y.at(4)=1;y.at(5)=-1;y.at(6)=0;y.at(7)=1;

    for(int i = 0;i < h;i ++){
        for(int j = 0;j < w;j ++){
            if(s.at(i).at(j) =='#') continue;

            int count = 0;
            for(int k = 0;k < 8;k ++){
                if(0<=i+x.at(k) && i+x.at(k)<h && 0<=j+y.at(k) && j+y.at(k)<w && s.at(i+x.at(k)).at(j+y.at(k)) == '#') count ++;
            }

            s.at(i).at(j) = count + '0';
        }
    }

    for(int i = 0;i < h;i ++){
        for(int j = 0;j < w;j ++){
            cout << s.at(i).at(j);
        }
        cout << endl;
    }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <stdlib.h>
#include <utility>
#include <math.h>
#include <stdexcept>
#include <algorithm>
#include <vector>
#include <cstring>
#include <string>
#include <cassert>
#include <string.h>
#include <tuple>

using namespace std;
#define  rep(i,n) for(int i=0;i<n;i++)
#define  rrep(i,n) for(int i=n-1;i>=0;i--)///n-1番目からn回
#define  REP(i,a,b) for(int i=a;i<=b;i++) ///a番目からb回
#define  RREP(i,a,b) for(int i=a;i<b;i--)
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pair_t;
#define MOD 1000003

//int arr[N]
////sort(arr,arr +N)

//vector <int> hoge
////sort(hoge.begin(),hoge.end());
///*min_element(hoge.begin(),hoge.end();　最小値　　　最大値はmax_element();
///(10-(n%10))%10  1桁目取得

#define Ru(n)  ( ((n)+9)/10*10  ) //切りあげ
#define Rd(n)  ( ((n)-10)/10*10 +10 )	切り捨て

typedef tuple<string,int,int> mytuple;////mytupleというtuple型

int gcd(int a,int b);
size_t length(const std::string& str) {
	return str.length();
}
bool comp(const pair_t &a, const pair_t &b) {
	return a.first < b.first;
}


bool mycompare1 (const mytuple &lhs, const mytuple &rhs){
	return get<1>(lhs) < get<1>(rhs);
}
bool mycompare2 (const mytuple &lhs, const mytuple &rhs){
	return get<2>(lhs) >get<2>(rhs);
}


int main() {

	int n;
	cin>>n;
	vector<mytuple> X;
	string rest;
	int score;
	rep(i,n) {
		cin >>rest>>score;
		X.push_back(make_tuple(rest,-score,i));
	}
	sort( X.begin(),X.end());//scoreでsort

	rep(i,n)
		cout << (get<2>(X[i]))+1<< endl;


	return 0;

}




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


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

int main() {
  string s;
  cin >> s;
  int l, r;
  rep(i, s.size()) if (s[i] == 'A') {
    l = i;
    break;
  }
  for (int i = s.size() - 1; i >= 0; --i) if (s[i] == 'Z') {
    r = i;
    break;
  }
  int ans = r - l + 1;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3744
N, M = map(int, input().split())
edge = [[] for _ in range(N)]
for i in range(M):
    A, B = map(int, input().split())
    edge[A-1].append(B-1)
    edge[B-1].append(A-1)
S = set()
S.add(0)
S.add(edge[0][0])
now = 0
ans1 = [1]
while True:
    next_v = -1
    for v in edge[now]:
        if v not in S:
            next_v = v
    if next_v<0:
        break
    now = next_v
    S.add(now)
    ans1.append(now+1)
now = edge[0][0]
ans2 = [edge[0][0]+1]
while True:
    next_v = -1
    for v in edge[now]:
        if v not in S:
            next_v = v
    if next_v<0:
        break
    now = next_v
    S.add(now)
    ans2.append(now+1)
ans = ans1[::-1]+ans2
print(len(ans))
print(*ans)

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

const int maxn=1e5+10;
int n,ord[maxn],cnt,deg[maxn],ans1[maxn],ans2[maxn];
vector<int> vec[maxn],g[maxn];

int main(){
	scanf("%d",&n);
	for(int i=1,u,v;i<n;++i){
		scanf("%d%d",&u,&v);
		vec[u].push_back(v);
		vec[v].push_back(u);
	}
	if(n<=3){
		for(int i=1;i<=n;++i)
			printf("%d\n",i);
		return 0;
	}
	for(int i=1;i<=n;++i)
		if(vec[i].size()==1)
			++deg[vec[i][0]];
		else
			for(int j=0;j<vec[i].size();++j)
				if(vec[vec[i][j]].size()!=1)
					g[i].push_back(vec[i][j]);
	for(int i=1;i<=n;++i)
		if(g[i].size()>2){
			puts("-1");
			return 0;
		}
	for(int i=1;i<=n;++i)
		if(g[i].size()==1){
			for(int p=i,last=-1;;){
				ord[++cnt]=p;
				bool flag=false;
				for(int j=0;j<g[p].size();++j)
					if(g[p][j]!=last){
						flag=true;
						last=p;
						p=g[p][j];
						break;
					}
				if(!flag)
					break;
			}
			goto fxckglt;
		}
	printf("1 ");
	for(int i=2;i<=n-2;++i)
		printf("%d ",i+1);
	printf("2 %d",n);
	return 0;
fxckglt:
	--deg[ord[1]];
	--deg[ord[cnt]];
	++cnt;
	for(int i=0,top=0;i<=cnt;++i){
		for(int j=0;j<deg[ord[i]];++j)
			++top,ans1[top]=top+1;
		++top;
		ans1[top]=top-deg[ord[i]];
	}
	for(int i=cnt,top=0;~i;--i){
		for(int j=0;j<deg[ord[i]];++j)
			++top,ans2[top]=top+1;
		++top;
		ans2[top]=top-deg[ord[i]];
	}
	for(int i=1;i<=n;++i)
		if(ans1[i]<ans2[i]){
			for(int j=1;j<=n;++j)
				printf("%d ",ans1[j]);
			return 0;
		}
		else if(ans1[i]>ans2[i]){
			for(int j=1;j<=n;++j)
				printf("%d ",ans2[j]);
			return 0;
		}
	for(int i=1;i<=n;++i)
		printf("%d ",ans1[i]);
	return 0;
}

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

int main() {
    string s;
    cin >>s;
    string a;
    if (s[0]=='S')
    {
        a="Cloudy";
        cout << a<< endl;
    }
     else if(s[0]=='C'){
        a="Rainy";
        cout << a<< endl;
    }
    else if(s[0]=='R'){
        a="Sunny";
        cout << a<< endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repr(i,a,n) for(int i=a;i>=n;i--)
#define INF 999999999
#define INF_M 2147483647
#define pb(a) push_back(a)

using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef vector<pii> VP;

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

int main() {
    string s1,s2;
    cin >> s1 >> s2;

    int dp[1010][1010];
    rep(i,0,s1.size()+1) dp[i][0] = i;
    rep(j,0,s2.size()+1) dp[0][j] = j;

    rep(i,0,s1.size()) {
        rep(j,0,s2.size()) {
            dp[i+1][j+1] = min(dp[i][j+1], dp[i+1][j]) + 1;
            dp[i+1][j+1] = min(dp[i+1][j+1], dp[i][j] + (s1[i] != s2[j]));
        }
    }

    cout << dp[s1.size()][s2.size()] << endl;
    return 0;
}

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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if ((a + b == c) || (b + c == a) || (c + a == b)) {
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}


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

#define debug(a) cout << #a << " " << a << endl;
#define _debug(a, i) cout << #a << "[" << i << "]" << " = " << a[i] << endl;
#define fastio ios_base::sync_with_stdio(false); \
			cin.tie(0);							 \
			cout.tie(0);
#define PI 3.141592654

using namespace std;

using ll = long long;
const int MOD = 1e9 + 7;
const ll INF = 1e18 + 9;

ll powmod(ll base, ll exp, const ll MOD) { ll ans = 1; while (exp) { if (exp & 1)	ans = (ans * base) % MOD; base = (base * base) % MOD; exp >>= 1; }return ans; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }
ll modInverse(ll n, const ll p) { return powmod(n, p - 2, p); }
void add(ll& x, ll v) { x = (x + v) % MOD; if (x < 0) x += MOD; }
//ll f[500005];
//ll kCn(ll k, ll n) { return (f[n] * modInverse((f[n - k] * f[k]) % MOD, MOD)) % MOD; }


void test_case() {

}


int main() {
	fastio;
	//#ifndef ONLINE_JUDGE
	//	freopen("input.txt", "r", stdin);
	//	freopen("output.txt", "w", stdout);
	//#endif // !ONLINE_JUDGE
	int n;
	cin >> n;
	vector<ll> a(n);
	bool zero = false;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		if (a[i] == 0)
			zero = true;
	}
	
	if (zero)
		cout << 0;
	else {
		ll ans = 1;
		for (int i = 0; i < n; ++i) {
			// ans * a[i] > 1e18
			if (a[i] <= 1000000000000000000/ans) {
				ans *= a[i];
			}
			else {
				ans = -1;
				break;
			}
		}
		cout << ans;
	}
	return 0;
}


Measured memory_bytes: 3924
h,w,d=map(int,input().split())
a=[ list(map(int,input().split())) for _ in range(h) ]
q=int(input())
cost=[0 for _ in range(h*w+1)]
pos=dict()
l=[]
for i in range(h):
    for j in range(w):
        pos[a[i][j]]=[i,j]
        l.append((a[i][j],i,j))
l.sort()
for val,x,y in l:
    if val-d<=0:
        cost[val]=0
    else:
        cost[val]=cost[val-d]+abs(pos[val][0]-pos[val-d][0])+abs(pos[val][1]-pos[val-d][1])
#print(l)
for _ in range(q):
    l,r=map(int,input().split())
    print(cost[r]-cost[l])


Measured memory_bytes: 33692
#include<bits/stdc++.h>
#include<string>
using namespace std;
#define LL long long int
#define DL double
#define MLL map<LL,LL>::iterator
#define MSL map<string,L>::iterator
#define MLS map<LL,string>::iterator
#define MSS map<string,string>::iterator
#define MCL map<char,LL>::iterator
#define SL set<LL>::iterator
#define SS set<string>::iterator
#define VL V<LL>::iterator
#define G getline
#define SZ size()
#define IN insert
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define MAX 1e18
#define MIN -1e18
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
V<LL>v;
int main()
{
    LL n,m,i,j,k,p,q,o,l,s,t,z=0,r;
    string a;
   cin>>n;
   for(i=0;i<n;i++)
   {
       cin>>o;
       v.PSB(o);
   }
   sort(v.B,v.E);
   k=v[n-1]/2;
   for(i=0;i<n-1;i++)
   {
       k+=v[i];
   }
   cout<<k<<endl;
    return 0;
}


Measured memory_bytes: 256