akhauriyash/Code-Regression huggingface dataset:
//============================================================================
// Name        : ITP_1_4_C.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
using namespace std;

int main() {
	int a,b;
	char op;
	do {
		cin >> a >> op >> b;
		if (op == '?') break;
		switch(op) {
		case '+' :
			printf("%d\n",a+b);
			break;
		case '-' :
			printf("%d\n",a-b);
			break;
		case '*' :
			printf("%d\n",a*b);
			break;
		case '/' :
			printf("%d\n",a/b);
			break;
		}
	} while(1);
	return 0;
}

Measured memory_bytes: 3184
/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
If I'm the sun, you're the moon
Because when I go up, you go down
*******************************
I'm working for the day I will surpass you
https://www.a2oj.com/Ladder16.html
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class Main
   {
      public static void main(String omkar[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int N = Integer.parseInt(st.nextToken());
         double lol = 1.0*N;
         lol /= 3;
         System.out.println(lol*lol*lol);
      }
   }

Measured memory_bytes: 22996
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

a,b = LI()
if a <= 8 and b <= 8:
    print('Yay!')
else:
    print(':(')

Measured memory_bytes: 38384
N, x = map(int, input().split())
a = list(map(int, input().split()))

# 左端から必要な分だけ食べる
ans = 0
for i in range(1, N):
    num = max(a[i-1] + a[i] - x, 0)
    ans += num
    a[i] = max(0, a[i] - num)
print(ans)

Measured memory_bytes: 14056
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;

public class Main{
  public static void main(String[] args){
    // 入力値の読み込み
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] A = new int[N];
    int[] B = new int[N];
    ArrayList<Pair> list = new ArrayList<>();
    for(int i=0; i<N; i++){
      list.add(new Pair(sc.nextInt(), sc.nextInt()));
    }
    Collections.sort(
      list,
      new Comparator<Pair>(){
        public int compare(Pair obj1, Pair obj2){
          return obj1.B - obj2.B;
        }
      }
    );
    String status = "Yes";
    int sumtime = 0;
    for(int i=0; i<list.size(); i++){
      sumtime += list.get(i).A;
      if(sumtime <= list.get(i).B){
        continue;
      }
      status = "No";
    }
    System.out.print(status);
  }  
}

class Pair{
  public int A = 0; //単位時間
  public int B = 0; //終了時刻
  public Pair(int A, int B){
    this.A = A;
    this.B = B;
  }
}

Measured memory_bytes: 106936
#include "bits/stdc++.h"
#include <random>

using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007LL
#define llMAX 9223372036854775807LL
#define llMIN -9223372036854775808LL
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,k,x,y;

int main(){
  ll ans=0;
  ll D=365;
  cin>>ans;
  vi c(26);
  vi last(26);
  vvi data(D, vi(26));  // N * M の2次元配列
  for(ll i=0;i<26;i++){
    cin>>c[i];
  }
  for(ll i=0;i<D;i++){
    for(ll j=0;j<26;j++){
      cin>>data[i][j];
    }
  }


  ll sc=0;
  ll sct=0;
  ll maxid=-1;
  for(ll i=0;i<D;i++){
    sc=-922337203685477580LL;
    maxid=0;
    for(ll j=0;j<26;j++){
      sct=data[i][j]-(last[j]*last[j]-last[j])/2*c[i];
      if (sc<sct){
        sc=sct;
        maxid=j;
      }
    }
    last[maxid]=i;
    cout<<(maxid+1)<<endl;
  }



  
  /*
  random_device rnd;     // 非決定的な乱数生成器
  for (int i = 0; i < n; ++i) {
    auto aa=rnd();
      cout << aa << "\n";
  }
  */

  return 0;
}

Measured memory_bytes: 3688
n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))
C = 0
for i in range(q):
    left = 0
    right = n
    while left < right:
        mid = (left + right) // 2
        if T[i] > S[mid]:
            left = mid + 1
        elif T[i] < S[mid]:
            right = mid
        else:
            C += 1
            break
print(C)


Measured memory_bytes: 16704
#include <stdio.h>

