akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <algorithm>
typedef long long ll;

const int N = 200005, P = 1000000007;
int n, Ans = 1, Res;
int Head[N], Next[N << 1], To[N << 1], Val[N << 1], En;
int Vis[N], Sta[N], Top, w[N], f, a, b, c, s[N];

ll Inv(ll a, ll s = 1) { for (int b = P - 2; b; b >>= 1, a = a * a % P)if (b & 1)s = s * a % P; return s % P; }
inline void Add(int x, int y, int z) { Next[++En] = Head[x], To[Head[x] = En] = y, Val[En] = z; }

void DFS1(int x, int Fa)
{
	Vis[x] = 2, Sta[++Top] = x;
	for (int i = Head[x], y; i; i = Next[i])
		if ((y = To[i]) != Fa)
		{
			if (Vis[y] == 2)
			{
				a = x, b = y, c = Val[i], ++f;
				int Ts = Top;
				do if (w[--Ts] > c)a = Sta[Ts], b = Sta[Ts + 1], c = w[Ts];
				while (Sta[Ts] != y);
			}
			else if (!Vis[y])w[Top] = Val[i], DFS1(y, x);
		}
	Vis[x] = 1, --Top;
}

void DFS2(int x, int Fa, int w)
{
	s[x] = 1;
	for (int i = Head[x], y; i; i = Next[i])
		if ((y = To[i]) != Fa && y != a && (x != a || y != b))
			if (DFS2(y, x, Val[i]), Val[i] < w)
				s[x] += s[y];
	Res = Res * Inv(s[x]) % P;
}

int main()
{
	scanf("%d", &n), n <<= 1;
	for (int i = 1, x, y; i <= n; ++i)scanf("%d%d", &x, &y), Add(x, y + n / 2, x + y), Add(y + n / 2, x, x + y);
	for (int i = 1; i <= n; ++i)Ans = (ll)Ans * i % P;
	for (int i = 1, Tmp; i <= n; ++i)
		if (!Vis[i])
		{
			f = 0, DFS1(i, 0);
			if (f != 1)return puts("0"), 0;
			Res = 1, DFS2(a, 0, c);
			Tmp = Res, std::swap(a, b);
			Res = 1, DFS2(a, 0, c);
			Ans = Ans * ll(Tmp + Res) % P;
		}
	printf("%d\n", Ans);
	return 0;
}

Measured memory_bytes: 13312
#include <iostream>                                             
#include <cstring>                                              
using namespace std;                                            
                                                                
int main() {                                                    
  int r, c;                                                     
  cin >> r >> c;                                                
  int rc[r+1][c+1];                                             
  memset(rc,0,sizeof(rc));                                      
  for (int i=0; i<r; i++) {                                     
    for (int j=0; j<c; j++) {                                   
      cin >> rc[i][j];                                          
    }                                                           
  }                                                             
  for (int i=0; i<r; i++) {                                     
    for (int j=0; j<c; j++) {                                   
      rc[i][c] += rc[i][j];                                     
      rc[r][j] += rc[i][j];                                     
    }                                                           
    rc[r][c] += rc[i][c];                                       
  }                                                             
  for (int i=0; i<r+1; i++) {                                   
    for (int j=0; j<c+1; j++) {                                 
      cout << ((i>=0 && j==0)?"":" ") << rc[i][j] << flush;     
    }                                                           
    cout << endl;                                               
  }                                                             
  return 0;                                                     
}                                                               
                             

Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define itn int
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(n);i++)
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
bool prime(int p){
	for(int i=2;i<=sqrt(p);i++){
		if(!p%i)return false;
	}
	return true;
}
signed main(){
	string s;
	cin>>s;
	bool a,b;
	if(s.size()%2)b=true;
	else b=false;
	if(s[0]==s[s.size()-1])a=true;
	else a=false;
	if(a==b)cout<<"Second"<<endl;
	else cout<<"First"<<endl;
	return 0;
}

Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		char[] c = sc.next().toCharArray();
		if(c[2] == c[3] && c[4] == c[5]) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
	
	static class FastScanner {
		private BufferedReader reader = null;
	    private StringTokenizer tokenizer = null;
	    public FastScanner(InputStream in) {
	        reader = new BufferedReader(new InputStreamReader(in));
	        tokenizer = null;
	    }

	    public String next() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                tokenizer = new StringTokenizer(reader.readLine());
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }
	        return tokenizer.nextToken();
	    }

	    public String nextLine() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                return reader.readLine();
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }

	        return tokenizer.nextToken("\n");
	    }

	    public long nextLong() {
	        return Long.parseLong(next());
	    }

	    public int nextInt() {
	        return Integer.parseInt(next());
	    }

	    public double nextDouble() {
	         return Double.parseDouble(next());
	     }

	    public int[] nextIntArray(int n) {
	        int[] a = new int[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextInt();
	        return a;
	    }

	    public long[] nextLongArray(int n) {
	        long[] a = new long[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextLong();
	        return a;
	    }
	}
}

Measured memory_bytes: 23124
n,m = map(int,input().split())
students = [list(map(int,input().split())) for _ in range(n)]
points = [list(map(int,input().split())) for _ in range(m)]
distinations = []
for i in range(n):
  point = -1
  dist = float("INF")
  x1 = students[i][0]
  y1 = students[i][1]
  for j in range(m):
    x2 = points[j][0]
    y2 = points[j][1]
    temp_dist = abs(x1 - x2) + abs(y1 - y2)
    if temp_dist < dist:
      dist = temp_dist
      point = j + 1
  distinations.append(point)
for d in distinations:
  print(d)

Measured memory_bytes: 3064
use v5.18;
use warnings;
use constant MOD => 1e9 + 7;
use List::Util qw( min );

