akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define endl "\n"
#define sz(x) ((ll)(x).size())
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define prt(x) cout << (x)
#define prtl(x) cout << (x) << endl
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define rrep(i,a,b) for(ll i=a; i>b; i--)
#define mp(a, b) make_pair(a, b)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define debug(v) cout << #v<< ": " << v <<endl;
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vc = vector<char>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using vvc = vector<vector<char>>;
using ll = long long int;
using P = pair<long long int, long long int>;
using Map = map<long long int, long long int>;
ll INF = 1LL<<60;
ll M = 1000000007;

int main(){
    ll a; cin >> a;
    if(a%1000 == 0){
        prtl(0);
    }else{
        ll g = a/1000;
        g++;
        prtl(g*1000 - a);
    }
}



Measured memory_bytes: 3584
/*input
2
1000000000 1000000000
*/
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define f first
#define s second
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
int const mod = 1e9+7;
int power(int x, int y, int mod = 2e18){ int ans = 1;x %= mod;while(y){if(y&1)ans = (x * ans) % mod;x = (x * x) % mod;y >>= 1;}return ans;}
int gcd(int a , int b){if(a==0)return b;return gcd(b%a,a);}

signed main() {
  IOS;
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  int pre[n];
  int las[n];
  int g = a[0];
  pre[0]=g;
  for(int i=1;i<n;i++){
    pre[i] = gcd(g,a[i]);
    g = gcd(g,a[i]);

  }
  g = a[n-1];
  las[n-1] = a[n-1];
  for(int i=n-2;i>=0;i--){
    las[i]=gcd(g,a[i]);
    g = gcd(g,a[i]);
  }
  int final_ans = g ;
  for(int i=1;i<n-1;i++)
    {
      final_ans = max(final_ans,gcd(pre[i-1],las[i+1]));
    }
  final_ans = max(final_ans,las[1]);
  final_ans = max(final_ans,pre[n-2]);
  cout << final_ans ; 
  
return 0;
}

Measured memory_bytes: 2560
#include "bits/stdc++.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x)  cerr<< #x <<" = "<< x<<endl;
using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
const int N=306;
ll ans=0,dis[N];
const ll B=1e13;
int arr[N][N],n;
vector<PII>adj[N];
int uzaklik(int x,int y){
	for(int i=1;i<=n;i++)
		dis[i]=B;
	dis[x]=0;queue<int>q;q.push(x);
	while(!q.empty()){
		int nd=q.front();
		q.pop();
		tr(it,adj[nd])
			if(umin(dis[it->ff],dis[nd]+it->ss))
				q.push(it->ff);
	}	
	return dis[y];
}
void merge(int w,int u,int v){
	int ret=uzaklik(u,v);
	if(ret<w){
		puts("-1");
		exit(0);
	}
	if(ret==w)
		return;
	ans+=w;	
	//~ cout<<u<<" "<<v<<" "<<w<<endl;
	adj[u].pb(mp(v,w));
	adj[v].pb(mp(u,w));
}
int main(){
    //~ freopen("file.in", "r", stdin);
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			scanf("%d",&arr[i][j]);

	vector<pair<int,PII> >edge;	
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++){
			edge.pb(mp(arr[i][j],mp(i,j)));
		}
	sort(all(edge));
	tr(it,edge)
		merge(it->ff,it->ss.ff,it->ss.ss);
	printf("%lld\n",ans);		
	return 0;
}


Measured memory_bytes: 1532
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if(a==5 && b==7 && c==5 || a==5 && b==5 && c==7 || a==7 && b==5 && c==5 )
        printf("YES\n");
    else
        printf("NO\n");
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  
  vector<vector<int>> a(n, vector<int>(2));
  for(int i = 0; i < n; i++){
    cin >> a.at(i).at(0);
    a.at(i).at(1) = i + 1;
  }
  
  sort(a.begin(), a.end());
  
  for(int i = 0; i < n; i++){
    if(i) cout << " ";
    cout << a.at(i).at(1);
  }
  cout << "\n";
}

Measured memory_bytes: 6272
#include <stdio.h>

#define STR_SIZE 51U
#define OFFSET 32U

int main(void) {
    int k, n;
    char s_in[STR_SIZE];

    scanf("%d %d", &n, &k);
    scanf("%s", s_in);

    s_in[k-1] += OFFSET;

    printf("%s\n", s_in);

	return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ll          long long
#define pb          push_back
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define rs(v,n)     v.resize(n)
#define hell        1000000007
#define peak        9123372036854775807
#define pii         acos(-1)
#define clr(a,x)    memset(a,x,sizeof(a))
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
template<class x,class y> x sum(x a,y b){return a+b;}
template<class x,class y> x mul(x a,y b){return a*b;}
template<class x,class y> x sub(x a,y b){return a-b;}
template<class x,class y> x divi(x a,y b){return a/b;}

template<class x,class y>
istream &operator>>(istream &in,pair<x,y> &p) 
{ 
    in>>p.F>>p.S;
    return in;
}
template<class x>
istream &operator>>(istream &in,vector<x> &v) 
{
    for(auto& i:v)
        in>>i;
    return in;
}
template<class x,class y>
ostream &operator<<(ostream &out,pair<x,y> &p) 
{ 
    out<<"("<<p.F<<","<<p.S<<") ";
    return out; 
}
template<class x>
ostream &operator<<(ostream &out,vector<x> &v) 
{ 
    out<<v.size()<<endl;
    for(auto i:v)
        out<<i<<" ";
    out<<endl;
    return out; 
}
#define N  1000005

int main()
{
    ios;
    ll tt=1;
    // cin>>tt;
    while(tt--)
    {
    	ll i,j,k,l,m,n;
    	cin>>n;
    	double y;
    	y=(2*pii*1.0*n);
    	cout<<setprecision(20)<<y;
    }
    return 0;
}

Measured memory_bytes: 3792
import java.util.Scanner;

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

    for(int i = 0; i < N; i++){
      int A = sc.nextInt();
    }
    System.out.println((N + K - 3) / (K - 1));
  }
}


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