int main(void)
{
  int a[3]={};
  int min=999;
  int cost=0;
  int point=0;
  int i,j,k;
  scanf("%d %d %d",&a[0],&a[1],&a[2]); 
  for(i=0; i<3; i++)
  {
    cost = 0;
    for(j=0; j<3; j++)
    {
       point=a[i];
       if( i==j ) continue;
       cost = ((point - a[j]) > 0)?(point - a[j]):(a[j] - point);
       point = a[j];
       for(k=0;k<3;k++)
       {
       if( i==k ) continue;
       if( j==k ) continue;
         cost += ((point - a[k]) > 0)?(point - a[k]):(a[k] - point);
         if ( cost < min ){
           min = cost;
          }
        }
     }
  }
  printf( "%d", min);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define int long long
int t1,t2,a1,a2,b1,b2;
signed main(){
cin>>t1>>t2>>a1>>a2>>b1>>b2;
int t3=t1*a1,t4=t1*b1,t5=t2*a2,t6=t2*b2;
if(t3>t4&&t5>t6){
	printf("0");
	return 0;
}
if(t3<t4&&t5<t6){
	printf("0");
	return 0;
}
if(t3<t4&&t3+t5<t4+t6){
	printf("0");
	return 0;
}
if(t3>t4&&t3+t5>t4+t6){
	printf("0");
	return 0;
}
if(t3>t4){
	swap(t3,t4);
	swap(t5,t6);
}
//cout<<t3<<" "<<t5<<endl;
int temp=t3+t5-t4-t6;
if(!temp){
	printf("infinity");
	return 0;
}
int temp2=t4-t3;
//cout<<temp<<" "<<temp2;
int op=(temp2/temp)*2;
if(temp2%temp==0)op--;
cout<<op+1;

return 0;
}


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

using namespace std;

#define INF 2000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;


int main()
{
	int K;
	int S;
	int ans;

	cin >> K >> S;

	// x + y + z == S;
	// 0<= x,y,z <= K;


	int z = 0;

	for (int i = 0; i <= K; i++) {
		for (int j = 0; j <= K; j++) {
			z = S - i - j;
			if (0 <= z && z <= K) {
				ans++;
			}
		}
	}

	cout << ans << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = int(a); i <= int(b); ++i)
using namespace std;
template <class A>
void pr(A a) {
  cout << (a) << endl;
}
template <class A, class B>
void pr(A a, B b) {
  cout << a << " ";
  pr(b);
}
template <class A, class B, class C>
void pr(A a, B b, C c) {
  cout << a << " ";
  pr(b, c);
}
template <class A, class B, class C, class D>
void pr(A a, B b, C c, D d) {
  cout << a << " ";
  pr(b, c, d);
}
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
int INF = numeric_limits<int>::max();
// for(int j=0;j<N;++j) {

int main(void) {
  int x1, x2, x3, x4, x5;
  cin >> x1 >> x2 >> x3 >> x4 >> x5;
  if (x1 == 0) {
    cout << 1 << endl;
  } else if (x1 == 0) {
    cout << 1 << endl;
  } else if (x2 == 0) {
    cout << 2 << endl;
  } else if (x3 == 0) {
    cout << 3 << endl;
  } else if (x4 == 0) {
    cout << 4 << endl;
  } else {
    cout << 5 << endl;
  }
  return 0;
}


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

using namespace std;

#define inf 1<<30
#define llong long long
#define usd unsigned
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define fn fill_n
typedef pair<int, int> P;
typedef struct data{
	int now;
	int cost;
}data;
int nw[9] = {0, 1, 0, -1, -1, 1, 1, -1, 0};
int nh[9] = {1, 0, -1, 0, 1, 1, -1, -1, 0};
int a,b,c,d, A[100], B[100], C[100][100], D[100][100][100];
string s, t, r;




int main(){
	cin >> a;
	b = 0;
	c = a;
	while(true){
		b += c%10;
		c/= 10;
		if(c/10) continue;
		else{
			b+=c;
			break;
		}
	}
	// cerr << a <<" " <<  b <<" " <<  c << endl;
	if(a%b) cout << "No" << endl;
	else cout << "Yes" << endl;

	return 0;
}

// #include <bits/stdc++.h>

// using namespace std;

// #define inf 1<<30
// #define llong long long
// #define usd unsigned
// #define pqueue priority_queue
// #define mp make_pair
// #define pb push_back
// #define fn fill_n
// typedef pair<int, int> P;
// typedef struct data{
// 	int now;
// 	int cost;
// }data;
// int nw[9] = {0, 1, 0, -1, -1, 1, 1, -1, 0};
// int nh[9] = {1, 0, -1, 0, 1, 1, -1, -1, 0};

// int n, k, a[100000];


// int main(){
// 	int mini;
// 	cin >> n >> k;
// 	for(int i = 0; i < n; i++){
// 		cin >> a[i];
// 		if(a[i] == 1) mini = i;
// 	}

// 	if(mini < k || mini >= n-k){
// 		cout << n/k+(n%k?1:0) << endl;
// 	}else{
		
// 	}


// 	return 0;
// }

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

const int INF = 1000000000;

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

		if(n==0)
			break;

		int T[10][10];
		for(int i=0; i<10; i++){
			for(int j=0; j<10; j++){
				if(i==j){
					T[i][j] = 0;
				}
				else{
					T[i][j] = INF;
				}
			}
		}

		int m = 0;     //How many towns are there?

		for(int i=0; i<n; i++){
			int a, b, c;
			cin >> a >> b >> c;

			T[a][b] = T[b][a] = c;

			if(a+1>m){
				m = a+1;
			}
			if(b+1>m){
				m = b+1;
			}
		}

		int d[10][10];
		for(int i=0;i<m;i++){
			for(int j=0;j<m;j++){
				d[i][j]=T[i][j];
			}
		}
		for(int k=0;k<m;k++){
			for(int i=0;i<m;i++){
				for(int j=0;j<m;j++){
					if(d[i][j]>d[i][k]+d[k][j]){
						d[i][j]=d[i][k]+d[k][j];
					}
				}
			}
		} 

		int dis=INF,name=-1,tmp;
		for(int i=0;i<m;i++){
			tmp = 0;
			for(int j=0;j<m;j++){
				tmp += d[i][j];
			}
			if(dis>tmp){
				dis=tmp;
				name=i;
			}
		}
		cout << name << " " << dis << endl;


	}

	return 0;
}


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  string st;
  unordered_set<string> s;
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    cin >> st;
    if (!s.count(st)) { //s.count(st) =0 (stが新出) ならば,条件の()内はtrue
      s.insert(st);
      ans++;
    }
  }
  cout << ans << endl;

}




Measured memory_bytes: 17688
#include<stdio.h>
#include<cstdio>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>

#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#include <iomanip>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll mod = 998244353;


ll N,A,B,C,D;
string S;
int iwa[200005];
bool flagA, flagB;



