akhauriyash/Code-Regression huggingface dataset:
/*  -*- coding: utf-8 -*-
 *
 * 1618.cc: A Garden with Ponds
 */

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

/* constant */

const int MAX_H = 10;
const int MAX_W = 10;
const int INF = 1 << 30;

/* typedef */

/* global variables */

int flds[MAX_H][MAX_W];

/* subroutines */

inline void setmin(int &a, int b) { if (a > b) a = b; }
inline void setmax(int &a, int b) { if (a < b) a = b; }

/* main */

int main() {
  for (int h, w; scanf("%d%d", &h, &w) == 2 && h > 0;) {
    for (int y = 0; y < h; y++)
      for (int x = 0; x < w; x++) scanf("%d", &flds[y][x]);

    int maxc = 0;
    for (int y0 = 0; y0 < h; y0++)
      for (int y1 = y0 + 2; y1 < h; y1++)
	for (int x0 = 0; x0 < w; x0++)
	  for (int x1 = x0 + 2; x1 < w; x1++) {
	    int mino = INF, maxd = 0, dsum = 0;

	    for (int x = x0; x <= x1; x++) {
	      setmin(mino, flds[y0][x]);
	      setmin(mino, flds[y1][x]);
	    }

	    for (int y = y0 + 1; y < y1; y++) {
	      setmin(mino, flds[y][x0]);
	      setmin(mino, flds[y][x1]);

	      for (int x = x0 + 1; x < x1; x++) {
		int &d = flds[y][x];
		setmax(maxd, d);
		dsum += d;
	      }
	    }

	    if (mino > maxd)
	      setmax(maxc, mino * (y1 - y0 - 1) * (x1 - x0 - 1) - dsum);
	  }

    printf("%d\n", maxc);
  }
  return 0;
}



Measured memory_bytes: 3164
#include <cstdio>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>

using std::cin;
using std::cout;
using std::endl;
using std::string;

int main()
{
	int hw[52][52] = {};
	int h, w;
	string arr;

	cin >> h >> w;

	for (int i = 0; i < h; ++i) {
		cin >> arr;
		for (int j = 0; j < w; ++j) {
			if (arr[j] == '#') hw[i+1][j+1] = 1;
		}
	}

	string ha = "Yes";

	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {

			if (hw[i + 1][j + 1] == 1) {
				if (hw[i + 1][j] == 0 && hw[i][j + 1] == 0 && hw[i + 2][j + 1] == 0 && hw[i + 1][j + 2] == 0) {
					ha = "No";
					break;
				}
			}

		}
	}

	cout << ha;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <cstring>
#include <cmath>
#include <cstdio>
 
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, n) for(int i = 0; i < (n); i++)
#define MP make_pair
#define X first
#define Y second
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()

using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> P;

const int INF = 1<<29;

int main(){
	int n;
	cin >> n;
	map<string, int> m;

	rep(i, n){
		string s;
		int x;
		cin >> s >> x;
		m[s] += x;
	}

	map<string, int>::iterator it;
	for(int i = 1; i <= 5; i++){
		for(it = m.begin(); it != m.end(); it++){
			if(it->first.size() == i) cout << it->first << ' ' << it->second << endl;
		}
	}

    return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

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

	ll n;
	cin >> n;

	if (n < 10) {
		cout << n << endl;
		return 0;
	}

	string s = to_string(n);

	bool flag9 = true;
	for (int i = 0; i < s.size(); i++) {
		if (i != 0 && s[i] != '9') {
			flag9 = false;
			break;
		}
	}

	int a = s[0] - '0';
	cout << (flag9 ? a + 9 * (s.size() - 1) : (a - 1) + 9 * (s.size() - 1)) << endl;
	return 0;
}


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

