akhauriyash/Code-Regression huggingface dataset:
N = int(input())
B = list(map(int, input().split()))

cnt = B[0]*2
p = B[0]
for i in range(1, N-1):
    if B[i]>=p:
        cnt += B[i]
    else:
        cnt -= p
        cnt += B[i]*2
    p = B[i]

print(cnt)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int n,m,l,a[1000][1000],b[1000][1000];
long long c[1000][1000];
int main()
{
    scanf("%d%d%d",&n,&m,&l);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
            scanf("%d",&a[i][j]);
    for(int i=1;i<=m;i++)
        for(int j=1;j<=l;j++)
            scanf("%d",&b[i][j]);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=l;j++)
            for(int k=1;k<=m;k++)
                c[i][j]+=a[i][k]*b[k][j];
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=l-1;j++)
            printf("%lld ",c[i][j]);
        printf("%lld\n",c[i][l]);
    }
}



Measured memory_bytes: 4428
#include <bits/stdc++.h>
	#include <set>
	#define ll long long 
	#include <string>
	#define pb push_back
	#define mp make_pair
	# define pi 3.14159265358979323846
	#define mod 1000000007
    #define rep(i,n) for(i=0;i<n;i++)
    #define rep1(i,n) for(i=1;i<n;i++)
	using namespace std;
	ll int multiply(ll int a,ll int b)
{
	ll int ans=(a%mod*b%mod)%mod;
	return ans;
}
ll int add(ll int a, ll int b)
{
	ll int ans=(a%mod+b%mod)% mod;	
	return ans;
}

	int power(ll int x,  ll int y, ll int p)  
{  
    ll int res = 1;     // Initialize result  
  
    x = x % p; // Update x if it is more than or  
                // equal to p 
   
    if (x == 0) return 0; // In case x is divisible by p; 
  
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % p;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}  
	void fastio()
	{					
		#ifndef ONLINE_JUDGE
	    // for getting input from input.txt
	    freopen("input.txt", "r", stdin);
	    // for writing output to output.txt
	    freopen("output.txt", "w", stdout);
	    #endif
	    ios_base::sync_with_stdio(false);
	    cin.tie(NULL);
	    cout.tie(NULL);

	}
	// vector<ll int> adj[100001];
	// ll int vis[100001]={0};
	// ll int indegree[100001]={0};
	// ll int dist[100001]={0};
	// void dfs(ll int n)
	// {
	// 	vis[n]=1;
	// 	for(auto node: adj[n])
	// 	{
	// 		dist[node]=max(dist[node],dist[n]+1);
	// 		indegree[node]--;
	// 		if (indegree[node]==0)
	// 			dfs(node);
	// 	}
	// }
	// ll int dp[100001]={0};
	void solve()
	{
		string s;
		cin>>s;
		if(s[s.size()-1]!='s')
			{s+='s';
		}
		else
			{
				
			s+="es";

			}
			cout<<s<<endl;
		
		
    }
	int main()
	{
		fastio();
		ll int t;
		t=1;
		// cin>>t;
		
		while(t--)
		{
			solve();
		}
			
	}
			

Measured memory_bytes: 3664
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstdio>
#include <climits>
#include <set>
#include <map>
using namespace std;

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

typedef long long ll;

int main()
{
    int n;
    cin >> n;
    vector<int> p(n), q(n);

    rep(i, n) cin >> p.at(i);
    rep(i, n) cin >> q.at(i);

    vector<int> a(n);
    rep(i, n) a.at(i) = i + 1;

    map<vector<int>, int> mp;
    do{
        mp[a] = mp.size();
    }while(next_permutation(a.begin(), a.end()));

    cout << abs(mp[q] - mp[p]) << endl;
    
    return 0;
}

Measured memory_bytes: 5248
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<utility>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<math.h>
#include <map>
using namespace std;
typedef long long int ll;
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define all(u) u.begin(),u.end()
#define pl pair<ll,ll>
#define fi first
#define se second
#define inf 1000000007

ll N,M;

int main() {
    cin >> N >> M;
    if (N > 2 && M > 2){
        cout << N*M-(2*(N+M)-4);
        return 0;
    }
    if (N == 2 || M == 2){
        cout << 0 << endl;
        return 0;
    }
    if (N > 1 || M > 1){
        cout << N*M-2 << endl;
        return 0;
    }
    else{
        cout << 1 << endl;
    }



    return 0;
}


Measured memory_bytes: 256
//ABC 050-B
#define _USE_MATH_DEFINES

#include <iostream>
#include <cmath>
#include <stdlib.h>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cstring>
#include <numeric>
#include <string>
#include <map>
#include <sstream>
using namespace std;

int main() {
	int N, T[100], M, P, X[100], TotalTime = 0;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> T[i];
		TotalTime += T[i];
	}
	cin >> M;
	for (int i = 0; i < M; i++) {
	cin >> P >> X[i];
	cout << TotalTime - T[P-1] + X[i] << endl;
	}
}

Measured memory_bytes: 256
h,w = map(int,input().split())
import numpy as np
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
load = []
for i in range(10):
  load.append(list(map(int,input().split())))
load = np.array(load)
dist = shortest_path(load)
count = 0
for i in range (h):
  h_list = list(map(int,input().split()))
  for j in range(w):
    if h_list[j] != -1:
      count += dist[h_list[j]][1]

print(int(count))
  

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

int main() {
	ios :: sync_with_stdio(false);
	int t; cin >> t;
	while(t --) {
		int a[120];
		memset(a, 0, sizeof a);
		auto f = [&]() {
			string s; cin >> s;
			reverse(s.begin(), s.end());
			for(int i = 0; i < s.size(); i ++)
				a[i] += s[i] - '0';
		};
		f(); f();
		for(int i = 0; i + 1 < 120; i ++)
			if(a[i] >= 10) {
				a[i + 1] ++;
				a[i] -= 10;
			}
		int s = -1;
		for(int i = 0; i < 120; i ++)
			if(a[i]) s = i;
		if(s == -1)
			cout << 0 << '\n';
		else if(s >= 80)
			cout << "overflow\n";
		else {
			for(int i = s; i >= 0; i --)
				cout << a[i];
			cout << '\n';
		}
	}
	return 0;
}