int main() {
	cin >> N >> A >> B >> C >> D;
	cin >> S;

	bool F=false;
	int margecnt = 0;
	FOR(i, A-1, D) {
		if (S[i] == '#') {
			if (F)flagA = true;
			F = true;
			if (margecnt >= 3)flagB = true;
			margecnt = 0;
		}
		else {
			F = false;
			if(i>=(B-2))margecnt++;
		}
	}
	if (D < N&&S[D] == '.')margecnt++;
	if (margecnt >= 3)flagB = true;
	
	if (C > D) {
		if (flagA == false && flagB == true)cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	else {
		if (flagA)cout << "No" << endl;
		else cout << "Yes" << endl;
	}



	return 0;
}

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

int main() {
    string s;
    cin >> s;

    if (s[2] == s[3] && s[4] == s[5]) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
const int INF=1001001000;
const int mINF=-1001001000;
int n,m;
vector<int> to[1010];
vector<int> bfs(int sv){
    queue<int> q;
    vector<int> dist(n+1,INF), pre(n+1,-1);
    q.push(sv);
    dist[sv]=0;
    while(!q.empty()){
        int now=q.front();q.pop();
        for(auto next: to[now]){
            if(dist[next]!=INF) continue;
            dist[next]=dist[now]+1;
            pre[next]=now;
            q.push(next);
        }
    }
    P best(INF,-1);
    for(int v=1; v<=n; v++){
        if(v==sv) continue;
        for(auto u: to[v]){
            if(u==sv){
                best=min(best,make_pair(dist[v],v));
            }
        }
    }
    if(best.first==INF) return vector<int>(n+1);
    vector<int> res;
    int v=best.second;
    while(v!=-1){
        res.push_back(v);
        v=pre[v];
    }
    return res;
}
int main(){
    cin >> n >> m;
    for(int i=0; i<m; i++){
        int a,b;cin >> a >> b;
        to[a].push_back(b);
    }
    vector<int> ans(n+1);
    for(int v=1; v<=n; v++){
        auto now=bfs(v);
        if(now.size()<ans.size()) ans=now;
    }
    if(ans.size()==n+1){
        cout << -1 << endl;
        return 0;
    }
    cout << ans.size() << endl;
    for(auto v: ans){
        cout << v << endl;
    }
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long
int main() {
    ll a, b, n, min;
    std::cin >> n;
    min = n;
    a = -1;
    b = -1;
    for (ll i = 2; i <= sqrt(n); i++) {
        if ((n % i == 0) and (n / i + i < min))
        {
            a = i;
            b = n / i;
            min = n / i + i;
        }
    }
    if (a + b - 2 < 0) {
        std::cout << n - 1;
    }
    else
        std::cout << a + b - 2;
}

Measured memory_bytes: 256
n,a,b = gets.split.map(&:to_i)
cnt = 0
(1..n).each do |i|
    sum = 0
    k = i
    while i > 0
        sum += i % 10
        i /= 10
    end
    if sum >= a && sum <= b
        cnt += k
    end
end
puts cnt

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

int main(){
    int a[5];
    int max_mod = 0; int sum = 0;
    for (int i = 0; i < 5; i++){
        cin >> a[i];
        max_mod = max(max_mod, (130 - a[i]) % 10); 
        sum += a[i] + (130 - a[i]) % 10;
    }
    cout << sum - max_mod << endl;
}

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

int main(){
    int a,b,res=0;
    cin>>a>>b;
    for(int i=a; i<=b; i++) {
        int s = i/10000 % 10, t = i%10, u = i/10%10, v = i/1000%10; 
        if(s==t && u==v) res++;
    }
    cout<<res;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
constexpr int kMod = 1000000007;
typedef long long LL;

int main() {
  LL N, M; std::cin >> N >> M;

  LL total = std::min(N, M/2);
  M -= total*2;
  total += M/4;
  std::cout << total << std::endl;
}


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

using namespace std;

using ll = long long;
using ld = long double;
using ull = unsigned long long;

#define int long long
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

void shift()
{
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
}
const int N = 2e5;


signed main()
{
    string s;
    cin >> s;
    vector<int>ans((int)s.size());
    vector<pair<int, int> > v;
    for(int i = 0; i < s.size(); ++i)
    {
        int cc = i;
        int cnt = 0;
        while(cc < s.size() && s[cc] == 'R')
            ++cc, ++cnt;
        int s1 = cnt;
        cnt = 0;
        while(cc < s.size() && s[cc] == 'L')
            ++cc, ++cnt;
        int s2 = cnt;
        v.push_back({s1, s2});
        i = cc - 1;
    }
    int cur_id = 0;
    for(int i = 0; i < v.size(); ++i)
    {
        if ((cur_id % 2) == ((cur_id + v[i].F - 1) % 2))
        {
            ans[cur_id + v[i].F - 1] = (v[i].F + v[i].S + 1) / 2;
            ans[cur_id + v[i].F] = (v[i].F + v[i].S) / 2;
        }
        else
        {
            ans[cur_id + v[i].F - 1] = (v[i].F + v[i].S) / 2;
            ans[cur_id + v[i].F] = (v[i].F + v[i].S + 1) / 2;
        }
        cur_id += v[i].F + v[i].S;
    }
    for(int i = 0; i < s.size(); ++i)
        cout << ans[i] << " ";
    return 0;
}


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

int main() {
	int W, H, x, y;
	cin >> W >> H >> x >> y;
	int ans = 0;
	if (x * 2 == W && y * 2 == H) {
		ans = 1;
	}
	printf("%.9lf %d\n", (double)W * H / 2, ans);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

bool canOrder(int s[10], int index, int left_top, int right_top) {
  if (index == 10) {
    return true;
  }
  if (s[index] > left_top) {
    if (canOrder(s, index + 1, s[index], right_top)) {
      return true;
    }
  }
  if (s[index] > right_top) {
    if (canOrder(s, index + 1, left_top, s[index])) {
      return true;
    }
  }
  return false;
}

bool canOrder(int s[10]) {
  return canOrder(s, 0, 0, 0);
}

int main() {
  //freopen("Ball.in", "r", stdin);
  int test_count;
  scanf("%d", &test_count);
  for (int test = 0; test < test_count; ++test) {
    int s[10];
    for (int i = 0; i < 10; ++i) {
      scanf("%d", &s[i]);
    }
    bool result = canOrder(s);
    printf("%s\n", result ? "YES" : "NO");
  }
  return 0;
}

Measured memory_bytes: 1008
#include <iostream>
#include <cmath>

using namespace std;

int main(){
    int a,b,c;
    cin >> a;
    cin >> b;
    cin >> c;
     
    if(a>b)  cout << 0;
    else if (a*c<=b)  cout << c;
    else cout << floor(double(b)/double(a));

    return 0;
}

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

void trace(int*,int);

#define MAX 1000


//Insertion Sort
int main(){
    int A[MAX];
    int N;
    int i;
    int j;
    int v;
    
    cin >> N;
    
    //input data
    for (i = 0;i < N;i++) {
        cin >> A[i];
    }

    trace(A,N);

    //Insertion Sort
    for (i = 1;i < N;i++) {
        v = A[i];
        j = i - 1;
        //compare
        while (j >= 0 && A[j] > v) {
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = v;
        trace(A,N);
    }
}

//trace
void trace(int *A,int n)
{
    int i;

    for (i = 0; i < n; i++) {
        if (i) {
            cout << " ";
        }
        cout << A[i];
    }
    cout << endl;
}

Measured memory_bytes: 1164
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int max = 1;
    for (int i = 1; i*i <= N; i++) {
      max = i*i;
    }
    System.out.println(max);
  }
}

Measured memory_bytes: 21972
import sys
input = sys.stdin.readline

s = input()[:-1]
A = 0
ans = 0
i = 0

while i<len(s):
    if s[i]=='A':
        A += 1
        i += 1
    else:
        if i+1<len(s) and s[i:i+2]=='BC':
            ans += A
            i += 2
        else:
            A = 0
            i += 1

print(ans)

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

typedef long long ll;

#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18

vector<ll> a;
vector<pair<int,ll>> X,Y;
void make_array(int L, int R, vector<pair<int,ll>> &t){
    int w = R-L;
    REP(i,(1<<w)){
        ll sum=0;
        int cnt=0;
        REP(j,w){
            if(i&(1<<j)){
                sum += a[L+j];
                cnt++;
            }
        }
        t.push_back({cnt,sum});
    }
}

int main() {
    ll n,k,l,r; cin >> n >> k >> l >> r;
    a.assign(n,0); REP(i,n) cin >> a[i];
    
    make_array(0,n/2,X);
    make_array(n/2,n,Y);
    
    sort(ALL(X));
    sort(ALL(Y));
        
    ll ans = 0;

    REP(i,X.size()){
        int itr_R = upper_bound(ALL(Y), pair<int,ll>(k-X[i].first, r-X[i].second)) - Y.begin();
        int itr_L = lower_bound(ALL(Y), pair<int,ll>(k-X[i].first, l-X[i].second)) - Y.begin();
        ans += itr_R - itr_L;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 43752
#include <cstdio>
    #include <iostream>
    #include <cmath>
    #include <cstring>
    #include <sstream>
    #include <algorithm>
    #include <cstdlib>
    #include <map>
    #include <queue>
    #include <utility>
    #include <vector>
    #include <set>
    #include <memory.h>
    #include <iomanip>
    #include <bitset>
    #include <list>
    #include <stack>
     
    using namespace std;
     
    #define mod 1000000007
     
    int n, x, y;
    vector<vector<int> > color(200001);
     
    vector<long long int> factmod(200001);
    vector<long long int> inversefactmod(200001);
     
    void getfactmod()
    {
    	factmod[0] = 1;
    	for(long long int i = 1; i < 200001; i++){
    		factmod[i] = (factmod[i - 1] * i) % mod;
    	}
    	return;
    }
     
    void getinversefactmod()
    {
    	for(long long int i = 0; i < 200001; i++){
    		// tmp[j] = factmod[i]^(2^j) % mod
    		long long int tmp[31];
    		tmp[0] = factmod[i];
    		for(long long int j = 1; j < 31; j++){
    			tmp[j] = (tmp[j - 1] * tmp[j - 1]) % mod;
    		}
    		long long int m = mod - 2;
    		inversefactmod[i] = 1;
    		for(long long int j = 30; j >= 0; j--){
    			long long int pow2 = (long long int)pow(2, j);
    			if(m >= pow2){
    				inversefactmod[i] = (inversefactmod[i] * tmp[j]) % mod;
    				m -= pow2;
    			}
    		}
    	}
    	return;
    }
     
    long long int comb(long long int n, long long int k)
    {
    	return factmod[n] * ((inversefactmod[k] * inversefactmod[n - k]) % mod) % mod;
    }
     
    long long int solve()
    {
    	int minw = 0, secminw = 0;
    	for(int i = 1; i <= n; i++){
    		if(color[i].size() == 0) continue;
    		if(minw == 0 || color[minw][0] > color[i][0]){
    			secminw = minw;
    			minw = i;
    		} else if(secminw == 0 || color[secminw][0] > color[i][0]){
    			secminw = i;
    		}
    	}
    	if(secminw == 0 || color[minw][0] + color[secminw][0] > y) return 1;
    	vector<int> tmp;
    	int sum = 0;
    	for(int i = 1; i <= n; i++){
    		if(color[i].size() == 0) continue;
    		int l = -1, r = color[i].size();
    		while(r - l > 1){
    			int mid = (r + l) / 2;
    			if((i == minw && (mid == 0 || color[i][0] + color[i][mid] <= x || color[secminw][0] + color[i][mid] <= y)) || (i != minw && ((color[i][0] + color[minw][0] <= y && color[i][0] + color[i][mid] <= x) || color[i][mid] + color[minw][0] <= y))) l = mid;
    			else r = mid;
    		}
    		tmp.push_back(l + 1);
    		sum += l + 1;
    	}
    	long long int ans = 1;
    	for(int i = 0; i < tmp.size(); i++){
    		ans = (ans * comb(sum, tmp[i])) % mod;
    		// cout << sum << " " << tmp[i] << " " << comb(sum, tmp[i]) << endl;
    		sum -= tmp[i];
    	}
    	return ans;
    }
     
    int main()
    {
    	cin >> n >> x >> y;
    	for(int i = 0; i < n; i++){
    		int c, w;
    		cin >> c >> w;
    		color[c].push_back(w);
    	}
    	for(int i = 1; i <= n; i++){
    		if(color[i].size() != 0) sort(color[i].begin(), color[i].end());
    	}
    	getfactmod();
    	getinversefactmod();
    	cout << solve() << endl;
    	return 0;
     
    }

Measured memory_bytes: 13564
#include <stdio.h>

int main(void)
{
	char str[81];
	int num = 0;
	
	while (scanf("%s", str) != EOF){
		int i;
		
		for (i = 0; str[i] != 0; i++){
			int tmp = 0;
			for (; '0' <= str[i] && str[i] <= '9'; i++){
				tmp *= 10;
				tmp += str[i] - '0';
			}
			num += tmp;
			if (str[i] == 0){
				break;
			}
		}
	}
	
	printf("%d\n", num);
	
	return 0;
}

Measured memory_bytes: 540
#include<bits/stdc++.h>
using namespace std;
#define il inline
#define ls(x) (x<<1)
#define rs(x) (x<<1|1)
#define gc getchar()
#define ll long long
#define int long long
#define ri register int
#define rc register char
#define rb register bool
#define rp(i,x,y) for(ri i=x;i<=y;++i)
#define my(i,x,y) for(ri i=x;i>=y;--i)
using namespace std;
    
il int read()
{
    rc ch=gc;ri x=0;rb y=1;
    while(ch!='-' && (ch>'9' || ch<'0'))ch=gc;
    if(ch=='-')ch=gc,y=0;
    while(ch>='0' && ch<='9')x=(x<<1)+(x<<3)+(ch^'0'),ch=gc;
    return y?x:-x;
}
ll min1[1000001], min2[1000001], adds[1000001];
inline void down(int nw) 
{
    if (!adds[nw])return;
    adds[ls(nw)] += adds[nw];
    adds[rs(nw)] += adds[nw];
    min1[ls(nw)] += adds[nw];
    min2[ls(nw)] += adds[nw];
    min1[rs(nw)] += adds[nw];
    min2[rs(nw)] += adds[nw];
    adds[nw] = 0;
}
inline void up(int nw) 
{
    min1[nw] = min(min1[ls(nw)], min1[rs(nw)]);
    min2[nw] = min(min2[ls(nw)], min2[rs(nw)]);
}
void setpt(int l, int r, int nw, int pt, ll num) 
{
    if (l == r) 
	{
        min1[nw] = min(min1[nw], num - l);
        min2[nw] = min(min2[nw], num + l);
        return;
    }
    int mid = (l + r) >> 1;down(nw);
    if (pt <= mid)setpt(l, mid, ls(nw), pt, num);
    else setpt(mid + 1, r, rs(nw), pt, num);
    up(nw);
}
ll query1(int rl, int rr, int l, int r, int nw) 
{
    if (rl == l && rr == r)return (min1[nw]);
    int mid = (l + r) >> 1;down(nw);
    if (rl > mid)return (query1(rl, rr, mid + 1, r, rs(nw)));
    if (rr <= mid)return (query1(rl, rr, l, mid, ls(nw)));
    return (min(query1(rl, mid, l, mid, ls(nw)), query1(mid + 1, rr, mid + 1, r, rs(nw))));
}
ll query2(int rl, int rr, int l, int r, int nw) 
{
    if (rl == l && rr == r)return (min2[nw]);
    int mid = (l + r) >> 1;down(nw);
    if (rl > mid)return (query2(rl, rr, mid + 1, r, rs(nw)));
    if (rr <= mid)return (query2(rl, rr, l, mid, ls(nw)));
    return (min(query2(rl, mid, l, mid, ls(nw)), query2(mid + 1, rr, mid + 1, r, rs(nw))));
}
ll query(int l, int r, int nw) 
{
    if (l == r)return (min1[nw] + l);
    int mid = (l + r) >> 1;down(nw);return (min(query(l, mid, ls(nw)), query(mid + 1, r, rs(nw))));
}
signed main() 
{
//	freopen("2558.in","r",stdin);
    int n = read(), q = read(), pre = read();
    memset(min1, 0x3f, sizeof(min1));memset(min2, 0x3f, sizeof(min2));setpt(1, n, 1, read(), 0);
    for (register int i = 1; i <= q; i++) 
	{
        int nw = read();
        ll cjr = min(query1(1, nw, 1, n, 1) + nw, query2(nw, n, 1, n, 1) - nw);
        adds[1] += abs(nw - pre);
        min1[1] += abs(nw - pre);
        min2[1] += abs(nw - pre);
        setpt(1, n, 1, pre, cjr);
        pre=nw;
    }
    printf("%lld\n",query(1,n,1));
    return (0);
}

Measured memory_bytes: 23808
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}

const LL INF=1e18;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int h,w,k;
    cin >> h >> w >> k;    
    int sx,sy,tx,ty;
    cin >> sx >> sy >> tx >> ty;
    --sx; --sy; --tx; --ty;
    vector<string> g(h);
    REP(i,h) cin >> g[i];
    auto toId=[&]( int i, int j, int v ) {
        return (i*w+j)*4+v;
    };
    auto ceilMod=[&]( LL x ) {
        return (x+k-1)/k*k;
    };
    vector<LL> dist(h*w*4,INF);
    MinHeap<pair<LL,LL>> q;
    auto push=[&]( int i, int j, int v, LL x ) {
        int id=toId(i,j,v);
        if ( dist[id]<=x ) return;
        dist[id]=x;
        q.emplace(x,id);
    };
    REP(v,4) push(sx,sy,v,0);
    while ( !q.empty() ) {
        LL d=q.top().first;
        LL id=q.top().second;
        q.pop();
        if ( dist[id]<d ) continue;
        int x=id/4/w;
        int y=id/4%w;
        int v=id%4;
        REP(nv,4) if ( v!=nv ) push(x,y,nv,ceilMod(d));
        {
            int nx=x+dx[v],ny=y+dy[v];
            if ( nx>=0&&nx<h&&ny>=0&&ny<w ) {
                if ( g[nx][ny]=='.' ) {
                    push(nx,ny,v,d+1);
                }
            }
        }
    }
    LL ans=INF;
    REP(v,4) chmin(ans,dist[toId(tx,ty,v)]);
    if ( ans==INF ) cout << -1 << '\n';
    else {
        cout << ceilMod(ans)/k << '\n';
    }
    return 0;
}


Measured memory_bytes: 43908
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
int main() {
    string s;
    int n,i1,count;
    i1=0;
    count=0;
    cin >> s;
    n=s.size();
    rep(i,n){
        if(s.at(i)=='A' || s.at(i)=='T'|| s.at(i)=='C'|| s.at(i)=='G'){
            i1=i1+1;
            count=max(count,i1);
        }
        else{
            i1=0;
        }
    }
    cout << count;
}

Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main()
{
    int d, t, s;
    cin >> d >> t >> s;
    float a;
    a = (float)d / s;
    if (a <= (float)t)
        cout << "Yes";
    else
    {
        cout << "No";
    }
    return 0;
}


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

int main() {


int a,b;
string s,t,u;
cin>>s>>t>>a>>b>>u;
if(s==u)
cout<<a-1<<" "<<b<<endl;
else
{
    cout<<a<<" "<<b-1<<endl;
}





}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    // var numberTests = readLine()!!.toInt()
    // var results = mutableListOf<String>()

    // for (i in 0..numberTests-1) {
    var s = readLine()!!
    var t = readLine()!!

    
    val result = experiment(s, t)
    // results.add(result)
    // }

    // for (result in results) {
        println(result)
    // }
}

fun experiment(s: String, t: String) : String {

    var result = 0

    val charsS = s.split("").filter { it != "" }
    val charsT = t.split("").filter { it != "" }

    for (i in 0..charsS.size-1) {
        if (charsS[i] != charsT[i]) result++
    }

    return result.toString()
}

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

#define BR "\n"
#define SP " "
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << SP; } cout << BR;
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << BR;

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

  vector<ll> a(N + 1);
  for (int i = 1; i <= N; i++) {
    cin >> a[i];
  }


  vector<ll> b(N + 1, 0);
  ll ballCount = 0;

  for (int i = N; i > 0; i--) {
    ll temp = 0;
    for (int j = 2; j <= N; j++) {
      if ( i * j > N ) break;
      temp += b[i * j];
    }
    temp %= 2;
    b[i] = (a[i] - temp + 2) % 2;
    ballCount += b[i];
  }

  cout << ballCount << BR;
  for (int i = 1; i <= N; i++) {
    if (b[i]) {
      ballCount--;
      if (ballCount) {
        cout << i << SP;
      } else {
        cout << i << BR;
      }
    }
  }

  return 0;
}

Measured memory_bytes: 3968
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
constexpr long long LINF = 1000100010001000100LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() { 
    int n; cin >> n;
    if(n<1000) cout << "ABC" << ln;
    else cout << "ABD" << ln;
}

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

int main(){
  
   int N;
  
  cin>>N;
  
  set <string> S;
  
 
  
  for(int i = 0;i < N;i++){
    string s;
    
    cin>>s;
    
    S.insert(s);
  }
  cout<<S.size();

  return 0;

}

Measured memory_bytes: 19216
a = int(raw_input())
b = raw_input()
num_list_str = b.split(" ", a)
num_list = [int(s) for s in num_list_str]
maxnum = max(num_list)
num_list.remove(maxnum)
if maxnum < sum(num_list):
  print "Yes"
else:
  print "No"


Measured memory_bytes: 2568
n,x,y=map(int,input().split())
ans=[0]*n
for i in range(1,n+1):
 for j in range(i+1,n+1):
   dist1=j-i
   dist2=abs(x-i)+abs(y-j)+1
   dist3=abs(y-i)+abs(x-j)+1
   d=min(dist1,dist2,dist3)
   ans[d]+=1
for i in range(1,n):
 print(ans[i])

Measured memory_bytes: 3444
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
#include <queue>
#include <iomanip>

using namespace std;
using ll = long long int;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
const int MOD=1000000007;
//const int MOD=998244353;
const int INTMAX=1001001000;
const ll LLMAX=1010010010010010000;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll N;
    cin>>N;
    vll A(N);
    for(ll i=0;i<N;i++) cin>>A[i];
    vll ans(N,0);
    ans[0]=A[N-1];
    for(ll i=0;i<=N-2;i++){
        if(i%2==0) ans[0]+=A[i];
        else ans[0]-=A[i];
    }
    
    for(ll i=1;i<N;i++){
        ans[i]=2*A[i-1]-ans[i-1];
    }
    
    for(ll i=0;i<N;i++) printf("%lld ",ans[i]);
    
    return 0;
}