my ($n, $m) = glob <>;
my %broken_stairs_map = map { $_ => 1 } map { chomp(my $stair = <>); $stair } 0 .. $m - 1;
my @dp = (1);
for my $now (0 .. $n - 1) {
    for (my $next = $now + 1; $next <= min($n, $now + 2); $next++) {
        unless (exists $broken_stairs_map{$next}) {
            $dp[$next] += $dp[$now] // 0;
            $dp[$next] %= MOD;
        }
    }
}
say $dp[$n];

Measured memory_bytes: 36864
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    scanf("%d", &n);
    int ans = 0;
    for(int x = 1; x <= n; x++){
        int sum = 0;
        for(int i = 1; i <= x; i++){
            if(x%i == 0){
                sum ++;
            }
        }
        if(sum == 8 && x%2) ans++;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

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

    int next = 1;
    int del = 0;
    for (int i = 0; i < n; i++)
    {
        if (a[i] == next)
        {
            next++;
        }
        else
        {
            del++;
        }
    }

    if (del == n)
    {
        del = -1;
    }

    cout << del << endl;

    return 0;
}

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

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

    const int NMMAX = 50;
    int A[NMMAX], B[NMMAX];

    for (int i = 0; i < M; i++) {
        cin >> A[i] >> B[i];
    }

    int road[NMMAX];
    for (int i = 0; i < N; i++) {
        road[i] = 0;
    }

    for (int i = 0; i < M; i++) {
        road[A[i] - 1] += 1;
        road[B[i] - 1] += 1;
    }

    for (int i = 0; i < N; i++) {
        cout << road[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int m,f,r;
        String rate="";
        while(true){
            m=sc.nextInt();
            f=sc.nextInt();
            r=sc.nextInt();
            if(m==-1 && f==-1 && r==-1){
                break;
            }else if(m==-1 || f==-1){
                rate="F";
            }else if(m+f>=80){
                rate="A";
            }else if(m+f>=65 && m+f<80){
                rate="B";
            }else if(m+f>=50 && m+f<65){
                rate="C";
            }else if(m+f>=30 && m+f<50){
                if(r>=50){
                    rate="C";
                }else{
                    rate="D";
                }
            }else if(m+f<30){
                rate="F";
            }
            System.out.println(rate);
        }
    }
}


Measured memory_bytes: 26184
import sys
input = lambda: sys.stdin.buffer.readline()

L = 26
D = int(input())
C = list(map(int, input().split()))
S = [list(map(int, input().split())) for _ in range(D)]

T = [int(input()) for _ in range(D)]

M = int(input())

class BinaryIndexedTree:
    def __init__(self, n):
        self.n = n
        self.data = [0] * (self.n+1)
    
    def sum(self, i):
        res = 0
        while i > 0:
            res += self.data[i]
            i -= i & -i
        return res
    
    def add(self, i, x):
        if i <= 0: raise IndexError
        while i <= self.n:
            self.data[i] += x
            i += i & -i
    
    def lower_bound(self, x):
        if x <= 0: return 0
        cur, s, k = 0, 0, 1 << (self.n.bit_length()-1)
        while k:
            nxt = cur + k 
            if nxt <= self.n and s + self.data[nxt] < x:
                s += self.data[nxt]
                cur = nxt
            k >>= 1
        return cur + 1

def rsum(x):
    return x*(x+1)//2

b = [BinaryIndexedTree(D) for _ in range(L)]

score = 0
for d, cont in enumerate(T):
    cont -= 1
    b[cont].add(d+1, 1)
    score += S[d][cont]

for i in range(L):
    m = b[i].sum(D)
    tmp = 0
    s = [0]
    for j in range(1, m+1):
        s.append(b[i].lower_bound(j))
    s.append(D+1)

    for j in range(len(s)-1):
        x = s[j+1] - s[j] - 1
        tmp += rsum(x)
    
    score -= tmp*C[i]


def chg(d, q):
    diff = 0
    p = T[d]-1
    d += 1

    o = b[p].sum(d)
    d1 = b[p].lower_bound(o-1)
    d2 = b[p].lower_bound(o+1)

    diff += rsum(d-d1) * C[p]
    diff += rsum(d2-d) * C[p]
    diff -= rsum(d2-d1) * C[p]

    o = b[q].sum(d)
    d1 = b[q].lower_bound(o)
    d2 = b[q].lower_bound(o+1)

    diff += rsum(d2-d1) * C[q]
    diff -= rsum(d-d1) * C[q]
    diff -= rsum(d2-d) * C[q]

    b[p].add(d, -1)
    b[q].add(d, 1)

    d -= 1
    T[d] = q+1
    diff -= S[d][p]
    diff += S[d][q] 

    return diff

for _ in range(M):
    d, q = map(lambda x: int(x)-1, input().split())
    diff = chg(d, q)
    score += diff
    print(score)


Measured memory_bytes: 75456
package main

import (
	"fmt"
)

func main() {
	var n, x, ans int
	fmt.Scan(&n)
	var s string
	fmt.Scan(&s)
	for i := 0; i < n; i++{
		if s[i] == 'I'{
			x++
		} else {
			x--
		}
		ans = max(ans, x) 
	}
	fmt.Println(ans)
}

func max(a, b int) int {
	if a > b{
		return a
	} else {
		return b
	}
}


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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, k;
    cin >> n >> k;

    vector<long long> a(n);
    long long mul = 1;
    for (int i = 0; i < n; i++){
        cin >> a[i];
        
        if (i < k)
            mul *= a[i];
    }

    for (int i = k; i < n; i++){
        if (a[i - k] >= a[i])
            cout << "No\n";
        else
            cout << "Yes\n";
    }

    return 0;
}


Measured memory_bytes: 4780
mod = 998244353
N = int(input())
D = list(map(int,input().split()))
from collections import Counter
if D[0] != 0 or 0 in D[1:]:
    print(0)
