akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std; 
 
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
 
typedef long long int ll; 
typedef long double ld; 

int main(){
	
	std::ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	string s, t;
	cin>>s>>t;
	ll ans = s.size();
	for(ll i=-1+t.size();i<s.size();++i){
		ll cnt = 0;
		for(ll j=0;j<t.size();++j){
			if(s[i-j]!=t[t.size()-1-j]){
				cnt++;
			}
		}
		ans = min(ans, cnt);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 3588
from sys import stdin
N, X = [int(x) for x in stdin.readline().rstrip().split()]

heights = [1]
putties = [1]
for _ in range(N):
    heights.append(heights[-1] * 2 + 3)
    putties.append(putties[-1] * 2 + 1)


def solve(n, x):
    if n == 0 and x == 1:
        return 1
    elif x == 1:
        return 0
    elif 1 < x <= 1+heights[n-1]:
        return solve(n-1, x-1)
    elif x == 2+heights[n-1]:
        return 1+putties[n-1]
    elif 2+heights[n-1] < x <= 2+2*heights[n-1]:
        return putties[n-1]+1+solve(n-1,x-2-heights[n-1]) 
    elif x == 3+2*heights[n-1]:
        return 2*putties[n-1]+1
print(solve(N, X))

Measured memory_bytes: 3064
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}
func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0
	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 3
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}
	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	n2 := n * n
	pp := make([]int, n2)
	for i := 0; i < n2; i++ {
		pp[i] = getNextInt(scanner) - 1
	}
	dp := makeGrid(n, n)
	vv := makeGrid(n, n)
	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			dp[i][j] = distance(i, j, n)
			vv[i][j] = 1
		}
	}

	ans := 0
	for i := 0; i < n2; i++ {
		y := pp[i] / n
		x := pp[i] % n
		ans += dp[y][x]
		dp[y][x]--
		vv[y][x] = 0
		dfs(y, x, n, dp, vv)
	}
	fmt.Fprintln(writer, ans)
}
func dfs(y, x, n int, dp, vv [][]int) {
	dy := [4]int{-1, 0, 0, 1}
	dx := [4]int{0, -1, 1, 0}
	for i := 0; i < 4; i++ {
		yy := y + dy[i]
		xx := x + dx[i]
		if yy < 0 {
			continue
		}
		if yy >= n {
			continue
		}
		if xx < 0 {
			continue
		}
		if xx >= n {
			continue
		}
		if dp[y][x]+vv[yy][xx] < dp[yy][xx] {
			dp[yy][xx] = dp[y][x] + vv[yy][xx]
			dfs(yy, xx, n, dp, vv)
		}
	}
}
func distance(y, x, n int) int {
	ans := y
	if ans > n-1-y {
		ans = n - 1 - y
	}
	if ans > x {
		ans = x
	}
	if ans > n-1-x {
		ans = n - 1 - x
	}
	return ans
}
func makeGrid(h, w int) [][]int {
	index := make([][]int, h, h)
	data := make([]int, h*w, h*w)
	for i := 0; i < h; i++ {
		index[i] = data[i*w : (i+1)*w]
	}
	return index
}


Measured memory_bytes: 113576
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

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

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        long k = sc.nextLong();


        List<Long> A = new ArrayList<>();
        List<Long> B = new ArrayList<>();

        A.add(0L);
        B.add(0L);

        long sumA_i = 0;
        for (int i = 0; i < n; i++) {
            long A_i = sc.nextLong();
            sumA_i += A_i;
            A.add(sumA_i);
        }


        long sumB_i = 0;
        for (int i = 0; i < m; i++) {
            long B_i = sc.nextLong();
            sumB_i += B_i;
            B.add(sumB_i);
        }

        int j = m,ans = 0;
        for(int i = 0; i <= n; i++){
            if(A.get(i) > k){
                break;
            }

            while (B.get(j) > k - A.get(i)){
                j--;
            }
            
            ans = Math.max(ans,i + j);
        }

        System.out.println(ans);


    }
}


Measured memory_bytes: 73856
//22
#include<iostream>
#include<string>

using namespace std;

int main(){
  int his[6]={};
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    double h;
    cin>>h;
    his[int((h-160)/5)]++;
  }
  for(int i=0;i<6;i++){
    cout<<i+1<<':'<<string(his[i],'*')<<endl;
  }
  return 0;
}

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

#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(), (a).end()
#define reset(a, v) memset((a), v, sizeof(a))

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ii> vii;

const int N = 2e5 + 5;

int n, k;
int dat[N];
int diff[N];