int main() {
    long long N,K;
    cin >> N >> K;

    if (K == 1) {
        cout << 0 << endl;
        return 0;
    }

    N = N % K;

    long long ans = N;
    while (1) {
        long long tmp = llabs(llabs(N) - llabs(K));
        N = tmp;
        if (N < ans) {
            ans = N;
        } else {
            break;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
from queue import Queue

inf = 10 ** 20

def bfs(H, W, s):
    d = [[inf for i in range(W)] for j in range(H)]
    q = Queue()

    d[0][0] = 1
    q.put([0, 0])

    dx = (0, -1, 1, 0)
    dy = (-1, 0, 0, 1)

    while not q.empty():
        p = q.get()
        x = p[0]
        y = p[1]
        for i in range(4):
            nx = x + dx[i]
            ny = y + dy[i]
            if(nx >= 0 and nx < H and ny >= 0 and ny < W):
                if(s[nx][ny] == '.' and d[x][y] + 1 < d[nx][ny]):
                    d[nx][ny] = d[x][y] + 1
                    q.put([nx, ny])

    return d[H-1][W-1]

H, W = map(int, input().split())
s = []
wnum = 0
for i in range(H):
    s.append(input())
    for j in range(W):
        if(s[i][j] == "."):
            wnum += 1
d = bfs(H, W, s)
if(d == inf):
    print("-1")
else:
    print(wnum - d)


Measured memory_bytes: 3952
/*input
2 3 1 2

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

// ALL DEFFINES HERE
#define ll long long int
#define ii pair<int, int>
#define mp make_pair
#define N 100005
#define rep(i, n) for(int i=0; i < n; i++)
#define Rep(i, k, n) for(int i=k; i < n; i++)
#define pb push_back
#define vi vector<int>
#define vii vector< vector<int> >
#define vl vector<ll>
#define F first
#define S second
#define all(v) v.begin(), v.end()

// ALL declarations here const ints etc
const  ll mod = 1e9+7; 

// IMPORTANT FUNCTION DECLARATIONS , 
//SORRY FOR THE BAD PRESENTATION
ll gcd(ll a, ll b)
{
	if ( b==0)
		return a;
	return gcd(b, a%b);
}
ll absl(ll a )
{
	return  a>= 0 ?a:-a;
}
ll maxl(ll a, ll b)
{
	return a >= b? a:b;
}
ll exp(ll a, ll n)
{
	if ( n==0)
		return 1;
	if ( n==1 )
		return a;
	if ( n & 1)
		return (a%mod * exp((a*a)%mod, n/2)%mod)%mod;
	else
		return exp((a*a)%mod, n/2)%mod;
}
// --->>> main starts here
// m*h >= l + k
double mi( double a , double b)
{
	return a < b? a : b;
}
double mx( double a , double b)
{
	return a >= b ? a : b;
}
void solve()
{
	double w , h, x, y;
	cin >> w >> h >> x >> y;
	int multiple =0;
	if ( w == 2*x && h == 2*y)
		multiple =1;
	
	cout <<w*h/2  <<  " " << multiple;

}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  // auto beginProgram = chrono::steady_clock::now();
  // int t; cin >> t;
  // while (t--) 
  {
    solve();
  }
  // auto endProgram = chrono::steady_clock::now();
  // std::chrono::duration<double> diff = endProgram - beginProgram;
  // cout << "\nTime: " <<diff.count()*1000 << " ms\n";
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define RREP(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define RFOR(i, s, n) for (int i = (int)n - 1; i >= s; --i)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
template<class T>istream&operator >>(istream&is,vector<T>&vec){for(T&x:vec)is>>x;return is;}
template<class T>inline void out(T t){cout << t << "\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout << t << " ";out(ts...);}
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;}
constexpr int INF = 1e18;

int dp[303][303][303];

signed main(){
	string s;
	int K;
	cin >> s >> K;
	int N = s.size();
	REP(i, N) {
		REP(j, N) {
			if(i > N - j - 1) continue;
			REP(k, N + 1) {
				CHMAX(dp[i + 1][j][k], dp[i][j][k]);
				CHMAX(dp[i][j + 1][k], dp[i][j][k]);
				CHMAX(dp[i + 1][j + 1][k + (s[i] != s[N - j - 1])], dp[i][j][k] + 1);
			}
		}
	}
	int ans = 0;
	REP(i, N + 1) REP(j, N + 1) REP(k, K + 1) CHMAX(ans, dp[i][j][k] * 2 - (i + j != N));
	out(ans);
}

Measured memory_bytes: 111668
#include <bits/stdc++.h>
using namespace std;
const int N = 1003, M = 1000000007;

int n, m;
char a[N][N];

int dp[N][N];
int main()
{
    cin >> n >> m;
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    for (int i = n - 1; i >= 0; --i)
    {
        for (int j = m - 1; j >= 0; --j)
        {
            if (i == n - 1 && j == m - 1)
            {
                dp[i][j] = 1;
                continue;
            }
            if (a[i][j] == '#')
                continue;
            dp[i][j] = (dp[i + 1][j] + dp[i][j + 1]) % M;
        }
    }
    cout << dp[0][0] << endl;
    return 0;
}


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

int N,ans=0,aans=0;
int a[3][110] = { 0 };


int main() {
	cin >> N;
	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < N; j++) {
			cin >> a[i][j];
		}
	}
	for (int i = 0; i < N; i++) {
		aans += a[0][i] + a[1][i];
		for (int j = 0; j < i; j++) {
			aans += a[0][j];
		}
		for (int j = i + 1; j < N; j++) {
			aans += a[1][j];
		}
		ans = max(ans, aans);
		aans = 0;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9'); t*=f;
}
const int maxn=(1e5)+10;
int n,ans,a[maxn];
int gcd(int x,int y) {
	if (!x||!y) return x+y;
	return gcd(y,x%y);
}
int main() {
	
	read(n); read(a[n+1]);
	for (int i=1;i<=n;i++) read(a[i]);
	n++;
	sort(a+1,a+n+1);
	for (int i=1;i<n;i++) ans=gcd(ans,a[i+1]-a[i]);
	printf("%d\n",ans);
	return 0;
}
/*
  0. Enough array size? Enough array size? Enough array size? Interger overflow?
  
  1. Think TWICE, Code ONCE!
  Are there any counterexamples to your algo?
    
  2. Be careful about the BOUNDARIES!
  N=1? P=1? Something about 0?
    
  3. Do not make STUPID MISTAKES!
  Time complexity? Memory usage? Precision error?
*/

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

public class Main {

	public static boolean[] cups;

	public static void swap (int a, int b) {
		boolean temp = cups[a];
		cups[a] = cups[b];
		cups[b] = temp;
	}

	public static int getNum (String str) {
		return str.equals("A") ? 0 : str.equals("B") ? 1 : 2;
	}

	public static void main(String[] args) throws IOException {

		BufferedReader br =
				new BufferedReader(new InputStreamReader(System.in));
		String line = "";
		cups = new boolean[]{true,false,false};

		while ((line = br.readLine()) != null) {
			String[] str = line.split(",");
			int swap1 = getNum(str[0]);
			int swap2 = getNum(str[1]);
			swap(swap1, swap2);
			line = null;
		}
		for (int i = 0; i < cups.length; i++) {
			if (cups[i]) {
				switch (i) {
					case 0 : System.out.println("A"); break;
					case 1 : System.out.println("B"); break;
					case 2 : System.out.println("C"); break;
				}
			}
		}

	}

}

Measured memory_bytes: 16916
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm> 
#include <cmath>

using namespace std;

typedef long long LL;

int N;
int a[105];
int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	int ans = 1 << 30;
	for (int i = -100; i <= 100; i++) {
		int tot = 0;
		for (int j = 0; j < N; j++) {
			tot += (a[j] - i) * (a[j] - i);
		}
		ans = min(ans, tot);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import numpy as np
from collections import Counter

N,M = map(int,input().split())
A = np.array([0]+[int(x) for x in input().split()],dtype=np.int64)
A_cum = np.mod(A.cumsum(),M)

c = Counter(A_cum)

answer = 0
for x in c.values():
  answer += x*(x-1)//2
print(answer)



Measured memory_bytes: 24308
#include <stdio.h>
#include <math.h>
#include <time.h>
#include<stdlib.h>
#include<string.h>

int main(void){
	int x;

	scanf("%d", &x);

	int a = x / 100;
	int b = x % 100;

	if (a * 5 >= b) {
		printf("1");
	}
	else {
		printf("0");
	}
}

Measured memory_bytes: 1640
H, W, M = map(int, input().split())

coord = set()
num_h = [0] * (H+1)
num_w = [0] * (W+1)
for i in range(M):
    h, w = map(int, input().split())
    num_h[h] += 1; num_w[w] += 1
    coord.add((h, w))

max_h = []
max_w = []
nh = nw = 0
for h in range(H+1):
    n = num_h[h]
    if n > nh:
        nh = n
        max_h = [h]
    elif n == nh:
        max_h.append(h)

for w in range(W+1):
    n = num_w[w]
    if n > nw:
        nw = n
        max_w = [w]
    elif n == nw:
        max_w.append(w)

for h in max_h:
    for w in max_w:
        if (h, w) not in coord:
            print(nh + nw)
            quit()

print(nh + nw - 1)

Measured memory_bytes: 83512
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll n; cin>>n;
    vector<ll>v(n);
    for(ll i=0;i<n-1;i++){
        cin>>v[i];
    }
    sort(v.begin(),v.end());
    for(ll i=1;i<=n;i++){
        vector<ll>::iterator it,itt;
        it=upper_bound(v.begin(),v.end(),i);
        itt=lower_bound(v.begin(),v.end(),i);

        cout<<abs((itt-v.begin())-(it-v.begin()))<<endl;
    }
}

Measured memory_bytes: 4840
#include<iostream>
using namespace std;
int main() {
    int x,y;
    for(int i=0; i<3000; i++) {
        cin >> x >> y;
        if(x == 0 && y == 0) {
            break;
        }
        
        if(x < y) {
            cout << x << " " << y << endl; 
        }else{
            cout << y << " " << x << endl;
        }
    }
}


Measured memory_bytes: 3040
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

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

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

int main(){
  int N; cin >> N;
  vector<ll> A(N);
  rep(i, N) cin >> A[i];

  map<ll ,ll> mp;
  ll ans = 0;
  rep(i, N){
    ans += mp[i - A[i]];
    mp[i + A[i]]++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 27508
// #include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <math.h>
#include <map>

typedef long long ll;
typedef unsigned long long ull;
#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(i,0,n)
#define RREP(i,n)   RFOR(i,0,n)

const int INF = 1e9;
const int MOD = 1e9+7;

using namespace std;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "{ }"; return ostr;}
   ostr << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}
   ostr << "}";
   return ostr;}

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


int main(void){
 ios::sync_with_stdio(false);

 ll N;
 cin >> N;
 vector<ll> height(N);
 REP(i, N) {cin >> height[i];}

 vector<ll> dp(N);
 REP(i, N) {dp[i] = 0;}

 FOR(i, 1, N){
   if (height[i] <= height[i-1]) {
     dp[i] = dp[i-1] + 1;
   }
   else dp[i] = 0;
 }
// cout  << dp << endl;

 ll ans = 0;
 REP(i, N) ans = max(ans, dp[i]);

 cout << ans << endl;



 return 0;
}



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

using namespace std;
using ll = long long;

ll n, k;
ll a[100005], b[100005];
ll cnt[100005];
//vector<pair<long long, long long> >V;

int main(){
  cin >> n >> k;
  for(int i = 0; i < n; ++i){
    cin >> a[i] >> b[i];
    cnt[a[i]] += b[i];
    //V.push_back(make_pair(a[i], b[i]));
  }
  for(int ans = 1; ans <= 100000; ++ans){
    if(k <= cnt[ans]){
      cout << ans << endl;
      break;
    }
    k -= cnt[ans];
  }
}

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

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    string s;
    cin >> s;
    
    for(int i = 0; i + 1 < (int)s.size(); i++){
        if(s[i] == s[i + 1]){
            cout << i + 1 << " " << i + 2 << "\n";
            return 0;
        }
        if(s[i] == s[i + 2] && i + 2 < (int)s.size()){
            cout << i + 1 << " " << i + 3 << "\n";
            return 0;
        }
    }
    
    cout << "-1 -1" << "\n";
    
    return 0;
}

Measured memory_bytes: 3748
import numpy as np
n, a, b = map(int, input().split())
a, b = min(a, b), max(a, b)
MOD = 10**9 + 7
v = pow(2, n, MOD) - 1


def cumprod(arr, MOD):
    L = len(arr)
    Lsq = int(L**.5 + 1)
    arr = np.resize(arr, Lsq**2).reshape(Lsq, Lsq)
    for n in range(1, Lsq):
        arr[:, n] *= arr[:, n - 1]
        arr[:, n] %= MOD
    for n in range(1, Lsq):
        arr[n] *= arr[n - 1, -1]
        arr[n] %= MOD
    return arr.ravel()[:L]


def make_fact(U, MOD):
    x = np.arange(U, dtype=np.int64)
    x[0] = 1
    fact = cumprod(x, MOD)
    x = np.arange(U, 0, -1, dtype=np.int64)
    x[0] = pow(int(fact[-1]), MOD - 2, MOD)
    fact_inv = cumprod(x, MOD)[::-1]
    return fact, fact_inv


# a / b = (a % N * pow(b, N - 2, N)) % N(mod=N)
fact, fact_inv = make_fact(2 * 10**5 + 1, MOD)
# print(fact)
# a_fact = fact[a]
# b_fact = fact[b]

n_fact = [n % MOD] * (b + 1)
for i in range(1, b + 1):
    n_fact[i] = (n_fact[i - 1] * (n - i)) % MOD
an_fact = n_fact[a - 1]
bn_fact = n_fact[b - 1]
# print('an a_fact', an_fact, a_fact)
# print('bn b_fact', bn_fact, b_fact)
# print('an a_fact', an_fact)
# print('bn b_fact', bn_fact)


def f(a, b, MOD):
    a, b = int(a), int(b)
    return (a % MOD * pow(b, MOD - 2, MOD)) % MOD


ca = an_fact
for i in range(1, a + 1):
    ca = f(ca, i, MOD)

cb = bn_fact
for i in range(1, b + 1):
    cb = f(cb, i, MOD)

# ca = f(an_fact, a_fact, MOD)
# cb = f(bn_fact, b_fact, MOD)
# print('v, ca, cb', v, ca, cb
print((v - ca - cb) % MOD)


Measured memory_bytes: 26112
import sys, math
from collections import defaultdict, deque, Counter
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations, product
from heapq import heappush, heappop
from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mat = lambda x, y, v: [[v]*y for _ in range(x)]
ten = lambda x, y, z, v: [mat(y, z, v) for _ in range(x)]
mod = 1000000007
sys.setrecursionlimit(1000000)

N = ri()
C = rs()

l, r = 0, N-1
ans = 0
while l < r:
	while C[l] == 'R' and l < N-1:
		l += 1
	while C[r] == 'W' and r > 0:
		r -= 1
	if l >= r: break
	l += 1
	r -= 1
	ans += 1
print(ans)

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

using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
#define all(x) x.begin(), x.end()

template <typename T1, typename T2> inline void chkmin(T1 &x, const T2 & y) {if (x > y) x = y;}
template <typename T1, typename T2> inline void chkmax(T1 &x, const T2 & y) {if (x < y) x = y;}

int n, k, c;
string s;

void read() {
	cin >> n >> k >> c;
	cin >> s;
}

const int MAXN = 2e5 + 10;

int pref[MAXN], suff[MAXN];

void build() {
	for (int i = 1; i <= n; i++) {
		pref[i] = pref[i - 1];
		if (s[i - 1] == 'o') {
			chkmax(pref[i], 1);
			if (i - c - 1 >= 1) {
				chkmax(pref[i], pref[i - c - 1] + 1);
			}
		}
	}
	for (int i = n; i >= 1; i--) {
		suff[i] = suff[i + 1];
		if (s[i - 1] == 'o') {
			chkmax(suff[i], 1);
			if (i + c + 1 <= n) {
				chkmax(suff[i], suff[i + c + 1] + 1);
			}
		}
	}
}

bool check(int pos) {
	if (s[pos - 1] == 'x') return false;
	if (pref[pos - 1] >= k) return false;
	if (suff[pos + 1] >= k) return false;
	for (int i = pos - 1; i >= max(1, pos - c - 1); i--) {
		int nxt = max(i + c + 1, pos + 1);
		if (nxt > n) continue;
		if (pref[i] + suff[nxt] >= k) return false;
	}
	return true;
}

void run() {
	build();
	/*cout << "pref = " << endl;
	for (int i = 1; i <= n; i++) {
		cout << pref[i] << " ";
	}
	cout << endl;
	cout << "suff = " << endl;
	for (int i = 1; i <= n; i++) {
		cout << suff[i] << " ";
	}
	cout << endl;*/
	for (int i = 1; i <= n; i++) {
		if (check(i)) {
			cout << i << "\n";
		}
	}
}

void write() {

}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	read();
	run();
	write();
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second

int main(int argc, char const *argv[]) {
    int n,k; std::cin >> n >> k;
    std::string s; std::cin >> s;
    int counter = 0; REP(i,n-1) if (s[i] ==  s[i+1]) counter++;
    std::cout << min(n-1,counter+2*k) << "\n";
    return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;
// import java.util.Arrays;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String[] scan = scanner.nextLine().split(" ");
		int k = scanner.nextInt();
		scanner.close();
		// int a = Integer.parseInt(scan[0]);
		// int b = Integer.parseInt(scan[1]);
		// int c = Integer.parseInt(scan[2]);

		int max = 0;
		int sum = 0;
		for(int i = 0; i < 3; i++) {
			int n = Integer.parseInt(scan[i]);
			sum += n;
			if(max < n) max = n;
		}
		// int sum = max * (int)Math.pow(2, (k - 1));
		sum -= max;
		// int add = 1;
		// for(int i = 1; i < k; i++) {
		// 	// int n = Integer.parseInt(scan[i]);
		// 	add *= 2;
		// }
		sum += max * Math.pow(2, k);
		System.out.println(sum);
	}
}


