akhauriyash/Code-Regression huggingface dataset:
//In the name of God:)
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define pii pair<int,int>
#define int long long int
using namespace std;
const int MAXN = 1e5 + 10;

void solve(){

}

int32_t main(){
  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
  int dp[3][MAXN] , n , h[3][MAXN] , ans = 0;
  cin>>n;
  for(int i = 0 ; i < n ; i++){
    cin>>h[0][i]>>h[1][i]>>h[2][i];
  }
  dp[0][0] = h[0][0];
  dp[1][0] = h[1][0];
  dp[2][0] = h[2][0];
  for(int i = 1 ; i < n ;i++){
      dp[0][i] = max(dp[1][i-1] , dp[2][i-1]) + h[0][i];
      dp[1][i] = max(dp[2][i-1] , dp[0][i-1]) + h[1][i];
      dp[2][i] = max(dp[1][i-1] , dp[0][i-1]) + h[2][i];
  }
  ans = max(max(dp[0][n-1] , dp[1][n-1]) , dp[2][n-1]);
  cout<<ans<<endl;
}


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

using namespace std;

string str;

long long int compute(string s){

    string tmulti = "";

    for(int i=0; i<s.length(); i++){

        if(s[i] == '-'){
            tmulti += str[i];
            tmulti += "+";

        }else{
            tmulti += str[i];
        }

    }

    reverse(tmulti.begin(), tmulti.end());

    long long int sum = 0;

    string temp = "";

    for(int i=0; i<tmulti.length(); i++){

        if(tmulti[i] == '+'){

            sum += (long long int) atoll(temp.c_str());
            temp = "";

        }else{
            temp += tmulti[i];
        }

    }

    sum += (long long int) atoll(temp.c_str());

    //cout << " TMULTI = " << tmulti << endl;

    //cout << " SUM = " << sum << endl;

    return sum;
}


int main(){

   // freopen("input.txt","r",stdin);

    cin >> str;

    long long int sum = atoll(str.c_str());

    reverse(str.begin(),str.end());

    //cout << str << " " << sum << endl;

    int n = str.length();

    long long int total = 0;

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

        string temp = str;

        for(int j=0; j<n-1; j++){

            if(i&(1<<j)){

                temp[j] = '-';
            }

        }

        //cout << temp << endl;
        total += compute(temp);
       // break;
    }

    cout << total << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include<numeric>
using namespace std;
#define rep(i,n) for(int i=0; i<(n);i++)
typedef long long ll;


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



Measured memory_bytes: 3120
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
using namespace std;
#define Fio                           \
    ios_base::sync_with_stdio(false); \
    cin.tie(nullptr);                 \
    cout.tie(nullptr)
#define f(i, n) for (long long int i = 0; i < n; i++)
#define ll long long int
#define fo(i, a, b) for (long long int i = a; i <= b; i++)
#define w(t)  \
    int t;    \
    cin >> t; \
    while (t--)
#define vi vector<int>
#define vl vector<long long int>
#define vvi vector<vector<int>>
#define vvl vector<vector<long long int>>
#define mii map<int, int>
#define umii unordered_map<int, int>
#define newl cout<<"\n"
#define pb push_back
#define mp make_pair
#define fi first
#define se second
const ll inf = 1e9 + 7;
const ll modc = 998244353;
#define MAX 300002

ll maxi(ll a,ll b){
	if(a>=b)return a;
	return b;
}

ll mini(ll a,ll b){
	if(a>=b)return b;
	return a;
}


