akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>

#define rep(i,n) for(int i=0;i<n;i++)
#define pb push_back

using namespace std;

int main()
{
	vector<int> res;
	int v[101];
	int a,b;
	char c;

	while(cin >> a >> c >> b)
	{
		if(a == 0 && b == 0) break;
		
		v[a] = b;
		if(res.empty())
		{
			res.pb(b);
		}
		else
		{
			vector<int>::iterator ite = find(res.begin(),res.end(),b);
			if(ite == res.end())
			{
				res.pb(b);
			}
		}
	}

	sort(res.begin(),res.end(),greater<int>());
	int team;
	while(cin >> team)
	{
		rep(i,res.size())
		{
			if(res[i] == v[team])
			{
				cout << i+1 << endl;
			}
		}
	}


	return 0;
}

Measured memory_bytes: 1220
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <cctype>
#include <algorithm>
#include <functional>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <iomanip>
#include <limits>

#define roop(i, n) for(int i=0;i<n;i++)
#define DIV 1000000007
//static const long double pi = 3.1415926535897932;

using namespace std;
using ll = long long int;
using ull = unsigned long long;

char toSmall(char c) { // 大文字を小文字へ
	return (c + 0x20);
}

char toLarge(char c) { // 小文字を大文字へ
	return (c - 0x20);
}

float myPower(int a, int n) { // aのn乗の計算
	float x = 1;
	while (n > 0) { // 全てのbitが捨てられるまで
		if ( n & 1) { // 一番右のbitが１のとき
			x *= a;
		}
		a *= a;
		n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
	}
	return x;
}

ll combination(ll n, ll r) { // nCr の計算
	if (n < 0 || r < 0 || r > n) return -1;

	if (n - r < r) r = n - r;
	if (r == 0) return 1;
	if (r == 1) return n;

	vector<ll> num(r);
	vector<ll> den(r);

	for (ll i = 0; i < r; i++) {
		num[i] = n - r + i + 1;
		den[i] = i + 1;
	}

	for (ll p = 2; p <= r; p++) {
		ll pivot = den[p - 1];
		if (pivot > 1) {
			ll offset = (n - r) % p;
			for (ll k = p - 1; k < r; k += p) {
				num[k - offset] /= pivot;
				den[k] /= pivot;
			}
		}
	}
	ll result = 1;
	for (ll k = 0; k < r; k++) {
		if (num[k] > 1) result *= num[k];
	}
	return result;
}

vector<string> split(const string& src, const char* delim = ",") { //カンマ区切り
	vector<string> vec;
	string::size_type len = src.length();

	for (string::size_type i = 0, n; i < len; i = n + 1) {
		n = src.find_first_of(delim, i);
		if (n == string::npos) {
			n = len;
		}
		vec.push_back(src.substr(i, n - i));
	}

	return vec;
}

bool check_int(string str)
{
	if (all_of(str.cbegin(), str.cend(), [](char ch) { return isdigit(ch);}))
	{
		return true;
	}
	return false;
}

struct rest {
	string s;
	int p;
	int num;

	/* -------------------------------------
	sort関数を使用したときのソートの定義をする。
	まずは文字列sでソートする。
	文字列sが同じだった場合、pでソートする。
	この条件を参考演算子で表現(ifでもOK)
	-------------------------------------*/
	bool operator<(const rest& right) const {
		return s == right.s ? p > right.p : s < right.s;
	}
};

int main() {
	long double a, b, ans;
	cin >> a >> b;
	ans = (a * b);
	ans = floor(ans);
	cout << setprecision(16) << ans << endl;
	return 0;
}

Measured memory_bytes: 3832
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0;i < (n);i++)
#define P pair<int,int>
#define pb push_back
#define mk make_pair
using namespace std;
const int INF = 1 << 20;

typedef long long ll;