Measured memory_bytes: 21844
n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]

s_l = list(set(s))
cnt = []

for i in s_l:
    cnt.append(s.count(i)-t.count(i))
    
if max(cnt) <= 0:
    print(0)
else:
    print(max(cnt))

Measured memory_bytes: 62592
import sys
n, m = map(int, input().split())
sc = []
for _ in range(m):
    s, c = map(int, input().split())
    sc.append((s, c))


def check(i):
    st = str(i)
    if len(st) != n:
        return False
    for s, c in sc:
        if i // (10 ** (n - s)) % 10 != c:
            # print(i, s, c, (10 ** (n - s)), i // (10 ** (n - s)) % 10)
            return False
    return True


for i in range(10 ** n):
    if check(i):
        print(i)
        sys.exit(0)
print(-1)


Measured memory_bytes: 3064
def run(A, B, C, K):
    if A > B:
        if A > C:
            ret = A*(2**K) + B + C
        else:
            if B > C:
                ret = B*(2**K) + A + C
            else:
                ret = C*(2**K) + A + B
    else:
        if B > C:
            ret = B*(2**K) + A + C
        else:
            ret = C*(2**K) + A + B
    return ret


def main():
    A, B, C = map(int, input().split())
    K = int(input())
    print(run(A, B, C, K))


