akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
inline int read () {
	int num = 0;
	char c = ' ';
	bool flag = true;
	for (;c > '9' || c < '0';c = getchar())
		if (c == '-')
			flag = false;
	for (;c >= '0' && c <= '9';num = (num << 1) + (num << 3) + c - 48, c = getchar());
	return flag ? num : -num;
}
const int maxn = 100200;
int n;
char s[maxn];
void init () {
	scanf ("%s",s + 1);
	n = strlen (s + 1);
}
void work () {
	int bj = 1, cnt = 1;
	for (int i = 1;i < n;i ++) {
		cnt ++;
		if (s[i] == '1') {
			printf ("%d %d\n",bj,cnt);
			bj = cnt;
		}
		else {
			printf ("%d %d\n",bj,cnt);
		}
	}
}
bool check () {
	if (s[1] != '1' || s[n] != '0') return false;
	int l = 1, r = n - 1;
	while (l < r)
		if (s[l ++] != s[r --]) return false;
	return true;
}
int main () {
	init ();
	if (check ()) 
		work ();
	else printf ("-1\n");
	return 0;
}

Measured memory_bytes: 1536
n=int(input())
l=list(map(int,input().split()))
t=0
for i in range(n):
    if l[i]%2==0:
        if l[i]%3>0 and l[i]%5>0:
            print("DENIED")
            break
        else:
            t+=1
    else:
        t+=1