int main(){
	Fio;
	string s,t;
	cin>>s>>t;
	int n = s.length(),m = t.length();
	ll dp[n+1][m+1] = {0};
	fo(i,0,n){
		fo(j,0,m){
			if(i==0 || j==0)dp[i][j] = 0;
			else if(s[i-1]==t[j-1])dp[i][j] = 1+dp[i-1][j-1];
			else if(s[i-1]!=t[j-1]){
				dp[i][j] = maxi(dp[i-1][j],dp[i][j-1]);
			}
		}
	}	
	string ans = "";
	ll i = n,j = m;
	while(i>0 && j>0){
		if(s[i-1]==t[j-1]){
			ans = s[i-1]+ans;
			i--,j--;
		}
		else if(dp[i-1][j]>dp[i][j-1])i--;
		else j--;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 74020
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) rep(i, x.size()) cerr << x[i] << (i == x.size() - 1 ? "\n" : " ")
using namespace std;
#define int long long
typedef long long ll;
typedef pair<int, int> pii;
const int INF = ((1LL << 30) + (1LL << 29));
const int MOD = 1000000007;

//=============================
int A,B,C;
int K;
//=============================
void input()
{
    cin>>A>>B>>C;
    cin>>K;
}
//=============================
void func(){}
//=============================
void solve()
{
    vector<int> v = {A,B,C};
    sort(v.begin(),v.end());

    cout<<(v[0]+v[1]+(v[2]<<K )) <<endl;
    

}
//=============================
signed main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

ll a,b,c,d,e,f;
int main(){
	scanf("%lld%lld%lld%lld%lld%lld",&a,&b,&c,&d,&e,&f);
	if(a*c+b*d==a*e+b*f){
		puts("infinity");
		return 0;
	}
	if(c<e){
		ll t=c;c=e;e=t;
		t=d;d=f;f=t;
	}
	if(a*c+b*d>a*e+b*f){
		puts("0");
		return 0;
	}
	ll M=a*(c-e);
	ll dd=(b*(f-d)-M);
	printf("%lld",M/dd*2+!!(M%dd));
}

Measured memory_bytes: 128
//
//  second.cpp
//  CoderTest
//
//  Created by yuya on 2019/07/25.
//  Copyright © 2019 yuya. All rights reserved.
//

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
#define ALL(x) (x).begin(), (x).end()
#define INF 1000000


int nC2(int n);

int main()
{
    int N;
    vector<vector<int>> A(3);
    
    int a;
    for (int i=0; i<3; i++) {
        for (int j=0; j<3; j++) {
            cin >> a;
            A[i].push_back(a);
        }
    }
    
    cin >> N;
    int b;
    
    for (int i=0; i<N; i++) {
        cin >> b;
        
        for (int j=0; j<3; j++) {
            for (int k=0; k<3; k++) {
                if(A[j][k] == b) {
                    A[j][k] = -1;
                }
            }
        }
    }
    
    int bingo=0;
    
    for (int i=0; i<3; i++) {
        for (int j=0; j<3; j++) {
            if (A[i][j] == -1 && j==2) {
                bingo = 1;
            } else if(A[i][j] != -1) {
                break;
            }
        }
    }
    
    for (int i=0; i<3; i++) {
        for (int j=0; j<3; j++) {
            if (A[j][i] == -1 && j==2) {
                bingo = 1;
            } else if(A[j][i] != -1) {
                break;
            }
        }
    }
    
    
    for (int i=0; i<3; i++) {
        if (A[i][i] == -1 && i==2) {
            bingo = 1;
        } else if(A[i][i] != -1) {
            break;
        }
    }
    
    for (int i=0; i<3; i++) {
        if (A[2-i][i] == -1 && i==2) {
            bingo = 1;
        } else if(A[2-i][i] != -1) {
            break;
        }
    }
    
    
    
    if (bingo) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
    return 0;
}

int nC2(int n)
{
    if(n <= 1) return 0;
    else return n*(n-1)/2;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef long double ld;

ll inv(ll a, ll b){
    return (a > 1 ? b - inv(b%a, a)*b/a : 1);
}

#define rc(s) return cout << s, 0
#define fi first
#define se second
#define L (nod << 1)
#define R (L | 1)
#define smax(X, Y) ((X) > (Y) ? (X) : (Y))
#define smin(X, Y) ((X) < (Y) ? (X) : (Y))

const ld e = 2.71828182845904523536028747;
const ld PI = 3.14159265359;
const ll inf = (1LL<<62);
const int iinf = (1<<30);

ld ans;
int n, k;

int main(){
    cin >> n >> k;
    for (int i=1; i<=n; i++){
        if (i >= k) ans += 1.0/n;
        else{
            ld cur = 1.0/n;
            int score = i;
            while (score < k) cur *= 0.5, score *= 2;
            ans += cur;
        }
    }
    cout << fixed << setprecision(10) << ans;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int N,S=0;
  int B[102];
  scanf("%d",&N);
  for(int i=1;i<N;i++)
    scanf("%d",B+i);
  B[0]=B[1];
  B[N]=B[N-1];
  for(int i=1;i<=N;i++){
    S+=(B[i-1]<=B[i]?B[i-1]:B[i]);
  }
  printf("%d\n",S);
  return 0;
}

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

using namespace std;
const int maxn = 1e3 + 5, mod = 1e9 + 7;
int n, m;
char a[maxn][maxn];
int f[maxn][maxn];

int dp(int u, int v)
{
    if (u > n || v > m || a[u][v] == '#') return 0;
    if (u == n && v == m) return 1;
    int &res = f[u][v];
    if (res != -1) return res;
    res = dp(u + 1, v);
    res = (res + dp(u, v + 1)) % mod;
    return res;
}

int main()
{
    #ifdef NTMA 
        freopen("abc.inp", "r", stdin);
    #endif
    memset(f, 255, sizeof(f));
    cin >> n >> m;
    for(int i=1; i<=n; ++i)
        for(int j=1; j<=m; ++j) cin >> a[i][j];
    cout << dp(1, 1);
}

Measured memory_bytes: 5248
inp = list(map(int,input().split()))
 
a = inp[0]*inp[1]

if (inp[0]==1 or inp[1]==1):
    print("1")
else:
    if (a %2 == 1):
        b = int(a/2)+1
        print('{:.19g}'.format(b))
    else:
        b = a/2
        print('{:.19g}'.format(b))
 

Measured memory_bytes: 3060
import bisect,sys
import math
from collections import deque

def sRaw():
    return input().rstrip("\r")


def iRaw():
    return int(input())


def ssRaw():
    return input().split()


def isRaw():
    return list(map(int, ssRaw()))

INF = 1 << 29

DIV = (10**9) + 7

def mod_inv_prime(a, mod=DIV):
    return pow(a, mod-2, mod)


def mod_inv(a, b):
    r = a
    w = b
    u = 1
    v = 0
    while w != 0:
        t = r//w
        r -= t*w
        r, w = w, r
        u -= t*v
        u, v = v, u
    return (u % b+b) % b


def CONV_TBL(max, mod=DIV):
    fac, finv, inv = [0]*max, [0]*max, [0]*max
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, max):
        fac[i] = fac[i-1]*i % mod
        inv[i] = mod - inv[mod % i] * (mod//i) % mod
        finv[i] = finv[i-1]*inv[i] % mod

    class CONV:
        def __init__(self):
            self.fac =fac
            self.finv = finv
            pass

        def ncr(self, n, k):
            if(n < k):
                return 0
            if(n < 0 or k < 0):
                return 0
            return fac[n]*(finv[k]*finv[n-k] % DIV) % DIV
        
    return CONV()



sys.setrecursionlimit(200005)


def main():
    s = sRaw()
    return "Yes" if "7" in s else "No"
if __name__ == "__main__":
    print(main())


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

#define REP(type, i, a, b) for( type i = a; i < b; i++ )
typedef long long ll;

using namespace std;

int main (void) {
    int N;
    ll ans = 0;
    scanf("%d\n", &N);
    ll PairNum;
    string S;
    cin >> S;
    int First, Second, Third;
    int F1, F2, F3;
    int i1,i2,i3;
    for ( First = 0; First < 10; First++){
        for ( Second = 0; Second < 10; Second++ ){
            for ( Third = 0; Third < 10; Third++ ){
                F1 = 0;
                F2 = 0;
                F3 = 0;
                REP( int, i, 0, N - 2 ){
                    if ( First  == (int)( S.at(i) - '0' ) ){
                        F1 = 1;
                        i1 = i;
                        break;
                    }
                }
                if ( F1 == 1 ){
                    REP( int, i, 1, N - 1 ){
                        if ( Second == (int)( S.at(i) - '0' ) && i1 < i ){
                            F2 = 1;
                            i2 = i;
                            break;
                        }
                    }
                }
                if ( F1 == 1 && F2 == 1 ){
                    REP( int, i, 2, N ){
                        if ( Third  == (int)( S.at(i) - '0' ) && i1 < i && i2 < i ){
                            F3 = 1;
                            i3 = i;
                            break;
                        }
                    }
                }
                if ( F1 == 1 && F2 == 1 && F3 == 1 ){
                    //cout << First << Second << Third << endl;
                    ans++;
                }
            }
        }
    }
    printf("%lld\n", ans);
    return 0;
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long

const int N = 1e5 + 5;
const int INF = 1e9;
 
const int MOD = 1e9 + 7;


            
int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n; cin >> n;
    vector<int> a(n), b(n), c(n);
    for(int i = 0; i < n; i++)
        cin >> a[i] >> b[i] >> c[i];
    int dp[n][3];
    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];
    for(int i = 1; i < n; i++)
    {
        dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a[i];
        dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + b[i];
        dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c[i];
    }

    cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2]));
}