if __name__ == '__main__':
    main()


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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using Graph = vector<vector<int>>;

int main(){
    ll N,T,A; cin>>N>>T>>A;
    vector<ll> H(N); rep(i,N)cin>>H.at(i);
    int res = 1;
    long double dif = fabs(T-H.at(0)*0.006-A);
    rep1(i,N){
        long double tmp = fabs(T-H.at(i)*0.006-A);
       // cout<<tmp<<endl;
        if(dif>tmp){
            res = i+1;
            dif = tmp;
        }
    }
    cout<<res<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <string>
using namespace std;
const int year = 2004;

string getDay(int mm, int dd)
{
    int yy = year;
    int ans;
    if(mm <= 2)
    {
        yy -= 1;
        mm += 12;
    }
    ans = (
        dd + ((8+(13 * mm))/5)
        + (yy + (yy / 4) - (yy / 100))
        + (yy / 400)
    ) % 7;

    switch(ans)
    {
        case 0:
            return "Sunday";
        case 1:
            return "Monday";
        case 2:
            return "Tuesday";
        case 3:
            return "Wednesday";
        case 4:
            return "Thursday";
        case 5:
            return "Friday";
        case 6:
            return "Saturday";
    }
}

int main()
{
    int mm, dd;
    while(1)
    {
        cin >> mm >> dd;
        if(mm == 0) break;
        cout << getDay(mm, dd) << endl;
    }

    return EXIT_SUCCESS;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
const double PI = acos(-1);
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
    return a < b && (a = b, true);
}
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
    return a > b && (a = b, true);
}
/*-------------------------------------------*/