int main(){
  int h,w;
  cin >> h >> w;
  string s[h][w];
  int a = 1,b = 0;;
  char c = 'A';
  REP(i,h){
    REP(j,w){
      cin >> s[i][j];
      if(s[i][j] == "snuke"){
	a = i;
	b = j;
	
      }
    }
  }
  c = 'A'+b;
  cout  << c << a+1 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repA(i,a,b) for(int i=a;i<=b;i++)
#define repD(i,b,a) for(int i=b;i>=a;i--)
#define fill(a) memset(a,0,sizeof(a))
#define f first
#define s second
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
int main()
{
    string str;
    cin>>str;
    if(str[2]==str[3] && str[4]==str[5])
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
package main
import "fmt"
func main() {
  var N int
  fmt.Scanf("%d", &N)
  stones := make([]int, N)
  for i:=0;i<N;i++ {
    fmt.Scanf("%d", &stones[i])
  }
  if N == 1 {
    fmt.Println(0)
    return
  }
  if N == 2 {
    fmt.Println(abs(stones[1]-stones[0]))
    return
  }
  dp := make([]int, N)
  dp[0] = 0
  dp[1] = abs(stones[1]-stones[0])
  for i:=2;i<N;i++ {
    dp[i] = min(dp[i-1]+abs(stones[i]-stones[i-1]), dp[i-2]+abs(stones[i]-stones[i-2]))
  }
  // dp[i]: min_{j=1}^2(dp[i-j]+abs(arr[i]-arr[i-j]))
  fmt.Println(dp[N-1])
}

func abs(num int) int {
  if num < 0 {
    return -num
  }
  return num
}

func min(a, b int) int {
  if a < b {
    return a
  }
  return b
}


Measured memory_bytes: 5504
n,p=map(int,input().split())
a=list(map(int, input().split()))
from math import factorial
o=0;e=0
for i in a:
    if i%2==0:e+=1
    else:o+=1
if p==0:
    odds=0
    for i in range(0,o+1,2):
        odds+=factorial(o)//factorial(i)//factorial(o-i)
else:
    odds=0
    for i in range(1,o+1,2):
        odds+=factorial(o)//factorial(i)//factorial(o-i)
print(odds*2**e)

Measured memory_bytes: 62100
#include<iostream>
#include<cstdio>
#include<cstdlib>
using namespace std;

const int MAX_N = 999999;
int prime[MAX_N];
bool is_prime[MAX_N + 1];

int sieve(int n)
{
	int p = 0;
	for (int i = 0; i <= n; i++)
		is_prime[i] = true;
	is_prime[0] = is_prime[1] = false;

	for (int i = 2; i <= n; i++)
	{
		if (is_prime[i])
		{
			prime[p++] = i;
			for (int j = i * 2; j <= n; j += i)
				is_prime[j] = false;
		}
	}
		return p;
}

int main()
{
	int n;
	while (scanf("%d", &n) != EOF)
	{
		int ans = sieve(n);
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 2468
N, M, X = gets.split.map(&:to_i)
Cs, As = [], []
N.times{c, *as = gets.split.map(&:to_i); Cs << c; As << as}
INF = 10**10

require 'matrix'

cs, as = Matrix.row_vector(Cs), Matrix[*As.transpose]
ans = INF
[0, 1].repeated_permutation(N).each do |a|
  v = Matrix.column_vector(a)
  ans = [ans, (cs*v)[0, 0]].min if (as*v).all?{_1 >= X}
end
puts ans == INF ? -1 : ans

Measured memory_bytes: 15164
s = input()
t = input()
if t in s:
    print(0)
else:
    count = 0
    val = 10001
    for j in range(len(s)-len(t)+1):
        k = 0
        count= 0
        for i in range(j,len(t)+j):
            if s[i]!=t[k]:
                count+=1
            k+=1
        val = min(val,count)
    print(val)

Measured memory_bytes: 67496
#![allow(unused_imports)]

use std::cmp::{max, min, Ordering};
use std::collections::*;
#[cfg(debug_assertions)]
include! {"./debug.rs"}

#[cfg(not(debug_assertions))]
macro_rules! debug {
    ($($arg:expr),*) => {};
}

macro_rules! read {
    ([$t:ident] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ([$t:ident]) =>
        (rl().split_whitespace().map(|w| read_type!(w, $t)).collect::<Vec<_>>());
    (_, [$t:ident] ; $n:expr) =>
        ((0..$n).map(|_| read!(_, [$t])).collect::<Vec<_>>());
    (_, [$t:ident]) =>
        (rl().split_whitespace().skip(1).map(|w| read_type!(w, $t)).collect::<Vec<_>>());
    ($($t:ident),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ($t:ident) => (read_type!(rl(), $t));
    ($($t:ident),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(read_type!(w.next().unwrap(), $t)),*)
    }};
}

macro_rules! read_type {
    ($s:expr, chars) => {
        $s.chars().collect::<Vec<char>>()
    };
    ($s:expr, usize1) => {
        read_type!($s, usize) - 1
    };
    ($s:expr, $t:ty) => {
        $s.parse::<$t>().unwrap()
    };
}

fn rl() -> String {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

impl<T: Iterator> IteratorExt for T {}

////////////////////////////////////////////////////////////////////////////////

fn main() {
    let (n, m) = read!(usize, usize);
    let mut a = read!(i64; m);
    a.insert(0, -1);
    a.push((n + 1) as i64);
    debug!(a);

    let b = (0..m + 1).map(|i| a[i + 1] - a[i] - 1).vec();
    debug!(b);

    let mut ans: i64 = 1;
    for x in b {
        ans *= if x == 0 {
            0
        } else if x <= 1 {
            1
        } else {
            let x = x as usize;
            let mut s = vec![0; x];
            s[0] = 1;
            s[1] = 1;
            for i in 2..x {
                s[i] = (s[i - 2] + s[i - 1]) % 1_000_000_007;
            }
            s[x - 1]
        };
        ans %= 1_000_000_007;
    }

    println!("{}", ans);
}


Measured memory_bytes: 6396
import java.util.ArrayList;
import java.util.Comparator;
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();
		List<Res> list = new ArrayList<>();
		for(int i = 1; i < N + 1; i++) {
			list.add(new Res(sc.next(), sc.nextInt(), i));
		}
		list.sort(Comparator.comparing(Res::getCity)
				.thenComparing((o1, o2) -> Integer.compare(o2.getPoint(), o1.getPoint())));
		for(Res res : list) {
			System.out.println(res.getNum());
		}
	}

}

class Res {
	private String city;
	private int point;
	private int num;

	protected Res(String city, int point, int num) {
		super();
		this.city = city;
		this.point = point;
		this.num = num;
	}

	public String getCity() {
		return city;
	}

	public void setCity(String city) {
		this.city = city;
	}

	public int getPoint() {
		return point;
	}

	public void setPoint(int point) {
		this.point = point;
	}

	public int getNum() {
		return num;
	}

	public void setNum(int num) {
		this.num = num;
	}

}

Measured memory_bytes: 26708
#include<bits/stdc++.h>
using namespace std;
typedef int Weight;
struct Edge {  //src:辺の始点,dst:辺の終点,weight:辺の重さ
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight : //辺は重さが重いものを"小さい"と定義する
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

//引数 g:隣接リスト,r:最小全域木の始点
//戻値 total:最小全域木の重み,T:最小全域木の辺集合
pair<Weight, Edges> prim(const Graph &g, int r = 0) {
  int n = g.size();
  Edges T;
  Weight total = 0;
  vector<bool> visited(n);
  priority_queue<Edge> Q;
  Q.push( Edge(-1, r, 0) );    //始め、-1とrを結ぶ辺があると考える
  while (!Q.empty()) {
    Edge e = Q.top(); Q.pop();
    if (visited[e.dst]) continue;
    T.push_back(e);
    total += e.weight;
    visited[e.dst] = true;
    for(auto f=g[e.dst].begin();f!=g[e.dst].end();++f) if(!visited[f->dst]) Q.push(*f);
  }
  return pair<Weight, Edges>(total, T);
}
  int main(){
  int v,e;
  cin>>v>>e;
  Graph g(v);    //頂点数vの空隣接リストgを生成
  for(int i=0;i<e;i++){// ...
    int s,t,w;
    cin>>s>>t>>w;
  g[s].push_back(Edge(s,t,w));    //隣接リストgにsからtに向かう重さwの辺を追加
  g[t].push_back(Edge(t,s,w));
 }
  pair<Weight,Edges>ans=prim(g); 
  cout<<ans.first<<endl;
 
   
  
}










Measured memory_bytes: 8712
for e in iter(input, '0 0 0 0 0'):
    N, A, B, C, X = map(int, e.split())
    Y = [*map(int, input().split())]
    lenY = len(Y)
    tgt = Y[0] == X
    cnt = 0
    while tgt < lenY and cnt < 10000:
        cnt += 1
        X = (A * X + B) % C
        tgt += Y[tgt] == X
    print(cnt if tgt == lenY else -1)


Measured memory_bytes: 5616
/**
 * Created by hiramekun at 20:44 on 2019-12-08.
 */
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

int main() {
    ll h, w;
    cin >> h >> w;
    int a[h][w], b[h][w];
    rep(i, h) rep(j, w) cin >> a[i][j];
    rep(i, h) rep(j, w) cin >> b[i][j];

    ll max_diff = 2 * 80 * 160;
    vector<vector<vector<bool>>> dp(h, vector<vector<bool>>(w, vector<bool>(max_diff)));
//    bool dp[h][w][max_diff];
    rep(i, h) rep(j, w) rep(l, max_diff) dp[i][j][l] = false;

    ll mid = max_diff / 2;
    dp[0][0][b[0][0] - a[0][0] + mid] = true;
    dp[0][0][-b[0][0] + a[0][0] + mid] = true;

    rep(i, h) {
        rep(j, w) {
            rep(l, max_diff) {
                if (!dp[i][j][l]) continue;
                if (i + 1 <= h - 1) {
                    dp[i + 1][j][l + b[i + 1][j] - a[i + 1][j]] = true;
                    dp[i + 1][j][l - b[i + 1][j] + a[i + 1][j]] = true;
                }
                if (j + 1 <= w - 1) {
                    dp[i][j + 1][l + b[i][j + 1] - a[i][j + 1]] = true;
                    dp[i][j + 1][l - b[i][j + 1] + a[i][j + 1]] = true;
                }
            }
        }
    }
    ll ans = 1e18;
    rep(i, max_diff) {
        if (dp[h - 1][w - 1][i]) ans = min(ans, abs(i - mid));
    }
    cout << ans << '\n';
}

Measured memory_bytes: 20864
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#include <vector>
#define ll long long 
using namespace std;

string a, b, c, ans;
int ca = 0, cb = 0, cc = 0, turn = 0;

int f(char x) {
	if (x == 'a') turn = 0;
	if (x == 'b') turn = 1;
	if (x == 'c') turn = 2;
	return turn;
}

int main() {
	cin >> a >> b >> c;
	for (;;) {
		if (turn == 0) {
			if (ca == a.length()) {
				ans = 'A';
				break;
			}
			turn = f(a[ca]);
			ca++;
		}
		

		if (turn == 1) {
			if (cb == b.length()) {
				ans = 'B';
				break;
			}
			turn = f(b[cb]);
			cb++;
		}
		

		if (turn == 2) {
			if (cc == c.length()) {
				ans = 'C';
				break;
			}
			turn = f(c[cc]);
			cc++;
		}
		
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <climits>
#include <iomanip>
#include <sstream>
#include <list>
using namespace std;

using ll = long long;
using ld = long double;
using ull = unsigned long long;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"

#define sz(x) (int)(x).size()
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

template <typename A, typename B> 
ostream& operator<<(ostream& os, pair<A,B> &p) {
	return os << "(" << p.first << "," << p.second << ")";
} 

template <typename A> 
ostream& operator<<(ostream& os, vector<A> &p) {
	for (auto &x : p) {
		os << x << " ";
	}
	os << endl;
	return os;
} 

vector<int> primes;

void siv(int n) {
	vector<bool> is_prime(n+1, true);
	is_prime[0] = is_prime[1] = false;
	for (int i = 2; i <= n; i++) {
	    if (is_prime[i] && (long long)i * i <= n) {
	    	primes.push_back(i);
	        for (int j = i * i; j <= n; j += i)
	            is_prime[j] = false;
	    }
	}
}

template <typename T>
T gcd(T a, T b) {
	if (a < 0) a *= -1;
	if (b < 0) b *= -1;
	
	while (b != 0) {
		T temp = a;
		a = b;
		b = temp % b;
	}

	return a;
}


// cout << setfill('0') << setw(5) << number < endl;
// while(getline(cin, s)) { .. } | `s` is a string


void solve() {
	int a;
	cin >> a;
	cout << a + a * a + a * a * a;
}


int main(){
	IOS;
	#ifndef ONLINE_JUDGE
	    // for getting input from input.txt
	    (void)freopen("input.txt", "r", stdin);
	    // for writing output to output.txt
	    (void)freopen("output.txt", "w", stdout);
	#endif

	int t = 1;
	// cin >> t;
	while(t--) 
		solve();

	// return 0;
}



























 

Measured memory_bytes: 3652
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#define    boost        ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define    nl           "\n"
#define    ll           long long
#define    pb           push_back
#define    mpr          make_pair
#define    fr(i,a,n)    for(ll i=a;i<n;++i)
#define    fr0(i,n)     for(ll i=0;i<n;++i)
#define    pii          pair<int, int>
#define    FO           find_by_order
#define    OK           order_of_key
#define    mem(a)       memset(a,0,sizeof(a))
#define    ff           first
#define    ss           second


typedef tree <
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update >
set_t;


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


template<typename T> void TIME(T start, T end)
{
#ifndef ONLINE_JUDGE
	double time_taken =  chrono::duration_cast<chrono::nanoseconds>(end - start).count();
	time_taken *= 1e-9;
	cout << "\nExecuted in: " << fixed
	     << time_taken << setprecision(9);
	cout << " sec";
#endif
}

///----------------------------- | FUNCTIONS | --------------------------------------///

/*
const int N = 2e5 + 5;

vector<int> adj[N];
bool visited[N];
//int val[N];
int depth[N];
//int parent[N];

void dfs(int v)
{
	visited[v] = true;
	for (int u : adj[v])
	{
		if (!visited[u])
		{
			//parent[u] = v;
			depth[u] = depth[v] + 1;
			dfs(u);
		}
	}
}
*/

// left shift << multiply by 2
// right shift >> divide by 2

///----------------------------- | START FROM HERE | --------------------------------------///

#define int long long //change int main to int32_t main
const int N = 2e5 + 5;
int n, ww;
int w[N], v[N];
int dp[105][N];

int rec(int i, int cap)
{
	if (dp[i][cap] != 0) return dp[i][cap];
	int result = 0;
	if (cap > 0 && i < n)
	{
		if (w[i] > cap)
		{
			result = rec(i + 1, cap);
		}
		else
		{
			int x = rec(i + 1, cap);
			int y = v[i] + rec(i + 1, cap - w[i]);
			result = max(x, y);
		}
	}
	dp[i][cap] = result;
	return result;
}

void solve()
{
	cin >> n >> ww;
	fr0(i, n) cin >> w[i] >> v[i];
	//memset(dp, - 1, sizeof(dp));
	int ans = rec(0, ww);
	cout << ans;

}





int32_t main()
{
	auto start = chrono::high_resolution_clock::now();
	boost;
	fio();
	int t;
	t = 1;
	//cin >> t;
	while (t--) solve();
	auto end = chrono::high_resolution_clock::now();
	TIME(start, end);
	return 0;
}




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

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		
		int N = sc.nextInt();
		int K = sc.nextInt();
	    long[] V = new long[N];
	    for (int i = 0; i < N; ++i)
	    	V[i] = sc.nextLong();

	    long res = 0;
	    for (int p = 0; p <= Math.min(K, N); ++p) {
	        for (int q = 0; p + q <= Math.min(K, N); ++q) {
	            List<Long> v = new ArrayList<>();
                long cur = 0;
	            for (int i = 0; i < p; ++i) { v.add(V[i]); cur += V[i];}
	            for (int i = 0; i < q; ++i) { v.add(V[N-1-i]) ; cur += V[N-1-i];}
	               
	            Collections.sort(v);
	            for (int i = 0; i < Math.min(K - p - q, (int)v.size()); ++i) {
	                if (v.get(i) < 0) cur -= v.get(i);
	            }
	            res = Math.max(res, cur);
	        }
	    }
	    out.println(res);
		
		out.close();
	}



static class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}
}



Measured memory_bytes: 24532
n, m = map(int, input().split())
a = []
for i in range(n):
    k = list(map(int, input().split()))
    a.append(k[1:])
cnt = 0
for i in range(1, 31):
    key = 1
    for j in range(n):
        if i not in a[j]:
            key = 0
            break
    if key == 1:
        cnt += 1
print(cnt)

Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define ENDL '\n'
#define io ios_base::sync_with_stdio(false);cin.tie(0);
#define sayy cout<<"Yes"<<ENDL;
#define sayn cout<<"No"<<ENDL;
#define sayY cout<<"YES"<<ENDL;
#define sayN cout<<"NO"<<ENDL;

typedef long long ll;
using namespace std;

int main(){
    io

    ll n, k;
    cin >> n >> k;

    vector<ll> v(n+1), dp(n+1, LONG_MAX);
    for(int i(1); i<=n; i++) cin >> v[i];

    dp[0] = 0;
    dp[1] = 0;
    dp[2] = abs(v[2] - v[1]);

    for(int i(3); i<=n; i++){
        for(int j = 1; j<=k; j++){
            if(i-j >= 1){
                dp[i] = min(dp[i], dp[i-j] + abs(v[i]-v[i-j]));
            }
        }
    }
    cout << dp[n] << ENDL;

    return 0;
}

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

int main() {
	int N, S = 0;
	cin >> N;
	vector<int> a(N);
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}

	sort(a.begin(), a.end());
	reverse(a.begin(), a.end());

	for (int j = 0; j < N; j++) {
		if (j % 2 == 0) {
			S += a[j];
		}
		else {
			S -= a[j];
		}
	}

	cout << S << endl;
}

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

#include<cmath>

int main()
{


    int n;
    cin>>n;

    vector<int> sub(n+1); 
    for(int i=2;i<=n;i++){
        int wk;
        cin>>wk;
        sub.at(wk)++;
    }

    for(int i=1;i<=n;i++){
        cout<<sub.at(i)<<endl;
    }

    return 0;
}  

Measured memory_bytes: 4052
H,W=map(int,input().split())
s=[]
for _ in range(H):
    s.append(list(input()))

inf=float("inf")
ans=[[inf]*W for _ in range(H)]

if s[0][0]==".":
    ans[0][0]=0
else:
    ans[0][0]=1

for i in range(H):
    for j in range(W):
        if j!=W-1:
            if s[i][j]=="." and s[i][j+1]=="#":
                ans[i][j+1]=min(ans[i][j]+1,ans[i][j+1])
            else:
                ans[i][j+1]=min(ans[i][j],ans[i][j+1])
        if i!=H-1:
            if s[i][j]=="." and s[i+1][j]=="#":
                ans[i+1][j]=min(ans[i][j]+1,ans[i+1][j])
            else:
                ans[i+1][j]=min(ans[i][j],ans[i+1][j]) 

print(ans[H-1][W-1])

Measured memory_bytes: 3188
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, 500001), 500000)
	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

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)

	a := getNextInt(scanner)
	b := getNextInt(scanner)
	if a > 0 {
		fmt.Println("Positive")
		return
	}
	if b >= 0 {
		fmt.Println("Zero")
		return
	}
	if (b-a)%2 == 0 {
		fmt.Println("Negative")
		return
	}
	fmt.Println("Positive")
	writer.Flush()
}


