akhauriyash/Code-Regression huggingface dataset:
from collections import deque
import sys

input = sys.stdin.readline
H,W = map(int, input().split())
table = []
dist = []
dx = [1,0,-1,0]
dy = [0,-1,0,1]
ans = 0

for i in range(H):
    S = list(input())
    table.append(S)

for sy in range(H):
    for sx in range(W):
        if table[sy][sx] == "#":
            continue
        Q = deque()
        Q.append((sy,sx))
        temp = [[-1]*W for i in range(H)]
        temp[sy][sx] = 0
        max_d = 0
        while Q:
            y,x = Q.popleft()
            for i in range(4):
                ny = y+dy[i]
                nx = x+dx[i]
                if 0<=ny<H and 0<=nx<W and temp[ny][nx]==-1 and table[ny][nx]==".":
                    Q.append((ny,nx))
                    temp[ny][nx]=temp[y][x]+1
                    max_d = max(max_d,temp[y][x]+1)
        ans = max(ans,max_d)
print(ans)


Measured memory_bytes: 47068
#include <iostream>
using namespace std;
static const int MAX = 100;
static const int INFTY = (1<<21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[MAX][MAX];

int dijkstra() {
  int minv;
  int d[MAX], color[MAX];

  for (int i = 0; i < n; i++) {
    d[i] = INFTY;
    color[i] = WHITE;
  }

  d[0] = 0;
  color[0] = GRAY;

  while ( 1 ) {
    minv = INFTY;
    int u = -1;

    for (int i = 0; i < n; i++) {
      if(minv > d[i] && color[i] != BLACK) {
        u = i;
        minv = d[i];
      }
    }

    if (u == -1) break;

    color[u] = BLACK;

    for (int v = 0; v < n; v++) {
      if (color[v] != BLACK && M[u][v] != INFTY) {
        if (d[v] > d[u] + M[u][v]) {
          d[v] = d[u] + M[u][v];
          color[v] = GRAY;
        }
      }
    }
  }

  for (int i = 0; i < n; i++) {
    cout << i << " " << (d[i] == INFTY ? -1 : d[i]) << endl;
  }
}

int main() {
  cin >> n;

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      M[i][j] = INFTY;
    }
  }

  int k, c, u, v;

  for (int i = 0; i < n; i++) {
    cin >> u >> k;
    for (int j = 0; j < k; j++) {
      cin >> v >> c;
      M[u][v] = c;
    }
  }

  dijkstra();

  return 0;
}


Measured memory_bytes: 3136
#include<iostream>
#include<algorithm>
#include<string>
#define rep(i, n) for(int i=0; i<n; i++)
using namespace std;

int main(){
    long long sum = 0;
    long long N, M; cin >> N >> M;
    long long tmp;
    rep(i, M){
        cin >> tmp;
        sum += tmp;
    }
    if(N-sum > -1) cout << N-sum << endl;
    else cout << -1 << endl;

}

Measured memory_bytes: 3636
# encoding:utf-8

import copy
import numpy as np
import random

a,b = map(int, input().split())
s = str(input())

s = s.split("-")
if len(s[0]) == a and len(s[1]) == b:
    try:
        int(s[0]) and int(s[1])
        print("Yes")
    except:
        print("No")
        
else:
    print("No")


Measured memory_bytes: 21132
#include <stdio.h>
int main(void){
    
    int x, y, temp;
    
    
    while(1){
        scanf("%d %d", &x, &y);
        if(x > y){
            temp = x;
            x = y;
            y = temp;
        }
        
        if(x == 0 && y == 0){
            break;
        }
        
        printf("%d %d\n", x, y);
        
    }
    
    return 0;
}

Measured memory_bytes: 600
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
/*多倍長整数/cpp_intで宣言
#include <boost/multiprecision/cpp_int.hpp>

using namespace boost::multiprecision;
*/

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0
#define debug(aa, a) fprintf(stderr, aa, a)

using ll =long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const long double PI = acos(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

ll lcm(ll number1, ll number2) {//lcmを求める
	return number1 / gcd(number1, number2) * number2;
}

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	int n;
	scanf("%d", &n);
	vector<int> a(n), b(n), p(n);
	rep(i, n)scanf("%d", &a[i]);
	rep(i, n)scanf("%d", &b[i]);
	rep(i, n)p[i] = i + 1;
	int bb, aa, i = 0;
	do {
		++i;
		if (a == p)aa = i;
		if (b == p)bb = i;
	} while (next_permutation(all(p)));
	printf("%d\n", abs(aa - bb));

	Please AC;
}


Measured memory_bytes: 888
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.OptionalInt;
import java.util.regex.Pattern;
import java.util.stream.Stream;

public class Main {
  public static void main(String[] args) {

    new Main().run();
  }

  public void run() {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());
      String line = br.readLine();
      final Pattern delim = Pattern.compile(" ");
      int[] arrayS = delim
        .splitAsStream(line)
        .parallel()
        .mapToInt(Integer::parseInt)
        .toArray();

      OptionalInt max =
        Arrays.stream(arrayS).max();

