akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

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

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#############
# Main Code #
#############

A,B = inputIL()

print(max(0,A-2*B))


Measured memory_bytes: 63980
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

struct Node {
    int label;
    Node* lhs;
    Node* rhs;
};

Node *root_l, *root_r;

Node* parse(string s, int l, int r) {
    if(r - l == 0) return nullptr;
    int sum = 0, i = l;
    for(;; i++) {
        if(s[i] == '(') sum++;
        if(s[i] == ')') sum--;
        if(sum == 0 && s[i] == ')') {
            i++;
            break;
        }
    }

    Node* ret = new Node;
    ret -> lhs = parse(s, l+1, i-1);

    i++; // '['
    int num = 0;
    while(isdigit(s[i])) num = num * 10 + (s[i] - '0'), i++;
    ret -> label = num;
    i++; // ']'

    ret -> rhs = parse(s, i+1, r-1);
    return ret;
}

string merge(Node* nl, Node* nr) {
    int value = nl -> label + nr -> label;
    string l = "", r = "";
    if(nl -> lhs && nr -> lhs) l = merge(nl -> lhs, nr -> lhs);
    if(nl -> rhs && nr -> rhs) r = merge(nl -> rhs, nr -> rhs);
    return "(" + l + ")[" + to_string(value) + "](" + r + ")";
}

int main() {
    string s, t; cin >> s >> t;
    root_l = parse(s, 0, s.length());
    root_r = parse(t, 0, t.length());

    cout << merge(root_l, root_r) << endl;
    return 0;
}


Measured memory_bytes: 3424
#include <bits/stdc++.h>
#define int long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define td(v) v.begin(),v.end()
#define tdr(v) v.rbegin(),v.rend()
#define endl "\n"
#define Matrix vector<vector<int> >
using namespace std;
const int MOD = 1e9+7;
const int MOD2 = 1e9 + 9;
const int INF = 5e18;
 
int gcd(int a, int b){return (b == 0 ? a : gcd(b, a%b));}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
 
 
inline long long mod(long long n, long long m){
    long long ret = n%m;
    if(ret < 0) ret += m;
    return ret;
}
 
int exp(int a, int b){
    int result = 1;
    while (b > 0){
        if (b & 1)
            result = result*a;
 
        b >>= 1;
        a = a*a;
    }
    return result;
}

void solve(){
    int k;
    int a, b;
    cin>>k>>a>>b;
    for(int i=a;i<=b;i++){
        if(i%k==0){
            cout<<"OK"<<endl;
            return;
        }
    }
    cout<<"NG"<<endl;
}
 
main(){
    fastio; 
    int x=0;
    int t=1;
    // cin>>t;
    while(t--)
        solve();
}

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

int main()
{
	int n;
	cin >> n;
	int d[n];
	for (int i = 0; i < n; ++i)
	{
		cin >> d[i];
	}
	
	int ans = 0;
	for (int i = 0; i < n; ++i)
	{
		for (int j = i+1; j < n; ++j)
		{
			ans += d[i] * d[j];
		}
	}
	
	cout << ans << endl;
	
	return 0;
}


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

using namespace std;
#define taskname ""
#define pb	push_back
typedef long double ld;
typedef long long ll;
const int maxn = 2e5 + 5;
int n , a[maxn] , b[maxn];
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	//freopen(taskname".INP", "r",stdin);
	//freopen(taskname".OUT", "w",stdout);
    cin >> n;
    for(int i = 1 ; i <= n ; ++i)cin >> a[i];
    int res = 0;
    for(int i = 1 ; i <= n ; ++i)
        b[a[i]] = b[a[i] - 1] + 1 , res = max(res , b[a[i]]);
    cout << n - res;
}


Measured memory_bytes: 1792
import java.util.Scanner;


public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int n = sc.nextInt();
			int p = sc.nextInt();
			if(p+n==0)break;
			
			int[] a = new int[n];
			int i = 0;
			while(true) {
				if(p>0) {
					p--;
					a[i]++;
				}
				else {
					p = a[i];
					a[i] = 0;
				}
				if(p==0) {
					boolean flag = true;
					for(int j=0;j<n;j++)
						if(a[j] != 0 && i != j)
							flag = false;
					if(flag) break;
				}
				i = (i+1)%n;
			}
			System.out.println(i);
		}
		
	}
}


Measured memory_bytes: 27160
// テ・ツ淞コテヲツ慊ャテ」ツδ?」ツδウテ」ツδ療」ツδャテ」ツδシテ」ツδ?

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

typedef pair<int, int> pii;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

int N, M, s, t;
vector<int> G[100010];
int ca[100010], cb[100010];

vector<int> dijkstra(int s) {
    vector<int> ret(N, INF);
    ret[s] = 0;

    // dist, point
    priority_queue< pii, vector<pii>, greater<pii> > q;
    q.push(pii(0, s));

    while(!q.empty()) {
        pii t = q.top(); q.pop();
        int cost = t.first, cur = t.second;
        for(int to : G[cur]) {
            if(ret[to] > ret[cur] + 1) {
                ret[to] = ret[cur] + 1;
                q.push(pii(ret[to], to));
            }
        }
    }

    return ret;
}

