akhauriyash/Code-Regression huggingface dataset:
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
//#define INF (INT_MAX/2)
#define EPS (1.0e-8)
//#define LINF (LLONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif


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

    int N; cin >> N;
    vi A(N); REP(i, N) cin >> A[i];
    deque<int> dq;
    dq.push_back(A[0]);
    FOR(i,1,N) {
        if (i%2==1) {
            dq.push_back(A[i]);
        } else {
            dq.push_front(A[i]);
        }
    }

    vi b;
    if (N%2==0) {
        while(!dq.empty()) {
            b.push_back(dq.back());
            dq.pop_back();
        }
    } else {
        while(!dq.empty()) {
            b.push_back(dq.front());
            dq.pop_front();
        }
    }

    cout << b[0];
    FOR(i,1,N){
        cout << " " << b[i];
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 4728
a,b,m = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
x = []
y = []
c = []
for i in range(m):
    val1,val2,val3 = map(int,input().split())
    x.append(val1)
    y.append(val2)
    c.append(val3)

ans = []
ans.append(min(a) + min(b))

for i in range(m):
    ans.append(a[x[i]-1] + b[y[i]-1] - c[i])

print(min(ans))

Measured memory_bytes: 27820
package main

import (
	"fmt"
	"sort"
)

func nextInt() int {
	var x int
	fmt.Scan(&x)
	return x
}

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

func main() {
	N := nextInt()

	A := make([]int, N)
	B := make([]int, N)
	for i := range make([]struct{}, N) {
		A[i] = nextInt()
		B[i] = A[i] - i
	}
	sort.Ints(B)
	b := (B[(N-1)/2] + B[N/2]) / 2

	ans := 0
	for i := range make([]struct{}, N) {
		ans += abs(B[i] - b)
	}
	fmt.Println(ans)
}


Measured memory_bytes: 7680
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;

int main(){
        ll n,i,s=0,ans=0;
        cin >> n;
        vector<ll> a(n);
        vector<ll> p(n-1);
        for(i=0;i<n;++i){
                cin >> a.at(i);
                s += a.at(i);
        }
        s %= MOD;
        for(i=0;i<n-1;++i){
                s -= a.at(i);
                if(s<0) s += MOD;
                ans += s*a.at(i);
                ans %= MOD;
        }
        cout << ans << endl;
        return 0;
}

Measured memory_bytes: 6400
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N,K;
    string S;
    cin >> N >> K >> S;
    S[K-1] += 'a' - 'A';
    cout << S << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <math.h>

#define ll long long
#define ull unsigned long long

using namespace std;

const int inf = 1000000000;
const double eps = 1e-7;

void solve() {
	int s;
	cin >> s;
	
	double a = s / 3.0;
	
	cout << fixed << setprecision(7) << a * a * a << endl;
}

int main() {
	int t = 1;
	//cin >> t;
	for (int i = 0; i < t; ++i)
		solve();
	return 0;
}

Measured memory_bytes: 256
#define DA(a, n) for (int __macro_i = 0; __macro_i < n; ++__macro_i) { cout << a[__macro_i] << " "; } cout << endl;
#include<iostream>
#include<vector>
#include<cassert>
#include<cmath>

using namespace std;

int main()
{
    int b[] = {1, 0, 0};
    char x, c, y;
    while(cin >> x >> c >> y) {
        int xi = x - 'A';
        int yi = y - 'A';
        int tmp = b[xi];
        b[xi] = b[yi];
        b[yi] = tmp;
        // DA(b, 3);
    }
    for (int i = 0; i < 3; ++i) {
        if (b[i]) {
            cout << (char)('A' + i) << endl;
            break;
        }
    }
}



Measured memory_bytes: 3004
// Problem : A - Payment
// Contest : AtCoder - AtCoder Beginner Contest 173
// URL : https://atcoder.jp/contests/abc173/tasks/abc173_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#define DEBUG fprintf(stderr, "Passing [%s] line %d\n", __FUNCTION__, __LINE__)
#define File(x) freopen(x".in","r",stdin); freopen(x".out","w",stdout)

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair <int, int> PII;
typedef pair <int, PII> PIII;

inline int gi()
{
    int f = 1, x = 0; char c = getchar();
    while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
    while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return f * x;
}

inline LL gl()
{
    LL f = 1, x = 0; char c = getchar();
    while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
    while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return f * x;
}

const int INF = 0x3f3f3f3f, N = 100003, M = N << 1;

int n, m;

int main()
{
    //File("");
    n = gi();
    int now = n / 1000;
    if (n % 1000 == 0) puts("0");
    else cout << (now + 1) * 1000 - n << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <cmath>
using namespace std;

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

typedef long long ll;

const int INF = 1e8;

int main() {
  int n; cin >> n;
      
  string ans = "";
  while(n != 0){
    if(n%2 != 0){
      n--;
      ans = "1" + ans;
    }
    else{
      ans = "0" + ans;
    }
    n /= -2;
  }
  
  if(ans == "") ans = "0";
  
  cout << ans << endl;
  
}


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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> road(M*2);
  for(int i=0; i<M; i++){
    int src,dst;
    cin >> src >> dst;
    road.push_back(src);
    road.push_back(dst);
  }
  
  for(int i=0; i<N; i++){
    int count=0;
    for(int j=0; j < road.size(); j++){
       if((i+1)==road.at(j)){
         count+=1;
       } 
    }
    cout<< count << endl;
    
  }
}

Measured memory_bytes: 256
n,m=map(int,input().split())
x=[list(map(int,input().split())) for i in range(n)]
ans=0
for i in range(8):
    a=[0]*n
    for j in range(n):
        for k in range(3):
            if i>>k&1:
                a[j]+=x[j][k]
            else:
                a[j]-=x[j][k]
    ans=max(ans,abs(sum(sorted(a,reverse=1)[:m])))
print(ans)

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

using namespace std;


#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()

#define int long long

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second

template <typename T>
void print(T x)
{
	std::cout << x <<" " ;
}


template <typename T>
void println(T x)
{
	std::cout << x << "\n";
}

signed main(void) {
	int N,K;
	cin >> N>>K;
	vector<int>h;
	h.resize(N);
	int ans = 0;
	rep(i,N) {
		cin >> h[i];
		if (h[i] >= K) {
			ans++;
		}
	}
	print(ans);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int a[N], b[N];
int main() {
	int n;
	scanf("%d", &n);
	for (int i = 1; i <= n; ++ i) scanf("%d%d", &a[i], &b[i]);
	long long ans = 0;
	for (int i = n; i >= 1; -- i) {
		ans += (ans + a[i] + b[i] - 1) / b[i] * b[i] - (a[i] + ans);
	}
	cout << ans << endl;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = INT64_MAX;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i=0;i<N;i++)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

ll n,m,q;
vector<PLL> tr,qe;
ll ma[510][510];
ll dp[510][510];
ll cal(ll l,ll r){
    if(dp[l][r]!=-1)return dp[l][r];
    if(l>r)return dp[l][r] = 0;
    if(l==r)return dp[l][r] = ma[l][r];
    return dp[l][r] = cal(l,r-1) + cal(l+1,r) - cal(l+1,r-1) + ma[l][r];
}

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    cin>>n>>m>>q;
    rep(i,510)rep(j,510){
        ma[i][j]=0;
        dp[i][j]=-1;
    }
    ll in,inp;
    rep(i,m){
        cin>>in>>inp;
        tr.pb(mp(in,inp));
        ma[in][inp]++;
    }
    rep(i,q){
        cin>>in>>inp;
        qe.pb(mp(in,inp));
    }
    cal(1,500);
    rep(i,q){
        print(cal(qe[i].first,qe[i].second));
    }
    return 0;
}

Measured memory_bytes: 12268
use std::env;
use std::io::*;
use std::str::*;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let s = stdin.bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}