      dispIntArray( countingSort(arrayS, max.getAsInt()) );
    }
    catch ( IOException e ) {
      System.out.println("IOException!");
    }

  }

  public int[] countingSort(int[] a, int k) {

    int   aLength = a.length;
    int[] result  = new int[aLength];
    int[] counter = new int[k+1];

    for (int var : a) {
      counter[var]++;
    }

    for (int i=1, max=k+1; i < max; i++) {
      counter[i] += counter[i-1];
    }

    for (int i=aLength-1, val=0; i>=0; i--) {
      val = a[i];
      result[counter[val]-1] = val;
      counter[val]--;
    }

    return result;
  }

  public void dispIntArray(int[] target) {
    StringBuilder s = new StringBuilder();

    for (int i : target) { s.append(i).append(" "); }
    s.setLength(s.length()-1);

    System.out.println(s);
  }
}


Measured memory_bytes: 199768
#include <bits/stdc++.h>
using namespace std;
vector<string> rotate(int h, int w, vector<string>& grid){
	vector<string> ngrid(w);
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			ngrid[w - 1 - j].push_back(grid[i][j]);
		}
	}
	return ngrid;
}
/**

  ..............

 	#

  .......
  .
  .
  .     #
  **/
const int maxn = 620;
char G[maxn][maxn];
int line_by_d[maxn][maxn], rows[maxn][maxn], cols[maxn][maxn];
int get_in_rows(int row, int x, int y){
	if(x > y)
		return 0;
	int sum = rows[row][y];
	if(x) sum -= rows[row][x - 1];
	return sum;
}
int get_in_cols(int col, int x, int y){
	if(x > y)
		return 0;
	int sum = cols[col][y];
	if(x) sum -= cols[col][x - 1];
	return sum;
}
int get_in_d(int row, int x, int y){
	if(x > y)
		return 0;
	int sum = line_by_d[row][y];
	if(x) sum -= line_by_d[row][x - 1];
	return sum;
}
int solve(int h, int w, vector<string>& grid){
	memset(G, '.', sizeof(G));
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			if(grid[i][j] == '#'){
				G[i - j + w - 1][i + j] = '#';
			}
		}
	}
	int n = h + w - 1;
	int ans = 0;
	int l = 2 * n / 3;
	for(int i = 0; i < n; i++){
		rows[i][0] = G[i][0] == '#';
		cols[i][0] = G[0][i] == '#';
		for(int j = 1; j < n; j++){
			rows[i][j] = G[i][j] == '#';
			cols[i][j] = G[j][i] == '#';
			rows[i][j] += rows[i][j - 1];
			cols[i][j] += cols[i][j - 1];
		}
	}
	int md2 = (w - 1) % 2;
	for(int d = 2; d <= l; d += 2){
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				line_by_d[i][j] = 0;	
			}
			for(int j = 0; j + d < n; j++){
				line_by_d[i][j] = G[i][j] == '#' && G[i][j + d] == '#';
			}
			for(int j = 1; j < n; j++){
				line_by_d[i][j] += line_by_d[i][j - 1];
			}
		}
		for(int i = d; i < n; i++){
			int from = 0;
			if((i + from) % 2 != md2) from++;
			for(int j = from; j < n; j += 2){
				if(G[i][j] == '#'){
					int nans = 0;
					nans += get_in_d(i - d, max(j - d + 1, 0), j - 1);
					if(G[i - d][j] == '#' && j - d >= 0){
						nans += get_in_cols(j - d, i - d + 1, i - 1);
					}		
					if(j - d >= 0 && G[i][j - d] == '#'){
						nans += get_in_rows(i - d, j - d + 1, j - 1);
					}
					if(G[i - d][j] == '#' && j - d >= 0 && G[i][j - d] == '#'){
						nans += 1;
					}
					if(G[i - d][j] == '#' && j - d >= 0 && G[i - d][j - d] == '#'){
						nans += 1;
					}
					if(j - d >= 0 && G[i][j - d] == '#' && G[i - d][j - d] == '#'){
						nans += 1;
					}
					ans += nans;
				}
			}
		}
	}
	return ans;
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int h, w; cin >> h >> w;
	vector<string> grid(h);
	for(int i = 0; i < h; i++) cin >> grid[i];
	long long ans = 0;
	for(int i = 0; i < 4; i++){
		grid = rotate(h, w, grid);
		swap(h, w);
		ans += solve(h, w, grid);
	}
	cout << ans / 3 << endl;
	return 0;
}



Measured memory_bytes: 5504
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
    int h, w;
    cin >> h >> w;
    vector<vector<char> > a(h, vector<char>(w));
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            char aa;
            cin >> aa;
            a[i][j] = aa;
        }
    }

    vector<int> ha(h);
    vector<int> wa(w);

    for(int i=0; i<h; i++){
        bool flag = true;
        for(int j=0; j<w; j++){
            if(a[i][j]=='#'){
                flag = false;
                break;
            }
        }

        if(flag){
            ha[i] = 1;
        }
    }

    for(int i=0; i<w; i++){
        bool flag = true;
        for(int j=0; j<h; j++){
            if(a[j][i]=='#'){
                flag = false;
                break;
            }
        }

        if(flag){
            wa[i] = 1;
        }
    }

    for(int i=0; i<h; i++){
        if(ha[i]){
            continue;
        }
        for(int j=0; j<w; j++){
            if(wa[j]){
                continue;
            }
            cout << a[i][j];
        }
        cout << endl;
    }


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define PI 3.14159265358979323846
using namespace std;
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   /// https://ideone.com/Fd5s8n