Measured memory_bytes: 5548
#include <stdio.h>
#include <stdlib.h>

#define MAX 200

int top, S[MAX];

void init_stack()
{
	top = -1;
}

void push(int v)
{
	S[++top] = v;
}

int pop()
{
	return S[top--];
}

int do_op(int a, int b, char op)
{
	int r = 0;
	
	switch (op) {
	case '+':
		r = a + b;
		break;
	case '-':
		r = a - b;
		break;
	case '*':
		r = a * b;
		break;
	}
	
	return r;
}

int main(int argc, char *argv[]) 
{
	char a[MAX];
	int op1, op2;

	init_stack();
	while (scanf("%s", a) != EOF) {
		if (isdigit(*a)) {
			push(atoi(a));
		} else {
			op2 = pop();
			op1 = pop();
			push(do_op(op1, op2, *a));
		} 
	}
	
	printf("%d\n", pop());
	
	return 0;
}


Measured memory_bytes: 2040
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <string>
using namespace std;
typedef long long int lli;

int main()
{
    int S, W;
    cin >> S >> W;
    if (S > W)
    {
        cout << "safe" << endl;
    }
    else
    {
        cout << "unsafe" << endl;
    }
    return 0;
}

Measured memory_bytes: 3596
from operator import itemgetter

n, h = map(int, input().split())
katanas = [list(map(int, input().split())) for _ in range(n)]

a_max = [0, 0]

for i in range(n):
	if katanas[i][0] > a_max[0] or (katanas[i][0] == a_max[0] and katanas[i][1] < a_max[1]):
		a_max = katanas[i]
		a_max_index = i

if a_max_index == 0:
	katanas = katanas[1:]
elif a_max_index == n-1:
	katanas = katanas[:n-1]
else:
	katanas = katanas[:a_max_index] + katanas[a_max_index + 1:]

b_sorted = sorted([katanas[i][1] for i in range(n-1)], reverse=True)

ans = 0

for i in range(n-1):
	if b_sorted[i] <= a_max[0]:
		break
	else:
		ans += 1
		h -= b_sorted[i]
		if h <= 0:
			print(ans)
			break