fn main() {
    // main の引数
    /*
        引数なしのときargs.len() = 1;
    */
    let args: Vec<String> = env::args().collect();

    let A = read::<i32>();
    let B = read::<i32>();

    if A%3 == 0 || B%3 == 0 || (A+B)%3 == 0 {
        println!("Possible");
    } else {
        println!("Impossible");
    }
}


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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  // 「累積和」と、一つ手前までの「累積和の最小値」の差が、最大となるものを探索する
  vector<int> res;
  while(1){
    int n; cin >> n;
    if(n == 0) break;
    vector<int> a(n, 0);
    vector<int> b(n, 0);
    int c = 0, ans = -1e9;
    REP(i, n){
      cin >> a[i];
      if(i){
        b[i] = b[i-1] + a[i];
        c = min(c, b[i-1]);
        ans = max(ans, b[i] - c);
      }else{
        b[i] = a[i];
        ans = max(ans, b[i]);
      }
    }
    res.push_back(ans);
  }
  for(auto &i : res){
    cout << i << endl;
  }
}


Measured memory_bytes: 3176
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(c) c.begin(),c.end()
#define INF int(1e9+7)

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;

int h[128];

int main()
{
	IO_OP;

	int n;
	cin >> n;
	for(int i=0;i<n;i++)
		cin >> h[i];
	int ans = 0;
	for(int i=0;i<=100;i++) {
		int ct = 0;
		for(int j=0;j<n;j++) {
			if(h[j] < i) {
				ans += ct;
				ct = 0;
			}
			else {
				ct = 1;
			}
		}
		ans += ct;
	}
	cout << ans-1 << endl;
}


Measured memory_bytes: 256
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  

#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;

#define mp make_pair  
#define Fi first  
#define Se second  
#define pb(x) push_back(x)  
#define szz(x) ((int)(x).size())  
#define rep(i, n) for(int i=0;i<n;i++)  
#define all(x) (x).begin(), (x).end()  
#define ldb ldouble  

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 17;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

vector <string> Vl;
char in[5050];
int main() {
	int N, K, i, j, k;
	scanf("%s %d", in, &K);
	N = strlen(in);
	for (i = 1; i <= K; i++) {
		for (j = 0; j + i <= N; j++) {
			Vl.emplace_back(in + j, in + j + i);
		}
	}
	sort(all(Vl));
	Vl.erase(unique(all(Vl)), Vl.end());
	printf("%s\n", Vl[K - 1].c_str());
}

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