int main() {
	scanf("%d %d", &k, &n);
	for (int i = 0; i < n; i++) scanf("%d", &dat[i]);
	for (int i = 0; i < n-1; i++) {
		diff[i] = dat[i+1] - dat[i];
	}
	diff[n-1] = k - dat[n-1] + dat[0];
	int maxi = 0, sum = 0;
	for (int i = 0; i < n; i++) {
		maxi = max(maxi, diff[i]);
		sum += diff[i];
	}
	printf("%d\n", sum - maxi);
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define deb(x) cout<<#x<<"="<<x<<endl;
#define endl '\n'
#define M 1000000007
#define int long long
#define INF 1e18
#define max_n 1000000

using namespace std;

void solve()
{
	ll n, x, t;
	cin >> n >> x >> t;
	ll r;
	if (n % x == 0)r = n / x;
	else r = n / x + 1;
	cout << r*t << endl;
}

int32_t main()
{
	IOS
	ll T = 1;
	// cin >> T;
	for (ll i = 1; i <= T; ++i)
	{
		// cout<<"Case #"<<i<<": ";
		solve();
	}
	return 0;
}

Measured memory_bytes: 3636
n=int(input())
task=[] 
for _ in range(n):
    a,b=map(int,input().split())
    task.append((b, -a))

task.sort()

time=0
flag=True
for i in task:
    time-=i[1]
    if time>i[0]:
        flag=False
        break

if flag:
    print("Yes")
else:
    print("No")



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

typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)
#define rep_r(i,s,n)for(ll i = n;i>s;i--)
#define rep_re(i,s,n)for(ll i = n;i>=s;i--)
using namespace std;
static const ll MOD = 1e9 + 7;
static const ll INF = 1e25;
static const ll MAX_N = 100001;

int main()
{
    ll n; string s; cin >> n >> s;
    ll ans = 0;
    rep(i, 0, s.size()) {
        if (i == 0) {
            ans++;
            continue;
        }
        else if (s[i - 1] == s[i]) {
            continue;
        }
        else {
            ans++;
        }
    }
    cout << ans << endl;
}



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

