akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[][] ary = new int[n][2];
        for (int i = 0; i < n; i++) {
            ary[i][0] = sc.nextInt();
            ary[i][1] = sc.nextInt();
        }
        double[][] array = new double[n][n];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                array[i][j] = Math.sqrt((ary[i][0] - ary[j][0]) * (ary[i][0] - ary[j][0]) + (ary[i][1] - ary[j][1]) * (ary[i][1] - ary[j][1]));
            }
        }
        
        double sum = 0;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (i == j) continue;
                sum += array[i][j];
            }
        }
        
        System.out.println(sum / n);
    }
}


Measured memory_bytes: 23764
n = int(input())

dig = n % 10
hon = [2, 4, 5, 7, 9]
pon = [0, 1, 6, 8]
bon = [3]

if dig in hon:
    print("hon")
elif dig in pon:
    print("pon")
elif dig in bon:
    print("bon")

Measured memory_bytes: 9184
import sys
from collections import deque
input = sys.stdin.readline

h, w = list(map(int, input().split()))
t = h * w

s = ""
for i in range(h):
    s += input().replace( '\n' , '' )

#print(s)

adj = [[] for _ in range(t)]

for i in range(t):
    #よこ
    if i % w != 0 and s[i-1] == ".":
        adj[i].append(i-1)
    if i % w != w-1 and s[i+1] == ".":
        adj[i].append(i+1)
    #たて
    if i - w >= 0 and s[i-w] == ".":
        adj[i].append(i-w)
    if i + w < t and s[i+w] == ".":
        adj[i].append(i+w)

#print(adj)

m = 0
for i in range(t):
    if s[i] == "#":
        pass
    else:
        #BFS
        depth = [0] * t
        visited = [False] * t
        q = deque([i])
        visited[i] = True
        while len(q) > 0:
            v = q.popleft()
            for w in adj[v]:
                if not visited[w]:
                    q.append(w)
                    visited[w] = True
                    depth[w] = depth[v] + 1
        
        #print(depth)
        
        m = max(m, max(depth))

print(m)




Measured memory_bytes: 74680
#include <algorithm>
#include <array>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>

using namespace std;

typedef long long ll;

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

  int min_cnt = t.length();
  for (int i = 0; i < s.length() - t.length() + 1; i++) {
    int cnt = 0;

    for (int j = 0; j < t.length(); j++) {
      if (s[i + j] != t[j]) {
        cnt++;
      }
    }

    if (min_cnt > cnt) {
      min_cnt = cnt;
    }
  }

  cout << min_cnt << endl;

  return 0;
}


Measured memory_bytes: 3160
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <stdio.h>

using namespace std;

int main()
{
    int n,count;
    count=0;
    cin >>n;
    vector<int> vec(n);
    bool flag;
    flag=false;

    for(int i=0;i<n;++i){
        cin >> vec[i];
    }
    
    while(true){
        for(int i=0;i<n;i++){
            if(vec[i]%2==0){
                vec[i]=vec[i]/2;
            }else{
                flag=true;
                break;
            }
            //cout<<vec[i];
            //cout<<"test";
        }
        //cout<<"test2";
        if(flag==true)break;
        count++;
    }
    cout<<count;
}






Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std; typedef long long ll; const int INF=1e9+7;
typedef pair<int,int> P;

int main() {
  int n; cin>>n;
  ll a[n+2]; a[0]=a[n+1]=0; for(int i=1;i<=n;i++) cin>>a[i];
  ll sm=0;
  for(int i=0;i<n+1;i++) {
    sm += abs(a[i]-a[i+1]);
  }
  for(int i=1;i<=n;i++) {
    ll an=sm;
    an -= abs(a[i-1]-a[i]) + abs(a[i]-a[i+1]);
    an += abs(a[i-1]-a[i+1]);
    cout<<an<<endl;
  }
}

Measured memory_bytes: 2048
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
const int Mmax = 2000;
int N, M;
int A[Mmax], B[Mmax];
ll C[Mmax];

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

    vector<ll> dist(N, 1e15);
    dist[0] = 0;
    for(int i=0; i<N-1; i++){
        for(int j=0; j<M; j++){
            if(dist[A[j]] == 1e15) continue;
            if(dist[A[j]]-C[j] < dist[B[j]]){
                dist[B[j]] = dist[A[j]]-C[j];
            }
        }
    }

    vector<bool> loop(N, false);
    for(int i=0; i<N; i++){
        for(int j=0; j<M; j++){
            if(dist[A[j]] == 1e15) continue;
            if(loop[A[j]] || dist[A[j]]-C[j] < dist[B[j]]){
                loop[B[j]] = true;
            }
        }
    }

    if(loop[N-1]) cout << "inf" << endl;
    else cout << -dist[N-1] << endl;
    return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int GCD(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   if(_a % _b == 0){
      return _b;
   }
   else{
      return GCD(_b, _a % _b);
   }
}

int LCM(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   return (_a*_b)/(GCD(_a, _b));
}

int main(){
   string s;
   cin >> s;
   string s_tmp = s.substr(4);
   cout << "2018" + s_tmp << endl;

   return 0;
}

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

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

int masu[100][100] = {};
int used[100][100] = {};
int w,h;
int dx[8] = {-1,-1,-1,0,0,1,1,1};
int dy[8] = {-1,0,1,-1,1,-1,0,1};