if h > 0:
	if h <= a_max[1]:
		print(ans + 1)
	else:
		print(ans + (h - a_max[1] -1) // a_max[0] + 2)

Measured memory_bytes: 29200
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int get_int(void) {
  int num;
  scanf("%d", &num);
  return num;
}

int get_int2(int *a1, int *a2) {
  scanf("%d %d", a1, a2);
  return 0;
}

int get_int3(int64_t *a1, int64_t *a2, int64_t *a3) {
  scanf("%lld %lld %lld", a1, a2, a3);
  return 0;
}

struct cake {
    int64_t beauty;
    int64_t tastiness;
    int64_t popularity;
};

#define NUM_MAX 1000

int desc(const void *a1, const void *a2) {
    int64_t aa1 = *(int64_t*)a1;
    int64_t aa2 = *(int64_t*)a2;
    if(aa1 < aa2) return 1;
    if(aa1 == aa2) return 0;
    return -1;
}

int64_t calc(struct cake *cs, int num, int *signs, int selects) {
    static int64_t arr[NUM_MAX];
    int i;
    for(i = 0; i < num; i++) {
        arr[i] = cs[i].beauty * signs[0] + 
            cs[i].tastiness * signs[1] +
            cs[i].popularity * signs[2];
    }
    qsort(arr, num, sizeof(int64_t), desc);
    int64_t ans = 0;
    for(i = 0; i < selects; i++) {
        ans += arr[i];
    }
    return ans;
}

int main(void) {
    int num, selects;
    struct cake cakes[NUM_MAX];
    get_int2(&num, &selects);
    int i, j, k;
    for(i = 0; i < num; i++) {
        int64_t p1, p2, p3;
        get_int3(&p1, &p2, &p3);
        cakes[i] = (struct cake){p1, p2, p3};
    }

    int64_t ans = 0;
    for(i = -1; i <= 1; i+=2) {
        for(j = -1; j <= 1; j+=2) {
            for(k = -1; k <= 1; k+=2) {
                int signs[3] = {i, j, k};
                int64_t res = calc(cakes, num, signs, selects);
                ans = max(res, ans);
            }
        }
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <cstdio>
#define int long long
#define pb push_back
#define mp make_pair
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
#define F first
#define S second
using namespace std;
typedef pair<int,int>pii;
int P=257,Q=329;
int MP=72611,MQ=86419;
int NP=4238,NQ=34410;
char s[200010];
int n,p;
int f1[200010],f2[200010];
int p1[200010],p2[200010];
int b1[200010],b2[200010];
int msk1,msk2,idx=1,ans=1;
signed main(){
	cin>>(s+1);
	n=strlen(s+1);
	p1[0]=p2[0]=1;
	b1[0]=b2[0]=1;
	for(int i=1;i<=n;i++)p1[i]=p1[i-1]*NP%MP;
	for(int i=1;i<=n;i++)p2[i]=p2[i-1]*NQ%MQ;
	for(int i=1;i<=n;i++)b1[i]=b1[i-1]*P%MP;
	for(int i=1;i<=n;i++)b2[i]=b2[i-1]*Q%MQ;
	for(int i=1;i<=n;i++)f1[i]=(f1[i-1]*P+s[i])%MP;
	for(int i=1;i<=n;i++)f2[i]=(f2[i-1]*Q+s[i])%MQ;
	msk1=msk2=s[1];
	// for(int i=1;i<=n;i++)cout<<p1[i]<<' ';
	// puts("");
	// for(int i=1;i<=n;i++)cout<<b1[i]<<' ';
	// puts("");
	// for(int i=1;i<=n;i++)cout<<f1[i]<<' ';
	// puts("");
	for(int i=2;i<=n;i++){
		int nmsk1=(f1[i]+MP-f1[idx]*b1[i-idx]%MP)%MP;
		int nmsk2=(f2[i]+MQ-f2[idx]*b2[i-idx]%MQ)%MQ;
		// cout<<nmsk1<<' '<<nmsk2<<endl;
		// cout<<msk1<<' '<<msk2<<endl;
		// cout<<"-------"<<endl;
		if(nmsk1!=msk1&&nmsk2!=msk2){
			msk1=nmsk1;
			msk2=nmsk2;
			idx=i;
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 9856
import java.io.PrintWriter
import java.util.*
import kotlin.math.pow

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun <T> Iterable<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)
fun <T> Array<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)
fun Int.pow(n: Int) = pow(n.toLong())
fun Int.pow(n: Long) = toDouble().pow(n.toDouble()).toLong()
fun Long.pow(n: Int) = pow(n.toLong())
fun Long.pow(n: Long) = toDouble().pow(n.toDouble()).toLong()

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val (H, W) = nextIntList()
    val S = Array(H) { next() }
    val T = Array(H) { IntArray(W) { Int.MAX_VALUE } }
    T[0][0] = if (S[0][0] == '.') 0 else 1
    val que = ArrayDeque<P>()
    que.add(P(0, 0))
    while (que.isNotEmpty()) {
        val (x, y) = que.poll()
        if (x < W - 1) {
            val t = T[y][x] + if (S[y][x] == '.' && S[y][x + 1] == '#') 1 else 0
            if (t < T[y][x + 1]) {
                T[y][x + 1] = t
                que.add(P(x + 1, y))
            }
        }
        if (y < H - 1) {
            val t = T[y][x] + if (S[y][x] == '.' && S[y + 1][x] == '#') 1 else 0
            if (t < T[y + 1][x]) {
                T[y + 1][x] = t
                que.add(P(x, y + 1))
            }
        }
    }
    println(T[H - 1][W - 1])
}

data class P(val x: Int, val y: Int)

Measured memory_bytes: 38524
def main():
    a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
    k = int(input())
    print(a[k-1])


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
    #define fio ios_base::sync_with_stdio(false), cin.tie(NULL)
    #define ll long long int
    #define ld long double
    #define f(a, b) for (ll i = a; i < b; i++)
    #define in(a, b) (b.find(a) != string::npos)
    #define X first
    #define Y second
    #define vi vector<int>
    #define fill(a, x) memset(a, x, sizeof(a))
    #define pb push_back
    #define pf push_front
    #define mp make_pair
    #define all(v) v.begin(), v.end()
    #define el "\n"
    const ll M = 1e9 + 7;
    using namespace std;

    int main() {
    fio;
    int n;cin>>n;
    int a[n]={0},b[n]={0};
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<n;i++)cin>>b[i];
    ll mx=0,tmp,ans;
    int cnt;
    for(int i=0;i<pow(2,n);i++){
        tmp=i;
        cnt=0;
        ans=0;
        while(tmp!=0){
            if(tmp%2==1){
                ans+=a[cnt]-b[cnt];
            }
            cnt++;
            tmp=tmp/2;
        }
        mx=max(mx,ans);
    }
    cout<<mx<<el;
    return 0;
    }


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

int main(void)
{

    char c_inputString[101];

    scanf("%s", c_inputString);

    int i_inputStringLength = strlen(c_inputString);
    int repeatCount = i_inputStringLength / 2;

    int index = 0;
    int i_changeCount = 0;
    for (int index = 0; index < repeatCount; index++)
    {
        if (c_inputString[index] != c_inputString[i_inputStringLength - 1])
        {
            i_changeCount++;
        }
        i_inputStringLength--;
    }

    printf("%d", i_changeCount);

}

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

const int mod = 2019;

signed main() {
	int l, r;
	cin >> l >> r;
	if (r - l >= 2019) {
		cout << 0 << endl;
		return 0;
	}
	l %= mod;
	r %= mod;
	if (r < l)r += mod;
	int ans = 2020;
	for (int i = l; i <= r; ++i) {
		for (int j = i + 1; j <= r; ++j) {
			ans = min(ans, (i * j) % mod);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
typedef long long ll;
using namespace std;

int main(void)
{
	int a, b;
	cin >> a >> b;
	if (a % 2 != 0 && b % 2 != 0)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define m_p make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
#define mod 1000000007
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
int m,n;
int main(){
	cin>>n>>m;
	if(n!=m)
	cout<<"No";
	else
	cout<<"Yes";
	re 0;
}

Measured memory_bytes: 256
import java.io.*;
public class Main{
    public static void main(String[] args){
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

        try {
            String line;
            int number = 0;

            line = reader.readLine();
            number = Integer.parseInt(line);
            
            System.out.println(number * number *number);
        
        } catch (NumberFormatException e) {
            System.out.println(e);
        } catch (IOException e) {
            System.out.println(e);
        }
    }
}


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

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

  bool canBuy = false;
  for (int i = 0; i <= 25; i++) {
    for (int j = 0; j <= 15; j++) {
      int total = 4 * i + 7 * j;
      if (total == n) {
        canBuy = true;
      }
    }
  }

  if (canBuy) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> height(N);
  vector<int> judge(N);
  for (int i = 0; i < N; i++){
    cin >> height.at(i);
    judge.at(i) = 1;
  }
  int A, B = 0;
  for (int i = 0; i < M; i++){
    cin >> A >> B;
    if (height.at(A - 1) > height.at(B - 1))
      judge.at(B - 1) = 0;
    else if (height.at(A - 1) < height.at(B - 1))
      judge.at(A - 1) = 0;
    else {
      judge.at(A - 1) = 0;
      judge.at(B - 1) = 0;
    }
  }
  int count = 0;
  for (int i = 0; i < N; i++) {
    if (judge.at(i) == 1)
     count++;
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 3988
#include <iostream>
using namespace std;
#define ll long long
int main()
{
    ll n,i,j,k;
    cin >> n;
    ll a[n][3],dp[n][3];
    for(i=0;i<n;i++)
    cin >> a[i][0] >> a[i][1] >> a[i][2];
    dp[0][0]=a[0][0];
    dp[0][1]=a[0][1];
    dp[0][2]=a[0][2];
    for(i=1;i<n;i++)
    {
        for(j=0;j<3;j++)
        {
            if(j==0)
            dp[i][j]=a[i][j] + max(dp[i-1][1],dp[i-1][2]);
            if(j==1)
            dp[i][j]=a[i][j] + max(dp[i-1][0],dp[i-1][2]);
            if(j==2)
            dp[i][j]=a[i][j] + max(dp[i-1][1],dp[i-1][0]);
        }
    }
    cout << max(max(dp[n-1][1],dp[n-1][2]),dp[n-1][0]) << endl;
    return 0;
}


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

int main(){
    int a, b;
    cin >> a >> b;
    if (a < b)
    {
        rep(i, b){
            cout << a;
        }
        cout << endl;
    }
    else
    {
        rep(i, a){
            cout << b;
        }
        cout << endl;
    }
       
    
    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;

struct node{
	int ti,vi;
};

node no[maxn];
int n,m;
int a[maxn];
long long sum;
bool cmp(node a, node b){
	return a.vi>b.vi;
}

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	
	//for(int i=1;i<=n;i++) cout<<a[i]<<endl;
	
	for(int i=1;i<=m;i++) scanf("%d%d",&no[i].ti,&no[i].vi);
	sort(no+1,no+m+1,cmp);
	
	//for(int i=1;i<=m;i++) printf("%d\n",no[i].vi);
	
	int p=1;
	int cnt=0;
	for(int i=1;i<=n;i++){
		if(a[i]<no[p].vi) a[i]=no[p].vi,cnt++;
		if(cnt==no[p].ti){
			p++;
			cnt=0;
		}
	}
	
	for(int i=1;i<=n;i++) sum+=a[i];
	printf("%lld\n",sum);
	
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A;
  cin >> A;
  string B;
  cin >> B;
  int C=0;
  for(int i=0;i<A;i++){
    if(B.size()<=A){
    C=1;
    }
    else{
      cout << B[i];
      C=2;
    }
  }
  if(C==1){
    cout << B << endl;
  }
  else if(C==2){
    cout << "..." << endl;
  }
}

Measured memory_bytes: 3624
def price(num_unit, shop):
    A, B, C = 0, 1, 2
    
    if shop == A:
        num_discount = (num_unit / 5) * 5
        return 380 * num_discount * 0.8 + 380 * (num_unit % 5)
    elif shop == B:
        num_discount = (num_unit / 4) * 4
        return 550 * num_discount * 0.85 + 550 * (num_unit % 4)
    else:
        num_discount = (num_unit / 3) * 3
        return 850 * num_discount * 0.88 + 850 * (num_unit % 3)

while True:
    quantity = int(raw_input())
    if quantity == 0: break

    comb = []
    for a in range(quantity / 200 + 1):
        for b in range(quantity / 200 + 1):
            for c in range(quantity / 200 + 1):
                if a * 200 + b * 300 + c * 500 == quantity:
                    comb.append([a, b, c])

    prices = []
    for c in comb:
        prices.append(price(c[0], 0) + price(c[1], 1) + price(c[2], 2))

    print int(min(prices))

Measured memory_bytes: 4288
# -*- coding: utf-8 -*-
import sys


def get_num():
    return int(input())


def get_nums(n):
    res = [0 for _ in range(n)]
    for i in range(n):
        res[i] = int(input())
    return res


def get_numbers():
    return map(int, input().split())

n = get_num()
h = list(get_numbers())

highest = 0
ans = 0
for height in h:
    if height >= highest:
        highest = height
        ans += 1

print(ans)

Measured memory_bytes: 38256
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
    static int[] w = new int[100010];
    static int[] v = new int[100010];
    static int[][] dp = new int[110][100010];
    static int k;

    static int chmin(int a, int b) {
        if (a > b) {
            a = b;
            return a;
        }
        return a;
    }

    static int chmax(int a, int b) {
        if (a < b) {
            a = b;
            return a;
        }
        return a;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int tasu = a + b;
        int hiku = a - b;
        int kakeru = a * b;

        System.out.println(Math.max(Math.max(a + b, a - b), Math.max(a + b, a * b)));
    }
}


Measured memory_bytes: 80340
#include<bits/stdc++.h>
#define stt static
#define rg register
#define ll long long
#define db double
#define pii pair<int,int>
#define mp make_pair
#define fst first
#define snd second
#define pb push_back
#define y1 substitute_of_y1
#define DEBUG(...) fprintf(stderr,__VA_ARGS__)
using namespace std;

template<typename T> T rd(){
	T nmb=0;int sgn=0;char chr=getchar();
	while(!isdigit(chr)){if(chr=='-')sgn=1;chr=getchar();}
	while(isdigit(chr)){nmb=(nmb<<3)+(nmb<<1)+chr-'0';chr=getchar();}
	return sgn?-nmb:nmb;
}
template<typename T> void wt(T nmb){
	if(nmb>9)wt(nmb/10);
	putchar(nmb%10+'0');
}
template<typename T> void cmax(T &x,T y){x=x>y?x:y;}
template<typename T> void cmin(T &x,T y){x=x<y?x:y;}
void proc_status(){
	ifstream t ("/proc/self/status");
	cerr<<string(istreambuf_iterator<char>(t),istreambuf_iterator<char>())<<endl;
	/*freopen("/proc/self/status","r",stdin);
	char ch[100];
	while(scanf("%s",ch)!=EOF)cerr<<ch<<endl;*/
}

const int N=20,K=(1<<16)+10;
const int P=1e9+7;

int pwr(int x,int y){
	int z=1;
	for(;y;y>>=1,x=(ll)x*x%P)
		if(y&1)z=(ll)z*x%P;
	return z;
}

int fac[K],inv[K];
void getfac(int n){
	fac[0]=1;
	for(int i=1;i<=n;++i)
		fac[i]=(ll)fac[i-1]*i%P;
	inv[n]=pwr(fac[n],P-2);
	for(int i=n;i;--i)
		inv[i-1]=(ll)inv[i]*i%P;
}
int C(int n,int m){
	if(n<0||m<0||n<m)return 0;
	return (ll)fac[n]*inv[m]%P*inv[n-m]%P;
}

int Lg[K];
void getLg(int n){
	Lg[1]=0;
	for(int i=2;i<=n;++i)
		Lg[i]=Lg[i>>1]+1;
}

int n,m,All;
int a[N];
int dp[N][K];

#define lowbit(x) ((x)&(-(x)))

void Init(){
	n=rd<int>(),m=rd<int>();
	for(int i=1;i<=m;++i)
		a[i]=rd<int>();
	sort(a+1,a+m+1);
	All=(1<<n)-1;
	getfac(All);
	getLg(All);
}

void Solve(){
	dp[m+1][0]=1;
	for(int S=0;S<=All;++S){
		for(int i=m;i;--i){
			(dp[i][S]+=dp[i+1][S])%=P;
			for(int T=S;T;T^=lowbit(T)){
				int t=lowbit(T);
				(dp[i][S]+=(ll)dp[i+1][S^t]*C((1<<n)-(S^t)-a[i],t-1)%P*fac[t]%P)%=P;
			}
		}
	}
	int Ans=0;
	for(int S=0;S<=All;++S)
		(Ans+=(ll)((__builtin_popcount(S)&1)?P-1:1)*dp[1][S]%P*fac[All-S]%P)%=P;
	Ans=(ll)Ans*(1<<n)%P;
	printf("%d\n",Ans);
}

int main(){
	Init();
	Solve();
	return 0;
}

Measured memory_bytes: 5120
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>


using namespace std;

int main() {
	string a;
	map<string, int> tick;
	vector<string> name;
	int max = 0, n;
	cin >> n;
	while (n--) {
		string a;
		cin >> a;
		tick[a]++;
		if (tick[a] > max) {
			name.clear();
			name.push_back(a);
			max = tick[a];
		}
		else if (tick[a] == max) {
			name.push_back(a);
		}
	}
	sort(name.begin(), name.end());
	for (auto p = name.begin(); p != name.end(); p++)
		cout << *p << endl;
	return 0;
}



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

int main() {
	int r, d; cin >> r >> d;
    vector<int> x(11,0); cin >> x.at(0);
    for (int i = 0; i < 10; i++)
    {
        x[i+1]=r*x[i]-d;
        cout << x.at(i+1) << endl;
    }
    

}
//g++ -o b.exe b.cpp

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

A = list(map(int,input().split()))
B = list(map(int,input().split()))


ans = 0
last = 0
for i in range(N):
    b = B[i]
    a = A[i] - last
    if a < b:
        ans += a
        b -= a
        if A[i+1]<b:
            ans += A[i+1]
            b -= A[i+1]
            last = A[i+1]
        elif A[i+1]>=b:
            ans += b
            last = b        
    elif a >= b:
        last = 0
        ans += b
print(ans)


Measured memory_bytes: 82020
import java.util.*;
import java.math.BigInteger;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println(a59_b(sc.next(),sc.next()));
    }

    static String a59_b(String i1, String i2) {
        BigInteger b1 = new BigInteger(i1);
        BigInteger b2 = new BigInteger(i2);

        int i = b1.compareTo(b2);
        if (i == -1) {
            return "LESS";
        } else if (i == 1) {
            return "GREATER";
        } else {
            return "EQUAL";
        }
    }
}


Measured memory_bytes: 22868
import queue

n, q = map(int, input().split())
queue = queue.Queue()
for i in range(n):
    name, time = input().split()
    queue.put((name, int(time)))

t = 0
while not queue.empty():
    name, time = queue.get()

    if time <= q:
        t += time
        print(name, t)
    else:
        queue.put((name, time - q))
        t += q



Measured memory_bytes: 13636
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a1 = sc.nextInt();
        int a2 = sc.nextInt();
        int a3 = sc.nextInt();
        if(a1+a2+a3>=22){
            System.out.println("bust");
        }else{
            System.out.println("win");
        }
    }
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
#include <math.h>
#define ALL(a)    a.begin(), a.end() 
#define rep(i, K, N)  for(long long int i = K; i < N; i++)
#define ll long long int
using namespace std;

int main(){
bool Ans = 1;
string S, T;cin >> S >> T;
ll L = S.size(), s_count = 0, t_count = 0;
vector<ll> A(L + 1);vector<ll> B(L + 1);
map<char, ll> s;map<char, ll> t;

rep(i, 0, L)s[S[i]]++;

rep(i, 0, L)t[T[i]]++;

for(auto x : s ){

    s_count++;

    A[x.second]++;

}

for(auto x : t ){

    t_count++;

    B[x.second]++;

}

if(s_count != t_count || A != B)Ans = 0;

if(Ans)cout << "Yes";

else cout << "No";
}

Measured memory_bytes: 7024
#include<iostream>
#include<cstdio>
#include<cstring>
 
const int MAXN=20;
 
int n;
char s[MAXN];
 
int main()
{
	int i;scanf("%s",s);
	n=strlen(s);
	if(n==1) {printf("%d",s[0]-'0');return 0;}
	int ans=0;
	for(i=0;i<n;i++) ans+=s[i]-'0';
	ans=std::max(ans,s[0]-1-'0'+(n-1)*9);
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
	N, Q = MAP()
	tree = defaultdict(list)
	dic = defaultdict(int)
	for _ in range(N-1):
		a, b = MAP()
		tree[a-1].append(b-1)
		tree[b-1].append(a-1)

	for _ in range(Q):
		p, x = MAP()
		dic[p-1] += x

	ans = [0]*N

	checked = [0]*N
	checked[0] = 1

	q = deque([])
	q.append(0)

	while q:
		n = q.popleft()
		ans[n] += dic[n]
		for node in tree[n]:
			if checked[node]:
				continue
			ans[node] += ans[n]
			checked[node] = 1
			q.append(node)

	print(*ans)

if __name__ == '__main__':
	main()

Measured memory_bytes: 99444
N = int(input())
A = list(map(int,input().split()))
A.sort()
S = [0] * N
total = 0
for i in range(N):
    total += A[i]
    S[i] = total
S = [0] + S
for i in range(1, N + 1):
    if A[-i] > 2 * S[-i - 1]:
        print(i)
        break

Measured memory_bytes: 14228
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)998244353;
const double EPS = 1e-9;
struct Edge {
  ll to;
  ll cost;
};
long long combination(long n, long r, long long mod) {
  //nCrを返す　O(r)
  // 逆元はその場で対応
  if (n < r) swap(n, r);
  long long bunbo = 1;
  long cnt = r;
  while (0 < cnt) {
    bunbo *= cnt;
    bunbo % mod;
    cnt--;
  }
 if (bunbo == 0) return 1;
  long long bunsi = 1;
  cnt = 0;
  while (cnt < r) {
    bunsi *= (n  - cnt);
    bunsi %= mod;
    cnt++;
  }
  return bunsi / bunbo % mod;
}
long long longpow(long long n, long long a, long long mod) {
  if (a == 0) return 1;
  if (a == 1) return n % mod;
  if (a % 2 == 1) return (n * longpow(n, a - 1, mod)) % mod;
  ll t = longpow(n, a / 2, mod) % mod;
  return (t * t) % mod;
}
int main() {
  int N;
  cin >> N;
  vector<int> d(N);
  map<int, int> uo{};
  REP(i, N) {
    cin >> d[i];
    uo[d[i]]++;
  }
  if(d[0]!=0||uo[0]>=2){
    cout << 0 << endl;
    return 0;
  }
  ll ans = 1;
  for(auto s:uo){
    if (s.first == 0) continue;
    int num = s.first,id=s.second;
    if (uo[num - 1] == 0) ans = 0;
    ans *= longpow(uo[num-1],uo[num],MOD);
    ans %= MOD;
  }
  cout << ans << endl;
 }

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


/*

#の周りを+1していく解き方。めんどい。
あと，いきなりs[i][j]てやっていいみたい。

int main (){

int H, W;
cin >> H >> W;
vector<string> S(H);
for (int i=0; i<H; i++) cin >> S.at(i);
int field[H][W];
for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
        if(S.at(i).at(j)=='#') field[i][j]=-1;
        else field[i][j]=0;
    }
}

for(int x=0; x<H; x++){
    for(int y=0; y<W; y++){
        if(field[x][y]==-1){
            for(int dx=-1; dx<=1; dx++){
                for(int dy=-1; dy<=1; dy++){
                    int nx=x+dx, ny=y+dy;
                    if(0<=nx && nx<H && 0<=ny && ny<W && field[nx][ny]!=-1){
                        field[nx][ny]++;
                    }
                }
            }
        }
    }
}
for(int x=0; x<H; x++){
    for(int y=0; y<W; y++){
        if(field[x][y]>=0) cout << field[x][y];
        else cout << "#";
    }
    cout << endl;
}


}
*/
#define rep(i,n) for(int i=0; i<n; i++)
int main (){

int H, W;
cin >> H >> W;
string s[H];
rep(i,H) cin >> s[i];

rep(i,H){
    rep(j,W){
        if(s[i][j]=='#'){
        cout << "#";
        }
        else{
        int cnt=0;
        for(int dx=-1; dx<=1; dx++){
            for(int dy=-1; dy<=1; dy++){
                int nx=i+dx, ny=j+dy;
                if(0<=nx && nx<=H && 0<=ny && ny<=W && s[nx][ny]=='#')
                cnt++;
            }
        }
        cout << cnt;
        }
    }
    cout << endl;
}

}

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

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

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


//-----------------------------------------------------------------------------

int n;

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

	cin>>n;
	int x=n;
	int sum=0;
	while(n>0) sum+=n%10,n/=10;
	cout<<(x%sum!=0?"No":"Yes")<<endl;

	return 0;
}


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

using namespace std;

typedef long long ll;

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

	int n;
	cin >> n;

	vector<ll> a(n);
	rep(i, n) cin >> a[i];

	ll q = 2;
	ll ans = a[0] - 1;
	rep(i, n - 1){
		if(a[i+1] == q){
			q++;
		}else{
			ans += (a[i+1] % q == 0 ? a[i+1] / q - 1: a[i+1] / q);
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 1024
/*
　　　∫ ∫ ∫
　　　ノヽ
　　（＿　 ）
　（＿　　　 ）
（＿＿＿＿＿＿ ）
　ヽ(´･ω･)ﾉ　
　　 |　 /
　　 UU
*/
#pragma region macro
#include <bits/stdc++.h>
typedef long long int64;
using namespace std;
typedef vector<int> vi;
const int MOD = (int)1e9 + 7;
const int64 INF = 1LL << 62;
const int inf = 1<<30;
const char bn = '\n';
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,s,n) for (int i = s; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end() //コンテナじゃないと使えない!!
#define debug(x) cerr << #x << ": " << x << "\n";
#define mp make_pair
template <typename T>
ostream& operator<<(ostream& os, const vector<T> &V){
    int N = V.size();
    REP(i,N){
        os << V[i];
        if (i!=N-1) os << " ";
    }
    os << "\n";
    return os;
}
template <typename T,typename S>
ostream& operator<<(ostream& os, pair<T,S> const&P){
    os << "(";
    os << P.first;
    os << " , ";
    os << P.second;
    os << ")";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, set<T> &S){
    auto it=S.begin();
    while(it!=S.end()){
        os << *it;
        os << " ";
        it++;
    }
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, deque<T> &q){
    for(auto it=q.begin();it<q.end();it++){
        os<<*it;
        os<<" ";
    }
    os<<endl;
    return os;
}
template <typename T,typename S>
ostream& operator<<(ostream& os, map<T,S> const&M){
    for(auto e:M){
        os<<e;
    }
    os<<endl;
    return os;
}
vector<pair<int,int>> dxdy = {mp(0,1),mp(1,0),mp(-1,0),mp(0,-1)};
#pragma endregion
//fixed<<setprecision(10)<<ans<<endl;


//素因数分解
map<int64,int64> prime_factorization(int64 n){
    int64 copy = n;
    map<int64,int64> res;
    for(int64 i=2;i*i<=copy;i++){
        while(n%i==0){
            res[i]++;
            n/=i;
        }
    }
    if(n!=1) res[n]++;
    return res;
}

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

    int64 ans=0;
    for(auto e:prime_factorization(N)){
        int64 a,b; tie(a,b) = e;
        int64 x = (sqrt(8*b+1) - 1) / 2;
        ans += x;
    }

    cout << ans << endl;
}

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

#define rep(i, n) REP(i, 0, n)
#define REP(i,k,n) for(int i = k; i < n; i++)
#define mmax(start, end) *max_element(start, end)
#define mmin(start, end) *min_element(start, end)
#define argmax max_element
#define argmin min_element
#define ALL(x) (x).begin(), (x).end()

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

int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};
int dx8[8] = {-1, -1, -1, 0, 0, 1, 1, 1};
int dy8[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

template<class T = ll> T in() {
    T _in;
    cin >> _in;
    return _in;
}

int num_b[51][51] = {0};

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

    int N, M;
    cin >> N >> M;

    rep(m, M) {
        int a, b;
        cin >> a >> b;
        num_b[a][b]++;
        num_b[b][a]++;
    }

    // REP(i, 1, N+1) {
    //     REP(j, 1, N+1) {
    //         cout << num_b[i][j] << " ";
    //     }
    //     cout << endl;
    // }

    REP(n, 1, N+1) {
        cout << accumulate(num_b[n], num_b[n]+N+1, 0) << endl;
    }
    return 0;
}


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

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

    int t[n];

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

    sort(t, t + n);

    int ans = 0;
    int tt = t[0];
    int bus = 0;
    for (int i = 0; i < n - 1; i++) {
        bus++;

        if (tt + k < t[i + 1] || bus == c) {
            ans++;
            bus = 0;
            tt = t[i + 1];
        }
    }

    ans++;

    cout << ans << endl;

    return 0;
}


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


int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	long long int a,b,c,d;
	cin>>a>>b>>c>>d;
	long long int x=a*c;
	long long int y=a*d;
	long long int z=b*d;
	long long int w=b*c;
	cout<<max(x,max(y,max(z,w)))<<endl;
	return 0;
}