int main() {
	int a=0, b=0, ab=0, o=0;
	int n;
	char d, e;
	while (scanf("%d,%c%c", &n, &d, &e) + 1) {
		if (d == 'A'&&e == 'B') { ab++; }
		else if (d == 'A') { a++; }
		else if (d == 'B') { b++; }
		else if (d == 'O') { o++; }
	}
	cout << a << endl << b << endl << ab << endl << o << endl;
	return 0;
}

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

int main(){
	int n;
	long long a,b,c1 = 1,c2 = 1;
	long long k1,k2;
	
	cin >> n;
	while(n--){
		k1 = k2 = 1;
		cin >> a >> b;
		if(a<c1){
			k1 = c1/a;
			if(c1%a) k1++;
		}
		if(b<c2){
			k2 = c2/b;
			if(c2%b) k2++;
		}
		k1 = max(k1,k2);
		c1 = a*k1;
		c2 = b*k1;
	}
	cout << c1+c2;
}

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

typedef long long ll;
typedef long double ld;
typedef double db;
int n;
int m;
bool vert[1000][1000];
bool vis[1000];
int d[1000];
int a[1000];
int sz=0;
bool bfs(int beg){
    int och[10000];
    och[0]=beg;
    d[beg]=1;
    vis[beg]=1;
    int j1=0;
    int j2=1;
    while(j1<j2){
        for(int i=0;i<n;i++){
            if(vert[och[j1]][i]==1){
                if(vis[i]==0){
                    vis[i]=1;
                    och[j2]=i;
                    j2++;
                }
                if(d[i]==d[och[j1]]) return 0;
                if(d[och[j1]]==1) d[i]=2;
                else d[i]=1;
            }
        }
        j1++;
    }
    int a1=0,b1=0;
    for(int i=0;i<j2;i++){
        if(d[och[i]]==1) a1++;
        else b1++;
    }
    a[sz]=abs(a1-b1);
    sz++;
    return 1;
} 
bool dost[10000];
bool dost1[10000];
int main()
{
    //ios_base::sync_with_stdio(false);
    //cout<<setprecision(20);
    
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int x_1,y;
        cin>>x_1>>y;
        x_1--;
        y--;
        vert[x_1][y]=1;
        vert[y][x_1]=1;
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(i!=j){
                if(vert[i][j]==1) vert[i][j]=0;
                else vert[i][j]=1;
            }
        }
    }
    for(int i=0;i<n;i++){
        if(vis[i]==0){
            bool s=0;
            s=bfs(i);
            if(s==0){
                cout<<"-1";
                return 0;
            }
        }
    }
    dost[0]=1;
    for(int j=0;j<sz;j++){
        for(int i=0;i<1000;i++){
            dost1[i]=0;
        }
        for(int i=0;i<1000;i++){
            if(dost[i]==1){
                dost1[abs(a[j]-i)]=1;
                dost1[abs(a[j]+i)]=1;
            }
        }
        for(int i=0;i<1000;i++){
            dost[i]=dost1[i];
        }
    }
    ll min=0;
    ll n1=n;
    while(dost[min]==0){
        min++;
    }
    ll a2=(n1-min)/2;
    ll b2=(n1+min)/2;
    ll ans=0;
    ans+=a2*(a2-1)/2;
    ans+=b2*(b2-1)/2;
    cout<<ans;
    return 0;
}

Measured memory_bytes: 896
// E.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>
#include <set>

using namespace std;

typedef long long LL;

int main(int argc, char* argv[]) {
	while (true) {
		LL n = -1;
		cin >> n;
		if (n <= 0) break;
		string s;
		cin >> s;
		int len = s.length();
		int ans = 0;
		for (int i = 1; i < len; ++i) {
			int c = 0;
			for (int j = 0; i + j <= len; ++j) {
				if (s[j] != s[i + j]) {
					c = 0;
				} else {
					++c;
					ans = max(ans, c);
					if (c >= i) {
						break;
					}
				}
			}

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


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


int insertionSort(std::vector<int>* a, int n, int g) {
  int cnt = 0;
  for (int i = g; i < n; ++i) {
    int v = (*a)[i];
    int j = i - g;
    while (j >= 0 && (*a)[j] > v) {
      (*a)[j + g] = (*a)[j];
      j = j - g;
      ++cnt;
    }
    (*a)[j + g] = v;
  }
  return cnt;
}

void shellSort(std::vector<int>* A, int n) {
  int cnt = 0;
  std::vector<int> G;
  int g = 1;
  G.push_back(g);
  while (1) {
    g = 3 * g + 1;
    if (g >= n)
      break;
    G.push_back(g);
  }
  for (int i = (int) G.size() - 1; i >= 0; --i) {
    cnt += insertionSort(A, n, G[i]);
  }
  std::cout << G.size() << std::endl;
  for (int i = (int) G.size() - 1; i >= 0; --i)
    std::cout << G[i] << (i == 0 ? "\n" : " ");
  std::cout << cnt << std::endl;
  for (int a : *A)
    std::cout << a << std::endl;
}

int main() {
  int n;
  std::cin >> n;
  std::vector<int> as;
  for (int i = 0; i < n; ++i) {
    int a;
    std::cin >> a;
    as.push_back(a);
  }
  shellSort(&as, n);
}

Measured memory_bytes: 6964
#include <stdio.h>
main(){
  int a[10],i=0,x=0,y=0,max,m2,m3;
  for(i=0;i<10;i++){
    scanf("%d",&a[i]);
 }
  max=a[0];
  for(i=0;i<10;i++){
    if(a[i]>max){max=a[i];
     x=i;
    }
  }

 m2=a[0];

 for(i=0;i<10;i++){
   if(i!=x&&a[i]==max){
     m2=a[i];
     y=i;
   }
   else if(a[i]>m2&&a[i]<max) {
     m2=a[i];
     y=i;
   }
  }

 m3=a[0];
 for(i=0;i<10;i++){
   if(i!=x&&i!=y&&a[i]==m2) m3=a[i];
   else if(a[i]>m3&&a[i]<max&&a[i]<m2) m3=a[i];
  }

printf("%d\n%d\n%d\n",max,m2,m3);
return 0; 
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  int S;
  int W;
  cin>>S;
  cin>>W;
  if(W >= S){
    cout<<"unsafe"<<'\n';
  }else{
    cout<<"safe"<<'\n';
  }
}

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

def main():
    N = int(input())
    h = list(map(int, input().split()))

    INF = 1 << 60

    dp = [INF] * 100010

    dp[0] = 0

    for i in range(N):
        if i + 1 < N:
            dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]))
        if i + 2 < N:
            dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]))

    print(dp[N - 1])