if t==n:
    print("APPROVED")

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
int main(){
  int X,Y,K,S,counter=0;
  cin>>K>>S;
  for(X=0;X<=K;X++){
    for(Y=0;Y<=K;Y++){
      if(S-X-Y>=0&&S-X-Y<=K){
        counter++;
      }
    }
  }
  cout<<counter<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <iterator>
#include <numeric>
#include <cstdint>
#include <cmath>
#include <bitset>
#include <string>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>

#define N_TIMES(i, n)     for ( uint64_t i = 0;     i <  n; ++i )
#define N_TIMES_REV(i, n) for (  int64_t i = n - 1; i >= 0; --i )

using namespace std;

struct QueueItem
{
  uint64_t node, prev, len;

  QueueItem(uint64_t node, uint64_t prev, uint64_t len)
    : node(node), prev(prev), len(len) {}
};

int main()
{
  uint64_t N, M;
  cin >> N >> M;

  vector<set<uint64_t>> edges(N);
  N_TIMES(m, M) {
    uint64_t A, B;
    cin >> A >> B;

    edges[A - 1].emplace(B - 1);
    edges[B - 1].emplace(A - 1);
  }

  vector<uint64_t> post(N, -1);
  vector<uint64_t> prev(N, -1);
  vector<uint64_t> len(N, -1);

  queue<QueueItem> q;
  q.emplace(0, -1, 0);
  while (!q.empty()) {
    QueueItem item = q.front(); q.pop();

    if (item.len >= len[item.node]) {
      continue;
    }

    len[item.node] = item.len;
    prev[item.node] = item.prev;
    post[item.node] = item.prev;

    for (uint64_t dst : edges[item.node]) {
      q.emplace(dst, item.node, item.len + 1);
    }
  }

  cout << "Yes" << endl;
  N_TIMES(n, N - 1) {
    cout << (post[n + 1] + 1) << endl;
  }

  return 0;
}

Measured memory_bytes: 36156
n,k=map(int,input().split())
ans=0
if k==0:
    print(n**2)
    import sys
    sys.exit()
    
for b in range(k,n+1):
    r=n//b
    ans+=(b-k)*r
    ans+=max(0,n%b-k+1)

print(ans)

Measured memory_bytes: 3060
import heapq

n,m = map(int,input().split())

a = list(map(int,input().split()))

a = [-1*i for i in a]

heapq.heapify(a)

count = 0

while count < m:
    item = heapq.heappop(a)
    item= abs(item)
    discount_item = item//2
    heapq.heappush(a,-1*discount_item)
    count += 1

result_prime = [-1*i for i in a]

print(sum(result_prime))


Measured memory_bytes: 85628
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d,s;
int main(){
	cin>>a>>b>>c;
	for(int i=1;i<=a;i++){
	cin>>d;
	if(d<b||d>=c)s++;
	}
	cout<<s<<endl;
	return 0;
}


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

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getChar(char ch){
	if(ch == 'A') return 1;
	else if(ch == 'C') return 2;
	else if(ch == 'G') return 3;
	else if(ch == 'T') return 4;
	else return 0;
}

long long getKey(char str[]){
	long long sum = 0, p = 1, i;
	for(i = 0;i < strlen(str); i++){
		sum += p*getChar(str[i]);
		p *= 5;
	}
	return sum;
}

int h1(int key){ return key % M;}
int h2(int key){ return 1 + (key % (M-1));}

int find(char str[]){
	long long key,i,h;
	key = getKey(str);
	for(i = 0;; i++){
		h = (h1(key)+i*h2(key))%M;
		if(strcmp(H[h],str) == 0) return 1;
		else if(strlen(H[h]) == 0) return 0;
	}
	return 0;
}

int insert(char str[]){
	long long key,i,h;
	key = getKey(str);
	for(i = 0;; i++){
		h = (h1(key)+i*h2(key))%M;
		if(strcmp(H[h],str) == 0) return 1;
		else if(strlen(H[h]) == 0){
			strcpy(H[h],str);
			return 0;
		}
	}
	return 0;
}

int main(){
	int i,n,h;
	char str[L],com[9];
	for(i = 0;i < M; i++) H[i][0] = '\0';
	scanf("%d",&n);
	for(i = 0;i < n; i++){
		scanf("%s %s", com,str);
		if(com[0] == 'i'){
			insert(str);
		}else{
			if(find(str)){
				printf("yes\n");
			}else{
				printf("no\n");
			}
		}
	}
	return 0;
}

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

int main()
{
    int n;
    string ans;

    cin >> n;
    ans = "No";
    rep(i,10)
        rep(j, 10) {
            if (i * j == n) {
                ans = "Yes";
                break;
            }

        }

    cout << ans << endl;
}


Measured memory_bytes: 3608
n, q = list(map(int, input().rstrip().split()))
ps = []
for i in range(n):
    name, time = input().rstrip().split()
    ps.append({'name': name, 'time': int(time)})

current_time = 0    
while ps:
    p = ps.pop(0)
    name = p['name']
    time = p['time']
    if time > q:
        ps.append({'name': name, 'time': time - q})
        current_time += q
    else:
        current_time += time
        print('{0} {1}'.format(name, current_time))


Measured memory_bytes: 20896
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdbool.h>
#include<math.h>
#include<limits.h>
int main(){
    int X;
    scanf("%d",&X);
    int ans = 0,deg=0;
    do{
        ans++;
        deg+=X;
    }while(deg%360);
    printf("%d",ans);
}


Measured memory_bytes: 1676
<?php

class In {

	private $buf = [];
	private $count = 0;
	private $pointer = 0;

	public function nextLine() {
		$ret = '';
		if($this->hasNext()){
			while($this->hasNext()){
				$ret .= $this->next();
			}
		}else{
			$ret = trim(fgets(STDIN));
		}

		return $ret;
	}

	public function next() {
		if(!$this->hasNext()) {
			$str = trim(fgets(STDIN));
			$this->buf = explode(' ',$str);
			$this->count = count($this->buf);
			$this->pointer = 0;
		}

		return $this->buf[$this->pointer++];
	}

	public function hasNext() {
		return $this->pointer < $this->count;
	}

	public function nextInt() {
		return (int)$this->next();
	}

	public function nextDouble() {
		return (double)$this->next();
	}
}

class Out {
	public function println($str = '') {
		echo $str . PHP_EOL;
	}
}

$in = new In();
$out = new Out();

$len = ord('z') - ord('a')+1;
$appear = [];
for ($i = 0;$i < $len;$i++) {
	$appear[] = false;
}


$S = $in->next();
$S = str_split($S);
foreach ($S as $s) {
	$appear[ord($s) - ord('a')] = true;
}

for ($i = 0;$i < $len;$i++) {
	if ($appear[$i] === false) {
		$out->println(chr(ord('a')+$i));
		return;
	}
}

$out->println('None');

?>


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

int main(){
int a[51];
int b;
a[0]=-100;
while(scanf("%d",&b),b){
	int s=0;
	int MIN=0;
	for(int c=0;c<b;c++)scanf("%d",&a[c+1]);
	a[b+1]=-100;
	for(int k=0;k<b;k++){
		if(a[k]+1!=a[k+1]&&a[k+1]+1!=a[k+2]){if(s)printf(" ");printf("%d",a[k+1]);s++;}
	    else if(a[k]+1==a[k+1]&&a[k+1]+1!=a[k+2]){if(s)printf(" ");printf("%d-%d",MIN,a[k+1]);s++;}
	    else if(a[k]+1!=a[k+1]&&a[k+1]+1==a[k+2])MIN=a[k+1];
	}
	puts("");
}
}

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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

ll N,C;
ll A[444];
ll B[444];
ll g[444][444];
ll po[444][444];
ll dp[444][444];

void init() {
	REP(i,444){
		ll now = 1;
		REP(j,444){
			po[i][j] = now;
			now = (now * i) % MOD;
		}
	}
}
			

int main(){

	init();
	
	cin >> N >> C;
	REP(i,N)cin >> A[i];
	REP(i,N)cin >> B[i];
	
	REP(i,N){
		REP(j,444){
			ll now = 0;
			for(int k = A[i];k <= B[i];k++){
				now = (now + po[k][j]) % MOD;
			}
			g[i][j] = now;
		}
	}
		
	dp[0][0] = 1;
	REP(i,N){
		REP(j,C+1){
			REP(k,C+1){
				if(j + k <= C){
					dp[i+1][j+k] = (dp[i+1][j+k] + dp[i][j] % MOD * g[i][k] % MOD) % MOD;
				}
				else {
					break;
				}
			}
		}
	}
		
	cout << dp[N][C] << endl;
	
	return 0;
}


Measured memory_bytes: 4608
import sys
import os
import math
import bisect
import collections
import itertools
import heapq
import re
import queue
# import fractions

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    S = iss()
    N = len(S)-1

    ret = 0
    for n in range(1 << N):
        fml = ''
        for m in range(len(S)):
            fml += S[m]
            if n >> m & 1:
                 fml += '+'
        ret += eval(fml)
    print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 4080
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=1e9+7;
const ll inf=1e16;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define all(x) x.begin(),x.end()
#define sum(x) accumulate(all(x),0)
#define gll greater<ll>()


void solve(){
 ll n,m,k;
  cin >> n >> m >> k;
 vll a(n),b(m);
 vll x(n+1,0),y(m+1,0); 
  rep(i,0,n) {
    cin >> a[i];
    x[i+1]=x[i]+a[i]; 
  }
  rep(i,0,m) {
    cin >> b[i];
    y[i+1]=y[i]+b[i]; 
  }
  
  ll ans=0;
  rep(i,0,n+1){
    if(x[i]>k) break;
    ll c=upper_bound(all(y),k-x[i])-y.begin();
   chmax(ans,i+(c-1)); 
  }
 
  cout << ans << endl;
}

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

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

using namespace std;

const int N = 100000 + 77;
int n , a[N] , b[N] , c[N] , dp[N][3];
int main(){
   ios::sync_with_stdio(0);cin.tie(0);
   cin >> n;
   for(int i = 1;i <= n;++ i){
      cin >> a[i] >> b[i] >> c[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(max(dp[n][0] , dp[n][1]) , dp[n][2]);
   return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? 1e9:1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
signed main(){
    int n,m; cin >> n >> m;
    vector<int>v(n);
    erep(e,v) cin >> e;
    vector<int>dp(n);
    rep(i,n){
        dp[i] = v[i] + (i?dp[i-1]:0);
    }
    int ans = 0;
    map<int,int>mp;
    rep(i,n)mp[dp[i]%m]++;
    rep(i,n){
        if(i == 0){
            ans += mp[0];
            mp[dp[i]%m]--;
        } else {
            ans += mp[(dp[i-1]) % m];
            mp[dp[i] % m]--;
        }
    }
    cout << ans << endl;
}




Measured memory_bytes: 5760
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>

using ll = long long;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, x) for(int i=1;i<=(int)(x);i++)
#define rrep(i, x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i, x) for(int i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007
#define put2darr(arr, row, col) rep(i, row) { rep(j, col) { printf("%18d", arr[i][j]); } cout << endl; }

using namespace std;

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

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

/* 1..10
 * rep:   0 1 2 3 4 5 6 7 8 9
 * reps:  1 2 3 4 5 6 7 8 9 10
 * rrep:  9 8 7 6 5 4 3 2 1 0
 * rreps: 10 9 8 7 6 5 4 3 2 1
 */


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



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
typedef long long int ll;
using namespace std;
int main()
{
	int n,m;
	cin >> n >> m;
	int l=0;
	int r=n+1;
	int a,b;
	for(int i=0; i<m; i++){
		cin >> a >> b;
		if(a>l){
			l=a;
		}
		if(b<r){
			r=b;
		}
	}
//	cout << l << " " << r << endl;
	if(r-l<0){
		r=l-1;
	}
	cout<< r-l+1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//cervello|Phoenix
using namespace std;
#define ll long long int
#define eb emplace_back
#define mk make_pair
#define all(x) x.begin(),x.end()
#define mod 1000000007

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n; cin>>n;
  ll mx_x = INT_MIN, mx_y = INT_MIN, mn_x = INT_MAX , mn_y = INT_MAX;
  for(int i=0; i<n; i++){
    ll x, y; cin>>x>>y;
    mx_x = max(mx_x, (ll)x+y);
    mn_x = min(mn_x, (ll)x+y);
    mx_y = max(mx_y, (ll)x-y);
    mn_y = min(mn_y, (ll)x-y);
  }
  ll ans = max(mx_x-mn_x, mx_y-mn_y);
  cout<<ans<<"\n";
  return 0;
}

Measured memory_bytes: 3576
n,m = map(int, input().split())

k = []
s = []
p = []

for i in range(m):
	int_arr = list(map(int , input().split()))
	k.append(int_arr[0])
	s.append(list(map(lambda x: x-1, int_arr[1:])))

p = list(map(int , input().split()))

on_pattern_cnt = 0

for s_pattern_int in range(2**n):
	s_pattern_binstr = str(bin(s_pattern_int)) # 2進数文字列化
	s_pattern_binstr = s_pattern_binstr[2:] # 0bの削除
	s_pattern_binstr = s_pattern_binstr.zfill(n)				# 上位を0で埋める
	s_pattern_binstr = s_pattern_binstr[::-1] # 反転

	s_pattern = []
	for c in s_pattern_binstr:
		s_pattern.append(int(c))

	flag = True
	for i in range(m): # 電球に関するループ
		on_cnt = 0
		for j in range(k[i]): # スイッチに関するループ
			if s_pattern[s[i][j]] == 1:
				on_cnt += 1

		if p[i] != on_cnt % 2:
			flag = False
			break

	if flag:
		on_pattern_cnt += 1


print(on_pattern_cnt)

Measured memory_bytes: 3188
//#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <bitset>
#include <string>
#include <set>
#include <stack>
#include <sstream>
#include <list>
//#include <array>
#include <vector>
#include <queue>
#include <map>
#include <memory>
#include <iterator>
#include <climits>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
#define FAST_IO ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef unsigned int UINT;
typedef unsigned long long ull;
typedef pair<int, int> pdi;
typedef pair<ll, int> pli;

int const maxn = 4000 + 10;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3f;
inline int lc(int x)  {return x << 1;}
inline int rc(int x)  {return x << 1 | 1;}


char s[maxn];
ll pre[5][maxn];
int vis[5][maxn];
int n;
int main(void) {
    FAST_IO;
    
    cin >> n >> s + 1;
    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        if (s[i] == 'R') {
            vis[0][i] = 1;
            pre[0][i] = pre[0][i - 1] + 1;
        } else {
            pre[0][i] = pre[0][i - 1];
        }
        if (s[i] == 'G') {
            vis[1][i] = 1;
            pre[1][i] = pre[1][i - 1] + 1;
        } else {
            pre[1][i] = pre[1][i - 1];
        }
        if (s[i] == 'B') {
            vis[2][i] = 1;
            pre[2][i] = pre[2][i - 1] + 1;
        } else {
            pre[2][i] = pre[2][i - 1];
        }
    }
    for (int i = 1; i <= n; i++) {
        if (s[i] == 'R') {
            ans += pre[1][i - 1] * (pre[2][n] - pre[2][i]);
            ans += pre[2][i - 1] * (pre[1][n] - pre[1][i]);
            for (int j = i - 1, k = i + 1; j > 0 && k <= n; j--, k++) {
                if (vis[1][j] && vis[2][k] || vis[2][j] && vis[1][k]) {
                    ans--;
                }
            }
        }
        if (s[i] == 'G') {
            ans += pre[0][i - 1] * (pre[2][n] - pre[2][i]);
            ans += pre[2][i - 1] * (pre[0][n] - pre[0][i]);
            for (int j = i - 1, k = i + 1; j > 0 && k <= n; j--, k++) {
                if (vis[0][j] && vis[2][k] || vis[2][j] && vis[0][k]) {
                    ans--;
                }
            }
        }
        if (s[i] == 'B') {
            ans += pre[0][i - 1] * (pre[1][n] - pre[1][i]);
            ans += pre[1][i - 1] * (pre[0][n] - pre[0][i]);
            for (int j = i - 1, k = i + 1; j > 0 && k <= n; j--, k++) {
                if (vis[0][j] && vis[1][k] || vis[1][j] && vis[0][k]) {
                    ans--;
                }
            }
        }
    }
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 3760
H,W=map(int,raw_input().split())
s=[raw_input() for r in xrange(H)]
# s[h][w]
dx = [1,1,0,-1,-1,-1,0,1]
dy = [0,1,1,1,0,-1,-1,-1]
for r in xrange(H):
  buf = []
  for c in xrange(W):
    if s[r][c] == '#':
      buf.append('#')
    else:
      cnt = 0
      for i in xrange(8):
        ri = r + dx[i]
        ci = c + dy[i]
        if (0 <= ri < H) and (0 <= ci < W):
          if s[ri][ci] == '#':
            cnt += 1
      buf.append(str(cnt))
  print ''.join(buf)


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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)


void aryan_p() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	return;
}


int32_t main() {

	int n, k ;
	cin >> n >> k;

	string s;
	cin >> s;
	int block = 0;
	char x = '0';
	int ans = 0 ;
	for (int i = 0 ; i < n ; i++) {
		if (s[i] != x) {
			x = s[i];
			block++;
		}

		if (s[i] == 'L' and i > 0 and s[i - 1] == 'L') {
			ans++;
		}
		if (s[i] == 'R' and i < n - 1 and s[i + 1] == 'R') {
			ans++;
		}
	}
	int half = (block - 1) / 2;
	if (half >= k) {
		ans += 2 * k;
	}
	else {
		ans = n - 1;
	}
	cout << ans;

	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
    int D;
    cin >> D;   // D = 365
    ll c[26];
    for(int i=0;i<26;i++)
        cin >> c[i];
    ll s[D][26];
    for(int i=0;i<D;i++){
        for(int j=0;j<26;j++){
            cin >> s[i][j];
        }
    }

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

    int last[26] = {};
    
    // D日分
    ll v = 0;
    for(int i=1;i<=D;i++){
        // 満足度の増加分
        v += s[i-1][t[i-1]-1];
        last[t[i-1]-1] = i;
        // 満足度の低下分（コンテスト26種分）
        for(int j=0;j<26;j++)
            v -= c[j]*(i - last[j]);
        // i日目終了時点での満足度
        cout << v << endl;
    }

}

Measured memory_bytes: 3696
#include <iostream>
#include <iomanip>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <limits>
#include <iterator>
#include <cmath>
#include <numeric>
#include <stack>
#include <queue>
#include <cassert>
#include <forward_list>
#include <chrono>
#include <deque>
#include <list>
#include <random>
#include <cstdio>
#include <sstream>

using namespace std;

int main()
{
	int a, b, t;
	cin >> a >> b >> t;

	cout << (t / a) * b << endl;;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int
main(int argc, char *argv[])
{
  int d, n;
  scanf("%d %d", &d, &n);

  int ans = 1;
  if(d != 0){
    for(int i = 0; i < d; i++) ans *= 100;
  }

  if(n == 100) n = 101;

  ans *= n;

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

  return 0;
}

Measured memory_bytes: 128
n = int(input())
s = '753'

stack = ['']
cnt = 0
while stack:
    t = stack.pop()
    for c in s:
        u = t + c
        if int(u) <= n:
            if '7' in u and '5' in u and '3' in u:
                # print(u)
                cnt += 1
            stack.append(u)
print(cnt)


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

int main() {
  int n;
  cin >> n;
  vector<ll> a(n), b(n);
  ll ans = 0;
  vector<ll> d(n);
  rep(i, n) {
    cin >> a[i] >> b[i];
    d[i] = a[i] + b[i];
    ans += a[i];
  }
  
  sort(d.rbegin(), d.rend());
  for(int i = 1; i < n; i += 2) {
    ans -= d[i];
  }
  cout << ans << endl;

}

Measured memory_bytes: 2560
#define _USE_MATH_DEFINES

#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <utility>
#include <climits>
#include <vector>
#include <map>
#include <queue>
#include <set>
using namespace std;

#define ll long long
const int MOD = 1000000007;//10^9+7
const string SPACE = " ";

ll powsur(ll a, ll b, ll p) {

	if (b == 0) {

		return 1;

	}
	else if (b % 2 == 0) {

		ll d = powsur(a, b / 2, p);
		return ((d%p)*(d%p)) % p;

	}
	else {

		return ((a%p)*powsur(a, b - 1, p) % p) % p;

	}

}
//pは素数,aのb乗をpで割った余り

ll CMOD(ll n, ll r, ll p) {

	ll a = 1, b = 1, c = 1, re;
	for (int i = 1; i <= n; i++) {

		a *= i;
		a = a%p;

	}
	for (int i = 1; i <= r; i++) {

		b *= i;
		b = b%p;

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

		c *= i;
		c = c%p;

	}
	b = powsur(b, p - 2, p);
	c = powsur(c, p - 2, p);
	re = ((a%p)*(b%p)) % p;
	re = ((re%p)*c%p) % p;

	return re;

}
//pは素数,(nCr)%p

ll gcd(ll a, ll b) {

	if (a > b) {

		ll tmp = a;
		a = b;
		b = tmp;

	}
	ll r;
	r = b%a;
	if (r == 0)return a;
	else return gcd(r, a);

}
//最大公約数

ll lcm(ll a, ll b) {

	return (a / gcd(a, b))*b;

}
//最小公倍数

ll MAX(ll a, ll b) {

	if (a > b)return a;
	else return b;

}
//MAX

int main() {

	int N, a[5][105], ans = 0;
	cin >> N;
	for (int i = 1; i <= 2; i++) {
		for (int j = 1; j <= N; j++) {

			cin >> a[i][j];

		}
	}

	for (int i = 1; i <= N; i++) {

		int tmp = 0;
		for (int j = 1; j < i; j++)tmp += a[1][j];
		tmp += a[1][i] + a[2][i];
		for (int j = i + 1; j <= N; j++)tmp += a[2][j];
		ans = max(ans, tmp);

	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int a,b,c;
  scanf("%d%d%d",&a,&b,&c);
  
  if(a+b+c<=21){
    printf("win\n");
  }
    
  else{
    printf("bust\n");
  }
    
  return 0;
}
    

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <stdio.h>
#include <math.h>
typedef long long ll;
using namespace std;

int main() {
	string s;
	cin>>s;
	char t;
	ll n=s.length(),a[26]={0};
	for(int i=0;i<n;i++){
		a[s[i]-'a']++;
	}
	for(int i=0;i<26;i++){
		if(a[i]==0){
			t='a'+i;
			cout << t<<endl;
			return 0;
		}
	}
	cout << "None"<<endl;
	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define loop(i,a,b) for(ll i=a; i<b; i++)
#define revloop(i,a,b) for(ll i=a; i>=b; i--)
#define pb push_back
#define vl vector<ll>
#define vvl vector<vl>
#define pl pair<ll,ll>
#define vpl vector<pl>
#define all(c) (c).begin(), (c).end()
#define sz(a) ((a).size())
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i!=(c).end(); i++))
#define mp make_pair
#define ss second
#define ff first
#define ld long double
const ll INF = 1e13;
const ll N = 301;
const ll mod= 1000000007;
bool prime(ll x)
{
	if(x<2) return false;
	for(ll i=2; i*i<=x; i++) if(x%i==0) return false;
	return true;
}
vl fac(N);
void fact()
{
	fac[0]=1;
	loop(i,1,N) fac[i]=(fac[i-1]*i)%mod;
}
 ld dp[N][N][N];
void solve()
{
 
  ll n;
  cin>>n;
  ll c1=0, c2=0, c3=0,x;
  loop(i,0,n)
  {
  	cin>>x;
  	if(x==1) c1++;
  	if(x==2) c2++;
  	if(x==3) c3++;
  }
  loop(i,0,n+1)
   loop(j,0,n+1)
    loop(k,0,n+1)
    {
    	ll sum = i+j+k;
    	if(sum==0)
    	{
    		dp[i][j][k]=0; continue;
		}
		dp[i][j][k]+=n;
		if(i) dp[i][j][k]+=dp[i-1][j+1][k]*i;
		if(j) dp[i][j][k]+=dp[i][j-1][k+1]*j;
		if(k) dp[i][j][k]+=dp[i][j][k-1]*k;
		dp[i][j][k]/=sum;
	}
	cout<<fixed<<setprecision(13)<<dp[c3][c2][c1];
}

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t=1;
    //cin>>t;
    while(t--) solve();
 return 0;
}

Measured memory_bytes: 426368
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

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

    vector<int> d;
    int temp;
    for (int i = 0; i < n; ++i) {
        cin >> temp;
        d.push_back(temp);
    }

    int count = 0;
    int x, y;

    for (int i = 0; i < n - 1; ++i) {
        x = d[i];

        for (int j = i + 1; j < n; ++j) {
            y = d[j];

            count += x * y;
        }
    }

    cout << count << endl;
    return 0;
}


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