signed main() {
    cin >> N >> M >> s >> t; s--; t--;
    rep(i,0,M) {
        int x, y; cin >> x >> y; x--; y--;
        G[x].push_back(y);
        G[y].push_back(x);
    }

    vector<int> da = dijkstra(s), db = dijkstra(t);
    rep(i,0,N) if(da[i] != INF) ca[ da[i] ]++;
    rep(i,0,N) if(db[i] != INF) cb[ db[i] ]++;

    
    int dist = da[t], ans = 0;
    repq(i,0,dist-2) {
        int j = dist - 2 - i;
        ans += ca[i] * cb[j];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 13348
n, m = [int(x) for x in raw_input().split()]

t = [[] for i in xrange(n)]

for i in xrange(m):
    a, b = [int(x) - 1 for x in raw_input().split()]
    t[a].append(b)
    t[b].append(a)

pre = [a]
pos = [b]
visited = {a, b}

while 1:
    for ne in t[pre[-1]]:
        if ne not in visited:
            visited.add(ne)
            pre.append(ne)
            break
    else:
        break


while 1:
    for ne in t[pos[-1]]:
        if ne not in visited:
            visited.add(ne)
            pos.append(ne)
            break
    else:
        break

print(len(pre) + len(pos))
print(" ".join(str(x + 1) for x in reversed(pre)) + " " + " ".join(str(x + 1) for x in pos))


Measured memory_bytes: 29940
#include<bits/stdc++.h>
using namespace std;
#define int long long
int N,K,h[100000+10]={},dp[100000+10]={},ans=0;

signed main(){
  cin >> N >> K;
  for(int i=1;i<=N;i++){
    cin >> h[i];
  }

  for(int i=1;i<=min(K+1,N);i++){
    dp[i]=abs(h[1]-h[i]);
  }


  for(int i=K+2;i<=N;i++){
    int tmp=dp[i-1]+abs(h[i]-h[i-1]);
    for(int j=i-K;j<i-1;j++){
      tmp=min(tmp,dp[j]+abs(h[j]-h[i]));
    }
    dp[i]=tmp;
  }
  cout << dp[N] << endl;
  return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=double;
using pll=pair<ll,ll>;
using vll=vector<ll>;
using vpll=vector<pll>;
using vvll=vector<vll>;
#define FOR(i,a,b) for(ll i=a;i<(ll)b;++i)
#define ROF(i,a,b) for(ll i=a;i>=(ll)b;--i)
#define F(n) FOR(i,0,n)
#define FF(n) FOR(j,0,n)
#define aa first
#define bb second
#define PB push_back
#define EQ(a,b) (fabs(a-b)<=(fabs(a+b)*EPS))

int main(){
  ios::sync_with_stdio(0);cout.tie(0);cin.tie(0);
  ll n;
  cin >> n;
  ll res = 0;
  F(n) {
    ll t;
    cin >> t;
    res += t;
  }
  cout << res - n << endl;

  return 0;
}


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

#define rep(i,n) for(int i=0;i<(n);i++)

typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//定数
#define INF 1000000000 //10^9:極めて大きい値,∞
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

int main(){
    ll x,k,d,c=0;
    cin>>x>>k>>d;
    x=abs(x);
    ll s=x/d;
    if(s>k){
        cout<<x-d*k<<endl;
        return 0;
    }
    else{
        k-=s;
    }
    ll a;
    if(k%2==0) a=x-d*s;
    else a=abs(x-d*(s+1));
    cout<<a<<endl;
    return 0;
}

Measured memory_bytes: 3580
N = int(input())
A = list(map(int,input().split()))
B = []
for k in range(N):
    B.append(A[k]-(k+1))
t = sorted(B)[N//2]
ans = 0
for k in range(N):
    ans += abs(A[k]-(t+k+1))
print(ans)


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

#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;
 
const ll INF = 1LL<<60;
const int MINF = 1e9;
const int MOD = 1e9+7;

using vi = vector<int>;
using vii = vector<vi>;

template<typename T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}


int main(){
    int n;cin >> n;
    vi t(n);
    vector<string> s(n);
    rep(i,n){
        cin >> s[i] >> t[i];
    }
    string x;cin >> x;
    int ans = 0;
    bool flag = false;
    for(int i=0;i<n;i++){
        if(flag){
            ans += t[i];
        }else{
            if(s[i] == x)flag = true;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#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);
ll n,c=0;
ll flag=0;
cin>>n;
ll a[3];
while(n>0)
{
    a[c++]=n%10;
    n=n/10;
}
for(ll i=0;i<3;i++)
{
    //cout<<a[i]<<" ";
    if(a[i]==7)
    {
       flag=1; 
       break;
    }
}
if(flag==1)
cout<<"Yes"<<endl;
else
cout<<"No"<<endl;
 return 0;
}

Measured memory_bytes: 3612
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1000000007
typedef long long ll;
using namespace std;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

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

    int N;
    cin >> N;
    vector<int> a(N);
    REP(i, N) cin >> a[i];

    int sum = 0;
    REP(i, N) sum += a[i];
    int b = sum / N;
    int c = b + 1;

    int ans_b = 0;
    int ans_c = 0;
    REP(i, N) {
        ans_b += (a[i] - b) * (a[i] - b);
        ans_c += (a[i] - c) * (a[i] - c);
    }

    std::cout << min(ans_b, ans_c) << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,k,a=1;
int main()
{
     cin>>n>>k;
     for(int i=0;i<n;i++)
    {
        if(a>k)  a+=k;
        else 
        a*=2;

    }
    cout<<a<<endl;

    return 0;
}

Measured memory_bytes: 256
#![allow(
    non_snake_case,
    unused_variables,
    unused_assignments,
    unused_mut,
    dead_code
)]
use proconio::input;
// use proconio::marker::Usize1;
//use proconio::marker::Chars;
//use std::collections::HashSet;
//use std::cmp::*;
fn main() {
    input! {
       mut n:u64
    }
    // 26^4+26^3+(26^2+26)
    // 2^50以下の数。
    // 1_000_000_000_000_001 < 26^11
    let mut ans: String = String::new();
    for i in 0..11 {
        n = n - 1;
        ans.push(((n % 26) as u8 + 'a' as u8) as char);
        n = n / 26;
        if n == 0 {
            break;
        }
    }
    println!("{}", ans.chars().rev().collect::<String>());
}


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


int main(){
    int n;
    cin>>n;
    string s,t,ans;
    cin>>s>>t;
    rep(i,n){
        ans+=s[i];
        ans+=t[i];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <chrono>

using namespace std;

int main(int argc, const char * argv[]) {

    ios::sync_with_stdio(false);
    cin.tie(0);

    int64_t x, y; cin >> x >> y;
    int64_t ans1, ans2, ans3, ans4;
    const int64_t INF = 1e+12;
    
    ans1 = (y >= x ? y - x : INF);
    ans2 = (-y >= x ? -y - x + 1 : INF);
    ans3 = (y >= -x ? y - (-x) + 1 : INF);
    ans4 = (-y >= -x ? (-y) - (-x) + 2 : INF);
    
    cout << min({ans1, ans2, ans3, ans4}) << endl;

    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

//コンテスト後に解説見たやつ

func main() {
	var s string
	var K int
	fmt.Scan(&s)
	fmt.Scan(&K)

	var substrs []string

	for i := 0; i < len(s); i++ {
		for j := min(i+5, len(s)); j > i; j-- {
			if !strSearch(substrs, s[i:j]) {
				substrs = append(substrs, s[i:j])
			}
		}
	}
	sort.Strings(substrs)

	fmt.Println(substrs[K-1])
}

func min(x, y int) int {
	if x < y {
		return x
	} else {
		return y
	}
}
func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}


Measured memory_bytes: 1664
import java.util.*;
import java.lang.*;
public class Main
{  
    public static void main(String args[])
    {
        Scanner sc = new Scanner(System.in);
        Integer n = sc.nextInt(); int ans = 0;
        if(n>=500) {
            ans = (n/500)*1000;
            n = n%500;
        }
        if(n >= 5) {
            ans += (n/5)*5;
        }
        System.out.println(ans);
    }
}

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

#define ll long long int

int t[100005];

int frog(int a[],int n,int i)
{
     if(i==n-1)
     return 0;
  	 else if(t[i]!=-1)
       return t[i];
     else if(i==n-2)
       return t[i]=(abs(a[i+1]-a[i])+frog(a,n,i+1));
	  else
     return t[i]=min((abs(a[i+2]-a[i])+frog(a,n,i+2)),(abs(a[i+1]-a[i])+frog(a,n,i+1)));
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
     int n;
     cin>>n;
     int a[n];
     for(int i=0;i<n;i++)
     {
          cin>>a[i];
     }
     memset(t,-1,sizeof(t));
     cout<<frog(a,n,0)<<"\n";
	return 0;
}


Measured memory_bytes: 8832
import java.util.*;
import java.math.*;
import java.lang.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
		int d = sc.nextInt();

		List<List<Integer>> list = new ArrayList<>();

		for (int i = 0; i < n; i++) {
			List<Integer> xList = new ArrayList<>();
			for (int j = 0; j < d; j++) {
				int xnd = sc.nextInt();
				xList.add(xnd);
			}
			list.add(xList);
		}


		int resultCount = 0;
		for (int i = 0; i < n; i++) {
			List<Integer> xiList = list.get(i);
			for (int l = i; l < n; l++) {
				if(i==l){
					continue;
				}
				List<Integer> xlList = list.get(l);
				int lengthDouble = 0;
				for (int j = 0; j < d; j++) {
					int xi = xiList.get(j);
					int xl = xlList.get(j);
					lengthDouble += (xi-xl) * (xi-xl);
				}
				double length = Math.sqrt(lengthDouble);
				// System.out.println("length "+length);
				// System.out.println("isNumber "+isNumber(length));


				if(isNumber(length)){
					resultCount++;
				}

			}
		}

			System.out.println(resultCount);

	}

	public static boolean isNumber(double val) {
		if ((val == Math.floor(val)) && !Double.isInfinite(val)) {
			return true;
		}
		return false;
	}

}


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

typedef long long ll;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string in;
  cin >> in;
  int l = in.length();
  int result = 0;
  for(int i = 0; i < l / 2; i++) {
    if(in[i] != in[l - 1 - i]) result++;
  }
  printf("%d", result);
  return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define RALL(n) rbegin(n),end(n)
#define MOD (1000000007)
#define INF (2e9)
#define INFL (2e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
using vint=vector<int>;
using vll=vector<ll>;
template<class T>using arr=vector<vector<T>>;
template<class T>int popcount(T &a){int c=0; rep(i, 8*(int)sizeof(a)){if((a>>i)&1) c++;} return c;}
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[i]);}
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()
{
    int n; string s;
    cin >> n >> s;

    vint w(n), b(n);
    if(s[0]=='#') b[0]++;
    rep(i, n-1){
        b[i+1] += b[i];
        if(s[i+1]=='#') b[i+1]++;
    }

    if(s[n-1]=='.') w[n-1]++;
    for(int i=n-1; i>0; i--){
        w[i-1] += w[i];
        if(s[i-1]=='.') w[i-1]++;
    }

    int ans = INF;
    rep(i, n+1){
        if(i==0) chmin(ans, w[i]);
        else if(i==n) chmin(ans, b[i-1]);
        else chmin(ans, b[i-1] + w[i]);
    }
    pr(ans);
    return 0;}

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

int main(){
    int W,H,x,y,r;
    cin >> W >> H >> x >> y >> r;

    if(x<=0){
        cout << "No" << endl;
    }else if(y<=0){
            cout << "No" << endl;
        }else if(r+x<=W){
        if(r+y<=H){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }else{
        cout << "No" << endl;
    }

    return 0;
}




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

int main(){
    int N; cin >> N;
    vector<Int> A(N+1), S(N+1, 0);
    rep1(i,N){
        cin >> A[i];
        S[i] = A[i] + S[i-1];
    }



    
    //+-+-
    Int ans1 = 0, changes1 = 0;
    rep1(i,N){
        Int S_now = S[i] + changes1;

        if(i%2 == 1 && S_now <= 0){
            changes1 += -S_now + 1;
            ans1 += -S_now + 1;
        } else if(i%2 == 0 && S_now >= 0){
            changes1 -= S_now + 1;
            ans1 += S_now + 1;
        }
    }

    //-+-+
    Int ans2 = 0, changes2 = 0;
    rep1(i,N){
        Int S_now = S[i] + changes2;

        if(i%2 == 0 && S_now <= 0){
            changes2 += -S_now + 1;
            ans2 += -S_now + 1;
        } else if(i%2 == 1 && S_now >= 0){
            changes2 -= S_now + 1;
            ans2 += S_now + 1;
        }
    }

    cout << min(ans1,ans2) << endl;
}


Measured memory_bytes: 1792
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);
	static boolean debug = false;

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

	static boolean solve() {
		int t = in.nextInt();
		int n = in.nextInt();
		if (t + n == 0) return false;

		boolean[][] visited = new boolean[1000][1000];
		for (int i=0; i<n; i++) {
			int x = in.nextInt() + offset;
			int y = in.nextInt() + offset;
			visited[x][y] = true;
		}

		int sx = in.nextInt() + offset;
		int sy = in.nextInt() + offset;

		ArrayDeque<int[]> deq = new ArrayDeque<>();
		int ans = 0;
		deq.add(new int[]{sx, sy, t});
		visited[sx][sy] = true;

		while (!deq.isEmpty()) {
			int[] cur = deq.pollFirst();
			int cx = cur[0], cy = cur[1];
			int ct = cur[2];
			ans++;
			if (ct == 0) continue;

			for (int i=0; i<6; i++) {
				int nx = cx + dx[i];
				int ny = cy + dy[i];
				if (!visited[nx][ny]) {
					visited[nx][ny] = true;
					deq.add(new int[]{nx, ny, ct-1});
				}
			}
		}
		out.println(ans);

		return true;
	}

	public static void main(String[] args) {
		debug = args.length > 0;
		long start = System.nanoTime();

		while(solve());
		out.flush();

		long end = System.nanoTime();
		dump((end - start) / 1000000 + " ms");
		in.close();
		out.close();
	}

	static void dump(Object... o) { if (debug) System.err.println(Arrays.deepToString(o)); }
}