if __name__ == "__main__":
    main()


Measured memory_bytes: 20492
#include <bits/stdc++.h>
#include <string.h>
#include <vector>
//s#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX 10000

using namespace std;

#define inf    0x3f3f3f3f
#define ll long long
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a; i<n; i++)
#define INF (int)1e15
#define MOD 1000000007

#define access(i) a[i/3][i%3]

 int main(){

  double x;
  cin>>x;


  if(x == 0.0)
      cout<<"1"<<endl;
  else if(x == 1.0)
  cout<<"0"<<endl;

 return 0;
 }

Measured memory_bytes: 3776
#include <stdio.h>
#include <math.h>
#include<string.h>

int main(){
	int n, i, ans[10], j;
	while(scanf("%d", &n) != EOF){
		j = 0;
		for(i = 0; i < 10; i++) ans[i] = 0;
		for(i = 512; i > 0; i /= 2){
			if(n >= i){
				n -= i;
				ans[j] = i;
				if(n == 0) break;
				j++;
			}
		}
		for(i = j; i > 0; i--) printf("%d ", ans[i]);
		printf("%d\n", ans[0]);
	}
	return 0;
}

Measured memory_bytes: 596
# include<iostream>
# include<cstdio>
# include<map>
# include<stdlib.h>
# include<string>
# include<cstring>
using namespace std;
int n,lo,hi,l,r;
int ask(int x)
{
	printf("%d\n",x);
	fflush(stdout);
	char s[20];
	scanf("%s",s);
	if(s[0]=='V')
	  exit(0);
	return s[0]=='M';
}
int main(void)
{
	
	scanf("%d",&n);
	l=ask(0);
	lo=0;hi=n;r=l;
	while(lo<hi)
	{
		int mid=(lo+hi)/2;
		int m=ask(mid);
		if((mid-lo)%2!=(m^l))
		{
			hi=mid;
			r=m;
		}
		else
		{
			lo=mid;
			l=m;
		}
	}
	return 0;
}

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

typedef long long LL;

const int N=200,INF=(1<<30)-1;

int n;
char e[N+9][N+9];

void into(){
  scanf("%d",&n);
  for (int i=1;i<=n;++i)
	scanf("%s",e[i]+1);
}

int dis[N+9][N+9];

void Floyd(){
  for (int i=1;i<=n;++i)
	for (int j=1;j<=n;++j) dis[i][j]=i==j?0:e[i][j]=='0'?INF:1;
  for (int i=1;i<=n;++i)
	for (int j=1;j<=n;++j)
	  for (int k=1;k<=n;++k)
		if (dis[j][i]+dis[i][k]<dis[j][k]) dis[j][k]=dis[j][i]+dis[i][k];
}

int ans;

bool Check_ans(int st){
  for (int i=1;i<=n;++i)
	for (int j=1;j<=n;++j)
	  if (e[i][j]=='1'&&abs(dis[st][i]-dis[st][j])^1) return 0;
  return 1;
}

void Get_ans(){
  ans=-1;
  for (int i=1;i<=n;++i){
	if (!Check_ans(i)) continue;
	for (int j=1;j<=n;++j) ans=max(ans,dis[i][j]+1);
  }
}

void work(){
  Floyd();
  Get_ans();
}

void outo(){
  printf("%d\n",ans);
}

int main(){
  into();
  work();
  outo();
  return 0;
}

Measured memory_bytes: 4008
import sys,math,collections
from collections import defaultdict

#from itertools import permutations,combinations
	
def file():
	sys.stdin = open('input.py', 'r')
	sys.stdout = open('output.py', 'w') 
def get_array():
	l=list(map(int, input().split()))
	return l
def get_2_ints():	
	a,b=map(int, input().split())
	return a,b
def get_3_ints():	
	a,b,c=map(int, input().split())
	return a,b,c	
def sod(n):
	n,c=str(n),0
	for i in n:	
		c+=int(i)
	return c	

def getFloor(A, x):

	(left, right) = (0, len(A) - 1)

	floor = -1
	while left <= right:
		mid = (left + right) // 2
		if A[mid] == x:
			return A[mid]
		elif x < A[mid]:
			right = mid - 1
		else:
			floor = A[mid]
			left = mid + 1
			
	return floor
#file()	
def main():
	l,r,n=get_3_ints()
	c=0
	for i in range(min(l,r),max(l,r)+1):
		#print(i)
		if(i%n==0):
			c+=1
	print(c)		


                       

















				

			







            
			
































		








if __name__ == '__main__':
    main()


Measured memory_bytes: 9488
def getN():
    return int(input())


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


def getList():
    return list(map(int, input().split()))

n, k = getNM()
nums = getList()

bucket = [0 for i in range(200001)]
for num in nums:
    bucket[num] += 1

bucket.sort()
print(sum(bucket[:-k]))

