akhauriyash/Code-Regression huggingface dataset:
N=int(input())
A=list(map(int,input().split()))
mod = 10**9+7
base = [(2**i)%mod for i in range(63,-1,-1)]

count = [0 for i in range(64)]
for i in range(N):
  b = list(map(int, list(bin(A[i])[2:])))
  b = [0]*(64-len(b))+b
  for j in range(64):count[j]+=b[j]

print(sum([base[i]*count[i]*(N-count[i]) for i in range(64)])%mod)


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

def calculate(s):
  if len(s) > 1:
    if int(s) > N:
      return 0
  
  ret = 1 if all([s.count(c) for c in '753']) else 0
  
  for i in '753':
    ret +=calculate(s+i)
  return ret

print(calculate(''))

Measured memory_bytes: 3060
N = int(input())
L0 = 2
L1 = 1

if N == 0:
    print(L0)
elif N == 1:
    print(L1)
else:
    for _ in range(2, N+1):
        L2 = L0 + L1
        L0, L1 = L1, L2
    print(L2)

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
#define INF 1e9
#define rep(i, n) for(int i=0;i<n;i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<double> VD;  
typedef vector<string> VS;  
typedef vector<char> VC; 
typedef vector<VS> VSS;
typedef vector<VC> VCC;    
typedef vector<VI> VII;   // VII a(n,vector<int>(m)) n * m 
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;   //MP a;
typedef vector<pair<int, int> > PS;
typedef long long ll;  //ll とdoubleは違う
template <class T, class U>  // chmax(max, a);
bool chmax(T &a, U b){
    if (a < b){ a = b;return 1;}
    return 0;
}
template <class T, class U> //chmin(min,a)
bool chmin(T &a, U b){
    if (a > b){ a = b; return 1;}
    return 0;
}
template<typename T>   // operator << (cout,a);
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}
   
// g++ -std=c++11 prac.cpp
        
int main(){
    int a,b,c,d,n,x,y=0,z,m,k,w,sum=0,ans=0,Max=-1e9,Min=1e9+1;
    string s,t,u;
    bool count=false,ok=true;
    cin >> n >> a >> b >> c >> d >> s;
    s = "#" + s + "#";
    for(int i=a; i+1<=c;i++){
        if(s[i]=='#' && s[i+1] =='#')
            ok=false;
    }
    for(int i=b; i+1<=d;i++){
        if(s[i]=='#' && s[i+1] =='#')
            ok=false;
    }
    if(!ok){
        cout << "No" << endl;
        return 0;
    }

    if(c>d){
        ok=false;
        for(int i=b;i<=d;i++){
            if(s[i-1]=='.' && s[i]=='.' && s[i+1]=='.')
                ok=true;
        }
        if(!ok){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 772
m, n = gets.split.map(&:to_i)
grid = m.times.map { gets.chomp }
  dp = Array.new(m, 0) { Array.new(n, 0) }
  dp[0][0] = 1
    
  (0...m).each do |i|
    (0...n).each do |j|
      next if grid[i][j] == '#'
      dp[i][j] = dp[i-1][j] + dp[i][j-1] if dp[i][j] == 0
      dp[i][j] %= 10**9 + 7
    end
  end
  puts dp[m-1][n-1]

Measured memory_bytes: 11900
#include<iostream>
#include<cstring>
#define ll long long
#define N 12345
using namespace std;
ll n,ans,a[N][N];
bool p[N][N];
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++) cin>>a[i][j];
    for(int i=1;i<=n;i++)      
        for(int j=1;j<=n;j++)
            for(int k=1;k<=n;k++)
			{
                if(i!=k&&i!=j&&j!=k)
				{
                    if(a[j][k]==a[j][i]+a[i][k])
                        p[j][k]=1;
                    if(a[j][k]>a[j][i]+a[i][k])
					{
                        cout<<"-1"<<endl;
                        return 0;
                    }
                }
            }
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
            if(p[i][j]==0) ans+=a[i][j];
    cout<<ans/2<<endl;
    return 0;
}

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

import sys
from itertools import accumulate

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

def divmod(a, b):
    d = a // b
    m = a % b
    return (d, m)

N = INT()
A = LIST()
B = LIST()

S1 = []
S2 = []
for i in range(3):
    if A[i] < B[i]:
        S1.append(i)
    else:
        S2.append(i)
        A[i], B[i] = B[i], A[i]

def calc(cnt, i):
    d, m = divmod(cnt, A[i])
    return d * B[i] + m

def count(S, N):
    if len(S) == 0:
        return N
    elif len(S) == 1:
        return calc(N, S[0])
    elif len(S) == 2:
        res = 0
        for x in range(N+1):
            y = N - x
            if y < 0:
                break
            cnt = calc(x, S[0]) + calc(y, S[1])
            res = max(res, cnt)
        return res
    else:
        res = 0
        for x in range(N+1):
            for y in range(N+1):
                z = N - x - y
                if z < 0:
                    break
                cnt = calc(x, S[0]) + calc(y, S[1]) + calc(z, S[2])
                res = max(res, cnt)
        return res

N2 = count(S1, N)
ans = count(S2, N2)
print(ans)


Measured memory_bytes: 42032
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int main() {
	int N;
	cin >> N;

	int ans = 0;

	for (int i = 0; i < N; i++)
	{
		int l, r;
		cin >> l >> r;
		ans += (r - l + 1);
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	long long n,i, sum = 0, t = 0, max = -10000000, min = 10000000;
	scanf("%lld", &t);
	for ( i = 1; i <= t; i++)
	{
		scanf("%lld ", &n);

		if (max < n)
			max = n;

		if (min > n)
			min = n;

		sum = sum + n;
	}
	printf("%lld %lld %lld\n", min, max, sum);
	return 0;
}


Measured memory_bytes: 2112
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
typedef long long int ll;

int dp[10010];

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n,W; cin >> n >> W;
	vector<int> v(n),w(n);
	for(int i=0;i<n;i++){
		cin >> v[i] >> w[i];
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<=W;j++){
			if(j+w[i]<=W){
				dp[j+w[i]]=max(dp[j+w[i]],dp[j]+v[i]);
			}
			dp[j+1]=max(dp[j+1],dp[j]);
		}
	}
	cout << dp[W] << endl;
}