Measured memory_bytes: 3128
h,n=[int(j) for j in input().split()]
ab=[[int(j) for j in input().split()] for i in range(n)]
dp=[10**18]*(h+1)
dp[0]=0
ans=10**18
for a,b in ab:
    for i in range(h+1):
        if dp[i]!=10**18:
            if i+a<h:
                if dp[i]+b<dp[i+a]:
                    dp[i+a]=dp[i]+b
            else:
                if dp[i]+b<ans:
                    ans=dp[i]+b

print(ans)







Measured memory_bytes: 42204
#include <bits/stdc++.h>		//线段树维护区间和
#define ll long long
#define inf 0x3f3f3f3f 
using namespace std;
const int maxn = 1e5+10;
int a[200005];
int n,k;
int check(int mid){
	int sum = 0;
	for(int i = 1; i <= n; i ++){
		if(a[i] != mid) sum += a[i]/mid;
		if(sum > k) return 0;
	}
	return sum <= k;
}
int main(){
	scanf("%d %d", &n, &k);
	int l = 1;
	int r = -1;
	for(int i = 1; i <= n; i ++){
		scanf("%d", a+i);
		r = max(r,a[i]);
	}
	if(k == 0){
		printf("%d\n", r);
		return 0;
	}
	int ans = r;
	while(l<r){
		int mid = (l+r)/2;
		if(check(mid)){
			r = mid;
			ans = mid;
		}else l = mid + 1;
	}
	printf("%d\n", ans);

 	return 0;
}

Measured memory_bytes: 4436
#include <bits/stdc++.h>
#ifdef LOC
#include "debuglib.h"
#else
#define deb(...)
#define DBP(...)
#endif
using namespace std;
using   ll         = long long;
using   Vi         = vector<int>;
using   Pii        = pair<int, int>;
#define pb           push_back
#define mp           make_pair
#define x            first
#define y            second
#define rep(i, b, e) for (int i = (b); i < (e); i++)
#define each(a, x)   for (auto& a : (x))
#define all(x)       (x).begin(), (x).end()
#define sz(x)        int((x).size())

constexpr int MOD = 1e9+7;

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cout << fixed << setprecision(18);

	int n; cin >> n;
	vector<ll> elems(n);
	each(e, elems) cin >> e;

	ll ans = 0;
	ll mult = 1;

	rep(bit, 0, 60) {
		ll cnt[2] = {};
		each(e, elems) {
			cnt[(e >> bit) & 1]++;
		}

		ans += cnt[0]*cnt[1] % MOD * mult % MOD;
		ans %= MOD;
		mult = mult*2 % MOD;
	}

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


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

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<vector<string>> res(n);
  res.at(0).push_back("a");
  for (int i=1; i<n; ++i) {
    for (string s : res.at(i-1)) {
      char end = 0;
      for (char c : s) if (end < c) end = c;
      ++end;
      for (char c='a'; c<=end; ++c) {
        res.at(i).push_back(s+c);
      }
    }
  }
  for (string s : res.at(n-1)) cout << s << endl;
  return 0;
}


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