int main(void) {

    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;

    int ans = 0;
    if (X > 0 && Y > 0) {
        int num = min(X, Y);
        if (A+B > 2*C) {
            ans += (2*C)*num;
        } else {
            ans += (A+B)*num;
        }
        X -= num; Y -= num;
    }

    if (X > 0) {
        if (A > 2*C) {
            ans += (2*C)*X;
        } else {
            ans += A*X;
        }
    } else if (Y > 0) {
        if (B > 2*C) {
            ans += (2*C)*Y;
        } else {
            ans += B*Y;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <iostream>
using namespace std;
int main()
{
	int n;
	scanf("%d",&n);
	int a[n];
	for(int i=0;i<n;i++)
		scanf("%d",&a[i]);
		sort(a,a+n);
		int p=0;
	for(int i=a[0];i<=a[n-1];i++)
	{
		p=p+(i-a[0])*(i-a[0]);
	}
//	printf("%d\n",p);
	for(int i=a[0];i<=a[n-1];i++)
	{
		int p1=0;
		for(int j=0;j<n;j++)
		{
			p1=p1+(i-a[j])*(i-a[j]);
		}
	//	printf("%d\n",p1);
		if(p1<p)
		p=p1;
	}
	printf("%d",p);
}

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

int main () {
    string c;
    cin >> c;
    if (c == "a" || c == "e" || c== "i" || c== "o" || c== "u") {
        cout << "vowel" << endl;
    }
    else {
        cout << "consonant" << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

#include <iostream>
#include <iomanip>
#include <sstream>
#include <stdint.h>
#include <string.h>

#include <unordered_set>

//#define _USE_MATH_DEFINES
//#include <math.h>


#include <vector>
#include <list>

#include <set>
#include <map>

#include <unordered_map>

#include <queue>

#include <string>

#include <vector>

#define sqr(x) (x) * (x)

#include <algorithm>
#include <functional>

#include <bitset>

#include <functional>

#include <chrono>

typedef unsigned int u32;
typedef int i32;

typedef unsigned long long int u64;
typedef long long int i64;

typedef uint16_t u16;
typedef int16_t i16;

typedef uint8_t u8;
typedef int8_t i8;


using namespace std;
using namespace std::chrono;

struct less_key
{
    bool operator() (pair<i64, i64> p1, pair<i64, i64> p2)
    {
        return (p1.first < p2.first || (p1.first == p2.first && p1.second < p2.second));
    }
};

struct pair_hash
{
    std::size_t operator()(const pair<i64, i64>& k) const
    {
        return static_cast<size_t>(k.first ^ k.second);
    }
};


#include <random>

const i64 mod = 1000000007ll;
const i64 inf = 10000000000000007ll;

const i64 mod2 = 998244353ll;

const double eps = 0.00000001;

i64 h[1004];


i64 t, a;

i64 f(i64 x) {
    return t - 6 * x;
}

int main() {
    i64 n;

    cin >> n;

    cin >> t >> a;

    for (i64 i = 0; i < n; i++) {
        cin >> h[i];
    }


    t *= 1000;
    a *= 1000;


    i64 b = 0;
    i64 bv = abs(a - f(h[0]));

    for (i64 i = 1; i < n; i++) {
        i64 tv = abs(a - f(h[i]));
        if (tv < bv) {
            bv = tv;
            b = i;
        }
    }

    cout << b + 1;


    return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Darshan
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n;
            n = in.nextInt();
            if (n <= 999)
                out.println("ABC");
            else
                out.println("ABD");
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();

            while (isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-') {
                sgn = -1;
                c = read();
            }

            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));

            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 21460
n, m, q = map(int, input().split())
abcd = [list(map(int, input().split())) for _ in range(q)]

def point(A):
    p = 0
    for a, b, c, d in abcd:
        if A[b-1] - A[a-1] == c: p+=d
    return p

def dfs(a):
    if len(a)==n:
        return point(a)
    res = 0
    prev_last = a[-1] if len(a) > 0 else 1
    for i in range(prev_last, m+1):
        a.append(i)
        res = max(res, dfs(a))
        a.pop()
    return res

print(dfs([]))

Measured memory_bytes: 9220
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;

int h,w,x;
char s[1000][1000];
bool visited [1000][1000];
pair<int,int> start,goal;
queue<pair<int,pair<int,int>>> q;
vector<pair<int,int>> ino;

int main(){
  int a,b,c,d;cin >>a>>b>>c>>d;
  cout << "ABC"<<a;
}


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

int main(){

    string s;
    cin >> s;

    map<int, int> wpos;
    for(int i=0; i<s.size(); i++){
        if(s.at(i) == 'W'){
            int buf = i+1;
            wpos[buf]++;
        }
    }
    long long pos = 1, cnt = 0;
    for(auto p: wpos){
        auto key = p.first;
        cnt += key - pos;
        pos++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 13004
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Deque;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.function.BiConsumer;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}

	static class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			int n = in.nextInt();
			int[] x = new int[n];
			for (int i = 0; i < n; i++) {
				x[i] = in.nextInt();
			}
			int ans = Integer.MAX_VALUE;
			for (int i = 1; i <= 100; i++) {
				int count = 0;
				for (int j = 0; j < n; j++) {
					count += (int) Math.pow(x[j] - i, 2);
				}
				ans = Math.min(ans, count);
			}
			out.println(ans);
		}
	}

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public char nextChar() {
			return next().charAt(0);
		}

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

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

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

	}
}


Measured memory_bytes: 21460
use proconio::fastout;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
 
#[fastout]
fn main() {
    input! {
        n: usize,
        m: usize,
        mut h: [usize; n],
    }
    let mut ans = vec![true; n];

    for _ in 0..m {
        input! {
            a: Usize1,
            b: Usize1,
        }
        if h[a] > h[b] {
            ans[b] = false;
        } else if h[a] < h[b] {
            ans[a] = false;
        } else {
            ans[a] = false;
            ans[b] = false;
        }
    }

    println!("{}", ans.into_iter().filter(|hi| *hi).count());
}


Measured memory_bytes: 5184
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
using namespace std;
struct Point { long double px, py; };
struct Circle { Point p; long double r; };
inline Point pol(long double r, long double d) { return Point{ cosl(d) * r, sinl(d) * r }; }
inline long double arg(const Point& a) { return atan2l(a.py, a.px); }
inline long double norm(const Point& a) { return a.px * a.px + a.py * a.py; }
inline long double abs(const Point& a) { return sqrtl(norm(a)); }
inline Point Minus(Point a, Point b) { return Point{ a.px - b.px,a.py - b.py }; }
inline Point Plus(Point a, Point b) { return Point{ a.px + b.px,a.py + b.py }; }
inline long double dst(const Point& a, const Point& b) { return abs(Minus(b, a)); }
inline vector<Point> crp(Circle c1, Circle c2) {
	double d = abs(Minus(c1.p, c2.p));
	double a = acos((c1.r * c1.r + d * d - c2.r * c2.r) / (2 * c1.r * d));
	double t = arg(Minus(c2.p, c1.p));
	return vector<Point>({ Plus(c1.p, pol(c1.r, t + a)), Plus(c1.p, pol(c1.r, t - a)) });
}
int main() {
	Circle x[100]; int n;
	while (true) {
		cin >> n; char ch; if (n == 0)break;
		for (int i = 0; i < n; i++) { cin >> x[i].p.px >> ch >> x[i].p.py; x[i].r = 1.0l; }
		int maxn = 1;
		for (int i = 0; i < n; i++) {
			for (int j = i + 1; j < n; j++) {
				if (dst(x[i].p, x[j].p) > 2.0l + 1e-10)continue;
				vector<Point> z = crp(x[i], x[j]);
				for (int k = 0; k < 2; k++) {
					int cnt = 0;
					for (int l = 0; l < n; l++) {
						if (dst(z[k], x[l].p) <= 1.0l + 1e-10) { cnt++; }
					}
					maxn = max(maxn, cnt);
				}
			}
		}
		cout << maxn << endl;
	}
	return 0;
}

Measured memory_bytes: 3488
//Volume2-0220
import java.util.*;

public class Main {

	public static void main(String[] args) {

		//declare
		final int    END  =  0;
		      double n;
			  String itgr,frac,ret;

    	//input
    	Scanner sc = new Scanner(System.in);
    	while(true){
    		n = sc.nextDouble();
    		if(n<END){break;}
    		
    		//calculate
    		ret = "";
    		itgr = Integer.toBinaryString((int)Math.floor(n));
    		n %= 1.0; frac = "";
    		for(int i=0;i<4;i++){
    			frac += (int)Math.floor(n*=2);
    			n%=1;
    		}
    		
    		//output
    		if( itgr.length() > 8 || n!=0){
    			System.out.println("NA");}
    		else {
    			while(itgr.length()<8){
    				itgr="0"+itgr;
    			}
    			ret = itgr + "." + frac;
	    		System.out.println(ret);
    		}
    	}
	}
}

Measured memory_bytes: 27736
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        int num2 = sc.nextInt();
        int sum = num - num2*2;
        if(sum<=0)
        {
            System.out.println("0");
        }
        else
        {
            System.out.println(sum);
        }
            
    }
}


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