Measured memory_bytes: 2944
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = (1e+9)+7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int main() {
	int n; cin >> n;
	string s;
	int alf[26]; fill(alf, alf + 26, 100);
	rep(i, n) {
		cin >> s;
		int len = s.length();
		int calf[26] = {};
		rep(j, len) {
			calf[s[j] - 'a']++;
		}
		rep(j, 26) {
			alf[j] = min(alf[j], calf[j]);
		}
	}
	rep(i, 26) {
		rep(j, alf[i]) {
			cout << char('a' + i);
		}
	}
	cout << endl;
	return 0;
}

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

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

	int ans = 0, before;

	for (int i = 0; i < N - 1; i++) {
		int b;
		cin >> b;

		if (i == 0) {
			ans += b;
			before = b;
		}
		else {
			ans += min(before, b);

			before = b;
		}
	}

	cout << ans + before << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

// 十分大きな回数を重ねると何かが収束する
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        long k = sc.nextLong();

        int inchiNum = 0;
        for(int i = 0; i < s.length(); i++) {
            if(s.charAt(i) == '1') {
                inchiNum++;
            } else {
                break;
            }
        }
        if(inchiNum >= k) 
        {
            System.out.println(1);
        } else {
            System.out.println(s.charAt(inchiNum));
        }
    }
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
using namespace std;
int main()
{
    fastio;
    string s;
    cin >> s;
    if (s[s.size()-1] == 's') s += "es";
    else s += "s";
    cout << s;
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <math.h>
#include <queue>
#include <stdio.h>
using namespace std;
using i64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)
#define INF 1<<29;