void dfs(int x, int y){
    used[x][y] = 1;
    REP(i,8){
        int tx = dx[i] + x;
        int ty = dy[i] + y;
        if(0 <= tx && tx < h && 0 <= ty && ty < w && used[tx][ty] != 1 && masu[tx][ty] == 1){
            dfs(tx,ty);
        }
    }
}

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(1){
        cin >> w >> h;
        if(w == 0 && h == 0) break;
        REP(i,h) REP(j,w) {
            cin >> masu[i][j];
            used[i][j] = 0;
        }
        int ans = 0;
        REP(i,h)  REP(j,w)  {
            if(!used[i][j] && masu[i][j] == 1){
                dfs(i,j);
                ans++;
            }
        }
        cout << ans << endl;
    }

}


Measured memory_bytes: 3268
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define vi vector<int>
#define vs vector<string>
#define vll vector<ll>

#define N 13
#define M 1000000007

int main() {
    string s;
    cin >> s;
    int l = s.length();
    int p = 1;
    ll dp[N] = {1};
    
    for (int i = (l - 1); i >= 0; i--) {
        ll next[N] = {0};
        
        if (s[i] == '?') {
            rep(ii, 10) {
                rep(iii, N) {
                    next[(p * ii + iii) % N] += dp[iii];
                    next[(p * ii + iii) % N] %= M;
                }
            }
        }
        else {
            int a = s[i] - '0';
            
            rep(ii, N) {
                next[(p * a + ii) % N] += dp[ii];
                next[(p * a + ii) % N] %= M;
            }
        }
        
        p = (p * 10) % N;
        rep(ii, N) dp[ii] = next[ii];
    }
    
    cout << dp[5] << endl;
    return 0;
}

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

int main(){
  int balls, bMachine, location, distance = 0;
  cin >> balls >> bMachine;
  
  rep(i, balls){
    cin >> location;
    if(abs(bMachine - location) < location)
      distance += abs(bMachine - location) * 2;
    else
      distance += location * 2;
  }
  
  cout << distance << endl;
}

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

using namespace std;

#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define pb push_back
#define endl '\n'
#define snd second
#define fst first
#define fastio cin.tie(NULL),cout.sync_with_stdio(true)

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector <int> vi;
typedef pair <ll, int> ii;
typedef pair <ii,int> iii;

const int mod = 1e9 + 7;
const int N = 200005;

ll v[N];

void solve(){
	int n;
	ll x = 0;
	cin >> n;
	for(int i = 0; i < n; i++)
		cin >> v[i];
	for(int i = 0; i < n; i++)
		x ^= v[i];
	for(int i = 0; i < n; i++)
		v[i] ^= x;
	for(int i = 0; i < n; i++){
		cout << v[i] <<  " ";
	}cout << endl;
}

int main(){
	fastio;
	int t = 1;
	//cin >> t;
	while(t--)
		solve();
	return 0;
}


Measured memory_bytes: 5112
using System;

	public class Class1
	{
		public static void Main(String[] args)
		{
			string triangle=Console.ReadLine();
			string[] abTheta=triangle.Split();
			double a=double.Parse(abTheta[0]);
			double b=double.Parse(abTheta[1]);
			double radian=double.Parse(abTheta[2])*(Math.PI/180);
			//S
			Console.WriteLine(b*a*Math.Sin(radian)/2);
			//a+b+c
			Console.WriteLine(a+b+(Math.Sqrt(a*a+b*b-(2*a*b*Math.Cos(radian)))));
			//b cosTheta
			Console.WriteLine(b*Math.Sin(radian));
			
		}
	}

Measured memory_bytes: 9208
#include <bits/stdc++.h>
using namespace std;
#define EQ(x, y) (abs(x - y) < 1e-9)
typedef long long ll;

ll dp[3010][3010];
int arr[3010];

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.precision(10);
	cout << fixed;

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

	for (int i = 1; i <= n; ++i){
		dp[i][i] = n & 1 ? arr[i] : -arr[i];
	}

	for (int l = n; l >= 1; --l){
		for (int r = l; r <= n; ++r){
			if ((n - l + r) & 1){ //positive
				dp[l][r] = max(arr[l] + dp[l + 1][r], arr[r] + dp[l][r - 1]);
			}
			else { //negative
				dp[l][r] = min(-arr[l] + dp[l + 1][r], -arr[r] + dp[l][r - 1]);
			}
		}
	}
	
	cout << dp[1][n] << '\n';
	return 0;
}

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

#define rep(i, n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i, s, n) for(long long i=(s);i<(long long)(n);i++)
#define repi(i, n) for(int i=0;i<(int)(n);i++)
#define rep2i(i, s, n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(), v.end()

#define deg2rad(deg) (((deg)/360)*2*M_PI)
#define rad2deg(rad) (((rad)/2/M_PI)*360)

using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

const ll INF = (1LL<<60);
const int INFi = (1<<29);

/*素数判定*/
bool is_prime(ll n){
    if(n==1) return false;
    for(ll i=2;i*i<=n;i++){
        if(n%i==0) return false;
    }
    return true;
}

/*約数列挙*/
vll enum_divisors(ll n){
    vll l;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            l.push_back(i);
            if(n/i != i) l.push_back(n/i);
        }
    }
   sort(all(l));
   return l;
}

/*素因数分解*/
vector<P> prime_factorize(ll n){
    vector<P> l;
    for(ll i=2;i*i<=n;i++){
        if(n%i!=0) continue;
        ll e = 0;
        while(n%i==0){
            e++;
            n /= i;
        }
        l.push_back({i, e});
    }
    if(n!=1) l.push_back({n, 1});
    return l;
}