Measured memory_bytes: 3264
#include <bits/stdc++.h>
using namespace std;
#define int long long int
signed  main() {
    long double a,b,c;
    cin>>a>>b>>c;
    
    a+=b+2*sqrt(a*b);
    
    if(a<c)
    cout<<"Yes";
    else
    cout<<"No";

 return 0;   
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    fun readSortedLongList() = readLine()!!
            .split(" ")
            .map { it.toLong() }
            .sorted()

    val n = readLine()!!.toLong()
    val a = readSortedLongList()
    val b = readSortedLongList()
    val c = readSortedLongList()
    var count = 0L

    /**
     * 要素以上の左端
     */
    fun List<Long>.lowerBound(num: Long): Int {
        var low = -1
        var high = this.size
        while (high - low > 1) {
            val mid = low + (high - low) / 2
            if (this[mid] >= num) high = mid
            else low = mid
        }
        return high
    }

    /**
     * 要素より大きいやつの左端
     */
    fun List<Long>.upperBound(num: Long): Int {
        var low = -1
        var high = this.size
        while (high - low > 1) {
            val mid = low + (high - low) / 2
            if (this[mid] > num) high = mid
            else low = mid
        }
        return high
    }

    b.forEach {
        val up = a.lowerBound(it).toLong()
        val down = n - c.upperBound(it).toLong()
        count += up * down
    }

    println(count)
}

Measured memory_bytes: 105944
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>
#include <iomanip>
#include <queue>
#include <cctype>
#include <stack>
#include <random>
#include <list>
#include <numeric>



#define rep(i,p,q) for(ll i = p;i < q;i++)
#define ll long long

using namespace std;

//tenka1 2017
int main(void) {
	ll N;
	cin >> N;
	bool isEnd = false;
	rep(h, 1, 3501) {
		rep(n, 1, 3501) {
			ll child = h * n * N;
			ll parent = 4 * h * n - N*(h + n);
			if (parent > 0 && child % parent == 0) {
				ll w = child / parent;
				if (4 * h * n * w == N * (h * n + n * w + h * w)) {
					cout << h << " " << n << " " << w  << endl;
					isEnd = true;
					break;
				}
			}

		}
		if (isEnd)break;
	}
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int K, x, y;
  scanf("%d", &K);
  if(K%2 == 0){
    x = K/2;
    y = K/2;
  }else{
    x = K/2;
    y = K/2 + 1;
  }
  printf("%d\n", x*y);
  return 0;
}


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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

ll INF=LLONG_MAX;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	int n; cin>>n;
	ll ans=0;
	for(int i=1; i<=n; i++){
		if(i%3!=0&&i%5!=0)ans+=i;
	}
	cout << ans << endl;
}	
/*  Benq's (modified)
	stuff you should look for
	* ll, int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
*/


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

#define ll long long
#define db double
#define el "\n"
#define ld long double
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n;i>=0;i--)
#define rep_a(i,a,n) for(int i=a;i<n;i++)
#define tr(ds, it) for(auto it=ds.begin(); it!=ds.end(); it++)
#define rtr(ds, it) for(auto it=ds.rbegin(); it!=ds.rend(); it--)
#define all(ds) ds.begin(), ds.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
typedef priority_queue <int> pq;
typedef vector< long long > vi;
typedef pair<long long, long long> ii;

const ll mod = 1000000007;
ll po(ll x, ll n ){ 
	ll ans=1;
     while(n>0){
     	if(n&1) ans=(ans*x)%mod;
     	x=(x*x)%mod;
     	n/=2;
     }
     return ans;
}



int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	int T=1;
	//cin >> T;
	while(T--){
		ll a,b;
		cin>>a>>b;
		if(a>=13) cout<<b<<el;
		else if(a>5) cout<<b/2<<el;
		else cout<<0<<el;
	}

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int n,a[101],i;
	double s=0.0;

	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%d",&a[i]);
	for(i=0;i<n;i++)
		s+=1.0/a[i];
	printf("%lf",1/s);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<list>
#include<string>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
using namespace std;

const int MAX = 500001;
const int NIL = -1;
struct Node {
	int key, priority;
	Node* parent, * left, * right;
};
struct Node T[MAX];
Node* head = NULL;
Node* _deleteNode(Node* t, int key);

Node* rightRotate(Node* t)
{
	Node* s = t->left;
	t->left = s->right;
	s->right = t;
	return s;
}

Node* leftRotate(Node* t)
{
	Node* s = t->right;
	t->right = s->left;
	s->left = t;
	return s;
}