Measured memory_bytes: 110680
import collections

n = input()
line = input().split()
odd = line[::2]
even = line[1::2]
o = collections.Counter(odd)
e = collections.Counter(even)
maxoddcnt = o.most_common()[0][1]
maxevencnt = e.most_common()[0][1]

#すべての値が同じときは半分を置換する
if odd == even and len(o.most_common()) == 1:
    print(len(odd))
    exit(0)

#奇数列，偶数列それぞれの最頻の文字が同じ場合は，いずれかを2番目に多い文字に置換しなければならない
if o.most_common()[0][0] == e.most_common()[0][0]:
    if len(o.most_common()) > 1 and len(e.most_common()) <= 1:
        maxoddcnt = o.most_common()[1][1]
    if len(o.most_common()) <= 1 and len(e.most_common()) > 1:
        maxevencnt = e.most_common()[1][1]
    if o.most_common()[1][1] + e.most_common()[0][1] >= o.most_common()[0][1] + e.most_common()[1][1]:
        maxoddcnt = o.most_common()[1][1]
    else: #if o.most_common()[1][1] + e.most_common()[0][1] <= o.most_common()[0][1] + e.most_common()[1][1] :
        maxevencnt = e.most_common()[1][1]

print(len(odd)-maxoddcnt+len(even)-maxevencnt)