int n;
string res = "Yes";
int main(){
  cin >> n;
  int t, x, y;
  int pt = 0, px = 0, py = 0;
  rep(i, n){
    cin >> t >> x >> y;
    int dist = abs(x - px) + abs(y - py);
    int time = t - pt;
    //cerr << dist <<" "<< time <<endl;
    if(dist > time){
      res = "No";
      break;
    }
    if(dist % 2 != time% 2){
      res = "No";
      break;
    }
    pt = t; px = x; py = y;
  }
  cout << res << endl;
  return 0;
}


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

using namespace std;
using ll = long long;
using ld = long double;

//#define int long long
//signed main(){
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int h,w;
    cin >> h >> w;
    bool mp[h*w];
    string tmp;
    for(int i = 0; i < h; i++) {
        cin >> tmp;
        for(int j = 0; j < w; j++) {
            if(tmp[j]=='#') mp[i*w+j] = false;
            else            mp[i*w+j] = true;
        }
    }

//    for(int i = 0; i < h*w; i++) {
//        cout << mp[i];
//        if(i%w==w-1) cout << "\n";
//    }

    vector<int> r(h*w,0);
    vector<int> c(h*w,0);
    for(int i = 0; i < h; i++) {
        int cnt=0;
        for(int j = 0; j < w; j++) {
            if(mp[i*w+j]) cnt++;
            else{
                for(int k = j-cnt; k < j; k++) {
                    r[i*w+k]=cnt;
                }
                cnt=0;
            }
        }
        for(int k = w-cnt; k < w; k++) {
            r[i*w+k]=cnt;
        }
    }

    for(int j = 0; j < w; j++) {
        int cnt=0;
        for(int i = 0; i < h; i++) {
            if(mp[i*w+j]) cnt++;
            else{
                for(int k = i-cnt; k < i; k++) {
                    c[k*w+j]=cnt;
                }
                cnt=0;
            }
        }
        for(int k = h-cnt; k < h; k++) {
            c[k*w+j]=cnt;
        }
    }

//    cout << "\n";
//    for(int i = 0; i < h*w; i++) {
//        cout << r[i];
//        if(i%w==w-1) cout << "\n";
//    }

//    cout << "\n";
//    for(int i = 0; i < h*w; i++) {
//        cout << c[i];
//        if(i%w==w-1) cout << "\n";
//    }

    int ans=0;
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            int idx=i*w+j;
            if(mp[idx]) ans=max(ans,r[idx]+c[idx]-1);
            else continue;
        }
    }
    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 35456
#include <bits/stdc++.h>
#define ll long long
#define lld long double
#define MOD 1000000007
#define CAP 10000000
#define inf 1000000000000000000LL
#define pii pair<ll,ll>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define endl '\n'
#define sz(v) v.size()
#define all(v)    v.begin(),v.end()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
ll power(ll x,ll y, ll md=MOD){ll res = 1;x%=md;while(y>0){if(y&1)res = (res*x)%md;x = (x*x)%md;y = y>>1;}return res%md;}

#define int ll

int ncr(int n, int r) {
	if(r>n) return 0;

	int fact[2000002];
	fact[0] = 1;
	for(int i=1;i<=2000000;i++) fact[i] = (fact[i-1]*i)%MOD;

	int ans = fact[n];
	ans *= power(fact[r],MOD-2); ans %= MOD;
	ans *= power(fact[n-r], MOD-2); ans %= MOD;
	return ans;
}