int t;
cin>>t;
map<string,int>mp;
int ans =0;
while(t--){
    string s;
    cin>>s;
    if(!mp[s])
    {
        mp[s]++;
        ans++;
    }

}
    cout << ans << endl;
}


Measured memory_bytes: 19200
#include<bits/stdc++.h>
#define LL long long

using namespace std;
const int N=1e6+10;
int rd()
{
    int x=0,w=1;char ch=0;
    while(ch<'0'||ch>'9'){if(ch=='-') w=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+(ch^48);ch=getchar();}
    return x*w;
}
int n,q[N<<1],hd,tl,tg;
char cc[N],ss[N];

int main()
{
    n=rd();
    scanf("%s%s",cc+1,ss+1);
    hd=n+1,tl=n;
    int ans=0;
    for(int i=n,j=n;i;--i)
    {
	while(j&&(i<j||cc[j]!=ss[i])) --j;
	if(!j){puts("-1");return 0;}
	if(i==j){hd=n+1,tl=n,tg=0;continue;}
	if(hd>tl) q[++tl]=j-tg,q[++tl]=i-tg,ans=max(ans,1);
	else
	{
	    --tg;
	    q[--hd]=j-tg;
	    while(hd<=tl&&q[tl]+tg>=i) --tl;
	    q[++tl]=i-tg;
	    ans=max(ans,tl-hd);
	}
	while(i>j&&ss[i-1]==ss[i]) --i;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 6400
#include <stdio.h>


int main(int argc, const char * argv[]) {
    int t[4][14];
    int n, i,j,c;
    char m, d;
    for(i=0; i < 4; i++){
        for(j=0; j < 14; j++){
            t[i][j]=0;
        }
    }
    scanf("%d", &c);
    for(i = 0; i < c; i++){
        scanf("%c", &d);
        scanf("%c %d", &m, &n);
        if(m == 'S'){
            t[0][n] = 1;
        }
        else if(m == 'H'){
            t[1][n] = 1;
        }
        else if(m == 'C'){
            t[2][n] = 1;
        }
        else if(m == 'D'){
            t[3][n] = 1;
        }
    }
    for(j=1; j < 14; j++){
        if(t[0][j] != 1){
            printf("S %d\n", j);
        }
    }
    
    for(j=1; j < 14; j++){
        if(t[1][j] != 1){
            printf("H %d\n", j);
        }
    }
    
    for(j=1; j < 14; j++){
        if(t[2][j] != 1){
            printf("C %d\n", j);
        }
    }
    
    for(j=1; j < 14; j++){
        if(t[3][j] != 1){
            printf("D %d\n", j);
        }
    }
    return 0;
}


Measured memory_bytes: 2044
#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++)

int main(){
    ll H, W;
    cin >> H >> W;
    vector<string> a(H);
    rep(i, 0, H) cin >> a[i];
    vector<bool> row(H, false), col(W, false);
    rep(h, 0, H){
        bool f = false;
        rep(w, 0, W){
            if(a[h][w] == '#') f = true;
        }
        row[h] = f;
    }
    rep(w, 0, W){
        bool f = false;
        rep(h, 0, H){
            if(a[h][w] == '#') f = true;
        }
        col[w] = f;
    }
    rep(h, 0, H){
        if(!row[h]) continue;
        rep(w, 0, W){
            if(!col[w]) continue;
            cout << a[h][w];
        }
        cout << endl;
    }
    return 0;
}

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

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader input =new BufferedReader (new InputStreamReader (System.in));
		String str = input.readLine( );
		int n = Integer.parseInt(str);

		str = input.readLine( );
		String[] strlist = str.split(" ");
		int[] list = new int[n*2];
		for(int i=0; i<n*2; i++){
			list[i] = Integer.parseInt(strlist[i]);
		}

		Arrays.sort(list);

		int answer = 0;

		for(int i=0; i<n; i++){
			answer = answer + list[i*2];
		}

		System.out.println(answer);
	}
}


Measured memory_bytes: 21200
// https://atcoder.jp/contests/abcXXX/tasks/abcXXX_x

#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pll = pair<ll, ll>;

static const ll INF = 1001001001;
static const ll LLINF = 1001001001001001001;

#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define RANGE(i, m, n) for(ll i = (m); i <= (n); ++i)
#define RRANGE(i, m, n) for(ll i = (m); i >= (n); --i)
#define POSITIVE(x) (x)=((x) < 0) ? 0 : (x)

ll pow(ll x, ll y) {
    ll ret = 1;
    while(y-- > 1) ret *= x;
    return ret;
}

ll gcd(ll x, ll y) {
    if (x < y) swap(x, y);
    if (y == 0) return x;
    ll r = x / y;
    return gcd(y, x-y*r);
}

int run(istream& in, ostream& out) {
    ll N;
    in >> N;
    vector<string> S(N);
    REP(i, N) {
        in >> S[i];
    }
    sort(S.begin(), S.end());
    map<string, ll> ans{};
    REP(i, N) {
        ans[S[i]]++;
    }
    ll max_count = 0;
    for(auto p : ans) {
        max_count = max(p.second, max_count);
    }
    vector<string> s{};
    for(auto p : ans) {
        if (p.second == max_count) {
            s.emplace_back(p.first);
        }
    }
    sort(s.begin(), s.end());
    for(auto ss : s) {
        cout << ss << endl;
    }
    return 0;
}

int main() {
    return run(cin, cout);
}