Node* getMinimun(Node* x)
{
	while (x->left != NULL)
		x = x->left;
	return x;
}

Node* Find(Node* x, int k)
{
	while (x != NULL && k != x->key) {
		if (k < x->key)
			x = x->left;
		else
			x = x->right;
	}
	return x;
}

Node* getSuccessor(Node* x)
{
	if (x->right != NULL)
		return getMinimun(x->right);
	Node* y = x->parent;
	while (y != NULL && x == y->right) {
		x = y;
		y = y->parent;
	}
	return y;
}

void preParse(Node* u)
{
	if (u == NULL)
		return;
	cout << " " << u->key;
	preParse(u->left);
	preParse(u->right);
}

void inParse(Node* u)
{
	if (u == NULL)
		return;
	inParse(u->left);
	cout << " " << u->key;
	inParse(u->right);
}

Node* insert(Node* t, int key, int priority)
{
	Node* z = new(Node);
	z->key = key;
	z->priority = priority;
	z->left = z->parent = z->right = NULL;
	if (t == NULL) {
		return z;
	}
	if (key == t->key)
		return t;
	else if (key < t->key) {
		t->left = insert(t->left, key, priority);
		if (t->priority < t->left->priority)
			t = rightRotate(t);
	}
	else {
		t->right = insert(t->right, key, priority);
		if (t->priority < t->right->priority)
			t = leftRotate(t);
	}
	return t;
}

Node* deleteNode(Node* t, int key)
{
	if (t == NULL)
		return NULL;
	if (key < t->key)
		t->left = deleteNode(t->left, key);
	else if (key > t->key)
		t->right = deleteNode(t->right, key);
	else
		return _deleteNode(t, key);
	return t;
}

int main(void)
{
	int n, key, priority;
	char ss[10];
	cin >> n;
	memset(ss, 0, sizeof(ss));
	for (int i = 0; i < n; i++) {
		scanf("%s", ss);
		if (ss[0] == 'i') {
			cin >> key >> priority;
			head = insert(head, key, priority);
		}
		else if (ss[0] == 'f') {
			cin >> key;
			if (Find(head, key))
				cout << "yes" << endl;
			else
				cout << "no" << endl;
		}
		else if (ss[0] == 'd') {
			cin >> key;
			head = deleteNode(head, key);
		}
		else {
			inParse(head);
			cout << endl;
			preParse(head);
			cout << endl;
		}
	}
	return 0;
}

Node* _deleteNode(Node* t, int key)
{
	if (t->left == NULL && t->right == NULL)
		return NULL;
	else if (t->left == NULL)
		t = leftRotate(t);
	else if (t->right == NULL)
		t = rightRotate(t);
	else {
		if (t->left->priority > t->right->priority)
			t = rightRotate(t);
		else
			t = leftRotate(t);
		return deleteNode(t, key);
	}
	return deleteNode(t, key);
}




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

A = []
B = []
i = 1