int main()
{
    i64 n;
    cin >> n;
    i64 b = -2;
    i64 cur = 0;
    i64 p[35] = {0};
    rep(i,35) p[i] = pow(b,i);

    for(int i=34;i>=0;--i)
    {
        i64 t = 0;
        for(int j=i-1;j>=0;--j)
            if(j%2==i%2)
                t += p[j];
        
        if((cur+p[i] >= n && cur+t < n) 
            || (cur+p[i] <= n && cur+t > n)
            || abs(cur+p[i]-n) <= abs(cur-n))
        {
            cout << "1";
            cur += p[i];
        }
        else if(cur != 0)
            cout << "0";
    }

    if(n == 0)
        cout << "0";
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
import math, string, itertools, fractions, heapq, collections, re, array, bisect, copy, functools, random
import sys
from collections import deque, defaultdict, Counter; from heapq import heappush, heappop
from itertools import permutations, combinations, product, accumulate, groupby
from bisect import bisect_left, bisect_right, insort_left, insort_right
from operator import itemgetter as ig
def main():
    sys.setrecursionlimit(10 ** 7)
    """inf = 10 ** 20; INF = float("INF"); ans = 0; tmp = 0; cnt = 0; ansli = []; tmpli = []; candili = []; stillset = set()
    eps = 1.0 / 10 ** 10; mod = 10 ** 9 + 7
    dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]; ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]; ddn9 = ddn + [(0, 0)]"""
    """for dx, dy in dd:
            nx = j + dx; ny = i + dy
                if 0 <= nx < w and 0 <= ny < h:"""
    def wi(): return list(map(int, sys.stdin.readline().split()))
    def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]#WideIntPoint
    def ws(): return sys.stdin.readline().split()
    def i(): return int(sys.stdin.readline())
    def s(): return input()
    def s_list(): return list(input())
    def hi(n): return [i() for _ in range(n)]
    def hs(n): return [s() for _ in range(n)]#HeightString
    def mi(n): return [wi() for _ in range(n)]#MatrixInt
    def num_grid(n): return [[int(i) for i in sys.stdin.readline().split()[0]] for _ in range(n)]#NumberGrid
    def mip(n): return [wip() for _ in range(n)]
    def ms(n): return [ws() for _ in range(n)]
    def grid(n): return [s_list() for _ in range(n)]

    a, b = wi()
    print(((b - 1) + (a - 1) - 1) // (a - 1))


if __name__ == '__main__':
    main()

Measured memory_bytes: 7244
import fractions
a, b = map(int, input().split())

def dfs(n):
    table = []
    i = 2
    while n >= i**2:
    # nのその数自身を除いた素因数は√n以下であることから。
        cnt = 0
        while n % i == 0:
            cnt += 1
            n /= i
        if cnt:
          table.append(cnt)
        i += 1
    if n > 1:
        table.append(1)
# 最後に残った、最大の素因数をリストに入れる。
    return table

dfs_list = dfs(fractions.gcd(a, b))

print(len(dfs_list)+1)

Measured memory_bytes: 5436
(defn TimeLimitExceeded [N T]
  (loop [i 1 n 10000 t T]
    (if (> i N) (if (= 10000 n) "TLE" n)
      (let[c (int(read)) ts (int(read))]
        (if (and (<= ts T) (< c n)) 
          (recur (inc i) c ts)
          (recur (inc i) n t))))))
(println (TimeLimitExceeded (int (read)) (int (read))))


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

int main() {
  int c[3][3] = {};
  for(int i = 0;i < 3;i++){
    for(int j = 0;j < 3;j++){
      cin >> c[i][j];
    }
  }

  bool flag = false;
  for(int a1 = 0; a1 <= 100; a1++){
    int b1 = c[0][0] - a1;
    int b2 = c[0][1] - a1;
    int b3 = c[0][2] - a1;
    int a2 = c[1][0] - b1;
    int a3 = c[2][0] - b1;
    if(a2+b1 == c[1][0] && a2+b2 == c[1][1] && a2+b3 == c[1][2]){
      if(a3+b1 == c[2][0] && a3+b2 == c[2][1] && a3+b3 == c[2][2]){
        flag = true;
      }
    }
  }
  if(flag){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
import java.util.*;


public class Main {
	int [] dx = {0,1,1,1,0,-1,-1,-1};
	int [] dy = {1,1,0,-1,-1,-1,0,1};
	
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int h = sc.nextInt();
			int w = sc.nextInt();
			char [][] data = new char[h][w];
			for(int i = 0; i < h; i++){
				data[i] = sc.next().toCharArray();
			}
			
			int [][] calc = new int[h][w];
			for(int i = 0; i < h; i++){
				for(int j = 0; j < w; j++){
					if(data[i][j] == '#'){
						for(int k = 0; k < dx.length; k++){
							int yy = i + dy[k];
							int xx = j + dx[k];
							if(0<= xx && xx < w && 0<= yy && yy < h){
								calc[yy][xx]++;
							}
						}
					}
				}
			}
			
			for(int i = 0; i < h; i++){
				for(int j = 0; j < w; j++){
					if(data[i][j] == '#'){
						calc[i][j] = -1;
					}
				}
			}
			
			for(int i = 0; i < h; i++){
				for(int j = 0; j < w; j++){
					if(calc[i][j] >= 0){
						System.out.print(calc[i][j]);
					}
					else{
						System.out.print("#");
					}
				}
				System.out.println("");
			}
		}
	}



	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().doit();
	}

}