Measured memory_bytes: 3604
#include <cstdio>
#include <algorithm>

const int MN = 105;

int N, A[MN], B[MN];

int main() {
	scanf("%d", &N);
	for (int i = 1; i <= N; ++i) scanf("%d", &A[i]), ++B[A[i]];
	std::sort(A + 1, A + N + 1);
	int len = A[N];
	for (int i = 0; i <= len; ++i) --B[std::max(len - i, i)];
	for (int i = 1; i <= N; ++i) if (B[i] < 0) return puts("Impossible"), 0;
	int hlen = (len + 1) / 2;
	for (int i = 1; i <= hlen; ++i) if (B[i]) return puts("Impossible"), 0;
	puts("Possible");
	return 0;
}

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

int main(){
 int a,b,c,d;
 cin >> a >> b >> c >> d;
 while(true){
   c -= b;
   if(c<=0){
     cout << "Yes" << endl;
     return 0;
   }
   a -= d;
   if(a<=0){
     cout << "No" << endl;
     return 0;
   }
 }
}
  
    


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

int main() {
  int64_t h, w;
  std::cin >> h >> w;

  int64_t ans = h * w;

  if (3 <= h) {
    ans = std::min(ans, h % 3 == 0 ? 0 : w);
  }
  if (3 <= w) {
    ans = std::min(ans, w % 3 == 0 ? 0 : h);
  }

  for (int64_t i = 1; i < h; i++) {
    const auto j = w / 2, k = w - j;
    const auto max = std::max({i * w, (h - i) * j, (h - i) * k});
    const auto min = std::min({i * w, (h - i) * j, (h - i) * k});
    ans = std::min(ans, max - min);
  }

  for (int64_t i = 1; i < w; i++) {
    const auto j = h / 2, k = h - j;
    const auto max = std::max({i * h, (w - i) * j, (w - i) * k});
    const auto min = std::min({i * h, (w - i) * j, (w - i) * k});
    ans = std::min(ans, max - min);
  }

  std::cout << ans << std::endl;

  return 0;
}


Measured memory_bytes: 256
// ABC043_B
#include <iostream>
#include <string>
#include <vector>
#include <iterator>
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;
using ll = long long;

#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define MIN(vec) min_element(vec.begin(), vec.end())  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(vec.begin(), vec.end())
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(vec.begin(), vec.end(), 0LL)  // 0 は初期値
#define vl vector<ll>
#define pll pair<ll, ll>
#define F first
#define S second

int main() {
    // input
    string S;
    cin >> S;
    
    // calculation
    vector<char> ch;
    REP(i, S.length()) {
        if (S[i] != 'B') {
            ch.push_back(S[i]);
        } else {
            if (!ch.empty()) ch.pop_back();
        }
    }
    
    REP(i, ch.size()) {
        cout << ch[i];
    }
    cout << "\n";
    return 0;
}

Measured memory_bytes: 256