Measured memory_bytes: 28404
/*
    Author : Wasi Ur Rahman
*/
#include <bits/stdc++.h>
using namespace std;
// defines
#define ll long long int
#define ull unsigned long long int
#define MOD 100000
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define sc scanf
#define pf printf
#define min3(a, b, c) min(a, min(b, c))
#define min4(a, b, c, d) min(d, min(a, min(b, c)))
#define max3(a, b, c) max(a, max(b, c))
#define max4(a, b, c, d) max(d, max(a, max(b, c)))
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) ((a) * (b) / gcd(a, b))
#define PI 3.141592653589793238462643
#define no cout << "NO" << endl;
#define yes cout << "YES" << endl;
#define elif else if
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
/* important funct */
int Int()
{
    int c;
    cin >> c;
    return c;
}
ll Long()
{
    ll c;
    cin >> c;
    return c;
}
double Double()
{
    double c;
    cin >> c;
    return c;
}

#define Int Int()
#define Long Long()
#define Double Double()
void sortString(string &str)
{
    sort(str.begin(), str.end());
}
bool isPrime(ll n)
{
    if (n <= 1)
        return false;
    for (ll i = 2; i < n; i++)
        if (n % i == 0)
            return false;
    return true;
}
ll ManualGcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
ll ManualLcm(ll a,ll b)
{
    return((a)*(b)/gcd(a,b));
}
ll fact(ll n)
{
    ll res = 1;
    for(ll i = n; i>=1; i--)
        res *= i;
    return res;
}
ll nCr(ll n,ll r)
{
    return (fact(n)/(fact(r)*fact(n-r)));
}
ll nPr(ll n,ll r)
{
    return fact(n)/fact(n-r);
}
const string s = "hello";
// Main
int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    IOS
    ll i,j;
    ll h=Long;
    ll a=Long;
    ll cnt = 0;
    ll tc = 0;
    double ans = (double)h / (double)a;
    cout << ceil(ans) << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

#define N 1000000

int insertionSort(int *,int,int);
void shellSort(int *,int);

int main(){

  int i;
  int j;
  int n;
  int data[N];

  scanf("%d",&n);

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

  shellSort(data,n);
  
  return 0;
}

int insertionSort(int *A, int n, int g){

  int i;
  int j;
  int v;
  int cnt=0;

  for(i=g;i<n;i++){
    v = A[i];
    j = i - g;
  while( j >= 0 && A[j] > v){
   A[j+g] = A[j];
   j = j - g;
   cnt++;
   }
   A[j+g] = v;
  }
  return cnt;
}

void shellSort(int *A, int n){

  int  i;
  int  m=5;
  int  cnt=0;
  int  m_cnt=0;
  int  G[5]={1000,100,10,4,1};
  
  for(i=0;i<m;i++){
  if(G[i]<=n){
  cnt += insertionSort(A, n, G[i]);
  m_cnt++;
   }
  }

  printf("%d\n",m_cnt);
    
  for(i=0;i<m-1;i++){
  if(G[i]<=n){
  printf("%d ",G[i]);
   }
  }
  
  printf("%d\n",G[i]);
  printf("%d\n",cnt);
  for(i=0;i<n;i++){
  printf("%d\n",A[i]);
  }
}

Measured memory_bytes: 4504
#include <bits/stdc++.h>
using namespace std;
#define int long long

// typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

// rep
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(x) cerr << #x << ": " << x << '\n'
#define DEBUGP(x) cerr << #x << ": " << x.first << " \t" << x.second << '\n'

int n, k;