Measured memory_bytes: 640
n = int(input())
moji = dict()
for i in range(n):
    s = input()
    moji[s] = moji.get(s, 0) + 1
max_cnt = max([value for value in moji.values()])
for key, value in sorted(moji.items(), key=lambda x: x[0]):
    if value == max_cnt:
        print(key)


Measured memory_bytes: 46556
#include<iostream>
#include<vector>

using namespace std;

int main(){
    int s,i;
    cin>>s;
   vector<int> n(10000,0);
    int tmp = s;
    n[tmp]++;
   for(i=1;;i++){
       if(tmp%2==0){
           tmp/=2;
       }else{
           tmp = 3*tmp + 1;
       }
       n[tmp]++;
       if(n[tmp]==2){
           cout<<i+1;
           return 0;
       }
   }
}

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

int main(void){
	int a,b,c,d;
	int sum1,sum2;

	scanf("%d %d %d %d",&a,&b,&c,&d);
	sum1=(a+b+c+d);
	fflush(stdin);
	scanf("%d %d %d %d",&a,&b,&c,&d);
	sum2=(a+b+c+d);
	if(sum1>=sum2)
		cout<<sum1<<endl;
	else
		cout<<sum2<<endl;

	return 0;
}

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

int main(){
    double r, pi, S, L;

    cin >> r;
    pi = 3.14159265358979323846;
    
    S = pi * r * r;
    L = 2 * pi * r;

    printf("%f %f \n", S, L);
   
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define UB upper_bound
#define LB lower_bound
#define PB push_back
#define mp make_pair
#define F first
#define S second
#define be(a) (a).begin(),(a).end()
#define deb(x) cout<< #x <<" "<<endl;
#define deb2(x, y) cout<< #x <<" "<< x <<endl<< #y <<" "<<y<<endl
#define fo(i, n) for(long long i=0; i<n; i++)
#define Fo(i, n, k) for(long long i=k; i<n; i++)
#define mod 1000000007
#define int long long

typedef long long ll;

void fileIO()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}
 