/*最小公倍数*/
ll lcm(ll a, ll b){
    return a*b/__gcd(a,b);
}

/*最大公約数*/
ll gcd(ll a, ll b){
    return __gcd(a,b);
}

/*組み合わせ(Combination)*/
const ll CMAX = 1010000;
const ll CMOD = 1e9+7;
ll fac[CMAX], finv[CMAX], inv[CMAX];
// テーブルを作る前処理
void combinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (ll i = 2; i < CMAX; i++) {
		fac[i] = fac[i - 1] * i % CMOD;
		inv[i] = CMOD - inv[CMOD%i] * (CMOD / i) % CMOD;
		finv[i] = finv[i - 1] * inv[i] % CMOD;
	}
}
// 二項係数計算
ll comb(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % CMOD) % CMOD;
}


int main(){

    ll n, m; cin >> n >> m;
    vector<vector<char>> a(n, vector<char>(n));
    vector<vector<char>> b(m, vector<char>(m));
    rep(i, n){
        string s; cin >> s;
        rep(j, n){
            a[i][j] = s[j];
        }
    }
    rep(i, m){
        string s; cin >> s;
        rep(j, m){
            b[i][j] = s[j];
        }
    }

    bool ans;
    rep(i, n-m+1){
        rep(j, n-m+1){
            ans = true;
            rep(ii, m){
                rep(jj, m){
                    if(b[ii][jj]!=a[i+ii][j+jj]){
                        ans = false;
                        break;
                    }
                }
                if(!ans) break;
            }
            if(ans){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }


    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3612
s = input()
num = [ int(i) for i in s]

for i in range(2):
    for j in range(2):
        for k in range(2):
            ans = str(num[0])
            val = num[0]
            if i == 0:
                ans += "+"
                val += num[1]
            else:
                ans += "-"
                val -= num[1]
            ans += str(num[1])
            if j == 0:
                ans += "+"
                val += num[2]
            else:
                ans += "-"
                val -= num[2]
            ans += str(num[2])
            if k == 0:
                ans += "+"
                val += num[3]
            else:
                ans += "-"
                val -= num[3]
            ans += str(num[3])
            if val == 7:
                print(ans + "=7")
                exit(0)
            

                
                



Measured memory_bytes: 38256
#![allow(unused_imports)]
use proconio::{input, fastout};
use proconio::marker::*;

#[fastout]
fn main() {
    input! {
    n: usize,
    k: usize,
    lr: [(usize, usize); k]
    }
    let mut dp = vec![ModInt::zero(); n + 1];
    dp[1] = ModInt::one();
    let mut s = vec![ModInt::zero(); n + 1];
    s[1] = ModInt::one();
    for i in 2..=n {
        for j in 0..k {
            let (l, r) = lr[j];
            dp[i] += s[i.checked_sub(l).unwrap_or(0)] - s[i.checked_sub(r + 1).unwrap_or(0)];
        }
        let t = s[i - 1];
        s[i] += t + dp[i];
    }
    let ans = dp[n];
    println!("{}", ans);

}

// ---------- begin ModInt ----------
// Thank you @sansen for referring to code

const MOD: u32 = 998244353;

#[derive(Clone, Copy)]
struct ModInt(u32);

impl std::ops::Add for ModInt {
    type Output = ModInt;
    fn add(self, rhs: ModInt) -> Self::Output {
        let mut d = self.0 + rhs.0;
        if d >= MOD {
            d -= MOD;
        }
        ModInt(d)
    }
}

impl std::ops::AddAssign for ModInt {
    fn add_assign(&mut self, rhs: ModInt) {
        *self = *self + rhs;
    }
}

impl std::ops::Sub for ModInt {
    type Output = ModInt;
    fn sub(self, rhs: ModInt) -> Self::Output {
        let mut d = self.0 + MOD - rhs.0;
        if d >= MOD {
            d -= MOD;
        }
        ModInt(d)
    }
}

impl std::ops::SubAssign for ModInt {
    fn sub_assign(&mut self, rhs: ModInt) {
        *self = *self - rhs;
    }
}

impl std::ops::Mul for ModInt {
    type Output = ModInt;
    fn mul(self, rhs: ModInt) -> Self::Output {
        ModInt((self.0 as u64 * rhs.0 as u64 % MOD as u64) as u32)
    }
}

impl std::ops::MulAssign for ModInt {
    fn mul_assign(&mut self, rhs: ModInt) {
        *self = *self * rhs;
    }
}

impl std::ops::Neg for ModInt {
    type Output = ModInt;
    fn neg(self) -> Self::Output {
        ModInt(if self.0 == 0 { 0 } else { MOD - self.0 })
    }
}

impl std::fmt::Display for ModInt {
    fn fmt<'a>(&self, f: &mut std::fmt::Formatter<'a>) -> std::fmt::Result {
        write!(f, "{}", self.0)
    }
}

impl std::str::FromStr for ModInt {
    type Err = std::num::ParseIntError;
    fn from_str(s: &str) -> Result<Self, Self::Err> {
        let val = s.parse::<u32>()?;
        Ok(ModInt::new(val))
    }
}

impl From<usize> for ModInt {
    fn from(val: usize) -> ModInt {
        ModInt((val % MOD as usize) as u32)
    }
}

#[allow(dead_code)]
impl ModInt {
    pub fn new(n: u32) -> ModInt {
        ModInt(n % MOD)
    }
    pub fn zero() -> ModInt {
        ModInt(0)
    }
    pub fn one() -> ModInt {
        ModInt(1)
    }
    pub fn pow(self, mut n: u32) -> ModInt {
        let mut t = ModInt::one();
        let mut s = self;
        while n > 0 {
            if n & 1 == 1 {
                t *= s;
            }
            s *= s;
            n >>= 1;
        }
        t
    }
    pub fn inv(self) -> ModInt {
        assert!(self.0 > 0);
        self.pow(MOD - 2)
    }
}
// ---------- end ModInt ----------



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

using namespace std;

int main(){
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	a-=b;
	c-=a;
	c=c>0?c:0;
	printf("%d\n",c);	
	return 0;
}

Measured memory_bytes: 256
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop;

void main() {
    auto N = readln.chomp.to!int;
    auto A = readln.split.map!(to!long).array;
    
    long hi = 10^^9;
    long lo = -(10^^9);

    long calc(long b) {
        return N.iota.map!(i => abs(A[i] - (b+i+1))).sum;
    }
    
    while (hi - lo > 2) {
        long mid1 = (2*hi + lo) / 3;
        long mid2 = (hi + 2*lo) / 3;
        long v1 = calc(mid1);
        long v2 = calc(mid2);
        if (v1 >= v2) hi = mid1;
        else lo = mid2;
    }

    iota(lo, lo+4).map!(b => calc(b)).reduce!min.writeln;
}


Measured memory_bytes: 11120
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	A, B, K := nextInt(), nextInt(), nextInt()

	if A > K {
		fmt.Println(A-K, B)
	} else if A+B > K {
		fmt.Println(0, A+B-K)
	} else {
		fmt.Println(0, 0)
	}
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define endl '\n';

int main()
{

    int l,r,d;
    cin>>l>>r>>d;
    int c=0;
    for(int i=l;i<=r;i++)
        {
            if(i%d==0) c++;
        }
    cout<<c<<endl;
    return 0;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define itn int

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


int main()
{
  int x, y, z;
  cin >> x >> y >> z;
  x -= z;
  cout << x / (y+z) << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
void tkansu(int,int);
void skansu(int,int);
void akansu(int,int);

int h,w;
char map[101][101];
int flg[101][101];	//共有する宣言

int main(void)
{
	int i,j,k;	//共有しない宣言
	int cnt;
	
	scanf("%d %d",&h,&w);
	while(h!=0 && w!=0){
		for(i=0;i<h;i++){
			for(j=0;j<w;j++){
				scanf(" %c",&map[i][j]);
			}
		}
		for(i=0;i<h;i++){
			for(j=0;j<w;j++){
				if(map[i][j]=='@'){
					flg[i][j]=1;
				}
				else if(map[i][j]=='#'){
					flg[i][j]=2;
				}
				else if(map[i][j]=='*'){
					flg[i][j]=3;
				}
			}
		}
		cnt=0;
		for(i=0;i<h;i++){
			for(j=0;j<w;j++){
				if(flg[i][j]==1){
					flg[i][j]=0;
					tkansu(i,j);
					cnt++;
				}
				else if(flg[i][j]==2){
					flg[i][j]=0;
					skansu(i,j);
					cnt++;
				}
				else if(flg[i][j]==3){
					flg[i][j]=0;
					akansu(i,j);
					cnt++;
				}
			}
		}
		printf("%d\n",cnt);
		scanf("%d %d",&h,&w);
	}
	return 0;
}
void tkansu(int a,int b)
{
	if(a+1<h && flg[a+1][b]==1){
		flg[a+1][b]=0;
		tkansu(a+1,b);
	}
	if(a-1>=0 && flg[a-1][b]==1){
		flg[a-1][b]=0;
		tkansu(a-1,b);
	}
	if(b+1<w && flg[a][b+1]==1){
		flg[a][b+1]=0;
		tkansu(a,b+1);
	}
	if(b-1>=0 && flg[a][b-1]==1){
		flg[a][b-1]=0;
		tkansu(a,b-1);
	}
}
void skansu(int a,int b)
{
	if(a+1<h && flg[a+1][b]==2){
		flg[a+1][b]=0;
		skansu(a+1,b);
	}
	if(a-1>=0 && flg[a-1][b]==2){
		flg[a-1][b]=0;
		skansu(a-1,b);
	}
	if(b+1<w && flg[a][b+1]==2){
		flg[a][b+1]=0;
		skansu(a,b+1);
	}
	if(b-1>=0 && flg[a][b-1]==2){
		flg[a][b-1]=0;
		skansu(a,b-1);
	}
}
void akansu(int a,int b)
{
	if(a+1<h && flg[a+1][b]==3){
		flg[a+1][b]=0;
		akansu(a+1,b);
	}
	if(a-1>=0 && flg[a-1][b]==3){
		flg[a-1][b]=0;
		akansu(a-1,b);
	}
	if(b+1<w && flg[a][b+1]==3){
		flg[a][b+1]=0;
		akansu(a,b+1);
	}
	if(b-1>=0 && flg[a][b-1]==3){
		flg[a][b-1]=0;
		akansu(a,b-1);
	}
}

Measured memory_bytes: 1696
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

int n;
vector <bool> used;
vector <int> s1, s2;
vector <vector <int>> g;

int main() {
	int n, v1, v2;
	cin >> n >> v1 >> v2;
	g.resize(n);
	used.resize(n);
	n--;
	v1--;
	v2--;
	for (int i = 0; i < n; i++) {
		int u, v;
		cin >> u >> v;
		u--;
		v--;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	queue <int> q;
	vector <int> taka(n + 1), aoki(n + 1);
	aoki[v2] = 0;
	used.resize(0);
	used.resize(n + 1);
	q.push(v2);
	while (!q.empty()) {
		int v = q.front();
		used[v] = true;
		for (int i = 0; i < g[v].size(); i++)
			if (used[g[v][i]] == false) {
				q.push(g[v][i]);
				aoki[g[v][i]] = aoki[v] + 1;
			}
		q.pop();
	}
	taka[v1] = 0;
	used.resize(0);
	used.resize(n + 1);
	q.push(v1);
	while (!q.empty()) {
		int v = q.front();
		used[v] = true;
		for (int i = 0; i < g[v].size(); i++)
			if (used[g[v][i]] == false) {
				q.push(g[v][i]);
				if (aoki[v] == taka[v])
					taka[g[v][i]] = 1000000;
				else
					taka[g[v][i]] = taka[v] + 1;
			}
		q.pop();
	}
	int ans = 0;
	for (int i = 0; i < n; i++)
		if (taka[i] <= aoki[i] && g[i].size() != 1) {
			ans = max(ans, aoki[i]);
		}
	cout << ans;
	return 0;
}

Measured memory_bytes: 6656
import math
def is_lt_or_e_K(k, x, a):
    if k >= sum([math.ceil(i / x) - 1 for i in a]):
        return True
    else:
        return False 
n, k = map(int, input().split())
a = list(map(int, input().split()))
high = max(a)
low = 0
while 1:
    if high - low < 2:
        break
    x = (high + low) // 2
    if is_lt_or_e_K(k, x, a):
        high = x
    else:
        low = x
print(high)


Measured memory_bytes: 31084
#include<stdio.h>
#define N 20
int main(void) {
	int v[N] = { 0 };
	int c[N] = { 0 };
	int n = 0;
	int i = 0;
	int sum = 0;


	scanf("%d", &n);

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

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

	for (i = 0; i < n; i++) {
		if ((v[i] - c[i]) >= 0) {
			sum += (v[i] - c[i]);
		}
	}

	printf("%d", sum);
}

Measured memory_bytes: 128
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int N = sc.nextInt();
			if (N == 0) {
				sc.close();
				break;
			}

			int M = sc.nextInt();
			ArrayList<String> list = new ArrayList<String>();
			for (int i = 0; i < N; i++) {
				String path[] = sc.next().split("/");
				String tmp = "";
				for (int j = 0; j < path.length; j++) {
					tmp += path[j];
					if (j < path.length - 1) {
						tmp += "/";
					}
					list.add(tmp);
				}
			}

			for (int i = 0; i < M; i++) {
				boolean found = true;
				String[] input = new String[2];
				for (int k = 0; k < 2; k++) {
					boolean suffix = false;
					String a = sc.next();
					if (a.charAt(a.length() - 1) == '/') {
						a += "index.html";
						suffix = true;
					}
					String path[] = a.split("/");
					String tmp = "";
					for (int j = 0; j < path.length; j++) {
						if (path[j].equals(".")) {
							tmp = tmp.replaceAll("/$", "");
						} else if (path[j].equals("..")) {
							if (tmp.equals("/")) {
								found = false;
							} else {
								tmp = tmp.replaceAll("/[a-zA-Z\\.]*/$", "");
							}
						} else {
							tmp += path[j];
						}
						if (j < path.length - 1) {
							tmp += "/";
						} else if (!list.contains(tmp) && !suffix) {
							// 末尾の時
							// フォルダなら
							tmp += "/index.html";
						}
						if (!list.contains(tmp)) {
							found = false;
						}
					}
					if (found) {
						input[k] = tmp;
					}
				}
				if (found) {
					if (input[0].equals(input[1])) {
						System.out.println("yes");
					} else {
						System.out.println("no");
					}
				} else {
					System.out.println("not found");
				}
			}

		}
	}
}

Measured memory_bytes: 22920
import java.util.Scanner;
public class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        String text,Line;
        int count[] = new int[26];
        int z;
        StringBuilder sb = new StringBuilder();
        while(sc.hasNextLine())
        {
           sb.append(sc.nextLine().toLowerCase());  
        }
        int toAscii[] =new int [sb.length()];
        
       
        for(int i =0; i<sb.length();i++)
        {
            z=0;
            toAscii[i] =(int) sb.charAt(i);
            if(97<=toAscii[i] && toAscii[i]<=122)
            {
                z = toAscii[i] - 97;
                count[z] =count[z]+1;
            }
        }
        for(int i = 0; i<26;i++)
        {
            z = i+97;
            char a = (char) z;
            System.out.println(a+ " : "+count[i]);
        }
    }
}


