akhauriyash/Code-Regression huggingface dataset:
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pul pair<ull, ull>
#define all(a) (a).begin(), (a).end()
#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 RREP(i,n) for (int i=(n)-1;i>=0;--i)

void YES() { cout << "YES" << endl; }
void NO() { cout << "NO" << endl; }
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }
void yes() { cout << "yes" << endl; }
void no() { cout << "no" << endl; }
void Taka() { cout << "Takahashi" << endl; }
void Aoki() { cout << "Aoki" << endl; }
void digit(int d) { cout << fixed << setprecision(d); }
void IOup() { cin.tie(0); ios::sync_with_stdio(false); }

int main() {
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); ++i)
		if (i % 2 == 0)
			cout << s[i];
	cout << endl;

	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <ext/rope>
using namespace std;
using namespace __gnu_cxx;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<ii, ii> iii;
int MOD = 1e9 + 9;
const ld E = 1e-7;
#define null NULL
#define ms(x) memset(x, 0, sizeof(x))
#ifndef LOCAL
#define endl "\n"
#endif
#ifndef LONG_LONG_MAX
#define LONG_LONG_MAX LLONG_MAX
#endif
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define _read(x) freopen(x, "r", stdin)
#define _write(x) freopen(x, "w", stdout)
#define files(x) _read(x ".in"); _write(x ".out")
#define filesdatsol(x) _read(x ".DAT"); _write(x ".SOL")
#define output _write("output.txt")
#define input _read("input.txt")
#define prev time_prev
#ifndef M_PI
#define M_PI acos(-1)
#endif
#define remove tipa_remove
#define next tipa_next
#define left tipa_left
#define right tipa_right
#define mod % MOD
#define y1 hello_world
unsigned char ccc;
bool _minus = false;
template<typename T>
inline T sqr(T t) {
	return (t * t);
}
inline void read(ll &n) {
	n = 0;
	_minus = false;
	while (true) {
		ccc = getchar();
		if (ccc == ' ' || ccc == '\n')
			break;
		if (ccc == '-') {
			_minus = true;
			continue;
		}
		n = n * 10 + ccc - '0';
	}
	if (_minus)
		n *= -1;
}
inline bool read(int &n) {
	n = 0;
	_minus = false;
	while (true) {
		ccc = getchar();
		if (ccc == ' ' || ccc == '\n') {
			if (ccc == '\n')
				return true;
			break;
		}
		if (ccc == '-') {
			_minus = true;
			continue;
		}
		n = n * 10 + ccc - '0';
	}
	if (_minus)
		n *= -1;
	return false;
}
char wwww[19];
int kkkk;
inline void write(ll y) {
	long long x = y;
	kkkk = 0;
	if (x < 0) {
		putchar('-');
		x *= -1;
	}
	if (!x)
		++kkkk, wwww[kkkk] = '0';
	else
		while (x) {
			++kkkk;
			wwww[kkkk] = char(x % 10 + '0');
			x /= 10;
		}
	for (int i = kkkk; i >= 1; --i)
		putchar(wwww[i]);
}
#ifdef LOCAL
//#define DEBUG
#endif
#ifdef DEBUG
#define dbg if(1)
#else
#define dbg if(0)
#endif

int N;

string _to_string(ll n) {
	string ans = "";
	while (n) {
		ans += char(n % 10 + '0');
		n /= 10;
	}
	reverse(ans.begin(), ans.end());
	return ans;
}

int q = 0;

bool get(ll n) {
	cout << "? " << n << endl;
	cout.flush();
	string s;
	cin >> s;
	return (s[0] == 'Y');
}

pair<ll, ll> solve() {
	q = 0;
	ll ans = 0;
	ll Q = 1e9;
	for (int i = 0; i < 9; i++) {
		int l = (ans == 0 ? 1 : 0);
		int r = 9;
		while (l < r) {
			int x = (l + r) >> 1;
			if (get((ans * 10 + x) * Q + Q - 1)) {
				r = x;
			} else {
				l = x + 1;
			}
		}
		ans = ans * 10 + l;
	}
	ans *= 10;
	while (ans > 1e9)
		ans /= 10;
	while (ans % 10 == 0 && get(ans + 9))
		ans /= 10;
	ll j = ans;
	while (j % 10 == 0)
		j /= 10;
	if (j != 1){
		if (get(ans * 10 - 1))
			ans *= 10;
	}else{
		if(ans == 1){
			if(!get(9)){
				ans *= 10;
			}
		}else{
			ans *= 10;
		}
	}
	return make_pair(ans, (ll) q);
}

int main() {
	sync;
	srand(time(NULL));
	cout.precision(10);
	cout << fixed;
#ifdef LOCAL
	input;
#else

#endif

	cout << "! " << solve().first << endl;
	cout.flush();

}


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

using namespace std;

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
// cout << fixed << setprecision(20);

const int MAX_V = 110000;
const int MAX_E = 110000;
const int INF = 1e12;

// 頂点fromから頂点toへのコストcostの辺
struct edge {
    int from, to, cost;
};

vector<edge> es;

int d[MAX_V];
int V, E;

// s番目の頂点から各頂点への最短距離を求める
void shortest_path(int s) {
    for (int i = 0; i <= V; i++)d[i] = INF;
    d[s] = 0;
    for (int j = 0;; j++) {
        bool update = false;
        for (int i = 0; i < es.size(); i++) {
            edge e = es[i];
            if (d[e.from] != INF && d[e.to] > d[e.from] + e.cost) {
                d[e.to] = d[e.from] + e.cost;
                update = true;
            }
        }
        if (!update)break;
        if (j == V) {
            fill(d, d + V + 1, INF);
            break;
        }
    }
}

int P;
int A[110000], B[110000], C[110000];
vector<pint> G[110000];
bool visited[110000];