Measured memory_bytes: 25856
#include<stdio.h>
int insertionSort(int[], int, int);
void shellSort(int[],int);

int main(){
  int n, i;
  int A[1000000];

  scanf("%d",&n);
  for( i = 0 ; i < n ; i++ ){
    scanf("%d",&A[i]);
  }

  shellSort(A, n);

  for( i = 0 ; i < n ; i++ ){
    printf("%d\n",A[i]);
  }

  return 0;
}

int insertionSort(int A[], int n, int g){
  int i, j, cnt=0, v;
  for( i = g ; i < n ; i++ ){
    v = A[i];
    j = i - g;
    while( j >= 0 && A[j] > v ){
      A[j+g] = A[j];
      j = j - g;
      cnt++;
    }
    A[j+g] = v;
  }
  return cnt;
}

void shellSort(int A[], int n){
  int i=0, m, cnt=0, a=1;
  int G[100];

  while(1){
    if( a > n ) break;
    G[i++] = a;
    a = 3 * a + 1;
  }
  m = i;

  printf("%d\n",m);
  for( i = m-1 ; i > 0 ; i-- ){
    printf("%d ",G[i]);
  }
  printf("%d\n",G[0]);

  for( i = m-1 ; i >= 0 ; i-- ){
    cnt += insertionSort(A, n, G[i]);
  }
  printf("%d\n",cnt);
}



Measured memory_bytes: 5612
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    double r;
    cin>>r;
    printf("%.10f\n", r * 2 * PI);
}

Measured memory_bytes: 3808
#include <iostream>
#include <algorithm>

using namespace std;

int n, k, h[200000];
long long res;

int main() {
    cin >> n >> k;
    for (int i = 0; i < n; ++i)
        cin >> h[i];
    sort(h, h + n);
    for (int i = 0; i < n - k; ++i)
        res += h[i];
    cout << res;
}

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

#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

using namespace std;

typedef long long ll;
typedef long double ld;



void solve() {
   int n, m;
   cin >> n >> m;
   vector<int> h(n);
   vector<int> maxi(n, -int(1e9) - 5);
   for (int i = 0; i < n; ++i) cin >> h[i];
    for (int i = 0; i < m; ++i) {
        int u, v;
        cin >> u >> v; --u; --v;
        maxi[u] = max(maxi[u], h[v]);
        maxi[v] = max(maxi[v], h[u]);
    }
    int cnt = 0;
    for (int i = 0; i < n; ++i) if (h[i] > maxi[i]) ++cnt;
        cout << cnt << endl;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}

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

int main() {
    string s, t;
    cin >> s >> t;
    int ans = 0;
    for (int i=0; i < s.size(); i++ ) {
        if (s[i] != t[i]) ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3856
extern "C"
{
#include <stdio.h>
}

void call(int n)
{
    int x = 0;
    for (int i = 1; i <= n; i++) {
        if (0 == i % 3) {
            printf(" %d", i);
        }
        else if (3 == i % 10) {
            printf(" %d", i);
        }
        else {
            x = i;
            while (x > 0) {
                x /= 10;
                if (3 == x % 10) {
                    printf(" %d", i);
                    break;
                }
            }
        }
        
        
    }
    putchar('\n');
}

int main()
{
    int val = 0;

    scanf("%d", &val);

    call(val);
}



Measured memory_bytes: 2768
/*
貪欲
後ろから見る
DP
順位表をチェック
二分探索


*/
#pragma GCC optimize("Ofast")
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include<tuple>
using namespace std;
#define INF 3e18+7
#define MAX 100000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;
//typedef pair<pair<int,int>,int> p;
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
struct edge{ll to,cost,val;};
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}
//__builtin_popcount(S);
//C.erase(unique(C.begin(),C.end()),C.end());

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

    int N;
    cin>>N;
    string S;
    cin>>S;
    int now=0;
    ll ans=1;
    for(int i=0;i<N*2;i++){
        if(S[i]=='W' && now%2==1 || (S[i]=='B' && now%2==0) ){
            now++;
        }else{
            ans*=now;
            ans%=MOD;
            now--;
        }
        if(now<0){
            cout<<0<<endl;
            return 0;
        }
    }
    if(now!=0){
        cout<<0<<endl;
        return 0;
    }
    for(int i=2;i<=N;i++){
        ans*=i;
        ans%=MOD;
    }
    cout<<ans<<endl;
}

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;
using vvs = vector<vs>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "{";
    rep(i, (int)v.size()) {
        if (i)
            os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
    for (auto val : array)
        std::cout << val << ", ";
    std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::setprecision(10);

    string s, t; std::cin >> s >> t;
    int ans = 0;
    rep(i, s.size()) {
        if (s[i] != t[i]) ans++;
    }
    std::cout << ans << "\n";
}


Measured memory_bytes: 3712
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include<set>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
#define all(x) (x).begin(),(x).end()
#define rep(i,m,n) for(int i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(int i = m;i >= n;--i)
#define INF INT_MAX-1
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;
const ll MOD = 1e9 + 7;
struct edge { ll from; ll to; ll cost; };


void err() {
	cout << "No" << endl;
	exit(0);
}


int main(){
	int h, w;
	cin >> h >> w;
	vector<int>cnt(26, 0);
	rep(i, 0, h) {
		string s;
		cin >> s;
		fore(c, s)cnt[c-'a']++;
	}

	if ((h*w) % 2 == 1) {
		rep(i, 0, 26) {
			if (cnt[i] % 2 == 1) {
				cnt[i]--;
				break;
			}
		}
	}

	rep(i, 0, 26) {
		if (cnt[i] % 2 == 1)err();
	}

	int k2 = 0;
	if (h % 2 == 1)k2 += w / 2;
	if (w % 2 == 1)k2 += h / 2;

	int have2 = 0;
	rep(i, 0, 26)have2 += (cnt[i]%4 == 2);

	if (have2 > k2)err();


	cout << "Yes" << endl;

	return 0;
}

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