else:
    dc1 = Counter(D[1:])
    dc = [0 for i in range(max(D))]
    for k,v in dc1.items():
        dc[k-1] = v
    ans = 1
    for i in range(1,len(dc)):
        if dc[i] == 0:
            ans = 0
            break
        ans = (ans*(dc[i-1]**dc[i]))%mod
    print(ans)

Measured memory_bytes: 20576
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int X, Y; cin >> X >> Y;
  int ans = X+Y/2;
  cout << ans << endl;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> min_cnt(26, 51);
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    vector<int> cnt(26, 0);
    for (int j = 0; j < s.size(); j++) {
      int pos = (int)(s[j] - 'a');
      cnt[pos]++;
    }
    for (int j = 0; j < 26; j++) {
      min_cnt[j] = min(min_cnt[j], cnt[j]);
    }
  }

  string ans = "";
  for (int i = 0; i < 26; i++) {
    if (min_cnt[i] < 51) {
      for (int j = 0; j < min_cnt[i]; j++) {
        ans += (char)('a' + i);
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int n;
    cin>>n;
    vector<long> a(n);
    rep(i,n) cin>>a[i];
    int ans=0;
    rep(i,n){
        while(i<n-1&&a[i]==a[i+1]) i++;
        if(a[i]<a[i+1]) while(i<n-1&&a[i]<=a[i+1]) i++;
        else if(a[i]>a[i+1]) while(i<n-1&&a[i]>=a[i+1]) i++;
        ans++;
    }
    cout<<ans;
}

Measured memory_bytes: 3940
N = int(input())
H = list(map(int, input().split()))

dp = [0]*N

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

print(dp[-1])


Measured memory_bytes: 13928
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define int ll
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define endl "\n"
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define rev(a) (a).rbegin(),(a).rend()
#define pll pair<ll,ll>
#define rep(i,a,b) for(long long i = (a); i < (b); i++)
#define derep(i,a,b) for(long long i = (a); i>=(b); i--)
ll modi = 1000000007;

bool cp(ll n){
    if(n == 1)return false;
    else if(n == 2)return true;
    else if(n ==3)return true;
    for(int i  = 2; i*i<=n; i++){
        if(n%i == 0){
            return false;
        }
    }
    return true;
}
void SforPrime(int n)
{
	bool prime[n+1];
	memset(prime, true, sizeof(prime));

	for (int p=2; p*p<=n; p++)
	{
		if (prime[p] == true)
		{
			for (int i=p*p; i<=n; i += p)
				prime[i] = false;
		}
	}
}
ll calPower(ll val, ll n){
    ll i = 1;
    ll ind = 1;
    ll prev = val;
    while(val<=n){
        if(n%val == 0)ind = i;
        val  = val*prev;
        i++;
    }
    return i-1;
}
int32_t main(){
    //130016239756757
    string s;
    cin>>s;
    if(s[2] == s[3] && s[4] == s[5])cout<<"Yes";
    else cout<<"No";
}

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

count = [0 for __ in range(N)]
Nl = [i for i in range(1,N+1)]

for i,n in enumerate(Nl):
    while n%2==0:
        n /= 2
        count[i] += 1
idx = count.index(max(count))
print(Nl[idx])

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

int main(){
    using namespace std;
    constexpr unsigned long MOD = 1000000007;
    unsigned long N, K;
    cin >> N >> K;
    if(N == K){
        unsigned long ans{1};
        for(unsigned long i{0}; i < N; ++i){
            long k;
            cin >> k;
            if(k > 0)(ans *= k) %= MOD;
            else (ans *= MOD - (-k % MOD)) %= MOD;
        }
        cout << ans << endl;
        return 0;
    }
    vector<unsigned long> pos, neg, zero;
    for(unsigned long i{0}; i < N; ++i){
        long k;
        cin >> k;
        if(k > 0)pos.emplace_back(k);
        else if(k < 0)neg.emplace_back(-k);
        else zero.emplace_back(0);
    }
    if(pos.empty()){
        copy(begin(zero), end(zero), back_inserter(neg));
        if(K & 1)sort(begin(neg), end(neg));
        else sort(begin(neg), end(neg), greater<>());
        unsigned long ans{1};
        for(unsigned long i{0}; i < K; ++i)(ans *= neg[i]) %= MOD;
        cout << (K & 1 ? (MOD - ans) % MOD : ans) << endl;
    }else{
        sort(begin(pos), end(pos));
        sort(begin(neg), end(neg));
        unsigned long ans{1};
        if(K & 1){
            --K;
            ans *= pos.back();
            pos.pop_back();
        }
        while((pos.size() > 1 || neg.size() > 1) && K){
            if(pos.size() < 2 || (neg.size() > 1 && pos.back() * pos.end()[-2] < neg.back() * neg.end()[-2])){
                (ans *= neg.back()) %= MOD;
                neg.pop_back();
                (ans *= neg.back()) %= MOD;
                neg.pop_back();
            }else{
                (ans *= pos.back()) %= MOD;
                pos.pop_back();
                (ans *= pos.back()) %= MOD;
                pos.pop_back();
            }
            K -= 2;
        }
        if(K)return 0 & puts("0");
        else cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 7476
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
	ll n,k,z,p,d;
	cin>>n>>k;
	ll i=1;
	cin>>z;
	p=z;
	vector<ll> v;
	while(i<k)
	{
		cin>>d;
		v.push_back(d-p);
		p=d;
		i++;
	}
	v.push_back(n-d+z);
	sort(v.begin(),v.end());
	i=0;
	ll sum=0;
	while(i<v.size()-1)
	{
		sum+=v[i];
		i++;
	}
	cout<<sum;
}

Measured memory_bytes: 2420
#include<stdio.h>
int a[5];
void sort(void) {
  int n, i;
  for (i = 0; i < 5; i ++) {
    if (a[i - 1] > a[i]) {
      n = a[i]; a[i] = a[i - 1]; a[i - 1] = n; i -= 2;
      if (i < 0) i ++;
    }
  }
}
int main() {
  while (scanf("%d,%d,%d,%d,%d", &a[0], &a[1], &a[2], &a[3], &a[4]) != EOF) {
    sort();
    if ((a[0] == a[1] || a[3] == a[4]) && a[1] == a[2] && a[2] == a[3]) printf("four card\n");
    else if (a[0] == a[1] && a[3] == a[4] && (a[1] == a[2] || a[2] == a[3])) printf("full house\n");
    else if ((a[1] == a[0] + 1 && a[2] == a[1] + 1 && a[3] == a[2] + 1 && a[4] == a[3] + 1) || (a[0] == 1 && a[1] == 10 && a[2] == 11 && a[3] == 12 && a[4] == 13)) printf("straight\n");
    else if ((a[0] == a[1] && a[1] == a[2]) || (a[1] == a[2] && a[2] == a[3]) || (a[2] == a[3] && a[3] == a[4])) printf("three card\n");
    else if ((a[0] == a[1] && a[2] == a[3]) || (a[0] == a[1] && a[3] == a[4]) || (a[1] == a[2] && a[3] == a[4])) printf("two pair\n");
    else if (a[0] == a[1] || a[1] == a[2] || a[2] == a[3] || a[3] == a[4]) printf("one pair\n");
    else printf("null\n");
  }
  return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h> 
const long long MOD = 1e9+7;
using namespace std;


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

	char b;
	cin >> b;

	if (b=='A') {
		cout << 'T' << endl;
	} else if (b=='C') {
		cout << 'G' << endl;
	} else if (b=='G') {
		cout << 'C' << endl;
	} else  if (b=='T') {
		cout << 'A' << endl;
	}
	return 0;
}


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

using namespace std;


pair<int, int> A[20000];
bool v[20000];
int main() {
    int h1, m1, h2, m2, k;
    scanf("%d%d%d%d%d", &h1, &m1, &h2, &m2, &k);
    int minute = m2 - m1;
    if (m2 < 0) m2 += 60;
    int hour = h2 - h1;
    if (hour < 0) hour += 24;
    printf("%d\n", hour * 60 + minute - k);
    return 0;
}


Measured memory_bytes: 3828
#include <iostream>

using namespace std;

int pow(int b, int e)
{
    int r = 1;
    
    while (0 < e)
    {
        if (e % 2 == 0)
        {
            b *= b;
            e >>= 1;
        } else {
            r *= b;
            e -= 1;
        }
    }
    
    return r;
}

int main()
{
    int N, K;
    cin >> N >> K;
    
    cout << pow(K - 1, N - 1) * K << endl;
    
    return 0;
}


Measured memory_bytes: 384
package main
import . "fmt"
func main() {
  var n,m int
  Scan(&n)
  m = n + 1
  for i:=0;i<n+1;i++ {
    var c,t int
    c = 0
    t = i
    for ;t>0; {
      c += t%6
      t /= 6
    }
    t = n-i
    for ;t>0; {
      c += t%9
      t /= 9
    }
    if c < m { m = c }
  }
  Println(m)
}

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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

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

    string s;cin>>s;
    int res = 0;
    for(int i=0;i<4;i++){
        if(s[i]=='2') res++;
    }
    cout<<res<<endl;
}


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


public class Main {
	private	static	BufferedReader	br = null;

	static {
		br = new BufferedReader(new InputStreamReader(System.in));
	}
 
    /**
     * @param args
     */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		int		num = 0;

		while((num = parseNum()) != 0) {
			int[][]	rec = new int[4][4];
			rec[0][1] = Integer.MAX_VALUE;
			rec[1][1] = Integer.MAX_VALUE;
			rec[2][1] = Integer.MIN_VALUE;
			rec[3][1] = Integer.MIN_VALUE;
			for (int i = 0; i < num; i++) {
				int[]	tmp = parseRec();
				if (i == 0) {
					rec[0] = rec[3] = tmp;
				} else {
					if (tmp[1] < rec[0][1]) {
						rec[1] = rec[0];
						rec[0] = tmp;
					} else if (tmp[1] < rec[1][1]) {
						rec[1] = tmp;
					}

					if (tmp[1] > rec[3][1]) {
						rec[2] = rec[3];
						rec[3] = tmp;
					} else if (tmp[1] > rec[2][1]) {
						rec[2] = tmp;
					}
				}
			}

			System.out.println(rec[0][0]);
			System.out.println(rec[1][0]);
			System.out.println(rec[2][0]);
		}
	}

	private static int parseNum() {
		int		param = 0;
		String	strin = null;

		if ((strin = parseStdin()) != null) {
			param = Integer.parseInt(strin);
		}
 
		return param;
	}

	private static int[] parseRec() {
		int[]	param = null;
		String	strin = null;

		if ((strin = parseStdin()) != null) {
			String[]	lines = strin.split(" ");

			param    = new int[2];
			param[0] = Integer.parseInt(lines[0]);
			for (int i = 1; i < lines.length; i+=2) {
				param[1] += Integer.parseInt(lines[i])*60+Integer.parseInt(lines[i+1]);
			}
		}
 
		return param;
	}

	private static String parseStdin() {
        String  stdin = null;
        
        try {
        	String  tmp = br.readLine();
        	if (tmp != null) {
            	if (!tmp.isEmpty()) {
            		stdin = tmp;
            	}
        	}
        }
        catch (IOException e) {}
 
        return stdin;
	}
}

Measured memory_bytes: 45088
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>
#include <climits>
#include <stack>

using namespace std;

typedef long long ll;
typedef long double ld;

#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define no {cout << 0; return;}
#define mkp make_pair
#define mkt make_tuple
#define cerr if(0) cerr

const int N = 30;

bool f[N][N];
int dist[N][N];
pi dx[4] = { {0, 1}, {0, -1}, {1, 0}, {-1, 0} };

void bfs(int vx, int vy) {
    queue <pi> q;
    dist[vx][vy] = 0;
    q.push({ vx, vy });
    while (!q.empty()) {
        int x = q.front().F, y = q.front().S;
        q.pop();
        loop(i, 4) {
            int nx = x + dx[i].F, ny = y + dx[i].S;
            if (!f[nx][ny])
                continue;
            if (dist[nx][ny] == -1) {
                dist[nx][ny] = dist[x][y] + 1;
                q.push({ nx, ny });
            }
        }
    }
}

void solve() {
    int n, m;
    cin >> n >> m;
    loop1(i, n) {
        loop1(j, m) {
            char c; cin >> c;
            f[i][j] = (c == '.');
        }
    }
    int ans = 0;
    loop1(i, n) {
        loop1(j, m) {
            if (!f[i][j])
                continue;
            loop1(ii, n)
                loop1(jj, m)
                    dist[ii][jj] = -1;
            bfs(i, j);
            loop1(ii, n)
                loop1(jj, m)
                    ans = max(ans, dist[ii][jj]);
        }
    }
    cout << ans;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //int t; cin >> t; loop(i, t)
    solve();
    return 0;
}

Measured memory_bytes: 3592
#include<stdio.h>

int main (){
	
	char i = 'A', j = 'A', x = 'B';
	scanf("%c %c %c", &i, &j, &x);
	
	if(i == j && j == x && i == x){
		printf("No\n");
	}
	else{
		printf("Yes\n");
	}
	return 0;
}

Measured memory_bytes: 3176
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

use std::cmp::Ordering;

/// Equivalent to std::lowerbound and std::upperbound in c++
pub trait BinarySearch<T> {
    fn lower_bound(&self, &T) -> usize;
    fn upper_bound(&self, &T) -> usize;
}

impl<T: Ord> BinarySearch<T> for [T] {
    fn lower_bound(&self, x: &T) -> usize {
        let mut low = 0;
        let mut high = self.len();

        while low != high {
            let mid = (low + high) / 2;
            match self[mid].cmp(x) {
                Ordering::Less => {
                    low = mid + 1;
                }
                Ordering::Equal | Ordering::Greater => {
                    high = mid;
                }
            }
        }
        low
    }

    fn upper_bound(&self, x: &T) -> usize {
        let mut low = 0;
        let mut high = self.len();

        while low != high {
            let mid = (low + high) / 2;
            match self[mid].cmp(x) {
                Ordering::Less | Ordering::Equal => {
                    low = mid + 1;
                }
                Ordering::Greater => {
                    high = mid;
                }
            }
        }
        low
    }
}

#[test]
fn test_binary_search() {
    let vec = vec![1, 2, 4, 6, 7, 12, 54, 60];

    assert_eq!(vec.lower_bound(&4), 2);
    assert_eq!(vec.upper_bound(&4), 3);
}

fn main() {
    let n = read::<usize>();
    let mut l = vec![0; n];

    for i in 0..n {
        l[i] = read::<i64>();
    }

    l.sort();

    let mut ans = 0;
    for i in 0..n {
        for j in i+1..n {
            let t = std::cmp::max(l[i]-l[j], l[j]-l[i]);
            let s = l.lower_bound(&(l[i]+l[j]));
            let t = l.upper_bound(&t);
            let mut sa: i64 = s as i64 - t as i64;
            if t <= i && i < s {
                sa -= 1;
            }
            if t <= j && j < s {
                sa -= 1;
            }
            if sa > 0 {
                ans += sa;
            }
        }
    }

    println!("{}", ans/3);
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int n, a, alice, bob;

int main(void) {
    vector<int> vc;
    cin >> n;
    while(n--) {
        cin >> a;
        vc.push_back(a);
    }
    sort(vc.begin(), vc.end(), greater<int>());

    for(int i=0; i < vc.size(); i++){
        if(i%2==0){
            alice+=vc[i];
        }else{
            bob+=vc[i];
        }
    }

    cout <<  alice-bob << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second

using namespace std;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    vector<int> a(n);
    int ans = 1;
    int cur = 1;
    for (int i = 0; i < n; ++ i) {
        cin >> a[i];
        if (i) {
            if (a[i] <= a[i - 1]) {
                cur ++;
                ans = max(ans, cur);
            }
            else cur = 1;
        }
    }
    cout << ans - 1;
}

Measured memory_bytes: 640
N = int(input())
A = list(map(int, input().split()))
oc, fc = 0, 0
for i in range(N):
	if A[i] % 4 == 0:
		fc += 1
	elif A[i] % 2 == 1:
		oc += 1
if fc >= oc:
	print('Yes')
elif (fc + 1 == oc) and (fc + oc == N):
	print('Yes')
else:
	print('No')

Measured memory_bytes: 19944
import java.io.InputStream
import java.io.PrintStream
import java.util.*

class Abc086A(
    val input: InputStream,
    val output: PrintStream
) {
    fun proc() {
        val sc = Scanner(input)
        val a = sc.nextInt()
        val b = sc.nextInt()
        if ((a * b) % 2 == 0) {
            output.print("Even")
        }else {
            output.print("Odd")
        }
    }
}

fun main(args: Array<String>) {
    Abc086A(System.`in`, System.out).proc()
}


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

using namespace std;
typedef long long ll;
typedef pair <int,int> pa;
const int N = 2e5+100;
char s[N];
int ans;
void solve()
{
   cin>>s+1;
   int len=strlen(s+1);
  // cout<<len<<endl;
   ans=len/2;
   while(1){
     int l=len-ans+1,r=ans;
     for(int i=l;i<r;i++)
        if((s[i]-'0')^(s[i+1]-'0')) return ;
        ans++;
   // if(ans==len) break;
   }
}
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);
    solve();
    cout<<ans-1<<endl;
    return 0;
}


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