while i*i <= N:
  if N % i == 0:
    A.append(i)
    B.append(N//i)
  i += 1

rlt = 13
for b in B:
  rlt = min(rlt,len(str(b)))

print(rlt)

Measured memory_bytes: 65408
import math

N = int(input())

# primes = []
# N_tmp = N
# for p in range(2, int(math.sqrt(N) + 1)):
#     if N_tmp % p > 0: continue
#     for i_p in range(1, 64):
#         if N % (p ** (i_p + 1)) > 0: break
#     primes.append((p, i_p))
#     N_tmp /= (p ** i_p)

divisors = []
for i in range(1, int(math.sqrt(N) + 1)):
    if N % i > 0: continue
    if (N // i) - i < 2: continue
    divisors.append(N // i)
    
print(sum(divisors) - len(divisors))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  
  int ans = a * c;
  ans = max(ans, a * d);
  ans = max(ans, b * c);
  ans = max(ans, b * d);
  cout << ans << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
 
using namespace std;
 
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileio freopen("in.in", "r", stdin),freopen("out.out", "w", stdout);
#define ll long long int
#define FF first
#define SS second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define pss printf
#define MOD 1000000007
#define INF 1e9
#define eps 0.00001
#define endl '\n'
#define debug(n1) cout<<n1<<endl
string s;
int dp[3][200005];
int rec(int i,int j)
{
	if(i>=s.length())
		return 0;
	if(dp[j][i]!=-1)
		return dp[j][i];
	int an=-INF;
	string x=s.substr(i,1);
	string y=s.substr(i-j,j);
	if(x!=y)
		an=max(an,1+rec(i+1,1));
	if(i+1<s.length())
	{
		x=s.substr(i,2);
		y=s.substr(i-j,j);
		if(x!=y)
			an=max(an,1+rec(i+2,2));
	}
	return dp[j][i]=an;
}
int main()
{
	SPEED;	
	cin>>s;
	int p=0;
	int ans=0;
	s="$"+s;
	memset(dp,-1,sizeof dp);
	cout<<rec(1,1)<<endl;
	return 0;
}

Measured memory_bytes: 47952
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define debug(val) cerr << "The value of " << #val << " is = " << val << '\n';
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 922337203685477;
const ll mininf = -922337203685477;
const ll nax = 0;

ll x, n, a[105], cek[105];

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	cin >> x >> n;
	for(ll i = 1; i <= n; i++){
		cin >> a[i];
		cek[a[i]]++;
	}
	ll mini = inf, ans = 0;
	for(ll i = x; i >= 0; i++){
		if(!cek[i]){
			mini = i - x;
			ans = i;
			break;
		}
	}
	for(ll i = x - 1; i <= inf; i--){
		if(!cek[i]){
			if(mini >= x - i){
				ans = i;
				break;
			}
			else{
				break;
			}
		}
	}
	cout << ans << '\n';
}


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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

typedef long long ll;

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

int main(){
  ll Q, H, S, D, N;
  cin >> Q >> H >> S >> D >> N;
  ll sum = 0;
  if(N >= 2){
    ll buy = min(8*Q, min(4*H, min(2*S, D)));
    sum += N / 2 * buy;
  }
  if(N % 2){
    ll buy = min(4*Q, min(2*H, S));
    sum+= buy;
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define sqr(x) ((x)*(x))
#define mp make_pair
#define uint unsigned
#define PI pair<int,int>
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
#define ld long double
#define int long long
const int N=105;
struct point{
	int x,y,id;
}a[N],q[N];
ld ans[N];
int n,top;
point operator -(point a,point b){
	return (point){a.x-b.x,a.y-b.y,a.id};
}
ll cha(point a,point b){
	return (ll)a.x*b.y-(ll)a.y*b.x;
}
inline bool cmp(point a,point b){
	return atan2(a.y,a.x)==atan2(b.y,b.x)?abs(a.x)<abs(b.x):atan2(a.y,a.x)<atan2(b.y,b.x);
}
inline ld dist(point a,point b){
	return (ll)(a.x-b.x)*(a.x-b.x)+(ll)(a.y-b.y)*(a.y-b.y);
}
inline ld dis(point a,point b){
	return sqrt(dist(a,b));
}
ld qiu(point a,point b,point c){
	//cout<<(ld)(dist(a,b)+dist(b,c)-dist(a,c))/2/dis(a,b)/dis(b,c)<<"zyy\n";
	return (M_PI-acos((dist(a,b)+dist(b,c)-dist(a,c))/2/dis(a,b)/dis(b,c)))/2/M_PI;
}
signed main(){
	//freopen("std.in","r",stdin); freopen("my.out","w",stdout);
	n=read();
	for(int i=1;i<=n;i++){
		a[i].x=read(); a[i].y=read(); a[i].id=i;
		if(a[i].y==a[1].y?a[i].x<a[1].x:a[i].y<a[1].y)swap(a[1],a[i]);
	}
	for(int i=n;i;i--)a[i]=a[i]-a[1];
	sort(&a[2],&a[n+1],cmp);
	for(int i=1;i<=n;i++){
		while(top>=2&&cha(q[top-1]-q[top-2],a[i]-q[top-1])<=0)top--;
		q[top++]=a[i];
		//cout<<a[i].x<<" "<<a[i].y<<endl;
	}
	//for(int i=0;i<top;i++)cout<<q[i].x<<" "<<q[i].y<<endl;
	for(int i=0;i<top;i++){
		ans[q[i].id]=top==2?0.5:qiu(q[(i+top-1)%top],q[i],q[(i+1)%top]);
	}
	for(int i=1;i<=n;i++)printf("%.7lf\n",(double)ans[i]);
}


Measured memory_bytes: 384
function main(input) {
    var output = [];
    for(var i = 0; i < input.length; i++) {
        if(0 != input[i]) {
            output.push('Case ' + (i + 1) + ': ' + input[i]);
        }
    }
    console.log(output.join('\n'));
  }
  
  process.stdin.resume();
  var input = '';  
  process.stdin.setEncoding('utf-8');
  process.stdin.on('data', function(chunk) {
    input += chunk;
  });
  process.stdin.on('end', function() {
    var inputData = input.split('\n');
    main(inputData);
  });

Measured memory_bytes: 19440
#include <algorithm>
#include <iostream>
#include <vector>

int main() {
    int N;
    std::cin >> N;

    std::vector<int> v(N);
    for (int i = 0; i < N; ++i) {
        std::cin >> v[i];
    }

    std::sort(v.begin(), v.end());
    const int ret = v.back() - v.front();

    std::cout << ret << std::endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
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; }
#define M 1000000007
#define all(a) (a).begin(),(a).end()
#define rep(i,n) reps(i,0,n)
#define reps(i,m,n) for(int i=(m);i<(n);i++)
int main(){
  int a,b,c;cin>>a>>b>>c;
  cout<<(a+b+c<22?"win":"bust");}


Measured memory_bytes: 256
import java.io.File;
import java.io.IOException;
import java.util.*;
 
public class Main {
 
	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);
		
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int[] A = new int[N];
		for(int i = 0; i < N; i++) A[i] = sc.nextInt();
		
		int ans = 0;
		while(true){
			boolean tf = true;
			for(int i = 0; i < N; i++) if(A[i] % 2 != 0) tf = false;
			if(!tf) break;
			ans++;
			for(int i = 0; i < N; i++) A[i] /= 2;
		}
		
		System.out.println(ans);
	}
}

Measured memory_bytes: 21716
package main

import (
	"fmt"
)

func main() {
	var bs []byte
	var s int
	fmt.Scan(&bs)
	for i, v := range bs {
		if (int(v)+i)%2 == 0 {
			s++
		}
	}
	if 2*s < len(bs) {
		fmt.Println(s)
	} else {
		fmt.Println(len(bs) - s)
	}
}


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

using ll = long long;
// #define int long long

#define LOG(variable) cout << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cout << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
/***** MAIN *****/
signed main() {
  string s;
  cin >> s;
  int blocks = 1;
  REP(i,s.size()-1) {
    if(s[i]!=s[i+1]) ++blocks;
  }
  cout << blocks-1;
  cout << "\n";
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 512
import math
from collections import defaultdict

n = int(input())
# k,x = map(int,input().split())
s_l = []
for i in range(n):
        s = list(input())
        s.sort()
        s_l.append(''.join(s))

# for i in range(n):
#         s_l.append(''.join(sorted(s_i_l[i])))
#         # for x in sorted(s_l[i]):
#         #         a += x
#         # s_l[i] = a
cnt = 0

d = defaultdict(lambda: 0)
for s in s_l:
        d[s] += 1

for v in d.values():
        cnt += int(v*(v-1)/2)
print(cnt)

Measured memory_bytes: 19832
#include <stdio.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

typedef long long ll;
typedef long double ld;

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

  int n;
  cin >> n;
  map<pair<int, int>, int> m;
  int cnt = 0;
  for (int i = 1; i <= n; ++i) {
    int first = 0;
    int j = i;
    while (j) {
      first = j % 10;
      j /= 10;
    }
    auto p = make_pair(first, i % 10);
    if (m.find(p) == m.end()) {
      m[p] = 1;
    } else {
      ++m[p];
    }
  }

  for (int i = 1; i <= n; ++i) {
    int first = 0;
    int j = i;
    while (j) {
      first = j % 10;
      j /= 10;
    }
    auto p = make_pair(i % 10, first);
    cnt += m[p];
  }
  cout << cnt;
}


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

int main() {
    int N, M; cin >> N >> M;
    vector<int> l(M);
    vector<int> r(M);

    int lmax=0, rmin=100001;
    rep(i, M) cin >> l.at(i) >> r.at(i);
    rep(i, M){
        lmax = max(l.at(i), lmax);
        rmin = min(r.at(i), rmin);
    }

    if(rmin < lmax) cout << 0 << endl;
    else cout << rmin-lmax+1 << endl;

}


Measured memory_bytes: 1024
from sys import stdin
import copy

letters = [chr(i) for i in range(97, 97+26)]

ans_list = []

def main():

    input = stdin.readline

    N = int(input())   

    dp('a',N)

    for i in ans_list:
        print(i)
    
def dp(ans,N):

    for i in range(ord('a'),ord('a')+len(list(set(ans)))+1):
        if len(ans) == N:
            ans_list.append(ans)
            return
        else:
            dp(ans + chr(i),N)


if __name__ == "__main__":
    main()

Measured memory_bytes: 13140
#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << 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...);
}

typedef long long int64;
typedef pair<int, int> ii;
#define SZ(x) (int)((x).size())
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

int main() {
  int64 a, b, c, d;
  cin >> a >> b >> c >> d;
  int64 ret = max(b * d, a * c);
  ret = max(ret, a * d);
  ret = max(ret, b * c);
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 3204
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
using namespace std;
//ここから

void solve(){
  char c;
  cin>>c;
  if(c=='a'||c=='i'||c=='u'||c=='e'||c=='o')cout<<"vowel";
  else cout<<"consonant";
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
  solve();
	return 0;
}


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


//long long型(64bit整数)
typedef long long ll;

int main(){
    ll a, b, m;
    cin >> a >> b >> m;
    ll A[100010], B[100010];
    ll minA = 10000000, minB = 10000000;
    for(ll i=0; i<a; i++){
        cin >> A[i];
        minA = min(minA, A[i]);
    }
    for(ll i=0; i<b; i++){
        cin >> B[i];
        minB = min(minB, B[i]);
    }
    ll x[100010], y[100010], c[100010];
    for(ll i=0; i<m; i++){
        cin >> x[i] >> y[i] >> c[i];
    }

    ll ans = minA + minB;
    for(ll i=0; i<m; i++){
        ll sum = A[x[i]-1] + B[y[i]-1] - c[i];
        ans = min(sum, ans);
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4096
#include <algorithm>
#include <functional>
#include <iostream>
#include <numeric>
#include <utility>
#include <vector>
using namespace std;

void calc_score(int D, vector<int>& c, vector<vector<int>>& s,
               vector<int>& ret) {
  vector<int> last(26, -1);
  int csum = accumulate(c.begin(), c.end(), 0);
  int score = 0, dec = 0;
  for (int d = 0; d < D; d++) {
    dec += csum - c[ret[d]] * (d - last[ret[d]]);
    score += s[d][ret[d]] - dec;
    last[ret[d]] = d;
    cout << score << endl;
  }
  return;
}

int calc_diff(int D, vector<int>& c, vector<vector<int>>& s, vector<int>& ret,
              int dc, int nc) {  // dc... day changed  nc... new contest
  int diff = 0, oc = ret[dc];    // oc... old contest
  diff += s[dc][nc] - s[dc][oc];

  int poc = 0, pnc = 0, noc = D, nnc = D;  // prev, next day

  for (int i = 0; i < dc; i++) {
    if (ret[i] == oc) poc = i;
    if (ret[i] == nc) pnc = i;
  }

  for (int i = D - 1; i > dc; i--) {
    if (ret[i] == oc) noc = i;
    if (ret[i] == nc) nnc = i;
  }

  diff = (noc - dc) * (dc - poc) - (nnc - dc) * (dc - pnc);
  return diff;
}

int main() {
  int D;
  cin >> D;
  vector<int> c(26);
  vector<vector<int>> s(D, vector<int>(26));
  vector<vector<pair<int, int>>> s_sorted(D, vector<pair<int, int>>(26));
  for (int i = 0; i < 26; i++) cin >> c[i];
  for (int i = 0; i < D; i++) {
    for (int j = 0; j < 26; j++) {
      cin >> s[i][j];
    }
  }
  vector<int> ret(D);
  for (int i = 0; i < D; i++) {
    cin >> ret[i];
    ret[i]--;
  }
  calc_score(D, c, s, ret);
  return 0;
}

Measured memory_bytes: 3224
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 
#define dump(x)  cout << #x << " = " << (x) << endl;
typedef long long lint;
using namespace std;
int main(){
	int n,m;
	cin>>n>>m;
	vector<int>s(m),c(m);
	rep(i,m){
		cin>>s.at(i);
		s.at(i)--;
		cin>>c.at(i);
	}
	rep(i,1000){
		string num = to_string(i);
		if(n!=num.length())continue;
		bool flag = true;
		rep(j,m)if(num.at(s.at(j))-'0'!=c.at(j))flag = false;
		if(flag){
			cout<<i<<endl;
			return 0;
		}
	}
	cout<<-1<<endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

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

    cin >> A  >> B  >> C;

    if((A == 5 && B == 5 && C == 7) || (A == 5 && B == 7 && C == 5)
    || (A == 7 && B == 5 && C == 5)){
        cout << "YES" << endl;
    }
    else{
         cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a == b) {
    if (a == c)
      cout << "No";
  	else
      cout << "Yes";
  } else if (a == c || b == c)
    cout << "Yes";
  else
    cout << "No";
}

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


const int maxn = 50+5;
const int maxm = 2500+100;
const int INF = 0x3f3f3f3f;
typedef long long LL;
LL dp[maxn][maxn][maxm];
int A[maxn];

int main()
{
  //  freopen("./test.txt","r",stdin);
    int n,S;
    scanf("%d %d",&n,&S);
    for(int i = 1;i <= n;++i)
        scanf("%d",&A[i]);

    memset(dp,0,sizeof(dp));
    dp[0][0][0] = 1;
    for(int i = 0;i < n;++i)
        for(int k = 0;k <= i;++k)
            for(int j = maxm;j >= 0;--j)
                if(dp[i][k][j])
                {
                    dp[i+1][k][j] += dp[i][k][j];
                    int nxtS = j + A[i+1];
                    dp[i+1][k+1][nxtS] += dp[i][k][j];
                }

    LL res = 0;
    for(int i = 1;i <= n;++i)
        res += dp[n][i][i*S];
    printf("%lld\n",res);

    return 0;
}


Measured memory_bytes: 61696
#include <iostream>
#include <string>

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

#if DEBUG_ON
    freopen("input", "r", stdin);
#endif

    std::string str, res;
    std::cin >> str;
    int pos = 0;
    for (char c : str) {
        if (c == 'B') {
            if (pos > 0) {
                res[pos--] = 0;
            }
        } else {
            res[pos++] = c;
        }
    }
    for (int i = 0; i < pos; ++i) {
        std::cout << res[i];
    }
    std::cout << '\n';
    return 0;
}

Measured memory_bytes: 256
N, M, C = gets.chomp.split(' ').map(&:to_i)
b_list = gets.chomp.split(' ').take(M).map(&:to_i)
a_list_list = N.times.map { gets.chomp.split(' ').take(M).map(&:to_i) }

ans = a_list_list.count do |a_list|
  a_list.zip(b_list).map { |(a, b)| a * b }.reduce(&:+) + C > 0
end
puts ans


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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  int H1, M1, H2, M2, K;
  cin >> H1 >> M1 >> H2 >> M2 >> K;
  int start = H1 * 60 + M1;
  int end = H2 * 60 + M2;

  cout << end - K - start << endl;

  return 0;
}


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

typedef long long ll;
const int MAX_N = 200000;

int main() {
	int N;
	static ll X[MAX_N], sorted[MAX_N];

	std::cin >> N;
	for(int i = 0; i < N; ++i) {
		std::cin >> X[i];
		sorted[i] = X[i];
	}
	std::sort(sorted, sorted + N);

	int m = sorted[(N + 1) / 2];
	for(int i = 0; i < N; ++i) {
		if(X[i] >= m) {
			std::cout << sorted[(N + 1) / 2 - 1] << std::endl;
		} else {
			std::cout << m << std::endl;
		}
	}
}


Measured memory_bytes: 5376
n, *aa = map(int, open(0).read().split())

swaps = 0
for i in range(1, n):
    for j in range(n-1, i-1, -1):
        if aa[j] < aa[j-1]:
            swaps += 1
            aa[j], aa[j-1] = aa[j-1], aa[j]

print(*aa)
print(swaps)


Measured memory_bytes: 5616
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i=0;i<N;i++){
    cin >> a[i];
    a[i]--;
  }
  vector<int> pos(N);
  for (int i=0;i<N;i++){
    pos[a[i]]=i;
  }
  set<int> s;
  s.insert(-1);
  s.insert(N);
  long long ans=0;
  for (int i=0;i<N;i++){
    int j=pos[i];
    s.insert(j);
    auto itr=s.find(j);
    --itr;
    int l=*itr;
    itr=s.find(j);
    ++itr;
    int r=*itr;
    ans+=(long long)(i+1)*(r-j)*(j-l);
  }
  cout << ans << endl;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <string>
using namespace std;
typedef double  dbl;
typedef long long int lld;
#define foi(i,n) for(i = 0; i < n; i+=1)
#define fod(i,n) for(i=n-1; i >=0; i-=1)
#define MAX std::numeric_limits<lld>::max()
#define MIN std::numeric_limits<lld>::min()
#define FastIO  ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int main ()
{
      FastIO
      lld A[3];
      cin >> A[0] >> A[1] >> A[2];
      set <lld> Myset;
      Myset.insert(A[0]);
      Myset.insert(A[1]);
      Myset.insert(A[2]);
      if (Myset.size() == 2)
      	cout << "Yes";
      else
      	cout <<  "No";
      return 0;
}

Measured memory_bytes: 256
//compiledef
#include <bits/stdc++.h>
#define rep(i, n) for(i=0;i<(n);i++)
#define per(i, n) for(i=(n);i>0;i--)
#define repx(i, n, x) for(i=(x);i<(n);i++)
#define xper(i, n, x) for(i=(n);i>(x);i--)
#define pback push_back

//c++def
using namespace std;
typedef long long int ll;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
int main(){
	int i, j;
	int n, k;
	int ca;
	cin >> n >> k;
	int dp[n];
	int h[n];
	rep(i, n){
		scanf("%d", &h[i]);
		dp[i] = 2e9;
	}
	dp[0] = 0;
	repx(i, n, 1){
		if(n==2){
			cout << h[1]-h[0] << endl;
			exit(0);
		}
		else{
			if(i==1)dp[i] = abs(h[i]-h[i-1]);
			else{
				for(j=1;j<=k; j++){
					if(i-j<0)break;
					ca = abs(h[i]-h[i-j])+dp[i-j];
					dp[i] = min(ca, dp[i]);
				}
			}
		}
	}
	cout << dp[n-1] << endl;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <set>
#include <map>
#include <vector>
#include <algorithm>

int main(){
  int N, H, W;
  scanf("%d %d %d", &N, &H, &W);
  printf("%lld\n", (N - W + 1) * (N - H + 1));
  return 0;
}

Measured memory_bytes: 128
ARGS=input().split()
A=int(ARGS[0])
B=int(ARGS[1])
C=int(ARGS[2])
K=int(ARGS[3])

if K <= A:
    print(str(K))
elif K <= A + B:
    print(str(A))
else:
    print(str(A - (C - (A + B + C - K))))

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

int main() {
    int K, N;
    cin >> K >> N;
    vector<int> A(N);
    for (int i = 0; i < N ; i++) {
        cin >> A[i];
    }
    A.push_back(K + A[0]);
    int d = 0;
    for (int i = 0; i < N; i++) {
        d = max(d, A[i + 1] - A[i]);
    }
    cout << K - d << endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <deque>
#include <numeric>
using namespace std;

int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<bool>>S(H+2, vector<bool>(W+2,0));
    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            char a;
            cin >> a;
            if (a == '#')S[i][j] = true;
        }
    }

    for (int i = 1; i <= H; i++) {
        int count;
        for (int j = 1; j <= W; j++) {
            if (S[i][j] == true) {
                cout << "#";
                continue;
            }
            count = S[i-1][j] + S[i-1][j-1] + S[i-1][j+1] + S[i][j-1] + S[i][j+1] + S[i+1][j-1] + S[i+1][j] + S[i+1][j+1] ;
            cout << count;
        }
        cout << endl;
    }


    return 0;
}

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