#ifdef DEBUG
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(...)
#endif

#ifdef __WIN32
#define LLFORMAT "I64"
#define Rand() ((rand() << 15) + rand())
#else
#define LLFORMAT "ll"
#define Rand() (rand())
#endif

using namespace std;

const int maxn = 21, maxm = (1 << 20) | 10;

int n, m;
char s[maxn][maxm];
int dp[maxn][maxm], pd[maxn][maxm];

void transfer(int n, int S) {
	for (int i = 0; i <= n; ++i) {
		memcpy(pd[i], dp[i], sizeof(dp[i][0]) * S);
		memset(dp[i], 0, sizeof(dp[i][0]) * S);
	}
	int s1 = 0, s2 = S - 1;
	for (int i = n, s = S >> 1; i; --i, s >>= 1) {
		s2 ^= s;
		for (int j = 0, t; j < S; ++j) {
			if(t = pd[i][j]) {
				pd[i - 1][j] += t;
				if(i == n || ((j >> i) & 1) != ((j >> i - 1) & 1)) {
					dp[i - 1][((j & s1) >> 1) | (j & s2)] += t;
				}
			}
		}
		s1 ^= s;
	}
	return;
}

int main(int argc, char *argv[]) {
	scanf("%d%d", &n, &m);
	for (int i = 0; i <= n; ++i) {
		scanf("%s", s[i]);
	}
	for (int i = n; i; --i) {
		debug("%d:\n", i);
		int S = 1 << i;
		for (int j = 0; j < S; ++j) {
			if(s[i][j] == '1') {
				++dp[i][j];
			}
			int cnt = 0;
			for (int k = 0; k <= i; ++k) {
				debug("\tdp[%d][%d] = %d", k, j, dp[k][j]);
				cnt += dp[k][j];
			}
			debug("\n");
			if(cnt >= m) {
				for (int k = i - 1; ~k; --k) {
					printf("%d", (j >> k) & 1);
				}
				putchar('\n');
				return 0;
			}
		}
		if(i > 1) {
			transfer(i, S);
		}
	}
	puts("");
	return 0;
}