signed main() {
	fast;

	int n;
	cin>>n;

	vector<int> x(n),y(n);
	for(int i=0;i<n;i++) cin>>x[i]>>y[i];

	int arr[n];
	for(int i=0;i<n;i++) arr[i] = i;

	lld sum = 0;

	do {
		lld dist = 0; 
		for(int i=1;i<n;i++) {
			dist += sqrt(1.0*(x[arr[i]]-x[arr[i-1]])*(x[arr[i]]-x[arr[i-1]]) + 1.0*(y[arr[i]]-y[arr[i-1]])*(y[arr[i]]-y[arr[i-1]]));
		}
		sum += dist;
	} while(next_permutation(arr, arr+n));

	for(int i=2;i<=n;i++) sum /= 1.0*i;

	cout<<std::fixed<<std::setprecision(20)<<sum;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<stack>
#include<queue>
using namespace std;

#define read(x) scanf("%d",&x)
#define readl(x) scanf("%lld",&x)
#define ll long long 
#define ull unsigned long long
#define MOD 998244353 
#define inf 2147483647

int n;
int a[200005];
ll k;
int rt[200005],cnt=0,p;
int b[200005],be,lo;

int main()
{
	read(n),readl(k);
	for(int i=1;i<=n;i++) read(a[i]);
	rt[0]=1,p=1,b[1]=0;
	while(1)
	{
		if(b[a[p]]!=0)
		{
			be=b[a[p]];
			lo=cnt-be+1;
			break;
		}
		rt[++cnt]=a[p];
		b[a[p]]=cnt;
		p=a[p];
	}
	if(k<=be) printf("%d\n",rt[k]);
	else
	{
		int s=(k-be)%lo;
		printf("%d\n",rt[s+be]);
	}
	return 0;
}

Measured memory_bytes: 6052
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T, class U>bool chmax(T& a, U&& b) { return a < b ? a = b, 1 : 0; }
template<class T, class U>bool chmin(T& a, U&& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    int N, M;
    cin >> N >> M;
    vv<int> graph(N);
    rep(i, M) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }

    int s = 0;
    int t = graph[s].front();
    vector<bool> used(N);
    used[s] = used[t] = true;

    vector<int> spath = { s };
    while (1) {
        bool ok = true;
        for (int v : graph[s]) {
            if (!used[v]) {
                used[v] = true;
                spath.push_back(v);
                s = v;
                ok = false;
                break;
            }
        }

        if (ok) {
            break;
        }
    }

    vector<int> tpath = { t };
    while (1) {
        bool ok = true;
        for (int v : graph[t]) {
            if (!used[v]) {
                used[v] = true;
                tpath.push_back(v);
                t = v;
                ok = false;
                break;
            }
        }

        if (ok) {
            break;
        }
    }

    write(spath.size() + tpath.size());
    reverse(all(spath));
    for (int v : spath) cout << (v + 1) << ' ';
    rep(i, tpath.size()) {
        cout << (tpath[i] + 1) << (i == tpath.size() - 1 ? '\n' : ' ');
    }
}

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

int main(){
    int x;
    for (int i=0; i<5; i++){
        cin >> x;
        if (x == 0){
            cout << i+1 << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define loop(i,a,n) for (ll i=a;i<n;i++)
#define loopm(i,a,n) for (ll i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define Graph(n) vector < vector < ll > > (n,vector < ll >(0,0))
#define tr(container,it)\
for(auto it=container.begin();it!=container.end();it++)
#define SZ(x) ((int)(x).size())
typedef vector<long long> VI;
typedef long long ll;
typedef vector < vector < ll > > VII;
typedef pair<ll,ll> PII;
typedef double db;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin>>n;
    VI v(n,0);
    map < ll , ll > m;
    ll ans=0;
    loop(i,0,n)
    {
        cin>>v[i];
        ans+=m[i-v[i]];
        m[v[i]+i]+=1;
    }
    cout<<ans<<"\n";

}


Measured memory_bytes: 27276
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

int main()
{
  int x, y;
  cin >> x >> y;
  if (x % 2 == 0 || y % 2 == 0) cout << "Even" << endl;
  else cout << "Odd" << endl;
}

Measured memory_bytes: 256
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")

#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>

using namespace std;

typedef pair <int, int> pii;
typedef pair <long long, long long> pll;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector <vector <ll>> matrix;

#define endl "\n"
#define mt make_tuple
#define mp make_pair

template <typename T1, typename T2>
bool umax(T1 &a, const T2&b) { return a < b ? a = b, 1 : 0;}
template <typename T1, typename T2> 
bool umin(T1 &a, const T2 &b) {return a > b ? a = b, 1 : 0;}
template <typename T>
T sqr(T a) {return a * a;}

mt19937 rng(20010709);
const int INF = 1000000001;
const int N = 200005;

struct ConvexHullTrick {
    struct Line {
        ll k, b;

        Line(ll k = 0, ll b = 0) : k(k), b(b) { }

        ll get(ll x) {
            return k * x + b;
        }
    };

    ld inter(const Line &a, const Line &b) {
        return (ld)(b.b - a.b) / (a.k - b.k);
    }

    ConvexHullTrick() { }
    vector <Line> lines;
    int ptr = 0;

    void add(const Line &a) {
        if (!lines.empty() && (lines.back().k == a.k)) {
            if (a.b >= a.b)
                return;
            else
                lines.pop_back();
        }

        while ((lines.size() > 1) && (inter(lines[lines.size() - 2], a) <= inter(lines[lines.size() - 2], lines.back())))
            lines.pop_back();

        lines.push_back(a);
    }

    ll get(ll x) {
        umin(ptr, lines.size() - 1);

        while ((ptr + 1 < lines.size()) && (lines[ptr].get(x) > lines[ptr + 1].get(x)))
            ptr++;

        return lines[ptr].get(x);
    }
};

int n;
ll c, h[N];
ConvexHullTrick CHT;

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

    cin >> n >> c;

    for (int i = 0; i < n; i++)
        cin >> h[i];

    CHT.add(ConvexHullTrick::Line(-2 * h[0], sqr(h[0]) + c));
    ll dp = 0;

    for (int i = 1; i < n; i++) {
        dp = CHT.get(h[i]) + sqr(h[i]);
        CHT.add(ConvexHullTrick::Line(-2 * h[i], dp + sqr(h[i]) + c));
    }

    cout << dp << endl;

    return 0;
}

Measured memory_bytes: 8048
#include <cstdio>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <string>
#include <deque>

using namespace std;

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

#define SZ(x) ((int)x.size())
#define debug

const int N = (int)5e3+5;
int n, m, lo[N][205], hi[N][205];
ll a[N][205], d[N], sum[N][N];
deque<int> q[205];

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 2; i <= n; ++i) scanf("%lld", &d[i]), d[i] += d[i - 1];
	for (int i = 1; i <= m; ++i) q[i].push_back(0), a[0][i] = (ll)1e9+7ll;
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= m; ++j) {
			scanf("%lld", &a[i][j]);
			while (SZ(q[j]) && a[q[j].back()][j] < a[i][j]) q[j].pop_back();
			lo[i][j] = q[j].back() + 1;
			q[j].push_back(i);
		}
	}
	for (int i = 1; i <= m; ++i) q[i].clear(), q[i].push_back(n + 1), a[n + 1][i] = (ll)1e9+7ll;
	for (int i = n; i >= 1; --i) {
		for (int j = 1; j <= m; ++j) {
			while (SZ(q[j]) && a[q[j].back()][j] <= a[i][j]) q[j].pop_back();
			hi[i][j] = q[j].back() - 1;
			q[j].push_back(i);
		}
	}
	for (int j = 1; j <= m; ++j) {
		for (int i = 1; i <= n; ++i) {
			int l = lo[i][j], r = hi[i][j];
			sum[l][i] += a[i][j], sum[i + 1][r + 1] += a[i][j];
			sum[l][r + 1] -= a[i][j], sum[i + 1][i] -= a[i][j];
		}
	}
	ll res = -(ll)1e18-7ll;
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= n; ++j) {
			sum[i][j] += (sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1]);
			if (i <= j) res = max(res, sum[i][j] - d[j] + d[i]);
		}
	}
	printf("%lld", res);
	return 0;
}


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