Measured memory_bytes: 22356
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.IllegalArgumentException
import java.lang.StringBuilder
import java.lang.reflect.Modifier
import java.util.*

fun lcm(a:Long, b:Long):Long {
    return a / gcd(a, b) * b
}

fun gcd(a:Long, b:Long):Long {
    val c = a % b
    if (c == 0L) return b
    return gcd(b, c)
}

fun PrintWriter.solve(sc: FastScanner) {
    val a = sc.nextLong()
    val b = sc.nextLong()
    val c = sc.nextLong()
    val d = sc.nextLong()
    println(calc(b, c, d) - calc(a - 1, c, d))
}

fun calc(b:Long, c:Long, d:Long):Long {
    return b - b / c - b / d + b / lcm(c, d)
}

fun main() {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}

Measured memory_bytes: 34424
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cassert>
#include <functional>
#include <string>
using namespace std;


int main(){
  int X, A, B; cin >> X >> A >> B;
  string ans = "delicious";
  if(B - A <= X){
    if(B - A <= 0){
      
    }else{
      ans = "safe";
    }
  }else{
    ans = "dangerous";
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

int n , K , cnt[26];

int main(){
  cin >> n >> K;
  rep(i,0,n) {
    string s;
    cin >> s;
    cnt[s[0] - 'A']++;
  }
  int ans = 0;
  while(true) {
    sort(cnt , cnt + 26);
    reverse(cnt , cnt + 26);
    int c = 0;
    rep(i,0,26) if(cnt[i]) {
      cnt[i]--;c++;
      if(c == K) break;
    }
    if(c == K) ans++;
    else break;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
import scala.io.StdIn.{readInt, readLine};
object Main {
    def main(args: Array[String]): Unit = {
        val n = readInt;
        val p = new Array[Int](n + 1);
        val first = readLine.split(" ").map(_.toInt);
        p(0) = first(0);
        p(1) = first(1);
        for (i <- (2 to n)) {
            val input = readLine.split(" ").map(_.toInt);
            p(i) = input(1);
        }
        val matrix = Array.ofDim[Int](n, n);
        for (i <- (0 until n); j <- (0 until n)) {if (i != j) matrix(i)(j) = Int.MaxValue}
        println(mcm(n, p, matrix));
    }

    def mcm(n: Int, p: Array[Int], matrix: Array[Array[Int]]): Int = {
        def _mcm(start: Int, end: Int): Int = {
            if (matrix(start)(end) < Int.MaxValue) {
                matrix(start)(end);
            } else {
                (start until end).foreach { i =>
                    val tmpMin = _mcm(start, i) + _mcm(i + 1, end) + (p(start) * p(i + 1) * p(end + 1));
                    if (tmpMin < matrix(start)(end)) {
                        matrix(start)(end) = tmpMin;
                    }
                }
            }
            matrix(start)(end);
        }
        _mcm(0, n - 1);
    }
}


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

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

    char a[10], b[10], c[10];

    // 引数の受け取り
    //
    cin >> a >> b >> c;
    a[0] -= 0x20;
    b[0] -= 0x20;
    c[0] -= 0x20;

    // 出力
    cout << a[0] << b[0] << c[0] << endl;
    return 0;
}



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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#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;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	return gcd(b, a%b);
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int t;
	cin >> t;
	REP(aaaa, t) {
		ll a, b, c, d;
		cin >> a >> b >> c >> d;
		ll g = gcd(b, d);
		if (a < b || d < b) {
			cout << "No" << endl;
			continue;
		}
		if (g == 1) {
			if (c+1>=b&&d>=b )cout << "Yes" << endl;
			else cout << "No" << endl;
		}
		else {
			ll k = a % b;
			ll s = (c - k+g) / g;
			ll m = s * g + k;
			if (m >= b && d >= b)cout << "Yes" << endl;
			else cout << "No" << endl;
		}
	}
}

Measured memory_bytes: 256