akhauriyash/Code-Regression huggingface dataset:
// https://atcoder.jp/contests/arc068/tasks/arc068_b
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, t, sz = 0;
    cin >> n;
    bitset<100001> bt;
    REP(i, n) {
        cin >> t;
        if (!bt[t]) {
            sz++;
            bt.set(t);
        }
    }
    cout << sz - (sz % 2 == 0) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;

int main()
{
	string s;
	cin >> s;

	string result;
	for (auto i = 0; i < s.length(); ++i)
	{
		if (s[i] == 'B')
		{
			if (result.length() > 0)
			{
				result.erase(result.length() - 1, 1);
			}
		}
		else
		{
			result += s[i];
		}
	}

	cout << result << endl;

	return 0;
}

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

arr = Array.new
1.upto(n) { |i|
  arr << i if i != p[i - 1]
}

if arr.length == 2 || arr.length == 0
  puts "YES"
elsif arr.length >= 3
  puts "NO"
end

Measured memory_bytes: 3836
N = int(input())
D = list(map(int, input().split()))

if D[0] != 0:
    print(0)
    exit(0)

waru = 998244353

dic = {}
dic2 = {}

for i in range(1, N+1):
    dic[i] = D[i-1]

for number, distance in dic.items():
    if distance in dic2:
        dic2[distance] = dic2[distance] + 1
    else:
        dic2[distance] = 1

if 0 in dic2:
    if dic2[0] >= 2:
        print(0)
        exit(0)

l = []

for i in range(1, len(dic2.items()) - 1):
    if i in dic2 and (i+1) in dic2:
        l.append(dic2[i] ** dic2[i+1])
    else:
        print(0)
        exit(0)

r = 1
for x in l:
    r *= x

d, m = divmod(r, waru)
print(m)


Measured memory_bytes: 28740
#JMD
#Nagendra Jha-4096

 
import sys
import math

#import fractions
#import numpy
 
###File Operations###
fileoperation=0
if(fileoperation):
    orig_stdout = sys.stdout
    orig_stdin = sys.stdin
    inputfile = open('W:/Competitive Programming/input.txt', 'r')
    outputfile = open('W:/Competitive Programming/output.txt', 'w')
    sys.stdin = inputfile
    sys.stdout = outputfile

###Defines...###
mod=1000000007
 
###FUF's...###
def nospace(l):
    ans=''.join(str(i) for i in l)
    return ans
 
 
 
##### Main ####
t=1
for tt in range(t):
    #n=int(input())
    a,b= map(int, sys.stdin.readline().split(' '))
    if a<=5 :
        print(0)
    elif a<=12:
        print(b//2)
    else:
        print(b)
    #a=list(map(int,sys.stdin.readline().split(' ')))
    
    
#####File Operations#####
if(fileoperation):
    sys.stdout = orig_stdout
    sys.stdin = orig_stdin
    inputfile.close()
    outputfile.close()

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

static const ll NIL = -1e15;

struct edge {
    int to, cost;
};

int n, m, p;
vector<edge> v[2500];
ll dist[2500], res;

int main() {
    cin >> n >> m >> p;
    int a, b, c;
    for (int i = 0; i < m; i++) {
        cin >> a >> b >> c;
        a--; b--;
        v[a].push_back({b, c});
    }
    for (int i = 1; i < n; i++) {
        dist[i] = NIL;
    }
	for (int i = 0; i < 2*n; i++) {
		for (int j = 0; j < n; j++) {
			for (edge e : v[j]) {
                if (dist[j] == NIL) continue;
				else if (i < n) dist[e.to] = max(dist[e.to], dist[j] + e.cost - p);
                else if (dist[j] + e.cost - p > dist[e.to]) dist[e.to] = 1e15;
			}
		}
	}
	
	if (dist[n - 1] == 1e15) {
		cout << -1 << endl;
	}
	else {
		cout << max(0ll, dist[n - 1]) << endl;
	}
}

Measured memory_bytes: 512
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  std::string S;

  std::cin >> S;

  std::set<char> set(ALL(S));

  std::cout << (S.size() == set.size() ? "yes" : "no") << std::endl;
  
  return 0;
}


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