int main(){
    int n;
    cin>>n;
    vector<int>a(n);
    ll sum=0,sum2=0,ans=1e18;
    rep(i,n){
        cin>>a[i];
        sum+=a[i];
    }
    rep(i,n){
        sum-=a[i];
        sum2+=a[i];
        ans=min(ans,abs(sum-sum2));
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

int stoi (string str )
{
	stringstream ss(str);
	int n;

	ss >>  n;

	return n;
}


int main()
{
//	cut here before submit 
//	freopen("testcase.diff2", "r", stdin);
	string str = "";
	int n;

	getline (cin, str );
	stringstream ssn(str);
	ssn >> n;

	int i;
	for (i = 0; i < n; ++i){
		getline (cin, str );
//		string org = str;
		sort (str.begin(), str.end() );
		string mins = str;
		sort (str.begin(), str.end(), greater<int>() );
		string maxs = str;
		int min = stoi (mins );
		int max = stoi (maxs );
		int res = max - min;
		cout << res << endl;
	} // end loop

		
	return 0;
}

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

using namespace std;

struct WordCount{
  string word;
  vector<int> page;
};

void PushWordCount(const string, const int, vector<WordCount>&);
bool Compare(const WordCount&, const WordCount&);

int main(){
  int Page;
  string Word;
  vector<WordCount> words;

  while(cin >> Word >> Page)
    PushWordCount(Word, Page, words);

  sort(words.begin(), words.end(), Compare);

  for(vector<WordCount>::size_type i=0; i != words.size(); ++i){
    cout << words[i].word << endl;
    sort(words[i].page.begin(), words[i].page.end());

    for(vector<int>::size_type j=0; j < words[i].page.size()-1; ++j)
      cout << words[i].page[j] << " ";
    cout << words[i].page[words[i].page.size()-1] << endl;
  }

  return 0;
}

void PushWordCount(const string Word, const int Page, vector<WordCount>& words){
  int isFound = 0;
  WordCount NewWord;
  vector<WordCount>::iterator iter = words.begin();

  while(iter != words.end()){
    if(iter->word == Word){
      isFound = 1;
      iter->page.push_back(Page);
      break;
    }
    ++iter;
  }
  
  if(isFound == 0){
    NewWord.word = Word;
    NewWord.page.push_back(Page);
    words.push_back(NewWord);
  }
}

bool Compare(const WordCount& x, const WordCount& y){
  return (x.word < y.word);
}

Measured memory_bytes: 0
#ifdef Prateek
  #include "Prateek.h"
#else
  #include <bits/stdc++.h>
  using namespace std;
  #define debug(...) 42
#endif
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
const int MOD = 1e9+7, N = 1e5 + 10; 

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int n,d;
   cin >> n >> d;
   int ans = 0;
   f(i,0,n){
      int x,y;
      cin >> x >> y;
      ans += (x*x+y*y <= d*d);
   }
   cout << ans << '\n';
   return 0;
}


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

int main() {
 int N  ;
  cin >> N ;
  vector<int> vec(N),ans(N);
    for (int i=0;i<N;i++){
      cin >>vec.at(i) ;
      }
   for(int i=0;i<N;i++){
    ans.at(vec.at(i)-1)=i+1;
   }
  for(int i=0;i<N;i++){
    cout << ans.at(i) <<' ';
  }
}

Measured memory_bytes: 1536
# encoding: utf-8
import sys
# input = sys.stdin.readline

N = int(input())
S = list(input())

w = [0] * (N + 1)
b = [0] * (N + 1)
wi = bi = 0
for i, Si in enumerate(S):
    if Si == '.': wi += 1
    else: bi += 1
    # print("#", i, wi, bi)
    w[i + 1] = wi
    b[i + 1] = bi

ans = N
for i in range(N + 1):
    ans_tmp = b[i] + (w[-1] - w[i])
    if ans > ans_tmp: ans = ans_tmp

print(ans)

Measured memory_bytes: 14180
x,y = map(int,input().split())
a = [1,3,5,7,8,10,12]
b = [4,6,9,11]
if x==2 and y == 2:
  print('Yes')
elif x in a and y in a:
  print('Yes')
elif x in b and y in b:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3060
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var L []int
var N, A, B, C int

func main() {
	s := wordScanner(100)
	scanInts(s, &N, &A, &B, &C)
	L = scanIntSlice(s, N)

	fmt.Println(dfs(N-1, 0, 0, 0))
}

func dfs(i, a, b, c int) int {
	if i < 0 {
		if min(a, b, c) == 0 {
			return 9999
		}
		return abs(A-a) + abs(B-b) + abs(C-c) - 30
	}
	r1 := dfs(i-1, a, b, c)
	r2 := dfs(i-1, a+L[i], b, c) + 10
	r3 := dfs(i-1, a, b+L[i], c) + 10
	r4 := dfs(i-1, a, b, c+L[i]) + 10
	return min(r1, r2, r3, r4)
}

func min(l ...int) int {
	r := l[0]
	for _, n := range l {
		if n < r {
			r = n
		}
	}
	return r
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func wordScanner(n int) *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)
	b := make([]byte, n)
	s.Buffer(b, n)
	return s
}

func scanInts(s *bufio.Scanner, vals ...*int) {
	for i := range vals {
		s.Scan()
		n, _ := strconv.Atoi(s.Text())
		*vals[i] = n
	}
}

func scanIntSlice(s *bufio.Scanner, n int) []int {
	vals := make([]int, n)
	for i := range vals {
		s.Scan()
		m, _ := strconv.Atoi(s.Text())
		vals[i] = m
	}
	return vals
}


Measured memory_bytes: 640
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

const (
	initialBufSize = 1024
	maxBufSize     = 1e6
)