typedef vector<pair<int, int>> vll;
typedef unordered_map<int, int> ump;



bool sortbysecdesc(const pair<int, int> &a, 
                    const pair<int, int> &b) 
{ 
    return a.second>b.second;
}



int32_t main()
{
    IOS;
    //fileIO();
    int T;
    T = 1;
    //cin>>T;

    while(T--)
    {
        int n, W;
        cin>>n>>W;
        int *w = new int [n];
        int *v = new int [n];

        for(int i = 0; i<n; i++)
        {
            cin>>w[i]>>v[i];
        }

        int dp[n+1][W+1];
        for(int i = 0; i<=n; i++) dp[i][0] = 0;
        for(int i = 0; i<=W; i++) dp[0][i] = 0;

        for(int i = 1; i<=n; i++)
        {
            for(int j = 1; j<=W; j++)
            {
                if(w[i-1]<=j)
                {
                    dp[i][j] = max(dp[i-1][j], v[i-1] + dp[i-1][j-w[i-1]]);
                }
                else dp[i][j] = dp[i-1][j];
            }
        }

        cout<<dp[n][W];

        delete [] w;
        delete [] v;        
        
    }
    
    return 0;
}



Measured memory_bytes: 82444
import math
n,d=map(int,input().split())

li=[list(map(int,input().split())) for i in range(n)]
#print(li)