int main(){
    int s;
    cin>>s;
    int b=s%100;
    int f=s/100;
    string ans="NA";
    if(b<=12&&f<=12&&b>0&&f>0) ans="AMBIGUOUS";
    else if(b<=12&&(f>12||f==0)&&b>0) ans="YYMM";
    else if((b>12||b==0)&&f<=12&&f>0) ans="MMYY";
    cout<<ans<<endl;
}


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

int main(void){
	char s[131072];
	int k,i,m;
	scanf("%s",s);
	scanf("%d",&k);
	m = strlen(s);
	for(i=0;i<m-1;i++){
		if((123 - s[i]) <= k && s[i] != 'a'){
			k-=(123 - s[i]);
			s[i] = 'a';
		}
	}
	s[m-1] = (((s[m-1]-97)+k%26)%26)+97;
	printf("%s\n",s);
	return 0;
}

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

int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	rep(i, s.size()) {
		s[i] = (s[i] - 'A' + n) % 26 + 'A';
	}
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1);
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 main() {
    int n; cin >> n;
    ll k; cin >> k;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    if (k == 0) {
        ll m = -1;
        rep(i, n) chmax(m, a[i]);
        cout << m << endl;
        return 0;
    }

    ll ng = 0, ok = 2e18;
    while (ok - ng > 1) {
        ll mid = (ok + ng) / 2;
        ll sum = 0;
        rep(i, n) {
            if (a[i] <= mid) continue;
            sum += a[i] / mid;
        }
        if (sum > k) ng = mid; // 短く切りすぎ
        else ok = mid;
    }
    cout << ok << endl;

}


