akhauriyash/Code-Regression huggingface dataset:
import sys
stdin = sys.stdin

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from collections import Counter

n = ni()
a = list(li())

even = Counter(a[::2])
odd = Counter(a[1::2])

es = [(0,0)]
for ek,ev in even.items():
    es.append((ev,ek))
    
es.sort()
    
    
os = [(0,0)]
for ok,ov in odd.items():
    os.append((ov,ok))
    
os.sort()
    

if es[-1][1] != os[-1][1]:
    print((n//2-es[-1][0]) + (n//2-os[-1][0]))
else:
    print(min((n//2-es[-1][0]) + (n//2-os[-2][0]),
              (n//2-es[-2][0]) + (n//2-os[-1][0])))

Measured memory_bytes: 20736
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations
import sys
import bisect
import string
import math
import time
from fractions import gcd
#import random


def I(): return int(input())


def MI(): return map(int, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['Yes', 'No']
MOD = 10**9+7
inf = float('inf')
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)


show_flg = False
# show_flg = True


def main():
    H, W = MI()
    graph = [None] * H
    ans = []

    for i in range(H):
        graph[i] = list(MI())

    q = []
    for i in range(H):
        range_w = range(W) if i % 2 == 0 else reversed(range(W))
        for j in range_w:
            q.append((i, j))

    for idx, (i, j) in enumerate(q):
        coin = graph[i][j]
        if coin % 2 == 1 and idx + 1 < len(q):
            ni, nj = q[idx+1]
            graph[i][j] -= 1
            graph[ni][nj] += 1
            ans.append([i+1, j+1, ni+1, nj+1])

    print(len(ans))
    for i in range(len(ans)):
        print(*ans[i])


if __name__ == '__main__':
    main()


Measured memory_bytes: 106404
n = int(input())
l = list(map(int,input().split()))
ans = 0
ansl = 0
d = {}
if len(l) == len(set(l)):
  for i in range(len(l)):
    print(0)
else:
  for s in l:
    if s not in d:
      d[s] = 1
    else:
      d[s] += 1
  for j,k in d.items():
    ans += k*(k-1)//2
  ansl = ans
  for i in range(n):
    ans = ansl
    x = d[l[i]]
    ans -= x - 1
    print(ans)

Measured memory_bytes: 26784
#include <bits/stdc++.h>
#define fastio() ios_base::sync_with_stdio(false);
using namespace std;
typedef long long ll;
typedef long double ld;

const int maxn = 55;

ll pwr[64], masks[maxn];
int n, m, x, y;
bool res[maxn][maxn];
vector<int> vs[maxn];
int d[maxn][maxn], nxt[maxn][maxn], eid[maxn][maxn];

void floyd(){
	for(int i = 0; i<n; i++) d[i][i] = 0, nxt[i][i] = i;
	for(int i = 0; i<n; i++)
		for(int j = 0; j<n; j++)
			if (i!=j && d[i][j] != 1) d[i][j] = 1e9;
	for(int k = 0; k<n; k++){
		for(int i = 0; i<n; i++){
			for(int j = 0; j<n; j++){
				if (d[i][j]>d[i][k]+d[k][j]){
					d[i][j] = d[i][k] + d[k][j];
					nxt[i][j] = nxt[i][k];
				}
			}
		}
	}
}

ll getmask(int u, int v){
	if (nxt[u][v] == -1) return 0ll;
	ll msk = 0ll;
	while(u != v){
		msk |= (1ll<<eid[u][nxt[u][v]]);
		u = nxt[u][v];
	}
	return msk;
}

void preprocess(){
	pwr[0] = 1; 
	for(ll i = 1; i<63; i++) pwr[i] = pwr[i-1]*2ll;
	memset(nxt, -1, sizeof(nxt));
	scanf("%d", &n);
	for(int i = 0; i<n; i++)
		for(int j = 0; j<n; j++) d[i][j] = 1e9;
	for(int i = 0; i<n-1; i++){
		scanf("%d %d", &x, &y);
		x--, y--;
		d[x][y] = d[y][x] = 1;
		nxt[x][y] = y;
		nxt[y][x] = x;
		eid[x][y] = eid[y][x] = i;
	}
	floyd();
	scanf("%d", &m);
	for(int i = 0; i<m; i++){
		scanf("%d %d", &x, &y);
		masks[i] = getmask(x-1, y-1); // edge mask
	}
}

int main(){
	preprocess();
	ll ans = pwr[n-1];
	for(int msk = 1; msk<(1<<m); msk++){ //all subsets of restrictions
		int sz = __builtin_popcount(msk);
		ll sgn = ((sz&1)?-1ll:1ll);
		ll emask = 0ll;
		for(int i = 0; i<m; i++) if ((msk>>i)&1) emask|= masks[i];
		ll g = __builtin_popcountll(emask);
		ans+= sgn*pwr[n-1-g];
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
import heapq,sys
input = sys.stdin.readline

n = int(input())
a = tuple(map(int,input().split()))
b = list(map(int,input().split()))
le = 10**6

tank = []
for i,e in enumerate(b):
    heapq.heappush(tank,-e*le-i)

res = 0
while len(tank):
    p = -heapq.heappop(tank)

    ele = p//le
    ind = p%le

    if ele == a[ind]:
        continue
    elif ele < a[ind]:
        print(-1)
        exit()

    if ind == n-1:
        w = b[ind-1] + b[0]
    elif ind == 0:
        w = b[-1] + b[1]
    else:
        w = b[ind-1] + b[ind+1]
    
    q = (ele-a[ind])//w
    if q == 0:
        print(-1)
        exit()
    res += q
    ele -= q*w
    b[ind] = ele
    heapq.heappush(tank,-ele*le-ind)

print(res)

Measured memory_bytes: 117368
from itertools import combinations

n, k = (int(x) for x in input().split())
XY = [tuple(int(x) for x in input().split()) for _ in range(n)]

ans = 10**20
X = []
Y = []
for x, y in XY:
    X.append(x)
    Y.append(y)

ans = 10**20
for ax, bx in combinations(X, 2):
    if ax > bx:
        ax, bx = bx, ax
    for ay, by in combinations(Y, 2):
        if ay > by:
            ay, by = by, ay
        count = 0
        for x, y in XY:
            if ax <= x <= bx and ay <= y <= by:
                count += 1
        if count >= k:
            ans = min(ans, (bx - ax) * (by - ay))

print(ans)


Measured memory_bytes: 74576
package main

import "fmt"

func main() {
	for {
		var m, n, r int
		fmt.Scanf("%d %d %d", &m, &n, &r)
		if m == -1 && n == -1 && r == -1 {
			break
		}
		if F(m,n,r) {
		}else if A(m, n, r) {
		} else if B(m, n, r) {
		} else if C(m, n, r) {
		} else if D(m, n, r) {
		}
	}
}

func A(m, n, r int) bool {
	if m+n >= 80 {
		fmt.Println("A")
		return true
	}
	return false
}

func B(m, n, r int) bool {
	if m+n < 80 && m+n >= 65 {
		fmt.Println("B")
		return true
	}
	return false
}

func C(m, n, r int) bool {
	if m+n < 65 && m+n >= 50 {
		fmt.Println("C")
		return true
	} else if m+n < 50 && m+n >= 30 && r >= 50 {
		fmt.Println("C")
		return true
	}
	return false
}

func D(m, n, r int) bool {
	if m+n < 50 && m+n >= 30 {
		fmt.Println("D")
		return true
	}
	return false
}

func F(m, n, r int) bool {
	if m == -1 || n == -1 || m+n < 30 {
		fmt.Println("F")
		return true
	}
	return false
}



Measured memory_bytes: 1116
import itertools

n=int(input())
l=list(map(int,input().split()))
a=[]
for i in itertools.combinations(l,3):
    b=list(i)
    if b[0]+b[1]>b[2] and b[1]+b[2]>b[0] and b[0]+b[2]>b[1] and len(list(set(b)))==len(b):
        a.append(i)
print(len(a))

Measured memory_bytes: 20396
N = int(input())
DS = input().split()
D = {}
for i in range(N):
    if DS[i] not in D:
        D[DS[i]] = 0
    D[DS[i]] += 1

M = int(input())
T = input().split()
flg = True
for i in range(M):
    if T[i] in D:
        D[T[i]] -= 1
        if D[T[i]] < 0:
            print('NO')
            flg = False
            break
    else:
        print('NO')
        flg = False
        break
if flg:
    print('YES')



Measured memory_bytes: 47968
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iterator>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>

using namespace std;

#define dump(n) cerr<<"# "<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

void turn(vvi& a)
{
	int n=a.size();
	vvi b=a;
	rep(i,n) rep(j,n)
		a[i][j]=b[n-1-j][i];
}

int main()
{
	for(int n,m;cin>>n>>m,n|m;){
		vvi grid(n,vi(n));
		rep(i,n) rep(j,n) cin>>grid[i][j];
		vvi pat(m,vi(m));
		rep(i,m) rep(j,m) cin>>pat[i][j];
		
		pii res(999,999);
		rep(r,4){
			rep(i,n-m+1) rep(j,n-m+1){
				bool ok=true;
				rep(k,m) rep(l,m)
					if(pat[k][l]!=-1 && pat[k][l]!=grid[i+k][j+l]){
						ok=false;
						break;
					}
				if(!ok)
					continue;
				rep(k,m) rep(l,m)
					if(pat[k][l]!=-1)
						res=min(res,mp(i+k,j+l));
			}
			turn(pat);
		}
		if(res==mp(999,999))
			cout<<"NA"<<endl;
		else
			cout<<res.second+1<<" "<<res.first+1<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 972
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    sc.close();
    double a = 0;
    int n1 = n;
    int ki = k;
    double kd = (double) k;
    double rate = 1;
    for (int i =0;i<k;i++){
      if (n1 == 0){
        break; 
      }else if (n1 >= ki){
        a += ((double)n1-(double)ki+1.0)*rate;
        n1 = ki-1;
      }
      kd = kd/2;
      ki = (int)Math.ceil(kd);
      rate = rate/2;
    }
    System.out.println(a/n);
  }
}

Measured memory_bytes: 21972
n = int(input())
a_list = list(map(int, input().split()))
x = min(a_list)
old_cost = sum([int((x - a) ** 2) for a in a_list])

if old_cost == 0:
    print("0")

else:
    while True:
        new_cost = sum([(x + 1 - a) ** 2 for a in a_list])
        if old_cost <= new_cost:
            break
        else:
            old_cost = new_cost
            x += 1
            
    print(old_cost)

Measured memory_bytes: 3060
#include <algorithm>
#include <functional>
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> as(N);
  for(int i = 0; i < N; ++i) {
    cin >> as[i];
  }
  sort(as.begin(), as.end(), greater<int>());
  int ans = 0;
  for(int i = 0; i < as.size(); ++i) {
    if(i % 2 == 0) {
      ans += as[i];
    } else {
      ans -= as[i];
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
string s;

int main()
{

    double d;
    cin >> d;
    printf("%.18f\n", max(sqrt(2) * d, floor(d) + 1));
    return 0;
}


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

int main() {
  vector<char> S(3),T(3);
  int ans = 0;
  for (int i = 0; i < 3; i++) {
    cin >> S.at(i);
  }
  for (int i = 0; i < 3; i++) {
    cin >> T.at(i);
  }
  for (int i = 0; i < 3; i++) {
    if (S.at(i) == T.at(i)) {
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

		Scanner sc = new Scanner (System.in);
		int a= sc.nextInt();
		int b= sc.nextInt();
		if (a ==b) System.out.println("a == b");
		else {
			if (a < b) System.out.println("a < b");
			else System.out.println("a > b");
		}
	}

}


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

int main(){
    cin >> n;
    int a[n]; for(int i=0; i<n; i++) cin >> a[i];
    int x = 0; for(int i=0; i<n; i++) x^=a[i];
    for(int i=0; i<n; i++) cout << (x^a[i]) << " ";
}


Measured memory_bytes: 4336
#include <set>
#include <map>
#include <vector>
#include <cmath>
#include <iostream>
#include <algorithm>

using namespace std;

void factorize(int n, set<int>& factors){
	int s = floor(sqrt(n));
	int i = 2;
	while(i <= s){
		if(n % i == 0){
			factors.insert(i);
			n /= i;
			s = floor(sqrt(n));
		}else{
			i ++;
		}
	}
	if(n > 1){
		factors.insert(n);
	}
}

int main(void){
	int N;
	cin >> N;
	vector<int> A_list(N);
	for(int i = 0; i < N; i ++){
		cin >> A_list[i];
	}
	
	int m = *max_element(A_list.begin(), A_list.end());
	
	vector<bool> prime_flag(m + 1, true);
	prime_flag[1] = false;
	map<int, int> prime_table;
	
	for(int i = 2; i <= m; i ++){
		if(prime_flag[i]){
			prime_table[i] = prime_table.size();
			for(int j = i * 2; j <= m; j += i){
				prime_flag[j] = false;
			}
		}
	}
	
//	#print(prime_table)
	vector<int> table(prime_table.size() + 1, 0);
	
	for(auto A: A_list){
		set<int> factors;
		factorize(A, factors);
		for(auto f: factors){
			table[prime_table[f]] += 1;
		}
	}
	
	int c = *max_element(table.begin(), table.end());
	
	if(m == 1 || c == 1){
		cout << "pairwise coprime" << endl;
	}else if(c == N){
		cout << "not coprime" << endl;
	}else{
		cout << "setwise coprime" << endl;
	}
	
	
	return 0;
}



Measured memory_bytes: 11080
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

macro_rules! read_value {
    ($next:expr, [graph1; $len:expr]) => {{
        let mut g = vec![vec![]; $len];
        let ab = read_value!($next, [(usize1, usize1)]);
        for (a, b) in ab {
            g[a].push(b);
            g[b].push(a);
        }
        g
    }};
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, usize1) => (read_value!($next, usize) - 1);
    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        read_value!($next, [$t; len])
    }};
    ($next:expr, $t:ty) => ($next().parse::<$t>().expect("Parse error"));
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (let _ = write!(out,$($format)*););
    }
    input!(x: [i64; 5]);
    puts!("{}\n", x.into_iter().position(|x| x == 0).unwrap() + 1);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


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

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] str_nums = br.readLine().split(" ");
        int[] nums = new int[3];
        nums[0] = Integer.parseInt(str_nums[0]);
        nums[1] = Integer.parseInt(str_nums[1]);
        nums[2] = Integer.parseInt(str_nums[2]);
        
        for (int i = nums[0]; i <= nums[1]; i++) {
            if (i < nums[0] + nums[2] || i > nums[1] - nums[2]) System.out.println(i);
        }
    }
}


Measured memory_bytes: 22612
#include <cstdio>
#include <iostream>
#include <string>

using namespace std;

int x, y, w, h, s, t, a[101][101]={0};

int func(int i, int j);

int main()
{
	int n;
	while(1){
		cin >> n;
		if(n == 0) break;
		cin >> w >> h;
		for(int i = 1; i <= w; i++){
			for(int j = 1; j <= h; j++){
				a[i][j] = 0;
			}
		}
		for(int i = 0; i < n; i++){
			cin >> x >> y;
			a[x][y] = 1;
		}
		int max = -1, b;
		cin >> s >> t;
		for(int i = 1; i+s-1 <= w; i++){
			for(int j = 1; j+t-1 <= h; j++){
				b = func(i, j);
				if(b > max) max = b;
			}
		}
		cout << max << endl;
	}
	return 0;
}

int func(int i, int j)
{
	int cnt=0;
	for(int k = i; k < i+s; k++){
		for(int l = j; l < t+j; l++){
			if(a[k][l] == 1){
				cnt++;
			}
		}
	}
	return cnt;
}

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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define IMP cout << "IMPOSSIBLE" << endl
#define Imp cout << "Impossible" << endl
#define imp cout << "impossible" << endl
#define M1 cout << "-1" << endl
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

template <typename T>
ostream &operator<<(ostream &os, vector<T> &v)
{
    os << "{";
    rep(i, v.size()) os << v[i] << (i == (int)v.size() - 1 ? "" : ", ");
    os << "}";
    return os;
}
template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }
struct in
{
    const size_t n = 0;
    in() = default;
    in(size_t n) : n(n){};
    template <typename T>
    operator T()
    {
        T ret;
        cin >> ret;
        return ret;
    }
    template <typename T>
    operator vector<T>()
    {
        assert(n != 0);
        vector<T> ret(n);
        for (auto &x : ret)
            cin >> x;
        return ret;
    }
};

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using vpint = vector<pint>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main()
{
    int h = in(), n = in();
    vint a(n), b(n);
    rep(i, n)
    {
        cin >> a[i] >> b[i];
    }

    vint dp(h + 10005, INF);
    dp[0] = 0;

    rep(i, n)
    {
        rep(j, h)
        {
            dp[j + a[i]] = min(dp[j + a[i]], dp[j] + b[i]);
        }
    }

    int ans = INF;
    REP(i, h, h + 10002)
    {
        ans = min(ans, dp[i]);
    }
    cout << ans << endl;
}

signed main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

#define Mod 1000003

typedef struct List {
	struct List *next;
	int x, y, count;
} list;

int main()
{
	int i, H, W, N, a[100001], b[100001];
	scanf("%d %d %d", &H, &W, &N);
	for (i = 1; i <= N; i++) scanf("%d %d", &(a[i]), &(b[i]));
	
	int h, j, k, m;
	list *hash[Mod] = {}, d[900001], *p;
	for (i = 1, m = 0; i <= N; i++) {
		for (j = -1; j <= 1; j++) {
			if (a[i] + j <= 1 || a[i] + j >= H) continue;
			for (k = -1; k <= 1; k++) {
				if (b[i] + k <= 1 || b[i] + k >= W) continue;
				h = (int)(((long long)(a[i] + j) * 10007 + (long long)(b[i] + k) * 30011) % Mod);
				for (p = hash[h]; p != NULL; p = p->next) if (p->y == a[i] + j && p->x == b[i] + k) break;
				if (p != NULL) p->count++;
				else {
					d[m].y = a[i] + j;
					d[m].x = b[i] + k;
					d[m].count = 1;
					d[m].next = hash[h];
					hash[h] = &(d[m++]);
				}
			}
		}
	}
	
	long long ans[10] = {(long long)(H - 2) * (W - 2)};
	for (i = 0; i < Mod; i++) {
		for (p = hash[i]; p != NULL; p = p->next) {
			ans[0]--;
			ans[p->count]++;
		}
	}
	
	for (i = 0; i < 10; i++) printf("%lld\n", ans[i]);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 31396
#include <bits/stdc++.h>
#define fi first
#define se second
#define ll long long
using namespace std;

const int MX=1005;
const double eps=1e-9;
using Point=pair<double,double>;
double r[MX],res[MX];
Point b[MX];
vector<pair<int,double>> adj[MX];
priority_queue<pair<double,int>,vector<pair<double,int>>,greater<pair<double,int>>> Q;
bool vst[MX];

double dist(const Point& A,const Point& B){
	return hypot(B.se-A.se,B.fi-A.fi);
}

int main() {
	#ifdef kvutxdy
	freopen("C:/Users/khanh/OneDrive/RoadtoPurple/Code/Codeforces/input.in", "r", stdin);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	double xs,ys,xt,yt;
	cin>>xs>>ys>>xt>>yt;
	int n;
	cin>>n;
	b[0]=Point(xs,ys);
	b[n+1]=Point(xt,yt);
	for(int i=1;i<=n;++i) cin>>b[i].fi>>b[i].se>>r[i];
	for(int i=0;i<=n;++i) for(int j=i+1;j<=n+1;++j){
		double d=dist(b[i],b[j]);
		if(i!=0) d-=r[i];
		if(j!=n+1) d-=r[j];
		d=max(d,0.0);
		adj[i].push_back({j,d});
		adj[j].push_back({i,d});
	}
	for(int i=1;i<=n+1;++i) res[i]=1e18;
	res[0]=0.0;
	Q.push({res[0],0});
	while(!Q.empty()){
		double d=Q.top().fi;
		int u=Q.top().se;
		Q.pop();
		if(d-res[u]>eps) continue;
		vst[u]=true;
		for(auto v:adj[u]) if(!vst[v.fi]&&res[v.fi]-d-v.se>eps){
			res[v.fi]=d+v.se;
			Q.push({res[v.fi],v.fi});
		}
	}
	cout<<fixed<<setprecision(11)<<res[n+1];
}

Measured memory_bytes: 22292
#include <stdio.h>
int main()
{
  
  int d1[6],d2[6],i,j,blank;
  
  for(i = 0; i < 6; i++)
  {
  
    scanf("%d",&d1[i]);
      
  }
    
  for(i = 0; i < 6; i++)
  {
      
    scanf("%d",&d2[i]);
      
  }
  
  for(i = 0; d1[1] != d2[1] && i < 3; i++)
  {
      
    //3S
    blank=d2[0];
    d2[0]=d2[4];
    d2[4]=d2[5];
    d2[5]=d2[1];
    d2[1]=blank;
      
  }
    
  if(d1[1] != d2[1])
  {
      
    //1E
    blank=d2[0];
    d2[0]=d2[3];
    d2[3]=d2[5];
    d2[5]=d2[2];
    d2[2]=blank;
  
    for(i = 0; d1[1] != d2[1] && i < 3; i++)
    {
  
      //3S
      blank=d2[0];
      d2[0]=d2[4];
      d2[4]=d2[5];
      d2[5]=d2[1];
      d2[1]=blank;
  
    }
  
  }
  
  if(d1[1] != d2[1])
  {
  
    printf("No\n");
  
    return 0;
  
  }
    
  for(i = 0; d1[0] != d2[0]; i++)
  {
      
    //3E
    blank=d2[0];
    d2[0]=d2[3];
    d2[3]=d2[5];
    d2[5]=d2[2];
    d2[2]=blank;
  
  }
  
  if(d1[0] != d2[0])
  {
      
    printf("No\n");
      
    return 0;
      
  }
  
  if(d1[2] == d2[2] && d1[3] == d2[3] && d1[4] == d2[4] && d1[5] == d2[5])
  {
  
    printf("Yes\n");
  
  } 
  else 
  {
  
    printf("No\n");
  
  }
  
  return 0;
  
}


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

using namespace std;

int main(void){
  int N, T, A;
  cin >> N >> T >> A;
  double minimum = 11451481083.0;
  int ans;
  for(int i = 0; i < N; i++){
    int H;
    cin >> H;
    if(abs(T - H * 0.006 - A) < minimum){
      ans = i + 1;
      minimum = abs(T - H * 0.006 - A);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#define llint long long

using namespace std;

int n;
llint a[100005];
llint dp[100005][2];

int main(void)
{
	cin >> n;
	for(int i = 1; i<=n; i++) cin >> a[i];
	
	for(int i = 0; i <= n; i++){
		for(int j = 0; j < 2; j++){
			dp[i][j] = -1e18;
		}
	}
	dp[0][0] = 0;
	
	for(int i = 0; i < n; i++){
		for(int j = 0; j < 2; j++){
			for(int k = 0; k < 2; k++){
				if(i == n-1 && k==1) continue;
				llint x = a[i+1];
				if((j+k)%2) x *= -1;
				dp[i+1][k] = max(dp[i+1][k], dp[i][j] + x);
			}
		}
	}
	
	/*	for(int i = 0; i <= n; i++){
		for(int j = 0; j < 2; j++){
			cout << dp[i][j] << " ";
		}
			cout << endl;
		}*/
	
	cout << max(dp[n][0], dp[n][1]) << endl;
	
	return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <typeinfo>
#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()
{
    ll n, k, d, tmp, res = 0;
    cin >> n >> k;
    vector<bool> a(n, false);
    rep(i, k)
    {
        cin >> d;
        rep(j, d)
        {
            cin >> tmp;
            a[tmp - 1] = true;
        }
    }
    rep(i, n)
    {
        if (!a[i])
            res++;
    }

    cout << res << endl;
}

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

ll max(ll a, ll b){
    return (a>b)?a:b;
}

const ll INF = 1000000000000000;

//集合を表すデータ構造、根は大きさを負で持ち、子は根を正で持つ
//[0]に全体の集合の数を入れる
//swapを使用するため<utility>をインクルードする
struct UnionFind{
    vector<int>data;
    UnionFind(int size) :   data(size+1, -1){
        data[0] = size;
    }

    //集合のmerge
    //すでに同じならfalse
    bool merge(int x, int y){
        x = root(x);    y = root(y);
        if(x == y)  return false;
        //要素数の少ない方を多い方に繋げる
        if(data[y] < data[x])   swap(x, y);
        data[x] += data[y];
        data[y] = x;
        data[0]--;
        return true;
    }

    //どの集合に属しているか
    int root(int x){
        //根に繋ぎ直す
        return (data[x] < 0) ? x : (data[x] = root(data[x]));
    }

    //ある要素が属する集合の大きさ
    int size(int x){
        return -data[root(x)];
    }

    //集合の数
    int set(){
        return data[0];
    }
};

int main(){
    int n;  cin >> n;
    ll k;   cin >> k;
    UnionFind uf(n);
    vector<int>p(n+1);    
    vector<int>g(n+1);
    rep(i, n){
        cin >> p[i+1];
        uf.merge(i+1, p[i+1]);
        g[i+1] = p[i+1];
    }
    vector<ll>c(n+1);     
    rep(i, n)   cin >> c[i+1];
    vector<vector<ll>>score(n+1, vector<ll>(n, -INF));
    ll ans = -INF;
    for(int v = 1; v <= n; v++){    //頂点v
        int now = v;
        ll tmp = 0;
        rep(i, uf.size(v)){ //i回移動
            tmp += c[now];
            score[uf.root(v)][i] = max(score[uf.root(v)][i], tmp);
            now = g[now];
        }
        tmp = 0;
        rep(i, uf.size(v)){
            if(i+1 > k) break;
            tmp = score[uf.root(v)][i];
            if(score[uf.root(v)][uf.size(uf.root(v))-1] > 0){
                ll e = (k-(i+1))/uf.size(v);
                tmp += score[uf.root(v)][uf.size(uf.root(v))-1]*e;
            }
            ans = max(ans, tmp);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 198888
/// In The Name Of God

#include <bits/stdc++.h>

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()

#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)

#define Kazakhstan ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);

#define nl '\n'
#define ioi exit(0);

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

const int N = (int)5e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;

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

using namespace std;

int n;
int a[N];
ll dp[N];
int main() {
	#ifdef wws
		freopen ("in.txt", "r", stdin);
	#endif
	Kazakhstan
	cin >> n;
	rep(i, 1, n) {
		cin >> a[i];
	}
	dp[1] = 1000;
	rep(i, 1, n) {
		dp[i] = max(dp[i], dp[i - 1]);
		rep(j, i + 1, n) {
			dp[j] = max(dp[j], (dp[i] / a[i]) * a[j] + dp[i] %  a[i]);
		}
	}
	cout << dp[n];
	ioi
}


Measured memory_bytes: 3644
if isfile("mystdin.txt");mystdin=open("mystdin.txt","r");redirect_stdin(mystdin);end
pI(x)=parse(Int,x)
pM(x::Array{SubString{String},1})=map(pI,x)
function main()
  s=chomp(readline())
  println(join(unique(s),"")==s ? "yes" : "no")
end
main()
if isdefined(Base, :mystdin);close(mystdin);end

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

int num[50]; 
long long f(long long n){
	if(n % 4 == 1)
	return 1;
	else if(n % 4 == 2)
	return n+1;
	else if(n % 4 == 3)
	return 0;
	else if(n % 4 == 0)
	return n;
} 
int main(){
    long long A, B;
	long long n = 1, sum = 0;
    int Max = 0;
    cin >> A >> B;
    long long tmp1 = f(A-1);
    long long tmp2 = f(B);
	if(A == B)
	cout << A;
	else{
		int i = 0;
		while(tmp1 != 0){	
			i++;
			if(tmp1 % 2 == 1)
			num[i]++;
			tmp1 /= 2;
		}
		Max = max(Max, i);
		i = 0;
		while(tmp2 != 0){
			i++;
			if(tmp2 % 2 == 1)
			num[i]++;
			tmp2 /= 2;
		}
		Max = max(Max, i);
		for(i = 1; i <= Max; i++){
			if(num[i] == 1)
			sum += n;
			n *= 2;
		}
		cout << sum;
	}
return 0;
}


Measured memory_bytes: 256
N = int(input())
S = input()
tmpMin = len(S.replace('W',''))
tmpIdx = -1
tmp = tmpMin
for i in range(N):
    if S[i] == 'E':
        tmp -= 1
    else:
        tmp += 1
    if tmp < tmpMin:
        tmpMin = tmp
        tmpIdx = i

print(tmpMin)

Measured memory_bytes: 3668
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue> //priority_queue
#include <map>
#include <set> //multiset set<int,greater<int>>大到小
#include <vector>// ::iterator it;
#include <stack>
#include <cmath> // auto &Name : STLName  Name.
#include <utility>
#include <sstream>
#include <string>
#define mod 1000000007
#define mod9 998244353
typedef unsigned long long ull;
typedef long long ll;
typedef double db;
typedef long double ld;
const db eps=1e-10;
const int INF = 0x3f3f3f3f;
const ll inf=0x3f3f3f3f3f3f3f3f;
const int N=1e5+5;
using namespace std;

int t,n,k;
db maxn=0,sum=0,minn,m;
db a[N]={0};
int main(){
    scanf("%d%lf",&n,&m);
    for(int i=1;i<=n;i++){
        scanf("%lf",&a[i]);
        sum+=a[i];
    }
    sort(a+1,a+n+1);
    k=(int)m;
    for(int i=n;k;k--,i--){
        if(a[i]<sum/m/4) break;
    }
    if(k==0){
        puts("Yes");
    }else{
        puts("No");
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*; 
class Main 
{
public static void main(String args[]) 
{
Scanner sc = new Scanner(System.in); 
int n = sc.nextInt(); 
if(n%10==2 || n%10==4 || n%10==5 || n%10==7 || n%10==9)   
{
System.out.println("hon");
} 
else if(n%10==0 ||n%10==1 ||n%10==6 ||n%10==8) 
{
System.out.print("pon");
}
else 
{
System.out.println("bon");
}  
}
}  

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

#if DEBUG && !ONLINE_JUDGE
  #include "header.h"
#else
  #define debug(args...)
#endif

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long lli;
typedef long double ld;

#define pb push_back
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x).size()
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b) for(auto i=(a);i<b;i++)

#define INF (int)1e9
#define EPS 1e-9
#define MOD 1000000007
void preprocess(void) {
  return;
}
bitset<4000001> p;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.precision(20);
  preprocess();
  int n; cin>>n;
  vi a(n);
  rep(i,0,n) cin>>a[i];
  int sum = 0;
  rep(i,0,n) sum += a[i];
  sum = (sum + 1)/2;
  debug(sum);
  p.set(a[0]);
  p.set(0);
  rep(i,1,n) {
    p = p | (p<<(a[i]));
  }
  int ans = 0;
  rep(i,sum,4000001) {
    if(p[i] == 1) {
      //debug(i);
      ans = i;
      break;
    }
  }
  debug(ans);
  cout<<ans<<endl;

}



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

struct UnionFind {
	vector<int> par;

	UnionFind(int n) : par(n, -1) { }
	void init(int n) { par.assign(n, -1); }

	int root(int x) {
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y) {
		return root(x) == root(y);
	}

	bool merge(int x, int y) {
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y); // merge technique
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x) {
		return -par[root(x)];
	}
};

int main() {
	int N, M;
	cin >> N >> M;
	vector<int>P(N);
	vector<int>X(M);
	vector<int>Y(M);
	for (int n = 0; n < N; ++n) {
		cin >> P[n];
		--P[n];
	}
	for (int n = 0; n < M; ++n) {
		cin >> X[n] >> Y[n];
		--X[n];
		--Y[n];
	}
	UnionFind uf(N);
	for (int n = 0; n < M; ++n) {
		uf.merge(X[n], Y[n]);
	}
	int ans = 0;
	for (int n = 0; n < N; ++n) {
		if (uf.root(P[n]) == uf.root(n)) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4792
#include <stdio.h>
int main(){
	int array[100]={};
	int i,n;

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

	for(i--;i>0;i--)
	printf("%d ",array[i]);
	printf("%d\n",array[0]);
}

Measured memory_bytes: 1764
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ll_s long
#define mod 1000000007
#define forn(i,start,lim) for(ll i=start;i<lim;i++)
#define forn_d(i,start,lim) for(ll i=start;i>=lim;i--)
#define f first
#define s second
#define pb push_back
#define pf push_front
#define mp make_pair
#define debug1(a) cout<<"------\n"<<#a<<" = "<<a<<endl<<"------"<<endl
#define debug2(a,b) cout<<"--------------\n"<<#a<<" = "<<a<<" ; "<<#b<<" = "<<b<<endl<<"--------------"<<endl
#define debug3(a,b,c) cout<<"----------------------\n"<<#a<<" = "<<a<<" ; "<<#b<<" = "<<b<<" ; "<<#c<<" = "<<c<<endl<<"----------------------"<<endl
#define sz(a) (ll)(a.size())
#define debug4(a) cout<<"chu "<<a<<endl
#define endl "\n"

int main()
{
  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  ll a,b,c;
  cin>>a>>b>>c;
  ll ans=c-(a-b);
  if(ans<0) ans=0;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
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();
        int[] a = new int[n];
        int sum = 0;
        int counter = 0;
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
            sum += a[i];
        }
        for (int i = 0; i < n; i++) {
            if (a[i] >= (double)sum / (4 * m)) {
                counter++;
            }
        }
        if (counter >= m) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
        sc.close();
    }
}

Measured memory_bytes: 21844
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = Integer.parseInt(sc.next());
        int B = Integer.parseInt(sc.next());
        int C = Integer.parseInt(sc.next());
        int D = Integer.parseInt(sc.next());
        int time = 0;

        if (A <= C) {
            if (B <= C) {
                time = 0;
            } else if (C < B && B <= D) {
                time = B - C;
            } else if (D < B) {
                time = D - C;
            }
        } else {
            if (D <= A) {
                time = 0;
            } else if (A < D && D <= B) {
                time = D - A;
            } else if (B < D) {
                time = B - A;
            }
        }

        PrintWriter out = new PrintWriter(System.out);
        out.println(time);

        sc.close();
        out.flush();
    }
}

Measured memory_bytes: 35344
#include<iostream>
#include<cstring>
using namespace std;
int cnt[25];
int main()
{
    int w,d;
    while(cin>>w>>d)
    {
        if(w==0&&d==0)
            break;
            memset(cnt,0,sizeof(cnt));
        int ans=0;
        int i;
        int x;
        for(i=1;i<=w;i++)
        {
            cin>>x;
            cnt[x]++;
            ans+=x;
        }
        int y;
        for(i=1;i<=d;i++)
        {
            cin>>y;
            if(cnt[y]!=0)
            cnt[y]--;
            else
                ans+=y;
        }
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include <cstdio>

#define MAXN 1000000

#define MOD 1000000007

int fact[MAXN + 1], invFact[MAXN + 1];

inline int lgput(int a, int n) {
    int r = 1;
    while (n) {
        if (n % 2)
            r = 1LL * r * a % MOD;
        n /= 2;
        a = 1LL * a * a % MOD;
    }
    return r;
}

int main() {
    int n;
    scanf("%d", &n);

    fact[0] = 1;
    for (int i = 1; i <= n; i++)
        fact[i] = 1LL * fact[i - 1] * i % MOD;
    invFact[n] = lgput(fact[n], MOD - 2);
    for (int i = n - 1; i >= 0; i--)
        invFact[i] = 1LL * invFact[i + 1] * (i + 1) % MOD;

    int k = (n - 1) / 2, last = 0, ans = 0;
    while (k < n - 1) {
        k++;
        int acum = 1LL * fact[k - 1] * fact[k] % MOD * invFact[2 * k - n] % MOD;
        ans = (ans + 1LL * (acum - last + MOD) * k) % MOD;
        last = acum;
    }

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

    return 0;
}


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

using namespace std;

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


Measured memory_bytes: 3636
def main():
    H, W = map(int, input().split())
    if H % 3 == 0 or W % 3 == 0: return 0
    min_d = min(H, W)
    if H % 3 != 0:
        for h in [H//3, H//3+1]:
            v1 = W*h
            v2 = (H-h)*(W//2)
            v3 = (H-h)*(W-W//2)
            min_d = min(min_d, max(v1,v2,v3)-min(v1,v2,v3))
    if W % 3 != 0:
        for w in [W//3, W//3+1]:
            v1 = H*w
            v2 = (W-w)*(H//2)
            v3 = (W-w)*(H-H//2)
            min_d = min(min_d, max(v1,v2,v3)-min(v1,v2,v3))

    return min_d

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

Measured memory_bytes: 3064
n = int(input())
a = [input()]
b = 1
for i in range(n-1):
  w = input()
  if w[0] == a[i][-1] and w not in a:
    a.append(w)
    continue
  else:
    b = 0
    break
print("Yes") if b == 1 else print("No")

Measured memory_bytes: 3060
#include<iostream>
#include<string.h>
int main(){for(int m,n,o,c,d,e,i;!(std::cin>>n).eof();){if(n<3)e=n>1;else{bool*v=new bool[c=(n&1?n:--n)/2+1];memset(v,1,c);for(i=m=e=1;i<c;i++){for(m=i;m<c&&!v[m];)m++;if(m==c)break;e++;for(d=o=m*2+1;d<n+1;d+=o*2)v[d/2]=0;if(n<o*o)break;}for(i=1;i<c;)e+=v[i++];delete[]v;}printf("%d\n",e);}}

Measured memory_bytes: 1400
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 200005
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

int n,k,c,dp[maxn],p[maxn];
char s[maxn];
vector <int> cnt[maxn];

int main()
{
	n=read(); k=read(); c=read(); scanf("%s",s+1);
	for(int i=n;i>=1;i--)
	{
		if(s[i]=='o') dp[i]=dp[min(i+c+1,n+1)]+1;
		else dp[i]=dp[i+1];
	}
	if(dp[1]>k) return 0; p[k]=0;
	for(int i=1;i<=n;i++)
	{
		if(s[i]=='x') continue;
		if(i>=p[dp[i]])
		{
			if(!p[dp[i]-1]) p[dp[i]-1]=i+c+1;
			cnt[dp[i]].pb(i);
		}
	}
	per(i,n,1) if(cnt[i].size()==1) printf("%d\n",cnt[i][0]);
	return 0;
}

Measured memory_bytes: 14208
/************* Al-Azhar ICPC Community ***********/
#include <bits/stdc++.h>

using namespace std;

string s;

bool isPalindorma(int l, int r) {
    string tmp = s.substr(0, r);
    string tmpre = tmp;
    reverse(tmp.begin(), tmp.end());
    return tmp == tmpre;


}

int main() {
cin>>s;
int n=s.length();
if(isPalindorma(0,n)&&isPalindorma(0,((n-1)/2))&&isPalindorma((n+3)/2,n))cout<<"Yes";
else cout<<"No";
}




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

int main(){
	int n;
	cin >> n;
	vector<ll>a(n);
	for (int i = 0;i < n;i++) {
		cin >> a[i];
	}

	vector<ll>s(n + 1);
	s[0] = 0;
	for (int i = 0;i < n;i++) {
		s[i + 1] = s[i] + a[i];
	}
	sort(s.begin(), s.end());

	ll ans = 0;
	for (int i = 0;i <= n;i++) {
		ll count = 1;
		while (i + 1 <= n&&s[i] == s[i + 1]) {
			count++;
			i++;
		}
		if (count > 1) {
			ans += count * (count - 1) / 2;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    int n, m, a, b;
    cin >> n >> m;
    vector<int> arr(n, 0);
    for(auto& val: arr)
        cin >> val;
    unordered_map<int, vector<int>> e;
    for(int i = 0; i < m; i++) {
        cin >> a >> b;
        e[a-1].push_back(b-1);
        e[b-1].push_back(a-1);
    }
    int ans = 0;
    for(int i = 0; i < n; i++) {
        if (e[i].size() == 0) {
            ans += 1;
            // cout << "good " << i << endl;
        } else {
            int cnt = 0;
            for(int neibor: e[i])
                if (arr[neibor] >= arr[i]) {
                    cnt += 1;
                }
            if (cnt == 0) {
                ans += 1;
                // cout << "good " << i << endl;
            }
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 11992
#include <iostream>
#include <cstdio>
#include <cmath>
#include <complex>
using namespace std;

#define EPS			(1e-10)
#define X(a)		(a).real()
#define Y(a)		(a).imag()
#define UNIT(a)		( (a)/abs(a) )
#define NORM(a)		( (a)*P(0,1) )


typedef complex<double> P;

double dot(P a, P b)
{
	return ( X(a)*X(b) + Y(a)*Y(b) );
}

double cross(P a, P b)
{
	return ( X(a)*Y(b) - Y(a)*X(b) );
}

double distPL(P p, P a, P b)
{
	return ( abs(cross(b-a, p-a))/abs(b-a) );
}

P symPL(P p, P a, P b)
{
	P v =UNIT(NORM(b-a));
	v *= ( dot(v,p-a)>0 ?  -1.0 : 1.0 );

	return p+2.0*v*distPL(p,a,b);
}

int main()
{
	P a,b,p,s; char c;
	while(cin >> X(a))
	{
		cin >> c >> Y(a);
		cin >> c >> X(b);
		cin >> c >> Y(b);
		cin >> c >> X(p);
		cin >> c >> Y(p);

		s = symPL(p,a,b);

		printf("%.6lf %.6lf\n",X(s),Y(s));
	}

}

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

long long H, W, N, x[100009], y[100009], c[100009], a[100009], b[100009], cola[100009], colb[100009], cnt1, cnt2;
vector<pair<long long, long long>>X[100009], Y[100009];
vector<pair<int, long long>>ax[100009], bx[100009];
vector<int>Z1[100009], Z2[100009];
bool flag = false;

void dfs1(int pos, long long depth) {
	if (a[pos] != -(1LL << 60)) {
		if (a[pos] != depth) flag = true;
		return;
	}
	a[pos] = depth; cola[pos] = cnt1; Z1[cnt1].push_back(pos);
	for (int i = 0; i < bx[pos].size(); i++) dfs1(bx[pos][i].first, depth + bx[pos][i].second);
}
void dfs2(int pos, long long depth) {
	if (b[pos] != -(1LL << 60)) {
		if (b[pos] != depth) flag = true;
		return;
	}
	b[pos] = depth; colb[pos] = cnt2; Z2[cnt2].push_back(pos);
	for (int i = 0; i < ax[pos].size(); i++) dfs2(ax[pos][i].first, depth + ax[pos][i].second);
}

int main() {
	cin >> H >> W >> N;
	for (int i = 1; i <= N; i++) {
		cin >> x[i] >> y[i] >> c[i];
		X[x[i]].push_back(make_pair(y[i], c[i]));
		Y[y[i]].push_back(make_pair(x[i], c[i]));
	}
	for (int i = 1; i <= H; i++) {
		sort(X[i].begin(), X[i].end());
		for (int j = 0; j < (int)X[i].size() - 1; j++) {
			ax[X[i][j].first].push_back(make_pair(X[i][j + 1].first, X[i][j + 1].second - X[i][j].second));
			ax[X[i][j + 1].first].push_back(make_pair(X[i][j].first, X[i][j].second - X[i][j + 1].second));
		}
	}
	for (int i = 1; i <= W; i++) {
		sort(Y[i].begin(), Y[i].end());
		for (int j = 0; j < (int)Y[i].size() - 1; j++) {
			bx[Y[i][j].first].push_back(make_pair(Y[i][j + 1].first, Y[i][j + 1].second - Y[i][j].second));
			bx[Y[i][j + 1].first].push_back(make_pair(Y[i][j].first, Y[i][j].second - Y[i][j + 1].second));
		}
	}
	for (int i = 1; i <= H; i++) a[i] = -(1LL << 60);
	for (int i = 1; i <= W; i++) b[i] = -(1LL << 60);
	for (int i = 1; i <= H; i++) { if (a[i] == -(1LL << 60)) { cnt1++; dfs1(i, 0); } }
	for (int i = 1; i <= W; i++) {
		if (b[i] == -(1LL << 60)) {
			cnt2++; long long E = (1LL << 40); if (Y[i].size() >= 1) E = Y[i][0].second - a[Y[i][0].first];
			dfs2(i, E);
		}
	}

	for (int i = 1; i <= cnt1; i++) {
		int V1 = Z1[i][0]; if (X[V1].size() == 0) continue;
		int V = colb[X[V1][0].first];
		long long m1 = (1LL << 60); for (int j = 0; j < Z1[i].size(); j++) m1 = min(m1, a[Z1[i][j]]);
		long long m2 = (1LL << 60); for (int j = 0; j < Z2[V].size(); j++) m2 = min(m2, b[Z2[V][j]]);
		if (m1 + m2 < 0) {
			flag = true;
		}
	}
	if (flag == true) cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 35452
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <iomanip>
#include <math.h>
#include <fstream>

using namespace std;

long long mod = 1000000007;

void dfs(int p, int prev, vector<int> &a, vector<int> &dp, int dpl, vector<vector<int>> &v, vector<int> &res)
{
    int l = -1, r = dpl, mid;
    while (r - l > 1)
    {
        mid = (l + r) / 2;
        if (dp[mid] >= a[p])
        {
            r = mid;
        }
        else
        {
            l = mid;
        }
    }
    int temp = dp[r];
    dp[r] = a[p];
    if (temp == -1)
    {
        dpl++;
    }
    res[p] = dpl;
    for (int i = 0; i < v[p].size(); i++)
    {
        if (v[p][i] == prev)
        {
            continue;
        }
        dfs(v[p][i], p, a, dp, dpl, v, res);
    }
    dp[r] = temp;
}

int main()
{
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    // ifstream cin("in.txt");
    // ofstream cout("out.txt");
    
    
    // int t;
    // cin >> t;
    // for (int qwe = 0; qwe < t; qwe++)
    // {
    //     cout << "Case #" << qwe + 1 << ": ";
    // }


    int n;
    cin >> n;
    vector<int> a(n);
    map<int, int> mp;
    set<int> st;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    for (int i = 1; i < n; i++)
    {
        mp[a[i] + a[0] - i]++;
    }
    long long rez = mp[0];
    int curr = 0;
    for (int i = 1; i < n; i++)
    {
        curr = a[0] - a[i] - i;
        mp[a[i] + a[0] - i]--;
        rez += mp[curr];
    }
    cout << rez << '\n';


    return 0;
}


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

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String X = scanner.next();
        String Y = scanner.next();
        String judge = "=";

        //listにA～Fを追加
        List<String> list = new ArrayList<>();
        for (String s : new String[] {"A", "B", "C", "D", "E", "F"}) {
            list.add(s);
        }

        int x = list.indexOf(X);
        int y = list.indexOf(Y);

        if (x < y) {
            judge = "<";
        } else if (x > y) {
            judge = ">";
        }
        System.out.println(judge);
    }

}

Measured memory_bytes: 21972