Measured memory_bytes: 26132
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////


int main(){
    string s;
    cin >> s;
    map<char,int> m;
    rep(i,0,sz(s))m[s[i]]++;

    if(abs(m['a']-m['b'])>1 || abs(m['a']-m['c'])>1 || abs(m['b']-m['c'])>1)NO;
    else YES;
    
    return  0;
}


Measured memory_bytes: 512
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll>P;
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll cmp(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????
    cin.tie(0);
    ios::sync_with_stdio(false);
    //------------------------------
    int N,W;cin>>N>>W;
    vector<ll>v(N+2),w(N+2);
    for(int i=1;i<=N;i++)
        cin>>v[i]>>w[i];
    ll dp[101][10001];
    for(int i=0;i<=N;i++)
        for(ll j=0;j<=W;j++)
            dp[i][j]=0;
    for(int i=1;i<=N;i++)
        for(int j=1;j<=W;j++)
        {
            if(j>=w[i])
                {
                    dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]);
                }
            else
            {
                dp[i][j]=dp[i-1][j];
            }
        }
    cout<<dp[N][W]<<endl;
    
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------




Measured memory_bytes: 11100
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApplication2
{
    class Program
    {
        class Runner
        {
            public int Num { get; set; }
            public decimal time { get; set; }
            public Runner(string[] s)
            {
                Num = int.Parse(s[0]);
                time = decimal.Parse(s[1]);
            }
        }

        static void Main(string[] args)
        {
            List<Runner> finalist = new List<Runner>();
            List<Runner> looser = new List<Runner>();
            for (int i = 0; i < 3; i++)
            {
                List<Runner> list = new List<Runner>();
                for (int j = 0; j < 8; j++)
                {
                    list.Add(new Runner(Console.ReadLine().Split(' ')));
                }
                list = list.OrderBy(s=> s.time).ToList();
                finalist.AddRange(list.Take(2));
                looser.AddRange(list.Skip(2));
            }

            finalist.AddRange(looser.OrderBy(s => s.time).Take(2));


            foreach (Runner runner in finalist)
            {
                Console.WriteLine("{0} {1}", runner.Num, runner.time);
            }

        }

        
    }
}