// @@ !! LIM()

int main(/* int argc, char *argv[] */) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll x; cin >> x;
  cout << 1 - x << endl;

  return 0;
}



Measured memory_bytes: 3632
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9 + 7;


int main(void){

    int K,S; cin>>K>>S;
    int cnt=0;
    for (int i = 0; i <= K; ++i) {
        for (int j = 0; j <= K; ++j) {
            int l = S-i-j;
            if(l>=0 && l<=K) cnt++;
        }
    }
    cout<<cnt<<endl;

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String... args) {
        Scanner sc = new Scanner(System.in);
        String str = "";

        while(sc.hasNext()) {
        	str += sc.nextLine();
        }
        str = str.toLowerCase();

        char[] alphabet = new char[] {'a','b','c','d','e','f','g','h','i','j','k',
        							  'l','m','n','o','p','q','r','s','t','u','v',
        							  'w','x','y','z'};

        int[] ans = new int[alphabet.length];

        for(int i = 0; i < str.length(); ++i) {
        	for(int j = 0; j < alphabet.length; j++) {
        		if(str.charAt(i) == alphabet[j]) {
        			ans[j]++;
        		}
        	}
        }

        for(int i = 0; i < alphabet.length; i++) {
        	System.out.println(String.format("%s : %d", alphabet[i], ans[i]));
        }

    }
}