var (
	scanner = bufio.NewScanner(os.Stdin)
)

func main() {
	scanner.Split(bufio.ScanWords)
	n := scanInt()

	for ; ; n++ {
		if isPrimeNum(n) {
			fmt.Println(n)
			return
		}
	}
}

func isPrimeNum(n int) bool {

	if n <= 1 {
		return false
	}

	l := int(math.Sqrt(float64(n)) + 1.)
	for i := 2; i < l; i++ {
		if n%i == 0 {
			return false
		}
	}

	return true
}

func scanInt() int {
	i, _ := strconv.Atoi(scanText())
	return i
}

func scanInts(size int) []int {
	ints := make([]int, size)
	for i := 0; i < size; i++ {
		ints[i] = scanInt()
	}
	return ints
}

func scanFloat64() float64 {
	f, _ := strconv.ParseFloat(scanText(), 64)
	return f
}

func scanFloat64s(size int) []float64 {
	f := make([]float64, size)
	for i := 0; i < size; i++ {
		f[i] = scanFloat64()
	}
	return f
}

func scanText() string {
	scanner.Scan()
	return scanner.Text()
}

func scanTexts(size int) []string {
	s := make([]string, size)
	for i := 0; i < size; i++ {
		s[i] = scanText()
	}
	return s
}

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}

func pow(x, y int) int {
	return int(math.Pow(float64(x), float64(y)))
}

// greatest common divisor(最大公約数)
func gcd(a, b int) int {
	for {
		mod := a % b
		if mod == 0 {
			return b
		}
		a, b = b, mod
	}
}

// latest common multiple(最小公倍数)
func lcm(a, b int) int {
	return (a / gcd(a, b)) * b
}

func fact(n int) int {
	ret := 1
	for i := 1; i <= n; i++ {
		ret *= i
	}
	return ret
}


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

int hash(string s)
{
	if (s == "A") return 0;
	if (s == "B") return 1;
	if (s == "AB") return 2;
	if (s == "O") return 3;
}

int main()
{
	int type[4] = {0};
	int i;
	string s;
	char c;

	while (cin>>i>>c>>s)
		type[hash(s)]++;

	for (i = 0; i < 4; i++)
		cout<<type[i]<<endl;

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#ifdef LOCAL_DEBUG
#define DEBUG 1
#define CERR if(DEBUG) cerr
#define MACRO(_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,NAME,...) NAME
#define pr(...) CERR<<MACRO(__VA_ARGS__,pr10,pr9,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)<<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define pr9(a,b,c,d,e,f,g,h,i) pr1(a)<<pr8(b,c,d,e,f,g,h,i)
#define pr10(a,b,c,d,e,f,g,h,i,j) pr1(a)<<pr9(b,c,d,e,f,g,h,i,j)
#define prArr(a){CERR<<(#a)<<"={";int i=0;for(auto t:(a))CERR<<(i++?", ":"")<<t;CERR<<"}"<<endl;}
#else
#define DEBUG 0
#define pr(...)
#define prArr(a)
#endif
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE

template<typename T>
class CumulativeSum{
public:
  Int n;
  vector<T> sum;
  vector<T> A;
  Int added;
  CumulativeSum():n(-1),added(0){}
  CumulativeSum(Int n):n(n), sum(n+1), A(n+1),added(0){}
  CumulativeSum(const vector<T> &B):n(B.size()), sum(n+1), A(n+1),added(0){
    for(Int i=1;i<=n;i++) sum[i] = sum[i-1] + B[i-1];
  }

  void apply(){
    for(Int i=1;i<=n;i++) A[i] = A[i] + A[i-1];
    for(Int i=1;i<=n;i++) A[i] = A[i] + A[i-1];
    for(Int i=1;i<=n;i++) sum[i] = sum[i] + A[i-1];
    added = 0; A.clear(); A.resize(n+1);
  }

  //[l, r)にxを加算
  void add(Int l, Int r, T x){
    added = 1;
    assert(l <= r && 0 <= l && r <= n);
    A[l] = A[l] + x;
    A[r] = A[r] - x;
  }

  //[l, r)の和を得る
  T get(Int l,Int r){
    assert(l<=r && 0<=l && r<=n);
    if(added) apply();
    return sum[r] - sum[l];
  }
};


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  Int K, N;
  cin>>K>>N;
  vector<Int> A(N);
  cin>>A;

  Int ans = K - (K - A[N-1]) - A[0];
  for(Int i=0;i<N-1;i++){
    Int len = K - (A[i + 1] - A[i]);
    Min(ans, len);
  }

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


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;
typedef long long ll;

int main(){
  int A,B,H,M;
  cin >> A >> B >> H >> M;
  double theta = abs(H*30+M/2.0-6.0*M);
  double ans = sqrt(A*A+B*B-2*A*B*cos(theta/180.0*M_PI));
  printf("%.20f\n",ans);
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
char a[5];
int main()
{
	cin>>a;
	if(a[2]=='E')cout<<5<<endl;
	if(a[2]=='D')cout<<4<<endl;
	if(a[2]=='U')cout<<3<<endl;
	if(a[2]=='I')cout<<2<<endl;
	if(a[2]=='T')cout<<1<<endl;
	if(a[2]=='N')
	{
		if(a[1]=='O')cout<<6<<endl;
		if(a[1]=='U')cout<<7<<endl;
	}
	return 0;
} 

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

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " : " << x << '\n'

using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;

const ll Mod = 1000000007LL;
const int N = 2e5 + 10;
const ll Inf = 2242545357980376863LL;
const ll Log = 30;

vector< pair<pll, ll> > E;
int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll n = 20;
	ll L;
	cin >> L;
	for(int i = 1; i < 20; i++){
		E.pb({{i, i + 1}, 0});
		if(L == 1) continue;
		if(L & 1){
			L--;
			E.pb({{i, n}, L});
		}
		if(L){
			E.pb({{i, i + 1}, L / 2});
			L /= 2;
		}
	}


	cout << "20 " << E.size() << '\n';
	for(auto x : E) cout << x.F.F << ' ' << x.F.S << ' ' << x.S << '\n'; 
	return 0;
}


Measured memory_bytes: 256
s=input()
n=len(s)
def dfs(i,f):
    if i==n-1:
        return sum(list(map(int,f.split("+"))))
    return dfs(i+1,f+s[i+1])+dfs(i+1,f+"+"+s[i+1])
print(dfs(0,s[0]))

Measured memory_bytes: 38896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
using Graph = vector<vector<int>>;
using Graphl = vector<vector<ll>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define FOR(itr, v) for (auto itr = (v).begin(); itr != (v).end(); ++itr)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a)  (a).rbegin(),(a).rend()
#define ERASE(a)  (a).erase(unique((a).begin(), (a).end()), (a).end()); // sortしてから
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; }
template<class T> void PrintVector(const vector<T> &vec) {for (auto val : vec) cout << val << " "; cout << endl;}
const long long INF = 1LL << 60;
const long long minusINF = -(1LL << 40);
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    int n; cin >> n;
    vector<ll> a(n);
    ll tmp = 0;
    rep(i, n)
    {
        cin >> a[i];
        tmp ^= a[i];
    }
    rep(i, n)
    {
        ll ans = tmp ^ a[i];
        cout << ans << " ";
    }
    cout << endl;
}