signed main()
{
    cin >> n >> k;


    int res = n % k;
    res = min(res, abs(n%k - k));

    cout << res << endl;
    return 0;
}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int rs[4005];
int gs[4005];
int bs[4005];

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

    int n;cin >> n;
    string s;cin >> s;

    inc(i, 0, n){
        rs[i+1] = rs[i];
        gs[i+1] = gs[i];
        bs[i+1] = bs[i];
        if(s[i] == 'R') rs[i+1] += 1;
        if(s[i] == 'G') gs[i+1] += 1;
        if(s[i] == 'B') bs[i+1] += 1;
    }

    LL ans = 0;

    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if((s[i] == 'R' && s[j] == 'G') || (s[i] == 'G' && s[j] == 'R')){
                ans += bs[n] - bs[j+1];
                int d = j-i;
                if(j+d<n){
                    if(s[j+d] == 'B') ans--;
                }
            }
            if((s[i] == 'R' && s[j] == 'B') || (s[i] == 'B' && s[j] == 'R')){
                ans += gs[n] - gs[j+1];
                int d = j-i;
                if(j+d<n){
                    if(s[j+d] == 'G') ans--;
                }
            }
            if((s[i] == 'G' && s[j] == 'B') || (s[i] == 'B' && s[j] == 'G')){
                ans += rs[n] - rs[j+1];
                int d = j-i;
                if(j+d<n){
                    if(s[j+d] == 'R') ans--;
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3704
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define PRINT(v) for (auto x : (V)) cout <<x <<" " <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
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> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }


int main() {
  int n; cin >>n;
  vector<int> A(n); rep(i, n) cin >>A[i];
  int res = 0;
  int renzoku = 1;
  int color = A[0];
  for (int i=1; i<n; i++){
    if (A[i] == color){
      renzoku++;
    }else{
      color = A[i];
      if (renzoku == 1) continue;
      res += renzoku / 2;
      renzoku = 1;
    }
  }
  if (renzoku > 1){
    res += renzoku / 2;
  }
  cout <<res <<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#include<deque>
#include<cmath>
#include<math.h>
#include<cstdlib>
#include<assert.h>
#include<string>
#include<sstream>
#include<algorithm>
#include<ctime>
#include<iostream>
#define ll long long 
#define ld long double
#define pb push_back
#define mp make_pair
#define BP(n) __builtin_popcount(n)
#define rep(i,n) for(i=0;i<n;i++)
#define rep1(j,n) for (j=1;j<=n;j++)
#define unique(v) vector<ll>::iterator it; sort(v.begin(),v.end()); it= unique(v.begin(),v.begin()+v.size()); v.resize(distance(v.begin(),it))
#define PI 3.14159265358979323846
#define mod 1000000007
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL) 
using namespace std;
void input(vector<ll>& v,ll n){ ll i,io; rep(i,n) { cin>>io; v.pb(io);} }
/*void output(vector<ll> v) { ll i; rep(i,v.size()) cout<<v.at(i)<<" "; }
bool perfsq(ll n){ return (ceil(sqrt(n))==floor(sqrt(n))); }
bool ispower2(ll n) { if (n&(n-1)==0) return true; else return false; }
bool binary_pred(int a,int b){ return a==b; }*/
int main()
{
	fastio;
	string a,b;
	cin>>a;
	cin>>b;
	int i,n=a.length(),count=0;
	rep(i,n)
	{
		if (a[i]!=b[i])
			count++;
	}
	cout<<count<<endl;
}

Measured memory_bytes: 3768
//Bokan ga bokka--nn!!
//Daily Lunch Special Tanoshii !!
//これは、頭が悪く競プロが世界で一番できないHIR180が
//IOI2014日本代表になるまでのN日間の記録である。
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
typedef long long ll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 2000000000
#define mod 1000000007
#define f first
#define s second
#define rep(i,x) for(int i=0;i<x;i++)
ll dp[205][205][205];
char hoge[205];
int n;
void add(ll& a,ll b)
{
	a=(a+b)%mod;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf(" %c",&hoge[i]);
	dp[0][0][0]=1;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<=n;j++)
		{
			for(int k=0;k<=n;k++)
			{
				if(!dp[i][j][k]) continue;
				if(hoge[i+1]=='-')
				{
					add(dp[i+1][j][k],dp[i][j][k]);
				}
				if(hoge[i+1]=='D')
				{
					add(dp[i+1][j][k],dp[i][j][k]*1LL*j%mod);
					if(j&&k) add(dp[i+1][j-1][k-1],dp[i][j][k]*1LL*j*k%mod);
				}
				if(hoge[i+1]=='U')
				{
					add(dp[i+1][j][k],dp[i][j][k]*1LL*k%mod);
					add(dp[i+1][j+1][k+1],dp[i][j][k]);
				}
			}
		}
	}
	cout << dp[n][0][0] << endl;
}

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

// #pragma comment(linker, "/STACK:16777216")

using namespace std;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

#define ll long long
#define ull unsigned long long
#define F first
#define S second
#define int ll
#define pii pair<int, int>
const int SZ = 20;
const double EPS = 1e-7;
const int mod = 1e9 + 7;
const int inf = 1e9 + 9;

struct custom_hash {
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return x + FIXED_RANDOM;
    }
};

int n;
int a[SZ];
pii x[SZ][SZ];

void read() {
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        for (int j = 0; j < a[i]; ++j) {
            cin >> x[i][j].F >> x[i][j].S;
            --x[i][j].F;
        }
    }
}

void solve() {
    int ans = 0;
    for (int i = 0; i < (1 << n); ++i) {
        bitset<15> b(i);
        bool z = true;
        for (int j = 0; j < 15; ++j) {
            if (b[j]) {
                for (int k = 0; k < a[j]; ++k) {
                    if (b[x[j][k].F] ^ (x[j][k].S != 0)) {
                        z = false;
                        break;
                    }
                }
            }
            if (!z) break;
        }
        if (z) {
            int cnt = 0;
            for (int j = 0; j < 15; ++j) {
                cnt += b[j];
            }
            ans = max(ans, cnt);
        }
    }
    cout << ans;
}

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

    read();
    solve();

    return 0;
}

Measured memory_bytes: 256
arr = list(input())
down = list()
areas = list()

for i, el in enumerate(arr):
    if el == "\\":
        down.append(i)
    elif el == "/" and not len(down) == 0:
        start_ind = down.pop()
        area = i - start_ind
        while len(areas) > 0 and areas[-1][0] > start_ind:
            area += areas.pop()[1]
        areas.append((start_ind, area))
    # print("LOOP: {}".format(i))
    # print("DOWN INDICES")
    # print(down)
    # print("AREAS")
    # print(areas)
    # print()

areas = [areas[i][1] for i in range(len(areas))]
print(sum(areas))
if len(areas) == 0:
    print("0")
else:
    print(len(areas), " ".join(map(str,areas)))


Measured memory_bytes: 6332
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++) cin>>a[i];
	sort(a,a+n);
	int x=0,y=0;
	for(int i=0;i<n;i++) if(i%2==0) x+=a[i];else y+=a[i];
	cout<<abs(x-y);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