Measured memory_bytes: 4680
#include<cstdio>
#include<cstring>
#include<iostream>
#include<string>
#include<map>
#include<vector>
#include<queue>
#include<set>
#include<sstream>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=2000+10,INF=0x3f3f3f3f,dx[]={1,1},dy[]={-1,1};
int a,b,c,d;
int main()
{
    while(~scanf("%d%d%d%d",&a,&b,&c,&d)){
        if(a+b>c+d) printf("Left\n");
        else if(a+b==c+d) printf("Balanced\n");
        else printf("Right\n");
    }

    return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x
using namespace std;

const int INF = 10000000;
const long long INFL = (1LL<<50);
const double PI = atan(1)*4;
const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}

template< typename T >
struct edge{
    int src, to;T cost;
    edge(int to,T cost) :src(-1),to(to),cost(cost){}
    edge(int src, int to, T cost) :src(src),to(to),cost(cost){}edge
    &operator=(const int &x){
        to =x;
        return *this;
    }
    operator int() const{ return to;}
};

template< typename T >
using Edges =vector< edge<T> >;
template< typename T >
using WeightedGraph =vector< Edges<T> >;
using UnWeightedGraph =vector< vector<int> >;
template< typename T >
using Matrix =vector< vector<T> >;


template< typename T >
vector< T > dijkstra(WeightedGraph< T > &g, int s) {
    // ダイクストラ法。O(E log V), All edges must have positive-weight
    const auto INF = numeric_limits< T >::max();
    vector< T > dist(g.size(), INF);
    
    using Pi = pair< T, int >;
    priority_queue< Pi, vector< Pi >, greater< Pi > > que;
    dist[s] = 0;
    que.emplace(dist[s], s);
    while(!que.empty()) {
        T cost;
        int idx;
        tie(cost, idx) = que.top();
        que.pop();
        if(dist[idx] < cost) continue;
        for(auto &e : g[idx]) {
            auto next_cost = cost + e.cost;
            if(dist[e.to] <= next_cost) continue;
            dist[e.to] = next_cost;
            que.emplace(dist[e.to], e.to);
        }
    }
    return dist;
}