Measured memory_bytes: 193792
n,m = map(int,input().split())
matrix = [[0 for i in range(m)] for j in range(n)]
b = [0 for i in range(m)]
c = [0 for i in range(n)]
for i in range(0,n):
    matrix[i] = list(map(int,input().split()))
for i in range(0,m):
    b[i] = int(input())
for i in range(0,n):
    for j in range(0,m):
        c[i] += matrix[i][j]*b[j]
    print(c[i])
    



Measured memory_bytes: 5980
n = int(input())
ans = 0

def ternary(t):
  t = list(map(int, list(t)))
  t = list(reversed(t))
  for i in range(len(t)):
    t[i] = t[i] + 1
    d = t[i] // 3
    t[i] = t[i] % 3
    
    if d <= 0:
      break
    else:
      if i == len(t)-1:
        t.append(0)
  return ''.join(map(str, list(reversed(t))))

def scg(t):
  t = t.replace('3', '0')
  t = t.replace('5', '1')
  t = t.replace('7', '2')
  
  t = ternary(t)
  
  t = t.replace('0', '3')
  t = t.replace('1', '5')
  t = t.replace('2', '7')
  
  return t

value = '357'
while n >= int(value):
  if '3' in value and '5' in value and '7' in value:
    ans += 1
  value = scg(value)