int main(){
  ll N; cin >> N;
  vector<P> a(N);
  rep(i,N) cin >> a[i].first >> a[i].second;

  vector<ll> v(8);
  rep(i, 8) v[i] = i;

// それぞれの列に対して上から何番目か
  do{
    // rep(i, 8) cout << v[i] << " ";
    // cout << endl;
    // まず条件に合うか
    bool check = true;
    rep(i,N){
      if(v[a[i].first] != a[i].second) check = false;
    }
    if(check){
      rep(i, 8){
        for(ll j = i - 1; j >= 0; j--){
          // i列に被っちゃうやつがいたらだめ
          if(v[j] == v[i] + (i - j) or v[j] == v[i] - (i - j)){
            check = false;
          }
        }
      }
      if(check) break;
    }
  }while(next_permutation(v.begin(), v.end()));


  // rep(i, 8) cout << v[i] << " ";
  // cout << endl;
  
  rep(i, 8){
    rep(j, 8){
      if(j == v[i]) cout << "Q";
      else cout<<".";
    }
    cout << endl;
  }
}



Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

string s[50];


int main()
{
  int h,w;cin>>h>>w;
  for(int i=0;i<h;i++)
    cin>>s[i];
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++)
      if(s[i][j]=='.')
	{
	  int c=0;
	  for(int x=max(0,i-1);x<=min(h-1,i+1);x++)
	    for(int y=max(0,j-1);y<=min(w-1,j+1);y++)
	      if((x!=i || y!=j) && s[x][y]=='#')
		c++;
	  s[i][j]=c+'0';
	}
  for(int i=0;i<h;i++)
    cout<<s[i]<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
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, Y;
    cin >> N >> Y;
    // 1000円i枚、5000円j枚、10000円k枚
    for(int i=0; i<=N; i++){
        for(int j=0; (i+j)<=N; j++){
            int k = N-(i+j);
            if(Y == 1000*i + 5000*j + 10000*k){
                // 条件を満たす
                cout << k << " " << j << " " << i << endl;
                return 0;
            }
        }
    }
    // 満たすものがなかった
    cout << "-1 -1 -1" << endl;
}

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

int main() {
    long long int n,c1=0;
    long long int a,b;
    long long int d1=0,d;
    cin>>n>>d;
    for(int i=0;i<n;i++)
    {
        cin>>a>>b;
    
        //d1+=sqrt((a*a)+(b*b));
        //cout<<(d1)<<"\n";
        if(((a*a)+(b*b))<=(d*d))
        {c1++;}
        //d1=0;
        
    }
    cout<<c1<<"\n";
    
	return 0;
}


Measured memory_bytes: 3632
#include<stdio.h>

int main(void)
{
  int N,i,j;
  int A[100000];
  int B[100000];
  scanf("%d\n",&N);
  for(i=0;i<=N-1;i++){
    scanf("%d",&A[i]);
    B[i]=0;
  }
  for(i=0;i<=N-1;i++){
    j=A[i]-1;
    B[j]=i+1;
  }
  for(i=0;i<=N-1;i++){
    printf("%d ",B[i]);
  }
  
  return 0;
}

Measured memory_bytes: 1536
n = int(input())
h = list(map(int,input().split()))

from collections import deque

d = deque()

d.append(h)
ans = 0

while d:
    p = d.pop()
    if p:
        p_min = min(p)

        p0 = []
        pp = []

        for i in range(len(p)):
            pp.append(p[i]-p_min)
            if p[i] - p_min == 0:
                p0.append(i)
        ans += p_min
        '''
        print(ans)
        print(pp)
        print(p0)
        '''
    
        for i in range(len(p0)-1):
            d.append(pp[p0[i]+1:p0[i+1]]) 
        d.append(pp[:p0[0]])
        d.append(pp[p0[len(p0)-1]+1:])

print(ans)

Measured memory_bytes: 38512
#include<bits/stdc++.h>
 
 
using namespace std;
int main()
{
 
string s;
cin>>s;
int y=0;
if(s[0]=='o'){
    y+=100;
}
if(s[1]=='o'){
    y+=100;
}
if(s[2]=='o'){
    y+=100;
}
cout<<700+y<<endl;
 
 
    return 0;
}

Measured memory_bytes: 256
import java.io.InputStream;
import java.util.Scanner;

public class Main {


	public static void main(String args[]) {
        InputStream inputStream = System.in;
        Scanner sc = new Scanner(inputStream);
        String out;
        int checkA=0;
        int checkAhigh=0;
        int checkB=0;
        int checkBrow=0;
        int A = sc.nextInt();
        int B=sc.nextInt();
        String[] N=new String[16];
        for(int z=0;z<16;z++) {
        	if(z%2==0&&checkA<A) {N[z]="A";checkA++;}
        	if(z%2==1&&checkB<B) {N[z]="B";checkB++;}
        	
        }
        
        if(checkA==A&&checkB==B) {System.out.println("Yay!");}
        else {System.out.println(":(");}
	}

}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

    ll X, Y;
    cin >> X >> Y;

    ll res = 0;
    if(X<=3){
    	res += (4-X)*100000;
    }
    if(Y<=3){
    	res += (4-Y)*100000;
    }
    if(X==1 && Y==1) res += 400000;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int p,q,r,ans;
  cin >> p >> q >> r;
  if (p>=q&&p>=r) ans=q+r;
  else if (q>=p&&q>=r) ans=p+r;
  else ans=p+q;
  cout << ans << endl;
  return 0;
}

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