void dfs(int v) {
    visited[v] = true;
    for (int i = 0; i < G[v].size(); i++) {
        es.push_back({G[v][i].first, v, G[v][i].second});
        if (!visited[G[v][i].first])dfs(G[v][i].first);
    }
}

signed main() {
    cin >> V >> E >> P;
    for (int i = 0; i < E; i++) {
        cin >> A[i] >> B[i] >> C[i];
        G[B[i]].push_back(pint(A[i], P - C[i]));
    }
    dfs(V);
    shortest_path(1);
    if (d[V] == INF)cout << -1 << endl;
    else cout << max(0LL, -d[V]) << endl;
}

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

using namespace std;

int main(){

	int a,b,ans;

	cin >> a >> b;

	if(a >= b){
		ans = a;
		a--;
	}
	else{
		ans = b;
		b--;
	}

	cout << ans + max(a,b) << '\n'; 

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using P = pair<int, int>;
long mod = (long) 1e9 + 7;
long factorials[500001];

int pre_factorials(int n){

    factorials[0] = 1;

    for (int i = 0; i < n; i++) {
        factorials[i + 1] = (long)(i + 1) * factorials[i] % mod;
    }
    
    return 0;
}

long modpow(long a, long p){
    
    if (p == 0) return 1;
    
    if (p % 2 == 0) {
        return modpow(a * a % mod, p / 2);
    
    } else
        return a * modpow(a, p - 1) % mod;
}

long comb(long a, long b){

    long af = factorials[(int) a];
    long bf = factorials[(int) b];
    long abf = factorials[(int) (a - b)];
    long res = af * modpow(bf, mod - 2) % mod * modpow(abf, mod - 2) % mod;
    return res;
}

int main(){
    
    long N = 200010;
    pre_factorials(N);
    
    long n, k;
    cin >> n >> k;
    n++;
    
    long ans = 0, min, max;
    
    for(long i = k; i <= n; i++){
        min = (1 + i) * i / 2;
        max = (n + n - i + 1) * i / 2;
        ans += max - min + 1;
        ans %= mod;
    }
    
    cout << ans << "\n";
    
    return 0;
}




Measured memory_bytes: 4680
#define _CRT_SECURE_NO_WARNINGS 
#include<cstdio>
using namespace std;

int N;
int A[10];
int main() {
	scanf("%d", &N);
	int all = 1, bad = 1;
	for (int i = 0; i < N; ++i) {
		scanf("%d", A + i);
		all *= 3;
		if (A[i] % 2 == 0) bad *= 2;
	}
	printf("%d\n", all - bad);
	return 0;
}

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

int in[10][10];
int sqr[150];
int main(){
    int n;
    int d;
    cin >>n >> d;
    for(int i=0;i<n;i++){
        for(int j=0;j<d;j++){
             cin >> in[i][j];
        }
    }
    for(int i=1;i<150;i++){
        sqr[i] = i*i;
    }
    int ans = 0;
    for(int i=0;i<n;i++){
        for(int k=(i+1);k<n;k++){
            int sum = 0;
            for(int j=0;j<d;j++){
                sum += (in[i][j]-in[k][j])*(in[i][j] - in[k][j]);
            }
            for(int l = 1;l<150;l++){
                if(sum == sqr[l]){
                    ans ++;
                    break;
                }
            }

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

Measured memory_bytes: 256
n = gets.to_i
a = gets.chomp.split.map(&:to_i)

b = []
index = n / 2
b[index] = a[0]
o = 1

a[1..-1].each.with_index(n % 2) do |m, i|
  if i.even?
    index -= o
  else
    index += o
  end

  b[index] = m
  o += 1
end

puts b.join(' ')


Measured memory_bytes: 27396
// AOJ 2672 Rescue a Postal Worker
// 2019.4.6 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

//// 高速入力
#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
int in()    // 非負整数の入力
{
	int n = 0, c = gc();
	//	while (isspace(c)) c = gc();
	do n = 10 * n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}


//// 優先度付きキュー（ダイクストラ法用）
#define MAX 1000000
typedef struct { int t, n, b; } QUE;
QUE que[MAX]; int qsize;

#define PARENT(i) ((i)>>1)
#define LEFT(i)   ((i)<<1)
#define RIGHT(i)  (((i)<<1)+1)

void min_heapify(int i)
{
	int l, r, min;
	QUE qt;

	l = LEFT(i), r = RIGHT(i);
	if (l < qsize && que[l].t < que[i].t) min = l; else min = i;
	if (r < qsize && que[r].t < que[min].t) min = r;
	if (min != i) {
		qt = que[i]; que[i] = que[min]; que[min] = qt;
		min_heapify(min);
	}
}

void deq()
{
	que[0] = que[--qsize];
	min_heapify(0);
}

void enq(int n, int t, int b)
{
	int i, min;
	QUE qt;

	i = qsize++;
	que[i].t = t, que[i].n = n, que[i].b = b;
	while (i > 0 && que[min = PARENT(i)].t > que[i].t) {
		qt = que[i]; que[i] = que[min]; que[min] = qt;
		i = min;
	}
}


//// 本問題関連
#define MAXV 1005
int N;
int goal;
int mask[MAXV], cond[MAXV], res[MAXV];
int hi[MAXV], *to[MAXV], *tm[MAXV];
char vis[MAXV][4096];

int dijkstra(int start)
{
	int i, n, t, b, nx, nb;

	enq(start, 0, 0);
	while (qsize) {
		n = que[0].n, t = que[0].t, b = que[0].b, deq();
		if ((b & goal) == goal) return t;
		if (vis[n][b]) continue;
		vis[n][b] = 1;
		for (i = 0; i < hi[n]; i++) {
			nx = to[n][i], nb = b;
			if ((nb & mask[nx]) == cond[nx]) nb |= res[nx];
			if (!vis[nx][nb]) enq(nx, t + tm[n][i], nb);
		}
	}
	return -1;
}

int main()
{
	int i, k, M, K, P, x, y, w;
	int *memo, sz;

	N = in(), M = in(), K = in(), P = in() - 1;
	memo = malloc(sizeof(int)*M*3);
	sz = 0; for (i = 0; i < M; i++) {
		memo[sz++] = x = in() - 1, memo[sz++] = y = in() - 1;
		hi[x]++, hi[y]++;
		memo[sz++] = in();
	}
	for (i = 0; i < N; i++) if (hi[i])
		to[i] = malloc(sizeof(int)*hi[i]), tm[i] = malloc(sizeof(int)*hi[i]);
	memset(hi, 0, sizeof(int)*N);
	i = 0; while (i < sz) {
		x = memo[i++], y = memo[i++], w = memo[i++];
		k = hi[x]++, to[x][k] = y, tm[x][k] = w;
		k = hi[y]++, to[y][k] = x, tm[y][k] = w;
	}
	goal = 0;
	for (i = 0; i < K; i++) {
		x = in() - 1, y = in() - 1;
		mask[x] |= 3 << (2 * i), res[x] |= 1 << (2 * i);
		mask[y] |= 3 << (2 * i);
		cond[y] |= 1 << (2 * i); res[y] |= 3 << (2 * i);
		goal |= 3 << (2 * i);
	}

	if ((k = dijkstra(P)) < 0) puts("Cannot deliver");
	else printf("%d\n", k);
	return 0;
}



Measured memory_bytes: 6968
#
import sys
sys.setrecursionlimit(12345678)
import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop


def main():
    a, b = map(int, input().split())
    print(max(0, a - b * 2))

if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
def zarg(N, S):
    Z = [0] * N
    Z[0] = N
    i = 1
    j = 0
    while i < N:
        while i+j < N and S[j] == S[i+j]:
            j += 1
        Z[i] = j
        if j == 0:
            i += 1
            continue
        k = 1
        while k + Z[k] < j:
            Z[i + k] = Z[k]
            k += 1
        i += k
        j -= k
    M = 0
    for i in range(1,N):
        M = max(M, min(Z[i], i))
    return M

N = int(input())
S = input()
ans = 0
for i in range(N):
    s = S[i:]
    ans = max(ans, zarg(N-i, s))
print(ans)

Measured memory_bytes: 48092
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n;
		int m = 0;
		long ans = 0;
		long sum = 0;

		n = sc.nextLong();
		m = sc.nextInt();

		for (int i = 0; i < m; i++) 
			sum += sc.nextInt();
		

		if (n - sum >= 0)
			ans = n - sum;
		else
			ans = -1;
		System.out.print(ans);
		sc.close();
	}
}

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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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; }

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

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

int Len[55], Pat[55];

int rec(int k, int x) {
   // バーガー全部
   if (x == Len[k]) return Pat[k];

   int ans = 0;
   
   // 下のバン
   x--;

   // 下のk-1バーガー
   if (x > 0) {
      int l = min(x, Len[k-1]);
      ans += rec(k-1, l);
      x -= l;
   }

   // 真ん中のパティ
   if (x > 0) {
      ans++;
      x--;
   }

   // 上のk-1バーガー
   if (x > 0) {
      int l = min(x, Len[k-1]);
      ans += rec(k-1, l);
      x -= l;
   }

   return ans;
}

signed main() {
   int N, X;
   cin >> N >> X;

   Len[0] = Pat[0] = 1;
   for (int i = 1; i <= N; i++) {
      Len[i] = Len[i-1] * 2 + 3;
      Pat[i] = Pat[i-1] * 2 + 1;
   }

   cout << rec(N, X) << endl;

   return 0;
}


Measured memory_bytes: 384
using System;

namespace Test
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            var index = 0;
            while (true)
            {
                var input = Console.ReadLine();
                if (input == "0") return;
                Console.WriteLine("Case {0}: {1}",++index,input);
            }
        }
    }
}