def dist(al,bl,d):
  total=0
  for i in range(d) :
    total += (al[i]-bl[i])**2
    
  return math.sqrt(total)

#print(dist([5,5],[1,2],2))
count=0
for i in range(n):
  for j in range(n):
    if i<= j :
      continue
    di=dist(li[i],li[j],d)
    if di.is_integer() :
      count+=1
print(count)
    


Measured memory_bytes: 3064
//
//  main.cpp
//  D - Triangles
//
//  Created by Hashizo on 2019/10/19.
//  Copyright © 2019 Hashizo. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <regex>
#include <cmath>

using namespace std;
 
#undef LONG_MAX
#undef LONG_MIN
 
#define LONG_MAX    9223372036854775807
#define LONG_MIN    (-LONG_MAX  -1)
 
#define ll long long
 
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
 
#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())

int main(int argc, const char * argv[]) {
    ll ans = 0;

	ll n;
	cin >> n;

	vector<ll> l(n);
	REP(i, n) {
		cin >> l[i];
	}
	
	
//	REP(i, n) {
//		FOR(j, i+1, n) {
//			FOR(k, j+1, n) {
//				if((l[i] < (l[j]+l[k])) &&
//				   (l[j] < (l[i]+l[k])) &&
//				   (l[k] < (l[i]+l[j]))) {
//					ans++;
//				}
//			}
//		}
//	}

	REP(i, n) {
		if (((i+1) - 2) > 0) {
			for (ll j = ((i+1)-2); j != 0; j--) {
				ans += j;
			}
		}
	}
	SORT(l);
	
	REP(i, n) {
		FOR(j, i+1, n) {
			FOR(k, j+1, n) {
				if((l[i] + l[j]) <= l[k]) {
					ans -= (n-k);
					break;
				}
			}
		}
	}
	
	
	
	cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
/* cerberus97 - Hanit Banga */

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 55;

int main() {
	fast_cin();
	int n, k;
	cin >> n >> k;
	cout << n - k + 1 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"
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, val;
    cin >> n;
    int pre = -1, cnt = 0;
    unordered_map<int, int> stats;
    for(int i = 0; i < n; i++) {
        cin >> val;
        if (val != pre) {
            stats[cnt] += 1;
            cnt = 1;
        } else {
            cnt += 1;
        }
        pre = val;
    }
    if (cnt > 0)
        stats[cnt] += 1;
    int ans = 0;
    for(auto& [num, freq]: stats) {
        ans += (num/2) * freq;
    }
    cout << ans << endl;
    return 0;
}


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

template<typename T>
T get_value(std::istream& is);

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

  int N;
  cin >> N;
  vector<int> P(N), Q(N);
  for (auto& e : P)
    cin >> e;
  for (auto& e : Q)
    cin >> e;

  vector<int> tmp(N);
  iota(tmp.begin(), tmp.end(), 1);

  auto index_p {-1ll}, index_q {-1ll};
  for (auto i {0u}; index_p == -1 || index_q == -1; ++i) {
    if (equal(tmp.begin(), tmp.end(), P.begin(), P.end()))
      index_p = i;
    if (equal(tmp.begin(), tmp.end(), Q.begin(), Q.end()))
      index_q = i;
    next_permutation(tmp.begin(), tmp.end());
  }

  cout << abs(index_p - index_q) << '\n';

  return 0;
}