int n;
vector<pair<int, int>> G[100000];

queue<int> que;
int d[100000];

pair<int, int> bfs(int r) {
    memset(d, -1, sizeof(d));
    d[r] = 0;
    que.push(r);
    while(!que.empty()) {
        int v = que.front();
        que.pop();
        for(auto &&e : G[v]) {
            if(!~d[e.first]) {
                d[e.first] = d[v] + e.second;
                que.push(e.first);
            }
        }
    }
    int res, mx = -1;
    rep(i, n) if(chmax(mx, d[i])) res = i;
    return make_pair(res, mx);
}

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

    cin >> n;
    rep(i, n - 1) {
        int a, b, c;
        cin >> a >> b >> c;
        G[a].emplace_back(b, c);
        G[b].emplace_back(a, c);
    }

    cout << bfs(bfs(0).first).second << "\n";

    return 0;
}


Measured memory_bytes: 9916
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<cmath>
#include<string>

#define ls (t<<1)
#define rs ((t<<1)+1)
#define mid ((l+r)>>1)
#define fi first
#define se second
#define mk make_pair
#define pb push_back

#define N 100005
#define M 200005
#define seed 23333

using namespace std;
int i,j,m,n,p,k,A,B,C,vis[N],col[N],Q[N],x,y;
vector<int>v[N]; 
int bfs(int x)
{
	Q[Q[0]=1]=x; vis[x]=1;
	int l=1,i;
	for (;l<=Q[0];++l)
	{
			int p=Q[l];
			for (i=0;i<(int)v[p].size();++i)
			{
					int k=v[p][i];
					if (vis[k]) continue;
					Q[++Q[0]]=k;
					vis[k]=1;
					col[k]=col[p]^1;
			}
	}
	for (i=1;i<=Q[0];++i)
	{
			int p=Q[i];
				for (j=0;j<(int)v[p].size();++j)
					if (col[p]==col[v[p][j]]) return 0;
	}
	return 1;
}
int main()
{
	scanf("%d%d",&n,&m);
	for (i=1;i<=m;++i)
	{
			scanf("%d%d",&x,&y);
			v[x].pb(y); v[y].pb(x);
	}
	for (i=1;i<=n;++i)	
	if (!vis[i])
	{
		if (bfs(i)) A++; else B++;
		if (Q[0]==1) A--,C++;
	}
	printf("%lld\n",2ll*C*n-1ll*C*C+2ll*A*A+2ll*A*B+1LL*B*B);
}