int main(){
    int H,W,D;
    cin >> H>> W>>D;
    vector<pair<int,int>> numbers(H*W);
    vector<vector<int>> boards(H);
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            int A;
            cin >> A;
            A--;
            boards[i].push_back(A);
            numbers[A].first = i;
            numbers[A].second = j;
        }
    }
    int Q;
    cin >> Q;
    vector<int> f(H*W,0);
    for(int i=D;i<(H*W);i++){
        f[i] = f[i-D] + abs(numbers[i].first-numbers[i-D].first) + abs(numbers[i].second-numbers[i-D].second); 
        // cerr <<"i=" <<i<<"f(i)="<<f[i] << endl;
    }
    
    for(int i=0;i<Q;i++){
        int L,R;
        cin >> L >>R;
        L--;R--;
        // cerr << "fR="<<f[R] << "fL=" << f[L] << endl;
        cout << f[R]-f[L] << endl;
    }
    
    return 0;
}

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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

int main(void) {
    int n;
    cin >> n;
    vector<string> s(n);
    rep(i,n) cin >> s[i];
    map<char, ll> mp;
    char tmp[5] = {'M', 'A', 'R', 'C', 'H'};
    for(auto v : s) {
        for(auto t : tmp) {
            if(v[0]== t) {
                mp[v[0]]++;
                break;
            }
        }
    }
    ll ans = 0;
    for(int i = 0; i < 5; ++i)
    for(int j = i+1; j < 5; ++j)
    for(int k = j+1; k < 5; ++k)
        ans += mp[tmp[i]] * mp[tmp[j]] * mp[tmp[k]];

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


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

using namespace std;
int arr[200005];
int main() {
#ifndef ONLINE_JUDGE
//	freopen("input.in", "r", stdin);
//	freopen("output.out", "w", stdout);
#endif

    int n;
    scanf("%d", &n);
    for(int i=0; i<n; i++)
        scanf("%d", arr + i);
    int cnt = 0;
    int best = 0;
    for(int i=0; i<n; i++){
        if(arr[i] > arr[i-1]){
            best = max(best, cnt);
            cnt = 0;
        }else{
            cnt++;
        }
    }
    
    printf("%d\n", max(best, cnt));
    return 0;
}


Measured memory_bytes: 640
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List
import Data.Char (digitToInt, intToDigit)

main :: IO ()
main = do
  n <- getl toInt
  solve <$> replicateM n (words <$> getLine) >>= mapM_ putStrLn

solve :: [[String]] -> [String]
solve = map (toMCXI . sum . map fromMCXI)

fromMCXI :: String -> Int
fromMCXI = fst . foldl f (0, 1)
  where
    f (a, i) c
      | c == 'm' = (a + i * 1000, 1)
      | c == 'c' = (a + i * 100, 1)
      | c == 'x' = (a + i * 10, 1)
      | c == 'i' = (a + i, 1)
      | otherwise = (a, digitToInt c)

toMCXI :: Int -> String
toMCXI n = concat $ zipWith ($) (map f "mcxi") (map g [3,2,1,0])
  where
    f c i
      | i == 0 = []
      | i == 1 = [c]
      | otherwise = [intToDigit i, c]
    g i = n `div` (10 ^ i) `mod` 10

toInt :: String -> Int
toInt = read

getl :: (String -> a) -> IO a
getl f = f <$> getLine

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

int main() {
  double N, K, i; cin >> N >> K;
  cout << (int)(log10(N) / log10(K)) + 1 << endl;
  return 0;
}


Measured memory_bytes: 640
N = int(input())
ans = ['a']
moji = ['a','b','c','d','e','f','g','h','i','j']
count = 1
while count < N:
    tmp = []
    for i in ans:
        for k in range(len(set(list(i)))+1):
            tmp.append(i+moji[k])
    count += 1
    ans = tmp
ans.sort()
for i in ans:
    print(i)

Measured memory_bytes: 12976
#include <stdio.h>
#include <stdlib.h>
int cmp(const void *a,const void *b){
  return *(int *)b-*(int *)a;
}
int main(void){
  int n,i,ans,a[1000];
  while(1){
    scanf("%d",&n);
    if(!n)
      break;
    for(i=0;i<n;i++)
      scanf("%d",&a[i]);
    qsort(a,n,sizeof(int),cmp);
    ans=1000001;
    for(i=0;i<n-1;i++){
      if(ans>a[i]-a[i+1])
	ans=a[i]-a[i+1];
    }
    printf("%d\n",ans);
  }
  return 0;
}

Measured memory_bytes: 644
import java.util.Scanner;
class Main{
    public static void main(String arg[]){
        Scanner scn=new Scanner(System.in);
        int n=scn.nextInt();
        int m=scn.nextInt();
        int x=scn.nextInt();
        int y=scn.nextInt();
        int z1=-101;
        int z2=101;
        int flag=1;
        for(int i=0;i<n;i++){
            int buf =scn.nextInt();
            z1=Math.max(z1,buf);
        }
        for(int i=0;i<m;i++){
            int buf=scn.nextInt();
            z2=Math.min(z2,buf);
        }
        for(int i=x+1;i<=y;i++){
            if(z1<i&&i<=z2){
                flag=0;
                break;
            }
        }
        if(flag==0){
            System.out.println("No War");
        }else{
            System.out.println("War");
        }
    }
}

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

using namespace std;

#define int long long
signed main()
{
    int n; cin >> n;

    map<int, int> mp;
    vector<int > a(n);
    for(auto &it : a){
        cin >> it;
        mp[it]++;
    }

    int sum = 0;
    for(auto it : mp)
    {
        sum += ((it.second)*(it.second-1))/2;
    }


    for(int i = 0; i < n; i++)
    {   
        int res = sum;
        int x = mp[a[i]];
        res -= ((x*(x-1))/2);
        x--;
        res += ((x*(x-1))/2);

        cout << res << "\n";
    }
    return 0;
}

Measured memory_bytes: 11008
W = str(input())
if W.count('a') % 2 == 0:
  if W.count('b') % 2 == 0:
    if W.count('c') % 2 == 0:
      if W.count('d') % 2 == 0:
        if W.count('e') % 2 == 0:
          if W.count('f') % 2 == 0:
            if W.count('g') % 2 == 0:
              if W.count('h') % 2 == 0:
                if W.count('i') % 2 == 0:
                  if W.count('j') % 2 == 0:
                    if W.count('k') % 2 == 0:
                      if W.count('l') % 2 == 0:
                        if W.count('m') % 2 == 0:
                          if W.count('n') % 2 == 0:
                            if W.count('o') % 2 == 0:
                              if W.count('p') % 2 == 0:
                                if W.count('q') % 2 == 0:
                                  if W.count('r') % 2 == 0:
                                    if W.count('s') % 2 == 0:
                                      if W.count('t') % 2 == 0:
                                        if W.count('u') % 2 == 0:
                                          if W.count('v') % 2 == 0:
                                            if W.count('w') % 2 == 0:
                                              if W.count('x') % 2 == 0:
                                                if W.count('y') % 2 == 0:
                                                  if W.count('z') % 2 == 0:
                                                    print('Yes')
                                                    exit()
print('No')
                                      
                                     


Measured memory_bytes: 3064
n,k,q = gets.chomp.split(" ").map(&:to_i)
b = q-k

point = Array.new(n+1){0}

q.times do
  point[gets.to_i] += 1
end

n.times do |i|
  if point[i+1] > b
    puts("Yes")
  else
    puts("No")
  end
end

Measured memory_bytes: 3196
#![allow(unused_mut)]
#![allow(non_snake_case)]
#![allow(unused_imports)]
use std::collections::HashSet;
use std::collections::HashMap;
use std::collections::BTreeSet;
use std::collections::VecDeque;
use std::cmp::{max, min};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        k: usize,
        s: chars,
    }
    for i in 0..n {
        if i + 1 == k {
            print!("{}", (s[i] as u8 - 'A' as u8 + 'a' as u8) as char);
        } else {
            print!("{}", s[i]);
        }
    }
}