int main() {
    int n;cin>>n;
    WeightedGraph<ll> g(n);
    rep(i,n-1){
        int a, b, c;cin>>a>>b>>c;
        a--;b--;
        g[a].emplace_back(a,b,c);
        g[b].emplace_back(b,a,c);
    }
    int q,k;cin>>q>>k;
    
    vector<ll> len(n);
    len = dijkstra(g,k-1);
    
    rep(i,q){
        int a, b;cin>>a>>b;
        a--;b--;
        cout<<len[a]+len[b]<<endl;
    }
    
    
    return 0;
}










Measured memory_bytes: 11988
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
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 main(){
    int D;
    ll G;
    vector<ll> p,c;
    cin>>D>>G;
    p.resize(D);
    c.resize(D);
    for(int i=0;i<D;i++) cin>>p[i]>>c[i];
    
    ll res=1<<29;
    for(int bit=0;bit<(1<<D);bit++){
        ll sum=0;
        ll num=0;
        for(int i=0;i<D;i++){
            if(bit & (1<<i)){
                sum+=c[i]+p[i]*100*(i+1);
                num+=p[i];
            }
        }
        if(sum>=G) res=min(res,num);
        else{
            for(int i=D-1;i>=0;i--){
                if(bit & (1<<i)) continue;
                for(int j=0;j<p[i];j++){
                    if(sum>=G) break;
                    sum+=100*(i+1);
                    num++;
                }
            }
        }
        res=min(res,num);
    }
    cout<<res<<endl;
}