Measured memory_bytes: 7936
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
#include <cassert>

using namespace std;

/* template */

using ll = long long;

void debug_out() { std::cout << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif

#define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define rrep(i, a, n) for (int i = ((int)(n-1)); i >= (int)(a); i--)
#define Rep(i, a, n) for (long long i = (long long)(a); i< (long long)(n); i++)
#define RRep(i, a, n) for (long long i = ((long long)(n-1ll)); i>=(long long)(a); i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}

struct Edge{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w){ }
};

struct edge{
    int from;
    int to;
    int weight;
    edge(int f,int t,int w) : from(f), to(t), weight(w){ }
};


using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;

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

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

bool isPalindrome(string s){
    string t = s;
    reverse(all(t));
    return s==t;
}

constexpr ll INF = 1e18+7;

vector<int> dx = {-1,0,1,0};
vector<int> dy = {0,-1,0,1};

/* template */

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<ll> a(n);
    rep(i,0,n) cin >> a[i];
    ll ans = 0ll;
    int right = 0;
    int sum = 0;
    rep(left,0,n){
        while(right<n && (sum^a[right]) == (sum+a[right])){
            sum += a[right];
            right++;
        }
        ans += right-left;
        if(left==right) right++;
        else sum ^=a[left];
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()

int main(){
    ll N,M;
    cin>>N>>M;
    ll ans=N*M;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3624
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("unroll-loops")
//#pragma warning(disable : 4996)

#ifdef _MSC_VER
#include <intrin.h>

#define __builtin_popcount __popcnt
#define __builtin_popcountll __popcnt64
#endif

#include <limits.h>
#include <math.h>
#include <time.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <complex>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include<atcoder/all>

using namespace std;

using namespace atcoder;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m - 1; i >= n; --i)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v, n) reverse(v, v + n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout << (x) << endl
#define pe(x) cout << (x) << " "
#define DEBUG(x) cout << #x << ": " << x << endl
#define lb(v, n) lower_bound(v.begin(), v.end(), (n))
#define ub(v, n) upper_bound(v.begin(), v.end(), (n))
//#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i, v.size()) cout << v[i] << " \n"[i==(int)v.size()-1]
template <typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template <typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 1e9 + 7;
constexpr int MAX = 500050;
const double pi = acos(-1);
constexpr double EPS = 1e-8;
constexpr ll LINF = 1e18 + 1;
constexpr int INF = 1e9 + 1;
void Yes(bool cond) { cout << (cond ? "Yes" : "No") << '\n'; }
void YES(bool cond) { cout << (cond ? "YES" : "NO") << '\n'; }



void solve() {
	int N, M; cin >> N >> M;
	scc_graph G(N);
	REP(i, M) {
		int a, b; cin >> a >> b;
		G.add_edge(a, b);
	}
	vector<vector<int>>res = G.scc();
	print(res.size());
	for (auto v : res) {
		cout << v.size() << " ";
		REP(i, v.size()) {
			cout << v[i] << " \n"[i == v.size() - 1];
		}
	}
}



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

	//int q;
	//cin >> q;
	//while (q--)
	solve();

}



Measured memory_bytes: 40132
/**************************
*                         *
*  Nothing Is Impossible  *
*                         *
**************************/
#include <algorithm>
#include <pthread.h>
#include <iostream>
#include <fstream>
#include <ctype.h>
#include <string>
#include <vector>
#include <thread>
#include <math.h>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <set>
#include <map>
#define GetRand(Min, Max) ((rand()%(int)(((Max) + 1)-(Min))) + (Min))
#define Rep(i, min, max) for(int i = min; i < max; ++i)
#define PB push_back
#define MP make_pair
typedef long long ll;
typedef long double ld;
using namespace std;