print(ans)

Measured memory_bytes: 3064
k = int(input())
s = "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"
l =s.split(",") 
print(l[k-1])

Measured memory_bytes: 38384
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,x,n) for(int i=x;i<n;i++)
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
//#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;

char M[10][10];

int main(){
  int h,w;
  cin>>h>>w;
  rep(i,h)rep(j,w)cin>>M[i][j];

  int sum=0;
  rep(i,h)rep(j,w){
    if(M[i][j]=='#'){
      sum++;
      M[i][j]='.';
    }
  }
  cout<<(sum==h+w-1?"Possible":"Impossible")<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define pii pair <int,int>
#define ull unsigned long long
#define mp make_pair
#define s second
#define f first                                          
#define _ ios_base::sync_with_stdio(false);cin.tie(0);

using namespace std;

const int maxn = (int)(1e5)+20;
const int mod = (int)(1e9)+7;


int n, a,b,c,d;
ll ans;

int main() {
	_
	cin >> a >> b >> c >> d;
	cin >> n;
	int cur = min(min(a*8, b*4),min(c*2, d));
	ans += n/2*1ll*cur;
	if (n&1) {
	 	cur = min(min(c,a*4), b*2);
	 	ans += cur;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
    #include <algorithm>
    #include <string>
    #include <cstdio>
    #include <cmath>
    #include <cstring>
    #include <stack>
    #include <map>
    using namespace std;
    int main()
    {
        long long n,k;
        cin>>n>>k;
        long long sum[n+3];
        sum[0]=0;
        for(int i=1;i<=n;i++)
        {
            int a;
            cin>>a;
            sum[i]=sum[i-1]+a;
        }
        for(int i=1;i<=n;i++)
             sum[i]=(sum[i]-i%k+k)%k;
        map<long long,long long> q;
        long long res=0;
        for(long long i=0;i<=min(n,k-1);i++)
        {
            res+=q[sum[i]];
            q[sum[i]]++;
        }
        for(long long i=min(n,k-1)+1;i<=n;i++)
        {
            q[sum[i-k]]--;
            res+=q[sum[i]];
            q[sum[i]]++;
        }
        cout<<res;
    }


Measured memory_bytes: 14336
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

const int N = 100001;

int n, A, B, C, fact[2 * N], mod = 1e9 + 7;

int powlog(int a, int b){
    if(b == 0) return 1;
    int ret = powlog(a, b / 2);
    if(b % 2) return 1LL * ret * ret % mod * a % mod;
    return 1LL * ret * ret % mod;
}
int nCr(int n, int r){
    assert(r <= n);
    return 1LL * fact[n] * powlog(1LL * fact[r] * fact[n - r] % mod, mod - 2) % mod;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    fact[0] = 1;
    for(int i = 1 ; i < 2 * N ; i++){
        fact[i] = 1LL * i * fact[i - 1] % mod;
    }
    cin >> n >> A >> B >> C;
    int sum = A + B;
    A = 1LL * A * powlog(sum, mod - 2) % mod;
    B = 1LL * B * powlog(sum, mod - 2) % mod;
    int ans = 0;
    for(int M = n ; M < 2 * n ; M++){
        int cur = 1LL * M * nCr(M - 1, n - 1) % mod * (1LL * powlog(A, n) * powlog(B, M - n) % mod
                                                     + 1LL * powlog(A, M - n) * powlog(B, n) % mod) % mod;
        ans = (ans + cur) % mod;
    }
    ans = 1LL * ans * 100 % mod * powlog(100 - C, mod - 2) % mod;
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <deque>
#include <algorithm>

using namespace std;

int main()
{
    deque<char> str;
    int revved = 0;
    char s[100005], c;
    int q;
    int t, f;
    cin >> s;
    for (int i = 0; s[i] != '\0'; i++)
    {
        str.push_back(s[i]);
    }
    cin >> q;
    for (int i = 0; i < q; i++)
    {
        cin >> t;
        if (t == 1)
            revved = !revved;
        else
        {
            cin >> f >> c;
            if (revved)
            {
                if (f == 1)
                    str.push_back(c);
                else
                    str.push_front(c);
            }
            else
            {
                if (f == 1)
                    str.push_front(c);
                else
                    str.push_back(c);
            }
        }
    }
    if (revved)
    {
        for (auto i = str.rbegin(); i != str.rend(); i++)
        {
            cout << *i;
        }
    }
    else
    {
        for (auto i = str.begin(); i != str.end(); i++)
        {
            cout << *i;
        }
    }

    return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int N, s, sum = 0, non10n = 1000;

	cin >> N;
	rep(i, N) {
		cin >> s;
		sum += s;
		if (s % 10 != 0 && s < non10n) non10n = s;
	}

	if (sum % 10 != 0) cout << sum << endl;
	else if (non10n == 1000) cout << 0 << endl;
	else cout << sum - non10n << endl;

	return 0;
}


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

# define rep(i, n) for(int(i)=0;(i)<(n);(i)++)
# define reps(i, n) for(int(i)=1;(i)<=(n);(i)++)
# define rrep(i, n) for(int i=((int)(n)); i>0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>=0; --i)
# define ALL(v) v.begin(), v.end()
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<typename T> void dump(T e){std::cout << e << std::endl;}
template<typename T> void dump(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void dump(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ dump(v); } }
typedef long long ll;


int main() {
  int n,m; cin >> n >> m;
  vector<int> num(n);
  int a,b;
  rep(i, m) {
    cin >> a >> b;
    num[a-1]++;
    num[b-1]++;
  }
  rep(i, n) dump(num[i]);  
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

  /**
   * @param args
   */
  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();

    for (int i = 0; i <= 20; i++) {
      if (i == 1) {
        if (a >= b) {
          System.out.println(i);
          return;
        }
      }

      if (((a * i) - (i - 1)) >= b) {
        System.out.println(i);
        return;
      }
    }
  }

}


Measured memory_bytes: 23892
import sys
from collections import defaultdict

if __name__ == '__main__':
    n, v = map(int, sys.stdin.readline().split())
    a = tuple(map(int, sys.stdin.readline().split()))
    b = tuple(map(int, sys.stdin.readline().split()))
    c = tuple(map(int, sys.stdin.readline().split()))
    d = tuple(map(int, sys.stdin.readline().split()))
    mp = defaultdict(int)
    ls = []
    for val1 in c:
        for val2 in d:
            mp[val1+val2] += 1
    ans = 0
    for val1 in a:
        for val2 in b:
           ans += mp[v-val1-val2]
    print(ans)



Measured memory_bytes: 179044
#include <algorithm>
#include <string>
#include <iostream>

using namespace std;


int main()
{
	int n;
	cin >> n;
	int num[n],nums[n];
	for (size_t i = 0; i < n; i++)
	{
		cin >> num[i];
		nums[i] = num[i];
	}
	sort(nums, nums + n);
	int me1 = nums[n / 2-1],me2=nums[n/2];
	for (size_t i = 0; i < n; i++)
	{
		if (num[i] >= me2)cout << me1 << endl;
		else cout << me2 << endl;
	}
    return 0;
}



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

//--------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

//--------------------------------------------
const double EPS = 1e-14;
const double PI  = acos(-1.0);

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

int n;
int a;
vector<int> v;

int main(){
  scanf("%d",&n);

  REP (i, n) {
    scanf("%d",&a);
    v.push_back(a);
  }

  sort(v.begin(), v.end(), greater<int>() );

  LL a = 0;
  LL b = 0;
  while (v.size() > 1 && b == 0) {
    if (v.at(0) == v.at(1)) {
      a == 0 ? a = v.at(0) : b = v.at(0);
      v.erase(v.begin(), v.begin() + 2);
    } else v.erase(v.begin(), v.begin() + 1);
  }
  printf("%lld\n",a * b);
}


Measured memory_bytes: 892
<?php
list($a) = ints();
list($b) = ints();
echo $a == $b ? "0" : "1";

function str(){
  return trim(fgets(STDIN));
}
function ints(){
  return array_map("intval", explode(" ", trim(fgets(STDIN))));
}
function int(){
  return intval(trim(fgets(STDIN)));
}
function o(...$val){
    if(count($val)==1)$val = array_shift($val);
    $trace = debug_backtrace();
    echo $trace[0]['line'].")";
    if(is_array($val)){
        if(count($val) == 0){
            echo "empty array";
        }elseif(!is_array(current($val))){
            echo "array:";
            echo implode(" ", $val)."\n";
        }else{
            echo "array:array\n";
            foreach($val as $row){
                echo implode(" ", $row)."\n";
            }
        }
    }else{
        echo $val."\n";
    }
}

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

int main(){
    int n;

    bool l[4][13];
    for(int i = 0; i < 4; i++){
        for(int j = 0; j < 13; j++){
            l[i][j] = false;
        }
    }
    
    cin >> n;

    for(int i = 0; i < n; i++){
        char mark;
        int number;
        cin >> mark >> number;
        switch(mark){
            case 'S': l[0][number-1] = true; break;
            case 'H': l[1][number-1] = true; break;
            case 'C': l[2][number-1] = true; break;
            case 'D': l[3][number-1] = true; break;
        }
    }

    //0:S
    for(int j = 0; j < 13; j++){
        if(l[0][j] == false){
            cout << "S " << j+1 << endl;
        }
    }

    //1:H
    for(int j = 0; j < 13; j++){
        if(l[1][j] == false){
            cout << "H " << j+1 << endl;
        }
    }

    //2:C
    for(int j = 0; j < 13; j++){
        if(l[2][j] == false){
            cout << "C " << j+1 << endl;
        }
    }

    //3:D
    for(int j = 0; j < 13; j++){
        if(l[3][j] == false){
            cout << "D " << j+1 << endl;
        }
    }

    return(0);
}

Measured memory_bytes: 3080
/*+lmake
 * STD = c++14
 * DEFINE += MDEBUG
 */
#include <bits/stdc++.h>
using namespace std;
using LL=long long;
#ifdef DEBUG
     #define debug(args...)            {dbg,args; cerr<<endl;}
#else
    #define debug(args...)              // Just strip off all debug tokens
#endif

struct debugger
{
    template<typename T> debugger& operator , (const T& v)
    {    
        cerr<<v<<" ";    
        return *this;    
    }
} dbg;
#define MAXN 100000
int a[MAXN+10];
void solve(long long N, vector<long long> A){
	for(int i=0; i<N; ++i) {
		a[i+1]=A[i];
	}	
	LL sum=0;
	for(int i=1; i<=N+1; ++i) {
		sum+=abs(a[i]-a[i-1]);
	}
	for(int i=1; i<=N; ++i) {
		LL t=sum-abs(a[i]-a[i-1])-abs(a[i+1]-a[i])+abs(a[i-1]-a[i+1]);
		printf("%lld\n",t);
	}
}

int main(){	
	long long N;
	scanf("%lld",&N);
	vector<long long> A(N-1+1);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&A[i]);
	}
	solve(N, A);
	return 0;
}



Measured memory_bytes: 3200
n,m=map(int,raw_input().split())
p=map(int,raw_input().split())
abc=[map(int,raw_input().split()) for _ in xrange(n-1)]
cnt=[0]*n

for i in xrange(m-1):
    p[i]-=1
    p[i+1]-=1
    if p[i]<p[i+1]:
        cnt[p[i]]+=1
        cnt[p[i+1]]-=1
    else:
        cnt[p[i]]-=1
        cnt[p[i+1]]+=1
    p[i]+=1
    p[i+1]+=1
    
for i in xrange(n-1):
    cnt[i+1]+=cnt[i]
    
ans=0
for i in xrange(n-1):
    ans+=min(abc[i][0]*cnt[i],abc[i][1]*cnt[i]+abc[i][2])
    
print(ans)

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

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#include <map>
#define all(x) (x).begin(),(x).end()

void solve(){

}
int main(){
    string key_top = "keyence";
    string key_end = "keyence";
    reverse(all(key_end));
    string s;
    cin >> s;

    int size = (int)key_top.size();

    int cnt1 = 0;
    for (int i = 0; i < size; i++){
        if (s[i] == key_top[i]){
            cnt1++;
        }
    }

    int cnt2 = 0;
    int ssize = (int)s.size();
    for (int i = 0; i < size; i++){
        if (s[ssize-i-1] == key_end[i]){
            cnt2++;
        }
    }
    if (cnt1 + cnt2 >= size){
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }


    return 0;
}


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

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n;
	cin >> n;
	int a[n+1], b[n+1], c[n+1];
	for (int i = 1; i <= n; i++) {
		cin >> a[i] >> b[i] >> c[i];
	}
	int dp[n+1][4];
	dp[1][1] = a[1];
	dp[1][2] = b[1];
	dp[1][3] = c[1];
	for (int i = 2; i <= n; i++) {
		for (int j = 1; j <= 3; j++) {
			if (j == 1) {
				dp[i][j] = max(dp[i-1][2] + a[i], dp[i-1][3] + a[i]);
			}
			else if (j == 2) {
				dp[i][j] = max(dp[i-1][1] + b[i], dp[i-1][3] + b[i]);
			}
			else if (j == 3) {
				dp[i][j] = max(dp[i-1][1] + c[i], dp[i-1][2] + c[i]);
			}
		}
	}
	int max_happiness = 0;
	for (int j = 1; j <= 3; j++) {
		max_happiness = max(dp[n][j], max_happiness);
	}
	cout << max_happiness << "\n";
	
	return 0;
}


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