Measured memory_bytes: 26372
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef pair<int,int> pii;
#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 F first
#define S second

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

int main(void) {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//freopen("in.txt", "r", stdin);
	ll a,b;
	cin >> a >> b;
	ll g = gcd(a,b);
	ll l = a*b/g;
	cout << l << '\n';
	return 0;
}


Measured memory_bytes: 256
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;
int main(void)
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	long long INF = 100000000000;
	int N, M; cin >> N >> M;
	vector<vector<pair<int, int>>> arr(N, vector<pair<int, int>>(0));
	vector<long long>cost(N, INF);
	for (int i = 0; i < M; i++)
	{
		int L, R, D;
		cin >> L >> R >> D; L--; R--;
		arr[R].push_back(make_pair(L, -D));
		arr[L].push_back(make_pair(R, D));
	}
	//arr[R][?].first= L .second = D;
	for (int i = 0; i < N; i++)
	{
		if (cost[i] == INF)
		{
			cost[i] = 0;
			stack<int> s;
			s.push(i);
			for (int t = 0; !s.empty();)
			{
				t = s.top();
				s.pop();
				//cout << t << "dayo\n";
				for (int m = 0; m < arr[t].size(); m++)
				{
					if (cost[arr[t][m].first] == INF)
					{
						cost[arr[t][m].first] = cost[t] + arr[t][m].second;
						s.push(arr[t][m].first);
					}
					else if (cost[arr[t][m].first] != cost[t] + arr[t][m].second)
					{
						cout << "No\n";
						return 0;
					}
				}
			}
		}
		else for (int mmmm = 0; mmmm < arr[i].size(); mmmm++)
		{
			if (cost[arr[i][mmmm].first] != cost[i] + arr[i][mmmm].second)
			{
				cout << "No\n";
				return 0;
			}
		}
	}
	cout << "Yes\n";
}