Measured memory_bytes: 4844
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>

using namespace std;



int main() {
	
	int h, w;
	cin >> h >> w;

	vector<string> s(50);

	for (int i = 0; i < h; i++) {
		cin >> s.at(i);
	}

	vector<int> x{ 1, 0, -1, 1, 0, -1, 1, -1 };
	vector<int> y{ 1, 1, 1, -1, -1, -1, 0, 0 };

	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (s.at(i).at(j) == '#') continue;

			int dx;
			int dy;
			int num = 0;
			for (int k = 0; k < 8; k++) {
				dx = x.at(k);
				dy = y.at(k);


				int a = i + dx;
				int b = j + dy;

				if (a >= h || a < 0) continue;
				if (b >= w || b < 0) continue;
				if (s.at(a).at(b) == '#') ++num;
			}
			s.at(i).at(j) = char(num + '0');
		}
	}

	for (int i = 0; i < h; i++) {
		cout << s.at(i) << endl;
	}

	return 0;
}

Measured memory_bytes: 3612
import std.stdio, std.string, std.conv, std.range, std.array, std.algorithm;
import std.uni, std.math, std.container, std.typecons, std.typetuple;
import core.bitop, std.datetime;

void main(){
    int N, W, vi, wi;
    readVars(N, W);

    auto v = new int[](N);
    auto w = new int[](N);

    foreach(i ; 0 .. N){
        readVars(vi, wi);
        v[i] = vi;
        w[i] = wi;
    }

    auto memo = new int[][](N + 1, W + 1);

    foreach(i ; 0 .. N + 1){
        memo[i][] = -1;
    }

    int ans = memorec(N, v, w, memo, 0, W);

    writeln(ans);
}

int memorec(int N, int[] v, int[] w, int[][] memo, int i, int u){
    if (memo[i][u] != -1) {
        return memo[i][u];
    }
    else if (i == N || u == 0) {
        memo[i][u] = 0;
        return memo[i][u];
    }
    else {
        memo[i][u] = memorec(N, v, w, memo, i + 1, u);

        if (u - w[i] >= 0) {
            memo[i][u] = max(memo[i][u], memorec(N, v, w, memo, i + 1, u - w[i]) + v[i]);
        }

        return memo[i][u];
    }
}

void readVars(T...)(auto ref T args){
    auto line = readln.split;
    foreach(ref arg ; args){
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    if(!line.empty){
        writeln(line);
        throw new Exception("args num < input num");
    }
}

Measured memory_bytes: 6600
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
#include <list>
#include <ctime>
#include <numeric>
using namespace std;
static const double EPS = 1e-8;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PI;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SZ(a) (int(a.size()))
#define F first
#define S second
const double pi=acos(-1);
int dx[]={0,1,0,-1,1,1,-1,-1},dy[]={1,0,-1,0,1,-1,1,-1};



main(){
  int n;
  while(cin>>n,n){
    string mes;
    cin>>mes;
    vector<PI> in;
    rep(i,n){
      int a,b;
      cin>>a>>b;
      in.pb(mp(a-1,b-1));
    }
    reverse(ALL(in));
    FOR(it,in){
      int a=it->F,b=it->S;
      swap(mes[a],mes[b]);
      mes[a]='a'+(mes[a]-'a'+abs(a-b))%26;
      mes[b]='a'+(mes[b]-'a'+abs(a-b))%26;      
    }
    cout<<mes<<endl;
  }
}

Measured memory_bytes: 0
import java.util.Scanner;

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

    public Main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        sc.close();
        String stra = a(a, b);
        String strb = a(b, a);
        System.out.print(stra.compareTo(strb) > 0 ? strb:stra);
    }

    String a(int a, int b) {
        String str1 = String.valueOf(a);
        StringBuilder str2 = new StringBuilder();
        for (int i=0;i<b;i++) {
            str2.append(str1);
        }
        return str2.toString();
    }
}

Measured memory_bytes: 23892
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader input =new BufferedReader (new InputStreamReader (System.in));
		String str = input.readLine( );
		String[] strlist = str.split(" ");
		int h = Integer.parseInt(strlist[0]);
		String[] list = new String[h];

		for(int i=0; i<h; i++){
			list[i] = input.readLine();
			System.out.println(list[i]);
			System.out.println(list[i]);
		}

	}

}