Measured memory_bytes: 256
k = int(input())
lunList = [i for i in range(1, 10)]
for i in range(k-9):
    x = lunList[i]
    for j in range(-1, 2):
        d = x%10 + j
        if 0 <= d <= 9:
            lunList.append(10*x + d)
print(lunList[k-1])

Measured memory_bytes: 16276
//#pragma GCC optimize(2)
// Happy TLE and WA every day!
// by: zxb the vegetable chicken
#include<bits/stdc++.h>
#define rep(i,n)        for(int i = 0; i < n; i++)
#define INF             0x3f3f3f3f
using namespace std;

// 0 2 1 2 0
int a[200200];
int dp[200200][5];
int n;

signed main(){
	ios::sync_with_stdio(false);
	cin >> n;
	rep(i, n) cin >> a[i];
	for(int i = 1; i <= n; i++){
		int mn = INF;
		int x = a[i - 1];
		mn = min(mn, dp[i - 1][0]);
		dp[i][0] = mn + x;
		mn = min(mn, dp[i - 1][1]);
		dp[i][1] = mn + ( (!x) ? 2 : (x&1) );
		mn = min(mn, dp[i - 1][2]);
		dp[i][2] = mn + !(x & 1);
		mn = min(mn, dp[i - 1][3]);
		dp[i][3] = mn + ( (!x) ? 2 : (x&1) );
		mn = min(mn, dp[i - 1][4]);
		dp[i][4] = mn + x;
	}
	int ans = INF;
	rep(i, 5) ans = min(ans, dp[n][i]);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#include <unordered_map>
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define REP(i,a,b) for(int i=a; i<=b; i++)
using namespace std;

typedef long long int ll;

int main() {
    ll n,cur=0;
    cin >> n;
    vector<ll> x(n);
    REP(i,0,n-1){
        cin >> x[i];
        cur^=x[i];
    }
    REP(i,0,n-1){
        ll ans=cur^x[i];
        cout << ans << " ";
    }
    return 0;
}


Measured memory_bytes: 4752