typedef double du ;
typedef string st ;
typedef long long ll ;
typedef long double ld ;
typedef long long int lli ;

#define vi vector <lli>
#define loop(num) for (lli i = 0 ; i < num ; i ++ )
#define loopcin(num , ar ) for (lli i = 0 ; i < num ; i ++ ) {cin >> ar [i] ;}
#define loopcout(num , ar) for (lli i = 0 ; i < num ; i ++ ) {cout << ar [i] << ' '; }

#define forr(num1 , num2) for (lli i = num1 ; i < num2 ; i ++ )
#define forrcin(num1 , num2 , ar ) for (lli i = num1 ; i < num2 ; i ++ ) {cin >> ar [i] ;}
#define forrcout(num1 , num2 , ar) for (lli i = num1 ; i < num2 ; i ++ ) {cout << ar [i] << ' '; }

#define D2forrcin(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cin >> A[i][j] ;}}
#define D2forrcout(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cout << A[i][j] << ' ' ;}cout << endl ;}

#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

#define F first
#define S second

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main ()
{
    fastio
    lli num1 , num2 ;
  char o ;
  cin >> num1 >> o >> num2 ;
  cout << (o == '+' ? num1 + num2 : num1 - num2 ) ;
    return 0 ;
}

/*___________________________________________________________________functions___________________________________________________________________________*/



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//mt19937 mrand(chrono::high_resolution_clock::now().time_since_epoch().count());
//int rnd(int x) { return mrand()%x;}
typedef long long ll;
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
char s[110][110];
int dp[110][110][2];
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++){
		scanf("%s",s[i]+1);
	}
	if(s[1][1]=='.') dp[1][1][0]=dp[1][1][1]=0;
	else dp[1][1][0]=dp[1][1][1]=1;
	for(int i=1;i<=n;i++) dp[i][0][1]=dp[i][0][0]=0x3f3f3f3f;
	for(int j=2;j<=m;j++){
		if(s[1][j]=='.'){
			dp[1][j][0]=dp[1][j][1]=dp[1][j-1][0];
		}
		else{
			if(s[1][j-1]=='.'){
				dp[1][j][0]=dp[1][j][1]=dp[1][j-1][0]+1;
			}
			else{
				dp[1][j][0]=dp[1][j-1][0];
				dp[1][j][1]=dp[1][j-1][0];
			}
		}
	}
	for(int i=2;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(s[i][j]=='.'){
				dp[i][j][0]=dp[i][j][1]=min(dp[i-1][j][1],dp[i][j-1][0]);
			}
			else{
				dp[i][j][0]=min((s[i-1][j]=='.')?(dp[i-1][j][1]+1):dp[i-1][j][1],(s[i][j-1]=='.')?(dp[i][j-1][0]+1):dp[i][j-1][0]);
				dp[i][j][1]=min((s[i-1][j]=='.')?(dp[i-1][j][1]+1):dp[i-1][j][1],(s[i][j-1]=='.')?(dp[i][j-1][0]+1):dp[i][j-1][0]);
			}
		}
	}
	printf("%d\n",min(dp[n][m][0],dp[n][m][1]));
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000001;

int main(){
  int n, k;
  cin >> n >> k;
  vector<int> an(n);
  for(int i=0; i<n; ++i) cin >> an[i];
  int l = 0, r = INF;
  while(l<r-1){
    int mid = (l+r)/2;
    int cnt = 0;
    for(int i=0; i<n; ++i){
      cnt += (an[i]-1) / mid;
    }
    if(cnt > k) l = mid;
    else r = mid;
  }
  cout << r << endl;
}

Measured memory_bytes: 3980
#include <iostream>

int main()
{
	int H, W;

	while (std::cin >> H >> W)
	{	
		if (H == 0 && W == 0) break;
		for (int i = 0; i < H; ++i)
		{
			for (int j = 0; j < W; ++j) std::cout << "#";
			std::cout << std::endl;
		}
		std::cout << std::endl;
 	}

	return 0;
}

Measured memory_bytes: 1152
#include <string>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <cmath>
#include <limits>
#include <tuple>
#include <queue>
#include <stack>

using namespace std;
typedef long long ll;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()