int main() {
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  if (a >= k) cout << k << endl;
  else if (a + b >= k) cout << a << endl;
  else cout << a - (k - a - b) << endl;
  
  return 0;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
 
#define INF 1234567890
#define ll long long

int T, N, M, K;
ll A, B, C, D;

int main()
{
	scanf("%lld %lld.%lld", &A, &B, &C);
	B = B*100+C;
	A*=B;
	printf("%lld", A/100);
	return 0;
}

Measured memory_bytes: 3828
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

/*
// 最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// 最小公倍数
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}*/

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

	string s;
	cin >> s;

	ll ans = 0;

	string str = "";

	rep(i, (int)s.size()) {
		if (i == (int)s.size() - 1) str += s[i];
		else if (s[i] == 'B' && s[i + 1] == 'C') {
			str += 'D';
			i++;
		}
		else str += s[i];
	}

	//cout << str << endl;

	ll cnt = 0;
	rep(i, (int)str.size()) {
		if (str[i] == 'B' || str[i] == 'C') {
			cnt = 0;
			continue;
		}

		if (str[i] == 'A') cnt++;
		else ans += cnt;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 916
import java.io.*;
import java.util.*;
public class Main
{
    static PrintWriter out=new PrintWriter((System.out));
    public static void main(String args[])throws IOException
    {
        Reader sc=new Reader();
        HashMap<String,Integer> map=new HashMap<String,Integer>();
        int c=0;
        int t=sc.nextInt();
        while(t-->0)
        {
            String s=sc.next();
            if(!map.containsKey(s))
            {
                c++;
                map.put(s,0);
            }
        }
        out.println(c);
        out.close();
    }

    static class Reader 
    { 
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer("");
        public String next()
        {
            while(!st.hasMoreTokens())
            {
                try
                {
                    st=new StringTokenizer(br.readLine());
                }
                catch(Exception e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

        public long nextLong()
        {
            return Long.parseLong(next());
        }

        public double nextDouble()
        {
            return Double.parseDouble(next());
        }

        public String nextLine()
        {
            try
            {
                return br.readLine();
            }
            catch(Exception e)
            {
                e.printStackTrace();
            }
            return null;
        }

        public boolean hasNext()
        {
            String next=null;
            try
            {
                next=br.readLine();
            }
            catch(Exception e)
            {
            }
            if(next==null)
            {
                return false;
            }
            st=new StringTokenizer(next);
            return true;
        }
    } 
}

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

int main()
{
  long int n,x,y,i,c=0;
  double d;
  cin>>n>>d;
  
  for(i=0;i<n;i++)
  {
  	cin>>x>>y;
    double p=sqrt(x*x+y*y);
    if(p<=d) c++;
  }
  cout<<c;
}

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

int main(){
  long long N, K;
  cin >> N >> K;
  long long ans=1;
  for(int i=0; i<N; i++){
    if(i==0) ans*=K;
    else ans*=K-1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
aa = [0]+a+[0]
allsum = sum([abs(aa[index+1]-aa[index]) for index in range(n+1)])

for i in range(1,n+1):  
  print(allsum-abs(aa[i]-aa[i-1])-abs(aa[i+1]-aa[i])+abs(aa[i+1]-aa[i-1]))


Measured memory_bytes: 14048
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,ans;
  ans = 10000000;
  cin >> n;
  vector<int>a(n);
  for(int i=0;i<n;i++){
    cin >> a.at(i);
  }
  for(int i=-100;i<101;i++){
    int sum = 0;
    for(int j=0;j<n;j++) sum += (a.at(j)-i)*(a.at(j)-i);
    ans = min(ans,sum);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
package main

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

func main() {
	sc := NewScanner()

	n := sc.ReadInt()
	k := sc.ReadInt()
	haveCandy := make([]bool, n+1)
	for i := 0; i < k; i++ {
		d := sc.ReadInt()
		for j := 0; j < d; j++ {
			a := sc.ReadInt()
			haveCandy[a] = true
		}
	}

	cnt := 0
	for i := 1; i <= n; i++ {
		if !haveCandy[i] {
			cnt++
		}
	}

	fmt.Println(cnt)
}

// util
// *   math/simple

func Abs(x int) int {
	if x >= 0 {
		return x
	}
	return -x
}

func Min(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}
	min := values[0]
	for _, v := range values {
		if v < min {
			min = v
		}
	}
	return min
}

func Max(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}
	max := values[0]
	for _, v := range values {
		if v > max {
			max = v
		}
	}
	return max
}

func Pow(base int, exponent uint) int {
	answer := 1
	for i := uint(0); i < exponent; i++ {
		answer *= base
	}
	return answer
}

// *   io

type Scanner struct {
	bufScanner *bufio.Scanner
}

func NewScanner() *Scanner {
	bufSc := bufio.NewScanner(os.Stdin)
	bufSc.Split(bufio.ScanWords)
	bufSc.Buffer(nil, 100000000)
	return &Scanner{bufSc}
}

func (sc *Scanner) ReadString() string {
	bufSc := sc.bufScanner
	bufSc.Scan()
	return bufSc.Text()
}

func (sc *Scanner) ReadInt() int {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.Atoi(text)
	if err != nil {
		panic(err)
	}
	return num
}


Measured memory_bytes: 1768
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <cassert>
using namespace std;
typedef long long ll;
const int INF = 1<<30;
const ll MOD = 1e9+7;
const double EPS = 1e-9;

int main(int argc, const char * argv[]) {
  
  int N; cin >> N;
  vector<pair<string, int>> v(N);
  string s;
  int p;
  map<int, int> mp;
  for(int i=0; i<N; i++){
    cin >> s >> p;
    v[i] = make_pair(s, -p);
    mp[-p] = i+1;
  }
  sort(v.begin(), v.end());
  for(auto c :v){
    cout << mp[c.second] << endl;
  }
  return 0;
}

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

int main() {
	long long x, y;
	cin >> x >> y;
	int ans = 0;
	while (x <= y) {
		ans ++; x *= 2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
def inpl(): return list(map(int, input().split()))
N = int(input())
H = inpl()

DP = [1e10]*N
DP[0] = 0
DP[1] = abs(H[1] - H[0])

for i in range(2, N):
    DP[i] = min(DP[i-1] + abs(H[i] - H[i-1]),
                DP[i-2] + abs(H[i] - H[i-2]))
print(DP[-1])

Measured memory_bytes: 52208
#include<bits/stdc++.h>
using namespace std;
const long long llINF = 9223372036854775807;
const int INF = 2147483647;
const int maxn = 2e5 + 7;
const int maxm = 1e6 + 7;
const int mod = 1e9 + 7;
const double pi = acos(-1.0);
const double eps = 1e-10;
int n, k;
long long ans;
int a[maxn];
long long pre[maxn];
long long tmp[maxn];

long long tree[2000010];
int lowbit(int k)
{
    return k & -k;
}
void add(long long x, long long k)
{
    while (x < maxn)
    {
        tree[x] += k;
        x += lowbit(x);
    }
}

long long sum(int x)
{
    long long ans = 0;
    while (x != 0)
    {
        ans += tree[x];
        x -= lowbit(x);
    }
    return ans;
}

int main(int argc, char const *argv[])
{
    scanf("%d%d", &n, &k);
    for (int i = 1; i <= n; i++)
    {
        scanf("%d", &a[i]);
    }
    for (int i = 1; i <= n; i++)
        pre[i] = pre[i - 1] + a[i];
    for (int i = 1; i <= n; i++)
        pre[i] -= 1ll * k * i;

    for (int i = 0; i <= n; i++)
        tmp[i] = pre[i];
    
    sort(tmp, tmp + n + 1);
    int cnt = unique(tmp, tmp + n + 1) - tmp;

    for (int i = 0; i <= n; i++)
    {
        ans += sum( lower_bound(tmp, tmp + cnt + 1, pre[i]) - tmp + 1);
        add(lower_bound(tmp, tmp + cnt + 1, pre[i]) - tmp + 1, 1);
    }

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

Measured memory_bytes: 7040
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
#define pb push_back
#define fr(i,n) for(int i=0;i<n;i++)
#define Fr(i,n) for(int i=0;i++<n;)
#define ifr(i,n) for(int i=n-1;i>=0;i--)
#define iFr(i,n) for(int i=n;i>0;i--)

int main(){
  ll n,k,c,b;
  pair<ll,ll> a[100010];
  cin>>n>>k;
  fr(i,n){cin>>c>>b;a[i]={c,b};}
  sort(a,a+n);
  fr(i,n){
    k-=a[i].second;
    if(k<=0){cout<<a[i].first<<endl;break;}
  }
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define dec(i, n)  decID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define FR front()
#define BA back()
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)
#define IN(T, ...) T __VA_ARGS__; IN_(__VA_ARGS__);
void IN_() { };
template<typename T, typename ... U> void IN_(T & a, U & ... b) { cin >> a; IN_(b ...); };
template<typename T> void OUT(T && a) { cout << a << endl; }
template<typename T, typename ... U> void OUT(T && a, U && ... b) { cout << a << " "; OUT(b ...); }

// ---- ----

template<typename T> istream & operator>>(istream & s, vector<T> & v) { RF(e, v) { s >> e; } return s; }
template<typename T> ostream & operator<<(ostream & s, vector<T> const & v) {
	inc(i, SI(v)) { s << (i == 0 ? "" : " ") << v[i]; }
	return s;
}

int main() {
	IN(int, n);
	IN(string, s);
	int M = 1 << n;
	vector<int> p(M), pp(M);
	cin >> p;
	
	inc(k, n) {
		inc(i, M) {
			int j = (i + (1 << k)) % M;
			int x = p[i];
			int y = p[j];
			if_not(x < y) { swap(x, y); }
			pp[i] = (s[y - x - 1] == '0' ? x : y);
		}
		p = pp;
	}
	RF(e, p) { OUT(e); }
}



Measured memory_bytes: 5264
import java.io.PrintWriter;
import java.util.*;

public class Main {
    void run() {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int l = sc.nextInt();
        int r = sc.nextInt();
        int d = sc.nextInt();
        int count = 0;
        for (int i = l; i <= r; i++) {
            if (i % d == 0) {
                count++;
            }
        }
        System.out.println(count);

        // out.println("Hello World");
        out.flush();
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}


Measured memory_bytes: 35692
import java.io.*;
import java.util.*;

public class Main{
    public void run(){
        try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))){
            String[] arg = br.readLine().split(" ");
            List<Integer> list = Arrays.asList(1,3,5,7,8,10,12);
            List<Integer> list2 = Arrays.asList(4,6,9,11);
            List<Integer> list3 = Arrays.asList(2);
            if(list.contains(Integer.parseInt(arg[0])) && list.contains(Integer.parseInt(arg[1]))){
                System.out.println("Yes");
                return;
            }
            if(list2.contains(Integer.parseInt(arg[0])) && list2.contains(Integer.parseInt(arg[1]))){
                System.out.println("Yes");
                return;
            }
            if(list3.contains(Integer.parseInt(arg[0])) && list3.contains(Integer.parseInt(arg[1]))){
                System.out.println("Yes");
                return;
            }
            System.out.println("No");
        }catch(Exception e){

        }
    }
    public static void main(String... args){
        new Main().run();
    }}

Measured memory_bytes: 21332
#include<iostream>
#include<cstdio>
#include<ios>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<string>
#include<list>
#include<utility>
#include<tuple>
#include<map>
#include<unordered_map>
#include<complex>
#include<set>
using namespace std;
typedef long long llong;
llong gcd(llong a, llong b) {
	if (a < b) std::swap(a, b);
	if (a % b == 0) return b;
	else return gcd(b, a % b);
}
llong lcm(llong a, llong b) {
	llong g = gcd(a, b);
	return a * b / g;
}
//ここまで共通
int N, C, D[35][35], c[550][550], E[3][35] = { 0 };
vector<int>A[3], ANS;

int main() {
	cin >> N >> C;
	for (int i = 0; i < C; i++) {
		for (int j = 0; j < C; j++) {
			cin >> D[i][j];
		}
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			cin >> c[i][j];
			c[i][j]--;
			A[(i + j) % 3].push_back(c[i][j]);
		}
	}
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < C; j++) {
			for (int k = 0; k < A[i].size(); k++) {
				E[i][j] += D[A[i][k]][j];
			}
		}
	}

	for (int i = 0; i < C; i++) {
		for (int j = 0; j < C; j++) {
			for (int k = 0; k < C; k++) {
				if(i != j && j != k && k != i)
					ANS.push_back(E[0][i] + E[1][j] + E[2][k]);
			}
		}
	}
	sort(ANS.begin(), ANS.end(), less<int>());
	cout << ANS[0] << endl;
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int ans=0;
    for(int i = 0; i < n; i++) {
        if(a[i]==i+1){
            if(i==n-1) ans++;
            else{
                ans ++;
                i++;
            }
        }
    }
    cout << ans << endl;

    return 0;
}

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

#define pb	push_back
#define eb	emplace_back
#define mk	make_pair
#define fi	first
#define se	second
#define endl	'\n'

typedef long long ll;
typedef pair<int,int> ii;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);

const int T = 2e5 + 3;
set<int> bag;
int v[T];
bool error[T];

int main() {
    ios_base::sync_with_stdio(false);
    int n,k; cin >> n >> k;

    for(int i = 0; i < n; i++) cin >> v[i];
    int ans = 1;
    for(int i = 0; i < k; i++) bag.insert(v[i]);

    int wat = 1;
    int taw = 0;
    bool ok = 0;

    while(wat < n) {
        if(v[wat] < v[wat-1]) taw = wat;
        if(wat-taw+1 >= k) error[wat] = 1;
        wat++;
    }

    if(error[k-1]) ok = 1;

    for(int i = k; i < n; i++) {
        int maxi = *bag.rbegin();
        int mini = *bag.begin();
        if(v[i] < maxi or v[i-k] != mini) {
            if(!error[i]) ans++;
            if(error[i] and !ok) ok = 1, ans++;
        }
        bag.erase(v[i-k]);
        bag.insert(v[i]);
    }

    cout << ans << endl;

    return 0;
}



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

int main(){
    ll a,b;cin >> a >> b;
    string s;cin >> s;
    bool ok=true;
    rep(i,s.size()){
        if(s[i]<'0' || s[i]>'9'){
            if(i==a && s[i]=='-')continue;
            ok=false;
        }
    }
    if(ok && s[a]=='-')cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main(void){
    int N;
    cin>>N;
    int A[N];
    for(int i=0;i<N;i++)
        cin>>A[i];
    sort(A,A+N);
    cout<<A[N-1]-A[0]<<endl;
    return 0;
}


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

public class Main {
	// AtCoder Beginner Contest 086
	// https://atcoder.jp/contests/abc086/tasks
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = 0;
		
		if (b >= 0 && b <= 9) {
			c = a * 10 + b;
		} else if (b >= 10 && b <= 99) {
			c = a * 100 + b;
		} else {
			c = a * 1000 + b;
		}
		double d = Math.sqrt(c*1.0);
		if ((int)d - d == 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
	
	static class FastReader { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() { 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next() { 
            while (st == null || !st.hasMoreElements()) { 
                try { 
                    st = new StringTokenizer(br.readLine()); 
                } catch (IOException  e) { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() { 
            String str = ""; 
            try{ 
                str = br.readLine(); 
            } catch (IOException e) { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
}


Measured memory_bytes: 21204
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Miscelleneous {
	class Program {
		static int[] parins() {
			return Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
		}
		static void Main(string[] args) {
			Console.ReadLine();
			var S = Console.ReadLine();
			var Stones = Parse(S);
			Console.WriteLine(calc(Stones));
		}

		static bool[] Parse(string d) {
			return d.Select(c => c == '#').ToArray();
		}

		static int calc(bool[] Blacks) {
			var N = Blacks.Length;
			int I;  //Count for Change into (index) of White leftside and rest Black rightside
			I = Blacks.Count(b => !b);
			int res = I;
			for (int i = 0; i < N; i++) {
				if (Blacks[i]) I++;
				else {
					I--;
					if (I < res) res = I;
				}
			}
			return res;
		}
	}

}

Measured memory_bytes: 12640
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const [X, Y] = input[0].map((str) => parseInt(str, 16));

  return X === Y ? "=" : X > Y ? ">" : "<";
};

console.log(main(read()));


Measured memory_bytes: 29660
from collections import defaultdict
dic = defaultdict(lambda : 0)
n = int(input())
for _ in range(n):
    str = ''.join(sorted(input()))
    dic[str] += 1
count = 0
memos = defaultdict(lambda : 0)
for key in dic.keys():
    value = dic[key]
    if not value in memos.keys():
        x = value*(value-1)/2
        memos[value] = int(x)
    else:
        x = memos[value]
    count += x
print(int(count))

Measured memory_bytes: 18236
import itertools

def input_ints():
    return list(map(int, input().split()))

def output_list(v):
    print(' '.join(str(x) for x in v))

def main():
    n = int(input())
    p = []
    for i in range(n):
        a, b = input_ints()
        p.append((b, a))
    p.sort()
    t = 0
    for i in range(n):
        if t > p[i][0] - p[i][1]:
            print('No')
            return
        t += p[i][1]
    print('Yes')


if __name__ == '__main__':
    main()


Measured memory_bytes: 29552
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <queue>
#include <utility>
using namespace std;

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

#define For(i, a, b) for(int i = (a); i < (b); i++)
#define Rep(i, n) For(i, 0, (n))

const int inf = 999999999;
const int mod = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int main(){
	ll n; cin >> n;
	ll t = 0, a = 0;
	cin >> t >> a;
	For(i, 0, n - 1){
		ll tt, aa; cin >> tt >> aa;
		if(tt >= t && aa >= a){
			t = tt; a = aa;
		}else{
			ll j = max((t + tt - 1)/tt, (a + aa - 1)/aa);
			t = tt * j; a = aa * j;
		}
	}
	cout << t + a << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define mod 1000000007 //10^9+7
#define div 998244353
#define rep(i,n) for(int i=0;i<n;i++)
int h,w;
string c[30][30];
signed main(){
    cin>>h>>w;
    rep(i,h){
        rep(j,w){
            cin>>c[i][j];
            if(c[i][j]=="snuke"){
                char c='A'+j;
                cout<<c<<i+1<<endl;
                return 0;
                
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int a, b;
	scanf("%d", &a);
	scanf("%d", &b);
	if (a < b)
		printf("a < b\n");
	else if (a > b)
		printf("a > b\n");
	else
		printf("a == b\n");
	return 0;
}



Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define vll vector<ll>
#define endl "\n"
#define pll pair<ll,ll>
#define all(x) (x).begin() , (x).end()
#define f first
#define s second
#define pr(x) cout<<x<<endl;
#define pr2(x,y) cout<<x<<" "<<y<<endl;
#define pr3(x,y,z) cout<<x<<" "<<y<<endl;
#define prv(v) for(auto x:v) cout<<x<<" ";
#define ffs fflush(stdout);
using namespace std;
 
const ll N =(2e5+5);
const ll MOD = 1e9;
const ll INF = LLONG_MAX;
const ll LOG = 29;
#define PI 3.1415 
  
double circumference(double r) 
{ 
    double cir = 2*PI*r; 
    return cir; 
} 
long long binpow(long long a, long long b) {
    a%=MOD;    
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = (res * a)%MOD;
        a = (a * a)%MOD;
 
        
        b >>= 1;
    }
    res%=MOD;
    return res;
} 

void solve(){
    double r;
    cin>>r;
    cout<<circumference(r)<<endl;
}
 
 
int main(){
    ios_base::sync_with_stdio(0);
     cin.tie(NULL);
     
    ll t=1;
    //cin>>t;
    while(t--){
        solve();
    }
     
 
 
    return 0;     
    
        
}//42364286 418930126

Measured memory_bytes: 3780
#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;
}
typedef long long ll;
const ll mod=(1e9)+7;
const int maxn=(2e6)+10;
ll jc[maxn],iv[maxn],ivjc[maxn];
ll C(int x,int y) {
	if (x<y) return 0;
	return jc[x]*ivjc[x-y]%mod*ivjc[y]%mod;
}
int n,m,k;
int main() {
	//freopen("1.txt","r",stdin);
	jc[0]=iv[0]=ivjc[0]=1;
	jc[1]=iv[1]=ivjc[1]=1;
	for (int i=2;i<maxn;i++) {
		jc[i]=jc[i-1]*i%mod;
		iv[i]=(mod-mod/i)*iv[mod%i]%mod;
		ivjc[i]=ivjc[i-1]*iv[i]%mod;
	}
	read(n); read(m);
	if ((n+m)%3!=0) { printf("0\n"); return 0; }
	k=(n+m)/3;
	n-=k,m-=k;
	if (n<0||m<0) { printf("0\n"); return 0; }
	printf("%lld\n",C(n+m,n));
	return 0;
}
/*
  REMEMBER:
  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!
  Array size? Integer overflow? Time complexity? Memory usage? Precision error?
*/

Measured memory_bytes: 47104
#include <stdio.h>
long long expo(long long M, long long m, long long n){
    if(n == 0){
        return 1;
    }
    if(n == 1){
        return m;
    }
    long long aHalf = expo(M, m, n / 2) % M;
    if(n % 2 == 1){
        return (((aHalf * aHalf) % M) * m) % M;
    }else{
        return (aHalf * aHalf) % M;
    }
}
int main(){
int m,n,i;
long long ans = 0, M = 1000000007;
scanf("%d%d", &m, &n);
int result = (int) expo(M, m * 1LL, n * 1LL);
printf("%d\n", result);
return 0;
}

Measured memory_bytes: 2740
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	long long ans = 0;
	int st[1<<18];
	for(int i = 0; i <101010; i++) st[i] = 0;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		st[a[i]]++;
		ans += a[i];
	}
	int q;
	cin >> q;
	sort(a.begin(),a.end());
	for(int i = 0; i < q; i++){
		int b,c;
		cin >> b >> c;
		st[c] += st[b];
		ans -=(long long) b*(long long)st[b];
		ans += (long long) c*(long long)st[b];
		st[b] = 0;
		cout << ans << endl;
	}
	return 0;
}	

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

#define ll long long
#define ulll unsigned __int128

const ll M=998244353;
const ulll ulll1=1, cm1=(ulll1<<100)-1;

namespace std {
	template<>
	struct hash<ulll> {
		inline size_t operator()(const ulll &x) const {
			return (size_t)(x^(x>>32)^(x>>64)^(x>>96));
		}
	};
}

unordered_map<ulll, ll> dp;

ll ans(ulll mask) {
	if(mask<=cm1)
		return 1;
	int l=mask>>100;
	auto it=dp.find(mask);
	if(it==dp.end()) {
		it=dp.insert(make_pair(mask, (1+(mask&1))*ans(((mask&cm1)>>1)|(((ulll)l-1)<<100))%M)).first;
		for(int k1=1; k1<=l/2; ++k1) {
			ulll mask2=cm1;
			for(int k2=1; k1*k2<=l; ++k2) {
				mask2&=(mask>>(k1*(k2-1)))&((ulll1<<k1)-1);
				if(k2>1)
					it->second=(ans(mask2|(((ulll)k1)<<100))*ans(((mask&cm1)>>(k1*k2))|(((ulll)l-k1*k2)<<100))+it->second)%M;
			}
		}
	}
	return it->second;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	string s;
	cin >> s;
	int n=s.size();
	ulll mask=0;
	for(int i=0; i<n; ++i)
		if(s[i]=='1')
			mask|=ulll1<<i;
	mask|=((ulll)n)<<100;
	cout << ans(mask);
}

Measured memory_bytes: 4236
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(x) x.begin(), x.end()
#define mod 1000000007
typedef long long ll;

int main(){
  int h, w;
  cin >> h >> w;
  set<int> rows;
  set<int> cols;
  vector<string> mp;
  rep(i, h){
    string str;
    cin >> str;
    mp.push_back(str);
  }
  rep(i, h){
    bool alldots = true;
    rep(j, w){
      if(mp[i][j] == '#') alldots = false;
    }
    if(alldots) rows.insert(i);
  }
  rep(j, w){
    bool alldots = true;
    rep(i, h){
      if(mp[i][j] == '#') alldots = false;
    }
    if(alldots) cols.insert(j);
  }
  rep(i, h){
    rep(j, w){
      if(rows.find(i) == rows.end() && cols.find(j) == cols.end()){
        cout << mp[i][j];
      }
    }
    if(rows.find(i) == rows.end()) cout << endl;
  }
  return 0;
}

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

#define ll long long
#define endl "\n"
#define int ll

signed main ()
{

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n, a, b;
	cin >> n >> a >> b;
	int ans = min(n % (a + b), a);
	ans += ((n / (a + b)) * a);
	cout << ans << endl;
	return 0;

}


Measured memory_bytes: 3652
N = int(input())
a = list(map(int,input().split()))
suma = sum(a)
ans = abs(suma - a[0])
sumb = a[0]
if N == 2:
    print(abs(a[0]-a[1]))
else:
    for i in range(1,N-1):
        sumb += a[i]
        ans = min(ans,abs(suma - 2*sumb))
    print(ans)

Measured memory_bytes: 76752
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

/*  Macros from Endagorion */
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;


int main(){
        
    ios_base::sync_with_stdio(0);
    
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    string a,b;
    cin>>a;
    cin>>b;
    int n_a = a.length();
    int n_b = b.length();

    if(n_a==n_b){
        int i=0,j=0;
        while(i<n_a && j<n_b){
            if(a[i]-'0' < b[i]-'0'){
                cout<<"LESS\n";
                return 0;
            }
            else if(a[i]-'0' > b[j]-'0'){
                cout<<"GREATER\n";
                return 0;
            }
            i++,j++;
        }
        cout<<"EQUAL\n";
    }
    else if(n_a<n_b){
        cout<<"LESS\n";
    }
    else{
        cout<<"GREATER\n";
    }
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int H,W,i,j;
	while(1){
		scanf("%d %d",&H,&W);
		if(H==0 && W==0)break;
		for(i=1;i<=H;i++){
			for(j=1;j<=W;j++){
				if(i==1 || j==1 || W==j || H==i){
					printf("#");
				}else{printf(".");}
			}
			puts("");
		}
		puts("");
	}
return 0;
}


Measured memory_bytes: 1992
#include <iostream>
#include <vector>
using namespace std;
int min(int a,int b, int c){
	if (a<=b && a<=c) return a;
	if (b<=a && b<=c) return b;
	if (c<=a && c<=b) return c;
}
int main() {
	int n;
	cin >> n;
	vector <int> p(n);
	for (int i=0; i<n; i++) cin >> p[i];
	int ans=0;
	for (int i=1; i<n-1; i++){
		if (p[i-1]==min(p[i-1],p[i],p[i+1]) && p[i]==min(p[i],p[i+1])) ans++;
		else if (p[i+1]==min(p[i-1],p[i],p[i+1]) && p[i]==min(p[i],p[i-1])) ans++;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"
typedef long long ll;
const ll MOD = 1000000007LL;
const ll MAX = 100010LL;

template <typename T> T gcd(T a, T b) { 
    if(b == 0) 
        return a; 
    return gcd(b, a % b); 
}
template <typename T> T power(T x, T y, ll m = MOD) {
    T ans = 1; 
    x %= m; 
    while (y > 0) { 
        if (y & 1LL) {
            ans = (ans * x) % m;   
        } 
        y >>= 1LL; 
        x = (x * x) % m; 
    } 
    return (ans % m); 
}

int main() {

    FAST_IO;

    int a[3];
    for (int i = 0; i < 3; ++i) {
        cin >> a[i];
    }
    if (a[0] + a[1] + a[2] >= 22) {
        cout << "bust" << endl;
    } else {
        cout << "win" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

#define int long long

template<typename A, size_t N, typename T>

void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//ここにグローバル変数宣言

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//ここに関数宣言


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
signed main(){
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int X;
cin>>X;
int c500=X/500;
int c5 = (X - (X/500)*500) /5 ;

cout<<c500*1000 + c5 *5<<endl;




return 0;





}

Measured memory_bytes: 3588
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

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

    ll ans = 0;
    ans = n*(n-1)/2LL;
    ans += m*(m-1)/2LL;
    cout << ans << endl; 
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<complex>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using Complex = complex<double>;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
double PI = acos(-1.0);
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)



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

	long double n, m, d;
	cin >> n >> m >> d;
	if (d != 0) {
		cout << setprecision(20) << 2.0*(m - 1)*(n - d) / (n*n) << endl;
	}else cout << setprecision(20) << (m - 1)*(n - d) / (n*n) << endl;
	
	return 0;
}

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

int main() {
    int n; cin >> n;
    vector<int> h(n);
    for (int &hi: h) cin >> hi;
    int ans = h.front() + h.back();
    for (int i = 0; i + 1 < n; i++) ans += abs(h[i] - h[i + 1]);
    cout << ans / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict


H, W, M = map(int, input().split())

h = [-1]
w = [-1]
hw_dict = defaultdict(int)
for _ in range(M):
    hi, wi = map(int, input().split())
    h.append(hi)
    w.append(wi)
    hw_dict[(hi, wi)] = 1
# print(h)
# print(w)
# print(hw)
h_cnt = [0] * (H + 1)
w_cnt = [0] * (W + 1)
for i in range(1, M + 1):
    h_cnt[h[i]] += 1
    w_cnt[w[i]] += 1
# print(h_cnt)
# print(w_cnt)

h_max = max(h_cnt)
w_max = max(w_cnt)

h_max_idx = []
w_max_idx = []


for i in range(1, H + 1):
    if h_cnt[i] == h_max:
        h_max_idx.append(i)

for i in range(1, W + 1):
    if w_cnt[i] == w_max:
        w_max_idx.append(i)


# print(h_max_idx)
# print(w_max_idx)

ans = 0

for i in h_max_idx:
    for j in w_max_idx:
        tmp = h_cnt[i] + w_cnt[j]
        if hw_dict[(i, j)] == 1:
            tmp -= 1
            ans = max(ans, tmp)
        else:
            ans = tmp
            break

print(ans)


Measured memory_bytes: 195924
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>

using namespace std;

int main()
{
	long long ans = 0;
	long long N, M;

	cin >> N >> M;

	if (N > M)
	{
		swap(N, M);
	}

	if (N == 1 && M == 1)
	{
		ans = 1;
	}
	else if (N == 1)
	{
		ans = M - 2;
	}
	else
	{
		ans = (N - 2) * (M - 2);
	}

	cout << ans << endl;

	return 0;
}

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

int main() {
  int A,B;
  cin >> A >> B;
  if(A >= 13){
    cout << B <<endl;
  }
  else if(12 >= A && A >= 6){
    cout << B/2 <<endl;
  }
  else{
    cout << 0 << endl;
  }
}

Measured memory_bytes: 256
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [a,b,t] <- getIntList
    print $ (t `div` a) * b

Measured memory_bytes: 380
def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    N = read_int()
    S = input()
    count = 1
    for i in range(1, N):
        if S[i] != S[i-1]:
            count += 1
    return count


if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 84648
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
    int a,b,c,d,e,k;
    cin >> a >> b >> c >> d >> e >> k;
    if(e-a <= k){
        cout << "Yay!" << endl;
    }else{
        cout << ":(" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
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;}
const int P = 1000000007;
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z main.cpp
//.\a.exe

int main(void){ios::sync_with_stdio(false);cin.tie(0);
////////////////////////////////////////////////////////
int n;
cin >> n;
int a[n];
for(int i=0;i<n;i++){
   cin >> a[i];
}

sort(a,a+n);

cout << a[n-1]-a[0] << endl;
////////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
//		String line = reader.readLine();
		String[] str = reader.readLine().split(" ");
		int[] ab = new int[str.length];
		for (int i = 0; i < str.length; i++) {
			ab[i] = Integer.parseInt(str[i]);
		}
		if ((ab[0] > ab[2] && ab[2] > ab[1]) || (ab[0] < ab[2] && ab[2] < ab[1])) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
	}
}

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

int main() {
  int n, l;
  cin >> n >> l;
  vector<string> s(n);
  for (int i = 0; i < n; ++i) {
    cin >> s.at(i);
  }
  sort(s.begin(), s.end());
  string ans;
  for (int i = 0; i < n; ++i) {
    ans += s.at(i);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{    
    int n;
    int counters=0;
    while(cin>>n)
    {
       if(n==0) return 0;
       else
         {
            counters++;
            cout<<"Case"<<" "<<counters<<":"<<" "<<n<<endl;
         }
    }
    return 0;
}


Measured memory_bytes: 3008
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(){
  string top;
  while(cin >> top, top != "-"){
    string left, right, res;
    cin >> left >> res;

    char center = left[0];
    left.erase(0, 1);
    while(!top.empty() || !left.empty()){
      if(res.find(center, 0) == string::npos && !left.empty()){
	right.push_back(center);
	center = left[0];
	left.erase(0, 1);
      }else if(!top.empty()){
	center = top[0];
	top.erase(0, 1);
      }
    }
    if(res.find(center, 0) == string::npos) right.push_back(center);

    cout << right << endl;
  }
  return 0;
}

Measured memory_bytes: 1200
#include <stdio.h>

int main(void)
{
    int i, n, x;
    i = 1;
    x = i;
    scanf("%d", &n);

    while (i <= n) {
        x = i;
        if(x%3==0) 
            printf(" %d", i);
        else {
            while(x) {
                if(x%10==3) {
                    printf(" %d", i);
                    break;
                } else
                    x/=10;
            }
        }
        i = i+1;
    }
    printf("\n");

    return 0;
}

Measured memory_bytes: 2696
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

string A[4] = {"dreamer", "dream", "eraser", "erase" };
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    RREP(i, S.length() - 1, 0) {
        string K;
        
        if(i + 6 == S.length() && S.substr(i, 6) == "eraser") {
            rep(i, 6) S.pop_back();
        }
        if(i + 7 == S.length() && S.substr(i, 7) == "dreamer") {
            rep(i, 7) S.pop_back();
        }
        if(i + 5 == S.length() && S.substr(i, 5) == "erase") {
            //cout <<  S.substr(i, 6) << " " << S << endl;
            rep(i, 5) S.pop_back();
        }
        if(i + 5 == S.length() && S.substr(i, 5) == "dream") {
            rep(i, 5) S.pop_back();
        }
        //cout << S << endl;
    }
    //cout << S << endl;
    if(S.length()) {
        cout << "NO" << endl;
        return 0;
    }
    cout << "YES" << endl;
    

    return 0;
}


Measured memory_bytes: 512