Measured memory_bytes: 6568
N,M = (int(a) for a in input().split())
s = [[int(a) for a in input().split()] for l in range(M)]
p = list(map(int,input().split()))

ans = 0

for i in range(2**N):
    count = [0]*M
    for j in range(N) :
        if (i>>j)&1 == 1 :
            for k in range(M) :
                if j+1 in s[k][1:] :
                    count[k] += 1
    count = [i%2 for i in count]
    if count == p :
        ans += 1
print(ans)






Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0), cin.tie(0)
#define RI(x) x = rit()
#define RII(a,b) a = rit(), b = rit()
#define RIII(a,b,c) a = rit(), b = rit(), c = rit()
#define REP(I, N) for(int I=0;I<(N);I++)
#define REPP(I, N) for(int I=1;I<=(N);I++)
#define SZ(x) (int)(x).size()
#define P pair<int, int>
#define F first
#define S second
#define PB(x) push_back(x)
#define endl "\n"
#define ll long long
//#define int long long

//===================================================//

#define N 100000
#define modn 1000000007

using namespace std;
inline int rit(){
    int f=0,key=1;
    char ch;
    do{
        ch = getchar();
        if(ch=='-') key=-1;
    }while(ch<'0'||ch>'9');
    do{
        f = f*10+ch-'0';
        ch = getchar();
    }while(ch>='0'&&ch<='9');
    return f*key;
}
int a,b,c,d,e,f;
P ans;
int32_t main(void){
    RIII(a,b,c), RIII(d,e,f);
    ans.F = a*100, ans.S = 0;
    for(int ii=0;ii<=100;++ii) for(int jj=0;jj<=100;++jj) for(int kk=0;kk<=100;++kk) for(int uu=0;uu<=100;++uu){
        int i = ii*a, j = jj*b, k = kk*c, u = uu*d;
        double per = (double)ans.S / ans.F;
        int als = 100 * (i+j) + k + u ;
        if( als <= f && (k+u) <= e * (i+j) && double(k+u) / als > per ){
            ans.F = als, ans.S = u+k ;
        }
    }
    printf("%d %d\n", ans.F, ans.S);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
long long int gcd(long long int a,long long int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
} 
long long int lcm(long long int a, long long int b) {

if (a == 0 || b == 0) 
   return 0;



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

}

   
int main(void){
    // Your code here!
long long int a,b;
cin >> a >> b;
cout << lcm(a,b);
    
}


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

using namespace std;

const int N=3e5+5;

int n;
int a[N];
long long S[N];
int X[N];

int main() {
    scanf("%d\n",&n);
    for (int i=1;i<=n;++i) {
        scanf("%d",&a[i]);
        S[i]=S[i-1]+a[i];
        X[i]=X[i-1]^a[i];
    }
    long long tot=0;
    for (int i=1;i<=n;++i) {
        int l=1;
        int r=i;
        int ans=0;
        while (l<=r) {
            int mid=(l+r)/2;
            if ((X[i]^X[mid-1])==(S[i]-S[mid-1])) {
                r=mid-1;
                ans=i-mid+1;
            } else {
                l=mid+1;
            }
        }
        tot+=ans;
    }
    cout<<tot<<endl;
    return 0;
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const long long INF = 1e18;
# define len(x) ((int)(x).size())
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define foreps(i, m, n) for(int i = m;i < n;i++)
# define ALL(x) (x).begin(), (x).end()
# define rall(x) (x).rbegin(), (x).rend()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

    ll ans = 0;
    reps(i, N - 1) {
        ll cnt = 0;
        for (char c = 'a'; c <= 'z'; c++) {
            bool left = false, right = false;
            foreps(j, 0, i) {
                if (S[j] == c) left = true;
            }
            foreps(j, i, N) {
                if (S[j] == c) right = true;
            }
            if (left && right) cnt++;
        }
        ans = max(ans, cnt);
    }
    cout << ans << endl;
}

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

static const int N = 1000;
int lcs(string,string);

int main() {

  string s1,s2;
  int n; cin >> n;
  for(int i = 0;i<n;i++) {
    cin >> s1 >> s2;
    cout << lcs(s1,s2) << endl;
  }
  return 0;
}

int lcs(string X,string Y) {
  
  int c[N+1][N+1];
  int m = X.size();
  int n = Y.size();
  int maxl = 0;
  X = ' ' + X;
  Y = ' ' + Y;
  for(int i=0;i<=m;i++) c[i][0] = 0;
  for(int j=0;j<=n;j++) c[0][j] = 0;

  for(int i=1;i<=m;i++) {
    for(int j=1;j<=n;j++) {
      if(X[i] == Y[j]) {
	c[i][j] = c[i-1][j-1]+1;
      } else {
	c[i][j] = max(c[i-1][j],c[i][j-1]);
      }
      maxl = max(maxl,c[i][j]);
    }
  }

  return maxl;
}



Measured memory_bytes: 7064
#include <stdio.h>
 
using namespace std;
 
int main(){
    int n,x;
    scanf("%d",&n);
 
    for(int i = 1; i<= n; i++)
    {
        if(i%3 == 0){
            printf(" %d",i);
        }else{
            x = i;
            do{
                if(x%10 == 3){
                    printf(" %d",i);
                    break;
                }
                x /=10;
            }while(x);
        }
    }
    printf("\n");
}


Measured memory_bytes: 2708
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Console;
using static System.Math;


namespace AtCoder
{
    class AtCoderrr
    {
        static void Main(string[] args)
        {
            int[] s = ReadLine().Split(' ').Select(int.Parse).ToArray();
            int n = s[0];
            int m = s[1];
            var dic = new SortedDictionary<long, long>();
            for (int i = 0; i < n; i++)
            {
                int[] ab = ReadLine().Split(' ').Select(int.Parse).ToArray();
                if (!dic.ContainsKey(ab[0]))
                    dic[ab[0]] = 0;
                dic[ab[0]] += ab[1];
            }

            long remain = m;
            long cost = 0;
            foreach (var item in dic)
            {
                if (remain == 0) break;
                var buyCount = Min(remain, item.Value);
                cost += item.Key * buyCount;
                remain -= buyCount;
            }
            WriteLine(cost);
        }
    }

    
}


Measured memory_bytes: 25128
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;

int main() {
    int N;
    cin >> N;
    rep(i, N + 1) {
        if (i*108/100 == N) {
            cout << i << endl;
            return 0;
        }
    }
    cout << ":(" << endl;
    return 0;
}

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

#define debug(x) cout << #x" = " << x;

#define st first
#define nd second

using namespace std;
using namespace placeholders;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

int main(){
	ll a, b, c;
	scanf("%lld%lld%lld", &a, &b, &c);
	if (a == b && b == c)
		puts(a & 1 ? "0" : "-1");
	else{
		int ans = 0;
		for (; !(1 & (a | b | c)); ++ans){
			ll ta = b + c >> 1, tb = a + c >> 1, tc = a + b >> 1;
			a = ta, b = tb, c = tc;
		}
		printf("%d\n", ans);
	}
	return 0;
}


Measured memory_bytes: 256
hw = input()
hw = hw.split()
h = int(hw[0])  #hは行, 1 <= h
w = int(hw[1])  #wは列, w <= 50

board_input = []
board_output = []

for i in range(h):
    b = input()
    board_input.append(b)

dx = [1, 0, -1, 0, 1, -1, -1, 1]
dy = [0, 1, 0, -1, 1, 1, -1, -1]

for i in range(h):
    s = ""
    for j in range(w):
        if board_input[i][j] == '#':
            s += '#'
            continue

        num = 0
        for d in range(8):
            ni = i + dx[d]
            nj = j + dy[d]
            if ni > h - 1 or nj > w - 1 or ni < 0 or nj < 0:
                continue
            if board_input[ni][nj] == '#':
                num += 1
                
        s += str(num)
    board_output.append(s)


for i in range(h):
    print(board_output[i])


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main()
{
	long long a,b;
	cin>>a>>b;
	for(long long i=1;i<=10000000;i++) if((i*8)/100==a && (i*10)/100==b) {cout<<i; return 0;}
	cout<<-1;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll n,a[200];
bool check(int a,int b,int c){
    bool f1=b>min(a,c);
    bool f2=b<max(a,c);
    return f1&&f2;
}
int main(){
    cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i];
    ll ans=0;
    for(int i=2;i<=n-1;i++){
        if(check(a[i-1],a[i],a[i+1])) ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long int
#define ld long long double
#define veci vector<ll>
#define it map<string, ll>::iterator
#define itr map<char, ll>::iterator
#define MOD 1000000007
#define test int T;cin>>T;while(T--)
#define nl "\n"
#define FULL(iii) iii.begin(),iii.end()
#define setbit(_) __builtin_popcount(_)
#define MAX 9223372036854775807 
#define TOUPR(str) trsform(str.begin(), str.end(),str.begin(), ::toupper)
#define TOLWR(str) trsform(str.begin(), str.end(),str.begin(), ::tolower)
#define pb push_back
#define len(s) s.length()
//#define cout cout<<setprecision(15)
#define N "NO"
#define Y "YES"
#define maxe(arr) *max_element(FULL(arr))
#define PI 3.141592653589793

int main()
{
    fio;
    ll n,i,s=0;
    cin>>n;
    veci a(n),dp(n);
    for(i=0;i<n;i++)
    cin>>a[i];
    dp[0]=0;
    dp[1]=abs(a[0]-a[1]);
    for(i=2;i<n;i++)
    {
        dp[i]=min(dp[i-1]+abs(a[i-1]-a[i]),dp[i-2]+abs(a[i-2]-a[i]));
    }
    cout<<dp[n-1]<<nl;
}

Measured memory_bytes: 1792
n, y = map(int, input().split())

for i in range(y // 10000 + 1):
    for j in range((y - 10000 * i) // 5000 + 1):
        if 10000 * i + 5000 * j + 1000 * (n - i - j) == y:
            ans = "{} {} {}".format(i, j, n - i - j)
            print(ans)
            j += 1
            exit()

else:
    print("-1 -1 -1")

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

using namespace std;

int main() {
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  int list[3] = {a, b, c};
  sort(list, list + 3);
  for (int i = 0; i < k; i++) {
    list[2] = list[2] * 2;
  }

  cout << list[0] + list[1] + list[2] << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#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>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype

template <class T>
int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount

const double EPS = 1e-8;
typedef long long ll;
typedef pair<int, int> pint;

const int MAX = 1000000;
int c[MAX + 1];
ll f[MAX + 1];
int main()
{
	for (int i = 0; i <= MAX; ++i)
		c[i] = i;
	f[0] = 1;
	for (int i = 1; i <= MAX; ++i)
	{
		f[i] = f[i-1] + c[i];
		for (int j = 2*i; j <= MAX; j += i)
			c[j] -= c[i];
	}

	int t, n;
	scanf("%d", &t);
	while (t--)
	{
		scanf("%d", &n);
		printf("%lld\n", f[n]);
	}

	return 0;
}

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

int main()
{
  ll n, x, y; cin >> n >> x >> y;
  x--; y--;
  vector<ll> ans(n);
  for (int i=0; i<n; i++) {
    for (int j=i+1; j<n; j++) {
      ll dist = j-i;
      dist = min(dist, abs(x-i)+1+abs(y-j));
      ans[dist]++;
    }
  }
  for (int i=1; i<n; i++) {
    cout << ans[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 256
def resolve():
    MOD = 10**9+7
    N = int(input())
    S = input()

    dp = [[0]*(N) for _ in range(N)]
    for j in range(N):
        dp[0][j] = 1


    for i in range(N-1):
        # 累積和
        cum_A = [0]*(N+1)
        for j in range(N-i):
            cum_A[j+1] = (cum_A[j] + dp[i][j]) % MOD

        if S[i] == "<":
            for j in range(N-i):
                # 引き算がある為、負の mod に気を付ける
                dp[i+1][j] = (cum_A[N - i] - cum_A[j + 1] + MOD) % MOD
        else:
            for j in range(N-i):
                dp[i+1][j] = cum_A[j + 1]
    print(dp[N-1][0])


if __name__ == "__main__":
    resolve()

Measured memory_bytes: 144528
#include<iostream>
#include<map>
using namespace std;
typedef long long LL;
typedef map<LL,LL> LLm;
typedef LLm::iterator LLit;
LL h,w,n;
LLm m;
LLit it;
LL ans[10];
LL dx[9]={-2,-2,-2,-1,-1,-1,0,0,0};
LL dy[9]={-2,-1,0,-2,-1,0,-2,-1,0};
void slove(LL x,LL y){
    LL a,b;
    LL temp;
    for(int i=0;i<9;++i){
        a=x+dx[i];
        b=y+dy[i];
        if(a<1 || b<1 || a>h-2 || b>w-2)   continue;
        temp=(h-2)*(b-1)+a;
        m[temp]++;
    }
}
int main(){
    LL x,y;
    cin>>h>>w>>n;
    for(LL i=0;i<n;++i){
        cin>>x>>y;
        slove(x,y);
    }
    ans[0]=(h-3)*(w-2)+w-2;
    LL temp;
    for(it=m.begin();it!=m.end();++it){
        temp=it->second;
        ans[temp]++;
        ans[0]--;
    }
    for(LL i=0;i<=9;++i)
        cout<<ans[i]<<endl;
    return 0;
}


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

public class Main {

	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str=br.readLine();
		int n;
		int a,b,c,d;
		int count = 0;
		
		while(str!=null){
			n=Integer.parseInt(str);
			for(a=0;a<=9;a++){
				for(b=0;b<=9;b++){
					for(c=0;c<=9;c++){
						for(d=0;d<=9;d++){
							if(a+b+c+d==n){
								count++;
							}
						}
					}
				}
			}
			System.out.println(count);
			count=0;
			str=br.readLine();
		}
	}

}

Measured memory_bytes: 24844
n,k = map(int,input().split())
a = list(map(int,input().split()))
ruto = [1]
kako = [0] * (n+1)
kako[1] = 1
saki = a[0]
flag = 0
for _ in range(k):
    if kako[saki] == 1:
        where = ruto.index(saki)
        ruto = ruto[where:]
        ans = (k-where)%len(ruto)
        print(ruto[ans])
        flag = 1
        break
    else:
        ruto.append(saki)
        kako[saki] = 1
        saki = a[saki-1]
if flag == 0:    
    print(ruto[-1])

Measured memory_bytes: 32176