Measured memory_bytes: 22764
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<int>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;


int main(){
  int i,j;
  int n;
  cin>>n;
  ll a[n],b[n],aa[n],bb[n];
  for(i=0;i<n;i++) cin>>a[i];
  for(i=0;i<n;i++) cin>>b[i];
  for(i=0;i<n;i++){
    aa[i]=a[i]^a[(i+1)%n];
    bb[i]=b[i]^b[(i+1)%n];
  }
  
  VI S(3*n);
  for(i=0;i<n;i++){
    S[i]=bb[i];
    S[i+n]=aa[i];
    S[i+2*n]=aa[i];
  }

  VI A(3*n,0);

  A[0]=3*n;

  i = 1, j = 0;
  while (i < 3 * n) {
    while (i+j < 3 * n && S[j] == S[i+j]) ++j;
    A[i] = j;
    if (j == 0) { ++i; continue;}
    int k = 1;
    while (i+k < 3 * n && k+A[k] < j) A[i+k] = A[k], ++k;
    i += k; j -= k;
  }

  for(i=0;i<n;i++){
    if(A[i+n]>=n){
      cout<<i<<" "<<(a[i]^b[0])<<endl;
    }
  }
  return 0;
}


Measured memory_bytes: 14336
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = int_fast64_t;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