Measured memory_bytes: 9168
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] dp = new int[n];
		int[] frog = new int[n];
		for(int i=0; i<n; i++) {
			frog[i] = sc.nextInt();
		}
		for(int i=1; i<n; i++) {
			dp[i] = Integer.MAX_VALUE;
		}
		for(int i=0; i<n; i++) {
			for(int j=i+1; j<i+k+1; j++) {
				if(j<n) dp[j] = Math.min(dp[j],dp[i]+ Math.abs(frog[i]-frog[j]));
			}
		}
		System.out.println(dp[n-1]);

	}

}


Measured memory_bytes: 50384
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
    ll N;
    cin>>N;
    string s;
    cin>>s;
    if(N%2==0)
    {
        for(ll i=0;i<N/2;i++)
        {
            if(s[i]!=s[N/2+i])
            {
                cout<<"No";
                return 0;
            }
        }
        cout<<"Yes";
    }
    else
        cout<<"No";
	return 0;
}

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

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

using namespace std;

int main(){

 ll int H,A;
 cin >> H >> A;

 if(H%A == 0){
	 cout << H/A;
 }
 else{
	 cout << H/A + 1;
 }











	return 0;

}



Measured memory_bytes: 256
N, K, Q = map(int, input().split())
point = [0] * N

for i in range(Q):
    point[int(input()) - 1] += 1
    i += 1

sum_point = sum(point)

for i in range(N):
    ans = K - (sum_point - point[i])
    if ans > 0:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 4680
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp2
{

    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] d = Console.ReadLine().Split().Select(int.Parse).ToArray();

            int ans = 0;

            for (int i = 0; i<N; i++)
            {
                for(int j = i+1; j<N; j++)
                {
                    ans += d[i] * d[j];
                }
            }
            Console.WriteLine(ans);
        }
    }
}


    




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

int main(void){
    int N, D;
    cin >> N >> D;
    int n = N / (2*D+1) ;
    if (n*(2*D+1)==N)
        cout << n << endl;
    else
        cout << n+1 << endl;
}


Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
        n: usize,
        mut a: [i64; n],
    };
    a.sort();
    let mut a = a.into_iter().collect::<std::collections::VecDeque<i64>>();
    let mut b = std::collections::VecDeque::<i64>::new();
    b.push_front(a.pop_front().unwrap());
    b.push_back(a.pop_back().unwrap());
    while !a.is_empty() {
        let a_f = *a.front().unwrap();
        let a_b = *a.back().unwrap();
        let b_f = *b.front().unwrap();
        let b_b = *b.back().unwrap();
        let v_afbf = (a_f - b_f).abs();
        let v_abbf = (a_b - b_f).abs();
        let v_afbb = (a_f - b_b).abs();
        let v_abbb = (a_b - b_b).abs();
        if v_afbf >= v_abbf && v_afbf >= v_afbb && v_afbf >= v_abbb {
            b.push_front(a.pop_front().unwrap());
        } else if v_abbf >= v_afbf && v_abbf >= v_afbb && v_abbf >= v_abbb {
            b.push_front(a.pop_back().unwrap());
        } else if v_afbb >= v_afbf && v_afbb >= v_abbf && v_afbb >= v_abbb {
            b.push_back(a.pop_front().unwrap());
        } else if v_abbb >= v_afbf && v_abbb >= v_abbf && v_abbb >= v_afbb {
            b.push_back(a.pop_back().unwrap());
        } else {
            unreachable!();
        }
    }

    let ans = b
        .iter()
        .enumerate()
        .skip(1)
        .map(|(i, &b_i)| (b_i - b[i - 1]).abs())
        .sum::<i64>();
    println!("{}", ans);
}


Measured memory_bytes: 5240
<?php
  $c[] = explode(" ",trim(fgets(STDIN)));
  $c[] = explode(" ",trim(fgets(STDIN)));
  $c[] = explode(" ",trim(fgets(STDIN)));
 
  for($i=0; $i<3; $i++){
      if($i==0){
          $p = $c[$i][$i];
          for($j=1; $j<3; $j++){
              $w[$j] = $c[$i][$j]-$p;
              $h[$j] = $c[$j][$i]-$p;
          }
          continue;
      }
      foreach($w as $j => $s){
          if($s != $c[$i][$j]-$c[$i][0]){
              echo "No";
              exit;
          }
      }
      foreach($h as $j => $s){
          if($s != $c[$j][$i]-$c[0][$i]){
              echo "No";
              exit;
          }
      }
  }
  echo "Yes";

Measured memory_bytes: 4604
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using ll = long long;
using namespace std;

int main() {
    int a, b;
    char x[110][110];
    
    cin >> a >> b;
    a--, b--;
    for(int i=1; i<=50; i++){
        for(int j=1; j<=100; j++){
            x[i][j] = '.';
        }
    }
    for(int i=51; i<=100; i++){
        for(int j=1; j<=100; j++){
            x[i][j] = '#';
        }
    }
    for(int i=1; i<=50 && b; i+=2){
        for(int j=1; j<=100 && b; j+=2){
            x[i][j] = '#';
            b--;
        }
    }
    for(int i=100; i>=51 && a; i-= 2){
        for(int j=1; j<=100 && a; j+=2){
            x[i][j] = '.';
            a--;
        }
    }
    
    cout << "100 100" << endl;
    for(int i=1; i<=100; i++){
        for(int j=1; j<=100; j++){
            cout << x[i][j];
        }
        cout << endl;
    } 
}


Measured memory_bytes: 256
def solve():
  n,t = (int(i) for i in input().split())
  a = list(int(i) for i in input().split())
  query = [-1]
  querymax = -1
  minA = a[0]
  for i in range(1,n):
    if minA < a[i]:
      if querymax <= a[i]-minA:
        querymax = a[i]-minA
        query.append(a[i]-minA)
    
    
    minA = min(minA,a[i])
  print(query.count(max(query)))
    
solve()


Measured memory_bytes: 14252