Measured memory_bytes: 5816
#include<stdio.h>
#include<algorithm>
using namespace std;
typedef long long ll;
struct node{
	int x,v;
	node(int a=0,int b=0){x=a;v=b;}
}p[100010];
int h[100010],nex[200010],to[200010],a[100010],b[100010],fa[100010],M;
ll s[100010],f[100010];
bool v[100010];
void add(int a,int b){
	M++;
	to[M]=b;
	nex[M]=h[a];
	h[a]=M;
}
bool operator<(node a,node b){return a.v<b.v;}
int get(int x){return x==fa[x]?x:(fa[x]=get(fa[x]));}
int main(){
	int n,m,i,j,x,y;
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;i++){
		scanf("%d%d",a+i,b+i);
		a[i]=max(a[i]-b[i],0);
		p[i]=node(i,a[i]);
	}
	while(m--){
		scanf("%d%d",&x,&y);
		add(x,y);
		add(y,x);
	}
	sort(p+1,p+n+1);
	for(i=1;i<=n;i++){
		fa[i]=i;
		s[i]=b[i];
		f[i]=a[i];
	}
	for(i=1;i<=n;i++){
		v[p[i].x]=1;
		for(j=h[p[i].x];j;j=nex[j]){
			if(v[to[j]]){
				x=get(p[i].x);
				y=get(to[j]);
				if(x==y)continue;
				fa[y]=x;
				s[x]+=s[y];
				f[x]=min(f[x],max(f[y],a[x]-s[y]));
			}
		}
	}
	x=get(1);
	printf("%lld",f[x]+s[x]);
}

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