void Solve(){
	string s;	cin >> s;
	if(s[2] == s[3] && s[4] == s[5]){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}

int main(){
	ios::sync_with_stdio(NULL);
	cin.tie(NULL); cout.tie(NULL);
	Solve();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = (B-1); I >= (A); --I)
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;

bool solve(){
	ll H,W;
	cin >> W >> H;
	ll dx[] = {0,1,0,-1};
	ll dy[] = {1,0,-1,0};
 	if(H==0&&W==0)return false;
	string tile[H];
	bool did[H][W];
	FOR(i,0,H)FOR(j,0,W)did[i][j]=false;
	FOR(i,0,H)cin >> tile[i];
	queue<P> q;
	ll ans = 0;
	FOR(i,0,H)FOR(j,0,W){
		if(tile[i][j]=='@'){
			q.push({i,j});
			ans++;
			did[i][j]=true;
		}else if(tile[i][j]=='#'){
			did[i][j]=true;
		}
	}
	while(not q.empty()){
		ll x = q.front().first;
		ll y = q.front().second;
		q.pop();
		FOR(i,0,4){
			if(x+dx[i]<H && x+dx[i]>=0 && y+dy[i]<W && y+dy[i]>=0){
				if(not did[x+dx[i]][y+dy[i]]){
					did[x+dx[i]][y+dy[i]] = true;
					ans++;
					q.push({x+dx[i],y+dy[i]});
				}
			}
		}
	}
	cout << ans << endl;
	return true;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	while(1){
		if(not solve())break;
	}
}


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

using namespace std;
const int SIZE = 512;
int cnt[SIZE][SIZE];
int main() {
  int N, M, Q; cin>>N>>M>>Q;

  for(int i = 0; i < M; i++) {
    int l, r; cin>>l>>r;
    cnt[l][r]++;
  }
  for(int i = 1; i <= N; i++) {
    for(int j = i + 1; j <= N; j++) {
      cnt[i][j] += cnt[i][j-1];
    }
  }
  while(--Q >= 0 ) {
    int p, q; cin>>p>>q;
    int ans = 0;
    for(int i = p; i <= q; i++) {
      ans += cnt[i][q];
    }
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 1920
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <deque>
#include <bitset>

#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) v.erase(remove(v.begin(), v.end(), a), v.end())
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define REPE(i, n) for (int (i) = 0; (i) <= (n); (i)++)
using namespace std;

int N;
int A[2000];
int sum = 0;

bitset<4000001> bit1;
bitset<4000001> bit2;

signed main()
{
	cin >> N;
	REP(i, N)
	{
		cin >> A[i];
		sum += A[i];
	}

	bit1.set(A[0]);
	bit2.set(A[0]);

	for (int i = 1; i < N; i++)
	{
		bit1 <<= A[i];
		bit1.set(A[i]);
		bit1 |= bit2;
		bit2 |= bit1;
	}

	int half = ceil(sum / 2.0);
	for (int i = half; i <= 4000000; i++)
	{
		if (bit1.test(i))
		{
			cout << i << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,d,i,j,an=0;
    cin>>n>>d;
    int a[n][d];
    for(i=0;i<n;i++)
    {
        for(j=0;j<d;j++)
        cin>>a[i][j];
    }
    for(i=0;i<n;i++)
    {
        for(j=i+1;j<n;j++)
        {
            int ans=0;
            for(int k=0;k<d;k++)
            {
                ans+=(a[i][k]-a[j][k])*(a[i][k]-a[j][k]);
            }
            double a=sqrt(ans);
            int x=(int)a;
            if(x*x==ans)
            an++;
        }
    }
    cout<<an;
    return 0;
}

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

int main(void){
    char s[5]; 
    int ans = 0;

    scanf("%s", s);

    for(int i = 0; i < 4; i++){
        if(s[i] == '-'){
            ans--;
        }else{
            ans++;
        }
    }

    printf("%d\n", ans);
    return 0;

} 


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define all(x) (x).begin(), (x).end()
#define MOD 1000000007
#define int long long
using ll = long long;
using namespace std;
const int INF = 1LL << 50;
using P       = pair<int, int>;

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

struct Setup {
    Setup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} SETUP;

signed main() {
    int a, b, c, d, e, k;
    cin >> a >> b >> c >> d >> e >> k;
    string ans = "Yay!";
    if (abs(a - b) > k || abs(a - c) > k || abs(a - d) > k || abs(a - e) > k || abs(b - c) > k || abs(b - d) > k || abs(b - e) > k || abs(c - d) > k || abs(c - e) > k || abs(d - e) > k) {
        ans = ":(";
    }
    cout << ans << endl;
}


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

int main() {
    string ans;
    int S,a,b;
    cin >> S;
    a = S/100;
    b = S%100;

    if(0 < a && a < 13)
    {
        if(0 < b && b < 13)
        ans = "AMBIGUOUS";
        else
        ans = "MMYY";
    }
    else
    {
         if(0 < b && b < 13)
        ans = "YYMM";
        else
        ans = "NA";
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    map<ll,ll> mp;
    ll ans = 0;
    for(int i=0;i<N;i++){
        int a;
        cin >> a;
        ans += a;
        mp[a]++;
    }
    int Q;
    cin >> Q;
    while(Q--){
        ll b,c;
        cin >> b >> c;
        ans -= mp[b]*b;
        ans += mp[b]*c;
        mp[c] += mp[b];
        mp[b] = 0;
        cout << ans << "\n";
    }
}

Measured memory_bytes: 9424
import java.util.*;
import java.io.*;
import java.math.BigInteger;
 
public class Main {
	public static void main(String[] args) {
	Scanner s = new Scanner(System.in);
	long X = s.nextLong();
	long K = s.nextLong();
	long D = s.nextLong();
	
	if(Math.abs(X)/D < K){
		if((K-X/D)%2 == 0){
			System.out.println(Math.abs(X)%D);
		}else{
			System.out.println(Math.abs(Math.abs(X)%D-D));
		}
	}else{
		System.out.println(Math.abs(X)-D*K);
	}
    
  }
}

Measured memory_bytes: 35644
package main

import "fmt"

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

	count := 0
	max := 0
	for _, r := range s {
		if r == 'A' || r == 'C' || r == 'G' || r == 'T' {
			count++
		} else {
			if count > max {
				max = count
			}
			count = 0
		}
	}
	if count > max {
		max = count
	}
	fmt.Println(max)
}


Measured memory_bytes: 512
#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>;

int main () {
  int i, j, k, N, A, B, x, y, count=0, ans=0, sum;
  
  cin >> A >> B;
  
  for(i=A;i<B+1;i++){
    x=i;
    y=0;
    rep(j,5){
      y+=(x%10)*pow(10,4-j);
      x/=10;
    }
    if(i==y)count+=1;
  }
  cout << count;
}




Measured memory_bytes: 4020
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());
    int k = Integer.parseInt(sc.next());
    String s = sc.next();
    String c = "";
    int d[] = new int[n+1];
    int cnt = 0;
    int same = 0;
    int ans = 0;
    int chk = 0;
    
    for (int i=0; i<n; i++) {
      c = s.substring(i,i+1);
      d[i] = (c.equals("L")) ? -1 : 1;
    }
    d[n] = 0;
    
    chk = d[0] == 1 ? -1 : 1;
    
    for (int i=0; i<n+1; i++) {
      if(d[i] == chk){
        for(int j=i; j<n+1; j++){
          if(d[j] == chk) {
            same++;
          } else {
            for (int jj=0; jj<same; jj++){
              d[i+jj] = -1 * chk;
            }
            i += same;
            same = 0;
            cnt++;
            break;
          }
        }
        if(cnt == k) {
          same = 0;
          break;
        }
      }
    }

    for (int i=1; i<n+1; i++) {
      if(d[i] == d[i-1]){
        same++; 
      } else {
        ans += same;
        same = 0;
      }
    }
    
    System.out.println(ans);
  }
}


Measured memory_bytes: 30352
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <math.h>
#include <bitset>

#define X first
#define Y second
#define vsort(v) sort(v.begin(), v.end())
#define vrev(v) reverse(v.begin(), v.end())
#define vmax_p(v) max_element(v.begin(), v.end())
#define vmin_p(v) min_element(v.begin(), v.end())
#define vmax_idx(v) distance(v.begin(), vmax_p(v))
#define vmin_idx(v) distance(v.begin(), vmin_p(v))
#define vcopy(src, dst) copy(src.begin(), src.end(), back_inserter(dst))
#define P pair

// stoi(s): string to int
// stod(s): string to double

// INT_MAX
// INT_MIN
// LLONG_MAX
// LLONG_MIN
// DBL_MIN
// DBL_MAX
// LDBL_MIN
// LDBL_MAX

// A-Z: 65~90
// a-z: 97~122
// |a-z| = 26

// floor(x): truncate

// 2進数変換
// string s = bitset<20>(x).to_string();

using namespace std;
using ll = long long;

int main(int argc, const char *argv[])
{
    int n, k;
    cin >> n >> k;
    cout << n - k + 1 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
#define rep(i, n) for(int i=0;i<n;i++)
#define irep(i, n) for(int i=n-1;i>=0;i--)
typedef long long ll;
#define intv vector<int>
#define llv vector<long long>
#define intvv vector<vector<int>>
#define llvv vector<vector<long long>>
using namespace std;


int main(){
    string s;
    cin >> s;
    int n = s.size();
    int ans1 = 0, ans2 = 0;
    rep(i, n){
        if(i % 2 != s[i] - '0') ans1++;
        else ans2++;
    }
    cout << min(ans1, ans2) << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 1e9+7;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;cin>>N;
  vector<Pii> x(N);
  vint ans(N*N);
  repeat(i,N){
    cin>>x[i].first;x[i].first--;
    x[i].second = i+1;
    ans[x[i].first]=x[i].second;
  }
  sort(x.begin(),x.end());
  int l=0;
  repeat(i,N){
    repeat(j,x[i].second-1){
      while(ans[l]!=0)l++;
      ans[l]=x[i].second;
    }
  }
  int r=N*N-1;
  for(int i=N-1;i>=0;i--){
    repeat(j,N-x[i].second){
      while(ans[r]!=0)r--;
      ans[r]=x[i].second;
    }
  }
  bool isok=true;
  vint cnt(N,0);
  int idx=0;
  repeat(i,N*N){
    cnt[ans[i]-1]++;
    if(i==x[idx].first){
      isok &= cnt[ans[i]-1]==ans[i];
      idx++;
    }
  }
  repeat(i,N){
    isok &= cnt[i]==N;
  }
  if(isok){
    cout << "Yes" << endl;
    repeat(i,N*N){
      cout << ans[i];
      cout << (i==N*N-1? "\n":" ");
    }
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 2176
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}
void readA(T)(size_t n,ref T[]t){t=new T[](n);auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  int n, k; readV(n, k);
  int[] d; readA(k, d);

  auto b = new bool[](10);
  foreach (di; d) b[di] = true;

  auto isOK(int n)
  {
    while (n > 0) {
      if (b[n%10]) return false;
      n /= 10;
    }
    return true;
  }

  foreach (i; n..100000)
    if (isOK(i)) {
      writeln(i);
      return;
    }
}


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

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	string s; cin >> s;
	for (int i = 1; i < (int)s.size(); ++i) {
		if (s[i] == 'C' && s[i-1] == 'A') return printf("Yes\n"), 0;
	}
	printf("No\n");
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7,MAX = 1e5;

char bi[5][4][11];

int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < 4; i++)
	{
		for (int j = 0; j < 3; j++)
		{
			for (int k = 0; k < 10; k++)
			{
				bi[i][j][k] = '0';
			}
		}
	}
	
	for(int i = 0;i < n;++i)
	{
		int b,f,r,v;
		cin >> b >> f >> r >> v;
		b--;f--;r--;
		bi[b][f][r] += v;
	}
	for (int i = 0; i < 4; i++)
	{
		if(i)
		{
			for(int j = 0;j<20;j++)
			cout<<'#';
		}
		if(i)cout<<endl;

		for (int j = 0; j < 3; j++)
		{
			for (int k = 0; k < 10; k++)
			{
				cout<<' '<<bi[i][j][k];
			}
			cout<<endl;
		}
		
	}

	return 0;
}


Measured memory_bytes: 3080
{$R-,S-,Q-,I-,O+}
var n,a,i:integer;
    f:double;
begin
  readln(n);
  f:=0.0;
  for i:=1 to n do begin
    read(a);
    f:=f+1/a;
  end;
  writeln(1/f:0:9);
end.

Measured memory_bytes: 128