Measured memory_bytes: 4352
#!/usr/bin/python3

import sys
from collections import defaultdict

n = int(input())
a = tuple(map(int, input().split()))

sv = defaultdict(list)
hv = defaultdict(list)

for i, ai in enumerate(a):
    sv[ai + i + 1].append(i + 1)
    hv[(i + 1) - ai].append(i + 1)


ps = 0
for x in sv:
    ps += len(sv[x]) * len(hv[x])

print(ps)


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

typedef long long LL;

template<typename T>
void printmatrix(vector<vector<T> > ar){
    for (int i = 0; i < (int)ar.size(); i++) {
        for (int j = 0; j < (int)ar.size(); j++) {
            cout << ar[i][j];
        }
        cout << endl;
    }
}

template<typename T>
void printvector(vector<T> vec){
    for (int i = 0; i < (int)vec.size(); i++) {
        cout << vec[i] << endl;
    }
}

template<typename T>
void unique(vector<T>& vec){
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
}

template<typename T>
vector<T> cumsum(vector<T> vec){
    vector<T> newvec((T)vec.size());
    int tmp = 0;
    for (int i = 0; i < (int)vec.size(); i++) {
        tmp += vec[i];
        newvec[i] = tmp;
    }

    return newvec;
}


int main(int argc, char const* argv[])
{
    string s;
    cin >> s;
    s[3] = '8';
    cout << s << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<cassert>
#include<cassert>
#include<unordered_map>
#include<unordered_set>
#include<functional>
#include<queue>
#include<stack>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<sstream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<numeric>
#include<random>
#include<chrono>
#include<bitset>
using namespace std;

#define all(x) (x).begin(), (x).end()
#define pb push_back
#define xx first
#define yy second
#define sz(x) (int)(x).size()
#define gc getchar
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mp make_pair

#ifndef ONLINE_JUDGE
#  define LOG(x) (cerr << #x << " = " << (x) << endl)
#else
#  define LOG(x) ((void)0)
#endif

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const double PI=3.1415926535897932384626433832795;
const ll INF = 1LL<<62;
const ll MINF = -1LL<<62;

template<typename T> T getint() {
	T val=0;
	char c;
	
	bool neg=false;
	while((c=gc()) && !(c>='0' && c<='9')) {
		neg|=c=='-';
	}

	do {
		val=(val*10)+c-'0';
	} while((c=gc()) && (c>='0' && c<='9'));

	return val*(neg?-1:1);
}

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); uniform_int_distribution<int>(0, n-1)(rng)