const int N = 110;
int n;
int b[N];
int ans = 0;

int main()
{
    ios_base::sync_with_stdio(false);
    cin >> n;
    for (int i = 1; i <= n - 1; i++)
        cin >> b[i];
    ans += b[1] + b[n-1];
    for (int i = 1; i <= n - 1; i++)
    {
        int temp = min(b[i], b[i+1]);
        ans += temp;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        try(Scanner sc = new Scanner(System.in)){
            String line = sc.nextLine();
            String answer = "";
            int length = line.length();
            for(int i=0; i<length; i++){
                char ch = line.charAt(i);
                if(Character.isLowerCase(ch)){
                    ch = Character.toUpperCase(ch);
                }else{
                    ch = Character.toLowerCase(ch);
                }
                answer += ch;
            }
            System.out.println(answer);
        }
    }
}


Measured memory_bytes: 31260
n, k = gets.split.map(&:to_i)
nums = gets.split.map(&:to_i)
zeros = Array.new(n + 1, 0)
previous = nums
k.times do |i|
  after = Array.new(n + 1, 0)
  previous.each_with_index do |num, index|
    if num == n
      after[0] += 1
      after[n] -= 1
    else
      min = index - num
      min = 0 if min < 0
      max = index + num
      max = n - 1 if max > n - 1
      after[min] += 1
      after[max + 1] -= 1
    end
  end
  minimum = n
  prev = after[0]
  (1...n).each do |i|
    cur = after[i]
    next if cur == n
    cur += prev
    minimum = cur if minimum > cur
    cur = n if cur > n
    after[i] = cur
    prev = cur
  end
  after.delete_at(-1)
  previous = after
  break if minimum == n