template<typename T>
inline T get_value(std::istream& is)
{
  T v;
  is >> v;
  return v;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int gcd(long a,long b){
if(a==0)
    return b;
    return gcd(b%a,a);
}
int main(){
  long long x,y,z;
  cin>>x>>y;
  if(x>y)
    swap(x,y);
  z=((x*y)/gcd(x,y));
  cout<<z;
}


Measured memory_bytes: 3604
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

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

  for(int i = 0; i <= N; i++){
    for(int j = 0; j <= M; j++){
      int num = i * M + j * N - 2 * i * j;
      if(num == K){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }

  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
int a[123];
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

	ll n,k; 
	cin>>n>>k;
	cout<<min(n%k,k-n%k)<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define tr(container, it) \
	for (auto it = container.begin(); it != container.end(); it++)
#define scontains(c,x) ((c).find(x) != (c).end())   //O(log n) 
#define contains(c,x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define Ichar(_x) char _x;scanf("%c",&_x);
#define Iint(_x) int _x;scanf("%d",&_x); 
#define Ill(_x)  ll _x;scanf("%lld",&_x);
#define inc(a,b,x)(x)>a && (x)<b	
#define incE(a,b,x)(x)>=a && (x)<=b	
//freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);




int arr[100000]={1};
int num[100000];
int main()
{
	Iint(n);
	Iint(m);
	int a, b;
	for (int i = 0; i < n; ++i)
	{
		num[i] = 1;
	}
	for (int i = 0; i < m; ++i)
	{
		scanf("%d", &a);
		scanf("%d", &b);
		if (arr[a-1] == 1)arr[b-1] = 1;
		if (arr[a - 1] == 0 && num[b - 1] == 0)
			arr[b - 1] = 0;
		num[a - 1]--; num[b - 1]++;
	}
	int nm=0;
	for (int i = 0; i < n; ++i)
	{
		if (num[i] != 0 && arr[i]==1)nm++;
	}
	std::cout << nm;



}











Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 7;
typedef long long ll;
int prime[maxn + 1];
int vis[maxn + 1];
void Prime(){
    memset(vis, 0, sizeof(vis));
    memset(prime, 0, sizeof(prime));
    for (int i = 2;i <= maxn; i++) {
//        cout<<" i = "<<i<<endl;
        if (!vis[i]) {
            prime[++prime[0]] = i;      //纪录素数， 这个prime[0] 相当于 cnt，用来计数
        }
        for (int j = 1; j <=prime[0] && i*prime[j] <= maxn; j++) {
//            cout<<"  j = "<<j<<" prime["<<j<<"]"<<" = "<<prime[j]<<" i*prime[j] = "<<i*prime[j]<<endl;
            vis[i*prime[j]] = 1;
            if (i % prime[j] == 0) {
                break;
            }
        }
    }
}
int n, a[maxn];
int num[maxn];
int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
    Prime();
    bool f = true;
    for (int i = 1; i <= n; i++) {
        int p = a[i];
        for (int j = 1; j <= prime[0] && p >= prime[j]; j++) {
            if(p % prime[j] == 0) {
                if(num[prime[j]]) f = false;
                num[prime[j]] = 1;
                while (p % prime[j] == 0) p /= prime[j];
                if(p == 1) break;
            }
            if(!vis[p]) {
                if(num[p]) f = false;
                num[p] = 1;
                break;
            }
        }
    }
    int gcd = a[1];
    for (int i = 2; i <= n; i++) gcd = __gcd(gcd, a[i]);
    if(f) printf("pairwise coprime\n");
    else if(!f && gcd == 1) printf("setwise coprime\n");
    else printf("not coprime\n");
}


Measured memory_bytes: 19248
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
using namespace std; //std::の省略のため
using ll = long long;

ll MOD = 1000000007;

int main()
{
    ll x, k, d;
    cin >> x >> k >> d;

    ll ans = 0;

    if(x>0){
        if((k - x/d) > 0){
            if((k - x/d)%2 == 0){
                ans = x%d;
            }
            else{
                ans = x%d - d;
                ans *= -1;
            }
        }
        else{
            ans = x - d*k;
        }
        
    }
    else{
        if((k + x/d) > 0){
            if((k + x/d)%2 == 0){
                ans = x%d;
                ans *= -1;
            }
            else{
                ans = x%d + d;
            }
        }
        else{
            ans = x + d*k;
        }
        
    }

    ans = abs(ans);
    

    cout << ans << endl;

}


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

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

using ll = long long;
using P = pair<int,int>;
using mp =  map<int,int>;

const int MOD = 1e9 + 7;

int main() {
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

    int n;
    cin >> n;
    int v[200005], tmp[200005];
    rep(i, n){
        cin >> v[i];
        tmp[i] = v[i];
    }
    sort(tmp, tmp+n);

    rep(i, n) {
        if(v[i] <= tmp[n/2 -1]){
            cout << tmp[n/2] << endl;
        }else{
            cout << tmp[n/2 - 1] << endl;
        }
    }


    return 0;
}


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

struct Queue_data
{
    long long len;
    vector<long long> p;
};

int main()
{
    long long ans = 0;
    long long N;
    cin >> N;
    vector<long long> p;
    p.resize(N);
    for (long long i = 0; i < N; i++)
    {
        cin >> p[i];
    }

    bool flag = true;
    for (long long i = 0; i < N - 1; i++)
    {
        if (p[i] == i + 1)
        {
            long long tmp = p[i];
            p[i] = p[i + 1];
            p[i + 1] = tmp;
            ans++;
        }
    }

    if (p[N - 1] == N)
    {
        ans++;
    }

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

Measured memory_bytes: 1024
from sys import stdin
input=stdin.readline
input()
a=list(map(int,input().split()))
ans=sum(a)
b=[0]*(10**5+1)
for i in a:
  b[i]+=1
c=int(input())
for i in range(c):
  n,m=map(int,input().split())
  if b[n]>0:
    x=b[n]
    if x>0:
      b[m]+=x
      b[n]=0
      ans+=(m-n)*x
  print(ans)

Measured memory_bytes: 20280
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>
#include<time.h>
typedef long long int ll;
//#include<bits/stdc++.h>


using namespace std;



int main()
{
   
    string a, b;
    cin >> a >> b;
    string c = b.substr(0, a.size());
    
    if (a == c)cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;

}

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

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		List<Integer> list = new ArrayList<Integer>();
		for (int i = 0; i < N; i++) {
			list.add(scan.nextInt());
		}
		int count = 0;
		for (int i = 0; i < list.size(); i++) {
			if ((i + 1) % 2 != 0 && list.get(i) % 2 != 0) {
				count++;
			}
		}
		System.out.println(count);
	}

}


Measured memory_bytes: 27188
import sys
input = sys.stdin.buffer.readline
from operator import itemgetter

def main():
    N = int(input())
    
    t = list(map(int,input().split()))
    a = list(map(int,input().split()))
    MOD = 10**9+7
    
    tt,tl = 0,[False for _ in range(N)]
    for x,num in enumerate(t):
        if num > tt:
            tl[x] = True
            tt = num
            
    at,al = 0,[False for _ in range(N)]
    for x,num in enumerate(a[::-1]):
        if num > at:
            al[-x-1] = True
            at = num

    ans,now = 1,0
    for i in range(N):
        if tl[i] == True and al[i] == True:
            if now < t[i] == a[i]:
                now = a[i]
            else:
                print(0)
                exit()
        elif tl[i] == True and al[i] == False:
            if t[i] > a[i]:
                print(0)
                exit()
            else:
                now = t[i]
        elif tl[i] == False and al[i] == True:
            if t[i] < a[i]:
                print(0)
                exit()
            else:
                now = a[i]
        else:
            ans *= min(t[i],a[i])
            ans %= MOD
    
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 17120
#define taskname "test"

#include <bits/stdc++.h>

using namespace std;

#define sz(x) (int)x.size()
#define fi first
#define se second

typedef long long lli;
typedef pair<int, int> pii;

const int maxn = 3e5 + 5;

struct segment_tree
{
    int val[maxn * 4];

    void init()
    {
        fill(begin(val), end(val), 0);
    }

    void update(int x, int l, int r, int p, int k)
    {
        if(l == r)
        {
            val[x] += k;
            return;
        }
        int mid = (l + r) / 2;
        if(p <= mid) update(x * 2, l, mid, p, k);
        else update(x * 2 + 1, mid + 1, r, p, k);
        val[x] = max(val[x * 2], val[x * 2 + 1]);
    }

    int get()
    {
        return val[1];
    }
} tree;

int h, w, n;
pii pos[maxn];

vector<int> vec[maxn];

void read_input()
{
    cin >> h >> w >> n;
    for(int i = 1; i <= n; ++i)
        cin >> pos[i].fi >> pos[i].se;
}

void solve()
{
    tree.init();
    for(int i = 1; i <= n; ++i)
    {
        vec[pos[i].fi].push_back(pos[i].se);
        tree.update(1, 1, w, pos[i].se, 1);
    }
    int ans = 0;
    for(int i = 1; i <= h; ++i)
    {
        for(auto&y: vec[i])
            tree.update(1, 1, w, y, -1);
        ans = max(ans, sz(vec[i]) + tree.get());
        for(auto&y: vec[i])
            tree.update(1, 1, w, y, 1);
    }
    cout << ans << '\n';
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    read_input();
    solve();
}



Measured memory_bytes: 27032
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,w;
    cin>>n>>w;
    long long int weight[n],value[n];
    for(long long int i=0;i<n;i++)
    {
        long long int v1,v2;
        cin>>v1>>v2;
        weight[i]=v1;
        value[i]=v2;
    }
    long long int dp[n+1][w+1];
    for(long long int i=0;i<=n;i++)
    {
        for(long long int j=0;j<=w;j++)
        {
            if(i==0||j==0)
            {
                dp[i][j]=0;
            }
            else if(weight[i-1]<=j)
            {
                dp[i][j]=max(value[i-1]+dp[i-1][j-weight[i-1]],dp[i-1][j]);
            }
            else
            {
                dp[i][j]=dp[i-1][j];
            }
        }
    }
    cout<<dp[n][w];
    return 0;
}