vector<int> a, dp;
int grundy(int x) {
  if(dp[x] >= 0) return dp[x];
  set<int> s;
  for(const int y : a) if(x - y >= 0) s.emplace(grundy(x - y));
  int res = 0;
  while(s.count(res) != 0) res++;
  return dp[x] = res;
}
void answer() {
  int n, k;
  cin >> n >> k;
  a.assign(n, 0);
  dp.assign(k+1, -1);
  rep(i, n) cin >> a[i];
  dp[0] = 0;
  REPC(i, 1, k) grundy(i);
  if(grundy(k) == 0) cout << "Second\n";
  else cout << "First\n";
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

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

int main(int argc, char const* argv[])
{
	int H, W;
	

	while((cin >> H >> W) && (H || W)){
		for (int i=0; i<H; i++) {
			for (int j=0; j<W; j++) {
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

string s;
long long ans;

void solve(int index, long long sum)
{
    if(index == s.size())
    {
        ans += sum;
        return;
    }
    long long int sum1 = 0;
    for(int i = index; i < s.size(); i++)
    {
        sum1 = (sum1 * 10) + (s[i] - '0');
        solve(i + 1, sum1 + sum);
    }
}

int main()
{
    cin >> s;
    solve(0, 0);
    cout << ans;
    return 0;
}





Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cassert>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<list>
#include <cstring>
#include <functional>
//#include<unordered_map>
//#include<unordered_set>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF ((Int)1<<60)
#define EPS (1e-10)
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define RREP(i,n) for(int i=1; i<=(int)(n); ++i)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
typedef long long Int;
typedef pair<Int, Int> P;
typedef vector<double> vec;
typedef vector<vec> mat;
const int N = 100005;
//////////////////////////////

int n;
char color[4400];
int a[4400], pos_w[4400], pos_b[4400];
int dp[2200][2200], 
cnt_w[4400][4400],// [i, n*2)にあるj以下の数の個数（白色の） 
cnt_b[4400][4400];// [i, n*2)にあるj以下の数の個数（黒色の）

void solve()
{
	memset(pos_w, -1, sizeof pos_w); 
	memset(pos_b, -1, sizeof pos_b);

	cin >> n;
	REP(i, n * 2) {
		cin >> color[i] >> a[i]; a[i]--;
		if (color[i] == 'W') pos_w[a[i]] = i;
		else pos_b[a[i]] = i;
	}

	for (int i = n * 2 - 1; i >= 0; i--) {
		for (int h = 0; h <= i; h++) {
			if (color[i] == 'W') cnt_w[h][a[i]]++;
			else cnt_b[h][a[i]]++;
		}
	}
	REP(i, n * 2) {
		for (int j = 1; j<(n * 2); j++) {
			cnt_w[i][j] += cnt_w[i][j - 1];
			cnt_b[i][j] += cnt_b[i][j - 1];
		}
	}

	REP(i, 2200) REP(j, 2200) dp[i][j] = INF;
	dp[0][0] = 0;
	for (int i = 0; i <= n; i++)for (int j = 0; j <= n; j++) { // 白:0, 1, ..., i-1まで置いた；次置くのはi
		if (i<n) {
			int cost_w = 0;
			if (i - 1 >= 0) cost_w += cnt_w[pos_w[i]][i - 1];
			if (j - 1 >= 0) cost_w += cnt_b[pos_w[i]][j - 1];
			dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + cost_w);
		}
		if (j<n) {
			int cost_b = 0;
			if (j - 1 >= 0) cost_b += cnt_b[pos_b[j]][j - 1];
			if (i - 1 >= 0) cost_b += cnt_w[pos_b[j]][i - 1];
			dp[i][j + 1] = min(dp[i][j + 1], dp[i][j] + cost_b);
		}
	}
	cout << dp[n][n] << endl;
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(13);
	solve();
	return 0;
}



Measured memory_bytes: 160128
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

#define rep(i, n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

int main() {
    ll n,c,k;
    cin>>n>>c>>k;
    vector<ll> t(n);
    rep(i,n){cin>>t[i];t[i]+=k; }
    sort(t.begin(),t.end());
    ll ans = 0;
    ll no = 0;
    ll ma = 0;
    for(int i=0;i<n;i++){
        if(no==0){
            ma=t[i];
            ans++;
            no++;
        }else if(t[i]-k<=ma&&no<c){
            no++;
        }else{
            no=0;
            i--;
        }
    }

    cout<<ans<<endl;




    return 0;
}


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

int main() {
  int n;
  cin >> n;
  
  for (int i; i < n; i++) {
    string color;
    cin >> color;
    
    if (color == "Y") {
      cout << "Four" << endl;
      break;
    }
    
    else if (i < n - 1)
      continue;
    
    else
      cout << "Three" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
   int a,b,c,d;
   cin>>a>>b>>c>>d;
   if(a==b){
       if(b!=c&&c==d)cout<<"yes"<<endl;
       else cout<<"no"<<endl;
   }else if(a==c){
       if(a!=b&&b==d)cout<<"yes"<<endl;
       else cout<<"no"<<endl;
   }else if(a==d){
       if(a!=b&&b==c)cout<<"yes"<<endl;
       else cout<<"no"<<endl;
   }else cout<<"no"<<endl;
    
}

Measured memory_bytes: 3072
import java.util.*;
public class Main {
	static Scanner sc = new Scanner(System.in);
	static int a, b, o, ab;
	static String[] line = new String[2];
	public static void main(String[] args) {
		while(read()){

		}
		System.out.println(a);
		System.out.println(b);
		System.out.println(ab);
		System.out.println(o);
	}
	static boolean read(){
		if(!sc.hasNext())return false;
		line = sc.next().split(",");
		char word = line[1].charAt(0);
		if(word == 'A' && line[1].length() == 1){
			a++;
		}else if(word == 'A' && line[1].length() == 2){
			ab++;
		}
		if(word == 'B'){
			b++;
		}else if(word == 'O'){
			o++;
		}
		return true;
	}
}

Measured memory_bytes: 11000
N,Q=map(int,input().split())
S=input()
AC=[0]*N

cnt=0
for i in range(N-1):
    if S[i]+S[i+1]=='AC':
        AC[i]=cnt
        cnt+=1
        AC[i+1]=cnt
    else:
        AC[i],AC[i+1]=cnt,cnt

for _ in range(Q):
    l,r=map(int,input().split())
    print(AC[r-1]-AC[l-1])

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

int main(void) {
	int ans, pos;
	char str[1001];
	int i;
	
	while (scanf("%s", str), strcmp(str, "0")){
		ans = 0;
		pos = 0;
		
		while (str[pos] != '\0'){
			ans += str[pos] - '0';
			pos++;
		}
		
		printf("%d\n", ans);
	}
	
	return 0;
}

Measured memory_bytes: 536
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;

#define int long long int
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define rep(i,a,b) for (int i = a; i < b; ++i)
#define IOS ios::sync_with_stdio(false); cin.tie(NULL);
#ifndef LOCAL
#define dbg(...) ;
#define endl '\n'
#endif

const int inf = 1e15;
const int MOD = 1e9 + 7;
const int N = 2e5 + 5;



signed main(){
    IOS;
    int a, b;
    cin >> a >> b;
    cout << a * b << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iomanip>

using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}


void solve(long long N, long long K, std::string S){
  char pre = S[0];
  ll cnt = 1;
  vector<pair<char, ll>> v;
  vector<ll> vv;
  for(int i=1; i<N; i++) {
    if(pre==S[i])
      cnt++;
    else {
      v.push_back(make_pair(pre, cnt));
      pre = S[i];
      cnt = 1;
    }
  }
  v.push_back(make_pair(pre, cnt));
  ll ans = v[0].second;
  for(ll i=1; i<v.size() and i<=2*K; i++) {
    ans+=v[i].second;
  }
  ans--;
  for(ll i=2*K+1; i<v.size(); i++) {
    ans+= v[i].second-1;
  }
  std::cout << ans << std::endl;
}

int main(){
  long long N;
  scanf("%lld",&N);
  long long K;
  scanf("%lld",&K);
  std::string S;
  std::cin >> S;
  solve(N, K, S);
  return 0;
}



Measured memory_bytes: 2676
#29 C - Flip,Flip, and Flip......
N,M = map(int,input().split())
N,M = min(N,M), max(N,M)

if N == 1 and M == 1:
    ans = 1
elif N == 1 and M != 1:
    ans = M - 2
elif N == 2 :
    ans = 0
else:
    ans = M*N - (2*M + 2*N) + 4
print(ans)

Measured memory_bytes: 9180
import java.util.*;
 
public class Main{
    
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int[] a = new int[n];
        for(int i = 0; i < n; i++){
            a[i] = sc.nextInt();
        }
        sc.close();

        if(n % 2 == 0){
            for(int i = n-1; i>=0; i = i-2)
                System.out.print(a[i] + " ");
            for(int i = 0; i<=n-2; i = i+2)
                System.out.print(a[i] + " ");
        } else {
            for(int i = n-1; i>=0; i = i-2)
                System.out.print(a[i] + " ");
            for(int i = 1; i<=n-1; i = i+2)
                System.out.print(a[i] + " ");
        }
    }
}

Measured memory_bytes: 92052
#include <iostream>
#include <vector>
#include <cmath>
#include <cstdio>

using namespace std;

typedef pair<int, int> P;
typedef pair<P, P> Q;
typedef pair<int, Q> R;

double diff(P a, P b) {
	double x = (double)a.first-(double)b.first;
	double y = (double)a.second-(double)b.second;
	return sqrt(x*x+y*y);
}

double ff(int a) {
	return (double)a/60.0;
}

int main() {
	int n;
	cin >> n;
	vector<R> data(n);
	int f, a, t, x, y;
	for (int i = 0; i < n; i++) {
		cin >> f >> a >> t >> x >> y;
		data[i] = R(f, Q(P(a, t), P(x, y)));
	}
	double amax, at, bmax, bt;
	amax = at = bmax = bt = 0.0;
	for (int i = 0; i < n-1; i++) {
		//cout << 'b' << endl;
		if ((((data[i].second).first).second == ((data[i+1].second).first).second) && (((data[i].second).first).first != ((data[i+1].second).first).first)) {
			//cout << ((data[i].second).first).first << ' ' <<  ((data[i+1].second).first).first << endl;
			if (((data[i].second).first).second == 0) {
				if (diff((data[i].second).second, (data[i+1].second).second) > amax) {
					amax = diff((data[i].second).second, (data[i+1].second).second);
					at = ff(data[i+1].first-data[i].first);
				} else if (diff((data[i].second).second, (data[i+1].second).second) == amax) {
					at = min(at, ff(data[i+1].first-data[i].first));
				}
			} else {
				if (diff((data[i].second).second, (data[i+1].second).second) > bmax) {
					bmax = diff((data[i].second).second, (data[i+1].second).second);
					bt = ff(data[i+1].first-data[i].first);
				} else if (diff((data[i].second).second, (data[i+1].second).second) == bmax) {
					bt = min(bt, ff(data[i+1].first-data[i].first));
				}
			}
		}
	}
	if (amax == 0.0) {
		cout << -1 << ' ' << -1 << endl;
	} else {
		printf("%.10f %.10f\n", amax, at);
	}
	if (bmax == 0.0) {
		cout << -1 << ' ' << -1 << endl;
	} else {
		printf("%.10f %.10f\n", bmax, bt);
	}
	return 0;
}

Measured memory_bytes: 1268
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")
}

fn main() {
    let n: usize = read();
    let mut cx: i64 = 0;
    let mut cy: i64 = 0;
    let mut ct: i64 = 0;
    let mut ans = String::from("Yes");
    for _ in 0..n {
        let nt: i64 = read();
        let nx: i64 = read();
        let ny: i64 = read();

        let t = nt - ct;
        let x = (nx - cx).abs();
        let y = (ny - cy).abs();

        if x + y > t || (x + y) % 2 != t % 2 {
            ans = "No".to_string();
        }

        cx = nx;
        ct = nt;
        cy = ny;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
d,g=map(int,input().split())
s=[list(map(int,input().split())) for _ in range(d)]
from itertools import product
ans=10000
for b in product([0,1],repeat=d):
  t=0
  sc=0
  mi=0
  for i in range(d):
    if b[i]:
      t+=s[i][0]
      sc+=(s[i][1]+(i+1)*100*s[i][0])
    else:
      mi=i
  z=-(-max(0,g-sc)//((mi+1)*100))
  if z>s[mi][0]-1:
    continue
  ans=min(ans,t+z)
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <vector>

using namespace std;

int main()
{
 long long int i,j=0,n,m,mod=1000000007;
 cin>>n>>m;
 if (m==0){
  vector<long long int> d(n+1);
  d[0]=1;
  d[1]=1;
  for (i=2;i<=n;i++){
   d[i]=(d[i-1]+d[i-2])%mod;
  }
  cout<<d[n]<<endl;
 }
 else {
  vector <int> a(m);
  vector<long long int> d(n+1);
  for (i=0;i<m;i++){
   cin>>a[i];
  }
  for (i=2;i<=n;i++){
   d[i]=0;
  }
  d[0]=1;
  for (i=1;i<=n;i++){
   if (a[j]==i){
    j++;
   }
   else if (i==1){
    d[i]=d[i-1]%mod;
   }
   else {
    d[i]=(d[i-1]+d[i-2])%mod;
   }
  }
  cout<<d[n]<<endl;
 }
 return 0;
}

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

int main(){
    string s;
    while(cin >> s, s != "#"){
        vector<string> v;
        int pos = 0;
        string acc = "";
        while(pos < s.length()){
            if(s[pos] == '/'){
                v.push_back(acc);
                acc = "";
            }else if(s[pos] == 'b'){
                acc += "b";
            }else{
                for(int i = 0; i < s[pos]-'0'; i++) acc += ".";
            }
            pos++;
        }
        v.push_back(acc);
        int h = v.size(), w = v[0].size();
        int di, dj;
        cin >> di >> dj;
        v[di-1][dj-1] = '.';
        cin >> di >> dj;
        v[di-1][dj-1] = 'b';
        for(int i = 0; i < h; i++){
            int j = 0;
            while(j < w){
                if(v[i][j]=='b'){
                    cout << 'b';
                    j++;
                }else{
                    int nj = j;
                    while(nj < w && v[i][nj]=='.')  nj++;
                    cout << nj-j;
                    j = nj;
                }
            }
            cout << "/\n"[i+1==h];
        }
    }
    return 0;
}


Measured memory_bytes: 3160
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A: Maximize the Formula
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int N = 3;

/* typedef */

/* global variables */

int as[N];

/* subroutines */

/* main */

int main() {
  for (int i = 0; i < N; i++) scanf("%d", &as[i]);
  sort(as, as + N);

  printf("%d\n", as[2] * 10 + as[1] + as[0]);
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
 
int main(){
    int n,i,max=0,imax,a,N,data[3];
    scanf("%d",&N);
    for(n=0;n<N;n++){
        scanf("%d %d %d",&data[0],&data[1],&data[2]);
         for(i=0;i<3;i++){
            if(data[i]>max){
                max=data[i];
                imax=i;
            }
        }
        if(imax!=2){
            data[imax]=data[2];
            data[2]=max;
        }
        a=data[0]*data[0]+data[1]*data[1];
        if(data[2]*data[2]==a)printf("YES\n");
        else printf("NO\n");
        max=0;
    }
    return 0;
}

Measured memory_bytes: 580
#include<bits/stdc++.h>
#define ll  long long
#define pb push_back
#define pii pair<int,int>
#define vi vector<ll>

#define sz(x) ((int) (x).size())
#define pll pair<long long,long long>
#define mp make_pair
#define F first
#define S second
#define T int tt; cin>>tt; while(tt--)
#define fastio ios_base::sync_with_stdio(false);
 
#define endl '\n'
#define all(a) (a).begin(), (a).end()
#define display(x) for(auto i : x) cout << i << " "; cout << '\n';
#define input(x) for(int i = 0; i < n; i++) cin >> x[i];
#define make(x,y) fill(all(x), y)     
#define FO(i,startLoop,n) for (int i = startLoop; i < n; i++)

#define mod 1000000007
#define Y cout<<"YES"<<endl;
#define N cout<<"NO"<<endl;
#define ITFO(myiterator, mymap) for(auto myiterator = mymap.begin(); myiterator!=mymap.end(); ++myiterator)
using namespace std;  
 

int main()
{
    fastio
    cin.tie(NULL); cout.tie(0);
    
     
  
  int n;cin>>n; int dp[n+1][3];
  FO(i, 0, n+1) FO(j, 0, 3) dp[i][j] = 0;

  for(int i=1; i<=n; ++i)
  {
    // cout<<dp[i][0]<<" "<<dp[i][0]<<"  "<<dp[i][0]<<endl;
    int a, b, c;
    cin>>a>>b>>c;
    // cout<<a<<"  "<<b<< "  "<<c <<endl;;
    dp[i][0] = a + max(dp[i-1][1], dp[i-1][2]);
    dp[i][1] = b + max(dp[i-1][0], dp[i-1][2]);
    dp[i][2] = c + max(dp[i-1][1], dp[i-1][0]);

    // cout<<dp[i][0]<<" "<<dp[i][1]<<"  "<<dp[i][2]<<endl;
  }
  cout<<max( dp[n][0], max( dp[n][1], dp[n][2]));
  
  cerr << "\nTime elapsed: "<< 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
   return 0;
}

Measured memory_bytes: 1408
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            int c = in.nextInt();
            if (b < a)
                out.println(0);
            else
                out.println(Math.min(b / a, c));
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

    }
}



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

auto keta(ll n) {
    ll res;
    for(ll i = 0; i < 100; i++) {
        n = n / 10;

        if(n == 0) {
            res = i + 1;
            break;
        }
    }
    return res;
}

int main() {
    int n;
    cin >> n;
    vector<int> d(n);
    rep(i, n) cin >> d[i];
    sort(d.begin(), d.end());
    int cnt = 1;
    rep(i, n - 1) {
        if(d[i] != d[i + 1]) {
            cnt++;
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

int main()
{
  ll a, b;
  cin >> a >> b;
  cout << lcm(a, b) << endl;  
  
  return 0;
}

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int mod = (int)1e9+7;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


ll cal(ll s){
	if(s<=0) return 0;
	int q2=s%4;
	if(q2%2) return q2<2? 1:0;
	return s + (q2? 1: 0);

}

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

	ll a,b;
	cin >>a >>b;
	
	ll r= cal(a-1), t=cal(b);
	
	cout <<  (t^r) <<"\n";

	return 0;
}




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

using namespace std;

using ll = long long;

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

    set<int> s;
    for (int i = 1; i <= n; i++) s.insert(i);

    for (int i = 0; i < k; i++) {
        int d;
        cin >> d;
        for (int j = 0; j < d; j++) {
            int a;
            cin >> a;
            s.erase(a);
        }
    }

    cout << s.size() << endl;

    return 0;
}

Measured memory_bytes: 3636
#include "stdio.h"

int main(){
    int a=0,b=0,ret=0;
    double c=0;
    ret = scanf("%d %d",&a,&b);
    if( ret == EOF ) {
    printf( "error in scanf\n");
    return -1;
  }
    c = (double)a/b;
    printf("%f",c);
    return 0;
}

Measured memory_bytes: 128