signed main() {
  int N;
  cin >> N;
  static int s[101010];
  for (int i = 0; i < N - 1; i++) cin >> s[i];

  int ans = 0;
  for (int i = 1; i < N; i++) {
    int sum = 0;
    int L = 0, R = N - 1;
    if ((N - 1) % i == 0) {
      while (L < R) {
        sum += s[L] + s[R];
        L += i;
        R -= i;
        ans = max(ans, sum);
      }
    } else {
      while (L + i < N - 1) {
        sum += s[L] + s[R];
        L += i;
        R -= i;
        ans = max(ans, sum);
      }
    }
  }

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


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

#define REP(i,n) for(int i=0;i<n;++i)
#define RREP(i,n) for(int i=n-1;i>=0;--i)
#define FOR(i,m,n) for(int i=m;i<n;++i)
#define RFOR(i,m,n) for(int i=n-1;i>=m;--i)
#define ALL(v) v.begin(),v.end()
#define PB(a) push_back(a)
#define INF 1000000001
#define MOD 1000000007
#define EPS 1e-9

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

using namespace std;


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int k, s;
	cin >> k >> s;
	vector<int> v(k + 1);
	int cnt = 0;
	REP(i, k + 1) v[i] = i;
	REP(i, k + 1) {
		REP(j, k + 1) {
			if (s >= i + j&&binary_search(ALL(v), s - i - j))cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}


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

int cmpAsc(const void * n1, const void * n2) {
	if (*(long *)n1 > *(long *)n2)
	{
		return 1;
	}
	else if (*(long *)n1 < *(long *)n2)
	{
		return -1;
	}
	else
	{
		return 0;
	}
}
int cmpDes(const void * n1, const void * n2) {
	if (*(long *)n1 > *(long *)n2)
	{
		return -1;
	}
	else if (*(long *)n1 < *(long *)n2)
	{
		return 1;
	}
	else
	{
		return 0;
	}
}

int main(void) {

  long n;
  scanf("%ld", &n);
  long first[n],second[n],third[n];
  for (long i = 0; i < n; i++) {
    scanf("%ld", &first[i]);
  }
  for (long i = 0; i < n; i++) {
    scanf("%ld", &second[i]);
  }
  for (long i = 0; i < n; i++) {
    scanf("%ld", &third[i]);
  }
  qsort(first, n, sizeof(long), cmpAsc);
  qsort(third, n, sizeof(long), cmpDes);
  long first_sum[n+1],third_sum[n+1];
  first_sum[0] = 0;
  third_sum[0] = 0;
  for (long i = 0; i < n; i++) {
    first_sum[0] += first[i];
    third_sum[0] += third[i];
  }
  long cur,child,child1,parent;
  for (long i = 0; i < n; i++) {
    first_sum[i+1] = first_sum[i];
    if (second[i] > first[0]) {
      first_sum[i+1] += second[i]-first[0];
      first[0] = first[n-1];
      cur = 0;
      while (1) {
        child = cur*2+1;
        if (child >= n-1) {
          break;
        }
        if (child < n-2) {
          child1 = child+1;
          if (first[child1] < first[child]) {
            child = child1;
          }
        }
        if (first[n-1] > first[child]) {
          first[cur] = first[child];
          first[child] = first[n-1];
          cur = child;
        } else {
          break;
        }
      }
      first[n-1] = second[i];
      cur = n-1;
      while (cur > 0) {
        parent = (cur-1)/2;
        if (second[i] < first[parent]) {
          first[cur] = first[parent];
          first[parent] = second[i];
          cur = parent;
        } else {
          break;
        }
      }
    }
  }
  for (long i = n-1; i >= 0; i--) {
    third_sum[n-i] = third_sum[n-i-1];
    if (second[i] < third[0]) {
      third_sum[n-i] += second[i]-third[0];
      third[0] = third[n-1];
      cur = 0;
      while (1) {
        child = cur*2+1;
        if (child >= n-1) {
          break;
        }
        if (child < n-2) {
          child1 = child+1;
          if (third[child1] > third[child]) {
            child = child1;
          }
        }
        if (third[n-1] < third[child]) {
          third[cur] = third[child];
          third[child] = third[n-1];
          cur = child;
        } else {
          break;
        }
      }
      third[n-1] = second[i];
      cur = n-1;
      while (cur > 0) {
        parent = (cur-1)/2;
        if (second[i] > third[parent]) {
          third[cur] = third[parent];
          third[parent] = second[i];
          cur = parent;
        } else {
          break;
        }
      }
    }
  }
  long score;
  long max = first_sum[0]-third_sum[0];
  for (long i = 0; i <= n; i++) {
    score = first_sum[i]-third_sum[n-i];
    if (score > max) {
      max = score;
    }
  }
  printf("%ld\n", max);

  return 0;
}

Measured memory_bytes: 4848
def main():
    n = int(input())
    A = []
    for i in range(n):
        A.append(int(input()))

    maxA = 0
    maxA_idx = 0
    for i in range(n):
        if A[i] > maxA:
            maxA_idx, maxA = i, A[i]
    maxA2nd = 0
    maxA2_idx = 0
    for i in range(n):
        if i != maxA_idx and A[i] > maxA2nd:
            maxA2_idx, maxA2nd = i, A[i]

    for i in range(n):
        if i != maxA_idx:
            print(maxA)
        else:
            print(maxA2nd)
    # return


if __name__ == '__main__':
    # print(main())
    main()

Measured memory_bytes: 12512
N = gets.to_i
Se = []
So = []
(N + 1).times{|i| So << []; Se << []}
(N - 1).times{|i|
  u, v, w = gets.chomp.split(" ").map(&:to_i);
  w.even? ? (Se[u] << v; Se[v] << u) : (So[u] << v; So[v] << u)
}

vtx = Array.new(N + 1)
vtx[1] = 1
q = [1]
while q.size > 0
  v = q.shift
  Se[v].select{|i| !vtx[i] }.each{|j| vtx[j] =   vtx[v]; q.push(j)}
  So[v].select{|i| !vtx[i] }.each{|j| vtx[j] = 1-vtx[v]; q.push(j)}
end

puts vtx[1, N]

Measured memory_bytes: 18428
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
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()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *

N = input()

if len(N) == 1:
	print(N)
else:
	ans1 = 9*(len(N)-1) + int(N[0])-1
	ans2 = sum([int(x) for x in list(N)])
	print(max(ans1, ans2))

Measured memory_bytes: 5204
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 13 09:53:12 2019

@author: Owner
"""

import collections
import scipy.misc
import sys
import numpy as np
import math
from operator import itemgetter
import itertools
import copy
import bisect

#素因数を並べる
def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(int(i))
    i += 1
  if n > 1:
    table.append(int(n))
  return table   
# 桁数を吐く
def digit(i):
    if i > 0:
        return digit(i//10) + [i%10]
    else:
        return []
    
def getNearestValueIndex(list, num):
    """
    概要: リストからある値に最も近い値のインデックスを取得する関数
    @param list: データ配列
    @param num: 対象値
    @return 対象値に最も近い値
    """

    # リスト要素と対象値の差分を計算し最小値のインデックスを取得
    idx = np.abs(np.asarray(list) - num).argmin()
    return idx

def find_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default


"""
N, X = map(int, input().split())

x = [0]*N
x[:] = map(int, input().split())

P = [0]*N
Y = [0]*N
for n in range(N):
    P[n], Y[n] = map(int, input().split())

    
all(nstr.count(c) for c in '753')

# 複数配列を並び替え
ABT = zip(A, B, totAB)
result = 0
# itemgetterには何番目の配列をキーにしたいか渡します
sorted(ABT,key=itemgetter(2))
A, B, totAB = zip(*ABT)
A.sort(reverse=True)

# 2進数のbit判定
(x >> i) & 1

# dp最小化問題
dp = [np.inf]*N
for n in range(N):
    if n == 0:
        dp[n] = 0
    else:
        for k in range(1,K+1):
            if n-k >= 0:
                dp[n] = min(dp[n], dp[n-k] + abs(h[n]-h[n-k]))
            else:
                break

"""

N, K = map(int, input().split())
S = input()
def main():
    now = 1
    cnt = 0
    nums = []
    for i in range(N):
        if S[i] == str(now):
            cnt += 1
        else:
            nums.append(cnt);
            now = 1-now
            cnt = 1
    if cnt != 0:
        nums.append(cnt)
    if len(nums)%2 ==0:
        nums.append(0)
    add = 2*K + 1
    res = 0
    # 累積和
    sums = [0]*(len(nums)+1)
    for i in range(len(nums)):
        sums[i+1] = sums[i] + nums[i]
    for i in range(0, len(nums), 2):
        left = i
        right = min(i+add, len(nums))
        tmp = sums[right] - sums[left]
        res = max(tmp, res)
    """
    # 尺取り法
    # ループの外にleft , right
    left = 0
    right = 0
    tmp= 0 # [left, right) のsum
    for i in range(0, len(nums), 2):
        # 次のleft, right を計算
        nextLeft = i
        nextRight = min(i+add, len(nums))
        # 左端を計算
        while (nextLeft > left):
            tmp -= nums[left]
            left += 1
        
        # 右端を計算
        while (nextRight > right):
            tmp += nums[right]
            right +=1
        res = max(tmp, res)
    """
    print(res)
 
if __name__ == '__main__':
    main()

Measured memory_bytes: 18484
n, m = map(int, input().split())
imos = [0] * (n + 1)
for _ in range(m):
    l, r = map(int, input().split())
    imos[l-1] += 1
    imos[r] -= 1
cnt = 1 if imos[0] == m else 0
for i in range(1, n):
    imos[i] += imos[i-1]
    if imos[i] == m:
        cnt += 1
print(cnt)


Measured memory_bytes: 73768
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
using namespace std;
stack<char>s;
char a[100005];
int main()
{
   scanf("%s",a);
   int len=strlen(a);
   int cnt=0;
   for(int i=0;i<len;i++)
   {
       if(s.empty()||a[i]==s.top()){
        s.push(a[i]);
       }
       else
       {
           cnt+=2;
           s.pop();
       }
   }
   printf("%d",cnt);
}


Measured memory_bytes: 384
import sys
import math

def resolve(in_):
    a, b, n = map(int, next(in_).split())
    x = min(b - 1, n)
    return math.floor(a * x / b) - a * math.floor(x / b)


def main():
    answer = resolve(sys.stdin.buffer)
    print(answer)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9232
#include <iostream>
#include <string.h>
#include <cstdio>
using namespace std;
char str1[82];
char str2[82];
void trans(char *orj,char *dest)
{
    int k=0,len=strlen(orj);
    bool ischk=false;
    for(int y=1;y<=26&&!ischk;y++)
    {
        for(int x=0;x<len;x++)
        {
            if(orj[x]>='a'&&orj[x]<='z')k=orj[x]-'a';
            else if(orj[x]>='A'&&orj[x]<='Z')k=orj[x]-'A';
            k=(k+y)%26;
            if(orj[x]>='a'&&orj[x]<='z')dest[x]='a'+k;
            else if(orj[x]>='A'&&orj[x]<='Z')dest[x]='A'+k;
            else dest[x]=orj[x];
        }
        if(strstr(dest,"the")!=NULL||strstr(dest,"this")!=NULL||strstr(dest,"that"))ischk=true;
    }

}
int main()
{
    while(gets(str1))
    {
        memset(str2,'\0',sizeof(str2));
        trans(str1,str2);
        printf("%s\n",str2);
    }
    return 0;
}

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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()
#define BETWEEN(a, x, b) (a) <= (x) && (x) <= (b) 

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<string> vs;

void solve()
{
    string s;
    string ans = "";
    cin >> s;
    REP(i, s.length())
    {
        if(s[i] == '0' || s[i] == '1') ans.push_back(s[i]);
        else if(!ans.empty()) ans.pop_back();
    }
    cout << ans << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();

    return 0;
}

Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class Program
{

    public void Proc()
    {
        long num = long.Parse(Reader.ReadLine());
        long[] ans = GetNum2(num);
        Console.WriteLine(50);
        Console.WriteLine(string.Join(" ", ans));
    }

    private long[] GetNum2(long num) {
        if (num == 0)
        {
            long[] tmp = new long[50];
            tmp = tmp.Select(a => (long)49).ToArray();
            tmp[49] = 0;
            return tmp;

        }
        if(num%50==0) {
            long[] tmp = GetNum2(0).Select(a=>a+num/50).ToArray();
            return tmp;
        } else {
            long[] tmp = GetNum2(num - 1).Select(a=>a-1).OrderBy(a=>a).ToArray();
            tmp[0] += 51;
            return tmp;
        }
    }

    private long[] GetNum(long num) {
        if(num == 0) {
            return new long[] { 1, 0 };
        }

        if (num % 2 == 0)
        {
            long[] tmp = GetNum(0).Select(a => a + num / 2).ToArray();
            return tmp;
        }
        else
        {
            long[] tmp = GetNum(num - 1);
            tmp[0]--;
            tmp[1] += 2;
            return tmp;
        }
                
    }



    public class Reader
	{
		private static StringReader sr;
		public static bool IsDebug = false;
		public static string ReadLine()
		{
			if (IsDebug)
			{
				if (sr == null)
				{
					sr = new StringReader(InputText.Trim());
				}
				return sr.ReadLine();
			}
			else
			{
				return Console.ReadLine();
			}
		}
		private static string InputText = @"

1

";
	}

	public static void Main(string[] args)
	{
#if DEBUG
		Reader.IsDebug = true;
#endif
		Program prg = new Program();
		prg.Proc();
	}
}

Measured memory_bytes: 13524
#include <iostream>
#include <vector>

using namespace std;
typedef long long ll;

int n;
ll k;

int main() {
    cin >> n >> k;
    vector< ll > a(n);
    ll x[40][2];

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

    for (ll i = 39; i >= 0; i--) {
        int cnt;
        cnt = 0;
        for (int j = 0; j < n; j++) {
            if ((a[j] >> i) & 1) {
                cnt++;
            }
        }

        x[i][0] = cnt * (1LL << i);
        x[i][1] = (n - cnt) * (1LL << i);
    }

    ll max = 0;
    for (int i = 39; i >= 0; i--) {
        ll sum = 0;
        int ki = ((k + 1) >> i) & 1;
        if (ki) {
            for (int j = 39; j > i; j--) {
                if (((k + 1) >> j) & 1) {
                    sum += x[j][1];
                } else {
                    sum += x[j][0];
                }
            }
            sum += x[i][0];
            for (int j = i - 1; j >= 0; j--) {
                if (x[j][1] > x[j][0]) {
                    sum += x[j][1];
                } else {
                    sum += x[j][0];
                }
            }
        }
        if (max < sum) {
            max = sum;
        }
    }

    cout << max << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
const int N = 2e5 + 5, mod = 1e9 + 7;

vector<int> adj[N];
int vis[N], c;

void dfs(int node){
    vis[node] = 1;
    c++;
    for(auto i: adj[node]){
        if(!vis[i]){
            dfs(i);
        }
    }
}

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n, m;
    cin >> n >> m;
    for(int i = 0; i < m; i++){
        int u, v;
        cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    int ans = 0;
    for(int i = 1; i <= n; i++){
        if(!vis[i]){
            c = 0;
            dfs(i);
            ans = max(ans, c);
        }
    }
    cout << ans;

    return 0;
}


Measured memory_bytes: 21612
#include<iostream>
#include<cstdio>
using namespace std;
const int N=2000;
const int MOD=1000000007;
int n,k;
long long fac[N+5],inv[N+5];
long long ksm(long long a,long long b)
{
	long long res=1;
	while(b)
	{
		if(b&1) res=res*a%MOD;
		a=a*a%MOD,b>>=1; 
	}
	return res;
}
void init()
{
	fac[0]=1;
	for(int i=1;i<=N;i++)
		fac[i]=fac[i-1]*i%MOD;
	inv[N]=ksm(fac[N],MOD-2);
	for(int i=N;i>=1;i--)
		inv[i-1]=inv[i]*i%MOD;
	return;
}
long long C(int n,int m)
{
	if(n<m) return 0;
	if(n==0||n==m) return 1;
	return fac[n]*inv[m]%MOD*inv[n-m]%MOD; 
}
int main()
{
    scanf("%d%d",&n,&k);
	init();
    for(int i=1;i<=k;i++)
        printf("%lld\n",C(n-k+1,i)*C(k-1,i-1)%MOD);
    return 0;
}

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

using namespace std;

#define f first
#define s second
#define pub push_back
#define pob pop_back

typedef vector<int> vi;
typedef vector<vi> graf;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vii> wgraf;

typedef vector<double> vd;
typedef pair<double,double> dd;
typedef vector<dd> vdd;

typedef uint64_t ui64;

int main(){

	int n;
	cin >> n;

	vector<double> v(n);
	for(auto &x: v)
		cin >> x;

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

	double val = v[0];

	for(int i = 1; i < n; i++){
		val = (val+v[i])/2;
	}

	printf("%.8f\n",val);

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;

constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433;

template <class T> vector<T> make_v(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto make_v(size_t N,T... t){return vector<decltype(make_v(t...))>(N,make_v(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
	int N; cin >> N;
	vector<pair<int,int>> p(N);
	for(int i = 0; i < N; ++i) {
		int A; cin >> A;
		p[i] = {A,i};
	}
	sort(ALL(p));
	for(int i = 0; i < N; ++i) {
		cout << p[i].second + 1 << " "; 
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, A;
  cin >> N >> A;
  
  int rem = N % 500;
  
  if (rem <= A) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n;
  int k;
  scanf("%d%d",&n,&k);
  int h[n];
  int count=0;
  
  for(int i=0;i<n;i++){
    scanf("%d",&h[i]);  
  }
 for (int i=0;i<n;i++){
    if(h[i]>=k){
      count=count+1;
    }
  }
printf("%d\n",count);
}

      
  


Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#define debug(x)  cerr << #x << " = " << x << endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;

const int maxN = 1e5 + 5;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;

ll gcd(ll a, ll b){return !b ? a : gcd(b, a % b);}
ll modP(ll a, ll b) {return (!b ? 1 : (modP(a, b / 2) * modP(a, b / 2) * (b % 2 ? a : 1)) % MOD);}

vector <int> part[2];

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n, k, flag = 1, cnt = 0, sum = 0, mx = 0;
	string s;
	cin >> n >> k;
	cin >> s;
	for (int i = 0; i < n; i++){
		if (flag == s[i] - '0'){
			cnt += 1;
		}
		else{
			part[flag].push_back(cnt);
			cnt = 1;
			flag = !flag;
		}
	}
	part[flag].push_back(cnt);
	cnt = 1;
	flag = !flag;
	if (flag){
		part[1].push_back(0);
	}
	if (part[0].size() <= k) return cout << n << endl, 0;
	for (int i = 0; i < k; i++){
		sum += part[0][i];
		sum += part[1][i];
	}
	sum += part[1][k];
	mx = sum;
	for (int i = k; i < part[0].size(); i++){
		sum -= part[1][i - k];
		sum -= part[0][i - k];
		sum += part[1][i + 1];
		sum += part[0][i];
		mx = max(mx, sum);
	}
	cout << mx << endl;
	return 0;
}



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

int main() {
    int N, P;
    cin >> N;
    if (N % 2 == 0) {
        P = N / 2;
    } else {
        P = N /2 + 1;
    }
    cout << P << endl; 
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
namespace Fact{
	long f[1000000];
	long rf[1000000];
	long pow(long N,long K){
		if(K == 0){
			return 1;
		}
		else if(K % 2 == 0){
			long t = pow(N,K/2);
			return t*t%mod;
		}
		else{
			return N*pow(N,K-1)%mod;
		}
	}
	void Fact(int N){
		for(int i=0;i<N+1;i++){
			if(i == 0){
				f[i] = 1;
			}
			else{
				f[i] = (f[i-1]*i)%mod;
			}
		}
		for(int i=N;i>=0;i--){
			if(i == N){
				rf[i] = pow(f[N],mod-2);
			}
			else{
				rf[i] = rf[i+1]*(i+1)%mod;
			}
		}
	}
	long GetFact(int N){
		return f[N];
	}
	long GetPerm(int N,int R){
		return f[N] * rf[N-R] % mod;
	}
	long GetConv(int N,int R){
		return ((f[N]*rf[R])%mod*rf[N-R])%mod;
	}
	long GetRev(int N){
		if(N == 0){
			return 1;
		}
		else{
			return rf[N] * f[N-1] % mod;
		}
	}
}
//-------------------------------------------------------
int ChildNum[5000];
vector<int> G[5000];
long DP[5000*5001];
long DP2[5000*5001];
void GetChildNum(int v,int f){
	int ans = 1;
	for(int i=0;i<G[v].size();i++){
		int t = G[v][i];
		if(t != f){
			GetChildNum(t,v);
			ans += ChildNum[t];
		}
	}
	ChildNum[v] = ans;
}
int GetCenter(int v,int f,int N){
	for(int i=0;i<G[v].size();i++){
		int t = G[v][i];
		if(t != f){
			if(ChildNum[t] >= N){
				return GetCenter(t,v,N);
			}
		}
	}
	return v;
}
void Calc(){
	int N = rei();
	Fact::Fact(100000);
	for(int i=0;i<N-1;i++){
		int x = rei()-1;
		int y = rei()-1;
		G[x].push_back(y);
		G[y].push_back(x);
	}
	GetChildNum(0,-1);
	int Center = GetCenter(0,-1,(N+1)/2);
	if(ChildNum[Center] * 2 == N){
		cout << Fact::GetFact(N/2) * Fact::GetFact(N/2) % mod << endl;
		return;
	}
	GetChildNum(Center,-1);
	for(int i=0;i<G[Center].size();i++){
		int t = G[Center][i];
		int c = ChildNum[t];
		for(int j=0;j<=c;j++){
			DP[t*5001+j] = Fact::GetConv(c,j) * Fact::GetPerm(c,j) % mod;
		}
	}
	DP2[0] = 1;
	int ch = 0;
	for(int i=0;i<G[Center].size();i++){
		int t = G[Center][i];
		int c = ChildNum[t];
		for(int k=0;k<=ch;k++){
			DP2[i*5001+k] %= mod;
			for(int j=c;j>=0;j--){
				DP2[i*5001+5001+j+k] += DP2[i*5001+k] * DP[t*5001+j] % mod;
			}
		}
		ch += c;
	}
	long ans = 0;
	for(int i=0;i<=N-1;i++){
		if(i % 2 == 0){
			ans += DP2[G[Center].size()*5001+i] % mod * Fact::GetFact(N-i) % mod;
		}
		else{
			ans += mod - DP2[G[Center].size()*5001+i] % mod * Fact::GetFact(N-i) % mod;
		}
	}
	ans %= mod;
	cout << ans << endl;
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

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

#define For(i, j, k) for(int i = j; i <= k; i++)
#define Forr(i, j, k) for(int i = j; i >= k; i--)

using namespace std;

const int N = 100010;

int A[N], n;

int main(){
	scanf("%d", &n);
	For(i, 1, n) scanf("%d", &A[i]);
	sort(A + 1, A + n + 1);
	int ans = false, now = false;
	Forr(r, n, 1){
		int l = r;
		while(l > 1 && A[l - 1] == A[r]) --l;
		//printf("%d %d\n", l, r);
		if(r == n) ans = (r - l) & 1, now = false;
		else{
			int d = (A[r + 1] - A[r]) & 1;
			now ^= d, ans ^= d;
			if(!now && !((r - l) & 1)){
				if(A[r] >= n - r) ans ^= 1;
			}
			if(now && ((r - l) & 1)){
				if(A[r] > n - r) ans ^= 1;
			}
			now = false;
		}
		r = l;
	}
	ans ^= !(A[1] & 1);
	puts(ans ? "First" : "Second");
	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
int main(){
  int A,B,max = 0;
  scanf("%d%d",&A,&B);
  for(int i =0;i<2;i++){
    if(A>B){
      max += A;
      A-=1;
    }else{
      max+=B;
      B-=1;
    }
  }
  printf("%d",max);
}
      
  
    


Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
/************************************************/
#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;
}
long double r;
int main(){
	ios::sync_with_stdio(0);
	cin>>r;
	r*=2;
	r*=3.1415926535897932384;
	cout<<r;
	re 0;
}

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

using namespace std;

const int MAXN = 1e7+5;
int f[MAXN];

int main(){
    int n;

    for(int i=1;i<MAXN;i++){
        for(int j=i;j<MAXN;j+=i){
            f[j]++;
        }
    }

    cin >>n;
    long long sum = 0;
    for(int i=1;i<=n;i++){
        sum += (long long)i * f[i];
    }

    cout << sum;

}


Measured memory_bytes: 42648
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pint = pair<int,int>;


const long long INFLL = 1LL << 60;
const int INFI = 1000000000;
ll SUM(ll n){
    ll ans=0;
    for(ll i=1;i<=n;i++)ans+=i;
    return ans;
}

int main() {
    string s; cin >> s; s = s+'.';
    ll ans=0;
    vector<ll> v;
    char start=s[0];
    ll count=1;
    for(int i=0;i<s.size()-1;i++){
        if(s[i]==s[i+1]) count++;
        else {v.push_back(count); count=1;}
    }
    if(start=='<'){
        for(int i=0;i<v.size()/2;i++){
            ans+=SUM(v[i*2])+SUM(v[i*2+1])-min(v[i*2], v[i*2+1]);
        }
        if(v.size()%2!=0) ans+=SUM(v[v.size()-1]);
    }else{
        ans+=SUM(v[0]);
        if(v.size()%2==0) ans+=SUM(v[v.size()-1]);
        for(int i=0;i<(v.size()-1)/2; i++){
            ans += SUM(v[i*2+1]) + SUM(v[i*2+2]) - min(v[i*2+1],v[i*2+2]);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3348
#include<bits/stdc++.h>
typedef long long ll;
#define INF 100000000
#define MOD 100000007
int dx[4]={1,0,-1,0},dy[4]={0,-1,0,1};
using namespace std;
int main(void){
    int a,b,k;
    cin>>a>>b>>k;
    int cnt=0;
    vector<int>res;
    for(int i=1;i<=min(a,b);i++){
        if(a%i==0 and b%i==0){
            res.push_back(i);
        }
    }
    cout<<res[res.size()-k]<<endl;
   return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		for (; solver.hasNext();) {
			solver.readBody(in.readLine());
		}
		solver.solve();
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		String[] strArr = str.split(" ");
		N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
		x = Integer.parseInt(strArr[1]);
	}

	int x;

	public boolean hasNext() {
		// return cnt < N;
		return cnt < 1;
	}

	public void readBody(String str) {
		// System.out.println(str);
		cnt++;
		String[] strArr = str.split(" ");
		int[] a = new int[N];
		for (int i = 0; i < N; i++)
			a[i] = Integer.parseInt(strArr[i]);
		Arrays.sort(a);
		int ans = 0;
		for (int i : a) {
			// System.out.println(i);
			if (x >= i) {
				ans++;
				x -= i;
			} else {
				break;
			}
		}
		if (ans == N && x > 0)
			ans--;
		System.out.println(ans);
	}

	public void solve() {

	}
}


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

int main(){
    int n;
    while(cin >> n, n){
        n = 1000 - n;
        cout << n/500 + n%500/100 + n%100/50 + n%50/10 + n%10/5 + n%5 << endl;
    }
    return 0;
}


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

    
int main() {
  int D, G;
  cin >> D >> G;
  vector<vector<int>> P(D, vector<int>(5));
  int q=0;
  int ss=10000;
  for (int i=0; i<D; i++) {
    cin >> P.at(i).at(0) >> P.at(i).at(1);
    P.at(i).at(2)=100*(i+1);
    P.at(i).at(3)=P.at(i).at(0)*P.at(i).at(2)+P.at(i).at(1);
  }
  for (int i=0; i<pow(2, D); i++) {
    int ii=i;
    int s=0, n=0;
    for (int j=0; j<D; j++) {
      P.at(j).at(4)=ii % 2;
      ii /=2;
      if (P.at(j).at(4)==1) {
        s+=P.at(j).at(3);
        n+=P.at(j).at(0);
      }
    }
    /*////////////////////////////
    cout << i << ":";
    for (int j=0; j<D; j++) {
      cout << P.at(j).at(4);
    }
    cout << endl;
    ///////////////////////////////*/
    if (s>=G) {
      ss=min(ss, n);
      continue;
    }
    for (int j=0; j<D; j++) {
      if (P.at(j).at(4)==1) continue;
      int d=(G-s+P.at(j).at(2)-1)/P.at(j).at(2);
      if (d>=P.at(j).at(0)) continue;
      ss=min(ss, n+d);
    }
  }
  cout << ss << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <stack>
#include <queue>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
using ll = long long;
using ld = long double;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    ll H, W, i, j, dp[110][110];
    string s[110];

    cin >> H >> W;

    for(i=0; i<H; i++){
        for(j=0; j<W; j++){
            dp[i][j] = INF;
        }
    }

    for(i=0; i<H; i++){
        cin >> s[i];
    }

    if(s[0][0]=='#'){
        dp[0][0] = 1;
    }
    else{
        dp[0][0] = 0;
    }

    for(i=0; i<H; i++){
        for(j=0; j<W; j++){
            if(i<H-1){
                if(s[i][j]=='.' && s[i+1][j]=='#'){
                    chmin(dp[i+1][j], dp[i][j]+1);
                }
                else chmin(dp[i+1][j], dp[i][j]);
            }

            if(j<W-1){
                if(s[i][j]=='.' && s[i][j+1]=='#'){
                    chmin(dp[i][j+1], dp[i][j]+1);
                }
                else chmin(dp[i][j+1], dp[i][j]);
            }
        }
    }

    cout << dp[H-1][W-1] << endl;

    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cmath>

using namespace std;

int main() {
    size_t n;
    cin >> n;
    vector<pair<double, double>> ps{};
    vector<size_t> is{};
    ps.reserve(n);
    is.reserve(n);
    for (size_t i = 0; i < n; ++i) {
        long long x;
        long long y;
        cin >> x >> y;
        ps.emplace_back(double(x), double(y));
        is.emplace_back(i);
    }
    double t = 0.0;
    size_t m = 0;
    do {
        double l = 0.0;
        for (size_t i = 1; i < n; ++i) {
            auto j = is[i - 1];
            auto k = is[i];
            auto& p0 = ps[j];
            auto& p1 = ps[k];
            auto x = p1.first - p0.first;
            auto y = p1.second - p0.second;
            l += hypot(x, y);
        }
        t += l;
        ++m;
    } while (next_permutation(begin(is), end(is)));
    printf("%.12f", t / double(m));
    return 0;
}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

int x[5];

int main()
{
	rep(i,5) cin>>x[i];
	rep(i,5)
	{
		if(x[i]==0)
		{
			cout<<i+1<<endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 3588
#include <iostream>
using namespace std;
int main(){
 
    int x,y,tmp;
    
    for(;;){
        cin>>x>>y;
        if(x==0&&y==0)break;
        if(x>y){
            tmp=x;
            x=y;
            y=tmp;
        }
        cout<<x<<" "<<y<<endl;
    }
  
    return 0;
 
}

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

int main(){
  string s;
  cin >> s;
  if(s.size()%2 != 0){
    cout << "No" << endl;
    return 0;
  }
  for(int i=0; i<s.size(); i++){
    string a;
    a.push_back(s.at(i));
    a.push_back(s.at(++i));
    if(a != "hi"){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 256
import itertools
import math
n=int(input())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
if p== q:
    print(0)
else:
    sample=[]
    for i in range(1,n+1):
        sample.append(i)
    perm=list(itertools.permutations(sample))
    for i in range(math.factorial(n)):
        perm[i]=list(perm[i])
    ans=[]
    for i in range(math.factorial(n)):
        if list(perm[i]) == p or list(perm[i]) == q :
            ans.append(i+1)
            if len(ans) == 2:
                break

    print(abs(ans[1]-ans[0]))


Measured memory_bytes: 51440
use std::io::prelude::*;

fn input<T: std::str::FromStr>() -> T {
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let a: i32 = input();
    let b: i32 = input();
    println!("{}", std::cmp::max(std::cmp::max(a + b, a - b), a * b));
}


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		int i = 1;
		int x;
		while(i <= n){
			x = i;
			if(x % 3 == 0){
				System.out.print(" " + i);
				i++;
				continue;
			}
			do{
				if(x % 10 == 3){
					System.out.print(" " + i);
					break;
					}
			}while((x /= 10) != 0);
			i++;
		}
		System.out.println("");
	}
}

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

vector<long long int>a[400000];
long long int h[400000];

int main() {
    long long int n,m,i,aa,bb,j,ans=0;
    cin>>n>>m;
    for(i=1;i<=n;i++)
    {
        cin>>h[i];
    }
    for(i=1;i<=m;i++)
    {
        cin>>aa>>bb;
        a[aa].push_back(bb);
        a[bb].push_back(aa);
    }
    for(i=1;i<=n;i++)
    {
        if(a[i].size()==0)
        {
            ans++;
            continue;
        }
        bool pp=0;
        for(j=0;j<a[i].size();j++)
        {
            if(h[a[i][j]]>=h[i])
            pp=1;
        }
        if(pp==0)
        ans++;
    }
    cout<<ans;
	return 0;
}

Measured memory_bytes: 17296
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const long long MAXN=100005;

long long dp[MAXN];
long long N,M,T,A[MAXN];
long long que[MAXN],hd,tl;
long long stk[MAXN],tp;

void push_back2(long long i)
{
    while(tp>0&&dp[i]-A[i+1]*3<=dp[stk[tp]]-A[stk[tp]+1]*3)
        tp--;
    stk[++tp]=i;
}
void push_back1(long long i)
{
    while(hd<=tl&&dp[i]-A[i+1]<=dp[que[tl]]-A[que[tl]+1])
        tl--;
    que[++tl]=i;
}

int main()
{
    scanf("%lld%lld%lld",&N,&M,&T);
    for(long long i=1;i<=N;i++)
        scanf("%lld",&A[i]);
    A[N+1]=M;
    memset(dp,0x3F,sizeof dp);
    dp[0]=A[1];
    que[1]=0;
    hd=tl=1;
    for(long long i=1;i<=N;i++)
    {
        while(hd<=tl&&(A[i]-A[que[hd]+1])*2>T)
        {
            push_back2(que[hd]);
            hd++;
        }
        if(hd<=tl)
            dp[i]=dp[que[hd]]+T+A[i+1]-A[que[hd]+1];
        if(tp)
            dp[i]=min(dp[i],dp[stk[1]]+A[i]*2+A[i+1]-A[stk[1]+1]*3);
        push_back1(i);
    }
    printf("%lld\n",dp[N]);

    return 0;
}


Measured memory_bytes: 2560
N, Y = map(int,input().split())
for a in range(N+1):
    for b in range(N-a+1):
        if Y == 10000*a + 5000*b + 1000*(N-(a+b)):
            print(a,b,N-(a+b))
            exit(0)
print("-1 -1 -1")


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

int main() {
  int N, K;
  string S;
  cin >> N >> K >> S;
  
  if (S.at(K-1) == 'A') S.at(K-1) = 'a';
  else if (S.at(K-1) == 'B') S.at(K-1) = 'b';
  else if (S.at(K-1) == 'C') S.at(K-1) = 'c';
  
  cout << S << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
int main() {
  int H, A;
  cin >> H >> A;
  cout << (H+A-1)/A << endl;
  return 0;
}


Measured memory_bytes: 764
#include <stdio.h>
int main()
{
	int x,s,a,b,c,d,e,f,g,h,i,j;
	scanf("%d",&x);
	s=0;
	a=x/1000000000;
	b=x/100000000%10;
	c=x/10000000%10;
	d=x/1000000%10;
	e=x/100000%10;
	f=x/10000%10;
	g=x/1000%10;
	h=x/100%10;
	i=x/10%10;
	j=x%10;
	s=a+b+c+d+e+f+g+h+i+j;
	if(x%s==0)
		printf("Yes");
	else
		printf("No");
    return 0;
}

Measured memory_bytes: 128