Measured memory_bytes: 79104
import sys
import math
def get_array(): return list(map(int, sys.stdin.readline().strip().split()))
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def input(): return sys.stdin.readline().strip()
n=int(input())
a=get_array()
count=0
for i in range(1,n+1):
    if i&1==1 and a[i-1]&1==1:
        count=count+1
print(count)

Measured memory_bytes: 62004
import java.util.*;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int W = sc.nextInt();
    int H = sc.nextInt();
    int N = sc.nextInt();
    
    int[][] a = new int[3][N];
    int min_x = 0;
    int max_x = W;
    int min_y = 0;
    int max_y = H;
    for(int i = 0; i < N; i++){
      a[0][i] = sc.nextInt();
      a[1][i] = sc.nextInt();
      a[2][i] = sc.nextInt();
      /*System.out.println(a[0][i]);
      System.out.println(a[1][i]);
      System.out.println(a[2][i]);*/
    }
    
    for(int i = 0; i < N; i++){
      if(a[2][i] == 1){
        min_x = Math.max(min_x, a[0][i]);
      }
      if(a[2][i] == 2){
        max_x = Math.min(max_x, a[0][i]);
      }
      if(a[2][i] == 3){
        min_y = Math.max(min_y, a[1][i]);
      }
      if(a[2][i] == 4){
        max_y = Math.min(max_y, a[1][i]);
      }
    }
 
    int x = max_x - min_x;
    int y = max_y - min_y;
    
    //System.out.println(x);
    //System.out.println(y);
    
    if(x <= 0 || y <= 0){
      System.out.println(0);
    }else{
      System.out.println(x*y);
    }
  }
}

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