int main(){
    int N, T;
    cin >> N >> T;
    if(N == 1){
        printf("%d\n", 0);
        return 0;
    }
    int A[N];
    for(int i = 0; i < N; i++) cin >> A[i];
    if(N == 2 && A[0] > A[1]){
        printf("%d\n", 0);
        return 0;
    }
    bool update = false;
    int min_A = A[0], max_A = A[1];
    int diff = max(A[1] - A[0], 0);
    int res = A[1] > A[0] ? 1 : 0;
    for(int i = 2; i < N; i++){
        if(A[i - 1] < min_A){
            min_A = A[i - 1];
            max_A = 0;
            update = true;
        }
        if(A[i] > max_A){
            max_A = A[i];
            update = true;
        }
        if(max_A - min_A > diff){
            diff = max_A - min_A;
            res = 1;
        }else if(max_A - min_A == diff && update == true){
            res++;
        }
        update = false;
    }
    printf("%d\n", res);
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)

bool judge(int const& i,int const& k,vector<int> const& a){
  bool ans=false;
  int buf=i;
  int one;
  int count=0;
  int count2=0;
  int keta=0;
  while(buf>0){
    one=buf%10;
    buf/=10;
    keta++;
    count=0;
    rep(i,k){
      if(one==a[i]){
        break;
      }
      else{
        count++;
      }
    }
    if(count==k){
      count2++;
    }
  }
  if(count2==keta){
    ans=true;
  }
  FINE:
  return ans;
}
signed main(){
  int n,k;cin>>n>>k;
  vector<int> a(k);
  rep(i,k)cin>>a[i];
  int ans=0;
  for(int i=n;i<=n*100;i++){
    if(judge(i,k,a)){
      ans=i;
      break;
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
// ABC156D - Bouquet

#include <bits/stdc++.h>
using namespace std;

#define MOD 1000000007

// 繰り返し二乗法 MOD Version
int power(int n, int p) {
	if (p == 0) {
		return 1;
	}
	if (p % 2 == 0) {
		long long t = power(n, p / 2);
		return (int)(t * t % MOD);
	}
	return (int)(((long long)n * power(n, p - 1))% MOD);
}

int nCr(int n, int r) { // MOD Version
	long long int retValue = 1;
	long long int temp;

//	cout << n << " " << r << endl;

	for (int i = n ; i > n - r; --i) {
		retValue = retValue * i;
		retValue %= MOD;
	}

	temp = 1;
	for (int i = 1 ; i < r + 1; ++i) {
		temp = temp * i;
		temp %= MOD;
	}
	temp = power(temp, MOD - 2);
//	cout << temp << endl;
	retValue = retValue * temp;
	retValue %= MOD;

//	cout << retValue << endl;

    return (int)retValue;
}

int main() {
	int n, a, b;
	cin >> n >> a >> b;

	long long int caseNo = 0;
	caseNo = power(2, n) - 1;
//	cout << caseNo << endl;

	caseNo = (caseNo - nCr(n, a)+ MOD)% MOD;
	caseNo = (caseNo - nCr(n, b)+ MOD)% MOD;

	cout << (int)caseNo << endl;
}


Measured memory_bytes: 256
f=[0 for _ in range(100001)]
mo= 1000000007
def ksm(a, b):
	ans=1
	while b:
		if (b&1):
		    ans=ans*a%mo
		b>>=1
		a=a*a%mo
	
	return ans

def main():
	n=int(input())
	l=list(map(int,input().split()))
	for i in range(1,n+2):
		x=l[i-1]
		if (f[x]):
		    l=f[x]-1;r=n-i+1;break
		else:
		    f[x]=i
	
	print(n)
	t=l+r
	sum1=1
	sum=n+1
	for i in range(2,n+2):
		if (t>=i-1):
		    sum1=(sum1*(t-i+2)%mo*ksm(i-1,mo-2))%mo
		else:
		    sum1=0
		sum=(sum*(n-i+2)%mo*ksm(i,mo-2))%mo
		print((sum-sum1+mo)%mo)
	
main()

Measured memory_bytes: 14876
#include<bits/stdc++.h>
#define pi acos(-1)
#define ll long long
#define pii pair<ll,ll>
#define debug(a) cout<<a<<'\n'
#define maxn 200009 /// I wanna be the wind
#define MOD 1000000007
#define F first
#define S second
#define rep(i, a, b) for(ll i = a; i < (b); ++i)
#define per(i, b, a) for(ll i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define all(x) begin(x), end(x)
#define sz(x) (ll)(x).size()
using namespace std;
const ll INF = 1e17 + 9;
ll fastpow(ll a, ll b){
    ll calc=1;
    for(;b>=1LL;b/=2LL){
        if((b&1LL))calc= calc*a;
        a=a*a;
    }
    return calc;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin>>n;
    string ans="";
    while(n>0){
        n-=1;
        ans+=char('a'+(n)%26);
        n/=26;
    }
    reverse(all(ans));
    cout<<ans<<"\n";
    return 0;  
}   

Measured memory_bytes: 3664
#include<stdio.h>
int main()
{
	int a, b;
	while (1){
		b = 0;
		scanf("%d", &a);
		if (a == 0)
			break;
		a = 1000 - a;
		b = a % 500;
		a /= 500;
		a += b / 100;
		b %= 100;
		a += b / 50;
		b %= 50;
		a += b / 10;
		b %= 10;
		a += b / 5;
		b %= 5;
		a += b;
		printf("%d\n", a);
	}
	return 0;
}

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

using namespace std;
using lint = long long;

int main(void)
{
    int S;
    cin >> S;
    int fw = S / 100;
    int bk = S - fw * 100;
    if(fw <= 12 && fw > 0){
        if(bk > 12 || bk <= 0){
            cout << "MMYY" << endl;
        }else{
            cout << "AMBIGUOUS" << endl;
        }
    }else{
        if(bk > 12 || bk <= 0){
            cout  << "NA" << endl;
        }else{
            cout << "YYMM" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.conv;



void main() {
    string input;

    while ((input = readln.chomp).length != 0) {
        auto n = input.to!int;
        auto sum = 0;
        auto a = 2;

        sum += a;
        if (n >= 2) {
            sum += (n+2)*(n-1)/2;
        }

        writeln(sum);
    }
}

Measured memory_bytes: 1048
HW = input().split()
H, W = int(HW[0]), int(HW[1])
S = [input() for _ in range(H)] 
result = [[0 for _ in range(W)] for _ in range(H)]

for i in range(H):
  for j in range(W):
    if S[i][j] == '#':
      result[i][j] = '#'
      continue
    if i-1 >= 0 and j-1 >= 0 and S[i-1][j-1] == '#':
      result[i][j] += 1
    if i-1 >= 0 and S[i-1][j] == '#':
      result[i][j] += 1
    if i-1 >= 0 and j+1 < W and S[i-1][j+1] == '#':
      result[i][j] += 1
    if j-1 >= 0 and S[i][j-1] == '#':
      result[i][j] += 1
    if j+1 < W and S[i][j+1] == '#':
      result[i][j] += 1
    if i+1 < H and j-1 >= 0 and S[i+1][j-1] == '#':
      result[i][j] += 1
    if i+1 < H and S[i+1][j] == '#':
      result[i][j] += 1
    if i+1 < H and j+1 < W and S[i+1][j+1] == '#':
      result[i][j] += 1

for i in range(H):
  ans = ''
  for j in range(W):
    ans += str(result[i][j])
  print(ans)
      

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

#ifdef _PRINTDEBUG
  #include "lib/printdebug.hpp"
#else
  #define printdebug(...) 1
#endif
#define MOD_1_000_000_007 (1000000007)
#define IINF (1<<28)
#define LINF (1LL<<60)
#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--)
#define yesno(cond)       YESNO((cond), "Yes", "No")
#define YESNO(cond, a, b) cout << ((cond) ? (a) : (b)) << "\n"

namespace solver {
  using namespace std;
  typedef long long ll;

  int N;
  string S;
  ll dp[3030][3030], sum[3030][3030];

  void init() {
    cin >> N >> S;
  }

  ll rec(int i, int j) {
    if(dp[i][j] >= 0) return dp[i][j];
    if(i >= N) return dp[i][j] = 1;
    if(sum[i][0] == -1) {
      sum[i][0] = 0;
      REPC(k, 1, N-i) {
        sum[i][k] = (sum[i][k-1] + rec(i+1, k-1)) % MOD_1_000_000_007;
      }
    }
    int lower_n = j;
    int greater_n = N-i-j;
    char c = '<';
    if(i > 0) c = S[i-1];
    if(c == '>' && lower_n > 0) {
      return dp[i][j] = (sum[i][lower_n] + MOD_1_000_000_007 - sum[i][0]) % MOD_1_000_000_007;
    } else if(c == '<' && greater_n > 0) {
      return dp[i][j] = (sum[i][lower_n+greater_n] + MOD_1_000_000_007 - sum[i][lower_n]) % MOD_1_000_000_007;
    } else {
      return dp[i][j] = 0;
    }
  }

  void solve() {
    memset(dp, -1, sizeof dp);
    memset(sum, -1, sizeof sum);
    cout << rec(0, 0) << endl;
  }
}

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  solver::init();
  solver::solve();
  return 0;
}

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

int main() {
  int n; cin>>n;
  vector<int> b(n-1),a(n);
  rep(i,n-1){
    cin>>b.at(i);
  }
  int sum=0;
  
  rep(i,n-2){
    a.at(i+1)=min(b.at(i),b.at(i+1));   
  }
  a.at(0)=b.at(0);
  a.at(n-1)=b.at(n-2);
  rep(i,n)sum+=a.at(i);
  cout<<sum;               

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize ("Ofast")
#define int long long 
#define ld long double
#define pb push_back
#define vi vector<int>
#define pii pair<int,int>
#define ff first
#define ss second
#define endl '\n'
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n;i>=0;i--)
#define loop(i,l,r) for(int i=l;i<r;i++)
#define rloop(i,r,l) for(int i=r;i>=l;i--)
#define watch(x) cerr<<(#x)<<"= "<<(x)<<endl;
#define watcharr(a) cerr<<(#a)<<"("<<sz(a)<<")= ";rep(i,sz(a))cerr<<a[i]<<",";cerr<<'\n';
#define inf 2000000000000000000LL
#define mod 1000000007
#define mod1 998244353
#define FASTIO std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;

int n;
int dp[100005][4];

signed main() {
    FASTIO;
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    //     freopen("stderr.txt", "w", stderr);
    // #endif

    // int tt=1;
    // cin>>tt;
    // while(tt--){
        int n;
        cin>>n;
        vi a(n),b(n),c(n);
        rep(i,n) cin>>a[i]>>b[i]>>c[i];
        dp[0][1]=a[0];
        dp[0][2]=b[0];
        dp[0][3]=c[0];
        loop(i,1,n){
            dp[i][1]=a[i]+max(dp[i-1][2],dp[i-1][3]);
            dp[i][2]=b[i]+max(dp[i-1][1],dp[i-1][3]);
            dp[i][3]=c[i]+max(dp[i-1][1],dp[i-1][2]);
        }
        cout<<max({dp[n-1][1],dp[n-1][2],dp[n-1][3]})<<endl;
        
        
    // }
    cerr<<"Time Elapsed: "<<1.0*clock()/CLOCKS_PER_SEC<<" sec";
    return 0;
}

Measured memory_bytes: 5760
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
	Scanner scan = new Scanner(System.in);

	int W = scan.nextInt();
	int H = scan.nextInt();
	int N = scan.nextInt();

	int[] x_ = new int[N];
	int[] y_ = new int[N];
	int[] a_ = new int[N];

	for(int i = 0; i < N; i++){
	    x_[i] = scan.nextInt();
	    y_[i] = scan.nextInt();
	    a_[i] = scan.nextInt();
	}

	int x_l = 0;
	int x_r = W;
	int y_d = 0;
	int y_u = H;

	for(int i = 0; i < N; i++){
	    //x < xi
	    if(a_[i] == 1){
		if(x_[i] > x_l)
		    x_l = x_[i];
	    //x > xi
	    }else if(a_[i] == 2){
		if(x_[i] < x_r)
		    x_r = x_[i];
	    //y < yi
	    }else if(a_[i] == 3){
		if(y_[i] > y_d)
		    y_d = y_[i];
	    //y > yi
	    }else if(a_[i] == 4){
		if(y_[i] < y_u)
		    y_u = y_[i];
	    }
	}

	if(y_d >= y_u || x_l >= x_r){
	    System.out.println(0);
	}else{
	    System.out.println((x_r-x_l)*(y_u-y_d));
	}
    }
}


Measured memory_bytes: 23124
#include <stdio.h>
 
int Search(int r);
 
int array1[10000],array2[500];

int n,m,count = 0;
 
int main(){

  int i;
  
  scanf("%d",&n);
  
  for(i = 0;i < n;i ++)
    {
      scanf("%d",&array1[i]);
    }
 
  scanf("%d",&m);
  
  for(i = 0;i < m;i ++)
    {
      scanf("%d",&array2[i]);
      count += Search(array2[i]);
    }
 
  printf("%d\n",count);
 
  return 0;
 
}
 
int Search(int r){

  int j;
  
  for(j = 0;j < n;j ++)
    {
      if(r == array1[j])
	{
	  return 1;
	}
    }
return 0;
}

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

using namespace std;

int main()
{
  char s[4];
  
  string a;
  
  int i;
  
  for(i=0;i<4;i++)
  {
    cin>>s[i];
  }
  
  a="No";
  
  for(i=0;i<2;i++)
  {
    if(s[i]==s[i+1]&&s[i+1]==s[i+2]) a="Yes";
  }
  
  cout<<a<<endl;
  
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define int long long
#define endl "\n"
#define fi first
#define se second
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define fr(a,b,c) for(int a=b; a<c; a++)
#define frr(a,b,c) for(int a=b;a>=c;a--)
#define pb push_back
#define pii pair<int,int>
#define R(a) ll a; cin >> a;
#define RS(a) string  a; cin >> a;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;

#define RA(a, n) ll a[(n) + 1] = {}; fr(i, 1, (n)+1) {cin >> a[i];}
#define RM(a, n, m) int a[n + 1][m + 1] = {}; fr(i, 1, n+1) {fr(j, 1, m+1) cin >> a[i][j];}
#define reset(X) memset(X, 0, sizeof(X))
using vi=vector<int>;
const int inf = 1e18;
const int mod=1e9+7;
unsigned int power(int x, unsigned int y, int p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
bool isPrime(int n)
{   if (n <= 1)  return false;
    if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;
    for (int i=5; i*i<=n; i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
           return false;
    return true;
}
int modInverse(int n, int p)
{
    return power(n, p-2, p);
}
const int maxn=2e3+1;
int f[maxn];
int nCr(int n,int r)
{
    int ans=f[n];
    ans=(ans*modInverse(f[r],mod))%mod;
    ans=(ans*modInverse(f[n-r],mod))%mod;
    return ans;
}
signed main()
{
    fastio;
    R(a);R(b);R(c);R(d);
    int mx=a*c;
    mx=max(mx,a*d);
    mx=max(mx,b*c);
    mx=max(mx,b*d);
    cout<<mx<<endl;

}


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

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;


void main() {
    int x, y, a, b, c;
    scan(x,y,a,b,c);
    auto p = readln.split.to!(long[]).sort!"a > b"()[0 .. x];
    auto q = readln.split.to!(long[]).sort!"a > b"();
    auto r = readln.split.to!(long[]).sort!"a > b"();

    long ans;

    long tmp = p.sum();
    int qf, rf;
    while (qf + rf < y) {
        if (rf == c || r[rf] < q[qf]) {
            tmp += q[qf];
            qf++;
        }
        else {
            tmp += r[rf];
            rf++;
        }
    }

    debug {
        writeln(tmp);
        writefln("qf: %s, rf: %s", qf, rf);
    }

    chmax(ans, tmp);

    foreach (k ; 0 .. x) {
        if (k >= c) {
            break;
        }

        if (k >= rf) {
            tmp -= p[$ - 1 - k];
            tmp += r[k];
            chmax(ans, tmp);
            debug {
                writeln(tmp);
                writefln("qf: %s, rf: %s", qf, rf);
            }
            continue;
        }

        tmp -= p[$ - 1 - k];
        
        if (rf == c || q[qf] > r[rf]) {
            tmp += q[qf];
            qf++;
        }
        else {
            tmp += r[rf];
            rf++;
        }

        debug {
            writeln(tmp);
            writefln("qf: %s, rf: %s", qf, rf);
        }

        chmax(ans, tmp);
    }

    writeln(ans);
}



void scan(T...)(ref T args) {
    auto line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x > arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x < arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

void yes(bool ok, string y = "Yes", string n = "No") {
    return writeln(ok ? y : n);
}


Measured memory_bytes: 12272
#include<iostream>
using namespace std;
#define MAX 2000000

int H, A[MAX+1];

void maxHeapify(int i) {
	int l, r, largest;
	l = 2 * i;
	r = 2 * i + 1;
	
	// 左の子、自分、右の子で値が最大のノードを選ぶ
	if ( l <= H && A[l] > A[i] ) largest = l;
	else largest = i;
	if ( l <= H && A[r] > A[largest] ) largest = r;
	
	if ( largest != i ){
		swap(A[i], A[largest]);
		maxHeapify(largest);
	}
}

int main() {
	cin >> H;
	
	for ( int i = 1; i <= H; i++ ) cin >> A[i];
	
	for ( int i = H / 2; i >= 1; i-- ) maxHeapify(i);
	
	for ( int i = 1; i <= H; i++ ) {
		cout << " " << A[i];
	}
	cout << endl;
	
	return 0;
}


Measured memory_bytes: 5028
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <ctime>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <deque>
#include <complex>
#include <string>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <valarray>
#include <iterator>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) container.begin(), container.end()
#define RALL(container) container.rbegin(), container.rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

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 (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;


ll n;

main(){
	while(cin >> n){
		int ans = 0;
		for(;n > 1;ans ++) n=(n+2)/3;
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1164
#include <cstdio>
#include <utility>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#define REP(i,n) for(int i=0;i<n;i++)
typedef long long ll;
using namespace std;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;

int main() 
{
	ll n,k,s;	//1 &#8804; n &#8804; 20, 1 &#8804; k &#8804; 10 and 1 &#8804; s &#8804; 155
	while(cin >> n>>k>>s && !(n==0 && k==0 && s==0))
	{
		ll a[11][21][156]={}; //i回目に最大値xで合計sになるもの
		a[0][0][0]=1;
	
		for(int i=0;i<k;i++)//i回目
		{
			for(int j=0;j<n+1;j++)//最大値jで
			{
				for(int l=0;l<s;l++)//合計lの配列から次がどう定義されるか
				{
					for(int m=j+1;m<n+1;m++)
					{
						if(l+m<=s)
						{
							a[i+1][m][l+m]+=a[i][j][l];
						}
					}
				}
			}
		}
		
		ll ans(0);
		REP(i,n+1){ans+=a[k][i][s];}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1444
#include <bits/stdc++.h>
#define rep(i,n) for(ll i = 0; i < (n); ++i)
#define srep(i,s,t) for(ll i = s; i < t; ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

const ll MOD = 1000000007;
ll dp[310][310][310]; // dp[i日目][1と強連結の数][1と強じゃない連結の数]
int main() {
    ll n, m;
    cin >> n >> m;

    rep(i,m+1)rep(j,n+1)rep(k,n+1)dp[i][j][k] = 0;

    dp[0][1][0] = 1;
    // 配るDP
    rep(i,m){
        rep(j,n+1){
            rep(k,n+1){
                if(dp[i][j][k] == 0) continue;
                if(j+k > n) continue;
                if(k == 0){
                    if(j == n){
                        dp[i+1][j][k] += dp[i][j][k] * n;
                        dp[i+1][j][k] %= MOD;
                    }else{
                        dp[i+1][j][k] += dp[i][j][k] * j;
                        dp[i+1][j][k] %= MOD;
                        dp[i+1][j][k+1] += dp[i][j][k] * (n - j);
                        dp[i+1][j][k+1] %= MOD;
                    }
                }else{
                    if(j+k == n){
                        dp[i+1][j+k][0] += dp[i][j][k] * j;
                        dp[i+1][j+k][0] %= MOD;
                        dp[i+1][j][k] += dp[i][j][k] * k;
                        dp[i+1][j][k] %= MOD;
                    }else{
                        dp[i+1][j+k][0] += dp[i][j][k] * j;
                        dp[i+1][j+k][0] %= MOD;
                        dp[i+1][j][k] += dp[i][j][k] * k;
                        dp[i+1][j][k] %= MOD;
                        dp[i+1][j][k+1] += dp[i][j][k] * (n-j-k);
                        dp[i+1][j][k+1] %= MOD;
                    }
                }
            }
        }
    }

    ll ans = dp[m][n][0];

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




Measured memory_bytes: 224232
#pragma GCC optimize("O3")
//#pragma GCC target("avx2")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << "\n";
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int n, a, b;
    cin >> n >> a >> b;

    ll ans = 0;
    FOR(i, 1, n + 1) {
        int c = 0;
        int cur = i;
        while(cur > 0) {
            c += cur % 10;
            cur /= 10;
        }

        if (a <= c && c <= b) {
            ans += i;
        }
    }

    print(ans);
}

Measured memory_bytes: 3640
N = int(input())
*A, = map(int, input().split())
S = [0]*(N+1)
for i in range(N):
    S[i+1] = S[i] + A[i]
INF = 10**30
ans = INF
def check(x, y, z):
    if 0 < y < x < z < N:
        B = (S[y], S[x]-S[y], S[z]-S[x], S[N]-S[z])
        return max(B)-min(B)
    return INF
y = z = 1
for x in range(2, N-1):
    s = S[x]
    while y < x and S[y+1]*2 <= s:
        y += 1
    t = S[N]-s
    while z < N and (S[z+1]-s)*2 <= t:
        z += 1
    for p in [0, 1]:
        for q in [0, 1]:
            ans = min(ans, check(x, y+p, z+q))
print(ans)


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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

ll N;
vector<ll> edges[200000];

ll depth(ll x) {
  vector<ll> v;
  for(auto nxt : edges[x]) {
    v.push_back(depth(nxt));
  }
  sort(begin(v), end(v), [](const auto &l, const auto &r) { return l > r;});
  ll res = 0;
  rep(i, v.size()) {
    res = max(res, v[i]+i+1);
  }
  // printf("depth[%d]=%d\n", x , res);
  return res;
}

signed main() {
  cin >> N;
  for (ll i=2; i<=N; i++) {
    ll x;
    cin >> x;
    edges[x].push_back(i);
    //printf("win:%d lose:%d\n", x, i);
  }
  ll ans = depth(1);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 15872
//IN THE NAME OF GOD;
//Test By Dev-C++5.11
#include<bits/stdc++.h>
#define ll  long long
#define isc ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define ld long double
#define ss string
#define ww while
#define vl vector<ll>
#define pb push_back
#define in insert
#define vec vector
#define itr iterator
#define gt goto
#define rep(i,n,j) for(ll i=n;i<j;i++)
#define tep(i,n,j) for(ll i=n;i>=j;i--)
#define co(n) cout << n ;
#define pll pair<ll,ll>
#define bft bool f=true
#define bff bool f=false 
using namespace std;

ll bmm(ll a, ll b) {
	if (b == 0) return a;
	else return bmm(b, a%b);
}
ll kmm(ll a, ll b) {
	return(a*b) / bmm(a, b);
}


const ll mod = 1e9 + 7;
const ll MAXN = 1e3+5;
ll x;
ss s;
vec <ss> a;
bft;
int main() {
	isc;
	a.pb("SUN");
	a.pb("MON");
	a.pb("TUE");
	a.pb("WED");
	a.pb("THU");
	a.pb("FRI");
	a.pb("SAT");
	cin >> s;
	rep(i,0,7 && f){
		if(a[i]==s){
			f=false;
			x=i;
		}
	}
	if(x==0)
		cout << 7;
	else
		cout << 7-x;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>

int main(){
	int n;
	while(std::cin >> n, n){
		int res = 0;
		for(int k=2;k<50;k++){
			int child = 2*n - k*k + k;
			if(child > 0 && child % (2 * k) == 0){
				res++;
			}
		}
		std::cout << res << std::endl;
	}
}

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

struct Dice {
  int f[6];

  void roll(char ch) {
    if (ch == 'N') {
      int t = f[0];
      f[0] = f[1];
      f[1] = f[5];
      f[5] = f[4];
      f[4] = t;
    } else if (ch == 'E') {
      int t = f[0];
      f[0] = f[3];
      f[3] = f[5];
      f[5] = f[2];
      f[2] = t;
    } else if (ch == 'W') {
      int t = f[0];
      f[0] = f[2];
      f[2] = f[5];
      f[5] = f[3];
      f[3] = t;
    } else if (ch == 'S') {
      int t = f[0];
      f[0] = f[4];
      f[4] = f[5];
      f[5] = f[1];
      f[1] = t;
    }
  }

  void spin() {
    int t = f[1];
    f[1] = f[2];
    f[2] = f[4];
    f[4] = f[3];
    f[3] = t;
  }

  int top() {
    return f[0];
  }

  int left() {
    return f[3];
  }

  int right() {
    return f[2];
  }

  int front() {
    return f[1];
  }
};

int main() {
  Dice d;

  for (int i = 0; i < 6; i++) cin >> d.f[i];

  int n;
  cin >> n;

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

    if (d.left() == a) d.roll('E');
    if (d.right() == a) d.roll('W');
    while (d.top() != a) d.roll('N');
    while (d.front() != b) d.spin();

    cout << d.right() << endl;
  }

  return 0;
}



Measured memory_bytes: 3080
tmp = input().split(' ')

N = int(tmp[0])
A = int(tmp[1])
B = int(tmp[2])

maxReaders = 0
minReaders = 0

# 最大購読者数
if A > B :
  maxReaders = B
else :
  maxReaders = A

# 最小購読者数
if A + B > N :
  minReaders = (A + B) - N
else :
  minReaders = 0

print(str(maxReaders) + ' ' + str(minReaders))


Measured memory_bytes: 3060
#!/usr/bin/python3
import sys
import re
from decimal import *

l = sys.stdin.readline()
#l = l.split(' ')
#l = [int(str) for str in l]
n = int(l)

tcount = 0
for i in range(3,n+1,2):
  count = 2
  for j in range(2,int(i+1/2)):
    if(i%j == 0):
      count += 1
  if(count == 8):
    tcount += 1

print(tcount)

sys.stdout.flush()


Measured memory_bytes: 5028
nums = [int(i) for i in input().split()]
ans = 0
jud = [i%2 for i in nums]
if jud != [1,1,1] and jud != [0,0,0]:
    if jud.count(0)>jud.count(1):
        for i,a in enumerate(jud):
            if a == 0:  nums[i] += 1
    else:
        for i,a in enumerate(jud):
            if a == 1:  nums[i] += 1
    ans += 1

mn = max(nums)
#print(nums)
for num in nums:
    ans += (mn-num)//2
print(ans)


Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<functional>
#include<map>
using namespace std;
#define inf 1000000009
#define int long long
string s[50];
signed main() {
	int h, w;
	cin >> h >> w;
	for (int i = 0; i < h; i++)cin >> s[i];
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			int ans = 0;
			for (int k = -1; k < 2; k++) {
				for (int l = -1; l < 2; l++) {
					int n = i + k, m = j + l;
					if (k == 0 && l == 0)continue;
					if (0 <= n&&n < h && 0 <= m&&m <= w&&s[n][m] == '#')ans++;
				}
			}
			if (s[i][j] != '#')s[i][j] = '0' + ans;
		}
	}
	for (int i = 0; i < h; i++)cout << s[i] << endl;
}

Measured memory_bytes: 256
n,k,c = map(int,input().split())
sl = list(input())

# 前貪欲
ansl = []
before = -float("inf")
for idx,s in enumerate(sl):
    if s == "o" and before + c < idx:
        before = idx
        ansl.append(idx)

# 後貪欲
ansl2 = []
before = -float("inf")
for idx,s in enumerate(sl[::-1]):
    if s == "o" and before + c < idx:
        before = idx
        ansl2.append(n-idx-1)


for a1,a2 in zip(ansl[:k], ansl2[:k][::-1]):
    if a1 == a2:
        print(a1+1)


Measured memory_bytes: 71112
import java.util.*;

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

        char[] c = new char[n];
        c[0] = 'a';
        dfs(c, n, 1, 1);
    }

    static char[] t = new char[] {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k'};
    static void dfs(char[] c, int n, int d, int used) {
        if(d == n) {
            System.out.println(new String(c));
            return;
        }
        for(int i=0; i<used+1; i++) {
            c[d] = t[i];
            dfs(c, n, d+1, Math.max(used, i+1));
        }
    }


}

Measured memory_bytes: 45060
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <string>
#include <cctype>
#include <map>
#include <queue>

using namespace std;

const int mod = 1000000007;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define ll long long

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

    priority_queue<ll> que;
    for (int i = 0; i < n; i++)
    {
        ll priceNum;
        cin >> priceNum;

        que.push(priceNum);
    }
    
    for (int i = 0; i < m; i++)
    {
        ll price = que.top();
        price /= 2;
        que.pop();
        que.push(price);
    }
    
    ll sum = 0;
    for (int i = 0; i < n; i++)
    {
        sum += que.top();
        que.pop();
    }
    
    cout << sum << endl;
}

Measured memory_bytes: 1400
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

int cans(bool f){
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


int main(){
    int a[3],b[3],c[3];
    rep(i,3) {
	cin >> a[i] >> b[i] >> c[i];
    }


    bool f = false;
    for(int i=1; i<3; i++) {
	for(int h1=-100; h1<=100; h1++) {
	    for(int h2=-100; h2<=100; h2++) {
		if(a[0] == b[0] + h1 && a[0] == c[0] + h2 && a[1] == b[1] + h1 && a[1] == c[1] + h2 && a[2] == b[2] + h1 && a[2] == c[2] + h2) f = true;
	    }
	}
    }
    cans(f);
    
    return 0;
}



Measured memory_bytes: 3620
#include<stdio.h>
#include<string.h>
char str[10001];
char joi[]="JOI";
char ioi[]="IOI";
main(){
  int i,j,n;
  while(scanf("%s",str)!=EOF){
    int a[2]={0};
    n=strlen(str);
    for(i=0;i<n;i++){
      if(str[i]==joi[0]){
	for(j=1;j<3;j++){
	  if(str[i+j]!=joi[j]) break;
	  else if(j==2) a[0]++;
	}
      }
      else if(str[i]==ioi[0]){
	for(j=1;j<3;j++){
	  if(str[i+j]!=ioi[j]) break;
	  else if(j==2) a[1]++;
	}
    }
    }
    printf("%d\n%d\n",a[0],a[1]);
  }
  return 0;
}

Measured memory_bytes: 0
// abc144_b
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N;
    cin >> N;

    REPN(i, 1, 10){
        if (N % i == 0){
            int j = N / i;
            if (0 < j && j < 10){
                print("Yes");
                return 0;
            }
        }
    }
    print("No");


    return 0;
}


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

public class Main {
	
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0007&lang=jp
	public static void main(String args[]) throws NumberFormatException, IOException {
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			int n  = Integer.parseInt(br.readLine());	
			double result = 100;
			
			for(int i = 0; i < n; i++){
				result = Math.ceil(result*1.05);
			}

			System.out.println((int)result * 1000);
	}
	
}

Measured memory_bytes: 24024
#include<iostream>
#include <string>
#include <iomanip>
#include <vector>
#include <queue>
#include <math.h>
#include <algorithm>
#include <functional>

using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)



signed main()
{
	int r, g, b;
	cin >> r >> g >> b;
	int tmp = 100 * r + 10 * g + b;
	if (tmp % 4 == 0) cout << "YES" << endl;
	else  cout << "NO" << endl;
}

Measured memory_bytes: 256