int main() {
 int A;
 int B;
 int C; 
 int D;
   
  cin >> A >> B >> C >> D ;
  if ((A+B)>(C+D)) {cout << "Left" << endl;}
  else if ((A+B)==(C+D)) {cout << "Balanced" << endl;}
  else if ((A+B)<(C+D)) {cout << "Right" << endl;}
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
d = {}
for i in range(N):
    d[i] = 0
for i in range(N):
    j =  i - A[i] + 1
    if j >= 0:
        d[j] += 1
ans = 0
for i in range(N):
    b = A[i] + i + 1
    c = i - A[i] + 1
    if c >= 0:
        d[c] -= 1
    if 0 <= b <= N - 1:
        ans += d[b]
print(ans)

Measured memory_bytes: 40624
//Author ::  ABHINAV3010 ::

#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define fast ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
typedef long long ll;
typedef pair<ll,ll> p;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    new_data_set;
ll mod=1000000007;
ll gcd(ll a,ll b)
{
    return (b==0)?a:gcd(b,a%b);
}
ll power(ll x, ll y, ll p=mod)
{ll res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1;x = (x*x) % p;}return res;}
int main()
{
fast;
ll n,k;
cin>>n>>k;
ll ans=0;
for(ll i=k;i<=n+1;i++)
{
    ll val1=(i*(i-1))/2;
    ll val2=(n*(n+1))/2;
    ll val3=((n-i)*(n-i+1))/2;
    val3=max(0ll,val3);
    val2=(val2-val3);
    ans=(ans+(val2-val1+mod+1)%mod)%mod;
}
cout<<ans<<endl;
return 0;
}


Measured memory_bytes: 3640
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

static inline int in()
{
	int n = 0, c = getchar_unlocked();
	do {
		n = 10 * n + c - '0';
		c = getchar_unlocked();
	} while (c >= '0');
	return n;
}

int main()
{
	int C = 0, n;

	n = in();
	vector<int> S(n);
	for (int &x: S)
		x = in();

	n = in();
	while (n--) {
		if(binary_search(S.begin(), S.end(), in()))
			C++;
	}

	printf("%d\n", C);
}


Measured memory_bytes: 2728
#include <cmath>
#include<vector>
#define rep(i, n) for (int i=0;i<n;i++)
#include <map> 
#include<algorithm>
#include <numeric>
#include<iostream>
#include<deque>
#include<queue>
#include<string>
#include <iomanip>
using namespace std;
typedef long long ll;