Measured memory_bytes: 9728
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using i64 = int64_t;
using f80 = __float80;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef v(i64) vi;
typedef v(vi) vvi;
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;}
template<typename T> ostream &operator<<(ostream &os, const vector< T > &v){
  rep(i,v.size()) os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<typename T> istream &operator>>(istream &is, vector< T > &v){
  for(T &in : v) is >> in;
  return is;
}

i64 pow_mod(i64 n, i64 k, i64 m){
  i64 r = 1;
  for(;k;k>>=1){
    if(k&1) r=(r*n)%m;
    n=(n*n)%m;
  }
  return r;
}

void Main()
{
  i64 X;
  cin >> X;

  i64 ans = 1;
  
  i64 b = 2;
  while(b * b <= X){
    i64 p = 2;
    while(true){
      if(pow(b,p)>X) break;
      chmax(ans,i64(pow(b,p)));
      p++;
    }
    b++;
  }
  cout << ans << "\n";
}

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

Measured memory_bytes: 384
MOD = 10 ** 9 + 7
INF = 10 ** 10
import sys
sys.setrecursionlimit(100000000)
dy = (-1,0,1,0)
dx = (0,1,0,-1)



def main():
    n = int(input())
    a = list(map(int,input().split()))
    cnt = [0] * (n + 1)
    cnt[0] = 3
    
    ans = 1
    for num in a:
        ans *= cnt[num]
        ans %= MOD
        cnt[num] -= 1
        cnt[num + 1] += 1
    
    print(ans)

if __name__ =='__main__':
    main()   


Measured memory_bytes: 14056
#include <stdio.h>

int main(void)
{
	int N;
	scanf("%d",&N);
	int p[N];
	int i,w = 0;
	for(i = 0; i < N;i++)
	{
		scanf("%d",&p[i]);
	}
	for(i = 0; i < N; i++)
	{
		if(p[i] != i+1)
		{
			w++;
		}
	}
	if(w < 3)
	{
		printf("YES");
	}
	else{
		printf("NO");
	}
	
	return 0;
}



Measured memory_bytes: 128
N,K = map(int,input().split())
c = 0
listA = []
for k in range(1,K+1):
    d = int(input())
    listA += list(map(int,input().split()))
    
for n in range(1,N+1):
    if n not in listA:
        c += 1
print(c)     

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


int main() {
	
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    cout.tie(NULL);
	
	map<ll,ll>m;
	
	ll n;
	cin>>n;
	ll a[n];
	for(ll i=0;i<n;i++)
	{
	    cin>>a[i];
	}
	

	ll ans=0;
	for( ll i=0;i<n;i++)
	{
	    ll x=a[i];
	
	    for(ll j=2;j*j<=x;j++)
	    {
	 
	        if((x%j)==0)
	        {
	            if(m[j]==0)
	            {
	                m[j]++;
	            }
	            else
	            {
	                ans++;
	                break;
	            }
	           while((x%j==0))
	           {
	               x/=j;
	           }
	        }
	       
	       
	    }
    	        if(ans==0 && x!=1)
    	        {
    	            if(m[x]>=1)
    	            {
    	            ans++;
    	            break;
    	            }
    	            else
    	            {
    	                m[x]++;
    	            }
    	        }
    	    if(ans==1)
    	    {
    	        break;
    	    }
	    
	}
	
	ll g=a[0];
	for(ll i=0;i<n;i++)
	{
	    g=__gcd(g,a[i]);
	}
	if(g!=1)
	{
	    ans++;
	}
	if(ans==0)
	{
	    cout<<"pairwise coprime"<<endl;
	}
	else if(ans==1)
	{
	    cout<<"setwise coprime"<<endl;
	}
	else
	{
	    cout<<"not coprime"<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 11444
#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <utility>
using namespace std;

#define MOD 1000000007
#define INF 1e9+7
#define INF_LONG 1e18
#define rep(i, n) for(int i=0; i<n; ++i)
#define rrep(i, m, n) for(int i=m; i<n; ++i)
typedef long long ll;

#define MAX_N 200000
#define MAX_M 100000
#define MAX_V 100
#define MAX_E 100
#define MAX_Q 100000

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

int ddx[] = {-1, 0, 1, 0, -1, 1, -1, 1};
int ddy[] = {0, -1, 0, 1, 1, 1, -1, -1};

ll gcd(ll x, ll y) {
  if(y==0) return x;
  else return gcd(y, x%y);
}

ll lcm(ll x, ll y) {
  return (x*y)/gcd(x, y);
}

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

int main() {

  int a, b, min = 100000;
  cin >> a >> b;

  int x, y;

  for(int i=1; i<=1000; ++i) {
    x = (int)(i*0.08);
    y = (int)(i*0.1);
    if(x==a&&y==b) {
      if(min>i) min = i;
    }
  }

  if(min==100000) cout << -1 << endl;
  else cout << min << endl;

  return 0;
}


Measured memory_bytes: 256
sx, sy, tx, ty = map(int, input().split())
answer = ''
answer += 'U' * (ty-sy) + 'R' * (tx-sx)
answer += 'D' * (ty-sy) + 'L' * (tx-sx)
answer += 'L' + 'U' * (ty-sy+1) + 'R' * (tx-sx+1) + 'D'
answer += 'R' + 'D' * (ty-sy+1) + 'L' * (tx-sx+1) + 'U'
print(answer)

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

using namespace std;

int main(){
    double n;
    while(cin >> n, n >= 0){
	n *= 1 << 4;
	if(n != (int)n || n >= (1 << 13)){
	    cout << "NA" << endl;
	    continue;
	}
	int l = (int)n >> 4, r = n - (l << 4);
	for(int i = 7;i >= 0;i--){
	    cout << ((l >> i) & 1);
	}
	cout << '.';
	for(int i = 3;i >= 0;i--){
	    cout << ((r >> i) & 1);
	}
	cout << endl;
    }
}

Measured memory_bytes: 1220
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

class Stream{
public:
    Stream(){

    }
    //配列以外の入力を受け取る
    void read(){

    }
    template<typename First, typename... Rest>
    void read(First& first, Rest&... rest){
        cin >> first;
        read(rest...);
    }
    template<typename T>
    vector<T> read_vec(size_t n){
        vector<T> tmp(n);
        for(size_t i = 0; i < n; i++){
            cin >> tmp[i];
        }
        return tmp;
    }
    //配列を区切って出力する
    template<typename T>
    void write_vec(vector<T>& v, char divider){
        for(size_t i = 0; i < v.size(); i++){
            cout << v[i] << divider;
        }
    }
};

int main(){
    Stream io;

    int H, W;
    io.read(H, W);
    auto S = io.read_vec<string>(H);
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            if(S[i][j] == '#') continue;
            int sum = 0;
            for(int x = max(0, j - 1); x <= min(j + 1, W - 1); x++){
                for(int y = max(0, i - 1); y <= min(i + 1, H - 1); y++){
                    if(x == j && y == i) continue;
                    if(S[y][x] == '#') sum++;
                }
            }
            S[i][j] = sum + '0';
        }
    }
    for(int i = 0; i < H; i++){
        cout << S[i] << '\n';
    }
    return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	buf := bufio.NewScanner(os.Stdin)
	buf.Split(bufio.ScanWords)
	buf.Scan()
	s := buf.Text()

	fmt.Printf("%s", string([]byte(s)[0]+1))
}


Measured memory_bytes: 640
#include<stdio.h>
#define abs(a) (((a)<0)?-(a):(a))
int main(int argc, char const *argv[]){
	long long n,a,b,c,d;
	scanf("%lld %lld %lld %lld %lld",&n,&a,&b,&c,&d);
	if((c+d)<=(n-1)*(d-c)){
		if((abs(b-a)/d+(abs(b-a)%d!=0))<=n-1) printf("YES\n");
		else printf("NO\n");
	}else{
		if((abs(b-a)/d+(abs(b-a)%d!=0))>n-1) printf("NO\n");
		else{
			b=b-a+(n-1)*d;
			if(0<=b%(c+d) && b%(c+d)<=(n-1)*(d-c)) printf("YES\n");
			else printf("NO\n");
		}
	}
	return 0;
}

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

#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define irrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define irrep2(i,n,a) for(int i = (int)(n); i >= (int)(a); i--)
#define fi first
#define se second

using ll = long long;
using v_int = std::vector<int>;
using v2_int = std::vector<v_int>;
using v_ll = std::vector<ll>;
using v2_ll = std::vector<v_ll>;
using v_string = std::vector<std::string>;
using v_bool = std::vector<bool>;
using v2_bool = std::vector<v_bool>;
using pii = std::pair<int, int>;
using pll = std::pair<ll, ll>;
using mii = std::map<int, int>;
using mll = std::map<ll, ll>;

const double PI = 3.1415926535897932;
const int INF = 2*(int)1e9;
const ll LINF = (ll)1e18;
const ll MOD = 1000000007;
//const int dc[4] = {1, -1, 0,  0};
//const int dr[4] = {0,  0, 1, -1};
const int dc[8] = {1, -1, 0,  0, 1, -1,  1, -1};
const int dr[8] = {0,  0, 1, -1, 1,  1, -1, -1};

using namespace std; 

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p)
{
    return o << "{" << p.first << "," << p.second << "}";
}