int main() {
	IO;
	int n,m;
	cin>>n>>m;
	cout<<(n/m+(n%m>0))<<"\n";
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++i)
#define FOR(i, a, b) for(ll i=(a); i < (ll)(b); ++i)
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(){
	ll s;
	cin >> s;
	
	ll x,y,p,q;
	// x2*y3 - x3*y2 = s
	// 1e9*y3 - x3 = s
	// 1e9*(y3-1) + (1e9-x3) = s
	// 1e9*p + q = s
	// y3 = p+1
	// x3 = 1e9 - q
	p = s/(ll)1e9;
	q = s%(ll)1e9;
	if(p==(ll)1e9){
		y = p;
		x = 0;
	}else{
		y = p+1;
		x = (ll)1e9 - q;
	}
	cout << "0 0 ";
	cout << (int)1e9 << " 1 ";
	cout << x << " " << y << endl;
	
	return 0;
}

Measured memory_bytes: 3616
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.SortedSet;
import java.util.TreeSet;

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

		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			Map<String, Integer> map = new HashMap<>();
			int maxCount = 0;
			for (int i = 0; i < n; i++) {
				String si = sc.next();
				int newCount = map.getOrDefault(si, 0) + 1;
				map.put(si, newCount);
				if (maxCount < newCount) {
					maxCount = newCount;
				}
			}
			SortedSet<String> keySet = new TreeSet<>(map.keySet());
			for (String key : keySet) {
				if (map.get(key) == maxCount) {
					System.out.println(key);
				}
			}
		}
	}

}


Measured memory_bytes: 100980
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define fi first
#define se second
#define INF 1000000009
#define lINF 1000000000000000009
using ll = long long;

int main(){
  int n;
  cin>>n;
  vector<int>a(n);
  rep(i,n)cin>>a[i];
  sort(a.begin(),a.end());
  auto judge=[&](ll mid){
    ll now=a[mid];
    rep(i,n){
      if(i==mid)continue;
      if(a[i]<=now*2){
        now+=a[i];
      }
      else{
        return 0;
      }
    }
    return 1;
  };
  auto bs=[&](){
    ll l=-1,r=n;
    while(r-l>1){
      ll mid=(l+r)/2;
      if(judge(mid)){
        r=mid;
      }
      else{
        l=mid;
      }
    }
    return r;
  };
  cout<<n-bs()<<endl;
  return(0);
}


Measured memory_bytes: 640
INF = 10**9+7

N = int(input())
A = sorted( list(map(int,input().split())) )
if N%2==1:
    tmp = [ 2*j for j in range(1,N//2+1)]
    TMP = sorted([0]+tmp+tmp)
else:
    tmp = [2*j+1 for j in range(N//2)]
    TMP = sorted(tmp+tmp)
if A==TMP:
    tmp=1
    for _ in range(N//2):
         tmp *=2
         tmp %=INF
    print(tmp)
else:
    print(0)

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n;
    cin >> n;
    vs s(n);
    rep(i, n) cin >> s[i];
    VSORT(s);
    auto it = unique(all(s));
    s.erase(it, s.end());
    cout << s.size() << endl;
    return 0;
}


Measured memory_bytes: 9524