end

previous[0] = n if previous.first > n
puts previous.join(' ')


Measured memory_bytes: 82676
# -*- Coding: utf-8 -*-
def reverse(str):
  if str == '0':
    str = '1'
  else:
    str = '0'
  return str


S = raw_input()
S = list(S)
N = len(S)
ans = 0

for i in xrange(N-1):
  if S[i] == S[i+1]:
    S[i+1] = reverse(S[i+1])
    ans += 1

print ans

Measured memory_bytes: 3460
A, B = map(int, input().split())
cnt = 0
for n in range(A,B+1):
  n_str = str(n)
  n_len = len(n_str)
  is_kaibun = True
  for i in range(n_len//2):
    if n_str[i] != n_str[n_len-1-i]:
      is_kaibun = False
  if is_kaibun is True:
    cnt += 1
print(cnt)

# if n_str[0] == n_str[4] and n_str[1] == n_str[3]:
#   cnt += 1

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define print(n) cout << n << endl
#define YN(c) (c)?(print("YES")):(print("NO"))
#define Yn(c) (c)?(print("Yes")):(print("No"))
#define yn(c) (c)?(print("yes")):(print("no"))
#define in(v) int v; cin >> v
#define din(v) int v;cin >> v
#define vint vector<int>
#define pb push_back
typedef long long int ll;

int main(){
  string s,t,u;
  map<string,int> m;
  cin >> s >> t;
  cin >> m[s] >> m[t];
  cin >> u;
  m[u]--;
  cout << m[s] << " " << m[t] << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>


using namespace std;

int main(){
	int H, W;

	while (1){
		cin >> H >> W;
		if (H == 0 && W == 0) break;
		for (int i = 0; i < H; i++){
			for (int j = 0; j < W; j++){
				if (i == 0 || i == H - 1 || j == 0 || j == W - 1){
					cout << "#";
				}
				else {
					cout << ".";
				}
			}
			cout << endl;
		}
		cout << endl;

	}

	return 0;
}

Measured memory_bytes: 1152