template<typename T, typename U, typename V> inline
ostream& operator<<(ostream &o, tuple<T,U,V> &p)
{
    return o << "{" << get<0>(p) << "," << get<1>(p) << "," << get<2>(p) << "}";
}

template<typename T> inline
istream& operator>>(istream &is, vector<T> &v)
{
    int len = (int)v.size();
    for(int i = 0; i < len; i++) {
        is >> v[i]; 
    }
    return is;
}

template<typename T> inline
ostream& operator<<(ostream &os, vector<T> &v)
{
    int len = (int)v.size();
    for(int i = 0; i < len; i++) { 
        os << v[i];
        if(i != len-1) { os << ","; } 
    } 
    return os;
}

template<typename T> inline
void chmin(T &a, T b) { a = min(a, b); }

template<typename T> inline
void chmax(T &a, T b) { a = max(a, b); }

int main(void)
{
    int n;
    cin >> n;
    
    irep(i, 10000) {
        if(1000 * i >= n) {
            cout << 1000*i-n << endl;
            return 0;
        }
    }

    return 0;
}

/*atcoder*/


Measured memory_bytes: 3628
package main

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

var rdr = bufio.NewReaderSize(os.Stdin, 400000)

func readLine() string {
	buf := make([]byte, 0, 400000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func delete(s []rune, i int) []rune {
	s = s[:i]
	n := make([]rune, len(s))
	copy(n, s)
	return n
}
func main() {
	s := readLine()
	ar := []rune{}
	result := 0
	for _, v := range s {
		if len(ar) > 0 && ar[len(ar)-1] != v {
			ar = delete(ar, len(ar)-1)
			result += 2
		} else {
			ar = append(ar, v)
		}
	}
	fmt.Println(result)
}


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

int main(){
  int n,count=1;
  cin >> n;
  vector<int> v(n,0);
  r(i,n)cin >> v.at(i);
  sort(v.begin(),v.end());
  r(i,n-1){
    if(v.at(i)!=v.at(i+1))count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main(int argc, char *argv[]) {
	int x, a, b;
	cin >> x >> a >> b;
	if (a>=b) cout << "delicious" << endl;
	else if (x >= b-a) cout << "safe" << endl;
	else cout << "dangerous" << endl;
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n int

	fmt.Scan(&n)

	var m int = 0
	var cnt int = 0
	
	for i := 0; i < n; i++ {
		var x int
		fmt.Scan(&x)
		if x >= m {
			cnt++
			m = x
		}
	}

	fmt.Print(cnt)
}


Measured memory_bytes: 1768
#include <stdio.h>

#define MOD 1000000007

char s[100002];

int main(void) {
	int ans = 0;
	int cnt = 2;

	int c;
	while ((c = getchar()) != EOF) {
		if (c != '1' && c != '0') continue;

		ans = ((ans*2)%MOD + ans + 2) % MOD;
		if (c == '1') cnt = (cnt*2) % MOD;
		else ans = (ans + MOD - cnt) % MOD;
	}

	printf("%d\n", (ans+1) % MOD);
}


Measured memory_bytes: 128
#include <bits/stdc++.h> 
using namespace std; 
int main() {
  string s, t; 
  cin >> s >> t; 
  int longueur = s.length(); 
  int res = 0; 
  for (int i = 0; i < longueur ; i ++) {
   	if (s[i] != t[i])
      	res ++; 
  }
  cout << res; 
  return 0; 
}

Measured memory_bytes: 3912
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <tuple>
#include <queue>
#include <set>
#include <math.h>
#include <array>
#include <list>
#include <set>
#include <string.h>

#define MOD 1000000007
#define INF 1000000000
using namespace std;
typedef long long ll;
typedef tuple<ll,int,int> p;
set <int> st;
int n;
int main(int argc,char const* argv[])
{
  int alicescore=0,bobscore=0;
  cin >> n;
  vector<int>cards (n+5);
  for(int i=0;i<n;i++)
    {
      cin >> cards[i];
    }
  sort(cards.begin(),cards.end(),greater<int>());
  for(int i=0;i<n;i++)
    {
      if(i%2==0) alicescore+=cards[i];
      else bobscore+=cards[i];
    }
  cout << alicescore-bobscore << endl;
  return 0;
}


Measured memory_bytes: 256