int main(void){
    int n;
    cin>>n;
    vector <int> v(n);
    rep(i, n){
        cin>>v[i];
    }
    int maxh=0;
    int ans=1;
    rep(i, n-1){
        maxh=max(maxh, v[i]);
        if(v[i+1]>=maxh) ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
h, w = map(int, input().split())
a = [[i for i in input()] for _ in range(h)]
a = [i for i in a if "#" in i]
a = [list(i) for i in zip(*a)]
a = [i for i in a if "#" in i]
a = [list(i) for i in zip(*a)]
a = ["".join(i) for i in a]
print(*a, sep="\n")


Measured memory_bytes: 9280
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll s[100009];
int main()
{
    ll n,a,b;
    scanf("%lld%lld%lld",&n,&a,&b);
    for(ll i=1;i<=n;i++)
    {
        scanf("%lld",&s[i]);
    }
    ll sum=0;
    for(ll i=2;i<=n;i++)
    {
        ll x=s[i]-s[i-1];
        sum+=min(a*x,b);
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define int long long
#define ld long double
#define endl '\n'
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define vpii vector<pii>
#define gr vector<vpii>
#define fi first
#define se second
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define GAME_OVER return 0
using namespace std;
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    vi a(n);
    for (int& i : a)
        cin >> i;
    int l = *min_element(all(a)), r = *max_element(all(a)), res = LLONG_MAX;
    for (int i = l; i <= r; i++)
    {
        int cur = 0;
        for (int j = 0; j < n; j++)
            cur += (a[j] - i) * (a[j] - i);
        res = min(res, cur);
    }
    cout << res << endl;
    GAME_OVER;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printInt(a) printf("%d\n", a)
#define scanInt(a) scanf("%d", &a)
#define scan2Int(a, b) scanf("%d %d", &a, &b)
#define scan3Int(a, b, c) scanf("%d %d %d", &a, &b, &c)
using namespace std;

int main() {
    int r;
    scanInt(r);
    printf("%f\n", 2 * r * M_PI); 
    return 0;
}


Measured memory_bytes: 3764
package main

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

func main() {

	scanner := bufio.NewScanner(os.Stdin)

	for {
		scanner.Scan()
		in_string := scanner.Text()

		if in_string == "0" {
			break
		}
		sum_v := 0
		for _, v := range in_string {
			num_v, _ := strconv.Atoi(string(v))
			sum_v += num_v
		}
		fmt.Println(sum_v)
	}

}



Measured memory_bytes: 1108
let x = read_int ()

let () =
  (match x mod 11 with
   | 0 -> (x / 11 * 2)
   | n when n <= 6 -> (x / 11) * 2 + 1
   | _ -> (x / 11) * 2 + 2)
  |> Printf.printf "%d\n"

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

int main( void )
{
    int m;
    cin >> m;

    for ( int l = 0; l < m; l++ ) {
        int answer = 0;
        int init, years, n;
        cin >> init >> years >> n;
        for ( int i = 0; i < n; i++ ) {
            int A = init;
            int type, fee;
            double x;
            cin >> type >> x >> fee;

            if ( type ) {
                for ( int j = 0; j < years; j++ ) {
                    int B = (int)floor( A * x );
                    A = A + B - fee;
                }
            } else {
                int r = 0;
                for ( int j = 0; j < years; j++ ) {
                    int B = (int)floor( A * x );
                    A -= fee;
                    r += B;
                }
                A += r;
            }
            answer = max( answer, A );
        }
        cout << answer << endl;
    }
    return 0;
}

Measured memory_bytes: 0
import java.util.*;

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

        int[] v = new int[N];
        int[] w = new int[N];

        for (int i = 0; i < N; i++) {
            v[i] = sc.nextInt();
            w[i] = sc.nextInt();
        }

        // dp[i+1][j]: インデックスiまでの品物から, 重さ制限jで選んだ時の, 価値の和の最大値
        int[][] dp = new int[N+1][W+1];

        for (int i = 0; i < N; i++) {
            for (int j = 1; j <= W; j++) {
                if (w[i] > j) {
                    dp[i+1][j] = dp[i][j];
                } else {
                    dp[i+1][j] = Math.max(dp[i][j], dp[i][j - w[i]] + v[i]);
                }
            }
        }

        System.out.println(dp[N][W]);
    }
}


Measured memory_bytes: 30952
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define rep(a,n) for(int i=a;i<n;i++)
#define rep1(a,n) for(int i=a;i<=n;i++)
int main()
{
   int n;
   cin>>n;
   int k;
   vi a;
   for(int i=0;i<n;i++)
    {
        cin>>k;
        a.pb(k);
    }
   int c=0,mini,maxi;
   for(int i=1;i<n-1;i++)
   {
       maxi=max(a[i-1],a[i+1]);
       mini=min(a[i-1],a[i+1]);
       maxi=max(maxi,a[i]);
       mini=min(mini,a[i]);

       if(mini!=a[i]&&maxi!=a[i])
          c++;
   }
   cout<<c<<"\n";
 return 0;
}


Measured memory_bytes: 256
parseInt(x)=parse(Int,x)
parseMap(x::Array{SubString{String},1})=map(parseInt,x)

function main()
	n = readline() |> parseInt
	total = 0
	for i in 1:n
		x,u = readline() |> split
		if u == "JPY"
			total += parse(Float64,x)
		else
			total += parse(Float64,x)*380000
		end
	end
	println(total)
end
main()

Measured memory_bytes: 113056
import heapq

N,M = (int(i) for i in input().split())
A = map(int,input().split())
A = list(map(lambda x: -1*x,A))
A.sort()
for i in range(M):
    item = heapq.heappop(A)
    if item % 2== 0:
        heapq.heappush(A,item//2)
    else:
        heapq.heappush(A,item//2+1)


print(-1*sum(A))


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

using namespace std;
typedef long long ll;

int main()
{
    const ll M=5000;
    int n,m;
    ll s;
    scanf("%d%d%lld",&n,&m,&s);
    vector<array<ll,3>> v[n+1];
    for(int i=0;i<m;i++)
    {
        int a,b;
        ll x,y;
        scanf("%d%d%lld%lld",&a,&b,&x,&y);
        v[a].push_back({b,x,y});
        v[b].push_back({a,x,y});
    }
    vector<ll> c(n+1,0);
    vector<ll> d(n+1,0);
    for(int i=1;i<=n;i++) scanf("%lld%lld",&c[i],&d[i]);
    vector<vector<ll>> res(n+1,vector<ll>(M+1,(1ll<<62)));
    priority_queue<array<ll,3>,vector<array<ll,3>>,greater<array<ll,3>>> q; //dist,a,money
    q.push({0,1,min(s,M)});
    res[1][min(s,M)]=0;
    while(!q.empty())
    {
        auto [dist,a,money]=q.top();
        q.pop();
        if(dist>res[a][money]) continue;
        //cout << "in " << a << " with dist=" << dist << " and money=" << money << endl;
        if(res[a][money]+d[a]<res[a][min(money+c[a],M)])
        {
            res[a][min(money+c[a],M)]=res[a][money]+d[a];
            q.push({res[a][min(money+c[a],M)],a,min(money+c[a],M)});
        }
        for(auto [to,w,t]:v[a])
        {
            if(money<w) continue;
            ll now=money-w;
            if(res[a][money]+t<res[to][now])
            {
                res[to][now]=res[a][money]+t;
                q.push({res[to][now],to,now});
            }
        }
    }
    for(int i=2;i<=n;i++)
    {
        ll best=(1ll<<62);
        for(int j=0;j<=M;j++) best=min(best,res[i][j]);
        printf("%lld\n",best);
    }
    return 0;
}


Measured memory_bytes: 11424
#include <iostream>
#include <assert.h>
#include <vector>
#include <unordered_map>
#include <queue>
#include <climits>
#include <cmath>
#include <algorithm>
#include <unordered_set>
using namespace std;
constexpr int64_t MOD = 1e9 + 1;

#include <unistd.h>

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

  int64_t N,Q;
  cin >> N >> Q; 
  vector<int32_t> r(N+1, N);
  vector<int32_t> c(N+1, N);
  int32_t rwall = N;
  int32_t cwall = N;
  int64_t res = (N - 2) * (N - 2);
  for (int i = 0; i < Q; i++) {
    int qtype, idx;
    cin >> qtype >> idx;

    auto update = [&res, idx](vector<int32_t>& vec, int32_t& wall, int32_t& ort_wall) {
      if (idx > wall) {
        res -= vec[idx] - 2;
      } else {
        res -= ort_wall - 2;
        for (int i = idx + 1; i < wall; i++) {
          vec[i] = ort_wall;
        }
        wall = idx;
      }
    };

    if (qtype == 1) {
      update(c, cwall, rwall);
    } else {
      update(r, rwall, cwall);
    }
  }
  cout << res << endl;


  return 0;
}


Measured memory_bytes: 4788
function Main(input){
var inputs = input.split("");
var sum = 0;
for(i=0;i<=(inputs.length-1);i++){
  sum += new Number(inputs[i]);
}
var harshed = new Number(input)%sum == 0;
if(harshed == true){
  console.log("Yes");
}else{
  console.log("No");
}
}
Main(require('fs').readFileSync('/dev/stdin','utf8'));

Measured memory_bytes: 7372
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws java.io.IOException {
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			double k[] = new double[2];
			String a = scan.next();
			String[] f = a.split(",", 0);
			k[0] = Double.parseDouble(f[1]);
			k[1] = Double.parseDouble(f[2]);
			if(k[0] / (k[1]*k[1]) >= 25){
				System.out.println(f[0]);
			}
		}
	}
}

Measured memory_bytes: 17144
// 2020.1.26.#153:A
#include <iostream>
#include <cmath>
using namespace std;

int main(int argc, char const* argv[])
{
	int		 i = 0;
	unsigned A, H;
	do
	{
		cin >> H;
		cin >> A;
		if(A <= 10000 && H <= 10000 && A >= 1 && H >= 1)
		{
			break;
		}
	} while(1);
	while(A * (++i) < H)
	{
	}
	cout << i << endl;

	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define min(a,b) ((a)<(b)?(a):(b))
#define reg register
#define file(x) freopen(x".in","r",stdin);freopen(x".out","w",stdout);
#define endfile fclose(stdin);fclose(stdout);
namespace IO{
    char buf[1<<15],*S,*T;
    inline char gc(){
        if (S==T){
            T=(S=buf)+fread(buf,1,1<<15,stdin);
            if (S==T)return EOF;
        }
		return *S++;
    }
    inline int read(){
        reg int x;reg bool f;reg char c;
        for(f=0;(c=gc())<'0'||c>'9';f=c=='-');
        for(x=c^'0';(c=gc())>='0'&&c<='9';x=(x<<3)+(x<<1)+(c^'0'));
        return f?-x:x;
    }
}
const int MN=1005;
const int inf=0x3f3f3f3f;
int n,a[MN],f[MN],g[2][MN*5];
int to[MN],nxt[MN],h[MN],cnt;
inline void ins(int s,int t){to[++cnt]=t;nxt[cnt]=h[s];h[s]=cnt;}
bool dfs(int st){
	if(!h[st]){f[st]=0;return true;}
	for(reg int i=h[st];i;i=nxt[i])if(!dfs(to[i]))return false;
	reg int pos=0;memset(g[1],0x3f,sizeof(g[1]));g[1][0]=0;
	for(reg int i=h[st];i;i=nxt[i],pos^=1){
		memset(g[pos],0x3f,sizeof(g[pos]));
		for(reg int j=0;j<=a[st];j++){
			if(j>=f[to[i]])g[pos][j]=min(g[pos][j],g[pos^1][j-f[to[i]]]+a[to[i]]);
			if(j>=a[to[i]])g[pos][j]=min(g[pos][j],g[pos^1][j-a[to[i]]]+f[to[i]]);
		}
	}
	reg int res=inf;
	for(reg int i=0;i<=a[st];i++)res=min(res,g[pos^1][i]);
	if(res==inf)return false;f[st]=res;return true;
}
int main(){
	//file("division");
n=IO::read();
	for(reg int i=2;i<=n;i++)ins(IO::read(),i);
	for(reg int i=1;i<=n;i++)a[i]=IO::read();
	puts(dfs(1)?"POSSIBLE":"IMPOSSIBLE");endfile;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
typedef vector<string> vstring;
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string s;
  cin>>s;
  if(s[(int)s.size()-1]!='s'){
    s.push_back('s');
  }
  else{
    s.push_back('e');
    s.push_back('s');
  }
  cout<<s<<'\n';
  return(0);
}


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

int main() {
    int q, h, s, d, n;
    cin >> q >> h >> s >> d >> n;

    long long a = 0;

    long long min2 = min({q*8, h*4, s*2, d});
    a += n / 2 * min2;

    if (n % 2 == 1) {
        long long min1 = min({q*4, h*2, s});
        a += min1;
    }

    cout << a << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
//import java.util.Arrays;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		//
		String s = sc.next();
		System.out.println(s.charAt(1) == s.charAt(2) && (s.charAt(0) == s.charAt(1) || s.charAt(3) == s.charAt(1)) ? "Yes" : "No");
	}
}


Measured memory_bytes: 35672
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int m = n * (n - 1) / 2;
    if (n % 2 == 0) m -= n / 2; else m -= (n - 1) / 2;
    cout << m << endl;

    int l = n % 2 == 0 ? n - 1 : n - 2;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < i; j++) {
            if (n % 2 != 0 && i == n - 1) {
                //nop
            } else {
                if (i + j == l) continue;
            }
            cout << j + 1 << ' ' << i + 1 << endl;
        }
    }

    //Nが偶数のときは足してN+1になるペアだけ辺ナシ
    //奇数のときはN番が仲間外れになって同様に

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lf double
#define ll long long
#define ii pair<int,int>
#define li pair<ll,int>
#define iii pair<ii,int>
#define iiii pair<ii,ii>
#define iiv pair< ii,vector<int> > 
#define mp make_pair
#define st first
#define nd second
#define pb push_back
#define pp pop_back
#define all(x) x.begin(),x.end()
#define len(x) strlen(x)
#define sz(x) (int) x.size()
#define orta ((bas+son)/2)
#define min3(x,y,z) min(min(x,y),z)
#define max3(x,y,z) max(max(x,y),z)
#define dbgs(x) cerr<<(#x)<<" --> "<<(x)<<" "
#define dbg(x) cerr<<(#x)<<" --> "<<(x)<<endl;getchar()
#define MOD 1000000007
#define inf 310000005
#define N 100005
#define LOG 19
#define KOK 500
using namespace std;