using namespace std;

int main() {
  int N;
  cin >> N;
  struct P {
    int64_t x, y;
  };

  vector<P> V(N);
  int i = 0;
  while (i < N) {
    cin >> V[i].x >> V[i].y;
    if (V[i].x == 0 && V[i].y == 0) {
      swap(V[i], V[N - 1]);
      N--;
      V.pop_back();
    } else {
      i++;
    }
  }

  double res = 0;
  for (int a = 0; a < N; a++) {
    vector<int64_t> X(6, 0), Y(6, 0);
    for (int b = 0; b < N; b++) {
      int64_t d = V[a].x * V[b].x + V[a].y * V[b].y;
      int64_t e = V[a].x * V[b].y - V[b].x * V[a].y;
      int offset = (d > 0) ? 0 : 3;
      if (e > 0) {
	X[offset + 0] += V[b].x;
	Y[offset + 0] += V[b].y;
      } else if (e == 0) {
	X[offset + 1] += V[b].x;
	Y[offset + 1] += V[b].y;
      } else {
	X[offset + 2] += V[b].x;
	Y[offset + 2] += V[b].y;
      }
    }

    for (int i = 0; i < (1 << 6); i++) {
      int64_t x = 0;
      int64_t y = 0;
      for (int j = 0; j < 6; j++) {
	if (i & (1 << j)) {
	  x += X[j];
	  y += Y[j];
	}
      }
      res = max(res, sqrt(x * x + y * y));
    }
  }

  printf("%.12lf\n", res);

  return 0;
}


Measured memory_bytes: 256
#pragma warning(disable:4996)
#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()

using ll = long long;
using ull = unsigned long long;
using vb = vector<bool>;
using vi = vector<int>;
using vll = vector<ll>;
using vs = vector<string>;
using vvb = vector<vb>;
using vvi = vector<vi>;
using vvll = vector<vll>;

template<typename A, typename T>void assign2d(A&arr, ll H, ll W, T t) { arr.resize(H); REP(i, H) arr[i].assign(W, t); }
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); REP(i, n)os << v[i] << (i == n - 1 ? "" : " "); return os; }
template <class T = int> inline T IN() { T x; cin >> x; return x; }
template<class T> inline void OUT(const T &x) { cout << x << "\n"; }
void YESNO(bool c) { OUT(c ? "YES" : "NO"); };
void YesNo(bool c) { OUT(c ? "Yes" : "No"); };
void yesno(bool c) { OUT(c ? "yes" : "no"); };
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); /*cout << fixed << setprecision(6);*/ } } pre__;

int main() {
	string S;
	cin >> S;
	int a, b;
	for (int i = 0; i < S.size(); ++i) {
		if (S[i] == 'A') {
			a = i;
			break;
		}
	}
	for (int i = S.size() - 1; i >= a; --i) {
		if (S[i] == 'Z') {
			b = i;
			break;
		}
	}
	OUT(b - a + 1);
	return 0;
}

Measured memory_bytes: 720
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
int main(){
	ll k;
	cin>>k;
	cin>>ws;
	string s;
	getline(cin,s);
	ll t=s.size();
	if(t<=k){cout<<s<<"\n";
	}
	else{char a[k+3];
	for(ll i=0;i<k;i++){cout<<s[i];
	}
	for(ll i=k;i<k+3;i++){
		cout<<".";
	}
	}
	
	
	return 0;
}


Measured memory_bytes: 3628