int main()
{
	string S;
	cin >> S;
	const string words[] = { "dreameraser", "dreamerase", "dreamer", "dream", "eraser","erase"};
	bool found = false;
	for (size_t i = 0; i < S.size();) {
		found = false;
		for (auto w : words) {
			auto x = S.substr(i, w.size());
			if (x == w) {
				i += w.size();
				found = true;
				break;
			}
		}
		if (!found)
			break;
	}
	cout << (found ? "YES" : "NO") << endl;
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
using namespace std;
char A[105];
int B[26];
int C[26];
int main()
{
    int N;
    while(scanf("%d",&N)!=EOF)
    {
        scanf("%s",A);
        int ans=0;
        memset(B,0,sizeof(B));
        memset(C,0,sizeof(C));
        for(int i=0;i<N;i++)
        {
            int temp=A[i]-'a';
            B[temp]++;
        }
        int k=0;
        int sum=0;
        for(int i=0;i<N;i++)
        {
            int temp=A[i]-'a';
            if(C[temp]==0)
            {
                C[temp]++;
                k++;
            }
            B[temp]--;
            if(B[temp]==0) k--;
            sum=max(sum,k);
        }
        printf("%d\n",sum);
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define N 500000
int A[N],count=0;
void Merge(int a[N], int left, int right);
int main(void);
void Merge(int a[N], int left, int right)
{
  int mid, i, j, k;
    if (left >= right)
        return;
    mid = (left + right) / 2;
    Merge(a, left, mid);
    Merge(a, mid + 1, right);
    for (i = left; i <= mid; i++)
      A[i] = a[i];
    for (i = mid + 1, j = right; i <= right; i++, j--)
        A[i] = a[j];
    i = left;
    j = right;
    for (k = left; k <= right; k++)
      if (A[i] <= A[j]){
        a[k] = A[i++];
    count++;
      }
    else{
      a[k] = A[j--];
      count++;
    }
}
int main(void)
{
  int i,total;
    int A[N];
    scanf("%d",&total);
    for(i=0;i<total;++i)
      scanf("%d",&A[i]);
      Merge(A, 0, total - 1);
      for (i = 0; i < total; i++){
        if(i){
          printf(" ");
        }
        printf("%d", A[i]);
      }
      printf("\n");
      printf("%d\n",count);
      return 0;
}



Measured memory_bytes: 5600
# coding: utf-8
A, B, K = map(int, input().split())
ans = []
for i in range(K):
    a, b = A + i, B - i
    if a < b:
        ans.extend([a, b])
    elif a == b:
        ans.append(a)
    else:
        break
ans.sort()
for a in ans:
    print(a)

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

namespace AtCoder
{
    class Program
    {
        static Dictionary<char, int> rightChars = new Dictionary<char, int>();
        static List<char> bothChars = new List<char>();
        static int max = 0;

        static void Main(string[] args)
        {
            //[summary]B - Cut and Count
            int n = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();
            
            foreach (var c in s)
            {
                if (rightChars.ContainsKey(c))
                {
                    rightChars[c]++;
                }
                else
                {
                    rightChars.Add(c, 1);
                }                
            }

            for(int i = 0; i < n; i++)
            {
                MoveChars(s[i]);
            }

            Console.WriteLine(max);
        }

        static void MoveChars(char c)
        {
            if (rightChars[c] > 1)
            {
                rightChars[c]--;
            }
            else
            {
                rightChars.Remove(c);
            }

            if (rightChars.ContainsKey(c))
            {
                if (!bothChars.Contains(c))
                {
                    bothChars.Add(c);

                    if (bothChars.Count > max)
                    {
                        max = bothChars.Count;
                    }
                }
            }
            else
            {
                bothChars.Remove(c);
            }
        }
    }
}

Measured memory_bytes: 13280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> v;
typedef pair<int,int>p;
typedef set<int>s;
#define ll long long
#define fr(i,a,b) for(int i=a;i<b;i++)
#define fre(i,a,b) for(int i=a;i<=b;i++)
#define FOR(i,a,b) for(int i=a;i>b;--i)
#define FORE(i,a,b) for(int i=a;i>=b;--i)
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define bg begin()
#define en end()
#define cn continue
/*note

*/
int main()
{
    ll int f[100005]= {0};
    ll int n,q,b,c,x,sum=0;
    cin>>n;
    vector<int>v;
    fr(i,0,n)
    {
        cin>>x;
        if(f[x]==0)
            v.pb(x);
        f[x]++;
        sum+=x;
    }
    cin>>q;
    fr(i,0,q){
    cin>>b>>c;
    sum-=(f[b]*b);
    f[c]+=f[b];
    sum+=(f[b]*c);
    f[b]=0;
    cout<<sum<<endl;
    }


}



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

const double pi = 3.1415;

int main() {
	int n, m;
	cin>>n>>m;
	
	long long sum =0;
	for(int i=0; i<m; i++) {
		int x;
		cin>>x;
		sum+=x;
	}
	
	if(n>=sum) cout<<n-sum<<endl;
	else cout<<-1<<endl;
}


Measured memory_bytes: 3636
/*
 * atcoder/abc130/c.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

#define EPS 0.000000001
ll W, H, x, y;

void solve() {
  cin >> W >> H >> x >> y;
  // 小さい方の面積が最大となるのは(x, y)と長方形の中点を通りちょうど２分される場合。
  // その場合の面積はちょうど長方形の半分。
  // (x, y)と等しい場合は無限の直線が解にある。
  cout << fixed << double(W) * double(H) * 0.5 << " " << (x * 2 == W and y * 2 == H) << endl;
}
int main() {
  cout.precision(15);

  solve();

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
using namespace std ;
int main(){
    int n, a;
    vector<int> v;
    int avg = 0;
    int sum = 0;
    
    
    int i;
    cin >> n;
    
    for(i = 0; i < n; i++){
        cin >> a;
        avg += a;
        v.push_back(a);
    }
    
if(avg%n == 0){
        avg /= n;
        for(i = 0; i < n; i++){
            sum += (avg - v[i]) * (avg - v[i]);
        }
        cout << sum << endl;
    }else{
        int sum2 = 0;
        avg /= n;
        for(i = 0; i < n; i++){
            sum += (avg - v[i]) * (avg - v[i]);
        }
        for(i = 0; i < n; i++){
            sum2 += (avg + 1 - v[i]) * (avg + 1 - v[i]);
        }
        
        cout << min(sum, sum2) << endl;
    }
    
}

Measured memory_bytes: 256