int n,t,x,y;

int main() {
	
	scanf("%d",&n);
	
	for(int i=1;i<=n;i++) {
		
		scanf("%d %d %d",&t,&x,&y);
		
		int wt=x+y;
		
		if(wt>t || (t-wt)%2) {
			
			printf("No");
			
			return 0;
			
		}
		
	}
	
	printf("Yes");
	

}	


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		String[] s = saori.nextHayami().split("");
		Arrays.sort(s);
		boolean flg = true;
		for(int i = 0;i < s.length - 1;i++){
			if(s[i].equals(s[i+1])){
				flg = false;
			}
		}
		if(flg){
			System.out.println("yes");
		} else {
			System.out.println("no");
		}
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}


Measured memory_bytes: 23124
//============================================================================
// Name        : abc135c.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>

using namespace std;

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

	vector<long long> A(N + 1);

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

	long long countm = 0;
	for(int i = 0; i < N; ++i){
		long long b;
		cin >> b;
		if(A[i] < b){
			if(A[i + 1] < (b - A[i])){
				countm += A[i + 1] + A[i];
				A[i + 1] = 0;
			}
			else {
				countm += b;
				A[i + 1] -= (b - A[i]);
			}
			A[i] = 0;
		}
		else {
			countm += b;
		}
	}

	cout << countm << endl;


	return 0;
}


Measured memory_bytes: 1024
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y-1);(X) >=0;--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
//template<class T> using vv=vector<vector<T>>;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x]=max(data[x],data[y]);
      data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  int i,j,k;
  int n,m;
  cin>>n;
  UnionFind uf(n);
  map<string,int> id;
  string str,st;
  rep(i,n){
    cin>>str>>uf.data[i];
    uf.data[i]*=-1;
    id[str]=i;
  }
  cin>>m;
  rep(i,m){
    cin>>str>>st;
    uf.unionSet(id[str],id[st]);
  }
  ll re=0;
  rep(i,n)
    re-=uf.size(i);
  cout<<-re<<endl;
  return 0;
}

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

typedef long long ll;
const ll MOD = 1e9 + 7;
const ll inf = 1LL<<60;
const double eps = 1e-9;

typedef pair<ll, ll> P;
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main()
{
    int n;
    cin >> n;
    vector <int> a(n);
    for (int i = 0;  i< n; i++) cin >> a[i];
    sort(a.begin(), a.end());
    int tmp = a[0];
    for (int i = 1; i < n; i++) {
        if (tmp == a[i]) {
            cout <<"NO" << endl;
            return 0;
        } else {
            tmp = a[i];
        }
    }
    cout << "YES" << endl;
    return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
using p = pair<int, int>;

int h, w, bl, wh;
string a[55];
int d[] = {0, 1, 0, -1};

void solve();
bool ch(p now);

int main() {
  while(1) {
    cin >> w >> h;
    if(w + h == 0) break;
    for(int i = 0; i < h; ++i) cin >> a[i];
    solve();
    cout << bl << " " << wh << endl;
  }

  return 0;
}

void solve() {
  bl = wh = 0;
  vector<vector<int>> v;
  queue<p> qu[2];
  v.resize(h);
  for(int i = 0; i < h; ++i) v[i].assign(w, 0);
  for(int i = 0; i < h; ++i)
    for(int j = 0; j < w; ++j) {
      if(a[i][j] == 'B') { qu[0].push({i, j}); }
      if(a[i][j] == 'W') { qu[1].push({i, j}); }
    }
  for(int t = 0; t < 2; ++t) {
    while(qu[t].size() > 0) {
      p now = qu[t].front();
      qu[t].pop();
      for(int i = 0; i < 4; ++i) {
        p nextp = now;
        nextp.fi += d[i];
        nextp.se += d[i ^ 1];
        if(!ch(nextp)) continue;
        if((v[nextp.fi][nextp.se] & (t + 1)) != (t + 1) &&
           a[nextp.fi][nextp.se] == '.') {
          v[nextp.fi][nextp.se] += (t + 1);
          qu[t].push(nextp);
        }
      }
    }
  }
  for(int i = 0; i < h; ++i)
    for(int j = 0; j < w; ++j) {
      bl += (v[i][j] == 1);
      wh += (v[i][j] == 2);
    }
}

bool ch(p now) {
  return now.fi >= 0 && now.fi < h && now.se >= 0 &&
         now.se < w;
}


Measured memory_bytes: 3096
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(void){
  char str1[12]="";
  scanf("%s", str1);

  for(int i=0;i<12;i++){
    printf("%c",str1[i]);
    if(i==3)
      putchar(' ');
  }
  putchar('\n');

  return EXIT_SUCCESS;
}


Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main(){
        char c[1001];
        cin >> c; 
        for(int i = 0 ; c[i] != '\0'; i++){
                c[i] -= 3; 
                if(c[i] < 'A') c[i] += 26;
        }  
        cout << c << endl;
}

Measured memory_bytes: 0
while True:
    N = int(input())
    if N == 0: break
    W, H = map(int, input().split())
    board = [[0]*W for _ in range(H)]
    for i in range(N):
        x, y = map(lambda x:int(x)-1, input().split())
        board[y][x] = 1
    w, h = map(int, input().split())
    ans = 0
    rowSums = []
    for row in board:
        rowSum = [sum(row[:w])]
        for i in range(W-w):
            rowSum.append(rowSum[i]-row[i]+row[i+w])
        rowSums.append(rowSum)
    areaSums = [[0]*(W-w+1) for _ in range(H-h+1)]
    for i in range(len(rowSums[0])):
        areaSums[0][i] = sum(rowSums[j][i] for j in range(h))
        for j in range(H-h):
            areaSums[j+1][i] = areaSums[j][i] - rowSums[j][i] + rowSums[j+h][i]
    print(max([max(row) for row in areaSums]))
            

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

int main(){
  int n;
  cin >> n;
  
  v diff;
  int a;
  for(int i=1; i<=n; i++){
    cin >> a;
    if(a==i)continue;
    diff.push_back(a-i);
  }
  
  if(diff.size()>2)
    cout << "NO" << endl;
  else
    cout << "YES" << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline
N,M=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
ind=[0]*N
import bisect
t=A[-1]
k=0
while(1):
  if k==M:
    break
  t=t/2
  a=bisect.bisect_right(A,t)
  b=N-a
  if b+k>M:
    break
  for j in range(b):
    j1=j+1
    ind[-j1]+=1
  k+=b
if k!=M:
  S=0
  for i in range(N):
    A[i]=(A[i]/(2**ind[i]))
  A.sort()
  ind2=[0]*N
  for j in range(M-k):
    ind2[-1-j]=1
  for i in range(N):
    S+=(A[i]//(2**ind2[i]))
  print(int(S))
else:
  S=0
  for i in range(N):
    S+=(A[i]//(2**ind[i]))
  print(S)


Measured memory_bytes: 58224
# ABC-140-D
N, K = map(int, input().split())
S = input()
ans = 0

#初期値を確認する。
for i in range(0, len(S)-1):
    if S[i] == S[i+1]:
        ans += 1

ans = min(N-1, ans + 2 * K)
print(ans)

Measured memory_bytes: 3316
#include "bits/stdc++.h"
using namespace std;

int main() {
    int A, B;
    cin >> A >> B;

    if (A % 2 == 1 && B % 2 == 1) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define debug(x) cerr<<#x<<" = "<<x
#define sp <<"  "
#define el <<endl
#define fgx cerr<<" ---------------------------------------------- "<<endl
#define uint unsigned int 
#define ULL unsigned long long
#define DB long double
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define rint register int 
inline int read(){
	int nm=0; bool fh=true; char cw=getchar();
	for(;!isdigit(cw);cw=getchar()) fh^=(cw=='-');
	for(;isdigit(cw);cw=getchar()) nm=nm*10+(cw-'0');
	return fh?nm:-nm;
}
#define M 200200
int n,m,S,p[M],X[M];
LL A[M],ans;
inline int solve(int l,int r){
	if(X[r]<S){ans+=S-X[l]; return X[l];}
	if(X[l]>S){ans+=X[r]-S; return X[r];}
	if(A[l]>=A[r]){
		A[l]+=A[r]; int pos=solve(l,r-1);
		ans+=X[r]-pos; return X[r];
	}
	A[r]+=A[l]; int pos=solve(l+1,r);
	ans+=pos-X[l]; return X[l];
}
int main(){
	n=read(),S=read();
	for(int i=1;i<=n;i++) X[i]=read(),A[i]=p[i]=read();
	solve(1,n),printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<int>>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18;
const int MOD = 1e9 + 7;

int main() {
    int N;
    string S;
    cin >> N >> S;
    int ans = 1;
    char tmp = S[0];
    for(int i = 1; i < N; ++i) {
        if(tmp == S[i])
            continue;
        tmp = S[i];
        ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define int long long int
int32_t main()
{
    string s;
    cin >> s;
    if (s[s.size() - 1] == '2' || s[s.size() - 1] == '4' || s[s.size() - 1] == '5' || s[s.size() - 1] == '7' || s[s.size() - 1] == '9')
        cout << "hon" << endl;
    else if (s[s.size() - 1] == '3')
        cout << "bon" << endl;
    else
        cout << "pon" << endl;

    return 0;
}

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

#define M 100

int main(void){
  int a,b,k;
  cin >> a >> b >> k;
  
  for (int i=M; i>=1; i--){
    if (a%i==0 && b%i==0) k--;
    if (k==0){
      cout << i << endl;
      break;
    }
  }
  return 0;
}
  
  
  

Measured memory_bytes: 256
program main
      implicit none
      integer :: n, m, x
      integer, allocatable :: c(:), a(:,:), d(:)
      integer :: i, j, k, cnt
      integer(8) :: minprice, price

      read *, n, m, x
      allocate( c(n) )
      allocate( a(n,m) )
      do i = 1, n
        read *, c(i), a(i,:)
      end do

      allocate( d(m) ) 
      minprice = 10**9
      do i = 0, (2**n-1)
        d(:) = 0
        price = 0
        do j = 1, n
          if( btest(i,j-1) ) then
            do k = 1, m
              d(k) = d(k) + a(j,k)
            end do
            price = price + c(j)
          end if
        end do
        cnt = 0
        do k = 1, m
          if ( d(k) >= x ) then
            cnt = cnt + 1
          else
            exit
          end if
        end do
        if ( cnt == m ) then
          if ( minprice > price ) then
            minprice = price
          end if
        end if
      end do

      if ( minprice < 10**9 ) then
        print *, minprice
      else
        print *, '-1'
      end if

end program main


Measured memory_bytes: 2780
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define P pair<ll,ll>
#define Graph vector<vector<ll>>
#define INF (1ll<<60)
#define mod 1000000007
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(){
    ll n;cin>>n;
    vector<P> vote(n),ans(n);
    rep(i,n){
        cin>>vote[i].first>>vote[i].second;
    }

    ans[0]=vote[0];
    rep(i,n-1){
        if(ans[i].first<=vote[i+1].first && ans[i].second<=vote[i+1].second){
            ans[i+1]=vote[i+1];
        }else{
            ll mul=max((ans[i].first+vote[i+1].first-1)/vote[i+1].first,(ans[i].second+vote[i+1].second-1)/vote[i+1].second);
            ans[i+1].first=mul*vote[i+1].first;
            ans[i+1].second=mul*vote[i+1].second;
        }
    }

    cout<<ans[n-1].first+ans[n-1].second<<endl;
    return 0;
}

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

int main() {
	int N; cin >> N;
	int a[200010];
	int cnt = 0, k = 0;

	for (int i = 0; i < N; ++i) cin >> a[i];

	for (int i = 1; i <= N; ++i) {
		for (int j = k; j < N; ++j) {
			if (a[j] == i) {
				cnt++;
				k = j;
				break;
			}
		}
		if (cnt != i) break;
	}

	if (!cnt) {
		if (a[0] == 1) cout << 0 << endl;
		else cout << -1 << endl;
	}
	else {
		cout << N - cnt << endl;
	}
}

Measured memory_bytes: 1024